diff --git a/cmake/cmake.define b/cmake/cmake.define index a739a77d21..10f2172541 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -118,12 +118,18 @@ ELSE () IF (${BUILD_SANITIZER}) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0") - MESSAGE(STATUS "Will compile with Address Sanitizer!") + MESSAGE(STATUS "Compile with Address Sanitizer!") ELSE () SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k") ENDIF () + # disable all assert + IF ((${DISABLE_ASSERT} MATCHES "true") OR (${DISABLE_ASSERTS} MATCHES "true")) + ADD_DEFINITIONS(-DDISABLE_ASSERT) + MESSAGE(STATUS "Disable all asserts") + ENDIF() + INCLUDE(CheckCCompilerFlag) IF (TD_ARM_64 OR TD_ARM_32) SET(COMPILER_SUPPORT_SSE42 false) @@ -156,7 +162,7 @@ ELSE () SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2") ENDIF() - MESSAGE(STATUS "SIMD instructions (AVX/AVX2) is ACTIVATED") + MESSAGE(STATUS "SIMD instructions (FMA/AVX/AVX2) is ACTIVATED") ENDIF() ENDIF () diff --git a/cmake/cmake.version b/cmake/cmake.version index f43465bf1d..ba85a3d99b 100644 --- a/cmake/cmake.version +++ b/cmake/cmake.version @@ -2,7 +2,7 @@ IF (DEFINED VERNUMBER) SET(TD_VER_NUMBER ${VERNUMBER}) ELSE () - SET(TD_VER_NUMBER "3.0.2.1") + SET(TD_VER_NUMBER "3.0.2.2") ENDIF () IF (DEFINED VERCOMPATIBLE) diff --git a/include/client/taos.h b/include/client/taos.h index 647f906d4f..e54300e33e 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -161,6 +161,8 @@ DLL_EXPORT int taos_stmt_set_tags(TAOS_STMT *stmt, TAOS_MULTI_BIND *tags) DLL_EXPORT int taos_stmt_set_sub_tbname(TAOS_STMT *stmt, const char *name); DLL_EXPORT int taos_stmt_get_tag_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields); DLL_EXPORT int taos_stmt_get_col_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields); +// let stmt to reclaim TAOS_FIELD_E that was allocated by `taos_stmt_get_tag_fields`/`taos_stmt_get_col_fields` +DLL_EXPORT void taos_stmt_reclaim_fields(TAOS_STMT *stmt, TAOS_FIELD_E *fields); DLL_EXPORT int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert); DLL_EXPORT int taos_stmt_num_params(TAOS_STMT *stmt, int *nums); diff --git a/include/common/tmsgcb.h b/include/common/tmsgcb.h index 32d00bb422..a1ebd855cd 100644 --- a/include/common/tmsgcb.h +++ b/include/common/tmsgcb.h @@ -39,6 +39,7 @@ typedef enum { QUEUE_MAX, } EQueueType; +typedef int32_t (*UpdateDnodeInfoFp)(void* pData, int32_t* dnodeId, int64_t* clusterId, char* fqdn, uint16_t* port); typedef int32_t (*PutToQueueFp)(void* pMgmt, EQueueType qtype, SRpcMsg* pMsg); typedef int32_t (*GetQueueSizeFp)(void* pMgmt, int32_t vgId, EQueueType qtype); typedef int32_t (*SendReqFp)(const SEpSet* pEpSet, SRpcMsg* pMsg); @@ -48,6 +49,7 @@ typedef void (*ReleaseHandleFp)(SRpcHandleInfo* pHandle, int8_t type); typedef void (*ReportStartup)(const char* name, const char* desc); typedef struct { + void* data; void* mgmt; void* clientRpc; PutToQueueFp putToQueueFp; @@ -57,6 +59,7 @@ typedef struct { RegisterBrokenLinkArgFp registerBrokenLinkArgFp; ReleaseHandleFp releaseHandleFp; ReportStartup reportStartupFp; + UpdateDnodeInfoFp updateDnodeInfoFp; } SMsgCb; void tmsgSetDefault(const SMsgCb* msgcb); @@ -67,6 +70,7 @@ void tmsgSendRsp(SRpcMsg* pMsg); void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg); void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type); void tmsgReportStartup(const char* name, const char* desc); +int32_t tmsgUpdateDnodeInfo(int32_t* dnodeId, int64_t* clusterId, char* fqdn, uint16_t* port); #ifdef __cplusplus } diff --git a/include/common/trow.h b/include/common/trow.h index 6a71a8844e..8332c10ed2 100644 --- a/include/common/trow.h +++ b/include/common/trow.h @@ -20,7 +20,6 @@ #include "talgo.h" #include "taosdef.h" #include "taoserror.h" -#include "tbuffer.h" #include "tdataformat.h" #include "tdef.h" #include "ttypes.h" diff --git a/include/libs/function/function.h b/include/libs/function/function.h index 32b8cc7389..32db6773e0 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -20,7 +20,6 @@ extern "C" { #endif -#include "tbuffer.h" #include "tcommon.h" #include "tvariant.h" @@ -138,7 +137,7 @@ typedef struct SqlFunctionCtx { char *pOutput; // final result output buffer, point to sdata->data int32_t numOfParams; // input parameter, e.g., top(k, 20), the number of results of top query is kept in param - SFunctParam *param; + SFunctParam *param; // corresponding output buffer for timestamp of each result, e.g., diff/csum SColumnInfoData *pTsOutput; int32_t offset; @@ -152,6 +151,7 @@ typedef struct SqlFunctionCtx { struct SSDataBlock *pSrcBlock; struct SSDataBlock *pDstBlock; // used by indefinite rows function to set selectivity SSerializeDataHandle saveHandle; + int32_t exprIdx; char udfName[TSDB_FUNC_NAME_LEN]; } SqlFunctionCtx; @@ -182,9 +182,9 @@ struct SScalarParam { int32_t numOfQualified; // number of qualified elements in the final results }; -void cleanupResultRowEntry(struct SResultRowEntryInfo *pCell); -bool isRowEntryCompleted(struct SResultRowEntryInfo *pEntry); -bool isRowEntryInitialized(struct SResultRowEntryInfo *pEntry); +void cleanupResultRowEntry(struct SResultRowEntryInfo *pCell); +bool isRowEntryCompleted(struct SResultRowEntryInfo *pEntry); +bool isRowEntryInitialized(struct SResultRowEntryInfo *pEntry); typedef struct SPoint { int64_t key; diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 6f700c75ed..3602225789 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -121,6 +121,7 @@ typedef struct SAggLogicNode { bool hasLast; bool hasTimeLineFunc; bool onlyHasKeepOrderFunc; + bool hasGroupKeyOptimized; } SAggLogicNode; typedef struct SProjectLogicNode { @@ -409,6 +410,7 @@ typedef struct SAggPhysiNode { SNodeList* pGroupKeys; SNodeList* pAggFuncs; bool mergeDataBlock; + bool groupKeyOptimized; } SAggPhysiNode; typedef struct SDownstreamSourceNode { diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index 559dc1009d..d37f8f76c2 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -78,6 +78,8 @@ typedef enum { } ESyncState; typedef struct SNodeInfo { + int64_t clusterId; + int32_t nodeId; uint16_t nodePort; char nodeFqdn[TSDB_FQDN_LEN]; } SNodeInfo; diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 1bfcae5681..9d594d1507 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -346,6 +346,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_TOPIC_SUBSCRIBED TAOS_DEF_ERROR_CODE(0, 0x03EB) #define TSDB_CODE_MND_CGROUP_USED TAOS_DEF_ERROR_CODE(0, 0x03EC) #define TSDB_CODE_MND_TOPIC_MUST_BE_DELETED TAOS_DEF_ERROR_CODE(0, 0x03ED) +#define TSDB_CODE_MND_INVALID_SUB_OPTION TAOS_DEF_ERROR_CODE(0, 0x03EE) #define TSDB_CODE_MND_IN_REBALANCE TAOS_DEF_ERROR_CODE(0, 0x03EF) // mnode-stream diff --git a/include/util/tbuffer.h b/include/util/tbuffer.h deleted file mode 100644 index 2ed1b7326b..0000000000 --- a/include/util/tbuffer.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2020 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_UTIL_BUFFER_H_ -#define _TD_UTIL_BUFFER_H_ - -#include "os.h" - -#ifdef __cplusplus -extern "C" { -#endif - -//////////////////////////////////////////////////////////////////////////////// -// usage example -/* -#include -#include "texception.h" - -int32_t main( int32_t argc, char** argv ) { - SBufferWriter bw = tbufInitWriter( NULL, false ); - - TRY( 1 ) { - //--------------------- write ------------------------ - // reserve 1024 bytes for the buffer to improve performance - tbufEnsureCapacity( &bw, 1024 ); - - // reserve space for the interger count - size_t pos = tbufReserve( &bw, sizeof(int32_t) ); - // write 5 integers to the buffer - for( int32_t i = 0; i < 5; i++) { - tbufWriteInt32( &bw, i ); - } - // write the integer count to buffer at reserved position - tbufWriteInt32At( &bw, pos, 5 ); - - // write a string to the buffer - tbufWriteString( &bw, "this is a string.\n" ); - // acquire the result and close the write buffer - size_t size = tbufTell( &bw ); - char* data = tbufGetData( &bw, false ); - - //------------------------ read ----------------------- - SBufferReader br = tbufInitReader( data, size, false ); - // read & print out all integers - int32_t count = tbufReadInt32( &br ); - for( int32_t i = 0; i < count; i++ ) { - printf( "%d\n", tbufReadInt32(&br) ); - } - // read & print out a string - puts( tbufReadString(&br, NULL) ); - // try read another integer, this result in an error as there no this integer - tbufReadInt32( &br ); - printf( "you should not see this message.\n" ); - } CATCH( code ) { - printf( "exception code is: %d, you will see this message after print out 5 integers and a string.\n", code ); - } END_TRY - - tbufCloseWriter( &bw ); - return 0; -} -*/ - -typedef struct SBufferReader { - bool endian; - const char* data; - size_t pos; - size_t size; -} SBufferReader; - -typedef struct SBufferWriter { - bool endian; - char* data; - size_t pos; - size_t size; - void* (*allocator)(void*, size_t); -} SBufferWriter; - -// common functions & macros for both reader & writer - -#define tbufTell(buf) ((buf)->pos) - -/* ------------------------ BUFFER WRITER FUNCTIONS AND MACROS ------------------------ */ -// *Allocator*, function to allocate memory, will use 'realloc' if NULL -// *Endian*, if true, writer functions of primitive types will do 'hton' automatically -#define tbufInitWriter(Allocator, Endian) \ - { .endian = (Endian), .data = NULL, .pos = 0, .size = 0, .allocator = ((Allocator) == NULL ? realloc : (Allocator)) } - -void tbufCloseWriter(SBufferWriter* buf); -void tbufEnsureCapacity(SBufferWriter* buf, size_t size); -size_t tbufReserve(SBufferWriter* buf, size_t size); -char* tbufGetData(SBufferWriter* buf, bool takeOver); -void tbufWrite(SBufferWriter* buf, const void* data, size_t size); -void tbufWriteAt(SBufferWriter* buf, size_t pos, const void* data, size_t size); -void tbufWriteStringLen(SBufferWriter* buf, const char* str, size_t len); -void tbufWriteString(SBufferWriter* buf, const char* str); -// the prototype of tbufWriteBinary and tbufWrite are identical -// the difference is: tbufWriteBinary writes the length of the data to the buffer -// first, then the actual data, which means the reader don't need to know data -// size before read. Write only write the data itself, which means the reader -// need to know data size before read. -void tbufWriteBinary(SBufferWriter* buf, const void* data, size_t len); -void tbufWriteBool(SBufferWriter* buf, bool data); -void tbufWriteBoolAt(SBufferWriter* buf, size_t pos, bool data); -void tbufWriteChar(SBufferWriter* buf, char data); -void tbufWriteCharAt(SBufferWriter* buf, size_t pos, char data); -void tbufWriteInt8(SBufferWriter* buf, int8_t data); -void tbufWriteInt8At(SBufferWriter* buf, size_t pos, int8_t data); -void tbufWriteUint8(SBufferWriter* buf, uint8_t data); -void tbufWriteUint8At(SBufferWriter* buf, size_t pos, uint8_t data); -void tbufWriteInt16(SBufferWriter* buf, int16_t data); -void tbufWriteInt16At(SBufferWriter* buf, size_t pos, int16_t data); -void tbufWriteUint16(SBufferWriter* buf, uint16_t data); -void tbufWriteUint16At(SBufferWriter* buf, size_t pos, uint16_t data); -void tbufWriteInt32(SBufferWriter* buf, int32_t data); -void tbufWriteInt32At(SBufferWriter* buf, size_t pos, int32_t data); -void tbufWriteUint32(SBufferWriter* buf, uint32_t data); -void tbufWriteUint32At(SBufferWriter* buf, size_t pos, uint32_t data); -void tbufWriteInt64(SBufferWriter* buf, int64_t data); -void tbufWriteInt64At(SBufferWriter* buf, size_t pos, int64_t data); -void tbufWriteUint64(SBufferWriter* buf, uint64_t data); -void tbufWriteUint64At(SBufferWriter* buf, size_t pos, uint64_t data); -void tbufWriteFloat(SBufferWriter* buf, float data); -void tbufWriteFloatAt(SBufferWriter* buf, size_t pos, float data); -void tbufWriteDouble(SBufferWriter* buf, double data); -void tbufWriteDoubleAt(SBufferWriter* buf, size_t pos, double data); - -/* ------------------------ BUFFER READER FUNCTIONS AND MACROS ------------------------ */ -// *Endian*, if true, reader functions of primitive types will do 'ntoh' automatically -#define tbufInitReader(Data, Size, Endian) \ - { .endian = (Endian), .data = (Data), .pos = 0, .size = ((Data) == NULL ? 0 : (Size)) } - -size_t tbufSkip(SBufferReader* buf, size_t size); -const char* tbufRead(SBufferReader* buf, size_t size); -void tbufReadToBuffer(SBufferReader* buf, void* dst, size_t size); -const char* tbufReadString(SBufferReader* buf, size_t* len); -size_t tbufReadToString(SBufferReader* buf, char* dst, size_t size); -const char* tbufReadBinary(SBufferReader* buf, size_t* len); -size_t tbufReadToBinary(SBufferReader* buf, void* dst, size_t size); -bool tbufReadBool(SBufferReader* buf); -char tbufReadChar(SBufferReader* buf); -int8_t tbufReadInt8(SBufferReader* buf); -uint8_t tbufReadUint8(SBufferReader* buf); -int16_t tbufReadInt16(SBufferReader* buf); -uint16_t tbufReadUint16(SBufferReader* buf); -int32_t tbufReadInt32(SBufferReader* buf); -uint32_t tbufReadUint32(SBufferReader* buf); -int64_t tbufReadInt64(SBufferReader* buf); -uint64_t tbufReadUint64(SBufferReader* buf); -float tbufReadFloat(SBufferReader* buf); -double tbufReadDouble(SBufferReader* buf); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_UTIL_BUFFER_H_*/ diff --git a/include/util/tcompare.h b/include/util/tcompare.h index c7a3ca20f2..f92e1c3970 100644 --- a/include/util/tcompare.h +++ b/include/util/tcompare.h @@ -36,17 +36,18 @@ extern "C" { #define FLT_GREATEREQUAL(_x, _y) (FLT_EQUAL((_x), (_y)) || ((_x) > (_y))) #define FLT_LESSEQUAL(_x, _y) (FLT_EQUAL((_x), (_y)) || ((_x) < (_y))) -#define PATTERN_COMPARE_INFO_INITIALIZER \ - { '%', '_' } +#define PATTERN_COMPARE_INFO_INITIALIZER { '%', '_', L'%', L'_' } typedef struct SPatternCompareInfo { - char matchAll; // symbol for match all wildcard, default: '%' - char matchOne; // symbol for match one wildcard, default: '_' + char matchAll; // symbol for match all wildcard, default: '%' + char matchOne; // symbol for match one wildcard, default: '_' + TdUcs4 umatchAll; // unicode version matchAll + TdUcs4 umatchOne; // unicode version matchOne } SPatternCompareInfo; -int32_t patternMatch(const char *pattern, const char *str, size_t size, const SPatternCompareInfo *pInfo); +int32_t patternMatch(const char *pattern, size_t psize, const char *str, size_t ssize, const SPatternCompareInfo *pInfo); -int32_t WCSPatternMatch(const TdUcs4 *pattern, const TdUcs4 *str, size_t size, const SPatternCompareInfo *pInfo); +int32_t wcsPatternMatch(const TdUcs4 *pattern, size_t psize, const TdUcs4 *str, size_t ssize, const SPatternCompareInfo *pInfo); int32_t taosArrayCompareString(const void *a, const void *b); @@ -79,9 +80,11 @@ int32_t compareDoubleVal(const void *pLeft, const void *pRight); int32_t compareLenPrefixedStr(const void *pLeft, const void *pRight); int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight); -int32_t compareStrRegexComp(const void *pLeft, const void *pRight); -int32_t compareStrRegexCompMatch(const void *pLeft, const void *pRight); -int32_t compareStrRegexCompNMatch(const void *pLeft, const void *pRight); +int32_t comparestrRegexMatch(const void *pLeft, const void *pRight); +int32_t comparestrRegexNMatch(const void *pLeft, const void *pRight); + +int32_t comparewcsRegexMatch(const void *pLeft, const void *pRight); +int32_t comparewcsRegexNMatch(const void *pLeft, const void *pRight); int32_t compareInt8ValDesc(const void *pLeft, const void *pRight); int32_t compareInt16ValDesc(const void *pLeft, const void *pRight); @@ -99,11 +102,11 @@ int32_t compareUint64ValDesc(const void *pLeft, const void *pRight); int32_t compareLenPrefixedStrDesc(const void *pLeft, const void *pRight); int32_t compareLenPrefixedWStrDesc(const void *pLeft, const void *pRight); -int32_t compareStrPatternMatch(const void *pLeft, const void *pRight); -int32_t compareStrPatternNotMatch(const void *pLeft, const void *pRight); +int32_t comparestrPatternMatch(const void *pLeft, const void *pRight); +int32_t comparestrPatternNMatch(const void *pLeft, const void *pRight); -int32_t compareWStrPatternMatch(const void *pLeft, const void *pRight); -int32_t compareWStrPatternNotMatch(const void *pLeft, const void *pRight); +int32_t comparewcsPatternMatch(const void *pLeft, const void *pRight); +int32_t comparewcsPatternNMatch(const void *pLeft, const void *pRight); int32_t compareInt8Int16(const void *pLeft, const void *pRight); int32_t compareInt8Int32(const void *pLeft, const void *pRight); diff --git a/include/util/tdef.h b/include/util/tdef.h index 4cf4f73b9b..f2e2ab4284 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -194,6 +194,7 @@ typedef enum ELogicConditionType { #define TSDB_TOPIC_NAME_LEN 193 // it is a null-terminated string #define TSDB_CGROUP_LEN 193 // it is a null-terminated string #define TSDB_USER_CGROUP_LEN (TSDB_USER_LEN + TSDB_CGROUP_LEN) // it is a null-terminated string +#define TSDB_STREAM_NAME_LEN 193 // it is a null-terminated string #define TSDB_DB_NAME_LEN 65 #define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN) @@ -213,8 +214,8 @@ typedef enum ELogicConditionType { #define TSDB_INDEX_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_INDEX_NAME_LEN + TSDB_NAME_DELIMITER_LEN) #define TSDB_TYPE_STR_MAX_LEN 32 #define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN) -#define TSDB_TOPIC_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN) -#define TSDB_STREAM_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN) +#define TSDB_TOPIC_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_TOPIC_NAME_LEN + TSDB_NAME_DELIMITER_LEN) +#define TSDB_STREAM_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_STREAM_NAME_LEN + TSDB_NAME_DELIMITER_LEN) #define TSDB_SUBSCRIBE_KEY_LEN (TSDB_CGROUP_LEN + TSDB_TOPIC_FNAME_LEN + 2) #define TSDB_PARTITION_KEY_LEN (TSDB_SUBSCRIBE_KEY_LEN + 20) #define TSDB_COL_NAME_LEN 65 @@ -311,7 +312,7 @@ typedef enum ELogicConditionType { #define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute #define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved. #define TSDB_MAX_KEEP_NS (365 * 292 * 1440) // data in db to be reserved. -#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years +#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years #define TSDB_MIN_MINROWS_FBLOCK 10 #define TSDB_MAX_MINROWS_FBLOCK 1000 #define TSDB_DEFAULT_MINROWS_FBLOCK 100 diff --git a/include/util/tjson.h b/include/util/tjson.h index df433227ca..6922930c13 100644 --- a/include/util/tjson.h +++ b/include/util/tjson.h @@ -30,6 +30,27 @@ extern "C" { val = _tmp; \ } while (0) +#define tjsonGetInt32ValueFromDouble(pJson, pName, val, code) \ + do { \ + double _tmp = 0; \ + code = tjsonGetDoubleValue(pJson, pName, &_tmp); \ + val = (int32_t)_tmp; \ + } while (0) + +#define tjsonGetInt8ValueFromDouble(pJson, pName, val, code) \ + do { \ + double _tmp = 0; \ + code = tjsonGetDoubleValue(pJson, pName, &_tmp); \ + val = (int8_t)_tmp; \ + } while (0) + +#define tjsonGetUInt16ValueFromDouble(pJson, pName, val, code) \ + do { \ + double _tmp = 0; \ + code = tjsonGetDoubleValue(pJson, pName, &_tmp); \ + val = (uint16_t)_tmp; \ + } while (0) + typedef void SJson; SJson* tjsonCreateObject(); diff --git a/include/util/tlog.h b/include/util/tlog.h index e6ef7f388f..6e9b304e1d 100644 --- a/include/util/tlog.h +++ b/include/util/tlog.h @@ -83,9 +83,21 @@ void taosPrintLongString(const char *flags, ELogLevel level, int32_t dflag, cons #endif ; -bool taosAssert(bool condition, const char *file, int32_t line, const char *format, ...); -#define ASSERTS(condition, ...) taosAssert(condition, __FILE__, __LINE__, __VA_ARGS__) -#define ASSERT(condition) ASSERTS(condition, "assert info not provided") +bool taosAssertDebug(bool condition, const char *file, int32_t line, const char *format, ...); +bool taosAssertRelease(bool condition); + +// Disable all asserts that may compromise the performance. +#if defined DISABLE_ASSERT +#define ASSERT(condition) +#define ASSERTS(condition, ...) +#else +#define ASSERTS(condition, ...) taosAssertDebug(condition, __FILE__, __LINE__, __VA_ARGS__) +#ifdef NDEBUG +#define ASSERT(condition) taosAssertRelease(condition) +#else +#define ASSERT(condition) taosAssertDebug(condition, __FILE__, __LINE__, "assert info not provided") +#endif +#endif // clang-format off #define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", DEBUG_FATAL, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }} diff --git a/include/util/tutil.h b/include/util/tutil.h index de96300155..9fb68aebdc 100644 --- a/include/util/tutil.h +++ b/include/util/tutil.h @@ -29,11 +29,17 @@ extern "C" { int32_t strdequote(char *src); size_t strtrim(char *src); char *strnchr(const char *haystack, char needle, int32_t len, bool skipquote); +TdUcs4* wcsnchr(const TdUcs4* haystack, TdUcs4 needle, size_t len); + char **strsplit(char *src, const char *delim, int32_t *num); char *strtolower(char *dst, const char *src); char *strntolower(char *dst, const char *src, int32_t n); char *strntolower_s(char *dst, const char *src, int32_t n); int64_t strnatoi(char *num, int32_t len); + +size_t tstrncspn(const char *str, size_t ssize, const char *reject, size_t rsize); +size_t twcsncspn(const TdUcs4 *wcs, size_t size, const TdUcs4 *reject, size_t rsize); + char *strbetween(char *string, char *begin, char *end); char *paGetToken(char *src, char **token, int32_t *tokenLen); diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 896d1d6ca6..36126d6468 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -1330,6 +1330,14 @@ int taos_stmt_get_col_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fiel return stmtGetColFields(stmt, fieldNum, fields); } +// let stmt to reclaim TAOS_FIELD_E that was allocated by `taos_stmt_get_tag_fields`/`taos_stmt_get_col_fields` +void taos_stmt_reclaim_fields(TAOS_STMT *stmt, TAOS_FIELD_E *fields) +{ + (void)stmt; + if (!fields) return; + taosMemoryFree(fields); +} + int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) { if (stmt == NULL || bind == NULL) { tscError("NULL parameter for %s", __FUNCTION__); diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index 8905dc2132..a3754d0695 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -909,10 +909,12 @@ void tmqFreeImpl(void* handle) { tmq_t* tmq = (tmq_t*)handle; // TODO stop timer - tmqClearUnhandleMsg(tmq); - if (tmq->mqueue) taosCloseQueue(tmq->mqueue); + if (tmq->mqueue) { + tmqClearUnhandleMsg(tmq); + taosCloseQueue(tmq->mqueue); + } if (tmq->delayedTask) taosCloseQueue(tmq->delayedTask); - if (tmq->qall) taosFreeQall(tmq->qall); + taosFreeQall(tmq->qall); tsem_destroy(&tmq->rspSem); diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 98b9b566ec..deefa65595 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -715,6 +715,8 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsNumOfSnodeWriteThreads = cfgGetItem(pCfg, "numOfSnodeUniqueThreads")->i32; tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64; + tsSIMDBuiltins = (bool) cfgGetItem(pCfg, "SIMD-builtins")->bval; + tsEnableMonitor = cfgGetItem(pCfg, "monitor")->bval; tsMonitorInterval = cfgGetItem(pCfg, "monitorInterval")->i32; tstrncpy(tsMonitorFqdn, cfgGetItem(pCfg, "monitorFqdn")->str, TSDB_FQDN_LEN); diff --git a/source/common/src/ttypes.c b/source/common/src/ttypes.c index 7b5d0a8805..d412fd89da 100644 --- a/source/common/src/ttypes.c +++ b/source/common/src/ttypes.c @@ -131,7 +131,10 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) { varDataCopy(val, src); break; default: { - memcpy(val, src, len); + if (len > 0) { + memcpy(val, src, len); + } + break; } } diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index a432201413..d308d3e618 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -178,7 +178,7 @@ static int32_t dmInitLog() { } static void taosCleanupArgs() { - if (global.envCmd != NULL) taosMemoryFree(global.envCmd); + if (global.envCmd != NULL) taosMemoryFreeClear(global.envCmd); } int main(int argc, char const *argv[]) { @@ -271,7 +271,6 @@ int mainWindows(int argc, char **argv) { taosCleanupCfg(); taosCloseLog(); - taosCleanupArgs(); taosConvDestroy(); return -1; } diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmFile.c b/source/dnode/mgmt/mgmt_mnode/src/mmFile.c index c5ddb9f021..f736ffd0c8 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmFile.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmFile.c @@ -180,6 +180,6 @@ int32_t mmWriteFile(const char *path, const SMnodeOpt *pOption) { return -1; } - dDebug("successed to write %s, deployed:%d", realfile, pOption->deploy); + dDebug("succeed to write %s, deployed:%d", realfile, pOption->deploy); return 0; } diff --git a/source/dnode/mgmt/mgmt_snode/src/smWorker.c b/source/dnode/mgmt/mgmt_snode/src/smWorker.c index 9bd5be5201..e8402eb7c0 100644 --- a/source/dnode/mgmt/mgmt_snode/src/smWorker.c +++ b/source/dnode/mgmt/mgmt_snode/src/smWorker.c @@ -58,11 +58,7 @@ static void smProcessStreamQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { dTrace("msg:%p, get from snode-stream queue", pMsg); int32_t code = sndProcessStreamMsg(pMgmt->pSnode, pMsg); if (code < 0) { - if (pMsg) { - dGError("snd, msg:%p failed to process stream msg %s since %s", pMsg, TMSG_INFO(pMsg->msgType), terrstr(code)); - } else { - dGError("snd, msg:%p failed to process stream empty msg since %s", pMsg, terrstr(code)); - } + dGError("snd, msg:%p failed to process stream msg %s since %s", pMsg, TMSG_INFO(pMsg->msgType), terrstr(code)); smSendRsp(pMsg, terrno); } @@ -161,8 +157,10 @@ int32_t smPutMsgToQueue(SSnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { smPutNodeMsgToWriteQueue(pMgmt, pMsg); break; default: - ASSERTS(0, "msg:%p failed to put into snode queue since %s, type:%s qtype:%d", pMsg, terrstr(), - TMSG_INFO(pMsg->msgType), qtype); + terrno = TSDB_CODE_INVALID_PARA; + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); + return -1; } return 0; } diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmFile.c b/source/dnode/mgmt/mgmt_vnode/src/vmFile.c index a49e855e39..dc32054fd7 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmFile.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmFile.c @@ -16,7 +16,7 @@ #define _DEFAULT_SOURCE #include "vmInt.h" -#define MAX_CONTENT_LEN 1024 * 1024 +#define MAX_CONTENT_LEN 2 * 1024 * 1024 SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) { taosThreadRwlockRdlock(&pMgmt->lock); @@ -60,7 +60,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t pFile = taosOpenFile(file, TD_FILE_READ); if (pFile == NULL) { - dDebug("file %s not exist", file); + dInfo("file %s not exist", file); code = 0; goto _OVER; } @@ -133,7 +133,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes = vnodesNum; code = 0; - dDebug("succcessed to read file %s, numOfVnodes:%d", file, vnodesNum); + dInfo("succcessed to read file %s, numOfVnodes:%d", file, vnodesNum); _OVER: if (content != NULL) taosMemoryFree(content); @@ -163,6 +163,7 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) { if (ppVnodes == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; code = -1; + dError("failed to write %s while get vnodelist", file); goto _OVER; } @@ -172,6 +173,7 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) { if (content == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; code = -1; + dError("failed to write %s while malloc content", file); goto _OVER; } @@ -213,6 +215,12 @@ _OVER: if (code != 0) return -1; - dDebug("successed to write %s, numOfVnodes:%d", realfile, numOfVnodes); - return taosRenameFile(file, realfile); + dInfo("succeed to write %s, numOfVnodes:%d", realfile, numOfVnodes); + code = taosRenameFile(file, realfile); + + if (code != 0) { + dError("failed to rename %s to %s", file, realfile); + } + + return code; } \ No newline at end of file diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index bc46772858..3ce37a5f8e 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -132,10 +132,12 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { pCfg->syncCfg.myIndex = pCreate->selfIndex; pCfg->syncCfg.replicaNum = pCreate->replica; memset(&pCfg->syncCfg.nodeInfo, 0, sizeof(pCfg->syncCfg.nodeInfo)); - for (int i = 0; i < pCreate->replica; ++i) { + for (int32_t i = 0; i < pCreate->replica; ++i) { SNodeInfo *pNode = &pCfg->syncCfg.nodeInfo[i]; + pNode->nodeId = pCreate->replicas[i].id; pNode->nodePort = pCreate->replicas[i].port; - tstrncpy(pNode->nodeFqdn, pCreate->replicas[i].fqdn, sizeof(pNode->nodeFqdn)); + tstrncpy(pNode->nodeFqdn, pCreate->replicas[i].fqdn, TSDB_FQDN_LEN); + (void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); } } @@ -188,8 +190,8 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { req.walRollPeriod, req.walSegmentSize, req.hashMethod, req.hashBegin, req.hashEnd, req.hashPrefix, req.hashSuffix, req.replica, req.selfIndex, req.strict); for (int32_t i = 0; i < req.replica; ++i) { - dInfo("vgId:%d, replica:%d id:%d fqdn:%s port:%u", req.vgId, i, req.replicas[i].id, req.replicas[i].fqdn, - req.replicas[i].port); + dInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d", req.vgId, i, req.replicas[i].fqdn, req.replicas[i].port, + req.replicas[i].id); } SReplica *pReplica = &req.replicas[req.selfIndex]; @@ -213,7 +215,7 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { SVnodeObj *pVnode = vmAcquireVnode(pMgmt, req.vgId); if (pVnode != NULL) { - dDebug("vgId:%d, already exist", req.vgId); + dInfo("vgId:%d, already exist", req.vgId); tFreeSCreateVnodeReq(&req); vmReleaseVnode(pMgmt, pVnode); terrno = TSDB_CODE_VND_ALREADY_EXIST; @@ -286,7 +288,8 @@ int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { dInfo("vgId:%d, start to alter vnode, replica:%d selfIndex:%d strict:%d", alterReq.vgId, alterReq.replica, alterReq.selfIndex, alterReq.strict); for (int32_t i = 0; i < alterReq.replica; ++i) { - dInfo("vgId:%d, replica:%d ep:%s:%u", alterReq.vgId, i, alterReq.replicas[i].fqdn, alterReq.replicas[i].port); + SReplica *pReplica = &alterReq.replicas[i]; + dInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d", alterReq.vgId, i, pReplica->fqdn, pReplica->port, pReplica->port); } if (alterReq.replica <= 0 || alterReq.selfIndex < 0 || alterReq.selfIndex >= alterReq.replica) { @@ -358,7 +361,7 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { } int32_t vgId = dropReq.vgId; - dDebug("vgId:%d, start to drop vnode", vgId); + dInfo("vgId:%d, start to drop vnode", vgId); if (dropReq.dnodeId != pMgmt->pData->dnodeId) { terrno = TSDB_CODE_INVALID_MSG; @@ -368,7 +371,7 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { SVnodeObj *pVnode = vmAcquireVnode(pMgmt, vgId); if (pVnode == NULL) { - dDebug("vgId:%d, failed to drop since %s", vgId, terrstr()); + dInfo("vgId:%d, failed to drop since %s", vgId, terrstr()); terrno = TSDB_CODE_VND_NOT_EXIST; return -1; } @@ -383,6 +386,7 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { vmCloseVnode(pMgmt, pVnode); vmWriteVnodeListToFile(pMgmt); + dInfo("vgId:%d, is dropped", vgId); return 0; } diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index 313a88fc5c..f808c67ef6 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -138,7 +138,7 @@ static void *vmOpenVnodeInThread(void *param) { SVnodeMgmt *pMgmt = pThread->pMgmt; char path[TSDB_FILENAME_LEN]; - dDebug("thread:%d, start to open %d vnodes", pThread->threadIndex, pThread->vnodeNum); + dInfo("thread:%d, start to open %d vnodes", pThread->threadIndex, pThread->vnodeNum); setThreadName("open-vnodes"); for (int32_t v = 0; v < pThread->vnodeNum; ++v) { @@ -156,14 +156,14 @@ static void *vmOpenVnodeInThread(void *param) { pThread->failed++; } else { vmOpenVnode(pMgmt, pCfg, pImpl); - dDebug("vgId:%d, is opened by thread:%d", pCfg->vgId, pThread->threadIndex); + dInfo("vgId:%d, is opened by thread:%d", pCfg->vgId, pThread->threadIndex); pThread->opened++; atomic_add_fetch_32(&pMgmt->state.openVnodes, 1); } } - dDebug("thread:%d, numOfVnodes:%d, opened:%d failed:%d", pThread->threadIndex, pThread->vnodeNum, pThread->opened, - pThread->failed); + dInfo("thread:%d, numOfVnodes:%d, opened:%d failed:%d", pThread->threadIndex, pThread->vnodeNum, pThread->opened, + pThread->failed); return NULL; } @@ -496,7 +496,7 @@ static void *vmRestoreVnodeInThread(void *param) { dError("vgId:%d, failed to restore vnode by thread:%d", pVnode->vgId, pThread->threadIndex); pThread->failed++; } else { - dDebug("vgId:%d, is restored by thread:%d", pVnode->vgId, pThread->threadIndex); + dInfo("vgId:%d, is restored by thread:%d", pVnode->vgId, pThread->threadIndex); pThread->opened++; atomic_add_fetch_32(&pMgmt->state.openVnodes, 1); } diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index 202dc50ac6..642ca1ebc1 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c @@ -86,12 +86,8 @@ static void vmProcessStreamQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, pMsg, pInfo); if (code != 0) { if (terrno != 0) code = terrno; - if (pMsg) { - dGError("vgId:%d, msg:%p failed to process stream msg %s since %s", pVnode->vgId, pMsg, TMSG_INFO(pMsg->msgType), - terrstr(code)); - } else { - dGError("vgId:%d, msg:%p failed to process stream empty msg since %s", pVnode->vgId, pMsg, terrstr(code)); - } + dGError("vgId:%d, msg:%p failed to process stream msg %s since %s", pVnode->vgId, pMsg, TMSG_INFO(pMsg->msgType), + terrstr(code)); vmSendRsp(pMsg, code); } @@ -146,16 +142,16 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp return -1; } - SMsgHead *pHead = pMsg->pCont; - int32_t code = 0; + SMsgHead *pHead = pMsg->pCont; + int32_t code = 0; pHead->contLen = ntohl(pHead->contLen); pHead->vgId = ntohl(pHead->vgId); SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pHead->vgId); if (pVnode == NULL) { - dGError("vgId:%d, msg:%p failed to put into vnode queue since %s, type:%s qtype:%d contLen:%d", pHead->vgId, pMsg, terrstr(), - TMSG_INFO(pMsg->msgType), qtype, pHead->contLen); + dGError("vgId:%d, msg:%p failed to put into vnode queue since %s, type:%s qtype:%d contLen:%d", pHead->vgId, pMsg, + terrstr(), TMSG_INFO(pMsg->msgType), qtype, pHead->contLen); return terrno != 0 ? terrno : -1; } diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index 0ff41d429e..dcb63f6524 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -345,6 +345,8 @@ SMsgCb dmGetMsgcb(SDnode *pDnode) { .registerBrokenLinkArgFp = dmRegisterBrokenLinkArg, .releaseHandleFp = dmReleaseHandle, .reportStartupFp = dmReportStartup, + .updateDnodeInfoFp = dmUpdateDnodeInfo, + .data = &pDnode->data, }; return msgCb; } diff --git a/source/dnode/mgmt/node_util/inc/dmUtil.h b/source/dnode/mgmt/node_util/inc/dmUtil.h index 2124b387ec..92b66230e3 100644 --- a/source/dnode/mgmt/node_util/inc/dmUtil.h +++ b/source/dnode/mgmt/node_util/inc/dmUtil.h @@ -167,6 +167,7 @@ void dmUpdateEps(SDnodeData *pData, SArray *pDnodeEps); void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet); void dmGetMnodeEpSetForRedirect(SDnodeData *pData, SRpcMsg *pMsg, SEpSet *pEpSet); void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet); +int32_t dmUpdateDnodeInfo(void *pData, int32_t *dnodeId, int64_t *clusterId, char *fqdn, uint16_t *port); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/node_util/src/dmEps.c b/source/dnode/mgmt/node_util/src/dmEps.c index 2ced9a350d..a7a63fbaca 100644 --- a/source/dnode/mgmt/node_util/src/dmEps.c +++ b/source/dnode/mgmt/node_util/src/dmEps.c @@ -182,22 +182,25 @@ _OVER: } int32_t dmWriteEps(SDnodeData *pData) { + int32_t code = -1; + char *content = NULL; + TdFilePtr pFile = NULL; + char file[PATH_MAX] = {0}; char realfile[PATH_MAX] = {0}; - snprintf(file, sizeof(file), "%s%sdnode%sdnode.json.bak", tsDataDir, TD_DIRSEP, TD_DIRSEP); snprintf(realfile, sizeof(realfile), "%s%sdnode%sdnode.json", tsDataDir, TD_DIRSEP, TD_DIRSEP); - TdFilePtr pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); + pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); if (pFile == NULL) { - dError("failed to write %s since %s", file, strerror(errno)); + dError("failed to open %s since %s", file, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); - return -1; + goto _OVER; } int32_t len = 0; int32_t maxLen = 256 * 1024; - char *content = taosMemoryCalloc(1, maxLen + 1); + content = taosMemoryCalloc(1, maxLen + 1); len += snprintf(content + len, maxLen - len, "{\n"); len += snprintf(content + len, maxLen - len, " \"dnodeId\": %d,\n", pData->dnodeId); @@ -221,20 +224,39 @@ int32_t dmWriteEps(SDnodeData *pData) { } len += snprintf(content + len, maxLen - len, "}\n"); - taosWriteFile(pFile, content, len); - taosFsyncFile(pFile); + if (taosWriteFile(pFile, content, len) != len) { + dError("failed to write %s since %s", file, strerror(errno)); + terrno = TAOS_SYSTEM_ERROR(errno); + goto _OVER; + } + + if (taosFsyncFile(pFile) < 0) { + dError("failed to fsync %s since %s", file, strerror(errno)); + terrno = TAOS_SYSTEM_ERROR(errno); + goto _OVER; + } + taosCloseFile(&pFile); - taosMemoryFree(content); + taosMemoryFreeClear(content); if (taosRenameFile(file, realfile) != 0) { terrno = TAOS_SYSTEM_ERROR(errno); dError("failed to rename %s since %s", file, terrstr()); - return -1; + goto _OVER; } + code = 0; pData->updateTime = taosGetTimestampMs(); - dDebug("successed to write %s, dnodeVer:%" PRId64, realfile, pData->dnodeVer); - return 0; + dInfo("succeed to write %s, dnodeVer:%" PRId64, realfile, pData->dnodeVer); + +_OVER: + if (content != NULL) taosMemoryFreeClear(content); + if (pFile != NULL) taosCloseFile(&pFile); + if (code != 0) { + dError("failed to write file %s since %s", realfile, terrstr()); + } + + return code; } void dmUpdateEps(SDnodeData *pData, SArray *eps) { @@ -332,3 +354,41 @@ void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) { dInfo("mnode index:%d %s:%u", i, pEpSet->eps[i].fqdn, pEpSet->eps[i].port); } } + +int32_t dmUpdateDnodeInfo(void *data, int32_t *dnodeId, int64_t *clusterId, char *fqdn, uint16_t *port) { + SDnodeData *pData = data; + int32_t ret = -1; + taosThreadRwlockRdlock(&pData->lock); + if (*dnodeId <= 0) { + for (int32_t i = 0; i < (int32_t)taosArrayGetSize(pData->dnodeEps); ++i) { + SDnodeEp *pDnodeEp = taosArrayGet(pData->dnodeEps, i); + if (strcmp(pDnodeEp->ep.fqdn, fqdn) == 0 && pDnodeEp->ep.port == *port) { + dInfo("dnode:%s:%u, update dnodeId from %d to %d", fqdn, *port, *dnodeId, pDnodeEp->id); + *dnodeId = pDnodeEp->id; + *clusterId = pData->clusterId; + ret = 0; + } + } + if (ret != 0) { + dInfo("dnode:%s:%u, failed to update dnodeId:%d", fqdn, *port, *dnodeId); + } + } else { + SDnodeEp *pDnodeEp = taosHashGet(pData->dnodeHash, dnodeId, sizeof(int32_t)); + if (pDnodeEp) { + if (strcmp(pDnodeEp->ep.fqdn, fqdn) != 0) { + dInfo("dnode:%d, update port from %s to %s", *dnodeId, fqdn, pDnodeEp->ep.fqdn); + tstrncpy(fqdn, pDnodeEp->ep.fqdn, TSDB_FQDN_LEN); + } + if (pDnodeEp->ep.port != *port) { + dInfo("dnode:%d, update port from %u to %u", *dnodeId, *port, pDnodeEp->ep.port); + *port = pDnodeEp->ep.port; + } + *clusterId = pData->clusterId; + ret = 0; + } else { + dInfo("dnode:%d, failed to update dnode info", *dnodeId); + } + } + taosThreadRwlockUnlock(&pData->lock); + return ret; +} \ No newline at end of file diff --git a/source/dnode/mgmt/node_util/src/dmFile.c b/source/dnode/mgmt/node_util/src/dmFile.c index d387fe4a3f..2eb1462efc 100644 --- a/source/dnode/mgmt/node_util/src/dmFile.c +++ b/source/dnode/mgmt/node_util/src/dmFile.c @@ -105,7 +105,7 @@ int32_t dmWriteFile(const char *path, const char *name, bool deployed) { return -1; } - dInfo("successed to write %s, deployed:%d", realfile, deployed); + dInfo("succeed to write %s, deployed:%d", realfile, deployed); code = 0; _OVER: diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 8a4f6c2195..87b5a5c42d 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -112,7 +112,6 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) { SDB_SET_INT8(pRaw, dataPos, pDb->cfg.hashMethod, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.numOfRetensions, _OVER) for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) { - ASSERT(taosArrayGetSize(pDb->cfg.pRetensions) == pDb->cfg.numOfRetensions); SRetention *pRetension = taosArrayGet(pDb->cfg.pRetensions, i); SDB_SET_INT64(pRaw, dataPos, pRetension->freq, _OVER) SDB_SET_INT64(pRaw, dataPos, pRetension->keep, _OVER) @@ -364,6 +363,7 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) { if (pCfg->hashPrefix < TSDB_MIN_HASH_PREFIX || pCfg->hashPrefix > TSDB_MAX_HASH_PREFIX) return -1; if (pCfg->hashSuffix < TSDB_MIN_HASH_SUFFIX || pCfg->hashSuffix > TSDB_MAX_HASH_SUFFIX) return -1; if (pCfg->tsdbPageSize < TSDB_MIN_TSDB_PAGESIZE || pCfg->tsdbPageSize > TSDB_MAX_TSDB_PAGESIZE) return -1; + if (taosArrayGetSize(pCfg->pRetensions) != pCfg->numOfRetensions) return -1; terrno = 0; return terrno; diff --git a/source/dnode/mnode/impl/src/mndDef.c b/source/dnode/mnode/impl/src/mndDef.c index b5c2fb05b3..a5f77513de 100644 --- a/source/dnode/mnode/impl/src/mndDef.c +++ b/source/dnode/mnode/impl/src/mndDef.c @@ -489,7 +489,7 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) { tlen += tEncodeSMqConsumerEp(buf, pConsumerEp); cnt++; } - ASSERT(cnt == sz); + if(cnt != sz) return -1; tlen += taosEncodeArray(buf, pSub->unassignedVgs, (FEncode)tEncodeSMqVgEp); tlen += taosEncodeString(buf, pSub->dbName); return tlen; diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index b9448797ea..c8c8e06c5e 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -21,6 +21,7 @@ #include "mndSync.h" #include "mndTrans.h" #include "tmisce.h" +#include "mndCluster.h" #define MNODE_VER_NUMBER 1 #define MNODE_RESERVE_SIZE 64 @@ -743,8 +744,12 @@ static void mndReloadSyncConfig(SMnode *pMnode) { if (objStatus == SDB_STATUS_READY || objStatus == SDB_STATUS_CREATING) { SNodeInfo *pNode = &cfg.nodeInfo[cfg.replicaNum]; - tstrncpy(pNode->nodeFqdn, pObj->pDnode->fqdn, sizeof(pNode->nodeFqdn)); + pNode->nodeId = pObj->pDnode->id; + pNode->clusterId = mndGetClusterId(pMnode); pNode->nodePort = pObj->pDnode->port; + tstrncpy(pNode->nodeFqdn, pObj->pDnode->fqdn, TSDB_FQDN_LEN); + (void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); + mInfo("vgId:1, ep:%s:%u dnode:%d", pNode->nodeFqdn, pNode->nodePort, pNode->nodeId); if (pObj->pDnode->id == pMnode->selfDnodeId) { cfg.myIndex = cfg.replicaNum; } @@ -758,7 +763,6 @@ static void mndReloadSyncConfig(SMnode *pMnode) { mInfo("vgId:1, mnode sync not reconfig since readyMnodes:%d updatingMnodes:%d", readyMnodes, updatingMnodes); return; } - // ASSERT(0); if (cfg.myIndex == -1) { #if 1 @@ -775,7 +779,8 @@ static void mndReloadSyncConfig(SMnode *pMnode) { mInfo("vgId:1, mnode sync reconfig, replica:%d myIndex:%d", cfg.replicaNum, cfg.myIndex); for (int32_t i = 0; i < cfg.replicaNum; ++i) { SNodeInfo *pNode = &cfg.nodeInfo[i]; - mInfo("vgId:1, index:%d, fqdn:%s port:%d", i, pNode->nodeFqdn, pNode->nodePort); + mInfo("vgId:1, index:%d, ep:%s:%u dnode:%d cluster:%" PRId64, i, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId, + pNode->clusterId); } int32_t code = syncReconfig(pMnode->syncMgmt.sync, &cfg); diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index 6a7e2aaa51..7a8de4099f 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -111,7 +111,7 @@ static int32_t convertToRetrieveType(char *name, int32_t len) { } else if (strncasecmp(name, TSDB_INS_TABLE_USER_PRIVILEGES, len) == 0) { type = TSDB_MGMT_TABLE_PRIVILEGES; } else { - // ASSERT(0); + mError("invalid show name:%s len:%d", name, len); } return type; diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index 2d1f6eb505..141bb1df60 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -488,7 +488,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea memcpy(smaObj.db, pDb->name, TSDB_DB_FNAME_LEN); smaObj.createdTime = taosGetTimestampMs(); smaObj.uid = mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN); - ASSERT(smaObj.uid != 0); + char resultTbName[TSDB_TABLE_FNAME_LEN + 16] = {0}; snprintf(resultTbName, TSDB_TABLE_FNAME_LEN + 16, "%s_td_tsma_rst_tb", pCreate->name); memcpy(smaObj.dstTbName, resultTbName, TSDB_TABLE_FNAME_LEN); @@ -558,13 +558,15 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea SNode *pAst = NULL; if (nodesStringToNode(streamObj.ast, &pAst) < 0) { - ASSERT(0); + terrno = TSDB_CODE_MND_INVALID_SMA_OPTION; + mError("sma:%s, failed to create since parse ast error", smaObj.name); return -1; } // extract output schema from ast if (qExtractResultSchema(pAst, (int32_t *)&streamObj.outputSchema.nCols, &streamObj.outputSchema.pSchema) != 0) { - ASSERT(0); + terrno = TSDB_CODE_MND_INVALID_SMA_OPTION; + mError("sma:%s, failed to create since extract result schema error", smaObj.name); return -1; } @@ -579,15 +581,18 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea }; if (qCreateQueryPlan(&cxt, &pPlan, NULL) < 0) { - ASSERT(0); + terrno = TSDB_CODE_MND_INVALID_SMA_OPTION; + mError("sma:%s, failed to create since create query plan error", smaObj.name); return -1; } // save physcial plan if (nodesNodeToString((SNode *)pPlan, false, &streamObj.physicalPlan, NULL) != 0) { - ASSERT(0); + terrno = TSDB_CODE_MND_INVALID_SMA_OPTION; + mError("sma:%s, failed to create since save physcial plan error", smaObj.name); return -1; } + if (pAst != NULL) nodesDestroyNode(pAst); nodesDestroyNode((SNode *)pPlan); @@ -826,14 +831,13 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) { mError("stream:%s, failed to drop task since %s", pStream->name, terrstr()); sdbRelease(pMnode->pSdb, pStream); - ASSERT(0); goto _OVER; } // drop stream if (mndPersistDropStreamLog(pMnode, pTrans, pStream) < 0) { + mError("stream:%s, failed to drop log since %s", pStream->name, terrstr()); sdbRelease(pMnode->pSdb, pStream); - ASSERT(0); goto _OVER; } } diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 54b3202d24..d504a94700 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -1177,7 +1177,9 @@ static int32_t mndCheckAlterColForTopic(SMnode *pMnode, const char *stbFullName, SNode *pAst = NULL; if (nodesStringToNode(pTopic->ast, &pAst) != 0) { - ASSERT(0); + terrno = TSDB_CODE_MND_FIELD_CONFLICT_WITH_TOPIC; + mError("topic:%s, create ast error", pTopic->name); + sdbRelease(pSdb, pTopic); return -1; } @@ -1222,7 +1224,9 @@ static int32_t mndCheckAlterColForStream(SMnode *pMnode, const char *stbFullName SNode *pAst = NULL; if (nodesStringToNode(pStream->ast, &pAst) != 0) { - ASSERT(0); + terrno = TSDB_CODE_MND_INVALID_STREAM_OPTION; + mError("stream:%s, create ast error", pStream->name); + sdbRelease(pSdb, pStream); return -1; } @@ -2094,7 +2098,9 @@ static int32_t mndCheckDropStbForTopic(SMnode *pMnode, const char *stbFullName, SNode *pAst = NULL; if (nodesStringToNode(pTopic->ast, &pAst) != 0) { - ASSERT(0); + terrno = TSDB_CODE_MND_INVALID_TOPIC_OPTION; + mError("topic:%s, create ast error", pTopic->name); + sdbRelease(pSdb, pTopic); return -1; } @@ -2141,7 +2147,9 @@ static int32_t mndCheckDropStbForStream(SMnode *pMnode, const char *stbFullName, SNode *pAst = NULL; if (nodesStringToNode(pStream->ast, &pAst) != 0) { - ASSERT(0); + terrno = TSDB_CODE_MND_INVALID_STREAM_OPTION; + mError("stream:%s, create ast error", pStream->name); + sdbRelease(pSdb, pStream); return -1; } diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index 418474baa6..b8ef185199 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -96,18 +96,12 @@ static SMqSubscribeObj *mndCreateSub(SMnode *pMnode, const SMqTopicObj *pTopic, pSub->subType = pTopic->subType; pSub->withMeta = pTopic->withMeta; - ASSERT(pSub->unassignedVgs->size == 0); - ASSERT(taosHashGetSize(pSub->consumerHash) == 0); - if (mndSchedInitSubEp(pMnode, pTopic, pSub) < 0) { tDeleteSubscribeObj(pSub); taosMemoryFree(pSub); return NULL; } - ASSERT(pSub->unassignedVgs->size > 0); - ASSERT(taosHashGetSize(pSub->consumerHash) == 0); - return pSub; } @@ -144,7 +138,10 @@ static int32_t mndBuildSubChangeReq(void **pBuf, int32_t *pLen, const SMqSubscri static int32_t mndPersistSubChangeVgReq(SMnode *pMnode, STrans *pTrans, const SMqSubscribeObj *pSub, const SMqRebOutputVg *pRebVg) { - ASSERT(pRebVg->oldConsumerId != pRebVg->newConsumerId); + if (pRebVg->oldConsumerId == pRebVg->newConsumerId) { + terrno = TSDB_CODE_MND_INVALID_SUB_OPTION; + return -1; + } void *buf; int32_t tlen; @@ -155,8 +152,8 @@ static int32_t mndPersistSubChangeVgReq(SMnode *pMnode, STrans *pTrans, const SM int32_t vgId = pRebVg->pVgEp->vgId; SVgObj *pVgObj = mndAcquireVgroup(pMnode, vgId); if (pVgObj == NULL) { - ASSERT(0); taosMemoryFree(buf); + terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } @@ -206,9 +203,9 @@ static SMqRebInfo *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) { } static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput) { - int32_t totalVgNum = pOutput->pSub->vgNum; - - mInfo("mq rebalance: subscription: %s, vgNum: %d", pOutput->pSub->key, pOutput->pSub->vgNum); + int32_t totalVgNum = pOutput->pSub->vgNum; + const char *sub = pOutput->pSub->key; + mInfo("sub:%s, mq rebalance vgNum:%d", sub, pOutput->pSub->vgNum); // 1. build temporary hash(vgId -> SMqRebOutputVg) to store modified vg SHashObj *pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); @@ -218,11 +215,10 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR int32_t actualRemoved = 0; for (int32_t i = 0; i < removedNum; i++) { int64_t consumerId = *(int64_t *)taosArrayGet(pInput->pRebInfo->removedConsumers, i); - ASSERT(consumerId > 0); + SMqConsumerEp *pConsumerEp = taosHashGet(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t)); - ASSERT(pConsumerEp); + if (pConsumerEp) { - ASSERT(consumerId == pConsumerEp->consumerId); actualRemoved++; int32_t consumerVgNum = taosArrayGetSize(pConsumerEp->vgs); for (int32_t j = 0; j < consumerVgNum; j++) { @@ -233,7 +229,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR .pVgEp = pVgEp, }; taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("mq rebalance: remove vgId:%d from consumer:%" PRId64, pVgEp->vgId, consumerId); + mInfo("sub:%s, mq rebalance remove vgId:%d from consumer:%" PRId64, sub, pVgEp->vgId, consumerId); } taosArrayDestroy(pConsumerEp->vgs); taosHashRemove(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t)); @@ -241,7 +237,10 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR taosArrayPush(pOutput->removedConsumers, &consumerId); } } - ASSERT(removedNum == actualRemoved); + + if (removedNum != actualRemoved) { + mError("sub:%s, mq rebalance removedNum:%d not matched with actual:%d", sub, removedNum, actualRemoved); + } // if previously no consumer, there are vgs not assigned { @@ -254,7 +253,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR .pVgEp = pVgEp, }; taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &rebOutput, sizeof(SMqRebOutputVg)); - mInfo("mq rebalance: remove vgId:%d from unassigned", pVgEp->vgId); + mInfo("sub:%s, mq rebalance remove vgId:%d from unassigned", sub, pVgEp->vgId); } } @@ -268,8 +267,8 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR minVgCnt = totalVgNum / afterRebConsumerNum; imbConsumerNum = totalVgNum % afterRebConsumerNum; } - mInfo("mq rebalance: %d consumer after rebalance, at least %d vg each, %d consumer has more vg", afterRebConsumerNum, - minVgCnt, imbConsumerNum); + mInfo("sub:%s, mq rebalance %d consumer after rebalance, at least %d vg each, %d consumer has more vg", sub, + afterRebConsumerNum, minVgCnt, imbConsumerNum); // 4. first scan: remove consumer more than wanted, put to remove hash int32_t imbCnt = 0; @@ -278,7 +277,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); if (pIter == NULL) break; SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; - ASSERT(pConsumerEp->consumerId > 0); + int32_t consumerVgNum = taosArrayGetSize(pConsumerEp->vgs); // all old consumers still existing are touched // TODO optimize: touch only consumer whose vgs changed @@ -298,7 +297,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR .pVgEp = pVgEp, }; taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("mq rebalance: remove vgId:%d from consumer:%" PRId64 ",(first scan)", pVgEp->vgId, + mInfo("sub:%s, mq rebalance remove vgId:%d from consumer:%" PRId64 ",(first scan)", sub, pVgEp->vgId, pConsumerEp->consumerId); } imbCnt++; @@ -313,7 +312,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR .pVgEp = pVgEp, }; taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("mq rebalance: remove vgId:%d from consumer:%" PRId64 ",(first scan)", pVgEp->vgId, + mInfo("sub:%s, mq rebalance remove vgId:%d from consumer:%" PRId64 ",(first scan)", sub, pVgEp->vgId, pConsumerEp->consumerId); } } @@ -325,13 +324,13 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR int32_t consumerNum = taosArrayGetSize(pInput->pRebInfo->newConsumers); for (int32_t i = 0; i < consumerNum; i++) { int64_t consumerId = *(int64_t *)taosArrayGet(pInput->pRebInfo->newConsumers, i); - ASSERT(consumerId > 0); + SMqConsumerEp newConsumerEp; newConsumerEp.consumerId = consumerId; newConsumerEp.vgs = taosArrayInit(0, sizeof(void *)); taosHashPut(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t), &newConsumerEp, sizeof(SMqConsumerEp)); taosArrayPush(pOutput->newConsumers, &consumerId); - mInfo("mq rebalance: add new consumer:%" PRId64, consumerId); + mInfo("sub:%s, mq rebalance add new consumer:%" PRId64, sub, consumerId); } } @@ -344,13 +343,16 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); if (pIter == NULL) break; SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; - ASSERT(pConsumerEp->consumerId > 0); // push until equal minVg while (taosArrayGetSize(pConsumerEp->vgs) < minVgCnt) { // iter hash and find one vg pRemovedIter = taosHashIterate(pHash, pRemovedIter); - ASSERT(pRemovedIter); + if (pRemovedIter == NULL) { + mError("sub:%s, removed iter is null", sub); + continue; + } + pRebVg = (SMqRebOutputVg *)pRemovedIter; // push taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp); @@ -361,7 +363,6 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR } } - ASSERT(pIter == NULL); // 7. handle unassigned vg if (taosHashGetSize(pOutput->pSub->consumerHash) != 0) { // if has consumer, assign all left vg @@ -377,9 +378,8 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR } while (1) { pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); - ASSERT(pIter); pConsumerEp = (SMqConsumerEp *)pIter; - ASSERT(pConsumerEp->consumerId > 0); + if (taosArrayGetSize(pConsumerEp->vgs) == minVgCnt) { break; } @@ -404,19 +404,19 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR pIter = taosHashIterate(pHash, pIter); if (pIter == NULL) break; pRebOutput = (SMqRebOutputVg *)pIter; - ASSERT(pRebOutput->newConsumerId == -1); + taosArrayPush(pOutput->pSub->unassignedVgs, &pRebOutput->pVgEp); taosArrayPush(pOutput->rebVgs, pRebOutput); - mInfo("mq rebalance: unassign vgId:%d (second scan)", pRebOutput->pVgEp->vgId); + mInfo("sub:%s, mq rebalance unassign vgId:%d (second scan)", sub, pRebOutput->pVgEp->vgId); } } // 8. generate logs - mInfo("mq rebalance: calculation completed, rebalanced vg:"); + mInfo("sub:%s, mq rebalance calculation completed, rebalanced vg", sub); for (int32_t i = 0; i < taosArrayGetSize(pOutput->rebVgs); i++) { SMqRebOutputVg *pOutputRebVg = taosArrayGet(pOutput->rebVgs, i); - mInfo("mq rebalance: vgId:%d, moved from consumer:%" PRId64 ", to consumer:%" PRId64, pOutputRebVg->pVgEp->vgId, - pOutputRebVg->oldConsumerId, pOutputRebVg->newConsumerId); + mInfo("sub:%s, mq rebalance vgId:%d, moved from consumer:%" PRId64 ", to consumer:%" PRId64, sub, + pOutputRebVg->pVgEp->vgId, pOutputRebVg->oldConsumerId, pOutputRebVg->newConsumerId); } { void *pIter = NULL; @@ -425,10 +425,11 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR if (pIter == NULL) break; SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; int32_t sz = taosArrayGetSize(pConsumerEp->vgs); - mInfo("mq rebalance: final cfg: consumer %" PRId64 " has %d vg", pConsumerEp->consumerId, sz); + mInfo("sub:%s, mq rebalance final cfg: consumer %" PRId64 " has %d vg", sub, pConsumerEp->consumerId, sz); for (int32_t i = 0; i < sz; i++) { SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, i); - mInfo("mq rebalance: final cfg: vg %d to consumer %" PRId64 "", pVgEp->vgId, pConsumerEp->consumerId); + mInfo("sub:%s, mq rebalance final cfg: vg %d to consumer %" PRId64 "", sub, pVgEp->vgId, + pConsumerEp->consumerId); } } } @@ -487,7 +488,7 @@ static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOu consumerNum = taosArrayGetSize(pOutput->newConsumers); for (int32_t i = 0; i < consumerNum; i++) { int64_t consumerId = *(int64_t *)taosArrayGet(pOutput->newConsumers, i); - ASSERT(consumerId > 0); + SMqConsumerObj *pConsumerOld = mndAcquireConsumer(pMnode, consumerId); SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(pConsumerOld->consumerId, pConsumerOld->cgroup); pConsumerNew->updateType = CONSUMER_UPDATE__ADD; @@ -497,7 +498,6 @@ static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOu taosArrayPush(pConsumerNew->rebNewTopics, &topic); mndReleaseConsumer(pMnode, pConsumerOld); if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) { - ASSERT(0); tDeleteSMqConsumerObj(pConsumerNew); taosMemoryFree(pConsumerNew); goto REB_FAIL; @@ -510,7 +510,7 @@ static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOu consumerNum = taosArrayGetSize(pOutput->removedConsumers); for (int32_t i = 0; i < consumerNum; i++) { int64_t consumerId = *(int64_t *)taosArrayGet(pOutput->removedConsumers, i); - ASSERT(consumerId > 0); + SMqConsumerObj *pConsumerOld = mndAcquireConsumer(pMnode, consumerId); SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(pConsumerOld->consumerId, pConsumerOld->cgroup); pConsumerNew->updateType = CONSUMER_UPDATE__REMOVE; @@ -520,7 +520,6 @@ static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOu taosArrayPush(pConsumerNew->rebRemovedTopics, &topic); mndReleaseConsumer(pMnode, pConsumerOld); if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) { - ASSERT(0); tDeleteSMqConsumerObj(pConsumerNew); taosMemoryFree(pConsumerNew); goto REB_FAIL; @@ -577,7 +576,6 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { char cgroup[TSDB_CGROUP_LEN]; mndSplitSubscribeKey(pRebInfo->key, topic, cgroup, true); SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); - /*ASSERT(pTopic);*/ if (pTopic == NULL) { mError("mq rebalance %s failed since topic %s not exist, abort", pRebInfo->key, topic); continue; @@ -585,8 +583,14 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { taosRLockLatch(&pTopic->lock); rebOutput.pSub = mndCreateSub(pMnode, pTopic, pRebInfo->key); + + if (rebOutput.pSub == NULL) { + mError("mq rebalance %s failed create sub since %s, abort", pRebInfo->key, terrstr()); + taosRUnLockLatch(&pTopic->lock); + mndReleaseTopic(pMnode, pTopic); + continue; + } memcpy(rebOutput.pSub->dbName, pTopic->db, TSDB_DB_FNAME_LEN); - ASSERT(taosHashGetSize(rebOutput.pSub->consumerHash) == 0); taosRUnLockLatch(&pTopic->lock); mndReleaseTopic(pMnode, pTopic); @@ -606,7 +610,6 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { // if add more consumer to balanced subscribe, // possibly no vg is changed - /*ASSERT(taosArrayGetSize(rebOutput.rebVgs) != 0);*/ if (mndPersistRebResult(pMnode, pMsg, &rebOutput) < 0) { mError("mq rebalance persist rebalance output error, possibly vnode splitted or dropped"); @@ -693,6 +696,7 @@ static SSdbRaw *mndSubActionEncode(SMqSubscribeObj *pSub) { terrno = TSDB_CODE_OUT_OF_MEMORY; void *buf = NULL; int32_t tlen = tEncodeSubscribeObj(NULL, pSub); + if (tlen <= 0) goto SUB_ENCODE_OVER; int32_t size = sizeof(int32_t) + tlen + MND_SUBSCRIBE_RESERVE_SIZE; SSdbRaw *pRaw = sdbAllocRaw(SDB_SUBSCRIBE, MND_SUBSCRIBE_VER_NUMBER, size); diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index 54d8aa7f60..93c9192bed 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "mndSync.h" +#include "mndCluster.h" #include "mndTrans.h" static int32_t mndSyncEqCtrlMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) { @@ -297,9 +298,12 @@ int32_t mndInitSync(SMnode *pMnode) { pCfg->myIndex = pMgmt->selfIndex; for (int32_t i = 0; i < pMgmt->numOfReplicas; ++i) { SNodeInfo *pNode = &pCfg->nodeInfo[i]; - tstrncpy(pNode->nodeFqdn, pMgmt->replicas[i].fqdn, sizeof(pNode->nodeFqdn)); + pNode->nodeId = pMgmt->replicas[i].id; pNode->nodePort = pMgmt->replicas[i].port; - mInfo("vgId:1, index:%d ep:%s:%u", i, pNode->nodeFqdn, pNode->nodePort); + tstrncpy(pNode->nodeFqdn, pMgmt->replicas[i].fqdn, sizeof(pNode->nodeFqdn)); + (void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); + mInfo("vgId:1, index:%d ep:%s:%u dnode:%d cluster:%" PRId64, i, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId, + pNode->clusterId); } tsem_init(&pMgmt->syncSem, 0, 0); diff --git a/source/dnode/mnode/impl/src/mndTelem.c b/source/dnode/mnode/impl/src/mndTelem.c index 1d3209691a..b0b49b42dc 100644 --- a/source/dnode/mnode/impl/src/mndTelem.c +++ b/source/dnode/mnode/impl/src/mndTelem.c @@ -17,7 +17,6 @@ #include "mndTelem.h" #include "mndCluster.h" #include "mndSync.h" -#include "tbuffer.h" #include "thttp.h" #include "tjson.h" diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 7f5ebd4a90..ce04c72344 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -384,7 +384,11 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq * topicObj.subType = pCreate->subType; topicObj.withMeta = pCreate->withMeta; if (topicObj.withMeta) { - ASSERT(topicObj.subType != TOPIC_SUB_TYPE__COLUMN); + if (topicObj.subType == TOPIC_SUB_TYPE__COLUMN) { + terrno = TSDB_CODE_MND_INVALID_TOPIC_OPTION; + mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); + return -1; + } } if (pCreate->subType == TOPIC_SUB_TYPE__COLUMN) { @@ -499,7 +503,6 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq * if (code < 0) { sdbRelease(pSdb, pVgroup); mndTransDrop(pTrans); - ASSERT(0); return -1; } void *buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len); @@ -718,7 +721,6 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) { // TODO check if rebalancing if (mndDropSubByTopic(pMnode, pTrans, dropReq.name) < 0) { - /*ASSERT(0);*/ mError("topic:%s, failed to drop since %s", pTopic->name, terrstr()); mndTransDrop(pTrans); mndReleaseTopic(pMnode, pTopic); diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 49f8d9be3c..acdc038299 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -785,8 +785,8 @@ static FORCE_INLINE int32_t tsdbKeyCmprFn(const void *p1, const void *p2) { return 0; } -#define SL_NODE_FORWARD(n, l) ((n)->forwards[l]) -#define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)]) +// #define SL_NODE_FORWARD(n, l) ((n)->forwards[l]) +// #define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)]) static FORCE_INLINE TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter) { if (pIter == NULL) return NULL; diff --git a/source/dnode/vnode/src/meta/metaSnapshot.c b/source/dnode/vnode/src/meta/metaSnapshot.c index 4dcb7f4ec0..6e505dfde5 100644 --- a/source/dnode/vnode/src/meta/metaSnapshot.c +++ b/source/dnode/vnode/src/meta/metaSnapshot.c @@ -192,7 +192,8 @@ int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) SDecoder* pDecoder = &(SDecoder){0}; tDecoderInit(pDecoder, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr)); - metaDecodeEntry(pDecoder, &metaEntry); + code = metaDecodeEntry(pDecoder, &metaEntry); + if (code) goto _err; code = metaHandleEntry(pMeta, &metaEntry); if (code) goto _err; @@ -201,6 +202,7 @@ int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) return code; _err: + tDecoderClear(pDecoder); metaError("vgId:%d, vnode snapshot meta write failed since %s", TD_VID(pMeta->pVnode), tstrerror(code)); return code; } diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index d0017e4ba2..141f79ee41 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -1117,6 +1117,11 @@ int32_t tqProcessTaskRecover1Req(STQ* pTq, SRpcMsg* pMsg) { // do recovery step 1 streamSourceRecoverScanStep1(pTask); + if (atomic_load_8(&pTask->taskStatus) == TASK_STATUS__DROPPING) { + streamMetaReleaseTask(pTq->pStreamMeta, pTask); + return 0; + } + // build msg to launch next step SStreamRecoverStep2Req req; code = streamBuildSourceRecover2Req(pTask, &req); @@ -1127,6 +1132,10 @@ int32_t tqProcessTaskRecover1Req(STQ* pTq, SRpcMsg* pMsg) { streamMetaReleaseTask(pTq->pStreamMeta, pTask); + if (atomic_load_8(&pTask->taskStatus) == TASK_STATUS__DROPPING) { + return 0; + } + // serialize msg int32_t len = sizeof(SStreamRecoverStep1Req); @@ -1165,6 +1174,11 @@ int32_t tqProcessTaskRecover2Req(STQ* pTq, int64_t version, char* msg, int32_t m return -1; } + if (atomic_load_8(&pTask->taskStatus) == TASK_STATUS__DROPPING) { + streamMetaReleaseTask(pTq->pStreamMeta, pTask); + return 0; + } + // restore param code = streamRestoreParam(pTask); if (code < 0) { diff --git a/source/dnode/vnode/src/tq/tqOffset.c b/source/dnode/vnode/src/tq/tqOffset.c index 5a4d414ab7..66d1ac2c7e 100644 --- a/source/dnode/vnode/src/tq/tqOffset.c +++ b/source/dnode/vnode/src/tq/tqOffset.c @@ -45,19 +45,37 @@ int32_t tqOffsetRestoreFromFile(STqOffsetStore* pStore, const char* fname) { } int32_t size = htonl(head.size); void* memBuf = taosMemoryCalloc(1, size); + if (memBuf == NULL) { + return -1; + } if ((code = taosReadFile(pFile, memBuf, size)) != size) { + taosMemoryFree(memBuf); return -1; } STqOffset offset; SDecoder decoder; tDecoderInit(&decoder, memBuf, size); if (tDecodeSTqOffset(&decoder, &offset) < 0) { + taosMemoryFree(memBuf); + tDecoderClear(&decoder); return -1; } + tDecoderClear(&decoder); if (taosHashPut(pStore->pHash, offset.subKey, strlen(offset.subKey), &offset, sizeof(STqOffset)) < 0) { return -1; } + + if (offset.val.type == TMQ_OFFSET__LOG) { + STqHandle* pHandle = taosHashGet(pStore->pTq->pHandle, offset.subKey, strlen(offset.subKey)); + if (pHandle) { + if (walRefVer(pHandle->pRef, offset.val.version) < 0) { + tqError("vgId: %d, tq handle %s ref ver %" PRId64 "error", pStore->pTq->pVnode->config.vgId, + pHandle->subKey, offset.val.version); + } + } + } + taosMemoryFree(memBuf); } @@ -123,6 +141,7 @@ int32_t tqOffsetCommitFile(STqOffsetStore* pStore) { const char* sysErrStr = strerror(errno); tqError("vgId:%d, cannot open file %s when commit offset since %s", pStore->pTq->pVnode->config.vgId, fname, sysErrStr); + taosMemoryFree(fname); return -1; } taosMemoryFree(fname); diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index 2ac0b2067f..75c0c0659e 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -63,7 +63,7 @@ int32_t tqBuildDeleteReq(SVnode* pVnode, const char* stbFullName, const SSDataBl .startTs = startTs, .endTs = endTs, }; - strncpy(req.tbname, name, TSDB_TABLE_NAME_LEN); + strncpy(req.tbname, name, TSDB_TABLE_NAME_LEN - 1); taosMemoryFree(name); /*tqDebug("stream delete msg, active: vgId:%d, ts:%" PRId64 " name:%s", pVnode->config.vgId, ts, name);*/ taosArrayPush(deleteReq->deleteReqs, &req); diff --git a/source/dnode/vnode/src/tq/tqSnapshot.c b/source/dnode/vnode/src/tq/tqSnapshot.c index ab7093a701..5c0649c109 100644 --- a/source/dnode/vnode/src/tq/tqSnapshot.c +++ b/source/dnode/vnode/src/tq/tqSnapshot.c @@ -173,6 +173,8 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) { if (code) goto _err; } + int vgId = TD_VID(pWriter->pTq->pVnode); + taosMemoryFree(pWriter); *ppWriter = NULL; @@ -184,7 +186,7 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) { return code; _err: - tqError("vgId:%d, tq snapshot writer close failed since %s", TD_VID(pWriter->pTq->pVnode), tstrerror(code)); + tqError("vgId:%d, tq snapshot writer close failed since %s", vgId, tstrerror(code)); return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index 007ae871a0..953b4884a3 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -19,9 +19,13 @@ #define SL_MAX_LEVEL 5 // sizeof(SMemSkipListNode) + sizeof(SMemSkipListNode *) * (l) * 2 -#define SL_NODE_SIZE(l) (sizeof(SMemSkipListNode) + ((l) << 4)) -#define SL_NODE_FORWARD(n, l) ((n)->forwards[l]) -#define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)]) +#define SL_NODE_SIZE(l) (sizeof(SMemSkipListNode) + ((l) << 4)) +#define SL_NODE_FORWARD(n, l) ((n)->forwards[l]) +#define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)]) +#define SL_GET_NODE_FORWARD(n, l) ((SMemSkipListNode *)atomic_load_64((int64_t *)&SL_NODE_FORWARD(n, l))) +#define SL_GET_NODE_BACKWARD(n, l) ((SMemSkipListNode *)atomic_load_64((int64_t *)&SL_NODE_BACKWARD(n, l))) +#define SL_SET_NODE_FORWARD(n, l, p) atomic_store_64((int64_t *)&SL_NODE_FORWARD(n, l), (int64_t)(p)) +#define SL_SET_NODE_BACKWARD(n, l, p) atomic_store_64((int64_t *)&SL_NODE_BACKWARD(n, l), (int64_t)(p)) #define SL_MOVE_BACKWARD 0x1 #define SL_MOVE_FROM_POS 0x2 @@ -250,18 +254,18 @@ void tsdbTbDataIterOpen(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDa if (pFrom == NULL) { // create from head or tail if (backward) { - pIter->pNode = SL_NODE_BACKWARD(pTbData->sl.pTail, 0); + pIter->pNode = SL_GET_NODE_BACKWARD(pTbData->sl.pTail, 0); } else { - pIter->pNode = SL_NODE_FORWARD(pTbData->sl.pHead, 0); + pIter->pNode = SL_GET_NODE_FORWARD(pTbData->sl.pHead, 0); } } else { // create from a key if (backward) { tbDataMovePosTo(pTbData, pos, pFrom, SL_MOVE_BACKWARD); - pIter->pNode = SL_NODE_BACKWARD(pos[0], 0); + pIter->pNode = SL_GET_NODE_BACKWARD(pos[0], 0); } else { tbDataMovePosTo(pTbData, pos, pFrom, 0); - pIter->pNode = SL_NODE_FORWARD(pos[0], 0); + pIter->pNode = SL_GET_NODE_FORWARD(pos[0], 0); } } } @@ -275,7 +279,7 @@ bool tsdbTbDataIterNext(STbDataIter *pIter) { return false; } - pIter->pNode = SL_NODE_BACKWARD(pIter->pNode, 0); + pIter->pNode = SL_GET_NODE_BACKWARD(pIter->pNode, 0); if (pIter->pNode == pIter->pTbData->sl.pHead) { return false; } @@ -286,7 +290,7 @@ bool tsdbTbDataIterNext(STbDataIter *pIter) { return false; } - pIter->pNode = SL_NODE_FORWARD(pIter->pNode, 0); + pIter->pNode = SL_GET_NODE_FORWARD(pIter->pNode, 0); if (pIter->pNode == pIter->pTbData->sl.pTail) { return false; } @@ -339,7 +343,7 @@ static int32_t tsdbGetOrCreateTbData(SMemTable *pMemTable, tb_uid_t suid, tb_uid int8_t maxLevel = pMemTable->pTsdb->pVnode->config.tsdbCfg.slLevel; ASSERT(pPool != NULL); - pTbData = vnodeBufPoolMalloc(pPool, sizeof(*pTbData) + SL_NODE_SIZE(maxLevel) * 2); + pTbData = vnodeBufPoolMallocAligned(pPool, sizeof(*pTbData) + SL_NODE_SIZE(maxLevel) * 2); if (pTbData == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; @@ -412,7 +416,7 @@ static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *p if (fromPos) px = pos[pTbData->sl.level - 1]; for (int8_t iLevel = pTbData->sl.level - 1; iLevel >= 0; iLevel--) { - pn = SL_NODE_BACKWARD(px, iLevel); + pn = SL_GET_NODE_BACKWARD(px, iLevel); while (pn != pTbData->sl.pHead) { if (pn->flag == TSDBROW_ROW_FMT) { tKey.version = pn->version; @@ -427,7 +431,7 @@ static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *p break; } else { px = pn; - pn = SL_NODE_BACKWARD(px, iLevel); + pn = SL_GET_NODE_BACKWARD(px, iLevel); } } @@ -447,7 +451,7 @@ static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *p if (fromPos) px = pos[pTbData->sl.level - 1]; for (int8_t iLevel = pTbData->sl.level - 1; iLevel >= 0; iLevel--) { - pn = SL_NODE_FORWARD(px, iLevel); + pn = SL_GET_NODE_FORWARD(px, iLevel); while (pn != pTbData->sl.pTail) { if (pn->flag == TSDBROW_ROW_FMT) { tKey.version = pn->version; @@ -462,7 +466,7 @@ static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *p break; } else { px = pn; - pn = SL_NODE_FORWARD(px, iLevel); + pn = SL_GET_NODE_FORWARD(px, iLevel); } } @@ -488,26 +492,28 @@ static int32_t tbDataDoPut(SMemTable *pMemTable, STbData *pTbData, SMemSkipListN int8_t level; SMemSkipListNode *pNode; SVBufPool *pPool = pMemTable->pTsdb->pVnode->inUse; + int64_t nSize; - ASSERT(pPool != NULL); - - // node + // create node level = tsdbMemSkipListRandLevel(&pTbData->sl); - pNode = (SMemSkipListNode *)vnodeBufPoolMalloc(pPool, SL_NODE_SIZE(level)); + nSize = SL_NODE_SIZE(level); + if (pRow->type == TSDBROW_ROW_FMT) { + pNode = (SMemSkipListNode *)vnodeBufPoolMallocAligned(pPool, nSize + pRow->pTSRow->len); + } else if (pRow->type == TSDBROW_COL_FMT) { + pNode = (SMemSkipListNode *)vnodeBufPoolMallocAligned(pPool, nSize); + } else { + ASSERT(0); + } if (pNode == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; } + pNode->level = level; pNode->flag = pRow->type; - if (pRow->type == TSDBROW_ROW_FMT) { pNode->version = pRow->version; - pNode->pData = vnodeBufPoolMalloc(pPool, pRow->pTSRow->len); - if (NULL == pNode->pData) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _exit; - } + pNode->pData = (char *)pNode + nSize; memcpy(pNode->pData, pRow->pTSRow, pRow->pTSRow->len); } else if (pRow->type == TSDBROW_COL_FMT) { pNode->iRow = pRow->iRow; @@ -516,40 +522,38 @@ static int32_t tbDataDoPut(SMemTable *pMemTable, STbData *pTbData, SMemSkipListN ASSERT(0); } - for (int8_t iLevel = level - 1; iLevel >= 0; iLevel--) { - SMemSkipListNode *pn = pos[iLevel]; - SMemSkipListNode *px; - - if (forward) { - px = SL_NODE_FORWARD(pn, iLevel); - - SL_NODE_BACKWARD(pNode, iLevel) = pn; - SL_NODE_FORWARD(pNode, iLevel) = px; - } else { - px = SL_NODE_BACKWARD(pn, iLevel); - - SL_NODE_BACKWARD(pNode, iLevel) = px; - SL_NODE_FORWARD(pNode, iLevel) = pn; + // set node + if (forward) { + for (int8_t iLevel = 0; iLevel < level; iLevel++) { + SL_NODE_FORWARD(pNode, iLevel) = SL_NODE_FORWARD(pos[iLevel], iLevel); + SL_NODE_BACKWARD(pNode, iLevel) = pos[iLevel]; + } + } else { + for (int8_t iLevel = 0; iLevel < level; iLevel++) { + SL_NODE_FORWARD(pNode, iLevel) = pos[iLevel]; + SL_NODE_BACKWARD(pNode, iLevel) = SL_NODE_BACKWARD(pos[iLevel], iLevel); } } - for (int8_t iLevel = level - 1; iLevel >= 0; iLevel--) { - SMemSkipListNode *pn = pos[iLevel]; - SMemSkipListNode *px; + // set forward and backward + if (forward) { + for (int8_t iLevel = level - 1; iLevel >= 0; iLevel--) { + SMemSkipListNode *pNext = pos[iLevel]->forwards[iLevel]; - if (forward) { - px = SL_NODE_FORWARD(pn, iLevel); + SL_SET_NODE_FORWARD(pos[iLevel], iLevel, pNode); + SL_SET_NODE_BACKWARD(pNext, iLevel, pNode); - SL_NODE_FORWARD(pn, iLevel) = pNode; - SL_NODE_BACKWARD(px, iLevel) = pNode; - } else { - px = SL_NODE_BACKWARD(pn, iLevel); - - SL_NODE_FORWARD(px, iLevel) = pNode; - SL_NODE_BACKWARD(pn, iLevel) = pNode; + pos[iLevel] = pNode; } + } else { + for (int8_t iLevel = level - 1; iLevel >= 0; iLevel--) { + SMemSkipListNode *pPrev = pos[iLevel]->forwards[pos[iLevel]->level + iLevel]; - pos[iLevel] = pNode; + SL_SET_NODE_FORWARD(pPrev, iLevel, pNode); + SL_SET_NODE_BACKWARD(pos[iLevel], iLevel, pNode); + + pos[iLevel] = pNode; + } } pTbData->sl.size++; diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index db29d75f17..1fc8049d00 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -76,6 +76,7 @@ static int32_t tFDataIterCmprFn(const SRBTreeNode* pNode1, const SRBTreeNode* pN static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) { int32_t code = 0; + int32_t lino = 0; SDFileSet dFileSet = {.fid = pReader->fid}; SDFileSet* pSet = taosArraySearch(pReader->fs.aDFileSet, &dFileSet, tDFileSetCmprFn, TD_GT); @@ -83,7 +84,7 @@ static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) { pReader->fid = pSet->fid; code = tsdbDataFReaderOpen(&pReader->pDataFReader, pReader->pTsdb, pSet); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); pReader->pIter = NULL; tRBTreeCreate(&pReader->rbt, tFDataIterCmprFn); @@ -93,13 +94,13 @@ static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) { pIter->type = SNAP_DATA_FILE_ITER; code = tsdbReadBlockIdx(pReader->pDataFReader, pIter->aBlockIdx); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); for (pIter->iBlockIdx = 0; pIter->iBlockIdx < taosArrayGetSize(pIter->aBlockIdx); pIter->iBlockIdx++) { pIter->pBlockIdx = (SBlockIdx*)taosArrayGet(pIter->aBlockIdx, pIter->iBlockIdx); code = tsdbReadDataBlk(pReader->pDataFReader, pIter->pBlockIdx, &pIter->mBlock); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); for (pIter->iBlock = 0; pIter->iBlock < pIter->mBlock.nItem; pIter->iBlock++) { SDataBlk dataBlk; @@ -108,7 +109,7 @@ static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) { if (dataBlk.minVer > pReader->ever || dataBlk.maxVer < pReader->sver) continue; code = tsdbReadDataBlockEx(pReader->pDataFReader, &dataBlk, &pIter->bData); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); ASSERT(pIter->pBlockIdx->suid == pIter->bData.suid); ASSERT(pIter->pBlockIdx->uid == pIter->bData.uid); @@ -139,7 +140,7 @@ static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) { pIter->iStt = iStt; code = tsdbReadSttBlk(pReader->pDataFReader, iStt, pIter->aSttBlk); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); for (pIter->iSttBlk = 0; pIter->iSttBlk < taosArrayGetSize(pIter->aSttBlk); pIter->iSttBlk++) { SSttBlk* pSttBlk = (SSttBlk*)taosArrayGet(pIter->aSttBlk, pIter->iSttBlk); @@ -148,7 +149,7 @@ static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) { if (pSttBlk->maxVer < pReader->sver) continue; code = tsdbReadSttBlockEx(pReader->pDataFReader, iStt, pSttBlk, &pIter->bData); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); for (pIter->iRow = 0; pIter->iRow < pIter->bData.nRow; pIter->iRow++) { int64_t rowVer = pIter->bData.aVersion[pIter->iRow]; @@ -169,13 +170,13 @@ static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) { pIter++; } - tsdbInfo("vgId:%d, vnode snapshot tsdb open data file to read for %s, fid:%d", TD_VID(pReader->pTsdb->pVnode), - pReader->pTsdb->path, pReader->fid); - return code; - -_err: - tsdbError("vgId:%d, vnode snapshot tsdb snap read open file failed since %s", TD_VID(pReader->pTsdb->pVnode), - tstrerror(code)); +_exit: + if (code) { + tsdbError("vgId:%d, %s failed since %s", TD_VID(pReader->pTsdb->pVnode), __func__, tstrerror(code)); + } else { + tsdbInfo("vgId:%d, %s done, path:%s, fid:%d", TD_VID(pReader->pTsdb->pVnode), __func__, pReader->pTsdb->path, + pReader->fid); + } return code; } @@ -318,12 +319,14 @@ _exit: static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { int32_t code = 0; - STsdb* pTsdb = pReader->pTsdb; + int32_t lino = 0; + + STsdb* pTsdb = pReader->pTsdb; while (true) { if (pReader->pDataFReader == NULL) { code = tsdbSnapReadOpenFile(pReader); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); } if (pReader->pDataFReader == NULL) break; @@ -338,17 +341,17 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { SBlockData* pBlockData = &pReader->bData; code = tsdbUpdateTableSchema(pTsdb->pVnode->pMeta, id.suid, id.uid, &pReader->skmTable); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); code = tBlockDataInit(pBlockData, &id, pReader->skmTable.pTSchema, NULL, 0); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); while (pRowInfo->suid == id.suid && pRowInfo->uid == id.uid) { code = tBlockDataAppendRow(pBlockData, &pRowInfo->row, NULL, pRowInfo->uid); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); code = tsdbSnapNextRow(pReader); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); pRowInfo = tsdbSnapGetRow(pReader); if (pRowInfo == NULL) { @@ -360,21 +363,22 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { } code = tsdbSnapCmprData(pReader, ppData); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); break; } - return code; - -_err: - tsdbError("vgId:%d, vnode snapshot tsdb read data for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path, - tstrerror(code)); +_exit: + if (code) { + tsdbError("vgId:%d, %s failed since %s, path:%s", TD_VID(pTsdb->pVnode), __func__, tstrerror(code), pTsdb->path); + } return code; } static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) { - int32_t code = 0; + int32_t code = 0; + int32_t lino = 0; + STsdb* pTsdb = pReader->pTsdb; SDelFile* pDelFile = pReader->fs.pDelFile; @@ -385,11 +389,11 @@ static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) { // open code = tsdbDelFReaderOpen(&pReader->pDelFReader, pDelFile, pTsdb); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); // read index code = tsdbReadDelIdx(pReader->pDelFReader, pReader->aDelIdx); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); pReader->iDelIdx = 0; } @@ -405,7 +409,7 @@ static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) { pReader->iDelIdx++; code = tsdbReadDelData(pReader->pDelFReader, pDelIdx, pReader->aDelData); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); int32_t size = 0; for (int32_t iDelData = 0; iDelData < taosArrayGetSize(pReader->aDelData); iDelData++) { @@ -422,7 +426,7 @@ static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) { *ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + size); if (*ppData == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; + TSDB_CHECK_CODE(code, lino, _exit); } SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData); @@ -449,11 +453,9 @@ static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) { } _exit: - return code; - -_err: - tsdbError("vgId:%d, vnode snapshot tsdb read del for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path, - tstrerror(code)); + if (code) { + tsdbError("vgId:%d, %s failed since %s, path:%s", TD_VID(pTsdb->pVnode), __func__, tstrerror(code), pTsdb->path); + } return code; } @@ -591,44 +593,39 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader) { int32_t tsdbSnapRead(STsdbSnapReader* pReader, uint8_t** ppData) { int32_t code = 0; + int32_t lino = 0; *ppData = NULL; // read data file if (!pReader->dataDone) { code = tsdbSnapReadData(pReader, ppData); - if (code) { - goto _err; + TSDB_CHECK_CODE(code, lino, _exit); + if (*ppData) { + goto _exit; } else { - if (*ppData) { - goto _exit; - } else { - pReader->dataDone = 1; - } + pReader->dataDone = 1; } } // read del file if (!pReader->delDone) { code = tsdbSnapReadDel(pReader, ppData); - if (code) { - goto _err; + TSDB_CHECK_CODE(code, lino, _exit); + if (*ppData) { + goto _exit; } else { - if (*ppData) { - goto _exit; - } else { - pReader->delDone = 1; - } + pReader->delDone = 1; } } _exit: - tsdbDebug("vgId:%d, vnode snapshot tsdb read for %s", TD_VID(pReader->pTsdb->pVnode), pReader->pTsdb->path); - return code; - -_err: - tsdbError("vgId:%d, vnode snapshot tsdb read for %s failed since %s", TD_VID(pReader->pTsdb->pVnode), - pReader->pTsdb->path, tstrerror(code)); + if (code) { + tsdbError("vgId:%d, %s failed since %s, path:%s", TD_VID(pReader->pTsdb->pVnode), __func__, tstrerror(code), + pReader->pTsdb->path); + } else { + tsdbDebug("vgId:%d, %s done, path:%s", TD_VID(pReader->pTsdb->pVnode), __func__, pReader->pTsdb->path); + } return code; } diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index 782cc69d30..69af536a44 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -125,13 +125,22 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) { if (tjsonAddIntegerToObject(pJson, "vndStats.timeseries", pCfg->vndStats.numOfTimeSeries) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "vndStats.ntimeseries", pCfg->vndStats.numOfNTimeSeries) < 0) return -1; - SJson *pNodeInfoArr = tjsonCreateArray(); - tjsonAddItemToObject(pJson, "syncCfg.nodeInfo", pNodeInfoArr); + SJson *nodeInfo = tjsonCreateArray(); + if (nodeInfo == NULL) return -1; + if (tjsonAddItemToObject(pJson, "syncCfg.nodeInfo", nodeInfo) < 0) return -1; + vDebug("vgId:%d, encode config, replicas:%d selfIndex:%d", pCfg->vgId, pCfg->syncCfg.replicaNum, + pCfg->syncCfg.myIndex); for (int i = 0; i < pCfg->syncCfg.replicaNum; ++i) { - SJson *pNodeInfo = tjsonCreateObject(); - tjsonAddIntegerToObject(pNodeInfo, "nodePort", (pCfg->syncCfg.nodeInfo)[i].nodePort); - tjsonAddStringToObject(pNodeInfo, "nodeFqdn", (pCfg->syncCfg.nodeInfo)[i].nodeFqdn); - tjsonAddItemToArray(pNodeInfoArr, pNodeInfo); + SJson *info = tjsonCreateObject(); + SNodeInfo *pNode = (SNodeInfo *)&pCfg->syncCfg.nodeInfo[i]; + if (info == NULL) return -1; + if (tjsonAddIntegerToObject(info, "nodePort", pNode->nodePort) < 0) return -1; + if (tjsonAddStringToObject(info, "nodeFqdn", pNode->nodeFqdn) < 0) return -1; + if (tjsonAddIntegerToObject(info, "nodeId", pNode->nodeId) < 0) return -1; + if (tjsonAddIntegerToObject(info, "clusterId", pNode->clusterId) < 0) return -1; + if (tjsonAddItemToArray(nodeInfo, info) < 0) return -1; + vDebug("vgId:%d, encode config, replica:%d ep:%s:%u dnode:%d", pCfg->vgId, i, pNode->nodeFqdn, pNode->nodePort, + pNode->nodeId); } return 0; @@ -240,15 +249,24 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) { tjsonGetNumberValue(pJson, "vndStats.ntimeseries", pCfg->vndStats.numOfNTimeSeries, code); if (code < 0) return -1; - SJson *pNodeInfoArr = tjsonGetObjectItem(pJson, "syncCfg.nodeInfo"); - int arraySize = tjsonGetArraySize(pNodeInfoArr); - assert(arraySize == pCfg->syncCfg.replicaNum); + SJson *nodeInfo = tjsonGetObjectItem(pJson, "syncCfg.nodeInfo"); + int arraySize = tjsonGetArraySize(nodeInfo); + if (arraySize != pCfg->syncCfg.replicaNum) return -1; + vDebug("vgId:%d, decode config, replicas:%d selfIndex:%d", pCfg->vgId, pCfg->syncCfg.replicaNum, + pCfg->syncCfg.myIndex); for (int i = 0; i < arraySize; ++i) { - SJson *pNodeInfo = tjsonGetArrayItem(pNodeInfoArr, i); - assert(pNodeInfo != NULL); - tjsonGetNumberValue(pNodeInfo, "nodePort", (pCfg->syncCfg.nodeInfo)[i].nodePort, code); - tjsonGetStringValue(pNodeInfo, "nodeFqdn", (pCfg->syncCfg.nodeInfo)[i].nodeFqdn); + SJson *info = tjsonGetArrayItem(nodeInfo, i); + SNodeInfo *pNode = &pCfg->syncCfg.nodeInfo[i]; + if (info == NULL) return -1; + tjsonGetNumberValue(info, "nodePort", pNode->nodePort, code); + if (code < 0) return -1; + tjsonGetStringValue(info, "nodeFqdn", pNode->nodeFqdn); + if (code < 0) return -1; + tjsonGetNumberValue(info, "nodeId", pNode->nodeId, code); + tjsonGetNumberValue(info, "clusterId", pNode->clusterId, code); + vDebug("vgId:%d, decode config, replica:%d ep:%s:%u dnode:%d", pCfg->vgId, i, pNode->nodeFqdn, pNode->nodePort, + pNode->nodeId); } tjsonGetNumberValue(pJson, "tsdbPageSize", pCfg->tsdbPageSize, code); diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index 0874a88cfe..ab7f73121f 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -105,8 +105,8 @@ int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) { // free info binary taosMemoryFree(data); - vInfo("vgId:%d, vnode info is saved, fname:%s replica:%d", pInfo->config.vgId, fname, - pInfo->config.syncCfg.replicaNum); + vInfo("vgId:%d, vnode info is saved, fname:%s replica:%d selfIndex:%d", pInfo->config.vgId, fname, + pInfo->config.syncCfg.replicaNum, pInfo->config.syncCfg.myIndex); return 0; @@ -206,6 +206,8 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) { } else { snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path); } + + vDebug("vgId:%d, save config while prepare commit", TD_VID(pVnode)); if (vnodeSaveInfo(dir, &pInfo->info) < 0) { code = terrno; TSDB_CHECK_CODE(code, lino, _exit); diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index e09fafb756..bec5d2977b 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -48,6 +48,7 @@ int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) { info.state.applied = -1; info.state.commitID = 0; + vInfo("vgId:%d, save config while create", pCfg->vgId); if (vnodeSaveInfo(dir, &info) < 0 || vnodeCommitInfo(dir, &info) < 0) { vError("vgId:%d, failed to save vnode config since %s", pCfg ? pCfg->vgId : 0, tstrerror(terrno)); return -1; @@ -79,12 +80,14 @@ int32_t vnodeAlter(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs) { pCfg->replicaNum = pReq->replica; memset(&pCfg->nodeInfo, 0, sizeof(pCfg->nodeInfo)); - vInfo("vgId:%d, save config, replicas:%d selfIndex:%d", pReq->vgId, pCfg->replicaNum, pCfg->myIndex); + vInfo("vgId:%d, save config while alter, replicas:%d selfIndex:%d", pReq->vgId, pCfg->replicaNum, pCfg->myIndex); for (int i = 0; i < pReq->replica; ++i) { SNodeInfo *pNode = &pCfg->nodeInfo[i]; + pNode->nodeId = pReq->replicas[i].id; pNode->nodePort = pReq->replicas[i].port; tstrncpy(pNode->nodeFqdn, pReq->replicas[i].fqdn, sizeof(pNode->nodeFqdn)); - vInfo("vgId:%d, save config, replica:%d ep:%s:%u", pReq->vgId, i, pNode->nodeFqdn, pNode->nodePort); + (void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); + vInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d", pReq->vgId, i, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId); } info.config.syncCfg = *pCfg; diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index 2fc06fba86..cc22668b29 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -405,6 +405,10 @@ static int32_t vnodeSnapWriteInfo(SVSnapWriter *pWriter, uint8_t *pData, uint32_ } else { snprintf(dir, TSDB_FILENAME_LEN, "%s", pWriter->pVnode->path); } + + SVnode *pVnode = pWriter->pVnode; + pWriter->info.config = pVnode->config; + vDebug("vgId:%d, save config while write snapshot", pWriter->pVnode->config.vgId); if (vnodeSaveInfo(dir, &pWriter->info) < 0) { code = terrno; goto _exit; diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index 5697487743..749c81224c 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -578,7 +578,8 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) { vInfo("vgId:%d, start to open sync, replica:%d selfIndex:%d", pVnode->config.vgId, pCfg->replicaNum, pCfg->myIndex); for (int32_t i = 0; i < pCfg->replicaNum; ++i) { SNodeInfo *pNode = &pCfg->nodeInfo[i]; - vInfo("vgId:%d, index:%d ep:%s:%u", pVnode->config.vgId, i, pNode->nodeFqdn, pNode->nodePort); + vInfo("vgId:%d, index:%d ep:%s:%u dnode:%d cluster:%" PRId64, pVnode->config.vgId, i, pNode->nodeFqdn, pNode->nodePort, + pNode->nodeId, pNode->clusterId); } pVnode->sync = syncOpen(&syncInfo); diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index 51150ede3c..e0d2276e6f 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -18,7 +18,6 @@ #include "function.h" #include "nodes.h" #include "plannodes.h" -#include "tbuffer.h" #include "tcommon.h" #include "tpagedbuf.h" #include "tsimplehash.h" @@ -116,6 +115,10 @@ struct SResultRowEntryInfo* getResultEntryInfo(const SResultRow* pRow, int32_t i static FORCE_INLINE SResultRow* getResultRowByPos(SDiskbasedBuf* pBuf, SResultRowPosition* pos, bool forUpdate) { SFilePage* bufPage = (SFilePage*)getBufPage(pBuf, pos->pageId); + if (NULL == bufPage) { + return NULL; + } + if (forUpdate) { setBufPageDirty(bufPage, true); } diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 44202b5412..45cfcba8b5 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -696,7 +696,7 @@ void cleanupExprSupp(SExprSupp* pSup); void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs); int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize, - const char* pkey); + const char* pkey, void* pState); void cleanupAggSup(SAggSupporter* pAggSup); void initResultSizeInfo(SResultInfo* pResultInfo, int32_t numOfRows); @@ -855,6 +855,8 @@ int32_t releaseOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResul int32_t saveOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResult, int32_t resSize); void getNextIntervalWindow(SInterval* pInterval, STimeWindow* tw, int32_t order); int32_t qAppendTaskStopInfo(SExecTaskInfo* pTaskInfo, SExchangeOpStopInfo* pInfo); +int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn_t searchFn, TSKEY ekey, int32_t pos, + int32_t order, int64_t* pData); #ifdef __cplusplus } diff --git a/source/libs/executor/src/dataInserter.c b/source/libs/executor/src/dataInserter.c index 0800b415bd..f78e3c22e1 100644 --- a/source/libs/executor/src/dataInserter.c +++ b/source/libs/executor/src/dataInserter.c @@ -25,8 +25,8 @@ extern SDataSinkStat gDataSinkStat; typedef struct SSubmitRes { - int64_t affectedRows; - int32_t code; + int64_t affectedRows; + int32_t code; SSubmitRsp2* pRsp; } SSubmitRes; @@ -85,7 +85,7 @@ int32_t inserterCallback(void* param, SDataBuf* pMsg, int32_t code) { } pInserter->submitRes.affectedRows += pInserter->submitRes.pRsp->affectedRows; - qDebug("submit rsp received, affectedRows:%d, total:%"PRId64, pInserter->submitRes.pRsp->affectedRows, + qDebug("submit rsp received, affectedRows:%d, total:%" PRId64, pInserter->submitRes.pRsp->affectedRows, pInserter->submitRes.affectedRows); tDecoderClear(&coder); taosMemoryFree(pInserter->submitRes.pRsp); @@ -97,7 +97,8 @@ _return: return TSDB_CODE_SUCCESS; } -static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, void* pMsg, int32_t msgLen, void* pTransporter, SEpSet* pEpset) { +static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, void* pMsg, int32_t msgLen, void* pTransporter, + SEpSet* pEpset) { // send the fetch remote task result reques SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == pMsgSendInfo) { @@ -121,9 +122,9 @@ static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, void* pMsg, int } static int32_t submitReqToMsg(int32_t vgId, SSubmitReq2* pReq, void** pData, int32_t* pLen) { - int32_t code = TSDB_CODE_SUCCESS; + int32_t code = TSDB_CODE_SUCCESS; int32_t len = 0; - void* pBuf = NULL; + void* pBuf = NULL; tEncodeSize(tEncodeSSubmitReq2, pReq, len, code); if (TSDB_CODE_SUCCESS == code) { SEncoder encoder; @@ -148,9 +149,8 @@ static int32_t submitReqToMsg(int32_t vgId, SSubmitReq2* pReq, void** pData, int return code; } - -int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** ppReq, const SSDataBlock* pDataBlock, const STSchema* pTSchema, - int64_t uid, int32_t vgId, tb_uid_t suid) { +int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** ppReq, const SSDataBlock* pDataBlock, + const STSchema* pTSchema, int64_t uid, int32_t vgId, tb_uid_t suid) { SSubmitReq2* pReq = *ppReq; SArray* pVals = NULL; int32_t numOfBlks = 0; @@ -194,8 +194,8 @@ int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** pp int32_t offset = 0; for (int32_t k = 0; k < pTSchema->numOfCols; ++k) { // iterate by column - int16_t colIdx = k; - const STColumn* pCol = &pTSchema->columns[k]; + int16_t colIdx = k; + const STColumn* pCol = &pTSchema->columns[k]; if (!pInserter->fullOrderColList) { int16_t* slotId = taosHashGet(pInserter->pCols, &pCol->colId, sizeof(pCol->colId)); if (NULL == slotId) { @@ -204,7 +204,7 @@ int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** pp colIdx = *slotId; } - + SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, colIdx); void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes); @@ -246,7 +246,7 @@ int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** pp lastTs = *(int64_t*)var; } } - + SValue sv; memcpy(&sv.val, var, tDataTypes[pCol->type].bytes); SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv); @@ -268,7 +268,7 @@ int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** pp ignoreRow = false; continue; } - + SRow* pRow = NULL; if ((terrno = tRowBuild(pVals, pTSchema, &pRow)) < 0) { tDestroySSubmitTbData(&tbData, TSDB_MSG_FLG_ENCODE); @@ -286,7 +286,6 @@ int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** pp taosArrayPush(pReq->aSubmitTbData, &tbData); - _end: taosArrayDestroy(pVals); if (terrno != 0) { @@ -301,7 +300,6 @@ _end: return TSDB_CODE_SUCCESS; } - int32_t dataBlocksToSubmitReq(SDataInserterHandle* pInserter, void** pMsg, int32_t* msgLen) { const SArray* pBlocks = pInserter->pDataBlocks; const STSchema* pTSchema = pInserter->pSchema; @@ -310,7 +308,7 @@ int32_t dataBlocksToSubmitReq(SDataInserterHandle* pInserter, void** pMsg, int32 int32_t vgId = pInserter->pNode->vgId; int32_t sz = taosArrayGetSize(pBlocks); int32_t code = 0; - SSubmitReq2 *pReq = NULL; + SSubmitReq2* pReq = NULL; for (int32_t i = 0; i < sz; i++) { SSDataBlock* pDataBlock = taosArrayGetP(pBlocks, i); @@ -329,23 +327,24 @@ int32_t dataBlocksToSubmitReq(SDataInserterHandle* pInserter, void** pMsg, int32 code = submitReqToMsg(vgId, pReq, pMsg, msgLen); tDestroySSubmitReq2(pReq, TSDB_MSG_FLG_ENCODE); taosMemoryFree(pReq); - + return code; } static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput, bool* pContinue) { SDataInserterHandle* pInserter = (SDataInserterHandle*)pHandle; taosArrayPush(pInserter->pDataBlocks, &pInput->pData); - void* pMsg = NULL; + void* pMsg = NULL; int32_t msgLen = 0; - int32_t code = dataBlocksToSubmitReq(pInserter, &pMsg, &msgLen); + int32_t code = dataBlocksToSubmitReq(pInserter, &pMsg, &msgLen); if (code) { return code; } taosArrayClear(pInserter->pDataBlocks); - - code = sendSubmitRequest(pInserter, pMsg, msgLen, pInserter->pParam->readHandle->pMsgCb->clientRpc, &pInserter->pNode->epSet); + + code = sendSubmitRequest(pInserter, pMsg, msgLen, pInserter->pParam->readHandle->pMsgCb->clientRpc, + &pInserter->pNode->epSet); if (code) { return code; } @@ -443,7 +442,7 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat inserter->pCols = taosHashInit(pInserterNode->pCols->length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK); - SNode* pNode = NULL; + SNode* pNode = NULL; int32_t i = 0; FOREACH(pNode, pInserterNode->pCols) { SColumnNode* pCol = (SColumnNode*)pNode; diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index fc3cfbd0f6..a5468008aa 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -1726,8 +1726,10 @@ STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowI return w; } - w = getResultRowByPos(pBuf, &pResultRowInfo->cur, false)->win; - + SResultRow* pRow = getResultRowByPos(pBuf, &pResultRowInfo->cur, false); + if (pRow) { + w = pRow->win; + } // in case of typical time window, we can calculate time window directly. if (w.skey > ts || w.ekey < ts) { w = doCalculateTimeWindow(ts, pInterval); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 149efef884..72419d8fe4 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -83,6 +83,7 @@ typedef struct SAggOperatorInfo { uint64_t groupId; SGroupResInfo groupResInfo; SExprSupp scalarExprSup; + bool groupKeyOptimized; } SAggOperatorInfo; static void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pBlock); @@ -149,6 +150,11 @@ SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, i pData->num = sizeof(SFilePage); } else { pData = getBufPage(pResultBuf, *currentPageId); + if (pData == NULL) { + qError("failed to get buffer, code:%s", tstrerror(terrno)); + return NULL; + } + pageId = *currentPageId; if (pData->num + interBufSize > getBufPageSize(pResultBuf)) { @@ -199,6 +205,10 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR if (isIntervalQuery) { if (p1 != NULL) { // the *p1 may be NULL in case of sliding+offset exists. pResult = getResultRowByPos(pResultBuf, p1, true); + if (NULL == pResult) { + T_LONG_JMP(pTaskInfo->env, terrno); + } + ASSERT(pResult->pageId == p1->pageId && pResult->offset == p1->offset); } } else { @@ -207,6 +217,10 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR if (p1 != NULL) { // todo pResult = getResultRowByPos(pResultBuf, p1, true); + if (NULL == pResult) { + T_LONG_JMP(pTaskInfo->env, terrno); + } + ASSERT(pResult->pageId == p1->pageId && pResult->offset == p1->offset); } } @@ -215,6 +229,10 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR if (pResultRowInfo->cur.pageId != -1 && ((pResult == NULL) || (pResult->pageId != pResultRowInfo->cur.pageId))) { SResultRowPosition pos = pResultRowInfo->cur; SFilePage* pPage = getBufPage(pResultBuf, pos.pageId); + if (pPage == NULL) { + qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo)); + T_LONG_JMP(pTaskInfo->env, terrno); + } releaseBufPage(pResultBuf, pPage); } @@ -222,6 +240,9 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR if (pResult == NULL) { ASSERT(pSup->resultRowSize > 0); pResult = getNewResultRow(pResultBuf, &pSup->currentPageId, pSup->resultRowSize); + if (pResult == NULL) { + T_LONG_JMP(pTaskInfo->env, terrno); + } // add a new result set for a new group SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset}; @@ -259,6 +280,11 @@ static int32_t addNewWindowResultBuf(SResultRow* pWindowRes, SDiskbasedBuf* pRes } else { SPageInfo* pi = getLastPageInfo(list); pData = getBufPage(pResultBuf, getPageId(pi)); + if (pData == NULL) { + qError("failed to get buffer, code:%s", tstrerror(terrno)); + return terrno; + } + pageId = getPageId(pi); if (pData->num + size > getBufPageSize(pResultBuf)) { @@ -604,9 +630,7 @@ void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock* pB } } -bool isTaskKilled(SExecTaskInfo* pTaskInfo) { - return (0 != pTaskInfo->code) ? true : false; -} +bool isTaskKilled(SExecTaskInfo* pTaskInfo) { return (0 != pTaskInfo->code) ? true : false; } void setTaskKilled(SExecTaskInfo* pTaskInfo, int32_t rspCode) { pTaskInfo->code = rspCode; } @@ -913,7 +937,7 @@ void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uin if (pResultRow->pageId == -1) { int32_t ret = addNewWindowResultBuf(pResultRow, pAggInfo->aggSup.pResultBuf, pAggInfo->binfo.pRes->info.rowSize); if (ret != TSDB_CODE_SUCCESS) { - return; + T_LONG_JMP(pTaskInfo->env, terrno); } } @@ -994,6 +1018,11 @@ static void doCopyResultToDataBlock(SExprInfo* pExprInfo, int32_t numOfExprs, SR int32_t finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, SExprSupp* pSup, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) { SFilePage* page = getBufPage(pBuf, resultRowPosition->pageId); + if (page == NULL) { + qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo)); + T_LONG_JMP(pTaskInfo->env, terrno); + } + SResultRow* pRow = (SResultRow*)((char*)page + resultRowPosition->offset); SqlFunctionCtx* pCtx = pSup->pCtx; @@ -1037,6 +1066,10 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprS for (int32_t i = pGroupResInfo->index; i < numOfRows; i += 1) { SResKeyPos* pPos = taosArrayGetP(pGroupResInfo->pRows, i); SFilePage* page = getBufPage(pBuf, pPos->pos.pageId); + if (page == NULL) { + qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo)); + T_LONG_JMP(pTaskInfo->env, terrno); + } SResultRow* pRow = (SResultRow*)((char*)page + pPos->pos.offset); @@ -1349,20 +1382,25 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan } } -static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBlock **ppBlock) { +static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBlock** ppBlock) { if (!tsCountAlwaysReturnValue) { return TSDB_CODE_SUCCESS; } + SAggOperatorInfo* pAggInfo = pOperator->info; + if (pAggInfo->groupKeyOptimized) { + return TSDB_CODE_SUCCESS; + } + SOperatorInfo* downstream = pOperator->pDownstream[0]; if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_PARTITION || (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN && - ((STableScanInfo *)downstream->info)->hasGroupByTag == true)) { + ((STableScanInfo*)downstream->info)->hasGroupByTag == true)) { return TSDB_CODE_SUCCESS; } SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx; - bool hasCountFunc = false; + bool hasCountFunc = false; for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) { const char* pName = pCtx[i].pExpr->pExpr->_function.functionName; @@ -1411,7 +1449,7 @@ static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBloc return TSDB_CODE_SUCCESS; } -static void destroyDataBlockForEmptyInput(bool blockAllocated, SSDataBlock **ppBlock) { +static void destroyDataBlockForEmptyInput(bool blockAllocated, SSDataBlock** ppBlock) { if (!blockAllocated) { return; } @@ -1437,8 +1475,8 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { int32_t order = TSDB_ORDER_ASC; int32_t scanFlag = MAIN_SCAN; - bool hasValidBlock = false; - bool blockAllocated = false; + bool hasValidBlock = false; + bool blockAllocated = false; while (1) { SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); @@ -1481,7 +1519,6 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { } destroyDataBlockForEmptyInput(blockAllocated, &pBlock); - } // the downstream operator may return with error code, so let's check the code before generating results. @@ -1636,7 +1673,7 @@ void cleanupAggSup(SAggSupporter* pAggSup) { } int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize, - const char* pkey) { + const char* pkey, void* pState) { int32_t code = initExprSupp(pSup, pExprInfo, numOfCols); if (code != TSDB_CODE_SUCCESS) { return code; @@ -1648,7 +1685,13 @@ int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo } for (int32_t i = 0; i < numOfCols; ++i) { - pSup->pCtx[i].saveHandle.pBuf = pAggSup->pResultBuf; + if (pState) { + pSup->pCtx[i].saveHandle.pBuf = NULL; + pSup->pCtx[i].saveHandle.pState = pState; + pSup->pCtx[i].exprIdx = i; + } else { + pSup->pCtx[i].saveHandle.pBuf = pAggSup->pResultBuf; + } } return TSDB_CODE_SUCCESS; @@ -1733,7 +1776,8 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiN int32_t num = 0; SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num); - int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str); + int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str, + pTaskInfo->streamInfo.pState); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -1755,11 +1799,13 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiN } pInfo->binfo.mergeResultBlock = pAggNode->mergeDataBlock; + pInfo->groupKeyOptimized = pAggNode->groupKeyOptimized; pInfo->groupId = UINT64_MAX; setOperatorInfo(pOperator, "TableAggregate", QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, true, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, destroyAggOperatorInfo, optrDefaultBufFn, NULL); + pOperator->fpSet = createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, destroyAggOperatorInfo, + optrDefaultBufFn, NULL); if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) { STableScanInfo* pTableScanInfo = downstream->info; diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 59266dad7e..5676e19cdf 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -458,7 +458,8 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode* int32_t num = 0; SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num); - code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, pInfo->groupKeyLen, pTaskInfo->id.str); + code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, pInfo->groupKeyLen, pTaskInfo->id.str, + pTaskInfo->streamInfo.pState); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -491,13 +492,17 @@ _error: static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) { SPartitionOperatorInfo* pInfo = pOperator->info; - + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + for (int32_t j = 0; j < pBlock->info.rows; ++j) { recordNewGroupKeys(pInfo->pGroupCols, pInfo->pGroupColVals, pBlock, j); int32_t len = buildGroupKeys(pInfo->keyBuf, pInfo->pGroupColVals); SDataGroupInfo* pGroupInfo = NULL; void* pPage = getCurrentDataGroupInfo(pInfo, &pGroupInfo, len); + if (pPage == NULL) { + T_LONG_JMP(pTaskInfo->env, terrno); + } pGroupInfo->numOfRows += 1; @@ -594,6 +599,10 @@ void* getCurrentDataGroupInfo(const SPartitionOperatorInfo* pInfo, SDataGroupInf } else { int32_t* curId = taosArrayGetLast(p->pPageList); pPage = getBufPage(pInfo->pBuf, *curId); + if (pPage == NULL) { + qError("failed to get buffer, code:%s", tstrerror(terrno)); + return pPage; + } int32_t* rows = (int32_t*)pPage; if (*rows >= pInfo->rowCapacity) { @@ -673,7 +682,8 @@ static int compareDataGroupInfo(const void* group1, const void* group2) { static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) { SPartitionOperatorInfo* pInfo = pOperator->info; - + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SDataGroupInfo* pGroupInfo = (pInfo->groupIndex != -1) ? taosArrayGet(pInfo->sortedGroupArray, pInfo->groupIndex) : NULL; if (pInfo->groupIndex == -1 || pInfo->pageIndex >= taosArrayGetSize(pGroupInfo->pPageList)) { @@ -691,7 +701,11 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) { int32_t* pageId = taosArrayGet(pGroupInfo->pPageList, pInfo->pageIndex); void* page = getBufPage(pInfo->pBuf, *pageId); - + if (page == NULL) { + qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo)); + T_LONG_JMP(pTaskInfo->env, terrno); + } + blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->rowCapacity); blockDataFromBuf1(pInfo->binfo.pRes, page, pInfo->rowCapacity); diff --git a/source/libs/executor/src/projectoperator.c b/source/libs/executor/src/projectoperator.c index 0cccc75ef5..2a90f24346 100644 --- a/source/libs/executor/src/projectoperator.c +++ b/source/libs/executor/src/projectoperator.c @@ -102,7 +102,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys } initResultSizeInfo(&pOperator->resultInfo, numOfRows); - code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str); + code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str, + pTaskInfo->streamInfo.pState); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -317,7 +318,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { if (pProjectInfo->mergeDataBlocks) { if (pRes->info.rows > 0) { - pFinalRes->info.id.groupId = 0; //clear groupId + pFinalRes->info.id.groupId = 0; // clear groupId pFinalRes->info.version = pRes->info.version; // continue merge data, ignore the group id @@ -402,7 +403,8 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy initResultSizeInfo(&pOperator->resultInfo, numOfRows); blockDataEnsureCapacity(pResBlock, numOfRows); - int32_t code = initAggSup(pSup, &pInfo->aggSup, pExprInfo, numOfExpr, keyBufSize, pTaskInfo->id.str); + int32_t code = initAggSup(pSup, &pInfo->aggSup, pExprInfo, numOfExpr, keyBufSize, pTaskInfo->id.str, + pTaskInfo->streamInfo.pState); if (code != TSDB_CODE_SUCCESS) { goto _error; } diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index b2aa2269a2..a7f5eb9b22 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -170,6 +170,10 @@ static SResultRow* getTableGroupOutputBuf(SOperatorInfo* pOperator, uint64_t gro } *pPage = getBufPage(pTableScanInfo->base.pdInfo.pAggSup->pResultBuf, p1->pageId); + if (NULL == *pPage) { + return NULL; + } + return (SResultRow*)((char*)(*pPage) + p1->offset); } diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index a88f673e0b..ac32b54f56 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -65,6 +65,8 @@ typedef struct SSysTableScanInfo { SSDataBlock* pRes; int64_t numOfBlocks; // extract basic running information. SLoadRemoteDataInfo loadInfo; + + int32_t tbnameSlotId; } SSysTableScanInfo; typedef struct { @@ -346,6 +348,11 @@ static int32_t optSysTabFilteImpl(void* arg, SNode* cond, SArray* result); static int32_t optSysCheckOper(SNode* pOpear); static int32_t optSysMergeRslt(SArray* mRslt, SArray* rslt); +static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableScanInfo* pInfo, const char* name, + SExecTaskInfo* pTaskInfo); +void extractTbnameSlotId(SSysTableScanInfo* pInfo, const SScanPhysiNode* pScanNode); +static SSDataBlock* sysTableScanFillTbName(SOperatorInfo* pOperator, const SSysTableScanInfo* pInfo, + const char* name, SSDataBlock* pBlock); __optSysFilter optSysGetFilterFunc(int32_t ctype, bool* reverse) { if (ctype == OP_TYPE_LOWER_EQUAL || ctype == OP_TYPE_LOWER_THAN) { *reverse = true; @@ -1309,83 +1316,111 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) { getDBNameFromCondition(pInfo->pCondition, dbName); sprintf(pInfo->req.db, "%d.%s", pInfo->accountId, dbName); } - + SSDataBlock* pBlock = NULL; if (strncasecmp(name, TSDB_INS_TABLE_TABLES, TSDB_TABLE_FNAME_LEN) == 0) { - return sysTableScanUserTables(pOperator); + pBlock = sysTableScanUserTables(pOperator); } else if (strncasecmp(name, TSDB_INS_TABLE_TAGS, TSDB_TABLE_FNAME_LEN) == 0) { - return sysTableScanUserTags(pOperator); + pBlock = sysTableScanUserTags(pOperator); } else if (strncasecmp(name, TSDB_INS_TABLE_STABLES, TSDB_TABLE_FNAME_LEN) == 0 && pInfo->showRewrite && IS_SYS_DBNAME(dbName)) { - return sysTableScanUserSTables(pOperator); + pBlock = sysTableScanUserSTables(pOperator); } else { // load the meta from mnode of the given epset - if (pOperator->status == OP_EXEC_DONE) { + pBlock = sysTableScanFromMNode(pOperator, pInfo, name, pTaskInfo); + } + + return sysTableScanFillTbName(pOperator, pInfo, name, pBlock); +} + +static SSDataBlock* sysTableScanFillTbName(SOperatorInfo* pOperator, const SSysTableScanInfo* pInfo, + const char* name, SSDataBlock* pBlock) { + if (pBlock != NULL) { + if (pInfo->tbnameSlotId != -1) { + SColumnInfoData* pColumnInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, pInfo->tbnameSlotId); + char varTbName[TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE] = {0}; + memcpy(varDataVal(varTbName), name, strlen(name)); + varDataSetLen(varTbName, strlen(name)); + for (int i = 0; i < pBlock->info.rows; ++i) { + colDataAppend(pColumnInfoData, i, varTbName, NULL); + } + doFilterResult(pBlock, pOperator->exprSupp.pFilterInfo); + } + } + if (pBlock && pBlock->info.rows != 0) { + return pBlock; + } else { + return NULL; + } +} + +static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableScanInfo* pInfo, const char* name, + SExecTaskInfo* pTaskInfo) { + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } + + while (1) { + int64_t startTs = taosGetTimestampUs(); + tstrncpy(pInfo->req.tb, tNameGetTableName(&pInfo->name), tListLen(pInfo->req.tb)); + tstrncpy(pInfo->req.user, pInfo->pUser, tListLen(pInfo->req.user)); + + int32_t contLen = tSerializeSRetrieveTableReq(NULL, 0, &pInfo->req); + char* buf1 = taosMemoryCalloc(1, contLen); + tSerializeSRetrieveTableReq(buf1, contLen, &pInfo->req); + + // send the fetch remote task result reques + SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); + if (NULL == pMsgSendInfo) { + qError("%s prepare message %d failed", GET_TASKID(pTaskInfo), (int32_t)sizeof(SMsgSendInfo)); + pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; return NULL; } - while (1) { - int64_t startTs = taosGetTimestampUs(); - tstrncpy(pInfo->req.tb, tNameGetTableName(&pInfo->name), tListLen(pInfo->req.tb)); - tstrncpy(pInfo->req.user, pInfo->pUser, tListLen(pInfo->req.user)); + int32_t msgType = (strcasecmp(name, TSDB_INS_TABLE_DNODE_VARIABLES) == 0) ? TDMT_DND_SYSTABLE_RETRIEVE + : TDMT_MND_SYSTABLE_RETRIEVE; - int32_t contLen = tSerializeSRetrieveTableReq(NULL, 0, &pInfo->req); - char* buf1 = taosMemoryCalloc(1, contLen); - tSerializeSRetrieveTableReq(buf1, contLen, &pInfo->req); + pMsgSendInfo->param = pOperator; + pMsgSendInfo->msgInfo.pData = buf1; + pMsgSendInfo->msgInfo.len = contLen; + pMsgSendInfo->msgType = msgType; + pMsgSendInfo->fp = loadSysTableCallback; + pMsgSendInfo->requestId = pTaskInfo->id.queryId; - // send the fetch remote task result reques - SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); - if (NULL == pMsgSendInfo) { - qError("%s prepare message %d failed", GET_TASKID(pTaskInfo), (int32_t)sizeof(SMsgSendInfo)); - pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; + int64_t transporterId = 0; + int32_t code = + asyncSendMsgToServer(pInfo->readHandle.pMsgCb->clientRpc, &pInfo->epSet, &transporterId, pMsgSendInfo); + tsem_wait(&pInfo->ready); + + if (pTaskInfo->code) { + qDebug("%s load meta data from mnode failed, totalRows:%" PRIu64 ", code:%s", GET_TASKID(pTaskInfo), + pInfo->loadInfo.totalRows, tstrerror(pTaskInfo->code)); + return NULL; + } + + SRetrieveMetaTableRsp* pRsp = pInfo->pRsp; + pInfo->req.showId = pRsp->handle; + + if (pRsp->numOfRows == 0 || pRsp->completed) { + pOperator->status = OP_EXEC_DONE; + qDebug("%s load meta data from mnode completed, rowsOfSource:%d, totalRows:%" PRIu64, GET_TASKID(pTaskInfo), + pRsp->numOfRows, pInfo->loadInfo.totalRows); + + if (pRsp->numOfRows == 0) { + taosMemoryFree(pRsp); return NULL; } + } - int32_t msgType = (strcasecmp(name, TSDB_INS_TABLE_DNODE_VARIABLES) == 0) ? TDMT_DND_SYSTABLE_RETRIEVE - : TDMT_MND_SYSTABLE_RETRIEVE; + char* pStart = pRsp->data; + extractDataBlockFromFetchRsp(pInfo->pRes, pRsp->data, pInfo->matchInfo.pList, &pStart); + updateLoadRemoteInfo(&pInfo->loadInfo, pRsp->numOfRows, pRsp->compLen, startTs, pOperator); - pMsgSendInfo->param = pOperator; - pMsgSendInfo->msgInfo.pData = buf1; - pMsgSendInfo->msgInfo.len = contLen; - pMsgSendInfo->msgType = msgType; - pMsgSendInfo->fp = loadSysTableCallback; - pMsgSendInfo->requestId = pTaskInfo->id.queryId; - - int64_t transporterId = 0; - int32_t code = - asyncSendMsgToServer(pInfo->readHandle.pMsgCb->clientRpc, &pInfo->epSet, &transporterId, pMsgSendInfo); - tsem_wait(&pInfo->ready); - - if (pTaskInfo->code) { - qDebug("%s load meta data from mnode failed, totalRows:%" PRIu64 ", code:%s", GET_TASKID(pTaskInfo), - pInfo->loadInfo.totalRows, tstrerror(pTaskInfo->code)); - return NULL; - } - - SRetrieveMetaTableRsp* pRsp = pInfo->pRsp; - pInfo->req.showId = pRsp->handle; - - if (pRsp->numOfRows == 0 || pRsp->completed) { - pOperator->status = OP_EXEC_DONE; - qDebug("%s load meta data from mnode completed, rowsOfSource:%d, totalRows:%" PRIu64, GET_TASKID(pTaskInfo), - pRsp->numOfRows, pInfo->loadInfo.totalRows); - - if (pRsp->numOfRows == 0) { - taosMemoryFree(pRsp); - return NULL; - } - } - - char* pStart = pRsp->data; - extractDataBlockFromFetchRsp(pInfo->pRes, pRsp->data, pInfo->matchInfo.pList, &pStart); - updateLoadRemoteInfo(&pInfo->loadInfo, pRsp->numOfRows, pRsp->compLen, startTs, pOperator); - - // todo log the filter info - doFilterResult(pInfo->pRes, pOperator->exprSupp.pFilterInfo); - taosMemoryFree(pRsp); - if (pInfo->pRes->info.rows > 0) { - return pInfo->pRes; - } else if (pOperator->status == OP_EXEC_DONE) { - return NULL; - } + // todo log the filter info + doFilterResult(pInfo->pRes, pOperator->exprSupp.pFilterInfo); + taosMemoryFree(pRsp); + if (pInfo->pRes->info.rows > 0) { + return pInfo->pRes; + } else if (pOperator->status == OP_EXEC_DONE) { + return NULL; } } } @@ -1407,6 +1442,8 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan goto _error; } + extractTbnameSlotId(pInfo, pScanNode); + pInfo->accountId = pScanPhyNode->accountId; pInfo->pUser = taosMemoryStrDup((void*)pUser); pInfo->sysInfo = pScanPhyNode->sysInfo; @@ -1449,6 +1486,26 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan return NULL; } +void extractTbnameSlotId(SSysTableScanInfo* pInfo, const SScanPhysiNode* pScanNode) { + pInfo->tbnameSlotId = -1; + if (pScanNode->pScanPseudoCols != NULL) { + SNode* pNode = NULL; + FOREACH(pNode, pScanNode->pScanPseudoCols) { + STargetNode* pTargetNode = NULL; + if (nodeType(pNode) == QUERY_NODE_TARGET) { + pTargetNode = (STargetNode*)pNode; + SNode* expr = pTargetNode->pExpr; + if (nodeType(expr) == QUERY_NODE_FUNCTION) { + SFunctionNode* pFuncNode = (SFunctionNode*)expr; + if (pFuncNode->funcType == FUNCTION_TYPE_TBNAME) { + pInfo->tbnameSlotId = pTargetNode->slotId; + } + } + } + } + } +} + void destroySysScanOperator(void* param) { SSysTableScanInfo* pInfo = (SSysTableScanInfo*)param; tsem_destroy(&pInfo->ready); diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index ab1feabf60..2d921d43d3 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -39,14 +39,10 @@ static void doSetVal(SColumnInfoData* pDstColInfoData, int32_t rowIndex, const S static void setNotFillColumn(SFillInfo* pFillInfo, SColumnInfoData* pDstColInfo, int32_t rowIndex, int32_t colIdx) { SRowVal* p = NULL; - if (FILL_IS_ASC_FILL(pFillInfo)) { - if (pFillInfo->prev.key != 0) { - p = &pFillInfo->prev; // prev has been set value - } else { // otherwise, use the value in the next row - p = &pFillInfo->next; - } + if (pFillInfo->type == TSDB_FILL_NEXT) { + p = FILL_IS_ASC_FILL(pFillInfo) ? &pFillInfo->next : &pFillInfo->prev; } else { - p = &pFillInfo->next; + p = FILL_IS_ASC_FILL(pFillInfo) ? &pFillInfo->prev : &pFillInfo->next; } SGroupKeys* pKey = taosArrayGet(p->pRowVal, colIdx); @@ -257,9 +253,16 @@ static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, int32_t rowIndex, SRowVa for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) { int32_t type = pFillInfo->pFillCol[i].pExpr->pExpr->nodeType; - if (type == QUERY_NODE_COLUMN || type == QUERY_NODE_OPERATOR || type == QUERY_NODE_FUNCTION) { + if ( type == QUERY_NODE_COLUMN || type == QUERY_NODE_OPERATOR || type == QUERY_NODE_FUNCTION) { + if (!pFillInfo->pFillCol[i].notFillCol && pFillInfo->type != TSDB_FILL_NEXT) { + continue; + } int32_t srcSlotId = GET_DEST_SLOT_ID(&pFillInfo->pFillCol[i]); + if (srcSlotId == pFillInfo->srcTsSlotId && pFillInfo->type == TSDB_FILL_LINEAR) { + continue; + } + SColumnInfoData* pSrcCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, srcSlotId); bool isNull = colDataIsNull_s(pSrcCol, rowIndex); @@ -288,8 +291,12 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t int64_t ts = ((int64_t*)pTsCol->pData)[pFillInfo->index]; // set the next value for interpolation - if ((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) { - copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, &pFillInfo->next); + if (pFillInfo->currentKey < ts && ascFill) { + SRowVal* pRVal = pFillInfo->type == TSDB_FILL_NEXT ? &pFillInfo->next : &pFillInfo->prev; + copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, pRVal); + } else if (pFillInfo->currentKey > ts && !ascFill) { + SRowVal* pRVal = pFillInfo->type == TSDB_FILL_NEXT ? &pFillInfo->prev : &pFillInfo->next; + copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, pRVal); } if (((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) && diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 0de38fe500..d78e9c4edf 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -22,7 +22,7 @@ #include "tfill.h" #include "ttime.h" -#define IS_FINAL_OP(op) ((op)->isFinal) +#define IS_FINAL_OP(op) ((op)->isFinal) #define DEAULT_DELETE_MARK (1000LL * 60LL * 60LL * 24LL * 365LL * 10LL); typedef struct SSessionAggOperatorInfo { @@ -119,8 +119,8 @@ static void doKeepNewWindowStartInfo(SWindowRowsSup* pRowSup, const int64_t* tsL pRowSup->groupId = groupId; } -static FORCE_INLINE int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn_t searchFn, TSKEY ekey, - int16_t pos, int16_t order, int64_t* pData) { +FORCE_INLINE int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn_t searchFn, TSKEY ekey, + int32_t pos, int32_t order, int64_t* pData) { int32_t forwardRows = 0; if (order == TSDB_ORDER_ASC) { @@ -636,6 +636,10 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num } SResultRow* pr = getResultRowByPos(pInfo->aggSup.pResultBuf, p1, false); + if (NULL == pr) { + T_LONG_JMP(pTaskInfo->env, terrno); + } + ASSERT(pr->offset == p1->offset && pr->pageId == p1->pageId); if (pr->closed) { @@ -666,8 +670,8 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num setNotInterpoWindowKey(pSup->pCtx, numOfExprs, RESULT_ROW_START_INTERP); updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &w, true); - applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, 0, pBlock->info.rows, - numOfExprs); + applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, 0, + pBlock->info.rows, numOfExprs); if (isResultRowInterpolated(pResult, RESULT_ROW_END_INTERP)) { closeResultRow(pr); @@ -817,13 +821,13 @@ static int32_t savePullWindow(SPullWindowInfo* pPullInfo, SArray* pPullWins) { } else { int32_t code = comparePullWinKey(pPullInfo, pPullWins, index); if (code == 0) { - SPullWindowInfo* pos = taosArrayGet(pPullWins ,index); + SPullWindowInfo* pos = taosArrayGet(pPullWins, index); pos->window.skey = TMIN(pos->window.skey, pPullInfo->window.skey); pos->window.ekey = TMAX(pos->window.ekey, pPullInfo->window.ekey); pos->calWin.skey = TMIN(pos->calWin.skey, pPullInfo->calWin.skey); pos->calWin.ekey = TMAX(pos->calWin.ekey, pPullInfo->calWin.ekey); return TSDB_CODE_SUCCESS; - } else if (code > 0 ){ + } else if (code > 0) { index++; } } @@ -879,10 +883,10 @@ int32_t compareWinRes(void* pKey, void* data, int32_t index) { } else if (pRKey->groupId < pDataPos->groupId) { return -1; } - + if (*(int64_t*)pRKey->key > pDataPos->ts) { return 1; - } else if (*(int64_t*)pRKey->key < pDataPos->ts){ + } else if (*(int64_t*)pRKey->key < pDataPos->ts) { return -1; } return 0; @@ -961,8 +965,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul } updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, true); - applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, pBlock->info.rows, - numOfOutput); + applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, + pBlock->info.rows, numOfOutput); doCloseWindow(pResultRowInfo, pInfo, pResult); @@ -996,8 +1000,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul } #endif updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true); - applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, pBlock->info.rows, - numOfOutput); + applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, + pBlock->info.rows, numOfOutput); doCloseWindow(pResultRowInfo, pInfo, pResult); } @@ -1164,7 +1168,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &window, false); applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, pRowSup->startRowIndex, - pRowSup->numOfRows, pBlock->info.rows, numOfOutput); + pRowSup->numOfRows, pBlock->info.rows, numOfOutput); // here we start a new session window doKeepNewWindowStartInfo(pRowSup, tsList, j, gid); @@ -1188,8 +1192,8 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI } updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pRowSup->win, false); - applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, pRowSup->startRowIndex, pRowSup->numOfRows, - pBlock->info.rows, numOfOutput); + applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, pRowSup->startRowIndex, + pRowSup->numOfRows, pBlock->info.rows, numOfOutput); } static int32_t openStateWindowAggOptr(SOperatorInfo* pOperator) { @@ -1315,6 +1319,10 @@ static void setInverFunction(SqlFunctionCtx* pCtx, int32_t num, EStreamType type static void doClearWindowImpl(SResultRowPosition* p1, SDiskbasedBuf* pResultBuf, SExprSupp* pSup, int32_t numOfOutput) { SResultRow* pResult = getResultRowByPos(pResultBuf, p1, false); + if (NULL == pResult) { + return; + } + SqlFunctionCtx* pCtx = pSup->pCtx; for (int32_t i = 0; i < numOfOutput; ++i) { pCtx[i].resultInfo = getResultEntryInfo(pResult, i, pSup->rowEntryInfoOffset); @@ -1328,6 +1336,9 @@ static void doClearWindowImpl(SResultRowPosition* p1, SDiskbasedBuf* pResultBuf, } } SFilePage* bufPage = getBufPage(pResultBuf, p1->pageId); + if (NULL == bufPage) { + return; + } setBufPageDirty(bufPage, true); releaseBufPage(pResultBuf, bufPage); } @@ -1394,8 +1405,8 @@ static int32_t getAllIntervalWindow(SSHashObj* pHashMap, SHashObj* resWins) { size_t keyLen = 0; int32_t iter = 0; while ((pIte = tSimpleHashIterate(pHashMap, pIte, &iter)) != NULL) { - void* key = tSimpleHashGetKey(pIte, &keyLen); - uint64_t groupId = *(uint64_t*)key; + void* key = tSimpleHashGetKey(pIte, &keyLen); + uint64_t groupId = *(uint64_t*)key; TSKEY ts = *(int64_t*)((char*)key + sizeof(uint64_t)); SResultRowPosition* pPos = (SResultRowPosition*)pIte; int32_t code = saveWinResult(ts, pPos->pageId, pPos->offset, groupId, resWins); @@ -1656,7 +1667,7 @@ static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SInt // the primary timestamp column bool needed = false; - for(int32_t i = 0; i < numOfCols; ++i) { + for (int32_t i = 0; i < numOfCols; ++i) { SExprInfo* pExpr = pCtx[i].pExpr; if (fmIsIntervalInterpoFunc(pCtx[i].functionId)) { needed = true; @@ -1724,7 +1735,7 @@ void initIntervalDownStream(SOperatorInfo* downstream, uint16_t type, SAggSuppor void initStreamFunciton(SqlFunctionCtx* pCtx, int32_t numOfExpr) { for (int32_t i = 0; i < numOfExpr; i++) { -// pCtx[i].isStream = true; + // pCtx[i].isStream = true; } } @@ -1748,7 +1759,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh int32_t num = 0; SExprInfo* pExprInfo = createExprInfo(pPhyNode->window.pFuncs, NULL, &num); - int32_t code = initAggSup(pSup, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str); + int32_t code = + initAggSup(pSup, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str, pTaskInfo->streamInfo.pState); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -1800,8 +1812,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh setOperatorInfo(pOperator, "TimeIntervalAggOperator", QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL, true, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = - createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, NULL, destroyIntervalOperatorInfo, optrDefaultBufFn, NULL); + pOperator->fpSet = createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, NULL, destroyIntervalOperatorInfo, + optrDefaultBufFn, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -1869,7 +1881,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator // pInfo->numOfRows data belong to the current session window updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &window, false); applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, pRowSup->startRowIndex, - pRowSup->numOfRows, pBlock->info.rows, numOfOutput); + pRowSup->numOfRows, pBlock->info.rows, numOfOutput); // here we start a new session window doKeepNewWindowStartInfo(pRowSup, tsList, j, gid); @@ -1886,8 +1898,8 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator } updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pRowSup->win, false); - applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, pRowSup->startRowIndex, pRowSup->numOfRows, - pBlock->info.rows, numOfOutput); + applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, pRowSup->startRowIndex, + pRowSup->numOfRows, pBlock->info.rows, numOfOutput); } static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) { @@ -2000,7 +2012,8 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi SExprInfo* pExprInfo = createExprInfo(pStateNode->window.pFuncs, NULL, &num); initResultSizeInfo(&pOperator->resultInfo, 4096); - code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str); + code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str, + pTaskInfo->streamInfo.pState); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -2018,8 +2031,8 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi setOperatorInfo(pOperator, "StateWindowOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE, true, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = - createOperatorFpSet(openStateWindowAggOptr, doStateWindowAgg, NULL, destroyStateWindowOperatorInfo, optrDefaultBufFn, NULL); + pOperator->fpSet = createOperatorFpSet(openStateWindowAggOptr, doStateWindowAgg, NULL, destroyStateWindowOperatorInfo, + optrDefaultBufFn, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -2068,7 +2081,8 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SSessionW SSDataBlock* pResBlock = createDataBlockFromDescNode(pSessionNode->window.node.pOutputDataBlockDesc); initBasicInfo(&pInfo->binfo, pResBlock); - int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str); + int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str, + pTaskInfo->streamInfo.pState); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -2091,8 +2105,8 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SSessionW setOperatorInfo(pOperator, "SessionWindowAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION, true, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = - createOperatorFpSet(optrDummyOpenFn, doSessionWindowAgg, NULL, destroySWindowOperatorInfo, optrDefaultBufFn, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doSessionWindowAgg, NULL, destroySWindowOperatorInfo, + optrDefaultBufFn, NULL); pOperator->pTaskInfo = pTaskInfo; code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -2309,7 +2323,8 @@ static void addRetriveWindow(SArray* wins, SStreamIntervalOperatorInfo* pInfo) { if (needDeleteWindowBuf(&nextWin, &pInfo->twAggSup) && !pInfo->ignoreExpiredData) { void* chIds = taosHashGet(pInfo->pPullDataMap, winKey, sizeof(SWinKey)); if (!chIds) { - SPullWindowInfo pull = {.window = nextWin, .groupId = winKey->groupId, .calWin.skey = nextWin.skey, .calWin.ekey = nextWin.skey}; + SPullWindowInfo pull = { + .window = nextWin, .groupId = winKey->groupId, .calWin.skey = nextWin.skey, .calWin.ekey = nextWin.skey}; // add pull data request if (savePullWindow(&pull, pInfo->pPullWins) == TSDB_CODE_SUCCESS) { int32_t size1 = taosArrayGetSize(pInfo->pChildren); @@ -2395,7 +2410,8 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p }; void* chIds = taosHashGet(pInfo->pPullDataMap, &winRes, sizeof(SWinKey)); if (isDeletedStreamWindow(&nextWin, groupId, pInfo->pState, &pInfo->twAggSup) && !chIds) { - SPullWindowInfo pull = {.window = nextWin, .groupId = groupId, .calWin.skey = nextWin.skey, .calWin.ekey = nextWin.skey}; + SPullWindowInfo pull = { + .window = nextWin, .groupId = groupId, .calWin.skey = nextWin.skey, .calWin.ekey = nextWin.skey}; // add pull data request if (savePullWindow(&pull, pInfo->pPullWins) == TSDB_CODE_SUCCESS) { int32_t size = taosArrayGetSize(pInfo->pChildren); @@ -2450,7 +2466,7 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p } updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true); applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, - pSDataBlock->info.rows, numOfOutput); + pSDataBlock->info.rows, numOfOutput); SWinKey key = { .ts = nextWin.skey, .groupId = groupId, @@ -2545,7 +2561,8 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); if (pBlock == NULL) { pOperator->status = OP_RES_TO_RETURN; - qDebug("===stream===return data:%s. recv datablock num:%" PRIu64 , IS_FINAL_OP(pInfo) ? "interval final" : "interval semi", pInfo->numOfDatapack); + qDebug("===stream===return data:%s. recv datablock num:%" PRIu64, + IS_FINAL_OP(pInfo) ? "interval final" : "interval semi", pInfo->numOfDatapack); pInfo->numOfDatapack = 0; break; } @@ -2665,7 +2682,7 @@ int64_t getDeleteMark(SIntervalPhysiNode* pIntervalPhyNode) { if (pIntervalPhyNode->window.deleteMark <= 0) { return DEAULT_DELETE_MARK; } - int64_t deleteMark = TMAX(pIntervalPhyNode->window.deleteMark,pIntervalPhyNode->window.watermark); + int64_t deleteMark = TMAX(pIntervalPhyNode->window.deleteMark, pIntervalPhyNode->window.watermark); deleteMark = TMAX(deleteMark, pIntervalPhyNode->interval); return deleteMark; } @@ -2713,7 +2730,8 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pResBlock = createDataBlockFromDescNode(pPhyNode->pOutputDataBlockDesc); initBasicInfo(&pInfo->binfo, pResBlock); - int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str); + int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str, + pTaskInfo->streamInfo.pState); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -2778,8 +2796,8 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, pOperator->status = OP_NOT_OPENED; pOperator->info = pInfo; - pOperator->fpSet = - createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, destroyStreamFinalIntervalOperatorInfo, optrDefaultBufFn, NULL); + pOperator->fpSet = createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, destroyStreamFinalIntervalOperatorInfo, + optrDefaultBufFn, NULL); if (pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL) { initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, &pInfo->twAggSup); } @@ -3578,8 +3596,8 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh setOperatorInfo(pOperator, "StreamSessionWindowAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION, true, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = - createOperatorFpSet(optrDummyOpenFn, doStreamSessionAgg, NULL, destroyStreamSessionAggOperatorInfo, optrDefaultBufFn, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doStreamSessionAgg, NULL, destroyStreamSessionAggOperatorInfo, + optrDefaultBufFn, NULL); if (downstream) { initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup); @@ -4083,8 +4101,8 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys setOperatorInfo(pOperator, "StreamStateAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE, true, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = - createOperatorFpSet(optrDummyOpenFn, doStreamStateAgg, NULL, destroyStreamStateOperatorInfo, optrDefaultBufFn, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doStreamStateAgg, NULL, destroyStreamStateOperatorInfo, + optrDefaultBufFn, NULL); initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -4107,6 +4125,9 @@ void destroyMAIOperatorInfo(void* param) { static SResultRow* doSetSingleOutputTupleBuf(SResultRowInfo* pResultRowInfo, SAggSupporter* pSup) { SResultRow* pResult = getNewResultRow(pSup->pResultBuf, &pSup->currentPageId, pSup->resultRowSize); + if (NULL == pResult) { + return pResult; + } pResultRowInfo->cur = (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset}; return pResult; } @@ -4169,8 +4190,8 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR } updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &currWin, true); - applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &iaInfo->twAggSup.timeWindowData, startPos, currPos - startPos, - pBlock->info.rows, pSup->numOfExprs); + applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &iaInfo->twAggSup.timeWindowData, startPos, + currPos - startPos, pBlock->info.rows, pSup->numOfExprs); finalizeResultRows(iaInfo->aggSup.pResultBuf, &pResultRowInfo->cur, pSup, pResultBlock, pTaskInfo); resetResultRow(miaInfo->pResultRow, iaInfo->aggSup.resultRowSize - sizeof(SResultRow)); @@ -4190,7 +4211,7 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &currWin, true); applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &iaInfo->twAggSup.timeWindowData, startPos, currPos - startPos, - pBlock->info.rows, pSup->numOfExprs); + pBlock->info.rows, pSup->numOfExprs); } static void cleanupAfterGroupResultGen(SMergeAlignedIntervalAggOperatorInfo* pMiaInfo, SSDataBlock* pRes) { @@ -4341,7 +4362,8 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, int32_t num = 0; SExprInfo* pExprInfo = createExprInfo(pNode->window.pFuncs, NULL, &num); - code = initAggSup(&pOperator->exprSupp, &iaInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str); + code = initAggSup(&pOperator->exprSupp, &iaInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str, + pTaskInfo->streamInfo.pState); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -4360,8 +4382,8 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, setOperatorInfo(pOperator, "TimeMergeAlignedIntervalAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL, false, OP_NOT_OPENED, miaInfo, pTaskInfo); - pOperator->fpSet = - createOperatorFpSet(optrDummyOpenFn, mergeAlignedIntervalAgg, NULL, destroyMAIOperatorInfo, optrDefaultBufFn, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, mergeAlignedIntervalAgg, NULL, destroyMAIOperatorInfo, + optrDefaultBufFn, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -4496,7 +4518,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &win, true); applyAggFunctionOnPartialTuples(pTaskInfo, pExprSup->pCtx, &iaInfo->twAggSup.timeWindowData, startPos, forwardRows, - pBlock->info.rows, numOfOutput); + pBlock->info.rows, numOfOutput); doCloseWindow(pResultRowInfo, iaInfo, pResult); // output previous interval results after this interval (&win) is closed @@ -4528,7 +4550,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &nextWin, true); applyAggFunctionOnPartialTuples(pTaskInfo, pExprSup->pCtx, &iaInfo->twAggSup.timeWindowData, startPos, forwardRows, - pBlock->info.rows, numOfOutput); + pBlock->info.rows, numOfOutput); doCloseWindow(pResultRowInfo, iaInfo, pResult); // output previous interval results after this interval (&nextWin) is closed @@ -4645,7 +4667,8 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; initResultSizeInfo(&pOperator->resultInfo, 4096); - int32_t code = initAggSup(pExprSupp, &pIntervalInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str); + int32_t code = initAggSup(pExprSupp, &pIntervalInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str, + pTaskInfo->streamInfo.pState); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -4665,8 +4688,8 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge initResultRowInfo(&pIntervalInfo->binfo.resultRowInfo); setOperatorInfo(pOperator, "TimeMergeIntervalAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL, false, OP_NOT_OPENED, pMergeIntervalInfo, pTaskInfo); - pOperator->fpSet = - createOperatorFpSet(optrDummyOpenFn, doMergeIntervalAgg, NULL, destroyMergeIntervalOperatorInfo, optrDefaultBufFn, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doMergeIntervalAgg, NULL, destroyMergeIntervalOperatorInfo, + optrDefaultBufFn, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -4843,7 +4866,8 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys initResultSizeInfo(&pOperator->resultInfo, 4096); size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; - code = initAggSup(pSup, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str); + code = initAggSup(pSup, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str, + pTaskInfo->streamInfo.pState); if (code != TSDB_CODE_SUCCESS) { goto _error; } diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index fa0cdb3943..06ef36664a 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -270,6 +270,10 @@ static int32_t sortComparInit(SMsortComparParam* pParam, SArray* pSources, int32 int32_t* pPgId = taosArrayGet(pSource->pageIdList, pSource->pageIndex); void* pPage = getBufPage(pHandle->pBuf, *pPgId); + if (NULL == pPage) { + return terrno; + } + code = blockDataFromBuf(pSource->src.pBlock, pPage); if (code != TSDB_CODE_SUCCESS) { return code; @@ -337,6 +341,11 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource* pSource, SMultiwayMergeT int32_t* pPgId = taosArrayGet(pSource->pageIdList, pSource->pageIndex); void* pPage = getBufPage(pHandle->pBuf, *pPgId); + if (pPage == NULL) { + qError("failed to get buffer, code:%s", tstrerror(terrno)); + return terrno; + } + int32_t code = blockDataFromBuf(pSource->src.pBlock, pPage); if (code != TSDB_CODE_SUCCESS) { return code; diff --git a/source/libs/executor/test/executorTests.cpp b/source/libs/executor/test/executorTests.cpp index 2efd06f440..913aae6cc3 100644 --- a/source/libs/executor/test/executorTests.cpp +++ b/source/libs/executor/test/executorTests.cpp @@ -43,6 +43,19 @@ enum { data_desc = 0x3, }; +TEST(testCase, windowFunctionTest) { + int64_t tsCol[100000]; + int32_t rows = 100000; + for (int32_t i = 0; i < rows; i++) { + tsCol[i] = 1648791213000 + i; + } + int32_t ekeyNum = 50000; + int32_t pos = 40000; + int64_t ekey = tsCol[ekeyNum]; + int32_t num = getForwardStepsInBlock(rows, binarySearchForKey, ekey, pos, TSDB_ORDER_ASC, tsCol); + ASSERT_EQ(num, ekeyNum - pos + 1); +} + typedef struct SDummyInputInfo { int32_t totalPages; // numOfPages int32_t current; diff --git a/source/libs/function/inc/builtinsimpl.h b/source/libs/function/inc/builtinsimpl.h index a7ac53fab6..cbda8dc472 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -32,7 +32,7 @@ typedef struct SSumRes { int16_t type; int64_t prevTs; bool isPrevTsSet; - bool overflow; // if overflow is true, dsum to be used for any type; + bool overflow; // if overflow is true, dsum to be used for any type; } SSumRes; typedef struct SMinmaxResInfo { @@ -46,7 +46,7 @@ typedef struct SMinmaxResInfo { } SMinmaxResInfo; int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc); -STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, const STupleKey* pKey); +STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock); int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos); const char* loadTupleData(SqlFunctionCtx* pCtx, const STuplePos* pPos); diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index a1e39b3548..51945d6a0a 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -41,15 +41,15 @@ #define HLL_BUCKET_MASK (HLL_BUCKETS - 1) #define HLL_ALPHA_INF 0.721347520444481703680 // constant for 0.5/ln(2) -//typedef struct SMinmaxResInfo { -// bool assign; // assign the first value or not -// int64_t v; -// STuplePos tuplePos; +// typedef struct SMinmaxResInfo { +// bool assign; // assign the first value or not +// int64_t v; +// STuplePos tuplePos; // -// STuplePos nullTuplePos; -// bool nullTupleSaved; -// int16_t type; -//} SMinmaxResInfo; +// STuplePos nullTuplePos; +// bool nullTupleSaved; +// int16_t type; +// } SMinmaxResInfo; typedef struct STopBotResItem { SVariant v; @@ -540,7 +540,7 @@ int32_t countFunction(SqlFunctionCtx* pCtx) { if (IS_NULL_TYPE(type)) { // select count(NULL) returns 0 numOfElem = 1; - *((int64_t*)buf) = 0; + *((int64_t*)buf) += 0; } else { numOfElem = getNumOfElems(pCtx); *((int64_t*)buf) += numOfElem; @@ -784,7 +784,7 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { pEntryInfo->isNullRes = (pEntryInfo->numOfRes == 0) ? 1 : 0; if (pCol->info.type == TSDB_DATA_TYPE_FLOAT) { - float v = *(float*)&pRes->v; + float v = GET_FLOAT_VAL(&pRes->v); colDataAppend(pCol, currentRow, (const char*)&v, pEntryInfo->isNullRes); } else { colDataAppend(pCol, currentRow, (const char*)&pRes->v, pEntryInfo->isNullRes); @@ -818,28 +818,31 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple return; } - if (pCtx->saveHandle.pBuf != NULL) { - if (pTuplePos->pageId != -1) { - int32_t numOfCols = pCtx->subsidiaries.num; - const char* p = loadTupleData(pCtx, pTuplePos); + if ((pCtx->saveHandle.pBuf != NULL && pTuplePos->pageId != -1) || + (pCtx->saveHandle.pState && pTuplePos->streamTupleKey.ts > 0)) { + int32_t numOfCols = pCtx->subsidiaries.num; + const char* p = loadTupleData(pCtx, pTuplePos); - bool* nullList = (bool*)p; - char* pStart = (char*)(nullList + numOfCols * sizeof(bool)); + bool* nullList = (bool*)p; + char* pStart = (char*)(nullList + numOfCols * sizeof(bool)); - // todo set the offset value to optimize the performance. - for (int32_t j = 0; j < numOfCols; ++j) { - SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j]; - int32_t dstSlotId = pc->pExpr->base.resSchema.slotId; + // todo set the offset value to optimize the performance. + for (int32_t j = 0; j < numOfCols; ++j) { + SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j]; + int32_t dstSlotId = pc->pExpr->base.resSchema.slotId; - SColumnInfoData* pDstCol = taosArrayGet(pBlock->pDataBlock, dstSlotId); - ASSERT(pc->pExpr->base.resSchema.bytes == pDstCol->info.bytes); - if (nullList[j]) { - colDataAppendNULL(pDstCol, rowIndex); - } else { - colDataAppend(pDstCol, rowIndex, pStart, false); - } - pStart += pDstCol->info.bytes; + SColumnInfoData* pDstCol = taosArrayGet(pBlock->pDataBlock, dstSlotId); + ASSERT(pc->pExpr->base.resSchema.bytes == pDstCol->info.bytes); + if (nullList[j]) { + colDataAppendNULL(pDstCol, rowIndex); + } else { + colDataAppend(pDstCol, rowIndex, pStart, false); } + pStart += pDstCol->info.bytes; + } + + if (pCtx->saveHandle.pState) { + tdbFree((void*)p); } } } @@ -2018,7 +2021,7 @@ static void firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowInde } if (!pInfo->hasResult) { - pInfo->pos = saveTupleData(pCtx, rowIndex, pSrcBlock, NULL); + pInfo->pos = saveTupleData(pCtx, rowIndex, pSrcBlock); } else { updateTupleData(pCtx, rowIndex, pSrcBlock, &pInfo->pos); } @@ -2071,8 +2074,8 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC; - // please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first function. - // we will use this opt implementation in an new version that is only available in scan subplan + // please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first + // function. we will use this opt implementation in an new version that is only available in scan subplan #if 0 if (blockDataOrder == TSDB_ORDER_ASC) { // filter according to current result firstly @@ -2179,7 +2182,8 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC; - // please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first function. + // please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first + // function. #if 0 if (blockDataOrder == TSDB_ORDER_ASC) { for (int32_t i = pInput->numOfRows + pInput->startRowIndex - 1; i >= pInput->startRowIndex; --i) { @@ -2236,9 +2240,9 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { int32_t round = pInput->numOfRows >> 2; int32_t reminder = pInput->numOfRows & 0x03; - for (int32_t i = pInput->startRowIndex, tick = 0; tick < round; i += 4, tick += 1) { - int64_t cts = pts[i]; - int32_t chosen = i; + for (int32_t i = pInput->startRowIndex, tick = 0; tick < round; i += 4, tick += 1) { + int64_t cts = pts[i]; + int32_t chosen = i; if (cts < pts[i + 1]) { cts = pts[i + 1]; @@ -2262,18 +2266,18 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { } } - for (int32_t i = pInput->startRowIndex + round * 4; i < pInput->startRowIndex + pInput->numOfRows; ++i) { - if (pResInfo->numOfRes == 0 || pInfo->ts < pts[i]) { - char* data = colDataGetData(pInputCol, i); - doSaveCurrentVal(pCtx, i, pts[i], type, data); - pResInfo->numOfRes = 1; - } + for (int32_t i = pInput->startRowIndex + round * 4; i < pInput->startRowIndex + pInput->numOfRows; ++i) { + if (pResInfo->numOfRes == 0 || pInfo->ts < pts[i]) { + char* data = colDataGetData(pInputCol, i); + doSaveCurrentVal(pCtx, i, pts[i], type, data); + pResInfo->numOfRes = 1; + } + } + } else { + for (int32_t i = pInput->startRowIndex; i < pInput->startRowIndex + pInput->numOfRows; ++i) { + if (colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) { + continue; } - } else { - for (int32_t i = pInput->startRowIndex; i < pInput->startRowIndex + pInput->numOfRows; ++i) { - if (colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) { - continue; - } numOfElems++; @@ -2439,7 +2443,7 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pInputCol = pInput->pData[0]; - int32_t type = pInputCol->info.type; + int32_t type = pInputCol->info.type; int32_t bytes = pInputCol->info.bytes; pInfo->bytes = bytes; @@ -2777,7 +2781,7 @@ int32_t topFunction(SqlFunctionCtx* pCtx) { } if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pRes->nullTupleSaved) { - pRes->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL); + pRes->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock); pRes->nullTupleSaved = true; } return TSDB_CODE_SUCCESS; @@ -2805,7 +2809,7 @@ int32_t bottomFunction(SqlFunctionCtx* pCtx) { } if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pRes->nullTupleSaved) { - pRes->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL); + pRes->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock); pRes->nullTupleSaved = true; } @@ -2863,7 +2867,7 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData // save the data of this tuple if (pCtx->subsidiaries.num > 0) { - pItem->tuplePos = saveTupleData(pCtx, rowIndex, pSrcBlock, NULL); + pItem->tuplePos = saveTupleData(pCtx, rowIndex, pSrcBlock); } #ifdef BUF_PAGE_DEBUG qDebug("page_saveTuple i:%d, item:%p,pageId:%d, offset:%d\n", pEntryInfo->numOfRes, pItem, pItem->tuplePos.pageId, @@ -2937,8 +2941,7 @@ void* serializeTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SSubsid return buf; } -static STuplePos doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length, - const STupleKey* pKey) { +static STuplePos doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length, STupleKey key) { STuplePos p = {0}; if (pHandle->pBuf != NULL) { SFilePage* pPage = NULL; @@ -2964,20 +2967,31 @@ static STuplePos doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf releaseBufPage(pHandle->pBuf, pPage); } else { // other tuple save policy - if (streamStateFuncPut(pHandle->pState, pKey, pBuf, length) < 0) { + if (streamStateFuncPut(pHandle->pState, &key, pBuf, length) < 0) { ASSERT(0); } - p.streamTupleKey = *pKey; + p.streamTupleKey = key; } return p; } -STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, const STupleKey* pKey) { +STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock) { prepareBuf(pCtx); + STupleKey key; + if (pCtx->saveHandle.pBuf == NULL) { + SColumnInfoData* pColInfo = taosArrayGet(pSrcBlock->pDataBlock, 0); + ASSERT(pColInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP); + int64_t skey = *(int64_t*)colDataGetData(pColInfo, rowIndex); + + key.groupId = pSrcBlock->info.id.groupId; + key.ts = skey; + key.exprIdx = pCtx->exprIdx; + } + char* buf = serializeTupleData(pSrcBlock, rowIndex, &pCtx->subsidiaries, pCtx->subsidiaries.buf); - return doSaveTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, pKey); + return doSaveTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, key); } static int32_t doUpdateTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length, STuplePos* pPos) { @@ -3623,7 +3637,7 @@ bool histogramFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultIn pInfo->totalCount = 0; pInfo->normalized = 0; - char *binTypeStr = strndup(varDataVal(pCtx->param[1].param.pz), varDataLen(pCtx->param[1].param.pz)); + char* binTypeStr = strndup(varDataVal(pCtx->param[1].param.pz), varDataLen(pCtx->param[1].param.pz)); int8_t binType = getHistogramBinType(binTypeStr); taosMemoryFree(binTypeStr); @@ -3947,7 +3961,6 @@ int32_t hllFunctionMerge(SqlFunctionCtx* pCtx) { int32_t start = pInput->startRowIndex; - for (int32_t i = start; i < start + pInput->numOfRows; ++i) { char* data = colDataGetData(pCol, i); SHLLInfo* pInputInfo = (SHLLInfo*)varDataVal(data); @@ -4423,7 +4436,7 @@ static void doReservoirSample(SqlFunctionCtx* pCtx, SSampleInfo* pInfo, char* da if (pInfo->numSampled < pInfo->samples) { sampleAssignResult(pInfo, data, pInfo->numSampled); if (pCtx->subsidiaries.num > 0) { - pInfo->tuplePos[pInfo->numSampled] = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL); + pInfo->tuplePos[pInfo->numSampled] = saveTupleData(pCtx, index, pCtx->pSrcBlock); } pInfo->numSampled++; } else { @@ -4454,7 +4467,7 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) { } if (pInfo->numSampled == 0 && pCtx->subsidiaries.num > 0 && !pInfo->nullTupleSaved) { - pInfo->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL); + pInfo->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock); pInfo->nullTupleSaved = true; } @@ -4758,7 +4771,7 @@ static void doModeAdd(SModeInfo* pInfo, int32_t rowIndex, SqlFunctionCtx* pCtx, pItem->count += 1; if (pCtx->subsidiaries.num > 0) { - pItem->tuplePos = saveTupleData(pCtx, rowIndex, pCtx->pSrcBlock, NULL); + pItem->tuplePos = saveTupleData(pCtx, rowIndex, pCtx->pSrcBlock); } taosHashPut(pInfo->pHash, data, hashKeyBytes, &pItem, sizeof(SModeItem*)); @@ -4798,7 +4811,7 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) { } if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pInfo->nullTupleSaved) { - pInfo->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL); + pInfo->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock); pInfo->nullTupleSaved = true; } @@ -5302,7 +5315,7 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t len = sprintf(st + VARSTR_HEADER_SIZE, "Total_Blocks=[%d] Total_Size=[%.2f Kb] Average_size=[%.2f Kb] Compression_Ratio=[%.2f %c]", - pData->numOfBlocks, pData->totalSize / 1024.0, averageSize/1024.0, compRatio, '%'); + pData->numOfBlocks, pData->totalSize / 1024.0, averageSize / 1024.0, compRatio, '%'); varDataSetLen(st, len); colDataAppend(pColInfo, row++, st, false); diff --git a/source/libs/function/src/detail/tminmax.c b/source/libs/function/src/detail/tminmax.c index cb5cea3cc8..3660ec272f 100644 --- a/source/libs/function/src/detail/tminmax.c +++ b/source/libs/function/src/detail/tminmax.c @@ -64,7 +64,7 @@ static void calculateRounds(int32_t numOfRows, int32_t bytes, int32_t* remainder, int32_t* rounds, int32_t* width) { const int32_t bitWidth = 256; - *width = (bitWidth>>3u) / bytes; + *width = (bitWidth >> 3u) / bytes; *remainder = numOfRows % (*width); *rounds = numOfRows / (*width); } @@ -92,8 +92,7 @@ static void calculateRounds(int32_t numOfRows, int32_t bytes, int32_t* remainder (_v) = (_sec)[j]; \ } \ } - - + static int8_t i8VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFunc, bool signVal) { int8_t v = 0; const int8_t* p = pData; @@ -116,7 +115,7 @@ static int8_t i8VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFu const int8_t* q = (const int8_t*)&initVal; EXTRACT_MAX_VAL(q, p, width, remain, v) - } else { // unsigned value + } else { // unsigned value for (int32_t i = 0; i < rounds; ++i) { next = _mm256_lddqu_si256((__m256i*)p); initVal = _mm256_max_epu8(initVal, next); @@ -126,7 +125,7 @@ static int8_t i8VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFu const uint8_t* q = (const uint8_t*)&initVal; EXTRACT_MAX_VAL(q, p, width, remain, v) } - + } else { // min function if (signVal) { for (int32_t i = 0; i < rounds; ++i) { @@ -241,7 +240,7 @@ static int32_t i32VectorCmpAVX2(const int32_t* pData, int32_t numOfRows, bool is // let compare the final results const int32_t* q = (const int32_t*)&initVal; EXTRACT_MAX_VAL(q, p, width, remain, v) - } else { // unsigned value + } else { // unsigned value for (int32_t i = 0; i < rounds; ++i) { next = _mm256_lddqu_si256((__m256i*)p); initVal = _mm256_max_epi32(initVal, next); @@ -281,7 +280,7 @@ static int32_t i32VectorCmpAVX2(const int32_t* pData, int32_t numOfRows, bool is } static float floatVectorCmpAVX(const float* pData, int32_t numOfRows, bool isMinFunc) { - float v = 0; + float v = 0; const float* p = pData; int32_t width, remain, rounds; @@ -358,7 +357,7 @@ static double doubleVectorCmpAVX(const double* pData, int32_t numOfRows, bool is static int32_t findFirstValPosition(const SColumnInfoData* pCol, int32_t start, int32_t numOfRows) { int32_t i = start; - + while (i < (start + numOfRows) && (colDataIsNull_f(pCol->nullbitmap, i) == true)) { i += 1; } @@ -495,7 +494,8 @@ static void handleInt64Col(const void* data, int32_t start, int32_t numOfRows, S } } -static void handleFloatCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf, bool isMinFunc) { +static void handleFloatCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf, + bool isMinFunc) { float* pData = (float*)pCol->pData; float* val = (float*)&pBuf->v; @@ -525,7 +525,8 @@ static void handleFloatCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRo pBuf->assign = true; } -static void handleDoubleCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf, bool isMinFunc) { +static void handleDoubleCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf, + bool isMinFunc) { double* pData = (double*)pCol->pData; double* val = (double*)&pBuf->v; @@ -736,11 +737,16 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { } if (!pBuf->assign) { - pBuf->v = *(int64_t*)tval; + if (type == TSDB_DATA_TYPE_FLOAT) { + GET_FLOAT_VAL(&pBuf->v) = GET_DOUBLE_VAL(tval); + } else { + pBuf->v = GET_INT64_VAL(tval); + } + if (pCtx->subsidiaries.num > 0) { index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); if (index >= 0) { - pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL); + pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock); } } } else { @@ -750,11 +756,11 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { int64_t val = GET_INT64_VAL(tval); if ((prev < val) ^ isMinFunc) { - *(int64_t*)&pBuf->v = val; + GET_INT64_VAL(&pBuf->v) = val; if (pCtx->subsidiaries.num > 0) { index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); if (index >= 0) { - pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL); + pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock); } } } @@ -764,11 +770,11 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { uint64_t val = GET_UINT64_VAL(tval); if ((prev < val) ^ isMinFunc) { - *(uint64_t*)&pBuf->v = val; + GET_UINT64_VAL(&pBuf->v) = val; if (pCtx->subsidiaries.num > 0) { index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); if (index >= 0) { - pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL); + pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock); } } } @@ -778,11 +784,11 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { double val = GET_DOUBLE_VAL(tval); if ((prev < val) ^ isMinFunc) { - *(double*)&pBuf->v = val; + GET_DOUBLE_VAL(&pBuf->v) = val; if (pCtx->subsidiaries.num > 0) { index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); if (index >= 0) { - pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL); + pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock); } } } @@ -792,13 +798,13 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { float val = GET_DOUBLE_VAL(tval); if ((prev < val) ^ isMinFunc) { - *(float*)&pBuf->v = val; + GET_FLOAT_VAL(&pBuf->v) = val; } if (pCtx->subsidiaries.num > 0) { index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); if (index >= 0) { - pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL); + pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock); } } } @@ -819,7 +825,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { memcpy(&pBuf->v, pCol->pData + (pCol->info.bytes * i), pCol->info.bytes); if (pCtx->subsidiaries.num > 0) { - pBuf->tuplePos = saveTupleData(pCtx, i, pCtx->pSrcBlock, NULL); + pBuf->tuplePos = saveTupleData(pCtx, i, pCtx->pSrcBlock); } pBuf->assign = true; numOfElems = 1; @@ -883,9 +889,9 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { _over: if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pBuf->nullTupleSaved) { - pBuf->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL); + pBuf->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock); pBuf->nullTupleSaved = true; } return numOfElems; -} \ No newline at end of file +} diff --git a/source/libs/function/src/tfunctionInt.c b/source/libs/function/src/tfunctionInt.c index 70378df0c3..3afa0e5cdd 100644 --- a/source/libs/function/src/tfunctionInt.c +++ b/source/libs/function/src/tfunctionInt.c @@ -20,7 +20,6 @@ #include "ttypes.h" #include "function.h" -#include "tbuffer.h" #include "tcompression.h" #include "tdatablock.h" #include "tfunctionInt.h" diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index acfd5c07af..c9fa70ff11 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -1230,7 +1230,6 @@ int32_t udfcGetUdfTaskResultFromUvTask(SClientUdfTask *task, SClientUvTaskNode * if (uvTask->rspBuf.base != NULL) { SUdfResponse rsp = {0}; void *buf = decodeUdfResponse(uvTask->rspBuf.base, &rsp); - assert(uvTask->rspBuf.len == POINTER_DISTANCE(buf, uvTask->rspBuf.base)); task->errCode = rsp.code; switch (task->type) { diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index 6c88e4d5c8..fe6ed7d785 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -400,7 +400,6 @@ void udfdProcessTeardownRequest(SUvUdfWork *uvUdf, SUdfRequest *request) { void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { SUdfdRpcSendRecvInfo *msgInfo = (SUdfdRpcSendRecvInfo *)pMsg->info.ahandle; - ASSERT(pMsg->info.ahandle != NULL); if (pEpSet) { if (!isEpsetEqual(&global.mgmtEp.epSet, pEpSet)) { @@ -461,13 +460,14 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { #else snprintf(path, sizeof(path), "%s/lib%s.so", tsTempDir, pFuncInfo->name); #endif - TdFilePtr file = - taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC | TD_FILE_AUTO_DEL); + + TdFilePtr file = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC); if (file == NULL) { fnError("udfd write udf shared library: %s failed, error: %d %s", path, errno, strerror(errno)); msgInfo->code = TSDB_CODE_FILE_CORRUPTED; goto _return; } + int64_t count = taosWriteFile(file, pFuncInfo->pCode, pFuncInfo->codeSize); if (count != pFuncInfo->codeSize) { fnError("udfd write udf shared library failed"); diff --git a/source/libs/index/inc/indexUtil.h b/source/libs/index/inc/indexUtil.h index dbaecaa963..148a521d5a 100644 --- a/source/libs/index/inc/indexUtil.h +++ b/source/libs/index/inc/indexUtil.h @@ -36,7 +36,6 @@ extern "C" { #define SERIALIZE_VAR_TO_BUF(buf, var, type) \ do { \ type c = var; \ - assert(sizeof(type) == sizeof(c)); \ memcpy((void *)buf, (void *)&c, sizeof(c)); \ buf += sizeof(c); \ } while (0) diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index 76dc84ae42..a99c87b7f9 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -226,7 +226,9 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) { indexDebug("w suid:%" PRIu64 ", colName:%s, colType:%d", key.suid, key.colName, key.colType); IndexCache** cache = taosHashGet(index->colObj, buf, sz); - assert(*cache != NULL); + ASSERTS(*cache != NULL, "index-cache already release"); + if (*cache == NULL) return -1; + int ret = idxCachePut(*cache, p, uid); if (ret != 0) { return ret; diff --git a/source/libs/index/src/indexComm.c b/source/libs/index/src/indexComm.c index e3f140047a..c2ac7f4478 100644 --- a/source/libs/index/src/indexComm.c +++ b/source/libs/index/src/indexComm.c @@ -170,7 +170,6 @@ TExeCond tCompare(__compar_fn_t func, int8_t cmptype, void* a, void* b, int8_t d } return tDoCompare(func, cmptype, &va, &vb); } - assert(0); return BREAK; #endif } @@ -367,7 +366,7 @@ int32_t idxConvertData(void* src, int8_t type, void** dst) { tlen = taosEncodeBinary(dst, src, strlen(src)); break; default: - ASSERT(0); + ASSERTS(0, "index invalid input type"); break; } *dst = (char*)*dst - tlen; @@ -459,7 +458,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { *dst = (char*)*dst - tlen; break; default: - ASSERT(0); + ASSERTS(0, "index invalid input type"); break; } return tlen; diff --git a/source/libs/index/src/indexFilter.c b/source/libs/index/src/indexFilter.c index 07696c3822..5c14424b7e 100644 --- a/source/libs/index/src/indexFilter.c +++ b/source/libs/index/src/indexFilter.c @@ -206,7 +206,9 @@ static FORCE_INLINE int32_t sifGetValueFromNode(SNode *node, char **value) { static FORCE_INLINE int32_t sifInitJsonParam(SNode *node, SIFParam *param, SIFCtx *ctx) { SOperatorNode *nd = (SOperatorNode *)node; - assert(nodeType(node) == QUERY_NODE_OPERATOR); + if (nodeType(node) != QUERY_NODE_OPERATOR) { + return -1; + } SColumnNode *l = (SColumnNode *)nd->pLeft; SValueNode *r = (SValueNode *)nd->pRight; diff --git a/source/libs/index/src/indexFst.c b/source/libs/index/src/indexFst.c index bbffcfa6c1..f3b7b2fbae 100644 --- a/source/libs/index/src/indexFst.c +++ b/source/libs/index/src/indexFst.c @@ -65,10 +65,7 @@ void fstUnFinishedNodesPushEmpty(FstUnFinishedNodes* nodes, bool isFinal) { taosArrayPush(nodes->stack, &un); } FstBuilderNode* fstUnFinishedNodesPopRoot(FstUnFinishedNodes* nodes) { - assert(taosArrayGetSize(nodes->stack) == 1); - FstBuilderNodeUnfinished* un = taosArrayPop(nodes->stack); - assert(un->last == NULL); return un->node; } @@ -82,7 +79,6 @@ FstBuilderNode* fstUnFinishedNodesPopFreeze(FstUnFinishedNodes* nodes, CompiledA FstBuilderNode* fstUnFinishedNodesPopEmpty(FstUnFinishedNodes* nodes) { FstBuilderNodeUnfinished* un = taosArrayPop(nodes->stack); - assert(un->last == NULL); return un->node; } void fstUnFinishedNodesSetRootOutput(FstUnFinishedNodes* nodes, Output out) { @@ -102,7 +98,8 @@ void fstUnFinishedNodesAddSuffix(FstUnFinishedNodes* nodes, FstSlice bs, Output } int32_t sz = taosArrayGetSize(nodes->stack) - 1; FstBuilderNodeUnfinished* un = taosArrayGet(nodes->stack, sz); - assert(un->last == NULL); + ASSERTS(un->last == NULL, "index-fst meet unexpected node"); + if (un->last != NULL) return; // FstLastTransition *trn = taosMemoryMalloc(sizeof(FstLastTransition)); // trn->inp = s->data[s->start]; @@ -247,7 +244,6 @@ void fstStateCompileForOneTrans(IdxFstFile* w, CompiledAddr addr, FstTransition* } void fstStateCompileForAnyTrans(IdxFstFile* w, CompiledAddr addr, FstBuilderNode* node) { int32_t sz = taosArrayGetSize(node->trans); - assert(sz <= 256); uint8_t tSize = 0; uint8_t oSize = packSize(node->finalOutput); @@ -322,7 +318,7 @@ void fstStateCompileForAnyTrans(IdxFstFile* w, CompiledAddr addr, FstBuilderNode // set_comm_input void fstStateSetCommInput(FstState* s, uint8_t inp) { - assert(s->state == OneTransNext || s->state == OneTrans); + ASSERT(s->state == OneTransNext || s->state == OneTrans); uint8_t val; COMMON_INDEX(inp, 0b111111, val); @@ -331,7 +327,7 @@ void fstStateSetCommInput(FstState* s, uint8_t inp) { // comm_input uint8_t fstStateCommInput(FstState* s, bool* null) { - assert(s->state == OneTransNext || s->state == OneTrans); + ASSERT(s->state == OneTransNext || s->state == OneTrans); uint8_t v = s->val & 0b00111111; if (v == 0) { *null = true; @@ -344,7 +340,7 @@ uint8_t fstStateCommInput(FstState* s, bool* null) { // input_len uint64_t fstStateInputLen(FstState* s) { - assert(s->state == OneTransNext || s->state == OneTrans); + ASSERT(s->state == OneTransNext || s->state == OneTrans); bool null = false; fstStateCommInput(s, &null); return null ? 1 : 0; @@ -352,11 +348,11 @@ uint64_t fstStateInputLen(FstState* s) { // end_addr uint64_t fstStateEndAddrForOneTransNext(FstState* s, FstSlice* data) { - assert(s->state == OneTransNext); + ASSERT(s->state == OneTransNext); return FST_SLICE_LEN(data) - 1 - fstStateInputLen(s); } uint64_t fstStateEndAddrForOneTrans(FstState* s, FstSlice* data, PackSizes sizes) { - assert(s->state == OneTrans); + ASSERT(s->state == OneTrans); return FST_SLICE_LEN(data) - 1 - fstStateInputLen(s) - 1 // pack size - FST_GET_TRANSITION_PACK_SIZE(sizes) - FST_GET_OUTPUT_PACK_SIZE(sizes); } @@ -370,7 +366,7 @@ uint64_t fstStateEndAddrForAnyTrans(FstState* state, uint64_t version, FstSlice* } // input uint8_t fstStateInput(FstState* s, FstNode* node) { - assert(s->state == OneTransNext || s->state == OneTrans); + ASSERT(s->state == OneTransNext || s->state == OneTrans); FstSlice* slice = &node->data; bool null = false; uint8_t inp = fstStateCommInput(s, &null); @@ -378,7 +374,7 @@ uint8_t fstStateInput(FstState* s, FstNode* node) { return null == false ? inp : data[node->start - 1]; } uint8_t fstStateInputForAnyTrans(FstState* s, FstNode* node, uint64_t i) { - assert(s->state == AnyTrans); + ASSERT(s->state == AnyTrans); FstSlice* slice = &node->data; uint64_t at = node->start - fstStateNtransLen(s) - 1 // pack size @@ -390,7 +386,7 @@ uint8_t fstStateInputForAnyTrans(FstState* s, FstNode* node, uint64_t i) { // trans_addr CompiledAddr fstStateTransAddr(FstState* s, FstNode* node) { - assert(s->state == OneTransNext || s->state == OneTrans); + ASSERT(s->state == OneTransNext || s->state == OneTrans); FstSlice* slice = &node->data; if (s->state == OneTransNext) { return (CompiledAddr)(node->end) - 1; @@ -406,7 +402,7 @@ CompiledAddr fstStateTransAddr(FstState* s, FstNode* node) { } } CompiledAddr fstStateTransAddrForAnyTrans(FstState* s, FstNode* node, uint64_t i) { - assert(s->state == AnyTrans); + ASSERT(s->state == AnyTrans); FstSlice* slice = &node->data; uint8_t tSizes = FST_GET_TRANSITION_PACK_SIZE(node->sizes); @@ -418,7 +414,7 @@ CompiledAddr fstStateTransAddrForAnyTrans(FstState* s, FstNode* node, uint64_t i // sizes PackSizes fstStateSizes(FstState* s, FstSlice* slice) { - assert(s->state == OneTrans || s->state == AnyTrans); + ASSERT(s->state == OneTrans || s->state == AnyTrans); uint64_t i; if (s->state == OneTrans) { i = FST_SLICE_LEN(slice) - 1 - fstStateInputLen(s) - 1; @@ -431,7 +427,7 @@ PackSizes fstStateSizes(FstState* s, FstSlice* slice) { } // Output Output fstStateOutput(FstState* s, FstNode* node) { - assert(s->state == OneTrans); + ASSERT(s->state == OneTrans); uint8_t oSizes = FST_GET_OUTPUT_PACK_SIZE(node->sizes); if (oSizes == 0) { @@ -445,7 +441,7 @@ Output fstStateOutput(FstState* s, FstNode* node) { return unpackUint64(data + i, oSizes); } Output fstStateOutputForAnyTrans(FstState* s, FstNode* node, uint64_t i) { - assert(s->state == AnyTrans); + ASSERT(s->state == AnyTrans); uint8_t oSizes = FST_GET_OUTPUT_PACK_SIZE(node->sizes); if (oSizes == 0) { @@ -462,19 +458,19 @@ Output fstStateOutputForAnyTrans(FstState* s, FstNode* node, uint64_t i) { // anyTrans specify function void fstStateSetFinalState(FstState* s, bool yes) { - assert(s->state == AnyTrans); + ASSERT(s->state == AnyTrans); if (yes) { s->val |= 0b01000000; } return; } bool fstStateIsFinalState(FstState* s) { - assert(s->state == AnyTrans); + ASSERT(s->state == AnyTrans); return (s->val & 0b01000000) == 0b01000000; } void fstStateSetStateNtrans(FstState* s, uint8_t n) { - assert(s->state == AnyTrans); + ASSERT(s->state == AnyTrans); if (n <= 0b00111111) { s->val = (s->val & 0b11000000) | n; } @@ -482,7 +478,7 @@ void fstStateSetStateNtrans(FstState* s, uint8_t n) { } // state_ntrans uint8_t fstStateStateNtrans(FstState* s, bool* null) { - assert(s->state == AnyTrans); + ASSERT(s->state == AnyTrans); *null = false; uint8_t n = s->val & 0b00111111; @@ -492,16 +488,16 @@ uint8_t fstStateStateNtrans(FstState* s, bool* null) { return n; } uint64_t fstStateTotalTransSize(FstState* s, uint64_t version, PackSizes sizes, uint64_t nTrans) { - assert(s->state == AnyTrans); + ASSERT(s->state == AnyTrans); uint64_t idxSize = fstStateTransIndexSize(s, version, nTrans); return nTrans + (nTrans * FST_GET_TRANSITION_PACK_SIZE(sizes)) + idxSize; } uint64_t fstStateTransIndexSize(FstState* s, uint64_t version, uint64_t nTrans) { - assert(s->state == AnyTrans); + ASSERT(s->state == AnyTrans); return (version >= 2 && nTrans > TRANS_INDEX_THRESHOLD) ? 256 : 0; } uint64_t fstStateNtransLen(FstState* s) { - assert(s->state == AnyTrans); + ASSERT(s->state == AnyTrans); bool null = false; fstStateStateNtrans(s, &null); return null == true ? 1 : 0; @@ -530,7 +526,7 @@ Output fstStateFinalOutput(FstState* s, uint64_t version, FstSlice* slice, PackS return unpackUint64(data + at, (uint8_t)oSizes); } uint64_t fstStateFindInput(FstState* s, FstNode* node, uint8_t b, bool* null) { - assert(s->state == AnyTrans); + ASSERT(s->state == AnyTrans); FstSlice* slice = &node->data; if (node->version >= 2 && node->nTrans > TRANS_INDEX_THRESHOLD) { uint64_t at = node->start - fstStateNtransLen(s) - 1 // pack size @@ -676,17 +672,17 @@ bool fstNodeGetTransitionAddrAt(FstNode* node, uint64_t i, CompiledAddr* res) { bool s = true; FstState* st = &node->state; if (st->state == OneTransNext) { - assert(i == 0); + ASSERT(i == 0); fstStateTransAddr(st, node); } else if (st->state == OneTrans) { - assert(i == 0); + ASSERT(i == 0); fstStateTransAddr(st, node); } else if (st->state == AnyTrans) { fstStateTransAddrForAnyTrans(st, node, i); } else if (FST_STATE_EMPTY_FINAL(node)) { s = false; } else { - assert(0); + ASSERT(0); } return s; } @@ -722,7 +718,7 @@ bool fstNodeFindInput(FstNode* node, uint8_t b, uint64_t* res) { bool fstNodeCompile(FstNode* node, void* w, CompiledAddr lastAddr, CompiledAddr addr, FstBuilderNode* builderNode) { int32_t sz = taosArrayGetSize(builderNode->trans); - assert(sz < 256); + ASSERT(sz < 256); if (sz == 0 && builderNode->isFinal && builderNode->finalOutput == 0) { return true; } else if (sz != 1 || builderNode->isFinal) { @@ -804,7 +800,7 @@ void fstBuilderInsertOutput(FstBuilder* b, FstSlice bs, Output in) { uint64_t prefixLen = fstUnFinishedNodesFindCommPrefixAndSetOutput(b->unfinished, bs, in, &out); if (prefixLen == FST_SLICE_LEN(s)) { - assert(out == 0); + ASSERT(out == 0); return; } @@ -848,7 +844,7 @@ void fstBuilderCompileFrom(FstBuilder* b, uint64_t istate) { addr = fstBuilderCompile(b, bn); fstBuilderNodeDestroy(bn); - assert(addr != NONE_ADDRESS); + ASSERT(addr != NONE_ADDRESS); } fstUnFinishedNodesTopLastFreeze(b->unfinished, addr); return; diff --git a/source/libs/index/src/indexFstDfa.c b/source/libs/index/src/indexFstDfa.c index 8ce0ba1e69..4d348e76f2 100644 --- a/source/libs/index/src/indexFstDfa.c +++ b/source/libs/index/src/indexFstDfa.c @@ -104,8 +104,9 @@ bool dfaBuilderRunState(FstDfaBuilder *builder, FstSparseSet *cur, FstSparseSet DfaState *t = taosArrayGet(builder->dfa->states, state); for (int i = 0; i < taosArrayGetSize(t->insts); i++) { int32_t ip = *(int32_t *)taosArrayGet(t->insts, i); - bool succ = sparSetAdd(cur, ip, NULL); - assert(succ == true); + + bool succ = sparSetAdd(cur, ip, NULL); + if (succ == false) return false; } dfaRun(builder->dfa, cur, next, byte); diff --git a/source/libs/index/src/indexFstFile.c b/source/libs/index/src/indexFstFile.c index 4620af8694..5a9c8dfe3d 100644 --- a/source/libs/index/src/indexFstFile.c +++ b/source/libs/index/src/indexFstFile.c @@ -100,7 +100,7 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of do { char key[1024] = {0}; - assert(strlen(ctx->file.buf) + 1 + 64 < sizeof(key)); + ASSERT(strlen(ctx->file.buf) + 1 + 64 < sizeof(key)); idxGenLRUKey(key, ctx->file.buf, blkId); LRUHandle* h = taosLRUCacheLookup(ctx->lru, key, strlen(key)); @@ -114,7 +114,8 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of if (left < kBlockSize) { nread = TMIN(left, len); int32_t bytes = taosPReadFile(ctx->file.pFile, buf + total, nread, offset); - assert(bytes == nread); + ASSERTS(bytes == nread, "index read incomplete data"); + if (bytes != nread) break; total += bytes; return total; @@ -124,7 +125,8 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of SDataBlock* blk = taosMemoryCalloc(1, cacheMemSize); blk->blockId = blkId; blk->nread = taosPReadFile(ctx->file.pFile, blk->buf, kBlockSize, blkId * kBlockSize); - assert(blk->nread <= kBlockSize); + ASSERTS(blk->nread <= kBlockSize, "index read incomplete data"); + if (blk->nread > kBlockSize) break; if (blk->nread < kBlockSize && blk->nread < len) { taosMemoryFree(blk); @@ -275,7 +277,10 @@ int idxFileWrite(IdxFstFile* write, uint8_t* buf, uint32_t len) { // update checksum IFileCtx* ctx = write->wrt; int nWrite = ctx->write(ctx, buf, len); - assert(nWrite == len); + ASSERTS(nWrite == len, "index write incomplete data"); + if (nWrite != len) { + return -1; + } write->count += len; write->summer = taosCalcChecksum(write->summer, buf, len); @@ -302,7 +307,6 @@ int idxFileFlush(IdxFstFile* write) { } void idxFilePackUintIn(IdxFstFile* writer, uint64_t n, uint8_t nBytes) { - assert(1 <= nBytes && nBytes <= 8); uint8_t* buf = taosMemoryCalloc(8, sizeof(uint8_t)); for (uint8_t i = 0; i < nBytes; i++) { buf[i] = (uint8_t)n; diff --git a/source/libs/index/src/indexFstRegister.c b/source/libs/index/src/indexFstRegister.c index e0abcadc78..adafecccb1 100644 --- a/source/libs/index/src/indexFstRegister.c +++ b/source/libs/index/src/indexFstRegister.c @@ -57,8 +57,8 @@ static void fstRegistryCellPromote(SArray* arr, uint32_t start, uint32_t end) { if (start >= sz && end >= sz) { return; } - - assert(start >= end); + ASSERTS(start >= end, "index-fst start lower than end"); + if (start < end) return; int32_t s = (int32_t)start; int32_t e = (int32_t)end; diff --git a/source/libs/index/src/indexFstUtil.c b/source/libs/index/src/indexFstUtil.c index b1a919b365..f1e8808cf5 100644 --- a/source/libs/index/src/indexFstUtil.c +++ b/source/libs/index/src/indexFstUtil.c @@ -101,7 +101,6 @@ FstSlice fstSliceDeepCopy(FstSlice* s, int32_t start, int32_t end) { int32_t slen; uint8_t* data = fstSliceData(s, &slen); - assert(tlen <= slen); uint8_t* buf = taosMemoryMalloc(sizeof(uint8_t) * tlen); memcpy(buf, data + start, tlen); diff --git a/source/libs/index/src/indexTfile.c b/source/libs/index/src/indexTfile.c index b34d05d297..d921ca7103 100644 --- a/source/libs/index/src/indexTfile.c +++ b/source/libs/index/src/indexTfile.c @@ -122,7 +122,6 @@ TFileCache* tfileCacheCreate(SIndex* idx, const char* path) { char buf[128] = {0}; int32_t sz = idxSerialCacheKey(&key, buf); - assert(sz < sizeof(buf)); taosHashPut(tcache->tableCache, buf, sz, &reader, sizeof(void*)); tfileReaderRef(reader); } @@ -151,9 +150,8 @@ void tfileCacheDestroy(TFileCache* tcache) { } TFileReader* tfileCacheGet(TFileCache* tcache, ICacheKey* key) { - char buf[128] = {0}; - int32_t sz = idxSerialCacheKey(key, buf); - assert(sz < sizeof(buf)); + char buf[128] = {0}; + int32_t sz = idxSerialCacheKey(key, buf); TFileReader** reader = taosHashGet(tcache->tableCache, buf, sz); if (reader == NULL || *reader == NULL) { return NULL; @@ -877,7 +875,7 @@ static int tfileWriteFooter(TFileWriter* write) { int nwrite = write->ctx->write(write->ctx, buf, (int32_t)strlen(buf)); indexInfo("tfile write footer size: %d", write->ctx->size(write->ctx)); - assert(nwrite == sizeof(FILE_MAGIC_NUMBER)); + ASSERTS(nwrite == sizeof(FILE_MAGIC_NUMBER), "index write incomplete data"); return nwrite; } static int tfileReaderLoadHeader(TFileReader* reader) { @@ -892,7 +890,6 @@ static int tfileReaderLoadHeader(TFileReader* reader) { } else { indexInfo("actual Read: %d, to read: %d, filename: %s", (int)(nread), (int)sizeof(buf), reader->ctx->file.buf); } - // assert(nread == sizeof(buf)); memcpy(&reader->header, buf, sizeof(buf)); return 0; @@ -914,7 +911,10 @@ static int tfileReaderLoadFst(TFileReader* reader) { indexInfo("nread = %d, and fst offset=%d, fst size: %d, filename: %s, file size: %d, time cost: %" PRId64 "us", nread, reader->header.fstOffset, fstSize, ctx->file.buf, size, cost); // we assuse fst size less than FST_MAX_SIZE - assert(nread > 0 && nread <= fstSize); + ASSERTS(nread > 0 && nread <= fstSize, "index read incomplete fst"); + if (nread <= 0 || nread > fstSize) { + return -1; + } FstSlice st = fstSliceCreate((uint8_t*)buf, nread); reader->fst = fstCreate(&st); @@ -929,7 +929,7 @@ static int tfileReaderLoadTableIds(TFileReader* reader, int32_t offset, SArray* // add block cache char block[4096] = {0}; int32_t nread = ctx->readFrom(ctx, block, sizeof(block), offset); - assert(nread >= sizeof(uint32_t)); + ASSERT(nread >= sizeof(uint32_t)); char* p = block; int32_t nid = *(int32_t*)p; diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index fb9560341e..12041bd2ae 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -409,6 +409,7 @@ static int32_t logicAggCopy(const SAggLogicNode* pSrc, SAggLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pGroupKeys); CLONE_NODE_LIST_FIELD(pAggFuncs); + COPY_SCALAR_FIELD(hasGroupKeyOptimized); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index c17077950f..d9b3237993 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -1918,6 +1918,7 @@ static const char* jkAggPhysiPlanExprs = "Exprs"; static const char* jkAggPhysiPlanGroupKeys = "GroupKeys"; static const char* jkAggPhysiPlanAggFuncs = "AggFuncs"; static const char* jkAggPhysiPlanMergeDataBlock = "MergeDataBlock"; +static const char* jkAggPhysiPlanGroupKeyOptimized = "GroupKeyOptimized"; static int32_t physiAggNodeToJson(const void* pObj, SJson* pJson) { const SAggPhysiNode* pNode = (const SAggPhysiNode*)pObj; @@ -1935,6 +1936,9 @@ static int32_t physiAggNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkAggPhysiPlanMergeDataBlock, pNode->mergeDataBlock); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddBoolToObject(pJson, jkAggPhysiPlanGroupKeyOptimized, pNode->groupKeyOptimized); + } return code; } @@ -1955,6 +1959,9 @@ static int32_t jsonToPhysiAggNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetBoolValue(pJson, jkAggPhysiPlanMergeDataBlock, &pNode->mergeDataBlock); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBoolValue(pJson, jkAggPhysiPlanGroupKeyOptimized, &pNode->groupKeyOptimized); + } return code; } diff --git a/source/libs/nodes/src/nodesMsgFuncs.c b/source/libs/nodes/src/nodesMsgFuncs.c index f5e4bc1ea4..a4b77fad69 100644 --- a/source/libs/nodes/src/nodesMsgFuncs.c +++ b/source/libs/nodes/src/nodesMsgFuncs.c @@ -2370,7 +2370,8 @@ enum { PHY_AGG_CODE_EXPR, PHY_AGG_CODE_GROUP_KEYS, PHY_AGG_CODE_AGG_FUNCS, - PHY_AGG_CODE_MERGE_DATA_BLOCK + PHY_AGG_CODE_MERGE_DATA_BLOCK, + PHY_AGG_CODE_GROUP_KEY_OPTIMIZE }; static int32_t physiAggNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { @@ -2389,6 +2390,9 @@ static int32_t physiAggNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { if (TSDB_CODE_SUCCESS == code) { code = tlvEncodeBool(pEncoder, PHY_AGG_CODE_MERGE_DATA_BLOCK, pNode->mergeDataBlock); } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeBool(pEncoder, PHY_AGG_CODE_GROUP_KEY_OPTIMIZE, pNode->groupKeyOptimized); + } return code; } @@ -2415,6 +2419,9 @@ static int32_t msgToPhysiAggNode(STlvDecoder* pDecoder, void* pObj) { case PHY_AGG_CODE_MERGE_DATA_BLOCK: code = tlvDecodeBool(pTlv, &pNode->mergeDataBlock); break; + case PHY_AGG_CODE_GROUP_KEY_OPTIMIZE: + code = tlvDecodeBool(pTlv, &pNode->groupKeyOptimized); + break; default: break; } diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 5fb652213c..d202e60a45 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -188,6 +188,7 @@ SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName); SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort); SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, bool force); SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue); +SNode* createRealTableNodeForIndexName(SAstCreateContext* pCxt, SToken* pDbName, SToken* pIndexName); SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SNode* pIndexName, SNode* pRealTable, SNodeList* pCols, SNode* pOptions); SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding, @@ -195,15 +196,13 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pIndexName); SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId); SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId); -SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, - SNode* pQuery); -SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, - SToken* pSubDbName, bool withMeta); -SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, - SNode* pRealTable, bool withMeta); -SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName); -SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pCGroupId, - const SToken* pTopicName); +SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SNode* pQuery); +SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SToken* pSubDbName, + bool withMeta); +SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SNode* pRealTable, + bool withMeta); +SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pTopicName); +SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pCGroupId, SToken* pTopicName); SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue); SNode* createDefaultExplainOptions(SAstCreateContext* pCxt); SNode* setExplainVerbose(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal); @@ -216,9 +215,9 @@ SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool const SToken* pLibPath, SDataType dataType, int32_t bufSize); SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pFuncName); SNode* createStreamOptions(SAstCreateContext* pCxt); -SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable, +SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken* pStreamName, SNode* pRealTable, SNode* pOptions, SNodeList* pTags, SNode* pSubtable, SNode* pQuery, SNodeList* pCols); -SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pStreamName); +SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pStreamName); SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId); SNode* createKillQueryStmt(SAstCreateContext* pCxt, const SToken* pQueryId); SNode* createBalanceVgroupStmt(SAstCreateContext* pCxt); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index ec158f27a3..abb34e7e80 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -462,10 +462,13 @@ tag_item(A) ::= column_name(B) AS column_alias(C). /************************************************ create index ********************************************************/ cmd ::= CREATE SMA INDEX not_exists_opt(D) - full_table_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); } + full_index_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); } cmd ::= CREATE INDEX not_exists_opt(D) - full_table_name(A) ON full_table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, D, A, B, C, NULL); } -cmd ::= DROP INDEX exists_opt(B) full_table_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, A); } + full_index_name(A) ON full_table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, D, A, B, C, NULL); } +cmd ::= DROP INDEX exists_opt(B) full_index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, A); } + +full_index_name(A) ::= index_name(B). { A = createRealTableNodeForIndexName(pCxt, NULL, &B); } +full_index_name(A) ::= db_name(B) NK_DOT index_name(C). { A = createRealTableNodeForIndexName(pCxt, &B, &C); } index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL NK_LP duration_literal(C) NK_RP sliding_opt(D) sma_stream_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D, E); } @@ -676,6 +679,10 @@ stream_name(A) ::= NK_ID(B). %destructor cgroup_name { } cgroup_name(A) ::= NK_ID(B). { A = B; } +%type index_name { SToken } +%destructor index_name { } +index_name(A) ::= NK_ID(B). { A = B; } + /************************************************ expression **********************************************************/ expr_or_subquery(A) ::= expression(B). { A = B; } //expr_or_subquery(A) ::= subquery(B). { A = createTempTableNode(pCxt, releaseRawExprNode(pCxt, B), NULL); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 553a289466..f582adb0c6 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -201,6 +201,24 @@ static bool checkIndexName(SAstCreateContext* pCxt, SToken* pIndexName) { return true; } +static bool checkTopicName(SAstCreateContext* pCxt, SToken* pTopicName) { + trimEscape(pTopicName); + if (pTopicName->n >= TSDB_TOPIC_NAME_LEN) { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pTopicName->z); + return false; + } + return true; +} + +static bool checkStreamName(SAstCreateContext* pCxt, SToken* pStreamName) { + trimEscape(pStreamName); + if (pStreamName->n >= TSDB_STREAM_NAME_LEN) { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pStreamName->z); + return false; + } + return true; +} + static bool checkComment(SAstCreateContext* pCxt, const SToken* pCommentToken, bool demand) { if (NULL == pCommentToken) { pCxt->errCode = demand ? TSDB_CODE_PAR_SYNTAX_ERROR : TSDB_CODE_SUCCESS; @@ -1555,6 +1573,13 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const return (SNode*)pStmt; } +SNode* createRealTableNodeForIndexName(SAstCreateContext* pCxt, SToken* pDbName, SToken* pIndexName) { + if (!checkIndexName(pCxt, pIndexName)) { + return NULL; + } + return createRealTableNode(pCxt, pDbName, pIndexName, NULL); +} + SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SNode* pIndexName, SNode* pRealTable, SNodeList* pCols, SNode* pOptions) { CHECK_PARSER_STATUS(pCxt); @@ -1613,9 +1638,11 @@ SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, cons return (SNode*)pStmt; } -SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, - SNode* pQuery) { +SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SNode* pQuery) { CHECK_PARSER_STATUS(pCxt); + if (!checkTopicName(pCxt, pTopicName)) { + return NULL; + } SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT); CHECK_OUT_OF_MEM(pStmt); COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName); @@ -1624,10 +1651,10 @@ SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists, return (SNode*)pStmt; } -SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, - SToken* pSubDbName, bool withMeta) { +SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SToken* pSubDbName, + bool withMeta) { CHECK_PARSER_STATUS(pCxt); - if (!checkDbName(pCxt, pSubDbName, true)) { + if (!checkTopicName(pCxt, pTopicName) || !checkDbName(pCxt, pSubDbName, true)) { return NULL; } SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT); @@ -1639,9 +1666,12 @@ SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, co return (SNode*)pStmt; } -SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, - SNode* pRealTable, bool withMeta) { +SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SNode* pRealTable, + bool withMeta) { CHECK_PARSER_STATUS(pCxt); + if (!checkTopicName(pCxt, pTopicName)) { + return NULL; + } SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT); CHECK_OUT_OF_MEM(pStmt); COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName); @@ -1653,8 +1683,11 @@ SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists, return (SNode*)pStmt; } -SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName) { +SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pTopicName) { CHECK_PARSER_STATUS(pCxt); + if (!checkTopicName(pCxt, pTopicName)) { + return NULL; + } SDropTopicStmt* pStmt = (SDropTopicStmt*)nodesMakeNode(QUERY_NODE_DROP_TOPIC_STMT); CHECK_OUT_OF_MEM(pStmt); COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName); @@ -1663,8 +1696,11 @@ SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const } SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pCGroupId, - const SToken* pTopicName) { + SToken* pTopicName) { CHECK_PARSER_STATUS(pCxt); + if (!checkTopicName(pCxt, pTopicName)) { + return NULL; + } SDropCGroupStmt* pStmt = (SDropCGroupStmt*)nodesMakeNode(QUERY_NODE_DROP_CGROUP_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->ignoreNotExists = ignoreNotExists; @@ -1776,9 +1812,12 @@ SNode* createStreamOptions(SAstCreateContext* pCxt) { return (SNode*)pOptions; } -SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable, +SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken* pStreamName, SNode* pRealTable, SNode* pOptions, SNodeList* pTags, SNode* pSubtable, SNode* pQuery, SNodeList* pCols) { CHECK_PARSER_STATUS(pCxt); + if (!checkStreamName(pCxt, pStreamName)) { + return NULL; + } SCreateStreamStmt* pStmt = (SCreateStreamStmt*)nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT); CHECK_OUT_OF_MEM(pStmt); COPY_STRING_FORM_ID_TOKEN(pStmt->streamName, pStreamName); @@ -1794,8 +1833,11 @@ SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const return (SNode*)pStmt; } -SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pStreamName) { +SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pStreamName) { CHECK_PARSER_STATUS(pCxt); + if (!checkStreamName(pCxt, pStreamName)) { + return NULL; + } SDropStreamStmt* pStmt = (SDropStreamStmt*)nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT); CHECK_OUT_OF_MEM(pStmt); COPY_STRING_FORM_ID_TOKEN(pStmt->streamName, pStreamName); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index cdbebec91c..a9a8e4d4c2 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -5011,6 +5011,10 @@ static int32_t checkAlterSuperTableBySchema(STranslateContext* pCxt, SAlterTable return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_ONE_JSON_TAG); } + if (getNumOfTags(pTableMeta) == 1 && pStmt->alterType == TSDB_ALTER_TABLE_DROP_TAG) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE, "the only tag cannot be dropped"); + } + int32_t tagsLen = 0; for (int32_t i = 0; i < pTableMeta->tableInfo.numOfTags; ++i) { tagsLen += pTagsSchema[i].bytes; @@ -7699,7 +7703,7 @@ static void destoryAlterTbReq(SVAlterTbReq* pReq) { static int32_t rewriteAlterTableImpl(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta, SQuery* pQuery) { if (getNumOfTags(pTableMeta) == 1 && pStmt->alterType == TSDB_ALTER_TABLE_DROP_TAG) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE); + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE, "the only tag cannot be dropped"); } if (TSDB_SUPER_TABLE == pTableMeta->tableType) { diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 84040bd7a8..7460664de2 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -104,26 +104,26 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 463 +#define YYNOCODE 465 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - bool yy63; - int32_t yy122; - EOrder yy162; - SDataType yy200; - SNode* yy320; - EJoinType yy334; - int8_t yy475; - int64_t yy483; - SNodeList* yy570; - SAlterOption yy695; - ENullOrder yy715; - EFillMode yy762; - SToken yy815; - EOperatorType yy828; + EJoinType yy42; + int8_t yy113; + int64_t yy159; + SToken yy179; + EOperatorType yy290; + EFillMode yy324; + SDataType yy394; + ENullOrder yy487; + SNode* yy602; + bool yy767; + int32_t yy820; + SAlterOption yy845; + SNodeList* yy874; + EOrder yy878; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -139,18 +139,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 727 -#define YYNRULE 550 -#define YYNRULE_WITH_ACTION 550 +#define YYNSTATE 730 +#define YYNRULE 553 #define YYNTOKEN 326 -#define YY_MAX_SHIFT 726 -#define YY_MIN_SHIFTREDUCE 1075 -#define YY_MAX_SHIFTREDUCE 1624 -#define YY_ERROR_ACTION 1625 -#define YY_ACCEPT_ACTION 1626 -#define YY_NO_ACTION 1627 -#define YY_MIN_REDUCE 1628 -#define YY_MAX_REDUCE 2177 +#define YY_MAX_SHIFT 729 +#define YY_MIN_SHIFTREDUCE 1081 +#define YY_MAX_SHIFTREDUCE 1633 +#define YY_ERROR_ACTION 1634 +#define YY_ACCEPT_ACTION 1635 +#define YY_NO_ACTION 1636 +#define YY_MIN_REDUCE 1637 +#define YY_MAX_REDUCE 2189 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -217,792 +216,740 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2803) +#define YY_ACTTAB_COUNT (2706) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 35, 282, 1770, 1898, 2153, 1898, 233, 581, 2148, 1811, - /* 10 */ 1978, 2148, 45, 43, 1554, 361, 1896, 603, 1895, 603, - /* 20 */ 370, 1974, 1404, 1978, 2152, 1759, 580, 179, 2149, 2151, - /* 30 */ 1991, 2149, 582, 1484, 1974, 1402, 44, 42, 41, 40, - /* 40 */ 39, 538, 38, 37, 1772, 2152, 44, 42, 41, 40, - /* 50 */ 39, 1970, 1976, 352, 536, 1974, 534, 593, 1479, 1429, - /* 60 */ 1626, 2009, 626, 18, 1970, 1976, 365, 476, 375, 596, - /* 70 */ 1410, 1827, 1829, 472, 1960, 626, 632, 470, 415, 471, - /* 80 */ 1664, 1430, 1834, 45, 43, 1970, 1976, 488, 138, 338, - /* 90 */ 615, 370, 163, 1404, 1640, 14, 626, 334, 1832, 469, - /* 100 */ 616, 1990, 474, 1670, 1484, 2026, 1402, 1431, 107, 1992, - /* 110 */ 636, 1994, 1995, 631, 130, 626, 616, 723, 324, 2153, - /* 120 */ 176, 509, 2079, 2148, 385, 1879, 364, 2075, 615, 1479, - /* 130 */ 130, 1781, 1486, 1487, 18, 615, 187, 514, 1513, 2152, - /* 140 */ 181, 1410, 478, 2149, 2150, 474, 1670, 1781, 2105, 262, - /* 150 */ 2087, 592, 161, 131, 591, 581, 2009, 2148, 1108, 2148, - /* 160 */ 173, 1784, 1459, 1469, 575, 48, 14, 557, 1485, 1488, - /* 170 */ 1429, 2148, 580, 179, 580, 179, 616, 2149, 582, 2149, - /* 180 */ 582, 341, 1883, 1405, 173, 1403, 2154, 179, 723, 345, - /* 190 */ 54, 2149, 582, 1347, 1348, 1514, 1864, 1110, 265, 1113, - /* 200 */ 1114, 1332, 1333, 1486, 1487, 574, 1884, 1781, 1408, 1409, - /* 210 */ 48, 1458, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, - /* 220 */ 628, 624, 1477, 1478, 1480, 1481, 1482, 1483, 2, 1346, - /* 230 */ 1349, 273, 274, 1459, 1469, 60, 272, 90, 120, 1485, - /* 240 */ 1488, 119, 118, 117, 116, 115, 114, 113, 112, 111, - /* 250 */ 346, 264, 344, 343, 1405, 511, 1403, 38, 37, 513, - /* 260 */ 488, 44, 42, 41, 40, 39, 1581, 34, 368, 1508, - /* 270 */ 1509, 1510, 1511, 1512, 1516, 1517, 1518, 1519, 60, 1408, - /* 280 */ 1409, 512, 1458, 1461, 1462, 1463, 1464, 1465, 1466, 1467, - /* 290 */ 1468, 628, 624, 1477, 1478, 1480, 1481, 1482, 1483, 2, - /* 300 */ 49, 11, 45, 43, 1697, 1429, 1127, 584, 1126, 1404, - /* 310 */ 370, 140, 1404, 1979, 2050, 568, 1579, 1580, 1582, 1583, - /* 320 */ 1991, 216, 1402, 1484, 1974, 1402, 1234, 658, 657, 656, - /* 330 */ 1238, 655, 1240, 1241, 654, 1243, 651, 1128, 1249, 648, - /* 340 */ 1251, 1252, 645, 642, 1194, 1591, 60, 433, 1479, 84, - /* 350 */ 64, 2009, 1558, 18, 1970, 1976, 432, 1410, 1429, 633, - /* 360 */ 1410, 182, 104, 134, 1960, 626, 632, 1828, 1829, 524, - /* 370 */ 523, 522, 1776, 45, 43, 1489, 139, 135, 518, 1196, - /* 380 */ 60, 370, 517, 1404, 1773, 14, 182, 516, 521, 2153, - /* 390 */ 84, 1990, 164, 515, 1484, 2026, 1402, 1735, 107, 1992, - /* 400 */ 636, 1994, 1995, 631, 723, 626, 1431, 723, 141, 576, - /* 410 */ 147, 2050, 2079, 1777, 31, 217, 364, 2075, 1628, 1479, - /* 420 */ 38, 37, 1486, 1487, 44, 42, 41, 40, 39, 182, - /* 430 */ 168, 1410, 11, 408, 9, 407, 505, 501, 497, 493, - /* 440 */ 214, 60, 129, 128, 127, 126, 125, 124, 123, 122, - /* 450 */ 121, 182, 1459, 1469, 1430, 571, 46, 1494, 1485, 1488, - /* 460 */ 1629, 38, 37, 1429, 1834, 44, 42, 41, 40, 39, - /* 470 */ 1405, 350, 1403, 1405, 296, 1403, 85, 1811, 723, 212, - /* 480 */ 1832, 120, 1614, 1757, 119, 118, 117, 116, 115, 114, - /* 490 */ 113, 112, 111, 1486, 1487, 1408, 1409, 182, 1408, 1409, - /* 500 */ 1460, 1458, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, - /* 510 */ 628, 624, 1477, 1478, 1480, 1481, 1482, 1483, 2, 524, - /* 520 */ 523, 522, 1428, 1459, 1469, 520, 519, 135, 518, 1485, - /* 530 */ 1488, 182, 517, 479, 362, 471, 1664, 516, 521, 577, - /* 540 */ 572, 566, 161, 515, 1405, 670, 1403, 211, 205, 150, - /* 550 */ 264, 1783, 210, 38, 37, 484, 453, 44, 42, 41, - /* 560 */ 40, 39, 593, 670, 1991, 1432, 1277, 1278, 661, 1408, - /* 570 */ 1409, 203, 1458, 1461, 1462, 1463, 1464, 1465, 1466, 1467, - /* 580 */ 1468, 628, 624, 1477, 1478, 1480, 1481, 1482, 1483, 2, - /* 590 */ 45, 43, 182, 138, 662, 2009, 1651, 1825, 370, 373, - /* 600 */ 1404, 53, 1834, 633, 175, 1460, 11, 161, 1960, 358, - /* 610 */ 632, 1484, 231, 1402, 195, 194, 1783, 1821, 1832, 38, - /* 620 */ 37, 1991, 1834, 44, 42, 41, 40, 39, 1621, 363, - /* 630 */ 41, 40, 39, 593, 1834, 1990, 1479, 452, 1832, 2026, - /* 640 */ 1960, 374, 312, 1992, 636, 1994, 1995, 631, 1410, 626, - /* 650 */ 1832, 1410, 2009, 595, 177, 2087, 2088, 682, 136, 2092, - /* 660 */ 633, 45, 43, 616, 138, 1960, 616, 632, 98, 370, - /* 670 */ 376, 1404, 1650, 46, 616, 87, 329, 184, 161, 542, - /* 680 */ 413, 540, 1484, 1127, 1402, 1126, 578, 1783, 414, 1991, - /* 690 */ 1774, 618, 1990, 2051, 1781, 723, 2026, 1781, 1641, 108, - /* 700 */ 1992, 636, 1994, 1995, 631, 1781, 626, 1479, 616, 242, - /* 710 */ 1486, 1487, 232, 2079, 1128, 404, 1960, 2078, 2075, 1410, - /* 720 */ 2009, 1879, 423, 1620, 1758, 178, 2087, 2088, 630, 136, - /* 730 */ 2092, 616, 189, 1960, 616, 632, 406, 402, 1766, 1781, - /* 740 */ 1459, 1469, 694, 692, 14, 438, 1485, 1488, 439, 38, - /* 750 */ 37, 13, 12, 44, 42, 41, 40, 39, 2094, 1671, - /* 760 */ 1990, 1405, 1781, 1403, 2026, 1781, 723, 318, 1992, 636, - /* 770 */ 1994, 1995, 631, 629, 626, 617, 2044, 666, 1381, 1382, - /* 780 */ 1825, 1486, 1487, 1432, 2091, 27, 1408, 1409, 593, 1458, - /* 790 */ 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 628, 624, - /* 800 */ 1477, 1478, 1480, 1481, 1482, 1483, 2, 616, 718, 616, - /* 810 */ 616, 1459, 1469, 327, 513, 1427, 616, 1485, 1488, 138, - /* 820 */ 191, 486, 446, 234, 487, 460, 1834, 620, 459, 2051, - /* 830 */ 1778, 668, 1405, 1879, 1403, 1649, 512, 1515, 1781, 1432, - /* 840 */ 1781, 1781, 1833, 429, 193, 461, 1527, 1781, 431, 1429, - /* 850 */ 152, 151, 665, 664, 663, 149, 81, 1408, 1409, 80, - /* 860 */ 1458, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 628, - /* 870 */ 624, 1477, 1478, 1480, 1481, 1482, 1483, 2, 1756, 1960, - /* 880 */ 180, 2087, 2088, 162, 136, 2092, 33, 2094, 302, 342, - /* 890 */ 1694, 616, 38, 37, 2094, 1551, 44, 42, 41, 40, - /* 900 */ 39, 419, 300, 70, 667, 553, 69, 1825, 8, 32, - /* 910 */ 38, 37, 588, 2090, 44, 42, 41, 40, 39, 1520, - /* 920 */ 2089, 683, 1781, 1751, 199, 466, 464, 188, 1113, 1114, - /* 930 */ 623, 457, 2099, 1547, 451, 450, 449, 448, 445, 444, - /* 940 */ 443, 442, 441, 437, 436, 435, 434, 326, 426, 425, - /* 950 */ 424, 1991, 421, 420, 340, 700, 699, 698, 697, 380, - /* 960 */ 60, 696, 695, 142, 690, 689, 688, 687, 686, 685, - /* 970 */ 684, 154, 680, 679, 678, 379, 378, 675, 674, 673, - /* 980 */ 672, 671, 2009, 241, 1648, 668, 240, 50, 616, 3, - /* 990 */ 633, 1460, 1768, 1647, 668, 1960, 616, 632, 1570, 106, - /* 1000 */ 1646, 1947, 377, 71, 152, 151, 665, 664, 663, 149, - /* 1010 */ 597, 585, 1991, 152, 151, 665, 664, 663, 149, 1781, - /* 1020 */ 552, 144, 1990, 132, 616, 88, 2026, 1781, 1960, 166, - /* 1030 */ 1992, 636, 1994, 1995, 631, 529, 626, 1960, 601, 1764, - /* 1040 */ 78, 77, 412, 2009, 1960, 186, 616, 616, 1736, 392, - /* 1050 */ 539, 596, 1645, 79, 416, 1781, 1960, 237, 632, 1644, - /* 1060 */ 602, 277, 222, 325, 230, 220, 400, 417, 398, 394, - /* 1070 */ 390, 387, 384, 224, 1991, 1505, 223, 1781, 1781, 532, - /* 1080 */ 409, 583, 2169, 1990, 526, 616, 616, 2026, 1981, 229, - /* 1090 */ 107, 1992, 636, 1994, 1995, 631, 1960, 626, 616, 611, - /* 1100 */ 613, 616, 176, 1960, 2079, 2009, 259, 226, 364, 2075, - /* 1110 */ 225, 182, 614, 633, 1547, 283, 1781, 1781, 1960, 1991, - /* 1120 */ 632, 228, 1684, 557, 227, 67, 52, 2148, 66, 1781, - /* 1130 */ 2106, 627, 1781, 556, 1623, 1624, 1983, 589, 1550, 1643, - /* 1140 */ 1642, 1639, 2154, 179, 525, 1990, 1413, 2149, 582, 2026, - /* 1150 */ 2009, 1638, 107, 1992, 636, 1994, 1995, 631, 633, 626, - /* 1160 */ 1677, 150, 660, 1960, 2168, 632, 2079, 2119, 1637, 1412, - /* 1170 */ 364, 2075, 38, 37, 1675, 1991, 44, 42, 41, 40, - /* 1180 */ 39, 2113, 527, 1960, 1960, 1960, 1636, 1635, 1634, 1633, - /* 1190 */ 1990, 1632, 569, 1631, 2026, 1960, 530, 107, 1992, 636, - /* 1200 */ 1994, 1995, 631, 2010, 626, 1991, 2009, 1888, 1156, 2168, - /* 1210 */ 62, 2079, 1960, 1379, 633, 364, 2075, 367, 366, 1960, - /* 1220 */ 215, 632, 246, 13, 12, 150, 2126, 1418, 381, 47, - /* 1230 */ 1960, 1960, 1960, 1960, 586, 1960, 2009, 1960, 1484, 270, - /* 1240 */ 1411, 68, 148, 1157, 633, 1665, 1990, 150, 253, 1960, - /* 1250 */ 2026, 632, 1822, 107, 1992, 636, 1994, 1995, 631, 62, - /* 1260 */ 626, 1991, 1578, 1479, 258, 2168, 594, 2079, 47, 47, - /* 1270 */ 261, 364, 2075, 1, 248, 1410, 1990, 600, 640, 148, - /* 1280 */ 2026, 1344, 564, 107, 1992, 636, 1994, 1995, 631, 2109, - /* 1290 */ 626, 275, 2009, 608, 279, 2168, 1416, 2079, 150, 1227, - /* 1300 */ 633, 364, 2075, 133, 676, 1960, 4, 632, 148, 386, - /* 1310 */ 391, 1521, 2142, 103, 339, 677, 599, 1366, 192, 1415, - /* 1320 */ 1470, 295, 622, 100, 418, 290, 1175, 1432, 160, 383, - /* 1330 */ 1255, 1259, 1990, 1889, 422, 427, 2026, 1173, 382, 107, - /* 1340 */ 1992, 636, 1994, 1995, 631, 455, 626, 1427, 440, 1881, - /* 1350 */ 1266, 2168, 447, 2079, 454, 1264, 545, 364, 2075, 557, - /* 1360 */ 153, 456, 462, 2148, 463, 196, 465, 467, 2098, 1433, - /* 1370 */ 468, 1991, 557, 1435, 477, 1430, 2148, 480, 2154, 179, - /* 1380 */ 202, 557, 481, 2149, 582, 2148, 1434, 204, 1419, 482, - /* 1390 */ 1414, 2154, 179, 1436, 483, 207, 2149, 582, 485, 557, - /* 1400 */ 2154, 179, 2009, 2148, 209, 2149, 582, 82, 83, 489, - /* 1410 */ 633, 213, 1130, 1422, 1424, 1960, 506, 632, 2154, 179, - /* 1420 */ 507, 508, 510, 2149, 582, 110, 624, 1477, 1478, 1480, - /* 1430 */ 1481, 1482, 1483, 1771, 1991, 219, 1937, 1767, 221, 155, - /* 1440 */ 328, 156, 1990, 1769, 1765, 157, 2026, 158, 546, 107, - /* 1450 */ 1992, 636, 1994, 1995, 631, 1936, 626, 544, 86, 235, - /* 1460 */ 547, 2054, 548, 2079, 146, 2009, 291, 364, 2075, 551, - /* 1470 */ 238, 561, 554, 633, 2110, 2120, 570, 2125, 1960, 1991, - /* 1480 */ 632, 606, 244, 567, 2101, 247, 353, 573, 2124, 7, - /* 1490 */ 579, 252, 562, 169, 560, 254, 255, 559, 2171, 256, - /* 1500 */ 354, 590, 257, 2147, 587, 1990, 1547, 137, 1431, 2026, - /* 1510 */ 2009, 260, 107, 1992, 636, 1994, 1995, 631, 633, 626, - /* 1520 */ 598, 2095, 604, 1960, 2052, 632, 2079, 357, 266, 93, - /* 1530 */ 364, 2075, 292, 293, 605, 1991, 1906, 609, 1905, 610, - /* 1540 */ 1904, 360, 95, 97, 1782, 59, 294, 2060, 99, 1752, - /* 1550 */ 1990, 297, 1826, 286, 2026, 638, 719, 107, 1992, 636, - /* 1560 */ 1994, 1995, 631, 722, 626, 51, 2009, 321, 720, 619, - /* 1570 */ 306, 2079, 301, 330, 633, 364, 2075, 320, 1954, 1960, - /* 1580 */ 1991, 632, 299, 331, 310, 1953, 75, 1952, 1951, 76, - /* 1590 */ 1948, 388, 389, 1396, 1397, 185, 393, 1946, 395, 396, - /* 1600 */ 397, 1945, 399, 1944, 401, 1943, 1990, 1942, 403, 405, - /* 1610 */ 2026, 2009, 1368, 108, 1992, 636, 1994, 1995, 631, 633, - /* 1620 */ 626, 1369, 1917, 1916, 1960, 1991, 632, 2079, 410, 411, - /* 1630 */ 1915, 621, 2075, 1914, 1872, 1871, 1323, 1869, 143, 1868, - /* 1640 */ 1867, 1870, 1991, 1866, 1865, 1863, 1862, 1861, 190, 428, - /* 1650 */ 1860, 634, 430, 1874, 1859, 2026, 2009, 1858, 108, 1992, - /* 1660 */ 636, 1994, 1995, 631, 633, 626, 1857, 1856, 1855, 1960, - /* 1670 */ 1854, 632, 2079, 2009, 1853, 1852, 333, 2075, 145, 1844, - /* 1680 */ 1843, 633, 1851, 1850, 1849, 1848, 1960, 1991, 632, 1847, - /* 1690 */ 1846, 1845, 1842, 1873, 1841, 1840, 1990, 1839, 1325, 1838, - /* 1700 */ 2026, 458, 1836, 165, 1992, 636, 1994, 1995, 631, 1837, - /* 1710 */ 626, 1835, 1202, 1990, 1699, 1698, 197, 2026, 2009, 198, - /* 1720 */ 108, 1992, 636, 1994, 1995, 631, 633, 626, 1696, 1660, - /* 1730 */ 200, 1960, 1116, 632, 2079, 73, 1115, 1659, 1930, 2076, - /* 1740 */ 1991, 1924, 174, 1913, 558, 2116, 201, 1980, 1912, 74, - /* 1750 */ 473, 475, 206, 208, 1892, 1760, 1991, 1695, 1990, 1693, - /* 1760 */ 490, 1691, 2026, 492, 491, 165, 1992, 636, 1994, 1995, - /* 1770 */ 631, 2009, 626, 496, 494, 495, 1149, 1689, 499, 633, - /* 1780 */ 498, 500, 1687, 503, 1960, 502, 632, 2009, 504, 1674, - /* 1790 */ 1673, 1656, 359, 1762, 1270, 633, 1761, 1271, 1193, 1192, - /* 1800 */ 1960, 1191, 632, 1185, 1190, 1685, 1187, 2117, 347, 1991, - /* 1810 */ 1186, 1990, 61, 1184, 691, 2026, 1678, 693, 166, 1992, - /* 1820 */ 636, 1994, 1995, 631, 348, 626, 528, 1990, 218, 1676, - /* 1830 */ 349, 2026, 531, 1655, 319, 1992, 636, 1994, 1995, 631, - /* 1840 */ 2009, 626, 533, 1654, 535, 1653, 537, 109, 630, 1386, - /* 1850 */ 1385, 541, 1388, 1960, 1929, 632, 1375, 1923, 159, 549, - /* 1860 */ 26, 1911, 1909, 2153, 19, 16, 565, 563, 20, 55, - /* 1870 */ 1593, 2170, 58, 239, 28, 243, 250, 251, 1981, 245, - /* 1880 */ 1990, 550, 167, 351, 2026, 30, 63, 318, 1992, 636, - /* 1890 */ 1994, 1995, 631, 555, 626, 1577, 2045, 1569, 249, 1991, - /* 1900 */ 1613, 29, 5, 6, 1608, 89, 1607, 1614, 21, 17, - /* 1910 */ 355, 726, 1612, 1611, 356, 1544, 57, 263, 1543, 1910, - /* 1920 */ 170, 1908, 1907, 1891, 1890, 289, 92, 607, 94, 91, - /* 1930 */ 2009, 56, 269, 22, 271, 369, 12, 276, 633, 65, - /* 1940 */ 172, 281, 1575, 1960, 96, 632, 716, 712, 708, 704, - /* 1950 */ 287, 23, 100, 278, 1991, 1420, 171, 183, 2029, 1506, - /* 1960 */ 1451, 1474, 1496, 625, 637, 639, 372, 10, 635, 1495, - /* 1970 */ 1990, 643, 1472, 1233, 2026, 36, 15, 319, 1992, 636, - /* 1980 */ 1994, 1995, 631, 24, 626, 2009, 105, 1471, 25, 280, - /* 1990 */ 371, 1443, 1256, 633, 641, 646, 1253, 644, 1960, 1250, - /* 2000 */ 632, 647, 649, 652, 1244, 1248, 650, 1991, 1242, 653, - /* 2010 */ 101, 659, 102, 284, 1265, 72, 1247, 1246, 1261, 1147, - /* 2020 */ 1245, 669, 612, 1181, 1180, 1990, 1179, 1178, 1177, 2026, - /* 2030 */ 1991, 1200, 319, 1992, 636, 1994, 1995, 631, 2009, 626, - /* 2040 */ 1176, 1174, 1172, 1171, 1170, 681, 633, 285, 1168, 1167, - /* 2050 */ 1166, 1960, 1991, 632, 1165, 1164, 1163, 268, 1162, 1195, - /* 2060 */ 1197, 2009, 267, 1159, 1158, 1155, 1154, 1153, 1152, 633, - /* 2070 */ 1692, 701, 1690, 702, 1960, 1991, 632, 703, 543, 1373, - /* 2080 */ 707, 236, 2026, 2009, 705, 314, 1992, 636, 1994, 1995, - /* 2090 */ 631, 633, 626, 1688, 706, 709, 1960, 1991, 632, 710, - /* 2100 */ 711, 1990, 1686, 713, 714, 2026, 2009, 1672, 303, 1992, - /* 2110 */ 636, 1994, 1995, 631, 633, 626, 715, 717, 1105, 1960, - /* 2120 */ 1652, 632, 288, 1990, 721, 725, 1406, 2026, 2009, 724, - /* 2130 */ 304, 1992, 636, 1994, 1995, 631, 633, 626, 298, 1627, - /* 2140 */ 1627, 1960, 1627, 632, 1627, 1627, 1990, 1627, 1627, 1627, - /* 2150 */ 2026, 1627, 1991, 305, 1992, 636, 1994, 1995, 631, 1627, - /* 2160 */ 626, 1627, 1627, 1627, 1627, 1627, 1627, 1627, 1990, 1991, - /* 2170 */ 1627, 1627, 2026, 1627, 1627, 311, 1992, 636, 1994, 1995, - /* 2180 */ 631, 1627, 626, 2009, 1627, 1627, 1627, 1627, 1627, 1627, - /* 2190 */ 1627, 633, 1627, 1627, 1627, 1627, 1960, 1627, 632, 1627, - /* 2200 */ 2009, 1627, 1627, 1627, 1627, 1627, 1627, 1627, 633, 1627, - /* 2210 */ 1627, 1627, 1627, 1960, 1991, 632, 1627, 1627, 1627, 1627, - /* 2220 */ 1627, 1627, 1627, 1990, 1627, 1627, 1627, 2026, 1627, 1627, - /* 2230 */ 315, 1992, 636, 1994, 1995, 631, 1627, 626, 1627, 1627, - /* 2240 */ 1990, 1627, 1627, 1627, 2026, 2009, 1627, 307, 1992, 636, - /* 2250 */ 1994, 1995, 631, 633, 626, 1627, 1627, 1627, 1960, 1627, - /* 2260 */ 632, 1627, 1627, 1627, 1627, 1627, 1627, 1627, 1627, 1627, - /* 2270 */ 1991, 1627, 1627, 1627, 1627, 1627, 1627, 1627, 1627, 1627, - /* 2280 */ 1627, 1627, 1627, 1627, 1627, 1990, 1627, 1627, 1627, 2026, - /* 2290 */ 1627, 1627, 316, 1992, 636, 1994, 1995, 631, 1627, 626, - /* 2300 */ 1991, 2009, 1627, 1627, 1627, 1627, 1627, 1627, 1627, 633, - /* 2310 */ 1627, 1627, 1627, 1627, 1960, 1627, 632, 1627, 1627, 1627, - /* 2320 */ 1627, 1627, 1627, 1991, 1627, 1627, 1627, 1627, 1627, 1627, - /* 2330 */ 1627, 2009, 1627, 1627, 1627, 1627, 1627, 1627, 1627, 633, - /* 2340 */ 1627, 1990, 1627, 1627, 1960, 2026, 632, 1627, 308, 1992, - /* 2350 */ 636, 1994, 1995, 631, 2009, 626, 1627, 1627, 1627, 1627, - /* 2360 */ 1627, 1627, 633, 1627, 1627, 1627, 1627, 1960, 1991, 632, - /* 2370 */ 1627, 1990, 1627, 1627, 1627, 2026, 1627, 1627, 317, 1992, - /* 2380 */ 636, 1994, 1995, 631, 1627, 626, 1627, 1991, 1627, 1627, - /* 2390 */ 1627, 1627, 1627, 1627, 1990, 1627, 1627, 1627, 2026, 2009, - /* 2400 */ 1627, 309, 1992, 636, 1994, 1995, 631, 633, 626, 1627, - /* 2410 */ 1627, 1627, 1960, 1991, 632, 1627, 1627, 1627, 2009, 1627, - /* 2420 */ 1627, 1627, 1627, 1627, 1627, 1627, 633, 1627, 1627, 1627, - /* 2430 */ 1627, 1960, 1627, 632, 1627, 1627, 1627, 1627, 1627, 1990, - /* 2440 */ 1627, 1627, 1627, 2026, 2009, 1627, 322, 1992, 636, 1994, - /* 2450 */ 1995, 631, 633, 626, 1627, 1627, 1627, 1960, 1990, 632, - /* 2460 */ 1627, 1627, 2026, 1627, 1627, 323, 1992, 636, 1994, 1995, - /* 2470 */ 631, 1991, 626, 1627, 1627, 1627, 1627, 1627, 1627, 1627, - /* 2480 */ 1627, 1627, 1627, 1627, 1990, 1627, 1627, 1991, 2026, 1627, - /* 2490 */ 1627, 2003, 1992, 636, 1994, 1995, 631, 1627, 626, 1627, - /* 2500 */ 1627, 1627, 2009, 1627, 1627, 1627, 1627, 1627, 1627, 1627, - /* 2510 */ 633, 1627, 1627, 1627, 1627, 1960, 1627, 632, 2009, 1627, - /* 2520 */ 1627, 1627, 1627, 1627, 1627, 1627, 633, 1627, 1627, 1627, - /* 2530 */ 1627, 1960, 1627, 632, 1627, 1627, 1627, 1627, 1627, 1627, - /* 2540 */ 1627, 1627, 1990, 1991, 1627, 1627, 2026, 1627, 1627, 2002, - /* 2550 */ 1992, 636, 1994, 1995, 631, 1627, 626, 1627, 1990, 1627, - /* 2560 */ 1991, 1627, 2026, 1627, 1627, 2001, 1992, 636, 1994, 1995, - /* 2570 */ 631, 1627, 626, 1627, 2009, 1627, 1627, 1627, 1627, 1627, - /* 2580 */ 1627, 1627, 633, 1627, 1627, 1627, 1627, 1960, 1991, 632, - /* 2590 */ 1627, 2009, 1627, 1627, 1627, 1627, 1627, 1627, 1627, 633, - /* 2600 */ 1627, 1627, 1627, 1627, 1960, 1627, 632, 1627, 1627, 1627, - /* 2610 */ 1627, 1627, 1627, 1627, 1990, 1627, 1627, 1627, 2026, 2009, - /* 2620 */ 1627, 335, 1992, 636, 1994, 1995, 631, 633, 626, 1627, - /* 2630 */ 1627, 1990, 1960, 1627, 632, 2026, 1627, 1627, 336, 1992, - /* 2640 */ 636, 1994, 1995, 631, 1991, 626, 1627, 1627, 1627, 1627, - /* 2650 */ 1627, 1627, 1627, 1627, 1627, 1627, 1627, 1627, 1627, 1990, - /* 2660 */ 1627, 1991, 1627, 2026, 1627, 1627, 332, 1992, 636, 1994, - /* 2670 */ 1995, 631, 1627, 626, 1627, 2009, 1627, 1627, 1627, 1627, - /* 2680 */ 1627, 1627, 1627, 633, 1627, 1627, 1627, 1627, 1960, 1627, - /* 2690 */ 632, 1627, 2009, 1627, 1627, 1627, 1627, 1627, 1627, 1627, - /* 2700 */ 633, 1627, 1627, 1627, 1627, 1960, 1627, 632, 1627, 1627, - /* 2710 */ 1627, 1627, 1627, 1627, 1627, 1990, 1627, 1991, 1627, 2026, - /* 2720 */ 1627, 1627, 337, 1992, 636, 1994, 1995, 631, 1627, 626, - /* 2730 */ 1627, 1627, 634, 1627, 1627, 1627, 2026, 1627, 1627, 314, - /* 2740 */ 1992, 636, 1994, 1995, 631, 1627, 626, 1627, 2009, 1627, - /* 2750 */ 1627, 1627, 1627, 1627, 1627, 1627, 633, 1627, 1627, 1627, - /* 2760 */ 1627, 1960, 1627, 632, 1627, 1627, 1627, 1627, 1627, 1627, - /* 2770 */ 1627, 1627, 1627, 1627, 1627, 1627, 1627, 1627, 1627, 1627, - /* 2780 */ 1627, 1627, 1627, 1627, 1627, 1627, 1627, 1627, 1990, 1627, - /* 2790 */ 1627, 1627, 2026, 1627, 1627, 313, 1992, 636, 1994, 1995, - /* 2800 */ 631, 1627, 626, + /* 0 */ 1909, 471, 376, 472, 1673, 1836, 1838, 480, 1989, 472, + /* 10 */ 1673, 1909, 45, 43, 1563, 1907, 606, 173, 1650, 1985, + /* 20 */ 371, 1989, 1412, 362, 1843, 1781, 1906, 606, 2003, 35, + /* 30 */ 283, 339, 1985, 1493, 1660, 1410, 1985, 618, 342, 1892, + /* 40 */ 1841, 470, 38, 37, 475, 1679, 44, 42, 41, 40, + /* 50 */ 39, 1981, 1987, 353, 416, 594, 604, 582, 1488, 2021, + /* 60 */ 618, 2160, 629, 18, 1981, 1987, 366, 597, 1981, 1987, + /* 70 */ 1418, 619, 1971, 1635, 635, 629, 581, 179, 1971, 629, + /* 80 */ 1843, 2161, 583, 45, 43, 130, 138, 351, 1437, 1114, + /* 90 */ 618, 371, 510, 1412, 325, 14, 1841, 335, 1437, 582, + /* 100 */ 1843, 2002, 1790, 2160, 1493, 2038, 1410, 359, 107, 2004, + /* 110 */ 639, 2006, 2007, 634, 64, 629, 1841, 726, 581, 179, + /* 120 */ 176, 265, 2091, 2161, 583, 191, 365, 2087, 1116, 1488, + /* 130 */ 1119, 1120, 1495, 1496, 18, 48, 1990, 577, 1522, 386, + /* 140 */ 181, 1418, 44, 42, 41, 40, 39, 1985, 2117, 262, + /* 150 */ 2099, 593, 479, 131, 592, 475, 1679, 2160, 60, 2021, + /* 160 */ 90, 81, 1468, 1478, 80, 48, 14, 576, 1494, 1497, + /* 170 */ 274, 275, 581, 179, 163, 273, 1649, 2161, 583, 1981, + /* 180 */ 1987, 477, 558, 1413, 8, 1411, 2160, 473, 726, 346, + /* 190 */ 629, 233, 38, 37, 1820, 1523, 44, 42, 41, 40, + /* 200 */ 39, 2166, 179, 1495, 1496, 60, 2161, 583, 1416, 1417, + /* 210 */ 575, 1467, 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, + /* 220 */ 631, 627, 1486, 1487, 1489, 1490, 1491, 1492, 2, 572, + /* 230 */ 1338, 1339, 1439, 1468, 1478, 60, 489, 84, 120, 1494, + /* 240 */ 1497, 119, 118, 117, 116, 115, 114, 113, 112, 111, + /* 250 */ 347, 134, 345, 344, 1413, 512, 1411, 38, 37, 514, + /* 260 */ 1785, 44, 42, 41, 40, 39, 673, 34, 369, 1517, + /* 270 */ 1518, 1519, 1520, 1521, 1525, 1526, 1527, 1528, 173, 1416, + /* 280 */ 1417, 513, 1467, 1470, 1471, 1472, 1473, 1474, 1475, 1476, + /* 290 */ 1477, 631, 627, 1486, 1487, 1489, 1490, 1491, 1492, 2, + /* 300 */ 1893, 11, 45, 43, 1706, 605, 1133, 1659, 1132, 182, + /* 310 */ 371, 1658, 1412, 578, 573, 567, 182, 11, 2003, 9, + /* 320 */ 60, 216, 409, 1493, 408, 1410, 1240, 661, 660, 659, + /* 330 */ 1244, 658, 1246, 1247, 657, 1249, 654, 1134, 1255, 651, + /* 340 */ 1257, 1258, 648, 645, 1567, 1600, 405, 2164, 1488, 2021, + /* 350 */ 1437, 1971, 487, 18, 1902, 1971, 182, 636, 619, 1630, + /* 360 */ 1418, 1133, 1971, 1132, 635, 1436, 1437, 407, 403, 525, + /* 370 */ 524, 523, 130, 45, 43, 1498, 264, 135, 519, 515, + /* 380 */ 2106, 371, 518, 1412, 1992, 14, 182, 517, 522, 1790, + /* 390 */ 1556, 2002, 1134, 516, 1493, 2038, 1410, 605, 107, 2004, + /* 400 */ 639, 2006, 2007, 634, 2003, 629, 2103, 726, 141, 2165, + /* 410 */ 147, 2062, 2091, 2160, 31, 217, 365, 2087, 1524, 1488, + /* 420 */ 38, 37, 1495, 1496, 44, 42, 41, 40, 39, 2164, + /* 430 */ 168, 1418, 1994, 2161, 2163, 2021, 506, 502, 498, 494, + /* 440 */ 214, 60, 1418, 636, 603, 1503, 1902, 2165, 1971, 619, + /* 450 */ 635, 1437, 1468, 1478, 1629, 1438, 46, 539, 1494, 1497, + /* 460 */ 104, 38, 37, 54, 1439, 44, 42, 41, 40, 39, + /* 470 */ 537, 182, 535, 1413, 139, 1411, 85, 2002, 726, 212, + /* 480 */ 1790, 2038, 1782, 454, 165, 2004, 639, 2006, 2007, 634, + /* 490 */ 32, 629, 1469, 1495, 1496, 1657, 664, 27, 1416, 1417, + /* 500 */ 1529, 1467, 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, + /* 510 */ 631, 627, 1486, 1487, 1489, 1490, 1491, 1492, 2, 525, + /* 520 */ 524, 523, 84, 1468, 1478, 559, 2128, 135, 519, 1494, + /* 530 */ 1497, 164, 518, 11, 49, 619, 1744, 517, 522, 1971, + /* 540 */ 1623, 195, 194, 516, 1413, 1786, 1411, 211, 205, 184, + /* 550 */ 1656, 685, 210, 38, 37, 485, 1779, 44, 42, 41, + /* 560 */ 40, 39, 1438, 605, 453, 1440, 1790, 1355, 1356, 1416, + /* 570 */ 1417, 203, 1467, 1470, 1471, 1472, 1473, 1474, 1475, 1476, + /* 580 */ 1477, 631, 627, 1486, 1487, 1489, 1490, 1491, 1492, 2, + /* 590 */ 45, 43, 182, 1469, 1971, 671, 1837, 1838, 371, 1638, + /* 600 */ 1412, 521, 520, 1354, 1357, 1590, 2003, 1873, 264, 585, + /* 610 */ 614, 1493, 1902, 1410, 152, 151, 668, 667, 666, 149, + /* 620 */ 120, 1775, 594, 119, 118, 117, 116, 115, 114, 113, + /* 630 */ 112, 111, 13, 12, 38, 37, 1488, 2021, 44, 42, + /* 640 */ 41, 40, 39, 2165, 1768, 597, 619, 2160, 1418, 1777, + /* 650 */ 1971, 175, 635, 138, 569, 1588, 1589, 1591, 1592, 1888, + /* 660 */ 414, 45, 43, 2164, 1830, 1843, 231, 2161, 2162, 371, + /* 670 */ 187, 1412, 364, 46, 1283, 1284, 232, 1790, 621, 2002, + /* 680 */ 2063, 1841, 1493, 2038, 1410, 182, 107, 2004, 639, 2006, + /* 690 */ 2007, 634, 2003, 629, 619, 726, 1843, 1766, 176, 623, + /* 700 */ 2091, 2063, 1200, 375, 365, 2087, 489, 1488, 415, 242, + /* 710 */ 1495, 1496, 1841, 1655, 1773, 596, 177, 2099, 2100, 1418, + /* 720 */ 136, 2104, 1579, 2021, 1637, 1790, 2118, 1536, 237, 87, + /* 730 */ 330, 636, 1412, 543, 1654, 541, 1971, 1202, 635, 1653, + /* 740 */ 1468, 1478, 1389, 1390, 14, 1410, 1494, 1497, 129, 128, + /* 750 */ 127, 126, 125, 124, 123, 122, 121, 1971, 434, 673, + /* 760 */ 630, 1413, 686, 1411, 1760, 2002, 726, 433, 663, 2038, + /* 770 */ 697, 695, 165, 2004, 639, 2006, 2007, 634, 1971, 629, + /* 780 */ 1418, 1495, 1496, 1971, 2106, 1652, 1416, 1417, 410, 1467, + /* 790 */ 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 631, 627, + /* 800 */ 1486, 1487, 1489, 1490, 1491, 1492, 2, 619, 1888, 1888, + /* 810 */ 2102, 1468, 1478, 328, 2129, 1435, 619, 1494, 1497, 189, + /* 820 */ 193, 424, 447, 619, 98, 461, 2106, 726, 460, 1971, + /* 830 */ 439, 558, 1413, 1843, 1411, 2160, 363, 440, 1790, 553, + /* 840 */ 41, 40, 39, 430, 161, 462, 1783, 1790, 432, 1842, + /* 850 */ 2166, 179, 2101, 1792, 1790, 2161, 583, 1416, 1417, 1958, + /* 860 */ 1467, 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 631, + /* 870 */ 627, 1486, 1487, 1489, 1490, 1491, 1492, 2, 1767, 374, + /* 880 */ 1119, 1120, 161, 162, 1651, 619, 619, 161, 303, 343, + /* 890 */ 1703, 1793, 514, 1413, 1765, 1411, 1792, 1437, 33, 488, + /* 900 */ 1787, 420, 301, 70, 38, 37, 69, 393, 44, 42, + /* 910 */ 41, 40, 39, 377, 513, 1745, 1790, 1790, 1416, 1417, + /* 920 */ 140, 161, 259, 2062, 199, 467, 465, 2131, 1971, 665, + /* 930 */ 1792, 458, 1834, 1560, 452, 451, 450, 449, 446, 445, + /* 940 */ 444, 443, 442, 438, 437, 436, 435, 327, 427, 426, + /* 950 */ 425, 570, 422, 421, 341, 703, 702, 701, 700, 381, + /* 960 */ 60, 699, 698, 142, 693, 692, 691, 690, 689, 688, + /* 970 */ 687, 154, 683, 682, 681, 380, 379, 678, 677, 676, + /* 980 */ 675, 674, 1648, 530, 1440, 671, 38, 37, 594, 417, + /* 990 */ 44, 42, 41, 40, 39, 1632, 1633, 1440, 540, 106, + /* 1000 */ 619, 671, 418, 619, 152, 151, 668, 667, 666, 149, + /* 1010 */ 2111, 1556, 230, 1647, 234, 619, 2003, 284, 586, 138, + /* 1020 */ 152, 151, 668, 667, 666, 149, 1971, 533, 594, 554, + /* 1030 */ 619, 1790, 527, 1646, 1790, 1645, 619, 229, 150, 1469, + /* 1040 */ 78, 77, 413, 253, 598, 186, 1790, 2021, 1644, 669, + /* 1050 */ 602, 670, 1834, 297, 1834, 636, 1820, 1971, 1693, 138, + /* 1060 */ 1971, 1790, 635, 326, 619, 1643, 401, 1790, 399, 395, + /* 1070 */ 391, 388, 385, 67, 2003, 589, 66, 1971, 278, 1971, + /* 1080 */ 526, 1421, 178, 2099, 2100, 1642, 136, 2104, 619, 2002, + /* 1090 */ 53, 215, 1971, 2038, 71, 1790, 107, 2004, 639, 2006, + /* 1100 */ 2007, 634, 616, 629, 2003, 2021, 13, 12, 2180, 1971, + /* 1110 */ 2091, 182, 150, 636, 365, 2087, 382, 2022, 1971, 1790, + /* 1120 */ 635, 2003, 180, 2099, 2100, 2125, 136, 2104, 188, 1971, + /* 1130 */ 1641, 619, 38, 37, 1674, 2021, 44, 42, 41, 40, + /* 1140 */ 39, 241, 160, 636, 79, 617, 1640, 2002, 1971, 619, + /* 1150 */ 635, 2038, 2021, 1686, 107, 2004, 639, 2006, 2007, 634, + /* 1160 */ 636, 629, 1790, 378, 1387, 1971, 2180, 635, 2091, 50, + /* 1170 */ 1684, 3, 365, 2087, 1971, 528, 1559, 2002, 2003, 240, + /* 1180 */ 1790, 2038, 600, 2138, 313, 2004, 639, 2006, 2007, 634, + /* 1190 */ 1971, 629, 531, 144, 2002, 132, 222, 224, 2038, 220, + /* 1200 */ 223, 107, 2004, 639, 2006, 2007, 634, 1420, 629, 2021, + /* 1210 */ 1897, 226, 1831, 2180, 225, 2091, 52, 636, 88, 365, + /* 1220 */ 2087, 384, 1971, 557, 635, 558, 62, 626, 579, 2160, + /* 1230 */ 565, 1424, 228, 368, 367, 227, 2003, 2121, 246, 595, + /* 1240 */ 150, 587, 47, 1426, 2166, 179, 1, 271, 258, 2161, + /* 1250 */ 583, 2002, 47, 1680, 1493, 2038, 1419, 4, 107, 2004, + /* 1260 */ 639, 2006, 2007, 634, 558, 629, 2003, 2021, 2160, 261, + /* 1270 */ 2180, 1162, 2091, 68, 148, 636, 365, 2087, 1587, 1488, + /* 1280 */ 1971, 150, 635, 2166, 179, 103, 679, 2154, 2161, 583, + /* 1290 */ 248, 1418, 601, 387, 1352, 100, 392, 2021, 2003, 276, + /* 1300 */ 590, 340, 721, 62, 1479, 636, 1163, 47, 1181, 2002, + /* 1310 */ 1971, 643, 635, 2038, 291, 148, 107, 2004, 639, 2006, + /* 1320 */ 2007, 634, 150, 629, 133, 611, 280, 1374, 2180, 2021, + /* 1330 */ 2091, 192, 680, 1233, 365, 2087, 148, 636, 625, 2002, + /* 1340 */ 1440, 419, 1971, 2038, 635, 2110, 107, 2004, 639, 2006, + /* 1350 */ 2007, 634, 383, 629, 1179, 1530, 1898, 1423, 2066, 296, + /* 1360 */ 2091, 423, 456, 1261, 365, 2087, 1435, 1265, 428, 441, + /* 1370 */ 455, 2002, 1514, 1890, 1272, 2038, 1270, 2003, 107, 2004, + /* 1380 */ 639, 2006, 2007, 634, 448, 629, 457, 463, 153, 464, + /* 1390 */ 2064, 196, 2091, 466, 468, 558, 365, 2087, 1441, 2160, + /* 1400 */ 469, 478, 1443, 481, 1427, 202, 1422, 1438, 2021, 482, + /* 1410 */ 204, 1442, 483, 1444, 2166, 179, 636, 484, 207, 2161, + /* 1420 */ 583, 1971, 486, 635, 209, 546, 82, 490, 83, 1430, + /* 1430 */ 1432, 213, 1136, 507, 508, 2003, 511, 1780, 509, 219, + /* 1440 */ 1776, 110, 627, 1486, 1487, 1489, 1490, 1491, 1492, 221, + /* 1450 */ 2002, 155, 156, 329, 2038, 2003, 1778, 107, 2004, 639, + /* 1460 */ 2006, 2007, 634, 1774, 629, 545, 2021, 547, 558, 622, + /* 1470 */ 157, 2091, 2160, 158, 636, 365, 2087, 235, 86, 1971, + /* 1480 */ 292, 635, 1948, 548, 1947, 238, 2021, 2166, 179, 552, + /* 1490 */ 571, 555, 2161, 583, 636, 146, 549, 609, 2122, 1971, + /* 1500 */ 2132, 635, 562, 568, 2137, 2136, 244, 247, 2002, 7, + /* 1510 */ 354, 574, 2038, 2003, 580, 108, 2004, 639, 2006, 2007, + /* 1520 */ 634, 2113, 629, 560, 563, 252, 355, 561, 2002, 2091, + /* 1530 */ 255, 169, 2038, 2090, 2087, 108, 2004, 639, 2006, 2007, + /* 1540 */ 634, 588, 629, 2003, 2021, 254, 257, 591, 1556, 2091, + /* 1550 */ 256, 137, 636, 624, 2087, 1439, 2107, 1971, 358, 635, + /* 1560 */ 2003, 599, 1445, 266, 2183, 1903, 93, 612, 293, 294, + /* 1570 */ 607, 613, 608, 260, 2021, 1917, 95, 1916, 2159, 1915, + /* 1580 */ 361, 97, 633, 295, 1791, 59, 637, 1971, 2072, 635, + /* 1590 */ 2038, 2021, 99, 108, 2004, 639, 2006, 2007, 634, 636, + /* 1600 */ 629, 1835, 641, 298, 1971, 722, 635, 2091, 1761, 723, + /* 1610 */ 287, 334, 2087, 725, 51, 331, 2002, 2003, 300, 307, + /* 1620 */ 2038, 332, 322, 319, 2004, 639, 2006, 2007, 634, 632, + /* 1630 */ 629, 620, 2056, 2002, 302, 321, 1965, 2038, 311, 1964, + /* 1640 */ 166, 2004, 639, 2006, 2007, 634, 75, 629, 2021, 1963, + /* 1650 */ 1962, 76, 1959, 389, 390, 1404, 636, 1405, 185, 394, + /* 1660 */ 1957, 1971, 396, 635, 2003, 397, 398, 1956, 400, 1955, + /* 1670 */ 402, 1954, 1953, 404, 1377, 406, 1376, 1928, 1927, 411, + /* 1680 */ 412, 2003, 1926, 1925, 1329, 1881, 1880, 1878, 1877, 143, + /* 1690 */ 2002, 1876, 584, 2181, 2038, 2021, 1879, 108, 2004, 639, + /* 1700 */ 2006, 2007, 634, 636, 629, 1875, 1874, 1872, 1971, 190, + /* 1710 */ 635, 2091, 2021, 1871, 1870, 429, 2088, 360, 1869, 431, + /* 1720 */ 636, 1883, 1868, 1867, 1866, 1971, 1865, 635, 1864, 1863, + /* 1730 */ 1862, 1861, 1860, 1859, 1858, 1857, 2003, 2002, 1856, 1855, + /* 1740 */ 1854, 2038, 145, 1853, 166, 2004, 639, 2006, 2007, 634, + /* 1750 */ 1852, 629, 1851, 1882, 2002, 1850, 1849, 1848, 2038, 2003, + /* 1760 */ 1847, 320, 2004, 639, 2006, 2007, 634, 2021, 629, 1331, + /* 1770 */ 1846, 1845, 1844, 459, 1708, 633, 1208, 197, 1707, 1705, + /* 1780 */ 1971, 1669, 635, 198, 200, 73, 1668, 1122, 174, 1121, + /* 1790 */ 2021, 2003, 1991, 1941, 1935, 370, 474, 2182, 636, 201, + /* 1800 */ 74, 476, 1924, 1971, 206, 635, 208, 1923, 1901, 2002, + /* 1810 */ 1769, 1704, 1155, 2038, 1702, 491, 319, 2004, 639, 2006, + /* 1820 */ 2007, 634, 2021, 629, 492, 2057, 493, 372, 1700, 497, + /* 1830 */ 636, 495, 2002, 496, 1698, 1971, 2038, 635, 2003, 320, + /* 1840 */ 2004, 639, 2006, 2007, 634, 500, 629, 499, 501, 1696, + /* 1850 */ 503, 504, 729, 1683, 1682, 505, 1665, 1771, 1277, 1276, + /* 1860 */ 218, 1770, 2003, 694, 2002, 1199, 290, 61, 2038, 2021, + /* 1870 */ 1198, 320, 2004, 639, 2006, 2007, 634, 636, 629, 1197, + /* 1880 */ 1196, 172, 1971, 696, 635, 1193, 1192, 719, 715, 711, + /* 1890 */ 707, 288, 1191, 2021, 1190, 1694, 348, 1687, 349, 1685, + /* 1900 */ 350, 636, 529, 532, 1664, 1663, 1971, 534, 635, 1662, + /* 1910 */ 536, 544, 538, 109, 1394, 2038, 1393, 1396, 315, 2004, + /* 1920 */ 639, 2006, 2007, 634, 26, 629, 1940, 105, 2003, 1383, + /* 1930 */ 281, 542, 55, 1934, 550, 2002, 1922, 159, 1920, 2038, + /* 1940 */ 2165, 551, 304, 2004, 639, 2006, 2007, 634, 239, 629, + /* 1950 */ 2003, 19, 352, 16, 1602, 556, 564, 28, 566, 2021, + /* 1960 */ 243, 58, 5, 615, 63, 245, 6, 636, 250, 1586, + /* 1970 */ 251, 30, 1971, 1578, 635, 2003, 1992, 167, 249, 29, + /* 1980 */ 89, 2021, 1622, 1623, 21, 1617, 1616, 356, 1621, 636, + /* 1990 */ 1620, 357, 1553, 263, 1971, 170, 635, 1552, 268, 92, + /* 2000 */ 1899, 2002, 57, 267, 1921, 2038, 2021, 1919, 305, 2004, + /* 2010 */ 639, 2006, 2007, 634, 636, 629, 20, 1918, 1900, 1971, + /* 2020 */ 1381, 635, 236, 2002, 269, 91, 22, 2038, 56, 272, + /* 2030 */ 306, 2004, 639, 2006, 2007, 634, 277, 629, 2003, 17, + /* 2040 */ 270, 1584, 65, 282, 94, 23, 1505, 610, 2002, 96, + /* 2050 */ 12, 10, 2038, 1504, 279, 312, 2004, 639, 2006, 2007, + /* 2060 */ 634, 1428, 629, 1515, 100, 2041, 2003, 1483, 628, 2021, + /* 2070 */ 1481, 36, 171, 183, 1480, 15, 24, 636, 640, 1452, + /* 2080 */ 1460, 638, 1971, 25, 635, 1262, 642, 373, 644, 646, + /* 2090 */ 1259, 1256, 647, 650, 649, 652, 2003, 2021, 1250, 1248, + /* 2100 */ 655, 653, 1239, 656, 1254, 636, 1253, 101, 285, 1252, + /* 2110 */ 1971, 2002, 635, 1267, 102, 2038, 662, 1271, 316, 2004, + /* 2120 */ 639, 2006, 2007, 634, 72, 629, 1153, 2021, 2003, 1251, + /* 2130 */ 672, 1187, 1186, 1185, 1184, 636, 1183, 1182, 1180, 2002, + /* 2140 */ 1971, 1178, 635, 2038, 1177, 1176, 308, 2004, 639, 2006, + /* 2150 */ 2007, 634, 286, 629, 1206, 684, 1174, 1173, 1172, 2021, + /* 2160 */ 2003, 1171, 1170, 1169, 1168, 1203, 1201, 636, 1165, 2002, + /* 2170 */ 1164, 1161, 1971, 2038, 635, 1160, 317, 2004, 639, 2006, + /* 2180 */ 2007, 634, 1159, 629, 1158, 1701, 704, 706, 1699, 705, + /* 2190 */ 708, 2021, 2003, 709, 1697, 710, 712, 714, 713, 636, + /* 2200 */ 1695, 2002, 716, 718, 1971, 2038, 635, 717, 309, 2004, + /* 2210 */ 639, 2006, 2007, 634, 1681, 629, 720, 2003, 1111, 1661, + /* 2220 */ 289, 1414, 724, 2021, 299, 727, 728, 1636, 1636, 1636, + /* 2230 */ 1636, 636, 1636, 2002, 1636, 1636, 1971, 2038, 635, 1636, + /* 2240 */ 318, 2004, 639, 2006, 2007, 634, 1636, 629, 2021, 2003, + /* 2250 */ 1636, 1636, 1636, 1636, 1636, 1636, 636, 1636, 1636, 1636, + /* 2260 */ 1636, 1971, 1636, 635, 1636, 2002, 1636, 1636, 1636, 2038, + /* 2270 */ 1636, 1636, 310, 2004, 639, 2006, 2007, 634, 1636, 629, + /* 2280 */ 2021, 1636, 1636, 1636, 1636, 1636, 1636, 1636, 636, 1636, + /* 2290 */ 2002, 1636, 1636, 1971, 2038, 635, 1636, 323, 2004, 639, + /* 2300 */ 2006, 2007, 634, 1636, 629, 1636, 1636, 1636, 1636, 1636, + /* 2310 */ 1636, 2003, 1636, 1636, 1636, 1636, 1636, 1636, 1636, 1636, + /* 2320 */ 1636, 1636, 2002, 1636, 1636, 1636, 2038, 1636, 2003, 324, + /* 2330 */ 2004, 639, 2006, 2007, 634, 1636, 629, 1636, 1636, 1636, + /* 2340 */ 1636, 1636, 2021, 1636, 1636, 1636, 1636, 1636, 1636, 1636, + /* 2350 */ 636, 1636, 1636, 1636, 1636, 1971, 1636, 635, 1636, 2021, + /* 2360 */ 1636, 1636, 1636, 1636, 1636, 1636, 1636, 636, 1636, 1636, + /* 2370 */ 1636, 1636, 1971, 1636, 635, 1636, 1636, 1636, 1636, 1636, + /* 2380 */ 1636, 1636, 1636, 1636, 2002, 2003, 1636, 1636, 2038, 1636, + /* 2390 */ 1636, 2015, 2004, 639, 2006, 2007, 634, 1636, 629, 1636, + /* 2400 */ 1636, 2002, 1636, 1636, 1636, 2038, 1636, 2003, 2014, 2004, + /* 2410 */ 639, 2006, 2007, 634, 1636, 629, 2021, 1636, 1636, 1636, + /* 2420 */ 1636, 1636, 1636, 1636, 636, 1636, 1636, 1636, 1636, 1971, + /* 2430 */ 1636, 635, 1636, 1636, 1636, 1636, 1636, 1636, 2021, 1636, + /* 2440 */ 1636, 1636, 1636, 1636, 1636, 1636, 636, 1636, 1636, 1636, + /* 2450 */ 1636, 1971, 1636, 635, 1636, 1636, 1636, 1636, 2002, 1636, + /* 2460 */ 1636, 1636, 2038, 1636, 1636, 2013, 2004, 639, 2006, 2007, + /* 2470 */ 634, 1636, 629, 2003, 1636, 1636, 1636, 1636, 1636, 1636, + /* 2480 */ 2002, 1636, 1636, 1636, 2038, 1636, 1636, 336, 2004, 639, + /* 2490 */ 2006, 2007, 634, 1636, 629, 1636, 1636, 2003, 1636, 1636, + /* 2500 */ 1636, 1636, 1636, 1636, 2021, 1636, 1636, 1636, 1636, 1636, + /* 2510 */ 1636, 1636, 636, 1636, 1636, 1636, 1636, 1971, 1636, 635, + /* 2520 */ 1636, 1636, 1636, 1636, 1636, 1636, 1636, 1636, 2021, 1636, + /* 2530 */ 1636, 1636, 1636, 1636, 1636, 1636, 636, 1636, 1636, 1636, + /* 2540 */ 1636, 1971, 1636, 635, 1636, 1636, 2002, 1636, 1636, 1636, + /* 2550 */ 2038, 1636, 1636, 337, 2004, 639, 2006, 2007, 634, 1636, + /* 2560 */ 629, 2003, 1636, 1636, 1636, 1636, 1636, 1636, 1636, 1636, + /* 2570 */ 2002, 1636, 1636, 1636, 2038, 1636, 1636, 333, 2004, 639, + /* 2580 */ 2006, 2007, 634, 1636, 629, 1636, 2003, 1636, 1636, 1636, + /* 2590 */ 1636, 1636, 2021, 1636, 1636, 1636, 1636, 1636, 1636, 1636, + /* 2600 */ 636, 1636, 1636, 1636, 1636, 1971, 1636, 635, 1636, 1636, + /* 2610 */ 1636, 1636, 1636, 1636, 1636, 1636, 1636, 2021, 2003, 1636, + /* 2620 */ 1636, 1636, 1636, 1636, 1636, 636, 1636, 1636, 1636, 1636, + /* 2630 */ 1971, 1636, 635, 1636, 2002, 1636, 1636, 1636, 2038, 1636, + /* 2640 */ 1636, 338, 2004, 639, 2006, 2007, 634, 1636, 629, 2021, + /* 2650 */ 1636, 1636, 1636, 1636, 1636, 1636, 1636, 636, 1636, 637, + /* 2660 */ 1636, 1636, 1971, 2038, 635, 1636, 315, 2004, 639, 2006, + /* 2670 */ 2007, 634, 1636, 629, 1636, 1636, 1636, 1636, 1636, 1636, + /* 2680 */ 1636, 1636, 1636, 1636, 1636, 1636, 1636, 1636, 1636, 1636, + /* 2690 */ 1636, 2002, 1636, 1636, 1636, 2038, 1636, 1636, 314, 2004, + /* 2700 */ 639, 2006, 2007, 634, 1636, 629, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 422, 423, 361, 375, 433, 375, 353, 433, 437, 356, - /* 10 */ 362, 437, 12, 13, 14, 385, 388, 389, 388, 389, - /* 20 */ 20, 373, 22, 362, 453, 0, 452, 453, 457, 458, - /* 30 */ 329, 457, 458, 33, 373, 35, 12, 13, 14, 15, - /* 40 */ 16, 21, 8, 9, 362, 3, 12, 13, 14, 15, - /* 50 */ 16, 403, 404, 405, 34, 373, 36, 337, 58, 20, - /* 60 */ 326, 360, 414, 63, 403, 404, 405, 14, 371, 368, - /* 70 */ 70, 374, 375, 20, 373, 414, 375, 333, 337, 335, - /* 80 */ 336, 20, 360, 12, 13, 403, 404, 62, 368, 367, - /* 90 */ 20, 20, 328, 22, 330, 95, 414, 63, 376, 334, - /* 100 */ 337, 400, 337, 338, 33, 404, 35, 20, 407, 408, - /* 110 */ 409, 410, 411, 412, 351, 414, 337, 117, 377, 433, - /* 120 */ 419, 358, 421, 437, 390, 368, 425, 426, 20, 58, - /* 130 */ 351, 368, 132, 133, 63, 20, 379, 358, 104, 453, - /* 140 */ 439, 70, 334, 457, 458, 337, 338, 368, 447, 429, - /* 150 */ 430, 431, 360, 433, 434, 433, 360, 437, 4, 437, - /* 160 */ 360, 369, 162, 163, 368, 95, 95, 433, 168, 169, - /* 170 */ 20, 437, 452, 453, 452, 453, 337, 457, 458, 457, - /* 180 */ 458, 381, 382, 183, 360, 185, 452, 453, 117, 37, - /* 190 */ 351, 457, 458, 132, 133, 161, 0, 43, 58, 45, - /* 200 */ 46, 162, 163, 132, 133, 409, 382, 368, 208, 209, - /* 210 */ 95, 211, 212, 213, 214, 215, 216, 217, 218, 219, - /* 220 */ 220, 221, 222, 223, 224, 225, 226, 227, 228, 168, - /* 230 */ 169, 126, 127, 162, 163, 95, 131, 97, 21, 168, + /* 0 */ 375, 333, 371, 335, 336, 374, 375, 333, 362, 335, + /* 10 */ 336, 375, 12, 13, 14, 390, 391, 360, 330, 373, + /* 20 */ 20, 362, 22, 387, 360, 362, 390, 391, 329, 424, + /* 30 */ 425, 367, 373, 33, 329, 35, 373, 20, 381, 382, + /* 40 */ 376, 334, 8, 9, 337, 338, 12, 13, 14, 15, + /* 50 */ 16, 405, 406, 407, 337, 337, 20, 435, 58, 360, + /* 60 */ 20, 439, 416, 63, 405, 406, 407, 368, 405, 406, + /* 70 */ 70, 337, 373, 326, 375, 416, 454, 455, 373, 416, + /* 80 */ 360, 459, 460, 12, 13, 351, 368, 367, 20, 4, + /* 90 */ 20, 20, 358, 22, 377, 95, 376, 63, 20, 435, + /* 100 */ 360, 402, 368, 439, 33, 406, 35, 367, 409, 410, + /* 110 */ 411, 412, 413, 414, 4, 416, 376, 117, 454, 455, + /* 120 */ 421, 58, 423, 459, 460, 58, 427, 428, 43, 58, + /* 130 */ 45, 46, 132, 133, 63, 95, 362, 20, 104, 392, + /* 140 */ 441, 70, 12, 13, 14, 15, 16, 373, 449, 431, + /* 150 */ 432, 433, 334, 435, 436, 337, 338, 439, 95, 360, + /* 160 */ 97, 94, 162, 163, 97, 95, 95, 368, 168, 169, + /* 170 */ 126, 127, 454, 455, 328, 131, 330, 459, 460, 405, + /* 180 */ 406, 14, 435, 183, 39, 185, 439, 20, 117, 37, + /* 190 */ 416, 353, 8, 9, 356, 161, 12, 13, 14, 15, + /* 200 */ 16, 454, 455, 132, 133, 95, 459, 460, 208, 209, + /* 210 */ 411, 211, 212, 213, 214, 215, 216, 217, 218, 219, + /* 220 */ 220, 221, 222, 223, 224, 225, 226, 227, 228, 167, + /* 230 */ 162, 163, 20, 162, 163, 95, 62, 343, 21, 168, /* 240 */ 169, 24, 25, 26, 27, 28, 29, 30, 31, 32, - /* 250 */ 98, 164, 100, 101, 183, 103, 185, 8, 9, 107, - /* 260 */ 62, 12, 13, 14, 15, 16, 208, 233, 234, 235, - /* 270 */ 236, 237, 238, 239, 240, 241, 242, 243, 95, 208, + /* 250 */ 98, 357, 100, 101, 183, 103, 185, 8, 9, 107, + /* 260 */ 366, 12, 13, 14, 15, 16, 62, 233, 234, 235, + /* 270 */ 236, 237, 238, 239, 240, 241, 242, 243, 360, 208, /* 280 */ 209, 129, 211, 212, 213, 214, 215, 216, 217, 218, /* 290 */ 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, - /* 300 */ 95, 230, 12, 13, 0, 20, 20, 265, 22, 22, - /* 310 */ 20, 417, 22, 362, 420, 257, 258, 259, 260, 261, - /* 320 */ 329, 35, 35, 33, 373, 35, 108, 109, 110, 111, + /* 300 */ 382, 230, 12, 13, 0, 337, 20, 329, 22, 246, + /* 310 */ 20, 329, 22, 251, 252, 253, 246, 230, 329, 232, + /* 320 */ 95, 35, 182, 33, 184, 35, 108, 109, 110, 111, /* 330 */ 112, 113, 114, 115, 116, 117, 118, 51, 120, 121, - /* 340 */ 122, 123, 124, 125, 35, 96, 95, 151, 58, 343, - /* 350 */ 4, 360, 14, 63, 403, 404, 160, 70, 20, 368, - /* 360 */ 70, 246, 341, 357, 373, 414, 375, 374, 375, 65, - /* 370 */ 66, 67, 366, 12, 13, 14, 355, 73, 74, 70, - /* 380 */ 95, 20, 78, 22, 363, 95, 246, 83, 84, 3, - /* 390 */ 343, 400, 344, 89, 33, 404, 35, 349, 407, 408, - /* 400 */ 409, 410, 411, 412, 117, 414, 20, 117, 417, 20, - /* 410 */ 419, 420, 421, 366, 2, 33, 425, 426, 0, 58, - /* 420 */ 8, 9, 132, 133, 12, 13, 14, 15, 16, 246, - /* 430 */ 48, 70, 230, 182, 232, 184, 54, 55, 56, 57, - /* 440 */ 58, 95, 24, 25, 26, 27, 28, 29, 30, 31, - /* 450 */ 32, 246, 162, 163, 20, 167, 95, 14, 168, 169, - /* 460 */ 0, 8, 9, 20, 360, 12, 13, 14, 15, 16, - /* 470 */ 183, 367, 185, 183, 353, 185, 94, 356, 117, 97, - /* 480 */ 376, 21, 96, 0, 24, 25, 26, 27, 28, 29, - /* 490 */ 30, 31, 32, 132, 133, 208, 209, 246, 208, 209, - /* 500 */ 162, 211, 212, 213, 214, 215, 216, 217, 218, 219, + /* 340 */ 122, 123, 124, 125, 14, 96, 178, 3, 58, 360, + /* 350 */ 20, 373, 384, 63, 386, 373, 246, 368, 337, 175, + /* 360 */ 70, 20, 373, 22, 375, 20, 20, 199, 200, 65, + /* 370 */ 66, 67, 351, 12, 13, 14, 164, 73, 74, 358, + /* 380 */ 408, 20, 78, 22, 47, 95, 246, 83, 84, 368, + /* 390 */ 245, 402, 51, 89, 33, 406, 35, 337, 409, 410, + /* 400 */ 411, 412, 413, 414, 329, 416, 434, 117, 419, 435, + /* 410 */ 421, 422, 423, 439, 2, 33, 427, 428, 161, 58, + /* 420 */ 8, 9, 132, 133, 12, 13, 14, 15, 16, 455, + /* 430 */ 48, 70, 95, 459, 460, 360, 54, 55, 56, 57, + /* 440 */ 58, 95, 70, 368, 384, 14, 386, 3, 373, 337, + /* 450 */ 375, 20, 162, 163, 270, 20, 95, 21, 168, 169, + /* 460 */ 341, 8, 9, 351, 20, 12, 13, 14, 15, 16, + /* 470 */ 34, 246, 36, 183, 355, 185, 94, 402, 117, 97, + /* 480 */ 368, 406, 363, 79, 409, 410, 411, 412, 413, 414, + /* 490 */ 233, 416, 162, 132, 133, 329, 106, 44, 208, 209, + /* 500 */ 243, 211, 212, 213, 214, 215, 216, 217, 218, 219, /* 510 */ 220, 221, 222, 223, 224, 225, 226, 227, 228, 65, - /* 520 */ 66, 67, 20, 162, 163, 346, 347, 73, 74, 168, - /* 530 */ 169, 246, 78, 333, 352, 335, 336, 83, 84, 251, - /* 540 */ 252, 253, 360, 89, 183, 62, 185, 165, 166, 44, - /* 550 */ 164, 369, 170, 8, 9, 173, 79, 12, 13, 14, - /* 560 */ 15, 16, 337, 62, 329, 20, 132, 133, 106, 208, + /* 520 */ 66, 67, 343, 162, 163, 450, 451, 73, 74, 168, + /* 530 */ 169, 344, 78, 230, 95, 337, 349, 83, 84, 373, + /* 540 */ 96, 137, 138, 89, 183, 366, 185, 165, 166, 351, + /* 550 */ 329, 70, 170, 8, 9, 173, 361, 12, 13, 14, + /* 560 */ 15, 16, 20, 337, 160, 20, 368, 132, 133, 208, /* 570 */ 209, 189, 211, 212, 213, 214, 215, 216, 217, 218, /* 580 */ 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, - /* 590 */ 12, 13, 246, 368, 370, 360, 329, 373, 20, 352, - /* 600 */ 22, 96, 360, 368, 359, 162, 230, 360, 373, 367, - /* 610 */ 375, 33, 127, 35, 137, 138, 369, 372, 376, 8, - /* 620 */ 9, 329, 360, 12, 13, 14, 15, 16, 175, 367, - /* 630 */ 14, 15, 16, 337, 360, 400, 58, 160, 376, 404, - /* 640 */ 373, 367, 407, 408, 409, 410, 411, 412, 70, 414, - /* 650 */ 376, 70, 360, 428, 429, 430, 431, 70, 433, 434, - /* 660 */ 368, 12, 13, 337, 368, 373, 337, 375, 341, 20, - /* 670 */ 352, 22, 329, 95, 337, 190, 191, 351, 360, 194, - /* 680 */ 351, 196, 33, 20, 35, 22, 451, 369, 351, 329, - /* 690 */ 363, 418, 400, 420, 368, 117, 404, 368, 330, 407, - /* 700 */ 408, 409, 410, 411, 412, 368, 414, 58, 337, 164, - /* 710 */ 132, 133, 126, 421, 51, 178, 373, 425, 426, 70, - /* 720 */ 360, 368, 351, 270, 0, 429, 430, 431, 368, 433, - /* 730 */ 434, 337, 379, 373, 337, 375, 199, 200, 361, 368, - /* 740 */ 162, 163, 346, 347, 95, 351, 168, 169, 351, 8, - /* 750 */ 9, 1, 2, 12, 13, 14, 15, 16, 406, 0, - /* 760 */ 400, 183, 368, 185, 404, 368, 117, 407, 408, 409, - /* 770 */ 410, 411, 412, 413, 414, 415, 416, 370, 192, 193, - /* 780 */ 373, 132, 133, 20, 432, 44, 208, 209, 337, 211, + /* 590 */ 12, 13, 246, 162, 373, 107, 374, 375, 20, 0, + /* 600 */ 22, 346, 347, 168, 169, 208, 329, 0, 164, 265, + /* 610 */ 384, 33, 386, 35, 126, 127, 128, 129, 130, 131, + /* 620 */ 21, 361, 337, 24, 25, 26, 27, 28, 29, 30, + /* 630 */ 31, 32, 1, 2, 8, 9, 58, 360, 12, 13, + /* 640 */ 14, 15, 16, 435, 0, 368, 337, 439, 70, 361, + /* 650 */ 373, 359, 375, 368, 257, 258, 259, 260, 261, 368, + /* 660 */ 351, 12, 13, 455, 372, 360, 127, 459, 460, 20, + /* 670 */ 379, 22, 367, 95, 132, 133, 126, 368, 420, 402, + /* 680 */ 422, 376, 33, 406, 35, 246, 409, 410, 411, 412, + /* 690 */ 413, 414, 329, 416, 337, 117, 360, 0, 421, 420, + /* 700 */ 423, 422, 35, 367, 427, 428, 62, 58, 351, 164, + /* 710 */ 132, 133, 376, 329, 361, 430, 431, 432, 433, 70, + /* 720 */ 435, 436, 96, 360, 0, 368, 449, 96, 361, 190, + /* 730 */ 191, 368, 22, 194, 329, 196, 373, 70, 375, 329, + /* 740 */ 162, 163, 192, 193, 95, 35, 168, 169, 24, 25, + /* 750 */ 26, 27, 28, 29, 30, 31, 32, 373, 151, 62, + /* 760 */ 361, 183, 348, 185, 350, 402, 117, 160, 361, 406, + /* 770 */ 346, 347, 409, 410, 411, 412, 413, 414, 373, 416, + /* 780 */ 70, 132, 133, 373, 408, 329, 208, 209, 392, 211, /* 790 */ 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, - /* 800 */ 222, 223, 224, 225, 226, 227, 228, 337, 49, 337, - /* 810 */ 337, 162, 163, 18, 107, 20, 337, 168, 169, 368, - /* 820 */ 58, 351, 27, 351, 351, 30, 360, 418, 33, 420, - /* 830 */ 351, 107, 183, 368, 185, 329, 129, 161, 368, 20, - /* 840 */ 368, 368, 376, 48, 379, 50, 96, 368, 53, 20, - /* 850 */ 126, 127, 128, 129, 130, 131, 94, 208, 209, 97, + /* 800 */ 222, 223, 224, 225, 226, 227, 228, 337, 368, 368, + /* 810 */ 434, 162, 163, 18, 451, 20, 337, 168, 169, 379, + /* 820 */ 379, 351, 27, 337, 341, 30, 408, 117, 33, 373, + /* 830 */ 351, 435, 183, 360, 185, 439, 352, 351, 368, 396, + /* 840 */ 14, 15, 16, 48, 360, 50, 363, 368, 53, 376, + /* 850 */ 454, 455, 434, 369, 368, 459, 460, 208, 209, 0, /* 860 */ 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, - /* 870 */ 221, 222, 223, 224, 225, 226, 227, 228, 0, 373, - /* 880 */ 429, 430, 431, 18, 433, 434, 2, 406, 23, 94, - /* 890 */ 0, 337, 8, 9, 406, 4, 12, 13, 14, 15, - /* 900 */ 16, 106, 37, 38, 370, 351, 41, 373, 39, 233, - /* 910 */ 8, 9, 44, 432, 12, 13, 14, 15, 16, 243, - /* 920 */ 432, 348, 368, 350, 59, 60, 61, 164, 45, 46, - /* 930 */ 63, 136, 244, 245, 139, 140, 141, 142, 143, 144, + /* 870 */ 221, 222, 223, 224, 225, 226, 227, 228, 0, 352, + /* 880 */ 45, 46, 360, 18, 329, 337, 337, 360, 23, 94, + /* 890 */ 0, 369, 107, 183, 0, 185, 369, 20, 2, 351, + /* 900 */ 351, 106, 37, 38, 8, 9, 41, 48, 12, 13, + /* 910 */ 14, 15, 16, 352, 129, 349, 368, 368, 208, 209, + /* 920 */ 419, 360, 463, 422, 59, 60, 61, 383, 373, 370, + /* 930 */ 369, 136, 373, 4, 139, 140, 141, 142, 143, 144, /* 940 */ 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, - /* 950 */ 155, 329, 157, 158, 159, 65, 66, 67, 68, 69, + /* 950 */ 155, 452, 157, 158, 159, 65, 66, 67, 68, 69, /* 960 */ 95, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 970 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - /* 980 */ 90, 91, 360, 164, 329, 107, 58, 42, 337, 44, - /* 990 */ 368, 162, 361, 329, 107, 373, 337, 375, 96, 134, - /* 1000 */ 329, 0, 351, 106, 126, 127, 128, 129, 130, 131, - /* 1010 */ 351, 44, 329, 126, 127, 128, 129, 130, 131, 368, - /* 1020 */ 394, 42, 400, 44, 337, 97, 404, 368, 373, 407, - /* 1030 */ 408, 409, 410, 411, 412, 4, 414, 373, 351, 361, - /* 1040 */ 175, 176, 177, 360, 373, 180, 337, 337, 349, 48, - /* 1050 */ 19, 368, 329, 156, 22, 368, 373, 361, 375, 329, - /* 1060 */ 351, 351, 99, 198, 33, 102, 201, 35, 203, 204, - /* 1070 */ 205, 206, 207, 99, 329, 208, 102, 368, 368, 48, - /* 1080 */ 390, 459, 460, 400, 53, 337, 337, 404, 47, 58, - /* 1090 */ 407, 408, 409, 410, 411, 412, 373, 414, 337, 351, - /* 1100 */ 351, 337, 419, 373, 421, 360, 461, 99, 425, 426, - /* 1110 */ 102, 246, 351, 368, 245, 351, 368, 368, 373, 329, - /* 1120 */ 375, 99, 0, 433, 102, 94, 164, 437, 97, 368, - /* 1130 */ 447, 361, 368, 171, 132, 133, 95, 269, 247, 329, - /* 1140 */ 329, 329, 452, 453, 22, 400, 35, 457, 458, 404, - /* 1150 */ 360, 329, 407, 408, 409, 410, 411, 412, 368, 414, - /* 1160 */ 0, 44, 361, 373, 419, 375, 421, 383, 329, 35, - /* 1170 */ 425, 426, 8, 9, 0, 329, 12, 13, 14, 15, - /* 1180 */ 16, 436, 22, 373, 373, 373, 329, 329, 329, 329, - /* 1190 */ 400, 329, 450, 329, 404, 373, 22, 407, 408, 409, - /* 1200 */ 410, 411, 412, 360, 414, 329, 360, 383, 35, 419, - /* 1210 */ 44, 421, 373, 96, 368, 425, 426, 12, 13, 373, - /* 1220 */ 339, 375, 44, 1, 2, 44, 436, 22, 339, 44, - /* 1230 */ 373, 373, 373, 373, 267, 373, 360, 373, 33, 44, - /* 1240 */ 35, 44, 44, 70, 368, 336, 400, 44, 444, 373, - /* 1250 */ 404, 375, 372, 407, 408, 409, 410, 411, 412, 44, - /* 1260 */ 414, 329, 96, 58, 427, 419, 435, 421, 44, 44, - /* 1270 */ 454, 425, 426, 438, 96, 70, 400, 96, 44, 44, - /* 1280 */ 404, 96, 436, 407, 408, 409, 410, 411, 412, 383, - /* 1290 */ 414, 96, 360, 96, 96, 419, 185, 421, 44, 96, - /* 1300 */ 368, 425, 426, 44, 13, 373, 248, 375, 44, 402, - /* 1310 */ 48, 96, 436, 95, 401, 13, 390, 181, 42, 185, - /* 1320 */ 96, 96, 117, 105, 380, 392, 35, 20, 164, 390, - /* 1330 */ 96, 96, 400, 383, 380, 378, 404, 35, 390, 407, - /* 1340 */ 408, 409, 410, 411, 412, 161, 414, 20, 337, 337, - /* 1350 */ 96, 419, 380, 421, 378, 96, 390, 425, 426, 433, - /* 1360 */ 96, 378, 93, 437, 345, 337, 337, 337, 436, 20, - /* 1370 */ 331, 329, 433, 20, 331, 20, 437, 396, 452, 453, - /* 1380 */ 343, 433, 375, 457, 458, 437, 20, 343, 183, 338, - /* 1390 */ 185, 452, 453, 20, 391, 343, 457, 458, 338, 433, - /* 1400 */ 452, 453, 360, 437, 343, 457, 458, 343, 343, 337, - /* 1410 */ 368, 343, 52, 208, 209, 373, 340, 375, 452, 453, - /* 1420 */ 340, 331, 360, 457, 458, 337, 221, 222, 223, 224, - /* 1430 */ 225, 226, 227, 360, 329, 360, 373, 360, 360, 360, - /* 1440 */ 331, 360, 400, 360, 360, 360, 404, 360, 399, 407, - /* 1450 */ 408, 409, 410, 411, 412, 373, 414, 197, 95, 341, - /* 1460 */ 188, 419, 395, 421, 398, 360, 396, 425, 426, 375, - /* 1470 */ 341, 373, 337, 368, 383, 383, 256, 443, 373, 329, - /* 1480 */ 375, 255, 386, 373, 446, 386, 373, 373, 443, 262, - /* 1490 */ 174, 445, 264, 443, 263, 442, 441, 249, 462, 440, - /* 1500 */ 271, 268, 402, 456, 266, 400, 245, 368, 20, 404, - /* 1510 */ 360, 455, 407, 408, 409, 410, 411, 412, 368, 414, - /* 1520 */ 337, 406, 373, 373, 419, 375, 421, 338, 341, 341, - /* 1530 */ 425, 426, 386, 386, 373, 329, 373, 166, 373, 384, - /* 1540 */ 373, 373, 341, 341, 368, 95, 356, 424, 95, 350, - /* 1550 */ 400, 337, 373, 341, 404, 364, 36, 407, 408, 409, - /* 1560 */ 410, 411, 412, 331, 414, 393, 360, 397, 332, 419, - /* 1570 */ 354, 421, 327, 387, 368, 425, 426, 354, 0, 373, - /* 1580 */ 329, 375, 342, 387, 354, 0, 190, 0, 0, 42, - /* 1590 */ 0, 35, 202, 35, 35, 35, 202, 0, 35, 35, - /* 1600 */ 202, 0, 202, 0, 35, 0, 400, 0, 22, 35, - /* 1610 */ 404, 360, 183, 407, 408, 409, 410, 411, 412, 368, - /* 1620 */ 414, 185, 0, 0, 373, 329, 375, 421, 179, 178, - /* 1630 */ 0, 425, 426, 0, 0, 0, 47, 0, 42, 0, - /* 1640 */ 0, 0, 329, 0, 0, 0, 0, 0, 151, 35, - /* 1650 */ 0, 400, 151, 0, 0, 404, 360, 0, 407, 408, - /* 1660 */ 409, 410, 411, 412, 368, 414, 0, 0, 0, 373, - /* 1670 */ 0, 375, 421, 360, 0, 0, 425, 426, 42, 0, - /* 1680 */ 0, 368, 0, 0, 0, 0, 373, 329, 375, 0, - /* 1690 */ 0, 0, 0, 0, 0, 0, 400, 0, 22, 0, - /* 1700 */ 404, 135, 0, 407, 408, 409, 410, 411, 412, 0, - /* 1710 */ 414, 0, 35, 400, 0, 0, 58, 404, 360, 58, - /* 1720 */ 407, 408, 409, 410, 411, 412, 368, 414, 0, 0, - /* 1730 */ 42, 373, 14, 375, 421, 39, 14, 0, 0, 426, - /* 1740 */ 329, 0, 44, 0, 448, 449, 40, 47, 0, 39, - /* 1750 */ 47, 47, 39, 174, 0, 0, 329, 0, 400, 0, - /* 1760 */ 35, 0, 404, 39, 48, 407, 408, 409, 410, 411, - /* 1770 */ 412, 360, 414, 39, 35, 48, 64, 0, 48, 368, - /* 1780 */ 35, 39, 0, 48, 373, 35, 375, 360, 39, 0, - /* 1790 */ 0, 0, 365, 0, 22, 368, 0, 35, 35, 35, - /* 1800 */ 373, 35, 375, 22, 35, 0, 35, 449, 22, 329, - /* 1810 */ 35, 400, 104, 35, 44, 404, 0, 44, 407, 408, - /* 1820 */ 409, 410, 411, 412, 22, 414, 50, 400, 102, 0, - /* 1830 */ 22, 404, 35, 0, 407, 408, 409, 410, 411, 412, - /* 1840 */ 360, 414, 35, 0, 35, 0, 22, 20, 368, 35, - /* 1850 */ 35, 195, 96, 373, 0, 375, 35, 0, 186, 22, - /* 1860 */ 95, 0, 0, 3, 44, 250, 254, 229, 250, 164, - /* 1870 */ 96, 460, 44, 166, 95, 95, 44, 47, 47, 96, - /* 1880 */ 400, 164, 95, 164, 404, 44, 3, 407, 408, 409, - /* 1890 */ 410, 411, 412, 172, 414, 96, 416, 96, 95, 329, - /* 1900 */ 96, 95, 171, 171, 35, 95, 35, 96, 44, 250, - /* 1910 */ 35, 19, 35, 35, 35, 96, 44, 47, 96, 0, - /* 1920 */ 47, 0, 0, 0, 0, 33, 39, 167, 39, 95, - /* 1930 */ 360, 244, 96, 95, 95, 365, 2, 95, 368, 95, - /* 1940 */ 48, 47, 96, 373, 95, 375, 54, 55, 56, 57, - /* 1950 */ 58, 44, 105, 165, 329, 22, 47, 47, 95, 208, - /* 1960 */ 22, 96, 229, 95, 106, 35, 35, 231, 210, 229, - /* 1970 */ 400, 35, 96, 22, 404, 95, 95, 407, 408, 409, - /* 1980 */ 410, 411, 412, 95, 414, 360, 94, 96, 95, 97, - /* 1990 */ 365, 96, 96, 368, 95, 35, 96, 95, 373, 96, - /* 2000 */ 375, 95, 35, 35, 96, 119, 95, 329, 96, 95, - /* 2010 */ 95, 107, 95, 44, 35, 95, 119, 119, 22, 64, - /* 2020 */ 119, 63, 130, 35, 35, 400, 35, 35, 35, 404, - /* 2030 */ 329, 70, 407, 408, 409, 410, 411, 412, 360, 414, - /* 2040 */ 35, 35, 35, 35, 35, 92, 368, 44, 35, 35, - /* 2050 */ 35, 373, 329, 375, 22, 35, 35, 165, 35, 35, - /* 2060 */ 70, 360, 170, 35, 35, 35, 35, 22, 35, 368, - /* 2070 */ 0, 35, 0, 48, 373, 329, 375, 39, 400, 187, - /* 2080 */ 39, 189, 404, 360, 35, 407, 408, 409, 410, 411, - /* 2090 */ 412, 368, 414, 0, 48, 35, 373, 329, 375, 48, - /* 2100 */ 39, 400, 0, 35, 48, 404, 360, 0, 407, 408, - /* 2110 */ 409, 410, 411, 412, 368, 414, 39, 35, 35, 373, - /* 2120 */ 0, 375, 22, 400, 21, 20, 22, 404, 360, 21, - /* 2130 */ 407, 408, 409, 410, 411, 412, 368, 414, 22, 463, - /* 2140 */ 463, 373, 463, 375, 463, 463, 400, 463, 463, 463, - /* 2150 */ 404, 463, 329, 407, 408, 409, 410, 411, 412, 463, - /* 2160 */ 414, 463, 463, 463, 463, 463, 463, 463, 400, 329, - /* 2170 */ 463, 463, 404, 463, 463, 407, 408, 409, 410, 411, - /* 2180 */ 412, 463, 414, 360, 463, 463, 463, 463, 463, 463, - /* 2190 */ 463, 368, 463, 463, 463, 463, 373, 463, 375, 463, - /* 2200 */ 360, 463, 463, 463, 463, 463, 463, 463, 368, 463, - /* 2210 */ 463, 463, 463, 373, 329, 375, 463, 463, 463, 463, - /* 2220 */ 463, 463, 463, 400, 463, 463, 463, 404, 463, 463, - /* 2230 */ 407, 408, 409, 410, 411, 412, 463, 414, 463, 463, - /* 2240 */ 400, 463, 463, 463, 404, 360, 463, 407, 408, 409, - /* 2250 */ 410, 411, 412, 368, 414, 463, 463, 463, 373, 463, - /* 2260 */ 375, 463, 463, 463, 463, 463, 463, 463, 463, 463, - /* 2270 */ 329, 463, 463, 463, 463, 463, 463, 463, 463, 463, - /* 2280 */ 463, 463, 463, 463, 463, 400, 463, 463, 463, 404, - /* 2290 */ 463, 463, 407, 408, 409, 410, 411, 412, 463, 414, - /* 2300 */ 329, 360, 463, 463, 463, 463, 463, 463, 463, 368, - /* 2310 */ 463, 463, 463, 463, 373, 463, 375, 463, 463, 463, - /* 2320 */ 463, 463, 463, 329, 463, 463, 463, 463, 463, 463, - /* 2330 */ 463, 360, 463, 463, 463, 463, 463, 463, 463, 368, - /* 2340 */ 463, 400, 463, 463, 373, 404, 375, 463, 407, 408, - /* 2350 */ 409, 410, 411, 412, 360, 414, 463, 463, 463, 463, - /* 2360 */ 463, 463, 368, 463, 463, 463, 463, 373, 329, 375, - /* 2370 */ 463, 400, 463, 463, 463, 404, 463, 463, 407, 408, - /* 2380 */ 409, 410, 411, 412, 463, 414, 463, 329, 463, 463, - /* 2390 */ 463, 463, 463, 463, 400, 463, 463, 463, 404, 360, - /* 2400 */ 463, 407, 408, 409, 410, 411, 412, 368, 414, 463, - /* 2410 */ 463, 463, 373, 329, 375, 463, 463, 463, 360, 463, - /* 2420 */ 463, 463, 463, 463, 463, 463, 368, 463, 463, 463, - /* 2430 */ 463, 373, 463, 375, 463, 463, 463, 463, 463, 400, - /* 2440 */ 463, 463, 463, 404, 360, 463, 407, 408, 409, 410, - /* 2450 */ 411, 412, 368, 414, 463, 463, 463, 373, 400, 375, - /* 2460 */ 463, 463, 404, 463, 463, 407, 408, 409, 410, 411, - /* 2470 */ 412, 329, 414, 463, 463, 463, 463, 463, 463, 463, - /* 2480 */ 463, 463, 463, 463, 400, 463, 463, 329, 404, 463, - /* 2490 */ 463, 407, 408, 409, 410, 411, 412, 463, 414, 463, - /* 2500 */ 463, 463, 360, 463, 463, 463, 463, 463, 463, 463, - /* 2510 */ 368, 463, 463, 463, 463, 373, 463, 375, 360, 463, - /* 2520 */ 463, 463, 463, 463, 463, 463, 368, 463, 463, 463, - /* 2530 */ 463, 373, 463, 375, 463, 463, 463, 463, 463, 463, - /* 2540 */ 463, 463, 400, 329, 463, 463, 404, 463, 463, 407, - /* 2550 */ 408, 409, 410, 411, 412, 463, 414, 463, 400, 463, - /* 2560 */ 329, 463, 404, 463, 463, 407, 408, 409, 410, 411, - /* 2570 */ 412, 463, 414, 463, 360, 463, 463, 463, 463, 463, - /* 2580 */ 463, 463, 368, 463, 463, 463, 463, 373, 329, 375, - /* 2590 */ 463, 360, 463, 463, 463, 463, 463, 463, 463, 368, - /* 2600 */ 463, 463, 463, 463, 373, 463, 375, 463, 463, 463, - /* 2610 */ 463, 463, 463, 463, 400, 463, 463, 463, 404, 360, - /* 2620 */ 463, 407, 408, 409, 410, 411, 412, 368, 414, 463, - /* 2630 */ 463, 400, 373, 463, 375, 404, 463, 463, 407, 408, - /* 2640 */ 409, 410, 411, 412, 329, 414, 463, 463, 463, 463, - /* 2650 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 400, - /* 2660 */ 463, 329, 463, 404, 463, 463, 407, 408, 409, 410, - /* 2670 */ 411, 412, 463, 414, 463, 360, 463, 463, 463, 463, - /* 2680 */ 463, 463, 463, 368, 463, 463, 463, 463, 373, 463, - /* 2690 */ 375, 463, 360, 463, 463, 463, 463, 463, 463, 463, - /* 2700 */ 368, 463, 463, 463, 463, 373, 463, 375, 463, 463, - /* 2710 */ 463, 463, 463, 463, 463, 400, 463, 329, 463, 404, - /* 2720 */ 463, 463, 407, 408, 409, 410, 411, 412, 463, 414, - /* 2730 */ 463, 463, 400, 463, 463, 463, 404, 463, 463, 407, - /* 2740 */ 408, 409, 410, 411, 412, 463, 414, 463, 360, 463, - /* 2750 */ 463, 463, 463, 463, 463, 463, 368, 463, 463, 463, - /* 2760 */ 463, 373, 463, 375, 463, 463, 463, 463, 463, 463, - /* 2770 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - /* 2780 */ 463, 463, 463, 463, 463, 463, 463, 463, 400, 463, - /* 2790 */ 463, 463, 404, 463, 463, 407, 408, 409, 410, 411, - /* 2800 */ 412, 463, 414, 326, 326, 326, 326, 326, 326, 326, - /* 2810 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2820 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2830 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2840 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2850 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2860 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2870 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2880 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2890 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2900 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2910 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2920 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2930 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2940 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2950 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2960 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2970 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2980 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 2990 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 3000 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 3010 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 3020 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 3030 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 3040 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 3050 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 3060 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 3070 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 3080 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 3090 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 3100 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 3110 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, 326, - /* 3120 */ 326, 326, 326, 326, 326, 326, 326, 326, 326, + /* 980 */ 90, 91, 329, 4, 20, 107, 8, 9, 337, 22, + /* 990 */ 12, 13, 14, 15, 16, 132, 133, 20, 19, 134, + /* 1000 */ 337, 107, 35, 337, 126, 127, 128, 129, 130, 131, + /* 1010 */ 244, 245, 33, 329, 351, 337, 329, 351, 44, 368, + /* 1020 */ 126, 127, 128, 129, 130, 131, 373, 48, 337, 351, + /* 1030 */ 337, 368, 53, 329, 368, 329, 337, 58, 44, 162, + /* 1040 */ 175, 176, 177, 446, 351, 180, 368, 360, 329, 370, + /* 1050 */ 351, 370, 373, 353, 373, 368, 356, 373, 0, 368, + /* 1060 */ 373, 368, 375, 198, 337, 329, 201, 368, 203, 204, + /* 1070 */ 205, 206, 207, 94, 329, 44, 97, 373, 351, 373, + /* 1080 */ 22, 35, 431, 432, 433, 329, 435, 436, 337, 402, + /* 1090 */ 96, 339, 373, 406, 106, 368, 409, 410, 411, 412, + /* 1100 */ 413, 414, 351, 416, 329, 360, 1, 2, 421, 373, + /* 1110 */ 423, 246, 44, 368, 427, 428, 339, 360, 373, 368, + /* 1120 */ 375, 329, 431, 432, 433, 438, 435, 436, 164, 373, + /* 1130 */ 329, 337, 8, 9, 336, 360, 12, 13, 14, 15, + /* 1140 */ 16, 164, 164, 368, 156, 351, 329, 402, 373, 337, + /* 1150 */ 375, 406, 360, 0, 409, 410, 411, 412, 413, 414, + /* 1160 */ 368, 416, 368, 351, 96, 373, 421, 375, 423, 42, + /* 1170 */ 0, 44, 427, 428, 373, 22, 247, 402, 329, 58, + /* 1180 */ 368, 406, 392, 438, 409, 410, 411, 412, 413, 414, + /* 1190 */ 373, 416, 22, 42, 402, 44, 99, 99, 406, 102, + /* 1200 */ 102, 409, 410, 411, 412, 413, 414, 35, 416, 360, + /* 1210 */ 383, 99, 372, 421, 102, 423, 164, 368, 97, 427, + /* 1220 */ 428, 392, 373, 171, 375, 435, 44, 63, 453, 439, + /* 1230 */ 438, 185, 99, 12, 13, 102, 329, 383, 44, 437, + /* 1240 */ 44, 267, 44, 22, 454, 455, 440, 44, 429, 459, + /* 1250 */ 460, 402, 44, 0, 33, 406, 35, 248, 409, 410, + /* 1260 */ 411, 412, 413, 414, 435, 416, 329, 360, 439, 456, + /* 1270 */ 421, 35, 423, 44, 44, 368, 427, 428, 96, 58, + /* 1280 */ 373, 44, 375, 454, 455, 95, 13, 438, 459, 460, + /* 1290 */ 96, 70, 96, 404, 96, 105, 48, 360, 329, 96, + /* 1300 */ 269, 403, 49, 44, 96, 368, 70, 44, 35, 402, + /* 1310 */ 373, 44, 375, 406, 394, 44, 409, 410, 411, 412, + /* 1320 */ 413, 414, 44, 416, 44, 96, 96, 181, 421, 360, + /* 1330 */ 423, 42, 13, 96, 427, 428, 44, 368, 117, 402, + /* 1340 */ 20, 380, 373, 406, 375, 438, 409, 410, 411, 412, + /* 1350 */ 413, 414, 392, 416, 35, 96, 383, 185, 421, 96, + /* 1360 */ 423, 380, 161, 96, 427, 428, 20, 96, 378, 337, + /* 1370 */ 378, 402, 208, 337, 96, 406, 96, 329, 409, 410, + /* 1380 */ 411, 412, 413, 414, 380, 416, 378, 93, 96, 345, + /* 1390 */ 421, 337, 423, 337, 337, 435, 427, 428, 20, 439, + /* 1400 */ 331, 331, 20, 398, 183, 343, 185, 20, 360, 375, + /* 1410 */ 343, 20, 338, 20, 454, 455, 368, 393, 343, 459, + /* 1420 */ 460, 373, 338, 375, 343, 392, 343, 337, 343, 208, + /* 1430 */ 209, 343, 52, 340, 340, 329, 360, 360, 331, 360, + /* 1440 */ 360, 337, 221, 222, 223, 224, 225, 226, 227, 360, + /* 1450 */ 402, 360, 360, 331, 406, 329, 360, 409, 410, 411, + /* 1460 */ 412, 413, 414, 360, 416, 197, 360, 401, 435, 421, + /* 1470 */ 360, 423, 439, 360, 368, 427, 428, 341, 95, 373, + /* 1480 */ 398, 375, 373, 188, 373, 341, 360, 454, 455, 375, + /* 1490 */ 256, 337, 459, 460, 368, 400, 397, 255, 383, 373, + /* 1500 */ 383, 375, 373, 373, 445, 445, 388, 388, 402, 262, + /* 1510 */ 373, 373, 406, 329, 174, 409, 410, 411, 412, 413, + /* 1520 */ 414, 448, 416, 249, 264, 447, 271, 263, 402, 423, + /* 1530 */ 443, 445, 406, 427, 428, 409, 410, 411, 412, 413, + /* 1540 */ 414, 266, 416, 329, 360, 444, 404, 268, 245, 423, + /* 1550 */ 442, 368, 368, 427, 428, 20, 408, 373, 338, 375, + /* 1560 */ 329, 337, 20, 341, 464, 386, 341, 166, 388, 388, + /* 1570 */ 373, 385, 373, 457, 360, 373, 341, 373, 458, 373, + /* 1580 */ 373, 341, 368, 356, 368, 95, 402, 373, 426, 375, + /* 1590 */ 406, 360, 95, 409, 410, 411, 412, 413, 414, 368, + /* 1600 */ 416, 373, 364, 337, 373, 36, 375, 423, 350, 332, + /* 1610 */ 341, 427, 428, 331, 395, 389, 402, 329, 342, 354, + /* 1620 */ 406, 389, 399, 409, 410, 411, 412, 413, 414, 415, + /* 1630 */ 416, 417, 418, 402, 327, 354, 0, 406, 354, 0, + /* 1640 */ 409, 410, 411, 412, 413, 414, 190, 416, 360, 0, + /* 1650 */ 0, 42, 0, 35, 202, 35, 368, 35, 35, 202, + /* 1660 */ 0, 373, 35, 375, 329, 35, 202, 0, 202, 0, + /* 1670 */ 35, 0, 0, 22, 185, 35, 183, 0, 0, 179, + /* 1680 */ 178, 329, 0, 0, 47, 0, 0, 0, 0, 42, + /* 1690 */ 402, 0, 461, 462, 406, 360, 0, 409, 410, 411, + /* 1700 */ 412, 413, 414, 368, 416, 0, 0, 0, 373, 151, + /* 1710 */ 375, 423, 360, 0, 0, 35, 428, 365, 0, 151, + /* 1720 */ 368, 0, 0, 0, 0, 373, 0, 375, 0, 0, + /* 1730 */ 0, 0, 0, 0, 0, 0, 329, 402, 0, 0, + /* 1740 */ 0, 406, 42, 0, 409, 410, 411, 412, 413, 414, + /* 1750 */ 0, 416, 0, 0, 402, 0, 0, 0, 406, 329, + /* 1760 */ 0, 409, 410, 411, 412, 413, 414, 360, 416, 22, + /* 1770 */ 0, 0, 0, 135, 0, 368, 35, 58, 0, 0, + /* 1780 */ 373, 0, 375, 58, 42, 39, 0, 14, 44, 14, + /* 1790 */ 360, 329, 47, 0, 0, 365, 47, 462, 368, 40, + /* 1800 */ 39, 47, 0, 373, 39, 375, 174, 0, 0, 402, + /* 1810 */ 0, 0, 64, 406, 0, 35, 409, 410, 411, 412, + /* 1820 */ 413, 414, 360, 416, 48, 418, 39, 365, 0, 39, + /* 1830 */ 368, 35, 402, 48, 0, 373, 406, 375, 329, 409, + /* 1840 */ 410, 411, 412, 413, 414, 48, 416, 35, 39, 0, + /* 1850 */ 35, 48, 19, 0, 0, 39, 0, 0, 35, 22, + /* 1860 */ 102, 0, 329, 44, 402, 35, 33, 104, 406, 360, + /* 1870 */ 35, 409, 410, 411, 412, 413, 414, 368, 416, 35, + /* 1880 */ 35, 48, 373, 44, 375, 35, 35, 54, 55, 56, + /* 1890 */ 57, 58, 22, 360, 35, 0, 22, 0, 22, 0, + /* 1900 */ 22, 368, 50, 35, 0, 0, 373, 35, 375, 0, + /* 1910 */ 35, 402, 22, 20, 35, 406, 35, 96, 409, 410, + /* 1920 */ 411, 412, 413, 414, 95, 416, 0, 94, 329, 35, + /* 1930 */ 97, 195, 164, 0, 22, 402, 0, 186, 0, 406, + /* 1940 */ 3, 164, 409, 410, 411, 412, 413, 414, 166, 416, + /* 1950 */ 329, 44, 164, 250, 96, 172, 229, 95, 254, 360, + /* 1960 */ 95, 44, 171, 130, 3, 96, 171, 368, 44, 96, + /* 1970 */ 47, 44, 373, 96, 375, 329, 47, 95, 95, 95, + /* 1980 */ 95, 360, 96, 96, 44, 35, 35, 35, 35, 368, + /* 1990 */ 35, 35, 96, 47, 373, 47, 375, 96, 165, 39, + /* 2000 */ 0, 402, 44, 170, 0, 406, 360, 0, 409, 410, + /* 2010 */ 411, 412, 413, 414, 368, 416, 250, 0, 0, 373, + /* 2020 */ 187, 375, 189, 402, 47, 95, 95, 406, 244, 95, + /* 2030 */ 409, 410, 411, 412, 413, 414, 95, 416, 329, 250, + /* 2040 */ 96, 96, 95, 47, 39, 44, 229, 167, 402, 95, + /* 2050 */ 2, 231, 406, 229, 165, 409, 410, 411, 412, 413, + /* 2060 */ 414, 22, 416, 208, 105, 95, 329, 96, 95, 360, + /* 2070 */ 96, 95, 47, 47, 96, 95, 95, 368, 106, 96, + /* 2080 */ 22, 210, 373, 95, 375, 96, 35, 35, 95, 35, + /* 2090 */ 96, 96, 95, 95, 35, 35, 329, 360, 96, 96, + /* 2100 */ 35, 95, 22, 95, 119, 368, 119, 95, 44, 119, + /* 2110 */ 373, 402, 375, 22, 95, 406, 107, 35, 409, 410, + /* 2120 */ 411, 412, 413, 414, 95, 416, 64, 360, 329, 119, + /* 2130 */ 63, 35, 35, 35, 35, 368, 35, 35, 35, 402, + /* 2140 */ 373, 35, 375, 406, 35, 35, 409, 410, 411, 412, + /* 2150 */ 413, 414, 44, 416, 70, 92, 35, 35, 35, 360, + /* 2160 */ 329, 22, 35, 35, 35, 70, 35, 368, 35, 402, + /* 2170 */ 35, 35, 373, 406, 375, 35, 409, 410, 411, 412, + /* 2180 */ 413, 414, 22, 416, 35, 0, 35, 39, 0, 48, + /* 2190 */ 35, 360, 329, 48, 0, 39, 35, 39, 48, 368, + /* 2200 */ 0, 402, 35, 39, 373, 406, 375, 48, 409, 410, + /* 2210 */ 411, 412, 413, 414, 0, 416, 35, 329, 35, 0, + /* 2220 */ 22, 22, 21, 360, 22, 21, 20, 465, 465, 465, + /* 2230 */ 465, 368, 465, 402, 465, 465, 373, 406, 375, 465, + /* 2240 */ 409, 410, 411, 412, 413, 414, 465, 416, 360, 329, + /* 2250 */ 465, 465, 465, 465, 465, 465, 368, 465, 465, 465, + /* 2260 */ 465, 373, 465, 375, 465, 402, 465, 465, 465, 406, + /* 2270 */ 465, 465, 409, 410, 411, 412, 413, 414, 465, 416, + /* 2280 */ 360, 465, 465, 465, 465, 465, 465, 465, 368, 465, + /* 2290 */ 402, 465, 465, 373, 406, 375, 465, 409, 410, 411, + /* 2300 */ 412, 413, 414, 465, 416, 465, 465, 465, 465, 465, + /* 2310 */ 465, 329, 465, 465, 465, 465, 465, 465, 465, 465, + /* 2320 */ 465, 465, 402, 465, 465, 465, 406, 465, 329, 409, + /* 2330 */ 410, 411, 412, 413, 414, 465, 416, 465, 465, 465, + /* 2340 */ 465, 465, 360, 465, 465, 465, 465, 465, 465, 465, + /* 2350 */ 368, 465, 465, 465, 465, 373, 465, 375, 465, 360, + /* 2360 */ 465, 465, 465, 465, 465, 465, 465, 368, 465, 465, + /* 2370 */ 465, 465, 373, 465, 375, 465, 465, 465, 465, 465, + /* 2380 */ 465, 465, 465, 465, 402, 329, 465, 465, 406, 465, + /* 2390 */ 465, 409, 410, 411, 412, 413, 414, 465, 416, 465, + /* 2400 */ 465, 402, 465, 465, 465, 406, 465, 329, 409, 410, + /* 2410 */ 411, 412, 413, 414, 465, 416, 360, 465, 465, 465, + /* 2420 */ 465, 465, 465, 465, 368, 465, 465, 465, 465, 373, + /* 2430 */ 465, 375, 465, 465, 465, 465, 465, 465, 360, 465, + /* 2440 */ 465, 465, 465, 465, 465, 465, 368, 465, 465, 465, + /* 2450 */ 465, 373, 465, 375, 465, 465, 465, 465, 402, 465, + /* 2460 */ 465, 465, 406, 465, 465, 409, 410, 411, 412, 413, + /* 2470 */ 414, 465, 416, 329, 465, 465, 465, 465, 465, 465, + /* 2480 */ 402, 465, 465, 465, 406, 465, 465, 409, 410, 411, + /* 2490 */ 412, 413, 414, 465, 416, 465, 465, 329, 465, 465, + /* 2500 */ 465, 465, 465, 465, 360, 465, 465, 465, 465, 465, + /* 2510 */ 465, 465, 368, 465, 465, 465, 465, 373, 465, 375, + /* 2520 */ 465, 465, 465, 465, 465, 465, 465, 465, 360, 465, + /* 2530 */ 465, 465, 465, 465, 465, 465, 368, 465, 465, 465, + /* 2540 */ 465, 373, 465, 375, 465, 465, 402, 465, 465, 465, + /* 2550 */ 406, 465, 465, 409, 410, 411, 412, 413, 414, 465, + /* 2560 */ 416, 329, 465, 465, 465, 465, 465, 465, 465, 465, + /* 2570 */ 402, 465, 465, 465, 406, 465, 465, 409, 410, 411, + /* 2580 */ 412, 413, 414, 465, 416, 465, 329, 465, 465, 465, + /* 2590 */ 465, 465, 360, 465, 465, 465, 465, 465, 465, 465, + /* 2600 */ 368, 465, 465, 465, 465, 373, 465, 375, 465, 465, + /* 2610 */ 465, 465, 465, 465, 465, 465, 465, 360, 329, 465, + /* 2620 */ 465, 465, 465, 465, 465, 368, 465, 465, 465, 465, + /* 2630 */ 373, 465, 375, 465, 402, 465, 465, 465, 406, 465, + /* 2640 */ 465, 409, 410, 411, 412, 413, 414, 465, 416, 360, + /* 2650 */ 465, 465, 465, 465, 465, 465, 465, 368, 465, 402, + /* 2660 */ 465, 465, 373, 406, 375, 465, 409, 410, 411, 412, + /* 2670 */ 413, 414, 465, 416, 465, 465, 465, 465, 465, 465, + /* 2680 */ 465, 465, 465, 465, 465, 465, 465, 465, 465, 465, + /* 2690 */ 465, 402, 465, 465, 465, 406, 465, 465, 409, 410, + /* 2700 */ 411, 412, 413, 414, 465, 416, }; -#define YY_SHIFT_COUNT (726) +#define YY_SHIFT_COUNT (729) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2120) +#define YY_SHIFT_MAX (2219) static const unsigned short int yy_shift_ofst[] = { /* 0 */ 865, 0, 71, 0, 290, 290, 290, 290, 290, 290, /* 10 */ 290, 290, 290, 290, 290, 361, 578, 578, 649, 578, /* 20 */ 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, /* 30 */ 578, 578, 578, 578, 578, 578, 578, 578, 578, 578, - /* 40 */ 578, 578, 578, 578, 578, 578, 578, 578, 115, 285, - /* 50 */ 70, 251, 140, 183, 205, 183, 70, 70, 1205, 1205, - /* 60 */ 183, 1205, 1205, 346, 183, 61, 108, 108, 61, 154, - /* 70 */ 154, 39, 434, 53, 53, 108, 108, 108, 108, 108, - /* 80 */ 108, 108, 108, 108, 108, 198, 150, 108, 108, 389, - /* 90 */ 108, 150, 108, 108, 108, 108, 150, 108, 108, 150, - /* 100 */ 108, 150, 150, 150, 108, 501, 795, 34, 34, 217, - /* 110 */ 454, 287, 287, 287, 287, 287, 287, 287, 287, 287, - /* 120 */ 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, - /* 130 */ 152, 386, 39, 434, 25, 309, 87, 87, 87, 483, - /* 140 */ 202, 202, 309, 502, 502, 502, 462, 376, 150, 581, - /* 150 */ 150, 581, 581, 462, 587, 218, 218, 218, 218, 218, - /* 160 */ 218, 218, 1892, 460, 304, 545, 453, 58, 286, 288, - /* 170 */ 338, 443, 663, 763, 883, 707, 819, 688, 869, 42, - /* 180 */ 688, 945, 891, 829, 1058, 1262, 1136, 1276, 1307, 1276, - /* 190 */ 1184, 1327, 1327, 1276, 1184, 1184, 1269, 1327, 1327, 1327, - /* 200 */ 1349, 1349, 1353, 198, 1355, 198, 1366, 1373, 198, 1366, - /* 210 */ 198, 198, 198, 1327, 198, 1360, 1360, 1349, 150, 150, - /* 220 */ 150, 150, 150, 150, 150, 150, 150, 150, 150, 1327, - /* 230 */ 1349, 581, 581, 1260, 1363, 1353, 501, 1272, 1355, 501, - /* 240 */ 1327, 1307, 1307, 581, 1220, 1226, 581, 1220, 1226, 581, - /* 250 */ 581, 150, 1227, 1316, 1220, 1228, 1231, 1248, 1058, 1229, - /* 260 */ 1233, 1238, 1261, 502, 1488, 1327, 1366, 501, 501, 1226, - /* 270 */ 581, 581, 581, 581, 581, 1226, 581, 1371, 501, 462, - /* 280 */ 501, 502, 1450, 1453, 581, 587, 1327, 501, 1520, 1349, - /* 290 */ 2803, 2803, 2803, 2803, 2803, 2803, 2803, 2803, 2803, 890, - /* 300 */ 382, 418, 1031, 249, 741, 902, 724, 412, 884, 1164, - /* 310 */ 878, 611, 611, 611, 611, 611, 611, 611, 611, 611, - /* 320 */ 887, 485, 24, 24, 477, 537, 196, 762, 20, 586, - /* 330 */ 105, 105, 616, 750, 676, 616, 616, 616, 505, 1001, - /* 340 */ 1032, 979, 897, 963, 974, 1008, 1022, 1122, 1160, 1174, - /* 350 */ 1117, 928, 1166, 1178, 1002, 967, 868, 962, 1181, 1185, - /* 360 */ 1195, 1197, 1198, 1203, 1222, 1215, 1111, 1134, 867, 1224, - /* 370 */ 1041, 1225, 1234, 1235, 1254, 1259, 1264, 1218, 1291, 1302, - /* 380 */ 1173, 759, 1578, 1585, 1396, 1587, 1588, 1547, 1590, 1556, - /* 390 */ 1390, 1558, 1559, 1560, 1394, 1597, 1563, 1564, 1398, 1601, - /* 400 */ 1400, 1603, 1569, 1605, 1586, 1607, 1574, 1436, 1429, 1622, - /* 410 */ 1623, 1449, 1451, 1630, 1633, 1589, 1634, 1635, 1637, 1596, - /* 420 */ 1639, 1640, 1641, 1643, 1644, 1645, 1646, 1647, 1497, 1614, - /* 430 */ 1650, 1501, 1653, 1654, 1657, 1666, 1667, 1668, 1670, 1674, - /* 440 */ 1675, 1682, 1683, 1684, 1685, 1689, 1690, 1691, 1636, 1679, - /* 450 */ 1680, 1692, 1693, 1694, 1695, 1676, 1697, 1699, 1709, 1566, - /* 460 */ 1702, 1711, 1677, 1714, 1658, 1715, 1661, 1728, 1729, 1688, - /* 470 */ 1696, 1698, 1700, 1718, 1703, 1722, 1704, 1737, 1706, 1710, - /* 480 */ 1738, 1741, 1743, 1713, 1579, 1748, 1754, 1755, 1712, 1757, - /* 490 */ 1759, 1725, 1716, 1724, 1761, 1739, 1727, 1734, 1777, 1745, - /* 500 */ 1730, 1742, 1782, 1750, 1735, 1749, 1789, 1790, 1791, 1793, - /* 510 */ 1708, 1726, 1762, 1772, 1796, 1763, 1764, 1766, 1769, 1770, - /* 520 */ 1773, 1771, 1775, 1781, 1778, 1805, 1786, 1816, 1802, 1776, - /* 530 */ 1829, 1808, 1797, 1833, 1807, 1843, 1809, 1845, 1824, 1827, - /* 540 */ 1814, 1815, 1656, 1756, 1765, 1854, 1705, 1821, 1857, 1672, - /* 550 */ 1837, 1717, 1707, 1861, 1862, 1719, 1721, 1860, 1820, 1615, - /* 560 */ 1779, 1774, 1780, 1731, 1638, 1732, 1612, 1783, 1828, 1799, - /* 570 */ 1787, 1803, 1806, 1801, 1832, 1830, 1831, 1810, 1841, 1618, - /* 580 */ 1804, 1811, 1883, 1864, 1659, 1869, 1871, 1875, 1877, 1878, - /* 590 */ 1879, 1819, 1822, 1870, 1687, 1872, 1873, 1919, 1921, 1922, - /* 600 */ 1923, 1834, 1887, 1838, 1836, 1846, 1839, 1842, 1760, 1844, - /* 610 */ 1924, 1889, 1788, 1849, 1847, 1700, 1894, 1907, 1733, 1736, - /* 620 */ 1740, 1934, 1933, 1751, 1863, 1865, 1868, 1876, 1880, 1891, - /* 630 */ 1909, 1881, 1888, 1910, 1895, 1938, 1758, 1893, 1858, 1896, - /* 640 */ 1930, 1931, 1899, 1900, 1936, 1902, 1903, 1960, 1906, 1908, - /* 650 */ 1967, 1911, 1912, 1968, 1914, 1886, 1897, 1898, 1901, 1951, - /* 660 */ 1904, 1915, 1969, 1917, 1979, 1920, 1969, 1969, 1996, 1955, - /* 670 */ 1958, 1988, 1989, 1991, 1992, 1993, 2005, 2006, 2007, 2008, - /* 680 */ 2009, 1961, 1953, 2003, 2013, 2014, 2015, 2032, 2020, 2021, - /* 690 */ 2023, 1990, 1770, 2024, 1773, 2028, 2029, 2030, 2031, 2045, - /* 700 */ 2033, 2070, 2036, 2025, 2038, 2072, 2049, 2046, 2041, 2093, - /* 710 */ 2060, 2051, 2061, 2102, 2068, 2056, 2077, 2107, 2082, 2083, - /* 720 */ 2120, 2100, 2103, 2104, 2116, 2108, 2105, + /* 40 */ 578, 578, 578, 578, 578, 578, 578, 578, 70, 346, + /* 50 */ 40, 140, 63, 225, 439, 225, 40, 40, 1221, 1221, + /* 60 */ 225, 1221, 1221, 110, 225, 435, 17, 17, 435, 85, + /* 70 */ 85, 68, 542, 167, 167, 17, 17, 17, 17, 17, + /* 80 */ 17, 17, 36, 17, 17, 174, 78, 17, 17, 117, + /* 90 */ 17, 78, 17, 36, 17, 36, 78, 17, 17, 78, + /* 100 */ 17, 78, 78, 78, 17, 204, 795, 34, 34, 217, + /* 110 */ 454, 710, 710, 710, 710, 710, 710, 710, 710, 710, + /* 120 */ 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + /* 130 */ 152, 444, 68, 542, 644, 667, 212, 212, 212, 697, + /* 140 */ 87, 87, 667, 345, 345, 345, 390, 303, 78, 372, + /* 150 */ 78, 372, 372, 390, 481, 218, 218, 218, 218, 218, + /* 160 */ 218, 218, 1833, 599, 304, 545, 184, 397, 286, 62, + /* 170 */ 330, 431, 341, 964, 835, 785, 977, 766, 145, 344, + /* 180 */ 766, 1127, 929, 877, 1009, 1248, 1146, 1289, 1320, 1289, + /* 190 */ 1201, 1346, 1346, 1289, 1201, 1201, 1294, 1346, 1346, 1346, + /* 200 */ 1378, 1378, 1382, 174, 1387, 174, 1391, 1393, 174, 1391, + /* 210 */ 174, 174, 174, 1346, 174, 1380, 1380, 1378, 78, 78, + /* 220 */ 78, 78, 78, 78, 78, 78, 78, 78, 78, 1346, + /* 230 */ 1378, 372, 372, 1268, 1383, 1382, 204, 1295, 1387, 204, + /* 240 */ 1346, 1320, 1320, 372, 1234, 1242, 372, 1234, 1242, 372, + /* 250 */ 372, 78, 1247, 1340, 1234, 1260, 1264, 1274, 1009, 1255, + /* 260 */ 1279, 1275, 1303, 345, 1535, 1346, 1391, 204, 204, 1542, + /* 270 */ 1242, 372, 372, 372, 372, 372, 1242, 372, 1401, 204, + /* 280 */ 390, 204, 345, 1490, 1497, 372, 481, 1346, 204, 1569, + /* 290 */ 1378, 2706, 2706, 2706, 2706, 2706, 2706, 2706, 2706, 2706, + /* 300 */ 890, 382, 724, 979, 249, 453, 626, 878, 412, 896, + /* 310 */ 978, 894, 1124, 1124, 1124, 1124, 1124, 1124, 1124, 1124, + /* 320 */ 1124, 488, 539, 130, 130, 404, 168, 607, 67, 436, + /* 330 */ 550, 44, 44, 826, 631, 257, 826, 826, 826, 994, + /* 340 */ 859, 967, 1151, 988, 1097, 1098, 1112, 1133, 1058, 1153, + /* 350 */ 1170, 1068, 1121, 1182, 1194, 863, 974, 1031, 1052, 1196, + /* 360 */ 1198, 1203, 1229, 1230, 1237, 1105, 1259, 1046, 1172, 1164, + /* 370 */ 1208, 337, 1263, 1267, 1271, 1278, 1280, 1292, 1190, 1273, + /* 380 */ 1319, 1236, 1253, 1636, 1639, 1456, 1649, 1650, 1609, 1652, + /* 390 */ 1618, 1452, 1620, 1622, 1623, 1457, 1660, 1627, 1630, 1464, + /* 400 */ 1667, 1466, 1669, 1635, 1671, 1651, 1672, 1640, 1489, 1493, + /* 410 */ 1677, 1678, 1500, 1502, 1682, 1683, 1637, 1685, 1686, 1687, + /* 420 */ 1647, 1688, 1691, 1696, 1705, 1706, 1707, 1713, 1714, 1558, + /* 430 */ 1680, 1718, 1568, 1721, 1722, 1723, 1724, 1726, 1728, 1729, + /* 440 */ 1730, 1731, 1732, 1733, 1734, 1735, 1738, 1739, 1740, 1700, + /* 450 */ 1743, 1750, 1752, 1753, 1755, 1756, 1747, 1757, 1760, 1770, + /* 460 */ 1638, 1771, 1772, 1741, 1774, 1719, 1778, 1725, 1779, 1781, + /* 470 */ 1742, 1746, 1744, 1745, 1773, 1749, 1775, 1754, 1786, 1759, + /* 480 */ 1761, 1793, 1794, 1802, 1765, 1632, 1807, 1808, 1810, 1748, + /* 490 */ 1811, 1814, 1780, 1776, 1787, 1828, 1796, 1785, 1790, 1834, + /* 500 */ 1812, 1797, 1809, 1849, 1815, 1803, 1816, 1853, 1854, 1856, + /* 510 */ 1857, 1763, 1758, 1823, 1837, 1861, 1830, 1835, 1844, 1845, + /* 520 */ 1819, 1839, 1850, 1851, 1870, 1859, 1895, 1874, 1897, 1876, + /* 530 */ 1852, 1899, 1878, 1868, 1904, 1872, 1905, 1875, 1909, 1890, + /* 540 */ 1893, 1879, 1881, 1736, 1821, 1829, 1926, 1768, 1894, 1933, + /* 550 */ 1751, 1912, 1777, 1782, 1936, 1938, 1788, 1783, 1937, 1907, + /* 560 */ 1703, 1862, 1858, 1865, 1791, 1727, 1795, 1704, 1869, 1917, + /* 570 */ 1873, 1882, 1883, 1884, 1877, 1924, 1923, 1929, 1885, 1927, + /* 580 */ 1766, 1886, 1887, 1961, 1940, 1789, 1950, 1951, 1952, 1953, + /* 590 */ 1955, 1956, 1896, 1901, 1946, 1784, 1958, 1948, 2004, 2007, + /* 600 */ 2017, 2018, 1930, 1960, 1745, 1977, 1931, 1944, 1945, 1934, + /* 610 */ 1941, 1880, 1947, 2000, 2005, 1889, 1954, 1959, 1745, 1996, + /* 620 */ 2001, 1817, 1820, 1824, 2048, 2039, 1855, 1970, 1971, 1973, + /* 630 */ 1974, 1976, 1978, 2025, 1980, 1981, 2026, 1983, 2058, 1871, + /* 640 */ 1988, 1972, 1989, 2051, 2052, 1993, 1994, 2054, 1997, 1995, + /* 650 */ 2059, 1998, 2002, 2060, 2006, 2003, 2065, 2008, 1985, 1987, + /* 660 */ 1990, 2010, 2080, 2009, 2012, 2064, 2019, 2082, 2029, 2064, + /* 670 */ 2064, 2091, 2062, 2067, 2096, 2097, 2098, 2099, 2101, 2102, + /* 680 */ 2103, 2106, 2109, 2110, 2084, 2063, 2108, 2121, 2122, 2123, + /* 690 */ 2139, 2127, 2128, 2129, 2095, 1819, 2131, 1839, 2133, 2135, + /* 700 */ 2136, 2140, 2160, 2149, 2185, 2151, 2141, 2148, 2188, 2155, + /* 710 */ 2145, 2156, 2194, 2161, 2150, 2158, 2200, 2167, 2159, 2164, + /* 720 */ 2214, 2181, 2183, 2219, 2198, 2201, 2199, 2202, 2204, 2206, }; -#define YY_REDUCE_COUNT (298) -#define YY_REDUCE_MIN (-429) -#define YY_REDUCE_MAX (2388) +#define YY_REDUCE_COUNT (299) +#define YY_REDUCE_MIN (-395) +#define YY_REDUCE_MAX (2289) static const short yy_reduce_ofst[] = { - /* 0 */ -266, -299, -9, 683, 745, 790, 846, 876, 932, 1042, - /* 10 */ 1105, 1150, 292, 1206, 1251, 360, 1296, 622, 1313, 1358, - /* 20 */ 235, 1411, 1427, 1480, 1570, 1625, 1678, 1701, 1723, 1746, - /* 30 */ 1768, 1823, 1840, 1885, 1941, 1971, 1994, 2039, 2058, 2084, - /* 40 */ 2142, 2158, 2214, 2231, 2259, 2315, 2332, 2388, -280, -278, - /* 50 */ 225, 690, 926, 939, 948, 966, 296, 451, -352, -339, - /* 60 */ -426, -318, -49, -429, -314, -370, -237, -221, -372, -256, - /* 70 */ 200, -200, -303, -235, -192, -161, 326, 329, 337, 371, - /* 80 */ 394, 397, 470, 473, 479, 6, 104, 472, 554, -204, - /* 90 */ 659, 242, 687, 709, 710, 748, 182, 749, 761, 262, - /* 100 */ 764, 247, 274, 318, 651, 21, -259, -422, -422, -236, - /* 110 */ 48, 267, 343, 506, 655, 664, 671, 723, 730, 810, - /* 120 */ 811, 812, 822, 839, 857, 858, 859, 860, 862, 864, - /* 130 */ 245, 352, -176, -7, 47, 179, 352, 481, 488, 327, - /* 140 */ 273, 409, 396, -243, 353, 465, -347, -106, -208, 224, - /* 150 */ 466, 407, 534, 121, 573, -359, 377, 631, 678, 696, - /* 160 */ 770, 801, 626, 368, 699, 784, 645, 742, 881, 804, - /* 170 */ 843, 843, 889, 824, 909, 880, 906, 831, 831, 816, - /* 180 */ 831, 837, 835, 843, 907, 913, 933, 944, 950, 954, - /* 190 */ 957, 1011, 1012, 972, 976, 983, 1019, 1028, 1029, 1030, - /* 200 */ 1039, 1043, 981, 1037, 1007, 1044, 1051, 1003, 1052, 1060, - /* 210 */ 1061, 1064, 1065, 1072, 1068, 1076, 1080, 1090, 1062, 1073, - /* 220 */ 1075, 1077, 1078, 1079, 1081, 1083, 1084, 1085, 1087, 1088, - /* 230 */ 1109, 1063, 1082, 1049, 1066, 1070, 1118, 1067, 1094, 1129, - /* 240 */ 1135, 1091, 1092, 1098, 1034, 1096, 1110, 1045, 1099, 1113, - /* 250 */ 1114, 843, 1038, 1046, 1050, 1053, 1055, 1059, 1100, 1036, - /* 260 */ 1047, 1056, 831, 1139, 1115, 1183, 1189, 1187, 1188, 1146, - /* 270 */ 1149, 1161, 1163, 1165, 1167, 1147, 1168, 1155, 1201, 1190, - /* 280 */ 1202, 1176, 1123, 1191, 1179, 1199, 1214, 1212, 1236, 1232, - /* 290 */ 1172, 1170, 1186, 1196, 1216, 1223, 1230, 1240, 1245, + /* 0 */ -253, -301, -11, 277, 687, 745, 792, 849, 907, 937, + /* 10 */ 969, 1048, 1106, 1126, 1184, 1214, 75, 1231, 1288, 363, + /* 20 */ 775, 1335, 1352, 1407, 1430, 1462, 1509, 1533, 1599, 1621, + /* 30 */ 1646, 1709, 1737, 1767, 1799, 1831, 1863, 1888, 1920, 1982, + /* 40 */ 1999, 2056, 2078, 2144, 2168, 2232, 2257, 2289, -282, -336, + /* 50 */ 285, 396, 790, 829, 960, 1033, 651, 691, -354, -341, + /* 60 */ -378, -337, -226, -26, 208, -364, -266, 21, -375, -332, + /* 70 */ -326, -343, -369, -293, -182, 112, 198, 309, 357, 470, + /* 80 */ 479, 486, -32, 548, 549, -106, -280, 663, 678, -201, + /* 90 */ 693, -260, 699, 60, 727, 226, 484, 751, 794, 305, + /* 100 */ 666, 527, 336, 561, 812, 119, -283, -395, -395, -154, + /* 110 */ 187, -295, -22, -18, 166, 221, 384, 405, 410, 456, + /* 120 */ 555, 653, 684, 704, 706, 719, 736, 756, 801, 817, + /* 130 */ 292, -28, -82, 222, 179, 255, -28, 376, 418, 483, + /* 140 */ 258, 279, 424, 291, 440, 441, -162, 501, 522, 559, + /* 150 */ 473, 679, 681, 700, 414, 195, 260, 288, 353, 367, + /* 160 */ 399, 407, 443, -312, 566, 544, 459, 499, 752, 597, + /* 170 */ 757, 757, 777, 827, 798, 840, 854, 802, 802, 813, + /* 180 */ 802, 819, 806, 757, 889, 898, 920, 961, 973, 981, + /* 190 */ 990, 1032, 1036, 1004, 992, 1008, 1044, 1054, 1056, 1057, + /* 200 */ 1069, 1070, 1005, 1062, 1034, 1067, 1074, 1024, 1075, 1084, + /* 210 */ 1081, 1083, 1085, 1090, 1088, 1093, 1094, 1107, 1076, 1077, + /* 220 */ 1079, 1080, 1089, 1091, 1092, 1096, 1103, 1110, 1113, 1104, + /* 230 */ 1122, 1109, 1111, 1066, 1095, 1082, 1136, 1099, 1114, 1144, + /* 240 */ 1154, 1115, 1117, 1129, 1059, 1118, 1130, 1060, 1119, 1137, + /* 250 */ 1138, 757, 1073, 1078, 1086, 1101, 1087, 1108, 1142, 1100, + /* 260 */ 1120, 1116, 802, 1183, 1148, 1224, 1220, 1222, 1225, 1179, + /* 270 */ 1180, 1197, 1199, 1202, 1204, 1206, 1181, 1207, 1186, 1235, + /* 280 */ 1227, 1240, 1216, 1162, 1238, 1228, 1258, 1266, 1269, 1277, + /* 290 */ 1282, 1219, 1223, 1226, 1232, 1265, 1281, 1284, 1276, 1307, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 10 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 20 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 30 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 40 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 50 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 60 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 70 */ 1625, 1882, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 80 */ 1625, 1625, 1625, 1625, 1625, 1703, 1625, 1625, 1625, 1625, - /* 90 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 100 */ 1625, 1625, 1625, 1625, 1625, 1701, 1875, 2081, 1625, 1625, - /* 110 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 120 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 130 */ 1625, 2093, 1625, 1625, 1703, 1625, 2093, 2093, 2093, 1701, - /* 140 */ 2053, 2053, 1625, 1625, 1625, 1625, 1810, 1625, 1625, 1625, - /* 150 */ 1625, 1625, 1625, 1810, 1625, 1625, 1625, 1625, 1625, 1625, - /* 160 */ 1625, 1625, 1925, 1625, 1625, 2118, 2172, 1625, 1625, 2121, - /* 170 */ 1625, 1625, 1625, 1887, 1625, 1763, 2108, 2085, 2099, 2156, - /* 180 */ 2086, 2083, 2102, 1625, 2112, 1625, 1918, 1880, 1625, 1880, - /* 190 */ 1877, 1625, 1625, 1880, 1877, 1877, 1754, 1625, 1625, 1625, - /* 200 */ 1625, 1625, 1625, 1703, 1625, 1703, 1625, 1625, 1703, 1625, - /* 210 */ 1703, 1703, 1703, 1625, 1703, 1682, 1682, 1625, 1625, 1625, - /* 220 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 230 */ 1625, 1625, 1625, 1940, 1931, 1625, 1701, 1927, 1625, 1701, - /* 240 */ 1625, 1625, 1625, 1625, 2129, 2127, 1625, 2129, 2127, 1625, - /* 250 */ 1625, 1625, 2141, 2137, 2129, 2145, 2143, 2114, 2112, 2175, - /* 260 */ 2162, 2158, 2099, 1625, 1625, 1625, 1625, 1701, 1701, 2127, - /* 270 */ 1625, 1625, 1625, 1625, 1625, 2127, 1625, 1625, 1701, 1625, - /* 280 */ 1701, 1625, 1625, 1779, 1625, 1625, 1625, 1701, 1657, 1625, - /* 290 */ 1920, 1933, 1903, 1903, 1813, 1813, 1813, 1704, 1630, 1625, - /* 300 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 310 */ 1625, 2140, 2139, 2008, 1625, 2057, 2056, 2055, 2046, 2007, - /* 320 */ 1775, 1625, 2006, 2005, 1625, 1625, 1625, 1625, 1625, 1625, - /* 330 */ 1894, 1893, 1999, 1625, 1625, 2000, 1998, 1997, 1625, 1625, - /* 340 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 350 */ 1625, 1625, 1625, 1625, 1625, 2159, 2163, 1625, 1625, 1625, - /* 360 */ 1625, 1625, 1625, 1625, 2082, 1625, 1625, 1625, 1625, 1625, - /* 370 */ 1982, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 380 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 390 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 400 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 410 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 420 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 430 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 440 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 450 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 460 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 470 */ 1625, 1662, 1987, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 480 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 490 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 500 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 510 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1742, - /* 520 */ 1741, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 530 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 540 */ 1625, 1625, 1625, 1990, 1625, 1625, 1625, 1625, 1625, 1625, - /* 550 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 2155, 2115, 1625, - /* 560 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 570 */ 1625, 1625, 1625, 1625, 1625, 1625, 1982, 1625, 2138, 1625, - /* 580 */ 1625, 2153, 1625, 2157, 1625, 1625, 1625, 1625, 1625, 1625, - /* 590 */ 1625, 2092, 2088, 1625, 1625, 2084, 1625, 1625, 1625, 1625, - /* 600 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 610 */ 1625, 1625, 1625, 1625, 1625, 1981, 1625, 2043, 1625, 1625, - /* 620 */ 1625, 2077, 1625, 1625, 2028, 1625, 1625, 1625, 1625, 1625, - /* 630 */ 1625, 1625, 1625, 1625, 1990, 1625, 1993, 1625, 1625, 1625, - /* 640 */ 1625, 1625, 1807, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 650 */ 1625, 1625, 1625, 1625, 1625, 1792, 1790, 1789, 1788, 1625, - /* 660 */ 1785, 1625, 1820, 1625, 1625, 1625, 1816, 1815, 1625, 1625, - /* 670 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 680 */ 1625, 1625, 1625, 1722, 1625, 1625, 1625, 1625, 1625, 1625, - /* 690 */ 1625, 1625, 1714, 1625, 1713, 1625, 1625, 1625, 1625, 1625, - /* 700 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 710 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, 1625, - /* 720 */ 1625, 1625, 1625, 1625, 1625, 1625, 1625, + /* 0 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 10 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 20 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 30 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 40 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 50 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 60 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 70 */ 1634, 1891, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 80 */ 1634, 1634, 1634, 1634, 1634, 1712, 1634, 1634, 1634, 1634, + /* 90 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 100 */ 1634, 1634, 1634, 1634, 1634, 1710, 1884, 2093, 1634, 1634, + /* 110 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 120 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 130 */ 1634, 2105, 1634, 1634, 1712, 1634, 2105, 2105, 2105, 1710, + /* 140 */ 2065, 2065, 1634, 1634, 1634, 1634, 1819, 1634, 1634, 1634, + /* 150 */ 1634, 1634, 1634, 1819, 1634, 1634, 1634, 1634, 1634, 1634, + /* 160 */ 1634, 1634, 1936, 1634, 1634, 2130, 2184, 1634, 1634, 2133, + /* 170 */ 1634, 1634, 1634, 1896, 1634, 1772, 2120, 2097, 2111, 2168, + /* 180 */ 2098, 2095, 2114, 1634, 2124, 1634, 1929, 1889, 1634, 1889, + /* 190 */ 1886, 1634, 1634, 1889, 1886, 1886, 1763, 1634, 1634, 1634, + /* 200 */ 1634, 1634, 1634, 1712, 1634, 1712, 1634, 1634, 1712, 1634, + /* 210 */ 1712, 1712, 1712, 1634, 1712, 1691, 1691, 1634, 1634, 1634, + /* 220 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 230 */ 1634, 1634, 1634, 1951, 1942, 1634, 1710, 1938, 1634, 1710, + /* 240 */ 1634, 1634, 1634, 1634, 2141, 2139, 1634, 2141, 2139, 1634, + /* 250 */ 1634, 1634, 2153, 2149, 2141, 2157, 2155, 2126, 2124, 2187, + /* 260 */ 2174, 2170, 2111, 1634, 1634, 1634, 1634, 1710, 1710, 1634, + /* 270 */ 2139, 1634, 1634, 1634, 1634, 1634, 2139, 1634, 1634, 1710, + /* 280 */ 1634, 1710, 1634, 1634, 1788, 1634, 1634, 1634, 1710, 1666, + /* 290 */ 1634, 1931, 1944, 1914, 1914, 1822, 1822, 1822, 1713, 1639, + /* 300 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 310 */ 1634, 1634, 2152, 2151, 2020, 1634, 2069, 2068, 2067, 2058, + /* 320 */ 2019, 1784, 1634, 2018, 2017, 1634, 1634, 1634, 1634, 1634, + /* 330 */ 1634, 1905, 1904, 2011, 1634, 1634, 2012, 2010, 2009, 1634, + /* 340 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 350 */ 1634, 1634, 1634, 1634, 1634, 1634, 2171, 2175, 1634, 1634, + /* 360 */ 1634, 1634, 1634, 1634, 1634, 2094, 1634, 1634, 1634, 1634, + /* 370 */ 1634, 1993, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 380 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 390 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 400 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 410 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 420 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 430 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 440 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 450 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 460 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 470 */ 1634, 1634, 1671, 1998, 1634, 1634, 1634, 1634, 1634, 1634, + /* 480 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 490 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 500 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 510 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 520 */ 1751, 1750, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 530 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 540 */ 1634, 1634, 1634, 1634, 2002, 1634, 1634, 1634, 1634, 1634, + /* 550 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 2167, 2127, + /* 560 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 570 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1993, 1634, 2150, + /* 580 */ 1634, 1634, 2165, 1634, 2169, 1634, 1634, 1634, 1634, 1634, + /* 590 */ 1634, 1634, 2104, 2100, 1634, 1634, 2096, 1634, 1634, 1634, + /* 600 */ 1634, 1634, 1634, 1634, 2001, 1634, 1634, 1634, 1634, 1634, + /* 610 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1992, 1634, + /* 620 */ 2055, 1634, 1634, 1634, 2089, 1634, 1634, 2040, 1634, 1634, + /* 630 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 2002, 1634, 2005, + /* 640 */ 1634, 1634, 1634, 1634, 1634, 1816, 1634, 1634, 1634, 1634, + /* 650 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1801, 1799, + /* 660 */ 1798, 1797, 1634, 1794, 1634, 1829, 1634, 1634, 1634, 1825, + /* 670 */ 1824, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 680 */ 1634, 1634, 1634, 1634, 1634, 1634, 1731, 1634, 1634, 1634, + /* 690 */ 1634, 1634, 1634, 1634, 1634, 1723, 1634, 1722, 1634, 1634, + /* 700 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 710 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, + /* 720 */ 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1819,85 +1766,87 @@ static const char *const yyTokenName[] = { /* 381 */ "tag_list_opt", /* 382 */ "tag_item", /* 383 */ "column_alias", - /* 384 */ "index_options", - /* 385 */ "func_list", - /* 386 */ "sliding_opt", - /* 387 */ "sma_stream_opt", - /* 388 */ "func", - /* 389 */ "sma_func_name", - /* 390 */ "query_or_subquery", - /* 391 */ "cgroup_name", - /* 392 */ "analyze_opt", - /* 393 */ "explain_options", - /* 394 */ "agg_func_opt", - /* 395 */ "bufsize_opt", - /* 396 */ "stream_name", - /* 397 */ "stream_options", - /* 398 */ "col_list_opt", - /* 399 */ "subtable_opt", - /* 400 */ "expression", - /* 401 */ "dnode_list", - /* 402 */ "where_clause_opt", - /* 403 */ "signed", - /* 404 */ "literal_func", - /* 405 */ "literal_list", - /* 406 */ "table_alias", - /* 407 */ "expr_or_subquery", - /* 408 */ "pseudo_column", - /* 409 */ "column_reference", - /* 410 */ "function_expression", - /* 411 */ "case_when_expression", - /* 412 */ "star_func", - /* 413 */ "star_func_para_list", - /* 414 */ "noarg_func", - /* 415 */ "other_para_list", - /* 416 */ "star_func_para", - /* 417 */ "when_then_list", - /* 418 */ "case_when_else_opt", - /* 419 */ "common_expression", - /* 420 */ "when_then_expr", - /* 421 */ "predicate", - /* 422 */ "compare_op", - /* 423 */ "in_op", - /* 424 */ "in_predicate_value", - /* 425 */ "boolean_value_expression", - /* 426 */ "boolean_primary", - /* 427 */ "from_clause_opt", - /* 428 */ "table_reference_list", - /* 429 */ "table_reference", - /* 430 */ "table_primary", - /* 431 */ "joined_table", - /* 432 */ "alias_opt", - /* 433 */ "subquery", - /* 434 */ "parenthesized_joined_table", - /* 435 */ "join_type", - /* 436 */ "search_condition", - /* 437 */ "query_specification", - /* 438 */ "set_quantifier_opt", - /* 439 */ "select_list", - /* 440 */ "partition_by_clause_opt", - /* 441 */ "range_opt", - /* 442 */ "every_opt", - /* 443 */ "fill_opt", - /* 444 */ "twindow_clause_opt", - /* 445 */ "group_by_clause_opt", - /* 446 */ "having_clause_opt", - /* 447 */ "select_item", - /* 448 */ "partition_list", - /* 449 */ "partition_item", - /* 450 */ "fill_mode", - /* 451 */ "group_by_list", - /* 452 */ "query_expression", - /* 453 */ "query_simple", - /* 454 */ "order_by_clause_opt", - /* 455 */ "slimit_clause_opt", - /* 456 */ "limit_clause_opt", - /* 457 */ "union_query_expression", - /* 458 */ "query_simple_or_subquery", - /* 459 */ "sort_specification_list", - /* 460 */ "sort_specification", - /* 461 */ "ordering_specification_opt", - /* 462 */ "null_ordering_opt", + /* 384 */ "full_index_name", + /* 385 */ "index_options", + /* 386 */ "index_name", + /* 387 */ "func_list", + /* 388 */ "sliding_opt", + /* 389 */ "sma_stream_opt", + /* 390 */ "func", + /* 391 */ "sma_func_name", + /* 392 */ "query_or_subquery", + /* 393 */ "cgroup_name", + /* 394 */ "analyze_opt", + /* 395 */ "explain_options", + /* 396 */ "agg_func_opt", + /* 397 */ "bufsize_opt", + /* 398 */ "stream_name", + /* 399 */ "stream_options", + /* 400 */ "col_list_opt", + /* 401 */ "subtable_opt", + /* 402 */ "expression", + /* 403 */ "dnode_list", + /* 404 */ "where_clause_opt", + /* 405 */ "signed", + /* 406 */ "literal_func", + /* 407 */ "literal_list", + /* 408 */ "table_alias", + /* 409 */ "expr_or_subquery", + /* 410 */ "pseudo_column", + /* 411 */ "column_reference", + /* 412 */ "function_expression", + /* 413 */ "case_when_expression", + /* 414 */ "star_func", + /* 415 */ "star_func_para_list", + /* 416 */ "noarg_func", + /* 417 */ "other_para_list", + /* 418 */ "star_func_para", + /* 419 */ "when_then_list", + /* 420 */ "case_when_else_opt", + /* 421 */ "common_expression", + /* 422 */ "when_then_expr", + /* 423 */ "predicate", + /* 424 */ "compare_op", + /* 425 */ "in_op", + /* 426 */ "in_predicate_value", + /* 427 */ "boolean_value_expression", + /* 428 */ "boolean_primary", + /* 429 */ "from_clause_opt", + /* 430 */ "table_reference_list", + /* 431 */ "table_reference", + /* 432 */ "table_primary", + /* 433 */ "joined_table", + /* 434 */ "alias_opt", + /* 435 */ "subquery", + /* 436 */ "parenthesized_joined_table", + /* 437 */ "join_type", + /* 438 */ "search_condition", + /* 439 */ "query_specification", + /* 440 */ "set_quantifier_opt", + /* 441 */ "select_list", + /* 442 */ "partition_by_clause_opt", + /* 443 */ "range_opt", + /* 444 */ "every_opt", + /* 445 */ "fill_opt", + /* 446 */ "twindow_clause_opt", + /* 447 */ "group_by_clause_opt", + /* 448 */ "having_clause_opt", + /* 449 */ "select_item", + /* 450 */ "partition_list", + /* 451 */ "partition_item", + /* 452 */ "fill_mode", + /* 453 */ "group_by_list", + /* 454 */ "query_expression", + /* 455 */ "query_simple", + /* 456 */ "order_by_clause_opt", + /* 457 */ "slimit_clause_opt", + /* 458 */ "limit_clause_opt", + /* 459 */ "union_query_expression", + /* 460 */ "query_simple_or_subquery", + /* 461 */ "sort_specification_list", + /* 462 */ "sort_specification", + /* 463 */ "ordering_specification_opt", + /* 464 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -2167,294 +2116,297 @@ static const char *const yyRuleName[] = { /* 259 */ "tag_item ::= column_name", /* 260 */ "tag_item ::= column_name column_alias", /* 261 */ "tag_item ::= column_name AS column_alias", - /* 262 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options", - /* 263 */ "cmd ::= CREATE INDEX not_exists_opt full_table_name ON full_table_name NK_LP col_name_list NK_RP", - /* 264 */ "cmd ::= DROP INDEX exists_opt full_table_name", - /* 265 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 266 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt", - /* 267 */ "func_list ::= func", - /* 268 */ "func_list ::= func_list NK_COMMA func", - /* 269 */ "func ::= sma_func_name NK_LP expression_list NK_RP", - /* 270 */ "sma_func_name ::= function_name", - /* 271 */ "sma_func_name ::= COUNT", - /* 272 */ "sma_func_name ::= FIRST", - /* 273 */ "sma_func_name ::= LAST", - /* 274 */ "sma_func_name ::= LAST_ROW", - /* 275 */ "sma_stream_opt ::=", - /* 276 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", - /* 277 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", - /* 278 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", - /* 279 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", - /* 280 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", - /* 281 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", - /* 282 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", - /* 283 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", - /* 284 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 285 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 286 */ "cmd ::= DESC full_table_name", - /* 287 */ "cmd ::= DESCRIBE full_table_name", - /* 288 */ "cmd ::= RESET QUERY CACHE", - /* 289 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", - /* 290 */ "analyze_opt ::=", - /* 291 */ "analyze_opt ::= ANALYZE", - /* 292 */ "explain_options ::=", - /* 293 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 294 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 295 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", - /* 296 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 297 */ "agg_func_opt ::=", - /* 298 */ "agg_func_opt ::= AGGREGATE", - /* 299 */ "bufsize_opt ::=", - /* 300 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 301 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tags_def_opt subtable_opt AS query_or_subquery", - /* 302 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 303 */ "col_list_opt ::=", - /* 304 */ "col_list_opt ::= NK_LP col_name_list NK_RP", - /* 305 */ "stream_options ::=", - /* 306 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 307 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 308 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 309 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 310 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 311 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", - /* 312 */ "subtable_opt ::=", - /* 313 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 314 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 315 */ "cmd ::= KILL QUERY NK_STRING", - /* 316 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 317 */ "cmd ::= BALANCE VGROUP", - /* 318 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 319 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 320 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 321 */ "dnode_list ::= DNODE NK_INTEGER", - /* 322 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 323 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 324 */ "cmd ::= query_or_subquery", - /* 325 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 326 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", - /* 327 */ "literal ::= NK_INTEGER", - /* 328 */ "literal ::= NK_FLOAT", - /* 329 */ "literal ::= NK_STRING", - /* 330 */ "literal ::= NK_BOOL", - /* 331 */ "literal ::= TIMESTAMP NK_STRING", - /* 332 */ "literal ::= duration_literal", - /* 333 */ "literal ::= NULL", - /* 334 */ "literal ::= NK_QUESTION", - /* 335 */ "duration_literal ::= NK_VARIABLE", - /* 336 */ "signed ::= NK_INTEGER", - /* 337 */ "signed ::= NK_PLUS NK_INTEGER", - /* 338 */ "signed ::= NK_MINUS NK_INTEGER", - /* 339 */ "signed ::= NK_FLOAT", - /* 340 */ "signed ::= NK_PLUS NK_FLOAT", - /* 341 */ "signed ::= NK_MINUS NK_FLOAT", - /* 342 */ "signed_literal ::= signed", - /* 343 */ "signed_literal ::= NK_STRING", - /* 344 */ "signed_literal ::= NK_BOOL", - /* 345 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 346 */ "signed_literal ::= duration_literal", - /* 347 */ "signed_literal ::= NULL", - /* 348 */ "signed_literal ::= literal_func", - /* 349 */ "signed_literal ::= NK_QUESTION", - /* 350 */ "literal_list ::= signed_literal", - /* 351 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 352 */ "db_name ::= NK_ID", - /* 353 */ "table_name ::= NK_ID", - /* 354 */ "column_name ::= NK_ID", - /* 355 */ "function_name ::= NK_ID", - /* 356 */ "table_alias ::= NK_ID", - /* 357 */ "column_alias ::= NK_ID", - /* 358 */ "user_name ::= NK_ID", - /* 359 */ "topic_name ::= NK_ID", - /* 360 */ "stream_name ::= NK_ID", - /* 361 */ "cgroup_name ::= NK_ID", - /* 362 */ "expr_or_subquery ::= expression", - /* 363 */ "expression ::= literal", - /* 364 */ "expression ::= pseudo_column", - /* 365 */ "expression ::= column_reference", - /* 366 */ "expression ::= function_expression", - /* 367 */ "expression ::= case_when_expression", - /* 368 */ "expression ::= NK_LP expression NK_RP", - /* 369 */ "expression ::= NK_PLUS expr_or_subquery", - /* 370 */ "expression ::= NK_MINUS expr_or_subquery", - /* 371 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 372 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 373 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 374 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 375 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 376 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 377 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 378 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 379 */ "expression_list ::= expr_or_subquery", - /* 380 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 381 */ "column_reference ::= column_name", - /* 382 */ "column_reference ::= table_name NK_DOT column_name", - /* 383 */ "pseudo_column ::= ROWTS", - /* 384 */ "pseudo_column ::= TBNAME", - /* 385 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 386 */ "pseudo_column ::= QSTART", - /* 387 */ "pseudo_column ::= QEND", - /* 388 */ "pseudo_column ::= QDURATION", - /* 389 */ "pseudo_column ::= WSTART", - /* 390 */ "pseudo_column ::= WEND", - /* 391 */ "pseudo_column ::= WDURATION", - /* 392 */ "pseudo_column ::= IROWTS", - /* 393 */ "pseudo_column ::= ISFILLED", - /* 394 */ "pseudo_column ::= QTAGS", - /* 395 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 396 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 397 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 398 */ "function_expression ::= literal_func", - /* 399 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 400 */ "literal_func ::= NOW", - /* 401 */ "noarg_func ::= NOW", - /* 402 */ "noarg_func ::= TODAY", - /* 403 */ "noarg_func ::= TIMEZONE", - /* 404 */ "noarg_func ::= DATABASE", - /* 405 */ "noarg_func ::= CLIENT_VERSION", - /* 406 */ "noarg_func ::= SERVER_VERSION", - /* 407 */ "noarg_func ::= SERVER_STATUS", - /* 408 */ "noarg_func ::= CURRENT_USER", - /* 409 */ "noarg_func ::= USER", - /* 410 */ "star_func ::= COUNT", - /* 411 */ "star_func ::= FIRST", - /* 412 */ "star_func ::= LAST", - /* 413 */ "star_func ::= LAST_ROW", - /* 414 */ "star_func_para_list ::= NK_STAR", - /* 415 */ "star_func_para_list ::= other_para_list", - /* 416 */ "other_para_list ::= star_func_para", - /* 417 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 418 */ "star_func_para ::= expr_or_subquery", - /* 419 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 420 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 421 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 422 */ "when_then_list ::= when_then_expr", - /* 423 */ "when_then_list ::= when_then_list when_then_expr", - /* 424 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 425 */ "case_when_else_opt ::=", - /* 426 */ "case_when_else_opt ::= ELSE common_expression", - /* 427 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 428 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 429 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 430 */ "predicate ::= expr_or_subquery IS NULL", - /* 431 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 432 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 433 */ "compare_op ::= NK_LT", - /* 434 */ "compare_op ::= NK_GT", - /* 435 */ "compare_op ::= NK_LE", - /* 436 */ "compare_op ::= NK_GE", - /* 437 */ "compare_op ::= NK_NE", - /* 438 */ "compare_op ::= NK_EQ", - /* 439 */ "compare_op ::= LIKE", - /* 440 */ "compare_op ::= NOT LIKE", - /* 441 */ "compare_op ::= MATCH", - /* 442 */ "compare_op ::= NMATCH", - /* 443 */ "compare_op ::= CONTAINS", - /* 444 */ "in_op ::= IN", - /* 445 */ "in_op ::= NOT IN", - /* 446 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 447 */ "boolean_value_expression ::= boolean_primary", - /* 448 */ "boolean_value_expression ::= NOT boolean_primary", - /* 449 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 450 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 451 */ "boolean_primary ::= predicate", - /* 452 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 453 */ "common_expression ::= expr_or_subquery", - /* 454 */ "common_expression ::= boolean_value_expression", - /* 455 */ "from_clause_opt ::=", - /* 456 */ "from_clause_opt ::= FROM table_reference_list", - /* 457 */ "table_reference_list ::= table_reference", - /* 458 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 459 */ "table_reference ::= table_primary", - /* 460 */ "table_reference ::= joined_table", - /* 461 */ "table_primary ::= table_name alias_opt", - /* 462 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 463 */ "table_primary ::= subquery alias_opt", - /* 464 */ "table_primary ::= parenthesized_joined_table", - /* 465 */ "alias_opt ::=", - /* 466 */ "alias_opt ::= table_alias", - /* 467 */ "alias_opt ::= AS table_alias", - /* 468 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 469 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 470 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 471 */ "join_type ::=", - /* 472 */ "join_type ::= INNER", - /* 473 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 474 */ "set_quantifier_opt ::=", - /* 475 */ "set_quantifier_opt ::= DISTINCT", - /* 476 */ "set_quantifier_opt ::= ALL", - /* 477 */ "select_list ::= select_item", - /* 478 */ "select_list ::= select_list NK_COMMA select_item", - /* 479 */ "select_item ::= NK_STAR", - /* 480 */ "select_item ::= common_expression", - /* 481 */ "select_item ::= common_expression column_alias", - /* 482 */ "select_item ::= common_expression AS column_alias", - /* 483 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 484 */ "where_clause_opt ::=", - /* 485 */ "where_clause_opt ::= WHERE search_condition", - /* 486 */ "partition_by_clause_opt ::=", - /* 487 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 488 */ "partition_list ::= partition_item", - /* 489 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 490 */ "partition_item ::= expr_or_subquery", - /* 491 */ "partition_item ::= expr_or_subquery column_alias", - /* 492 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 493 */ "twindow_clause_opt ::=", - /* 494 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 495 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 496 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 497 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 498 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", - /* 499 */ "sliding_opt ::=", - /* 500 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 501 */ "fill_opt ::=", - /* 502 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 503 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 504 */ "fill_mode ::= NONE", - /* 505 */ "fill_mode ::= PREV", - /* 506 */ "fill_mode ::= NULL", - /* 507 */ "fill_mode ::= LINEAR", - /* 508 */ "fill_mode ::= NEXT", - /* 509 */ "group_by_clause_opt ::=", - /* 510 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 511 */ "group_by_list ::= expr_or_subquery", - /* 512 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 513 */ "having_clause_opt ::=", - /* 514 */ "having_clause_opt ::= HAVING search_condition", - /* 515 */ "range_opt ::=", - /* 516 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 517 */ "every_opt ::=", - /* 518 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 519 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 520 */ "query_simple ::= query_specification", - /* 521 */ "query_simple ::= union_query_expression", - /* 522 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 523 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 524 */ "query_simple_or_subquery ::= query_simple", - /* 525 */ "query_simple_or_subquery ::= subquery", - /* 526 */ "query_or_subquery ::= query_expression", - /* 527 */ "query_or_subquery ::= subquery", - /* 528 */ "order_by_clause_opt ::=", - /* 529 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 530 */ "slimit_clause_opt ::=", - /* 531 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 532 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 533 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 534 */ "limit_clause_opt ::=", - /* 535 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 536 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 537 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 538 */ "subquery ::= NK_LP query_expression NK_RP", - /* 539 */ "subquery ::= NK_LP subquery NK_RP", - /* 540 */ "search_condition ::= common_expression", - /* 541 */ "sort_specification_list ::= sort_specification", - /* 542 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 543 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 544 */ "ordering_specification_opt ::=", - /* 545 */ "ordering_specification_opt ::= ASC", - /* 546 */ "ordering_specification_opt ::= DESC", - /* 547 */ "null_ordering_opt ::=", - /* 548 */ "null_ordering_opt ::= NULLS FIRST", - /* 549 */ "null_ordering_opt ::= NULLS LAST", + /* 262 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options", + /* 263 */ "cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP", + /* 264 */ "cmd ::= DROP INDEX exists_opt full_index_name", + /* 265 */ "full_index_name ::= index_name", + /* 266 */ "full_index_name ::= db_name NK_DOT index_name", + /* 267 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 268 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt", + /* 269 */ "func_list ::= func", + /* 270 */ "func_list ::= func_list NK_COMMA func", + /* 271 */ "func ::= sma_func_name NK_LP expression_list NK_RP", + /* 272 */ "sma_func_name ::= function_name", + /* 273 */ "sma_func_name ::= COUNT", + /* 274 */ "sma_func_name ::= FIRST", + /* 275 */ "sma_func_name ::= LAST", + /* 276 */ "sma_func_name ::= LAST_ROW", + /* 277 */ "sma_stream_opt ::=", + /* 278 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", + /* 279 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", + /* 280 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", + /* 281 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", + /* 282 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", + /* 283 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", + /* 284 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", + /* 285 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", + /* 286 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 287 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 288 */ "cmd ::= DESC full_table_name", + /* 289 */ "cmd ::= DESCRIBE full_table_name", + /* 290 */ "cmd ::= RESET QUERY CACHE", + /* 291 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", + /* 292 */ "analyze_opt ::=", + /* 293 */ "analyze_opt ::= ANALYZE", + /* 294 */ "explain_options ::=", + /* 295 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 296 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 297 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 298 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 299 */ "agg_func_opt ::=", + /* 300 */ "agg_func_opt ::= AGGREGATE", + /* 301 */ "bufsize_opt ::=", + /* 302 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 303 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tags_def_opt subtable_opt AS query_or_subquery", + /* 304 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 305 */ "col_list_opt ::=", + /* 306 */ "col_list_opt ::= NK_LP col_name_list NK_RP", + /* 307 */ "stream_options ::=", + /* 308 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 309 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 310 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 311 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 312 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", + /* 313 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", + /* 314 */ "subtable_opt ::=", + /* 315 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 316 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 317 */ "cmd ::= KILL QUERY NK_STRING", + /* 318 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 319 */ "cmd ::= BALANCE VGROUP", + /* 320 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 321 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 322 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 323 */ "dnode_list ::= DNODE NK_INTEGER", + /* 324 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 325 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 326 */ "cmd ::= query_or_subquery", + /* 327 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 328 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", + /* 329 */ "literal ::= NK_INTEGER", + /* 330 */ "literal ::= NK_FLOAT", + /* 331 */ "literal ::= NK_STRING", + /* 332 */ "literal ::= NK_BOOL", + /* 333 */ "literal ::= TIMESTAMP NK_STRING", + /* 334 */ "literal ::= duration_literal", + /* 335 */ "literal ::= NULL", + /* 336 */ "literal ::= NK_QUESTION", + /* 337 */ "duration_literal ::= NK_VARIABLE", + /* 338 */ "signed ::= NK_INTEGER", + /* 339 */ "signed ::= NK_PLUS NK_INTEGER", + /* 340 */ "signed ::= NK_MINUS NK_INTEGER", + /* 341 */ "signed ::= NK_FLOAT", + /* 342 */ "signed ::= NK_PLUS NK_FLOAT", + /* 343 */ "signed ::= NK_MINUS NK_FLOAT", + /* 344 */ "signed_literal ::= signed", + /* 345 */ "signed_literal ::= NK_STRING", + /* 346 */ "signed_literal ::= NK_BOOL", + /* 347 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 348 */ "signed_literal ::= duration_literal", + /* 349 */ "signed_literal ::= NULL", + /* 350 */ "signed_literal ::= literal_func", + /* 351 */ "signed_literal ::= NK_QUESTION", + /* 352 */ "literal_list ::= signed_literal", + /* 353 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 354 */ "db_name ::= NK_ID", + /* 355 */ "table_name ::= NK_ID", + /* 356 */ "column_name ::= NK_ID", + /* 357 */ "function_name ::= NK_ID", + /* 358 */ "table_alias ::= NK_ID", + /* 359 */ "column_alias ::= NK_ID", + /* 360 */ "user_name ::= NK_ID", + /* 361 */ "topic_name ::= NK_ID", + /* 362 */ "stream_name ::= NK_ID", + /* 363 */ "cgroup_name ::= NK_ID", + /* 364 */ "index_name ::= NK_ID", + /* 365 */ "expr_or_subquery ::= expression", + /* 366 */ "expression ::= literal", + /* 367 */ "expression ::= pseudo_column", + /* 368 */ "expression ::= column_reference", + /* 369 */ "expression ::= function_expression", + /* 370 */ "expression ::= case_when_expression", + /* 371 */ "expression ::= NK_LP expression NK_RP", + /* 372 */ "expression ::= NK_PLUS expr_or_subquery", + /* 373 */ "expression ::= NK_MINUS expr_or_subquery", + /* 374 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 375 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 376 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 377 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 378 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 379 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 380 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 381 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 382 */ "expression_list ::= expr_or_subquery", + /* 383 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 384 */ "column_reference ::= column_name", + /* 385 */ "column_reference ::= table_name NK_DOT column_name", + /* 386 */ "pseudo_column ::= ROWTS", + /* 387 */ "pseudo_column ::= TBNAME", + /* 388 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 389 */ "pseudo_column ::= QSTART", + /* 390 */ "pseudo_column ::= QEND", + /* 391 */ "pseudo_column ::= QDURATION", + /* 392 */ "pseudo_column ::= WSTART", + /* 393 */ "pseudo_column ::= WEND", + /* 394 */ "pseudo_column ::= WDURATION", + /* 395 */ "pseudo_column ::= IROWTS", + /* 396 */ "pseudo_column ::= ISFILLED", + /* 397 */ "pseudo_column ::= QTAGS", + /* 398 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 399 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 400 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 401 */ "function_expression ::= literal_func", + /* 402 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 403 */ "literal_func ::= NOW", + /* 404 */ "noarg_func ::= NOW", + /* 405 */ "noarg_func ::= TODAY", + /* 406 */ "noarg_func ::= TIMEZONE", + /* 407 */ "noarg_func ::= DATABASE", + /* 408 */ "noarg_func ::= CLIENT_VERSION", + /* 409 */ "noarg_func ::= SERVER_VERSION", + /* 410 */ "noarg_func ::= SERVER_STATUS", + /* 411 */ "noarg_func ::= CURRENT_USER", + /* 412 */ "noarg_func ::= USER", + /* 413 */ "star_func ::= COUNT", + /* 414 */ "star_func ::= FIRST", + /* 415 */ "star_func ::= LAST", + /* 416 */ "star_func ::= LAST_ROW", + /* 417 */ "star_func_para_list ::= NK_STAR", + /* 418 */ "star_func_para_list ::= other_para_list", + /* 419 */ "other_para_list ::= star_func_para", + /* 420 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 421 */ "star_func_para ::= expr_or_subquery", + /* 422 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 423 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 424 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 425 */ "when_then_list ::= when_then_expr", + /* 426 */ "when_then_list ::= when_then_list when_then_expr", + /* 427 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 428 */ "case_when_else_opt ::=", + /* 429 */ "case_when_else_opt ::= ELSE common_expression", + /* 430 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 431 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 432 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 433 */ "predicate ::= expr_or_subquery IS NULL", + /* 434 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 435 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 436 */ "compare_op ::= NK_LT", + /* 437 */ "compare_op ::= NK_GT", + /* 438 */ "compare_op ::= NK_LE", + /* 439 */ "compare_op ::= NK_GE", + /* 440 */ "compare_op ::= NK_NE", + /* 441 */ "compare_op ::= NK_EQ", + /* 442 */ "compare_op ::= LIKE", + /* 443 */ "compare_op ::= NOT LIKE", + /* 444 */ "compare_op ::= MATCH", + /* 445 */ "compare_op ::= NMATCH", + /* 446 */ "compare_op ::= CONTAINS", + /* 447 */ "in_op ::= IN", + /* 448 */ "in_op ::= NOT IN", + /* 449 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 450 */ "boolean_value_expression ::= boolean_primary", + /* 451 */ "boolean_value_expression ::= NOT boolean_primary", + /* 452 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 453 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 454 */ "boolean_primary ::= predicate", + /* 455 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 456 */ "common_expression ::= expr_or_subquery", + /* 457 */ "common_expression ::= boolean_value_expression", + /* 458 */ "from_clause_opt ::=", + /* 459 */ "from_clause_opt ::= FROM table_reference_list", + /* 460 */ "table_reference_list ::= table_reference", + /* 461 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 462 */ "table_reference ::= table_primary", + /* 463 */ "table_reference ::= joined_table", + /* 464 */ "table_primary ::= table_name alias_opt", + /* 465 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 466 */ "table_primary ::= subquery alias_opt", + /* 467 */ "table_primary ::= parenthesized_joined_table", + /* 468 */ "alias_opt ::=", + /* 469 */ "alias_opt ::= table_alias", + /* 470 */ "alias_opt ::= AS table_alias", + /* 471 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 472 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 473 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 474 */ "join_type ::=", + /* 475 */ "join_type ::= INNER", + /* 476 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 477 */ "set_quantifier_opt ::=", + /* 478 */ "set_quantifier_opt ::= DISTINCT", + /* 479 */ "set_quantifier_opt ::= ALL", + /* 480 */ "select_list ::= select_item", + /* 481 */ "select_list ::= select_list NK_COMMA select_item", + /* 482 */ "select_item ::= NK_STAR", + /* 483 */ "select_item ::= common_expression", + /* 484 */ "select_item ::= common_expression column_alias", + /* 485 */ "select_item ::= common_expression AS column_alias", + /* 486 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 487 */ "where_clause_opt ::=", + /* 488 */ "where_clause_opt ::= WHERE search_condition", + /* 489 */ "partition_by_clause_opt ::=", + /* 490 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 491 */ "partition_list ::= partition_item", + /* 492 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 493 */ "partition_item ::= expr_or_subquery", + /* 494 */ "partition_item ::= expr_or_subquery column_alias", + /* 495 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 496 */ "twindow_clause_opt ::=", + /* 497 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 498 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 499 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 500 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 501 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", + /* 502 */ "sliding_opt ::=", + /* 503 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 504 */ "fill_opt ::=", + /* 505 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 506 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 507 */ "fill_mode ::= NONE", + /* 508 */ "fill_mode ::= PREV", + /* 509 */ "fill_mode ::= NULL", + /* 510 */ "fill_mode ::= LINEAR", + /* 511 */ "fill_mode ::= NEXT", + /* 512 */ "group_by_clause_opt ::=", + /* 513 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 514 */ "group_by_list ::= expr_or_subquery", + /* 515 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 516 */ "having_clause_opt ::=", + /* 517 */ "having_clause_opt ::= HAVING search_condition", + /* 518 */ "range_opt ::=", + /* 519 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 520 */ "every_opt ::=", + /* 521 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 522 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 523 */ "query_simple ::= query_specification", + /* 524 */ "query_simple ::= union_query_expression", + /* 525 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 526 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 527 */ "query_simple_or_subquery ::= query_simple", + /* 528 */ "query_simple_or_subquery ::= subquery", + /* 529 */ "query_or_subquery ::= query_expression", + /* 530 */ "query_or_subquery ::= subquery", + /* 531 */ "order_by_clause_opt ::=", + /* 532 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 533 */ "slimit_clause_opt ::=", + /* 534 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 535 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 536 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 537 */ "limit_clause_opt ::=", + /* 538 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 539 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 540 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 541 */ "subquery ::= NK_LP query_expression NK_RP", + /* 542 */ "subquery ::= NK_LP subquery NK_RP", + /* 543 */ "search_condition ::= common_expression", + /* 544 */ "sort_specification_list ::= sort_specification", + /* 545 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 546 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 547 */ "ordering_specification_opt ::=", + /* 548 */ "ordering_specification_opt ::= ASC", + /* 549 */ "ordering_specification_opt ::= DESC", + /* 550 */ "null_ordering_opt ::=", + /* 551 */ "null_ordering_opt ::= NULLS FIRST", + /* 552 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2602,63 +2554,64 @@ static void yy_destructor( case 379: /* table_name_cond */ case 380: /* from_db_opt */ case 382: /* tag_item */ - case 384: /* index_options */ - case 386: /* sliding_opt */ - case 387: /* sma_stream_opt */ - case 388: /* func */ - case 390: /* query_or_subquery */ - case 393: /* explain_options */ - case 397: /* stream_options */ - case 399: /* subtable_opt */ - case 400: /* expression */ - case 402: /* where_clause_opt */ - case 403: /* signed */ - case 404: /* literal_func */ - case 407: /* expr_or_subquery */ - case 408: /* pseudo_column */ - case 409: /* column_reference */ - case 410: /* function_expression */ - case 411: /* case_when_expression */ - case 416: /* star_func_para */ - case 418: /* case_when_else_opt */ - case 419: /* common_expression */ - case 420: /* when_then_expr */ - case 421: /* predicate */ - case 424: /* in_predicate_value */ - case 425: /* boolean_value_expression */ - case 426: /* boolean_primary */ - case 427: /* from_clause_opt */ - case 428: /* table_reference_list */ - case 429: /* table_reference */ - case 430: /* table_primary */ - case 431: /* joined_table */ - case 433: /* subquery */ - case 434: /* parenthesized_joined_table */ - case 436: /* search_condition */ - case 437: /* query_specification */ - case 441: /* range_opt */ - case 442: /* every_opt */ - case 443: /* fill_opt */ - case 444: /* twindow_clause_opt */ - case 446: /* having_clause_opt */ - case 447: /* select_item */ - case 449: /* partition_item */ - case 452: /* query_expression */ - case 453: /* query_simple */ - case 455: /* slimit_clause_opt */ - case 456: /* limit_clause_opt */ - case 457: /* union_query_expression */ - case 458: /* query_simple_or_subquery */ - case 460: /* sort_specification */ + case 384: /* full_index_name */ + case 385: /* index_options */ + case 388: /* sliding_opt */ + case 389: /* sma_stream_opt */ + case 390: /* func */ + case 392: /* query_or_subquery */ + case 395: /* explain_options */ + case 399: /* stream_options */ + case 401: /* subtable_opt */ + case 402: /* expression */ + case 404: /* where_clause_opt */ + case 405: /* signed */ + case 406: /* literal_func */ + case 409: /* expr_or_subquery */ + case 410: /* pseudo_column */ + case 411: /* column_reference */ + case 412: /* function_expression */ + case 413: /* case_when_expression */ + case 418: /* star_func_para */ + case 420: /* case_when_else_opt */ + case 421: /* common_expression */ + case 422: /* when_then_expr */ + case 423: /* predicate */ + case 426: /* in_predicate_value */ + case 427: /* boolean_value_expression */ + case 428: /* boolean_primary */ + case 429: /* from_clause_opt */ + case 430: /* table_reference_list */ + case 431: /* table_reference */ + case 432: /* table_primary */ + case 433: /* joined_table */ + case 435: /* subquery */ + case 436: /* parenthesized_joined_table */ + case 438: /* search_condition */ + case 439: /* query_specification */ + case 443: /* range_opt */ + case 444: /* every_opt */ + case 445: /* fill_opt */ + case 446: /* twindow_clause_opt */ + case 448: /* having_clause_opt */ + case 449: /* select_item */ + case 451: /* partition_item */ + case 454: /* query_expression */ + case 455: /* query_simple */ + case 457: /* slimit_clause_opt */ + case 458: /* limit_clause_opt */ + case 459: /* union_query_expression */ + case 460: /* query_simple_or_subquery */ + case 462: /* sort_specification */ { - nodesDestroyNode((yypminor->yy320)); + nodesDestroyNode((yypminor->yy602)); } break; case 327: /* account_options */ case 328: /* alter_account_options */ case 330: /* alter_account_option */ case 345: /* speed_opt */ - case 395: /* bufsize_opt */ + case 397: /* bufsize_opt */ { } @@ -2672,13 +2625,14 @@ static void yy_destructor( case 368: /* table_name */ case 375: /* function_name */ case 383: /* column_alias */ - case 389: /* sma_func_name */ - case 391: /* cgroup_name */ - case 396: /* stream_name */ - case 406: /* table_alias */ - case 412: /* star_func */ - case 414: /* noarg_func */ - case 432: /* alias_opt */ + case 386: /* index_name */ + case 391: /* sma_func_name */ + case 393: /* cgroup_name */ + case 398: /* stream_name */ + case 408: /* table_alias */ + case 414: /* star_func */ + case 416: /* noarg_func */ + case 434: /* alias_opt */ { } @@ -2698,9 +2652,9 @@ static void yy_destructor( case 340: /* force_opt */ case 341: /* not_exists_opt */ case 343: /* exists_opt */ - case 392: /* analyze_opt */ - case 394: /* agg_func_opt */ - case 438: /* set_quantifier_opt */ + case 394: /* analyze_opt */ + case 396: /* agg_func_opt */ + case 440: /* set_quantifier_opt */ { } @@ -2719,22 +2673,22 @@ static void yy_destructor( case 370: /* duration_list */ case 371: /* rollup_func_list */ case 381: /* tag_list_opt */ - case 385: /* func_list */ - case 398: /* col_list_opt */ - case 401: /* dnode_list */ - case 405: /* literal_list */ - case 413: /* star_func_para_list */ - case 415: /* other_para_list */ - case 417: /* when_then_list */ - case 439: /* select_list */ - case 440: /* partition_by_clause_opt */ - case 445: /* group_by_clause_opt */ - case 448: /* partition_list */ - case 451: /* group_by_list */ - case 454: /* order_by_clause_opt */ - case 459: /* sort_specification_list */ + case 387: /* func_list */ + case 400: /* col_list_opt */ + case 403: /* dnode_list */ + case 407: /* literal_list */ + case 415: /* star_func_para_list */ + case 417: /* other_para_list */ + case 419: /* when_then_list */ + case 441: /* select_list */ + case 442: /* partition_by_clause_opt */ + case 447: /* group_by_clause_opt */ + case 450: /* partition_list */ + case 453: /* group_by_list */ + case 456: /* order_by_clause_opt */ + case 461: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy570)); + nodesDestroyList((yypminor->yy874)); } break; case 349: /* alter_db_option */ @@ -2748,28 +2702,28 @@ static void yy_destructor( } break; - case 422: /* compare_op */ - case 423: /* in_op */ + case 424: /* compare_op */ + case 425: /* in_op */ { } break; - case 435: /* join_type */ + case 437: /* join_type */ { } break; - case 450: /* fill_mode */ + case 452: /* fill_mode */ { } break; - case 461: /* ordering_specification_opt */ + case 463: /* ordering_specification_opt */ { } break; - case 462: /* null_ordering_opt */ + case 464: /* null_ordering_opt */ { } @@ -2897,18 +2851,15 @@ static YYACTIONTYPE yy_find_shift_action( do{ i = yy_shift_ofst[stateno]; assert( i>=0 ); - assert( i<=YY_ACTTAB_COUNT ); - assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); + /* assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); */ assert( iLookAhead!=YYNOCODE ); assert( iLookAhead < YYNTOKEN ); i += iLookAhead; - assert( i<(int)YY_NLOOKAHEAD ); - if( yy_lookahead[i]!=iLookAhead ){ + if( i>=YY_NLOOKAHEAD || yy_lookahead[i]!=iLookAhead ){ #ifdef YYFALLBACK YYCODETYPE iFallback; /* Fallback token */ - assert( iLookAhead %s\n", @@ -2923,8 +2874,16 @@ static YYACTIONTYPE yy_find_shift_action( #ifdef YYWILDCARD { int j = i - iLookAhead + YYWILDCARD; - assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) ); - if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){ + if( +#if YY_SHIFT_MIN+YYWILDCARD<0 + j>=0 && +#endif +#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT + j0 + ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", @@ -2938,7 +2897,6 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ - assert( i>=0 && iyytos; #ifndef NDEBUG if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ - yysize = yyRuleInfoNRhs[yyruleno]; + yysize = yyRuleInfo[yyruleno].nrhs; if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", + fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", yyTracePrompt, - yyruleno, yyRuleName[yyruleno], - yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ yypParser->yyhwm++; @@ -4304,78 +3711,78 @@ static YYACTIONTYPE yy_reduce( yy_destructor(yypParser,329,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy815, &yymsp[-1].minor.yy0, yymsp[0].minor.yy475); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy179, &yymsp[-1].minor.yy0, yymsp[0].minor.yy113); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy815, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy179, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy815, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy179, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy815, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy179, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 28: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy815); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy179); } break; case 29: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy475 = 1; } +{ yymsp[1].minor.yy113 = 1; } break; case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy475 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy113 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } break; case 31: /* cmd ::= GRANT privileges ON priv_level TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy483, &yymsp[-2].minor.yy815, &yymsp[0].minor.yy815); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy159, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy179); } break; case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy483, &yymsp[-2].minor.yy815, &yymsp[0].minor.yy815); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy159, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy179); } break; case 33: /* privileges ::= ALL */ -{ yymsp[0].minor.yy483 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy159 = PRIVILEGE_TYPE_ALL; } break; case 34: /* privileges ::= priv_type_list */ case 36: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==36); -{ yylhsminor.yy483 = yymsp[0].minor.yy483; } - yymsp[0].minor.yy483 = yylhsminor.yy483; +{ yylhsminor.yy159 = yymsp[0].minor.yy159; } + yymsp[0].minor.yy159 = yylhsminor.yy159; break; case 35: /* privileges ::= SUBSCRIBE */ -{ yymsp[0].minor.yy483 = PRIVILEGE_TYPE_SUBSCRIBE; } +{ yymsp[0].minor.yy159 = PRIVILEGE_TYPE_SUBSCRIBE; } break; case 37: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy483 = yymsp[-2].minor.yy483 | yymsp[0].minor.yy483; } - yymsp[-2].minor.yy483 = yylhsminor.yy483; +{ yylhsminor.yy159 = yymsp[-2].minor.yy159 | yymsp[0].minor.yy159; } + yymsp[-2].minor.yy159 = yylhsminor.yy159; break; case 38: /* priv_type ::= READ */ -{ yymsp[0].minor.yy483 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy159 = PRIVILEGE_TYPE_READ; } break; case 39: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy483 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy159 = PRIVILEGE_TYPE_WRITE; } break; case 40: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy815 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy815 = yylhsminor.yy815; +{ yylhsminor.yy179 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy179 = yylhsminor.yy179; break; case 41: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy815 = yymsp[-2].minor.yy815; } - yymsp[-2].minor.yy815 = yylhsminor.yy815; +{ yylhsminor.yy179 = yymsp[-2].minor.yy179; } + yymsp[-2].minor.yy179 = yylhsminor.yy179; break; case 42: /* priv_level ::= topic_name */ - case 270: /* sma_func_name ::= function_name */ yytestcase(yyruleno==270); - case 466: /* alias_opt ::= table_alias */ yytestcase(yyruleno==466); -{ yylhsminor.yy815 = yymsp[0].minor.yy815; } - yymsp[0].minor.yy815 = yylhsminor.yy815; + case 272: /* sma_func_name ::= function_name */ yytestcase(yyruleno==272); + case 469: /* alias_opt ::= table_alias */ yytestcase(yyruleno==469); +{ yylhsminor.yy179 = yymsp[0].minor.yy179; } + yymsp[0].minor.yy179 = yylhsminor.yy179; break; case 43: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy815, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy179, NULL); } break; case 44: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy815, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy0); } break; case 45: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy63); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy767); } break; case 46: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy815, yymsp[0].minor.yy63); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy179, yymsp[0].minor.yy767); } break; case 47: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -4392,49 +3799,50 @@ static YYACTIONTYPE yy_reduce( case 51: /* dnode_endpoint ::= NK_STRING */ case 52: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==52); case 53: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==53); - case 271: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==271); - case 272: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==272); - case 273: /* sma_func_name ::= LAST */ yytestcase(yyruleno==273); - case 274: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==274); - case 352: /* db_name ::= NK_ID */ yytestcase(yyruleno==352); - case 353: /* table_name ::= NK_ID */ yytestcase(yyruleno==353); - case 354: /* column_name ::= NK_ID */ yytestcase(yyruleno==354); - case 355: /* function_name ::= NK_ID */ yytestcase(yyruleno==355); - case 356: /* table_alias ::= NK_ID */ yytestcase(yyruleno==356); - case 357: /* column_alias ::= NK_ID */ yytestcase(yyruleno==357); - case 358: /* user_name ::= NK_ID */ yytestcase(yyruleno==358); - case 359: /* topic_name ::= NK_ID */ yytestcase(yyruleno==359); - case 360: /* stream_name ::= NK_ID */ yytestcase(yyruleno==360); - case 361: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==361); - case 401: /* noarg_func ::= NOW */ yytestcase(yyruleno==401); - case 402: /* noarg_func ::= TODAY */ yytestcase(yyruleno==402); - case 403: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==403); - case 404: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==404); - case 405: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==405); - case 406: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==406); - case 407: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==407); - case 408: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==408); - case 409: /* noarg_func ::= USER */ yytestcase(yyruleno==409); - case 410: /* star_func ::= COUNT */ yytestcase(yyruleno==410); - case 411: /* star_func ::= FIRST */ yytestcase(yyruleno==411); - case 412: /* star_func ::= LAST */ yytestcase(yyruleno==412); - case 413: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==413); -{ yylhsminor.yy815 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy815 = yylhsminor.yy815; + case 273: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==273); + case 274: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==274); + case 275: /* sma_func_name ::= LAST */ yytestcase(yyruleno==275); + case 276: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==276); + case 354: /* db_name ::= NK_ID */ yytestcase(yyruleno==354); + case 355: /* table_name ::= NK_ID */ yytestcase(yyruleno==355); + case 356: /* column_name ::= NK_ID */ yytestcase(yyruleno==356); + case 357: /* function_name ::= NK_ID */ yytestcase(yyruleno==357); + case 358: /* table_alias ::= NK_ID */ yytestcase(yyruleno==358); + case 359: /* column_alias ::= NK_ID */ yytestcase(yyruleno==359); + case 360: /* user_name ::= NK_ID */ yytestcase(yyruleno==360); + case 361: /* topic_name ::= NK_ID */ yytestcase(yyruleno==361); + case 362: /* stream_name ::= NK_ID */ yytestcase(yyruleno==362); + case 363: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==363); + case 364: /* index_name ::= NK_ID */ yytestcase(yyruleno==364); + case 404: /* noarg_func ::= NOW */ yytestcase(yyruleno==404); + case 405: /* noarg_func ::= TODAY */ yytestcase(yyruleno==405); + case 406: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==406); + case 407: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==407); + case 408: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==408); + case 409: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==409); + case 410: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==410); + case 411: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==411); + case 412: /* noarg_func ::= USER */ yytestcase(yyruleno==412); + case 413: /* star_func ::= COUNT */ yytestcase(yyruleno==413); + case 414: /* star_func ::= FIRST */ yytestcase(yyruleno==414); + case 415: /* star_func ::= LAST */ yytestcase(yyruleno==415); + case 416: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==416); +{ yylhsminor.yy179 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy179 = yylhsminor.yy179; break; case 54: /* force_opt ::= */ case 73: /* not_exists_opt ::= */ yytestcase(yyruleno==73); case 75: /* exists_opt ::= */ yytestcase(yyruleno==75); - case 290: /* analyze_opt ::= */ yytestcase(yyruleno==290); - case 297: /* agg_func_opt ::= */ yytestcase(yyruleno==297); - case 474: /* set_quantifier_opt ::= */ yytestcase(yyruleno==474); -{ yymsp[1].minor.yy63 = false; } + case 292: /* analyze_opt ::= */ yytestcase(yyruleno==292); + case 299: /* agg_func_opt ::= */ yytestcase(yyruleno==299); + case 477: /* set_quantifier_opt ::= */ yytestcase(yyruleno==477); +{ yymsp[1].minor.yy767 = false; } break; case 55: /* force_opt ::= FORCE */ - case 291: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==291); - case 298: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==298); - case 475: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==475); -{ yymsp[0].minor.yy63 = true; } + case 293: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==293); + case 300: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==300); + case 478: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==478); +{ yymsp[0].minor.yy767 = true; } break; case 56: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -4467,206 +3875,206 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 66: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy63, &yymsp[-1].minor.yy815, yymsp[0].minor.yy320); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy767, &yymsp[-1].minor.yy179, yymsp[0].minor.yy602); } break; case 67: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy63, &yymsp[0].minor.yy815); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy767, &yymsp[0].minor.yy179); } break; case 68: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy815); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy179); } break; case 69: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy815, yymsp[0].minor.yy320); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy179, yymsp[0].minor.yy602); } break; case 70: /* cmd ::= FLUSH DATABASE db_name */ -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy815); } +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy179); } break; case 71: /* cmd ::= TRIM DATABASE db_name speed_opt */ -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy815, yymsp[0].minor.yy122); } +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy179, yymsp[0].minor.yy820); } break; case 72: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy63 = true; } +{ yymsp[-2].minor.yy767 = true; } break; case 74: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy63 = true; } +{ yymsp[-1].minor.yy767 = true; } break; case 76: /* db_options ::= */ -{ yymsp[1].minor.yy320 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy602 = createDefaultDatabaseOptions(pCxt); } break; case 77: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 78: /* db_options ::= db_options CACHEMODEL NK_STRING */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 79: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 80: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 81: /* db_options ::= db_options DURATION NK_INTEGER */ case 82: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==82); -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 83: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 84: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 85: /* db_options ::= db_options KEEP integer_list */ case 86: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==86); -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_KEEP, yymsp[0].minor.yy570); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_KEEP, yymsp[0].minor.yy874); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 87: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 88: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 89: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 90: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 91: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 92: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 93: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 94: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_RETENTIONS, yymsp[0].minor.yy570); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_RETENTIONS, yymsp[0].minor.yy874); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 95: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 96: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 97: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 98: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 99: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-3].minor.yy320, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-3].minor.yy602, DB_OPTION_WAL_RETENTION_PERIOD, &t); } - yymsp[-3].minor.yy320 = yylhsminor.yy320; + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; case 100: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 101: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-3].minor.yy320, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-3].minor.yy602, DB_OPTION_WAL_RETENTION_SIZE, &t); } - yymsp[-3].minor.yy320 = yylhsminor.yy320; + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; case 102: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 103: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 104: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 105: /* db_options ::= db_options TABLE_PREFIX NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 106: /* db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ -{ yylhsminor.yy320 = setDatabaseOption(pCxt, yymsp[-2].minor.yy320, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 107: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy320 = createAlterDatabaseOptions(pCxt); yylhsminor.yy320 = setAlterDatabaseOption(pCxt, yylhsminor.yy320, &yymsp[0].minor.yy695); } - yymsp[0].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createAlterDatabaseOptions(pCxt); yylhsminor.yy602 = setAlterDatabaseOption(pCxt, yylhsminor.yy602, &yymsp[0].minor.yy845); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; case 108: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy320 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy320, &yymsp[0].minor.yy695); } - yymsp[-1].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy602, &yymsp[0].minor.yy845); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; case 109: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy695.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy695.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 110: /* alter_db_option ::= CACHEMODEL NK_STRING */ -{ yymsp[-1].minor.yy695.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy695.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 111: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -{ yymsp[-1].minor.yy695.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy695.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 112: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy695.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy695.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 113: /* alter_db_option ::= KEEP integer_list */ case 114: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==114); -{ yymsp[-1].minor.yy695.type = DB_OPTION_KEEP; yymsp[-1].minor.yy695.pList = yymsp[0].minor.yy570; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_KEEP; yymsp[-1].minor.yy845.pList = yymsp[0].minor.yy874; } break; case 115: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy695.type = DB_OPTION_PAGES; yymsp[-1].minor.yy695.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_PAGES; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 116: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy695.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy695.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 117: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -{ yymsp[-1].minor.yy695.type = DB_OPTION_WAL; yymsp[-1].minor.yy695.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_WAL; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 118: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ -{ yymsp[-1].minor.yy695.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy695.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 119: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy570 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy570 = yylhsminor.yy570; +{ yylhsminor.yy874 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy874 = yylhsminor.yy874; break; case 120: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 322: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==322); -{ yylhsminor.yy570 = addNodeToList(pCxt, yymsp[-2].minor.yy570, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy570 = yylhsminor.yy570; + case 324: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==324); +{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-2].minor.yy874, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy874 = yylhsminor.yy874; break; case 121: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy570 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy570 = yylhsminor.yy570; +{ yylhsminor.yy874 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy874 = yylhsminor.yy874; break; case 122: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy570 = addNodeToList(pCxt, yymsp[-2].minor.yy570, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy570 = yylhsminor.yy570; +{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-2].minor.yy874, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy874 = yylhsminor.yy874; break; case 123: /* retention_list ::= retention */ case 145: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==145); @@ -4675,289 +4083,289 @@ static YYACTIONTYPE yy_reduce( case 199: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==199); case 204: /* col_name_list ::= col_name */ yytestcase(yyruleno==204); case 255: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==255); - case 267: /* func_list ::= func */ yytestcase(yyruleno==267); - case 350: /* literal_list ::= signed_literal */ yytestcase(yyruleno==350); - case 416: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==416); - case 422: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==422); - case 477: /* select_list ::= select_item */ yytestcase(yyruleno==477); - case 488: /* partition_list ::= partition_item */ yytestcase(yyruleno==488); - case 541: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==541); -{ yylhsminor.yy570 = createNodeList(pCxt, yymsp[0].minor.yy320); } - yymsp[0].minor.yy570 = yylhsminor.yy570; + case 269: /* func_list ::= func */ yytestcase(yyruleno==269); + case 352: /* literal_list ::= signed_literal */ yytestcase(yyruleno==352); + case 419: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==419); + case 425: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==425); + case 480: /* select_list ::= select_item */ yytestcase(yyruleno==480); + case 491: /* partition_list ::= partition_item */ yytestcase(yyruleno==491); + case 544: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==544); +{ yylhsminor.yy874 = createNodeList(pCxt, yymsp[0].minor.yy602); } + yymsp[0].minor.yy874 = yylhsminor.yy874; break; case 124: /* retention_list ::= retention_list NK_COMMA retention */ case 156: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==156); case 200: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==200); case 205: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==205); case 256: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==256); - case 268: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==268); - case 351: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==351); - case 417: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==417); - case 478: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==478); - case 489: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==489); - case 542: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==542); -{ yylhsminor.yy570 = addNodeToList(pCxt, yymsp[-2].minor.yy570, yymsp[0].minor.yy320); } - yymsp[-2].minor.yy570 = yylhsminor.yy570; + case 270: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==270); + case 353: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==353); + case 420: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==420); + case 481: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==481); + case 492: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==492); + case 545: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==545); +{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-2].minor.yy874, yymsp[0].minor.yy602); } + yymsp[-2].minor.yy874 = yylhsminor.yy874; break; case 125: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy320 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 126: /* speed_opt ::= */ - case 299: /* bufsize_opt ::= */ yytestcase(yyruleno==299); -{ yymsp[1].minor.yy122 = 0; } + case 301: /* bufsize_opt ::= */ yytestcase(yyruleno==301); +{ yymsp[1].minor.yy820 = 0; } break; case 127: /* speed_opt ::= MAX_SPEED NK_INTEGER */ - case 300: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==300); -{ yymsp[-1].minor.yy122 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + case 302: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==302); +{ yymsp[-1].minor.yy820 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; case 128: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 130: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==130); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy63, yymsp[-5].minor.yy320, yymsp[-3].minor.yy570, yymsp[-1].minor.yy570, yymsp[0].minor.yy320); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy767, yymsp[-5].minor.yy602, yymsp[-3].minor.yy874, yymsp[-1].minor.yy874, yymsp[0].minor.yy602); } break; case 129: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy570); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy874); } break; case 131: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy570); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy874); } break; case 132: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy63, yymsp[0].minor.yy320); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy767, yymsp[0].minor.yy602); } break; case 133: /* cmd ::= ALTER TABLE alter_table_clause */ - case 324: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==324); -{ pCxt->pRootNode = yymsp[0].minor.yy320; } + case 326: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==326); +{ pCxt->pRootNode = yymsp[0].minor.yy602; } break; case 134: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy320); } +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy602); } break; case 135: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy320 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy320, yymsp[0].minor.yy320); } - yymsp[-1].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy602, yymsp[0].minor.yy602); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; case 136: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy320 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy320, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy815, yymsp[0].minor.yy200); } - yymsp[-4].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy602, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy179, yymsp[0].minor.yy394); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; case 137: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy320 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy320, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy815); } - yymsp[-3].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy602, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy179); } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; case 138: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy320 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy320, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy815, yymsp[0].minor.yy200); } - yymsp[-4].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy602, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy179, yymsp[0].minor.yy394); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; case 139: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy320 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy320, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy815, &yymsp[0].minor.yy815); } - yymsp[-4].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy602, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy179, &yymsp[0].minor.yy179); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; case 140: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy320 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy320, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy815, yymsp[0].minor.yy200); } - yymsp[-4].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy602, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy179, yymsp[0].minor.yy394); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; case 141: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy320 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy320, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy815); } - yymsp[-3].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy602, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy179); } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; case 142: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy320 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy320, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy815, yymsp[0].minor.yy200); } - yymsp[-4].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy602, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy179, yymsp[0].minor.yy394); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; case 143: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy320 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy320, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy815, &yymsp[0].minor.yy815); } - yymsp[-4].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy602, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy179, &yymsp[0].minor.yy179); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; case 144: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy320 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy320, &yymsp[-2].minor.yy815, yymsp[0].minor.yy320); } - yymsp[-5].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy602, &yymsp[-2].minor.yy179, yymsp[0].minor.yy602); } + yymsp[-5].minor.yy602 = yylhsminor.yy602; break; case 146: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 149: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==149); - case 423: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==423); -{ yylhsminor.yy570 = addNodeToList(pCxt, yymsp[-1].minor.yy570, yymsp[0].minor.yy320); } - yymsp[-1].minor.yy570 = yylhsminor.yy570; + case 426: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==426); +{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-1].minor.yy874, yymsp[0].minor.yy602); } + yymsp[-1].minor.yy874 = yylhsminor.yy874; break; case 147: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ -{ yylhsminor.yy320 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy63, yymsp[-8].minor.yy320, yymsp[-6].minor.yy320, yymsp[-5].minor.yy570, yymsp[-2].minor.yy570, yymsp[0].minor.yy320); } - yymsp[-9].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy767, yymsp[-8].minor.yy602, yymsp[-6].minor.yy602, yymsp[-5].minor.yy874, yymsp[-2].minor.yy874, yymsp[0].minor.yy602); } + yymsp[-9].minor.yy602 = yylhsminor.yy602; break; case 150: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy320 = createDropTableClause(pCxt, yymsp[-1].minor.yy63, yymsp[0].minor.yy320); } - yymsp[-1].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createDropTableClause(pCxt, yymsp[-1].minor.yy767, yymsp[0].minor.yy602); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; case 151: /* specific_cols_opt ::= */ case 182: /* tags_def_opt ::= */ yytestcase(yyruleno==182); case 254: /* tag_list_opt ::= */ yytestcase(yyruleno==254); - case 303: /* col_list_opt ::= */ yytestcase(yyruleno==303); - case 486: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==486); - case 509: /* group_by_clause_opt ::= */ yytestcase(yyruleno==509); - case 528: /* order_by_clause_opt ::= */ yytestcase(yyruleno==528); -{ yymsp[1].minor.yy570 = NULL; } + case 305: /* col_list_opt ::= */ yytestcase(yyruleno==305); + case 489: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==489); + case 512: /* group_by_clause_opt ::= */ yytestcase(yyruleno==512); + case 531: /* order_by_clause_opt ::= */ yytestcase(yyruleno==531); +{ yymsp[1].minor.yy874 = NULL; } break; case 152: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ - case 304: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==304); -{ yymsp[-2].minor.yy570 = yymsp[-1].minor.yy570; } + case 306: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==306); +{ yymsp[-2].minor.yy874 = yymsp[-1].minor.yy874; } break; case 153: /* full_table_name ::= table_name */ -{ yylhsminor.yy320 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy815, NULL); } - yymsp[0].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy179, NULL); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; case 154: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy320 = createRealTableNode(pCxt, &yymsp[-2].minor.yy815, &yymsp[0].minor.yy815, NULL); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createRealTableNode(pCxt, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy179, NULL); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 157: /* column_def ::= column_name type_name */ -{ yylhsminor.yy320 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy815, yymsp[0].minor.yy200, NULL); } - yymsp[-1].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy179, yymsp[0].minor.yy394, NULL); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; case 158: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy320 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy815, yymsp[-2].minor.yy200, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy179, yymsp[-2].minor.yy394, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; case 159: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy200 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 160: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy200 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 161: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy200 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 162: /* type_name ::= INT */ case 163: /* type_name ::= INTEGER */ yytestcase(yyruleno==163); -{ yymsp[0].minor.yy200 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_INT); } break; case 164: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy200 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 165: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy200 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 166: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy200 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 167: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy200 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy394 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 168: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy200 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 169: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy200 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy394 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 170: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy200 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy394 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 171: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy200 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy394 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 172: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy200 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy394 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 173: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy200 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy394 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 174: /* type_name ::= JSON */ -{ yymsp[0].minor.yy200 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 175: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy200 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy394 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 176: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy200 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 177: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy200 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 178: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy200 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy394 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 179: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy200 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 180: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy200 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy394 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 181: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy200 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy394 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 183: /* tags_def_opt ::= tags_def */ - case 415: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==415); -{ yylhsminor.yy570 = yymsp[0].minor.yy570; } - yymsp[0].minor.yy570 = yylhsminor.yy570; + case 418: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==418); +{ yylhsminor.yy874 = yymsp[0].minor.yy874; } + yymsp[0].minor.yy874 = yylhsminor.yy874; break; case 184: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy570 = yymsp[-1].minor.yy570; } +{ yymsp[-3].minor.yy874 = yymsp[-1].minor.yy874; } break; case 185: /* table_options ::= */ -{ yymsp[1].minor.yy320 = createDefaultTableOptions(pCxt); } +{ yymsp[1].minor.yy602 = createDefaultTableOptions(pCxt); } break; case 186: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy320 = setTableOption(pCxt, yymsp[-2].minor.yy320, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setTableOption(pCxt, yymsp[-2].minor.yy602, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 187: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy320 = setTableOption(pCxt, yymsp[-2].minor.yy320, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy570); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setTableOption(pCxt, yymsp[-2].minor.yy602, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy874); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 188: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy320 = setTableOption(pCxt, yymsp[-2].minor.yy320, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy570); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setTableOption(pCxt, yymsp[-2].minor.yy602, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy874); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 189: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy320 = setTableOption(pCxt, yymsp[-4].minor.yy320, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy570); } - yymsp[-4].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setTableOption(pCxt, yymsp[-4].minor.yy602, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy874); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; case 190: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy320 = setTableOption(pCxt, yymsp[-2].minor.yy320, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setTableOption(pCxt, yymsp[-2].minor.yy602, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 191: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy320 = setTableOption(pCxt, yymsp[-4].minor.yy320, TABLE_OPTION_SMA, yymsp[-1].minor.yy570); } - yymsp[-4].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setTableOption(pCxt, yymsp[-4].minor.yy602, TABLE_OPTION_SMA, yymsp[-1].minor.yy874); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; case 192: /* table_options ::= table_options DELETE_MARK duration_list */ -{ yylhsminor.yy320 = setTableOption(pCxt, yymsp[-2].minor.yy320, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy570); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setTableOption(pCxt, yymsp[-2].minor.yy602, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy874); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 193: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy320 = createAlterTableOptions(pCxt); yylhsminor.yy320 = setTableOption(pCxt, yylhsminor.yy320, yymsp[0].minor.yy695.type, &yymsp[0].minor.yy695.val); } - yymsp[0].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createAlterTableOptions(pCxt); yylhsminor.yy602 = setTableOption(pCxt, yylhsminor.yy602, yymsp[0].minor.yy845.type, &yymsp[0].minor.yy845.val); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; case 194: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy320 = setTableOption(pCxt, yymsp[-1].minor.yy320, yymsp[0].minor.yy695.type, &yymsp[0].minor.yy695.val); } - yymsp[-1].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setTableOption(pCxt, yymsp[-1].minor.yy602, yymsp[0].minor.yy845.type, &yymsp[0].minor.yy845.val); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; case 195: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy695.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy695.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 196: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy695.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy695.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 197: /* duration_list ::= duration_literal */ - case 379: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==379); -{ yylhsminor.yy570 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy320)); } - yymsp[0].minor.yy570 = yylhsminor.yy570; + case 382: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==382); +{ yylhsminor.yy874 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy602)); } + yymsp[0].minor.yy874 = yylhsminor.yy874; break; case 198: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 380: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==380); -{ yylhsminor.yy570 = addNodeToList(pCxt, yymsp[-2].minor.yy570, releaseRawExprNode(pCxt, yymsp[0].minor.yy320)); } - yymsp[-2].minor.yy570 = yylhsminor.yy570; + case 383: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==383); +{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-2].minor.yy874, releaseRawExprNode(pCxt, yymsp[0].minor.yy602)); } + yymsp[-2].minor.yy874 = yylhsminor.yy874; break; case 201: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy320 = createFunctionNode(pCxt, &yymsp[0].minor.yy815, NULL); } - yymsp[0].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createFunctionNode(pCxt, &yymsp[0].minor.yy179, NULL); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; case 202: /* rollup_func_name ::= FIRST */ case 203: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==203); case 258: /* tag_item ::= QTAGS */ yytestcase(yyruleno==258); -{ yylhsminor.yy320 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; case 206: /* col_name ::= column_name */ case 259: /* tag_item ::= column_name */ yytestcase(yyruleno==259); -{ yylhsminor.yy320 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy815); } - yymsp[0].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy179); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; case 207: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } @@ -4972,13 +4380,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } break; case 211: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy320, yymsp[0].minor.yy320, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy602, yymsp[0].minor.yy602, OP_TYPE_LIKE); } break; case 212: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy320, yymsp[0].minor.yy320, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy602, yymsp[0].minor.yy602, OP_TYPE_LIKE); } break; case 213: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy320, NULL, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy602, NULL, OP_TYPE_LIKE); } break; case 214: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } @@ -4990,7 +4398,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; case 217: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy320, yymsp[-1].minor.yy320, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy602, yymsp[-1].minor.yy602, OP_TYPE_EQUAL); } break; case 218: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } @@ -5009,13 +4417,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } break; case 224: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy815); } +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy179); } break; case 225: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy320); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy602); } break; case 226: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy320); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy602); } break; case 227: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } @@ -5034,7 +4442,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } break; case 233: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy320); } +{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy602); } break; case 234: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } @@ -5049,7 +4457,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; case 238: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy320); } +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy602); } break; case 239: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } @@ -5058,10 +4466,10 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; case 241: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy320, yymsp[-1].minor.yy320, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy602, yymsp[-1].minor.yy602, OP_TYPE_EQUAL); } break; case 242: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy320, yymsp[0].minor.yy320, yymsp[-3].minor.yy570); } +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy602, yymsp[0].minor.yy602, yymsp[-3].minor.yy874); } break; case 243: /* cmd ::= SHOW VNODES NK_INTEGER */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } @@ -5070,755 +4478,763 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, createValueNode(pCxt, TSDB_DATA_TYPE_VARCHAR, &yymsp[0].minor.yy0)); } break; case 245: /* cmd ::= SHOW db_name_cond_opt ALIVE */ -{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy320, QUERY_NODE_SHOW_DB_ALIVE_STMT); } +{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy602, QUERY_NODE_SHOW_DB_ALIVE_STMT); } break; case 246: /* cmd ::= SHOW CLUSTER ALIVE */ { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } break; case 247: /* db_name_cond_opt ::= */ case 252: /* from_db_opt ::= */ yytestcase(yyruleno==252); -{ yymsp[1].minor.yy320 = createDefaultDatabaseCondValue(pCxt); } +{ yymsp[1].minor.yy602 = createDefaultDatabaseCondValue(pCxt); } break; case 248: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy320 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy815); } - yymsp[-1].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy179); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; case 249: /* like_pattern_opt ::= */ - case 312: /* subtable_opt ::= */ yytestcase(yyruleno==312); - case 425: /* case_when_else_opt ::= */ yytestcase(yyruleno==425); - case 455: /* from_clause_opt ::= */ yytestcase(yyruleno==455); - case 484: /* where_clause_opt ::= */ yytestcase(yyruleno==484); - case 493: /* twindow_clause_opt ::= */ yytestcase(yyruleno==493); - case 499: /* sliding_opt ::= */ yytestcase(yyruleno==499); - case 501: /* fill_opt ::= */ yytestcase(yyruleno==501); - case 513: /* having_clause_opt ::= */ yytestcase(yyruleno==513); - case 515: /* range_opt ::= */ yytestcase(yyruleno==515); - case 517: /* every_opt ::= */ yytestcase(yyruleno==517); - case 530: /* slimit_clause_opt ::= */ yytestcase(yyruleno==530); - case 534: /* limit_clause_opt ::= */ yytestcase(yyruleno==534); -{ yymsp[1].minor.yy320 = NULL; } + case 314: /* subtable_opt ::= */ yytestcase(yyruleno==314); + case 428: /* case_when_else_opt ::= */ yytestcase(yyruleno==428); + case 458: /* from_clause_opt ::= */ yytestcase(yyruleno==458); + case 487: /* where_clause_opt ::= */ yytestcase(yyruleno==487); + case 496: /* twindow_clause_opt ::= */ yytestcase(yyruleno==496); + case 502: /* sliding_opt ::= */ yytestcase(yyruleno==502); + case 504: /* fill_opt ::= */ yytestcase(yyruleno==504); + case 516: /* having_clause_opt ::= */ yytestcase(yyruleno==516); + case 518: /* range_opt ::= */ yytestcase(yyruleno==518); + case 520: /* every_opt ::= */ yytestcase(yyruleno==520); + case 533: /* slimit_clause_opt ::= */ yytestcase(yyruleno==533); + case 537: /* limit_clause_opt ::= */ yytestcase(yyruleno==537); +{ yymsp[1].minor.yy602 = NULL; } break; case 250: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy320 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; case 251: /* table_name_cond ::= table_name */ -{ yylhsminor.yy320 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy815); } - yymsp[0].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy179); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; case 253: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy320 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy815); } +{ yymsp[-1].minor.yy602 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy179); } break; case 257: /* tag_item ::= TBNAME */ -{ yylhsminor.yy320 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } - yymsp[0].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; case 260: /* tag_item ::= column_name column_alias */ -{ yylhsminor.yy320 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy815), &yymsp[0].minor.yy815); } - yymsp[-1].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy179), &yymsp[0].minor.yy179); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; case 261: /* tag_item ::= column_name AS column_alias */ -{ yylhsminor.yy320 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy815), &yymsp[0].minor.yy815); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; +{ yylhsminor.yy602 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy179), &yymsp[0].minor.yy179); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 262: /* cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy63, yymsp[-3].minor.yy320, yymsp[-1].minor.yy320, NULL, yymsp[0].minor.yy320); } + case 262: /* cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy767, yymsp[-3].minor.yy602, yymsp[-1].minor.yy602, NULL, yymsp[0].minor.yy602); } break; - case 263: /* cmd ::= CREATE INDEX not_exists_opt full_table_name ON full_table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy63, yymsp[-5].minor.yy320, yymsp[-3].minor.yy320, yymsp[-1].minor.yy570, NULL); } + case 263: /* cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy767, yymsp[-5].minor.yy602, yymsp[-3].minor.yy602, yymsp[-1].minor.yy874, NULL); } break; - case 264: /* cmd ::= DROP INDEX exists_opt full_table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy63, yymsp[0].minor.yy320); } + case 264: /* cmd ::= DROP INDEX exists_opt full_index_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy767, yymsp[0].minor.yy602); } break; - case 265: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy320 = createIndexOption(pCxt, yymsp[-7].minor.yy570, releaseRawExprNode(pCxt, yymsp[-3].minor.yy320), NULL, yymsp[-1].minor.yy320, yymsp[0].minor.yy320); } + case 265: /* full_index_name ::= index_name */ +{ yylhsminor.yy602 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy179); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 266: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-11].minor.yy320 = createIndexOption(pCxt, yymsp[-9].minor.yy570, releaseRawExprNode(pCxt, yymsp[-5].minor.yy320), releaseRawExprNode(pCxt, yymsp[-3].minor.yy320), yymsp[-1].minor.yy320, yymsp[0].minor.yy320); } + case 266: /* full_index_name ::= db_name NK_DOT index_name */ +{ yylhsminor.yy602 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy179); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 269: /* func ::= sma_func_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy320 = createFunctionNode(pCxt, &yymsp[-3].minor.yy815, yymsp[-1].minor.yy570); } - yymsp[-3].minor.yy320 = yylhsminor.yy320; + case 267: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-9].minor.yy602 = createIndexOption(pCxt, yymsp[-7].minor.yy874, releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), NULL, yymsp[-1].minor.yy602, yymsp[0].minor.yy602); } break; - case 275: /* sma_stream_opt ::= */ - case 305: /* stream_options ::= */ yytestcase(yyruleno==305); -{ yymsp[1].minor.yy320 = createStreamOptions(pCxt); } + case 268: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-11].minor.yy602 = createIndexOption(pCxt, yymsp[-9].minor.yy874, releaseRawExprNode(pCxt, yymsp[-5].minor.yy602), releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), yymsp[-1].minor.yy602, yymsp[0].minor.yy602); } break; - case 276: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - case 309: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==309); -{ ((SStreamOptions*)yymsp[-2].minor.yy320)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy320); yylhsminor.yy320 = yymsp[-2].minor.yy320; } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 271: /* func ::= sma_func_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy602 = createFunctionNode(pCxt, &yymsp[-3].minor.yy179, yymsp[-1].minor.yy874); } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; - case 277: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy320)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy320); yylhsminor.yy320 = yymsp[-2].minor.yy320; } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 277: /* sma_stream_opt ::= */ + case 307: /* stream_options ::= */ yytestcase(yyruleno==307); +{ yymsp[1].minor.yy602 = createStreamOptions(pCxt); } break; - case 278: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy320)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy320); yylhsminor.yy320 = yymsp[-2].minor.yy320; } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 278: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + case 311: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==311); +{ ((SStreamOptions*)yymsp[-2].minor.yy602)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy602); yylhsminor.yy602 = yymsp[-2].minor.yy602; } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 279: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy63, &yymsp[-2].minor.yy815, yymsp[0].minor.yy320); } + case 279: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy602)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy602); yylhsminor.yy602 = yymsp[-2].minor.yy602; } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 280: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy63, &yymsp[-3].minor.yy815, &yymsp[0].minor.yy815, false); } + case 280: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy602)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy602); yylhsminor.yy602 = yymsp[-2].minor.yy602; } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 281: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy63, &yymsp[-5].minor.yy815, &yymsp[0].minor.yy815, true); } + case 281: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy767, &yymsp[-2].minor.yy179, yymsp[0].minor.yy602); } break; - case 282: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy63, &yymsp[-3].minor.yy815, yymsp[0].minor.yy320, false); } + case 282: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy767, &yymsp[-3].minor.yy179, &yymsp[0].minor.yy179, false); } break; - case 283: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy63, &yymsp[-5].minor.yy815, yymsp[0].minor.yy320, true); } + case 283: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy767, &yymsp[-5].minor.yy179, &yymsp[0].minor.yy179, true); } break; - case 284: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy63, &yymsp[0].minor.yy815); } + case 284: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy767, &yymsp[-3].minor.yy179, yymsp[0].minor.yy602, false); } break; - case 285: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy63, &yymsp[-2].minor.yy815, &yymsp[0].minor.yy815); } + case 285: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy767, &yymsp[-5].minor.yy179, yymsp[0].minor.yy602, true); } break; - case 286: /* cmd ::= DESC full_table_name */ - case 287: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==287); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy320); } + case 286: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy767, &yymsp[0].minor.yy179); } break; - case 288: /* cmd ::= RESET QUERY CACHE */ + case 287: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy767, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy179); } + break; + case 288: /* cmd ::= DESC full_table_name */ + case 289: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==289); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy602); } + break; + case 290: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 289: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy63, yymsp[-1].minor.yy320, yymsp[0].minor.yy320); } + case 291: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy767, yymsp[-1].minor.yy602, yymsp[0].minor.yy602); } break; - case 292: /* explain_options ::= */ -{ yymsp[1].minor.yy320 = createDefaultExplainOptions(pCxt); } + case 294: /* explain_options ::= */ +{ yymsp[1].minor.yy602 = createDefaultExplainOptions(pCxt); } break; - case 293: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy320 = setExplainVerbose(pCxt, yymsp[-2].minor.yy320, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 295: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy602 = setExplainVerbose(pCxt, yymsp[-2].minor.yy602, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 294: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy320 = setExplainRatio(pCxt, yymsp[-2].minor.yy320, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 296: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy602 = setExplainRatio(pCxt, yymsp[-2].minor.yy602, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 295: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy63, yymsp[-8].minor.yy63, &yymsp[-5].minor.yy815, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy200, yymsp[0].minor.yy122); } + case 297: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy767, yymsp[-8].minor.yy767, &yymsp[-5].minor.yy179, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy820); } break; - case 296: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy63, &yymsp[0].minor.yy815); } + case 298: /* cmd ::= DROP FUNCTION exists_opt function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy767, &yymsp[0].minor.yy179); } break; - case 301: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tags_def_opt subtable_opt AS query_or_subquery */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy63, &yymsp[-8].minor.yy815, yymsp[-5].minor.yy320, yymsp[-7].minor.yy320, yymsp[-3].minor.yy570, yymsp[-2].minor.yy320, yymsp[0].minor.yy320, yymsp[-4].minor.yy570); } + case 303: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tags_def_opt subtable_opt AS query_or_subquery */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy767, &yymsp[-8].minor.yy179, yymsp[-5].minor.yy602, yymsp[-7].minor.yy602, yymsp[-3].minor.yy874, yymsp[-2].minor.yy602, yymsp[0].minor.yy602, yymsp[-4].minor.yy874); } break; - case 302: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy63, &yymsp[0].minor.yy815); } + case 304: /* cmd ::= DROP STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy767, &yymsp[0].minor.yy179); } break; - case 306: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy320)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy320 = yymsp[-2].minor.yy320; } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 308: /* stream_options ::= stream_options TRIGGER AT_ONCE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy602)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy602 = yymsp[-2].minor.yy602; } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 307: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy320)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy320 = yymsp[-2].minor.yy320; } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 309: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy602)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy602 = yymsp[-2].minor.yy602; } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 308: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-3].minor.yy320)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy320)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy320); yylhsminor.yy320 = yymsp[-3].minor.yy320; } - yymsp[-3].minor.yy320 = yylhsminor.yy320; + case 310: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-3].minor.yy602)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy602)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy602); yylhsminor.yy602 = yymsp[-3].minor.yy602; } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; - case 310: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -{ ((SStreamOptions*)yymsp[-3].minor.yy320)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy320 = yymsp[-3].minor.yy320; } - yymsp[-3].minor.yy320 = yylhsminor.yy320; + case 312: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ +{ ((SStreamOptions*)yymsp[-3].minor.yy602)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy602 = yymsp[-3].minor.yy602; } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; - case 311: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ -{ ((SStreamOptions*)yymsp[-2].minor.yy320)->fillHistory = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy320 = yymsp[-2].minor.yy320; } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 313: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ +{ ((SStreamOptions*)yymsp[-2].minor.yy602)->fillHistory = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy602 = yymsp[-2].minor.yy602; } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 313: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 500: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==500); - case 518: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==518); -{ yymsp[-3].minor.yy320 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy320); } + case 315: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 503: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==503); + case 521: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==521); +{ yymsp[-3].minor.yy602 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy602); } break; - case 314: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 316: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 315: /* cmd ::= KILL QUERY NK_STRING */ + case 317: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 316: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 318: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 317: /* cmd ::= BALANCE VGROUP */ + case 319: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 318: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 320: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 319: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy570); } + case 321: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy874); } break; - case 320: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 322: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 321: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy570 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 323: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy874 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 323: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy320, yymsp[0].minor.yy320); } + case 325: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy602, yymsp[0].minor.yy602); } break; - case 325: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy320, yymsp[-2].minor.yy570, yymsp[0].minor.yy320); } + case 327: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy602, yymsp[-2].minor.yy874, yymsp[0].minor.yy602); } break; - case 326: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy320, NULL, yymsp[0].minor.yy320); } + case 328: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy602, NULL, yymsp[0].minor.yy602); } break; - case 327: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy320 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 329: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 328: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy320 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 330: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 329: /* literal ::= NK_STRING */ -{ yylhsminor.yy320 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 331: /* literal ::= NK_STRING */ +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 330: /* literal ::= NK_BOOL */ -{ yylhsminor.yy320 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 332: /* literal ::= NK_BOOL */ +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 331: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy320 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy320 = yylhsminor.yy320; + case 333: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 332: /* literal ::= duration_literal */ - case 342: /* signed_literal ::= signed */ yytestcase(yyruleno==342); - case 362: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==362); - case 363: /* expression ::= literal */ yytestcase(yyruleno==363); - case 364: /* expression ::= pseudo_column */ yytestcase(yyruleno==364); - case 365: /* expression ::= column_reference */ yytestcase(yyruleno==365); - case 366: /* expression ::= function_expression */ yytestcase(yyruleno==366); - case 367: /* expression ::= case_when_expression */ yytestcase(yyruleno==367); - case 398: /* function_expression ::= literal_func */ yytestcase(yyruleno==398); - case 447: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==447); - case 451: /* boolean_primary ::= predicate */ yytestcase(yyruleno==451); - case 453: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==453); - case 454: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==454); - case 457: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==457); - case 459: /* table_reference ::= table_primary */ yytestcase(yyruleno==459); - case 460: /* table_reference ::= joined_table */ yytestcase(yyruleno==460); - case 464: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==464); - case 520: /* query_simple ::= query_specification */ yytestcase(yyruleno==520); - case 521: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==521); - case 524: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==524); - case 526: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==526); -{ yylhsminor.yy320 = yymsp[0].minor.yy320; } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 334: /* literal ::= duration_literal */ + case 344: /* signed_literal ::= signed */ yytestcase(yyruleno==344); + case 365: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==365); + case 366: /* expression ::= literal */ yytestcase(yyruleno==366); + case 367: /* expression ::= pseudo_column */ yytestcase(yyruleno==367); + case 368: /* expression ::= column_reference */ yytestcase(yyruleno==368); + case 369: /* expression ::= function_expression */ yytestcase(yyruleno==369); + case 370: /* expression ::= case_when_expression */ yytestcase(yyruleno==370); + case 401: /* function_expression ::= literal_func */ yytestcase(yyruleno==401); + case 450: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==450); + case 454: /* boolean_primary ::= predicate */ yytestcase(yyruleno==454); + case 456: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==456); + case 457: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==457); + case 460: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==460); + case 462: /* table_reference ::= table_primary */ yytestcase(yyruleno==462); + case 463: /* table_reference ::= joined_table */ yytestcase(yyruleno==463); + case 467: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==467); + case 523: /* query_simple ::= query_specification */ yytestcase(yyruleno==523); + case 524: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==524); + case 527: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==527); + case 529: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==529); +{ yylhsminor.yy602 = yymsp[0].minor.yy602; } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 333: /* literal ::= NULL */ -{ yylhsminor.yy320 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 335: /* literal ::= NULL */ +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 334: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy320 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 336: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 335: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy320 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 337: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 336: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy320 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 338: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 337: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy320 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + case 339: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } break; - case 338: /* signed ::= NK_MINUS NK_INTEGER */ + case 340: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy320 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy320 = yylhsminor.yy320; + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 339: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy320 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 341: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 340: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy320 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 342: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 341: /* signed ::= NK_MINUS NK_FLOAT */ + case 343: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy320 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy320 = yylhsminor.yy320; + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 343: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy320 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 345: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 344: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy320 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 346: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 345: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy320 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 347: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 346: /* signed_literal ::= duration_literal */ - case 348: /* signed_literal ::= literal_func */ yytestcase(yyruleno==348); - case 418: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==418); - case 480: /* select_item ::= common_expression */ yytestcase(yyruleno==480); - case 490: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==490); - case 525: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==525); - case 527: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==527); - case 540: /* search_condition ::= common_expression */ yytestcase(yyruleno==540); -{ yylhsminor.yy320 = releaseRawExprNode(pCxt, yymsp[0].minor.yy320); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 348: /* signed_literal ::= duration_literal */ + case 350: /* signed_literal ::= literal_func */ yytestcase(yyruleno==350); + case 421: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==421); + case 483: /* select_item ::= common_expression */ yytestcase(yyruleno==483); + case 493: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==493); + case 528: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==528); + case 530: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==530); + case 543: /* search_condition ::= common_expression */ yytestcase(yyruleno==543); +{ yylhsminor.yy602 = releaseRawExprNode(pCxt, yymsp[0].minor.yy602); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 347: /* signed_literal ::= NULL */ -{ yylhsminor.yy320 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 349: /* signed_literal ::= NULL */ +{ yylhsminor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 349: /* signed_literal ::= NK_QUESTION */ -{ yylhsminor.yy320 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 351: /* signed_literal ::= NK_QUESTION */ +{ yylhsminor.yy602 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 368: /* expression ::= NK_LP expression NK_RP */ - case 452: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==452); - case 539: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==539); -{ yylhsminor.yy320 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy320)); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 371: /* expression ::= NK_LP expression NK_RP */ + case 455: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==455); + case 542: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==542); +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy602)); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 369: /* expression ::= NK_PLUS expr_or_subquery */ + case 372: /* expression ::= NK_PLUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy320)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy602)); } - yymsp[-1].minor.yy320 = yylhsminor.yy320; + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 370: /* expression ::= NK_MINUS expr_or_subquery */ + case 373: /* expression ::= NK_MINUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy320), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy602), NULL)); } - yymsp[-1].minor.yy320 = yylhsminor.yy320; + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 371: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + case 374: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy320); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), releaseRawExprNode(pCxt, yymsp[0].minor.yy320))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 372: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + case 375: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy320); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), releaseRawExprNode(pCxt, yymsp[0].minor.yy320))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 373: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + case 376: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy320); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), releaseRawExprNode(pCxt, yymsp[0].minor.yy320))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 374: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + case 377: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy320); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), releaseRawExprNode(pCxt, yymsp[0].minor.yy320))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 375: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ + case 378: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy320); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), releaseRawExprNode(pCxt, yymsp[0].minor.yy320))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 376: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 379: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 377: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + case 380: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy320); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), releaseRawExprNode(pCxt, yymsp[0].minor.yy320))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 378: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + case 381: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy320); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), releaseRawExprNode(pCxt, yymsp[0].minor.yy320))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 381: /* column_reference ::= column_name */ -{ yylhsminor.yy320 = createRawExprNode(pCxt, &yymsp[0].minor.yy815, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy815)); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 384: /* column_reference ::= column_name */ +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy179, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy179)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 382: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy320 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy815, &yymsp[0].minor.yy815, createColumnNode(pCxt, &yymsp[-2].minor.yy815, &yymsp[0].minor.yy815)); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 385: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy179, createColumnNode(pCxt, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy179)); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 383: /* pseudo_column ::= ROWTS */ - case 384: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==384); - case 386: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==386); - case 387: /* pseudo_column ::= QEND */ yytestcase(yyruleno==387); - case 388: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==388); - case 389: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==389); - case 390: /* pseudo_column ::= WEND */ yytestcase(yyruleno==390); - case 391: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==391); - case 392: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==392); - case 393: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==393); - case 394: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==394); - case 400: /* literal_func ::= NOW */ yytestcase(yyruleno==400); -{ yylhsminor.yy320 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 386: /* pseudo_column ::= ROWTS */ + case 387: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==387); + case 389: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==389); + case 390: /* pseudo_column ::= QEND */ yytestcase(yyruleno==390); + case 391: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==391); + case 392: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==392); + case 393: /* pseudo_column ::= WEND */ yytestcase(yyruleno==393); + case 394: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==394); + case 395: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==395); + case 396: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==396); + case 397: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==397); + case 403: /* literal_func ::= NOW */ yytestcase(yyruleno==403); +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 385: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy320 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy815, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy815)))); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 388: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy179)))); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 395: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 396: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==396); -{ yylhsminor.yy320 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy815, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy815, yymsp[-1].minor.yy570)); } - yymsp[-3].minor.yy320 = yylhsminor.yy320; + case 398: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 399: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==399); +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy179, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy179, yymsp[-1].minor.yy874)); } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; - case 397: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ -{ yylhsminor.yy320 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy320), yymsp[-1].minor.yy200)); } - yymsp[-5].minor.yy320 = yylhsminor.yy320; + case 400: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), yymsp[-1].minor.yy394)); } + yymsp[-5].minor.yy602 = yylhsminor.yy602; break; - case 399: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy320 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy815, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy815, NULL)); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 402: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy179, NULL)); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 414: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy570 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy570 = yylhsminor.yy570; + case 417: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy874 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy874 = yylhsminor.yy874; break; - case 419: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 483: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==483); -{ yylhsminor.yy320 = createColumnNode(pCxt, &yymsp[-2].minor.yy815, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 422: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 486: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==486); +{ yylhsminor.yy602 = createColumnNode(pCxt, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 420: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -{ yylhsminor.yy320 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy570, yymsp[-1].minor.yy320)); } - yymsp[-3].minor.yy320 = yylhsminor.yy320; + case 423: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy874, yymsp[-1].minor.yy602)); } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; - case 421: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -{ yylhsminor.yy320 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy320), yymsp[-2].minor.yy570, yymsp[-1].minor.yy320)); } - yymsp[-4].minor.yy320 = yylhsminor.yy320; + case 424: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), yymsp[-2].minor.yy874, yymsp[-1].minor.yy602)); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; - case 424: /* when_then_expr ::= WHEN common_expression THEN common_expression */ -{ yymsp[-3].minor.yy320 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), releaseRawExprNode(pCxt, yymsp[0].minor.yy320)); } + case 427: /* when_then_expr ::= WHEN common_expression THEN common_expression */ +{ yymsp[-3].minor.yy602 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602)); } break; - case 426: /* case_when_else_opt ::= ELSE common_expression */ -{ yymsp[-1].minor.yy320 = releaseRawExprNode(pCxt, yymsp[0].minor.yy320); } + case 429: /* case_when_else_opt ::= ELSE common_expression */ +{ yymsp[-1].minor.yy602 = releaseRawExprNode(pCxt, yymsp[0].minor.yy602); } break; - case 427: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 432: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==432); + case 430: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 435: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==435); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy320); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy828, releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), releaseRawExprNode(pCxt, yymsp[0].minor.yy320))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy290, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 428: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + case 431: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy320); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy320), releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), releaseRawExprNode(pCxt, yymsp[0].minor.yy320))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy602), releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-4].minor.yy320 = yylhsminor.yy320; + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; - case 429: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + case 432: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy320); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy320), releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), releaseRawExprNode(pCxt, yymsp[0].minor.yy320))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy602), releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-5].minor.yy320 = yylhsminor.yy320; + yymsp[-5].minor.yy602 = yylhsminor.yy602; break; - case 430: /* predicate ::= expr_or_subquery IS NULL */ + case 433: /* predicate ::= expr_or_subquery IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), NULL)); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 431: /* predicate ::= expr_or_subquery IS NOT NULL */ + case 434: /* predicate ::= expr_or_subquery IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy320), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), NULL)); } - yymsp[-3].minor.yy320 = yylhsminor.yy320; + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; - case 433: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy828 = OP_TYPE_LOWER_THAN; } + case 436: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy290 = OP_TYPE_LOWER_THAN; } break; - case 434: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy828 = OP_TYPE_GREATER_THAN; } + case 437: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy290 = OP_TYPE_GREATER_THAN; } break; - case 435: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy828 = OP_TYPE_LOWER_EQUAL; } + case 438: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy290 = OP_TYPE_LOWER_EQUAL; } break; - case 436: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy828 = OP_TYPE_GREATER_EQUAL; } + case 439: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy290 = OP_TYPE_GREATER_EQUAL; } break; - case 437: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy828 = OP_TYPE_NOT_EQUAL; } + case 440: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy290 = OP_TYPE_NOT_EQUAL; } break; - case 438: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy828 = OP_TYPE_EQUAL; } + case 441: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy290 = OP_TYPE_EQUAL; } break; - case 439: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy828 = OP_TYPE_LIKE; } + case 442: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy290 = OP_TYPE_LIKE; } break; - case 440: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy828 = OP_TYPE_NOT_LIKE; } + case 443: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy290 = OP_TYPE_NOT_LIKE; } break; - case 441: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy828 = OP_TYPE_MATCH; } + case 444: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy290 = OP_TYPE_MATCH; } break; - case 442: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy828 = OP_TYPE_NMATCH; } + case 445: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy290 = OP_TYPE_NMATCH; } break; - case 443: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy828 = OP_TYPE_JSON_CONTAINS; } + case 446: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy290 = OP_TYPE_JSON_CONTAINS; } break; - case 444: /* in_op ::= IN */ -{ yymsp[0].minor.yy828 = OP_TYPE_IN; } + case 447: /* in_op ::= IN */ +{ yymsp[0].minor.yy290 = OP_TYPE_IN; } break; - case 445: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy828 = OP_TYPE_NOT_IN; } + case 448: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy290 = OP_TYPE_NOT_IN; } break; - case 446: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -{ yylhsminor.yy320 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy570)); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 449: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy874)); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 448: /* boolean_value_expression ::= NOT boolean_primary */ + case 451: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy320), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy602), NULL)); } - yymsp[-1].minor.yy320 = yylhsminor.yy320; + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 449: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 452: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy320); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), releaseRawExprNode(pCxt, yymsp[0].minor.yy320))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 450: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 453: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy320); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy320); - yylhsminor.yy320 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), releaseRawExprNode(pCxt, yymsp[0].minor.yy320))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 456: /* from_clause_opt ::= FROM table_reference_list */ - case 485: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==485); - case 514: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==514); -{ yymsp[-1].minor.yy320 = yymsp[0].minor.yy320; } + case 459: /* from_clause_opt ::= FROM table_reference_list */ + case 488: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==488); + case 517: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==517); +{ yymsp[-1].minor.yy602 = yymsp[0].minor.yy602; } break; - case 458: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy320 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy320, yymsp[0].minor.yy320, NULL); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 461: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy602 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy602, yymsp[0].minor.yy602, NULL); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 461: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy320 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy815, &yymsp[0].minor.yy815); } - yymsp[-1].minor.yy320 = yylhsminor.yy320; + case 464: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy602 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy179, &yymsp[0].minor.yy179); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 462: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy320 = createRealTableNode(pCxt, &yymsp[-3].minor.yy815, &yymsp[-1].minor.yy815, &yymsp[0].minor.yy815); } - yymsp[-3].minor.yy320 = yylhsminor.yy320; + case 465: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy602 = createRealTableNode(pCxt, &yymsp[-3].minor.yy179, &yymsp[-1].minor.yy179, &yymsp[0].minor.yy179); } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; - case 463: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy320 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy320), &yymsp[0].minor.yy815); } - yymsp[-1].minor.yy320 = yylhsminor.yy320; + case 466: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy602 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy602), &yymsp[0].minor.yy179); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 465: /* alias_opt ::= */ -{ yymsp[1].minor.yy815 = nil_token; } + case 468: /* alias_opt ::= */ +{ yymsp[1].minor.yy179 = nil_token; } break; - case 467: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy815 = yymsp[0].minor.yy815; } + case 470: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy179 = yymsp[0].minor.yy179; } break; - case 468: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 469: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==469); -{ yymsp[-2].minor.yy320 = yymsp[-1].minor.yy320; } + case 471: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 472: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==472); +{ yymsp[-2].minor.yy602 = yymsp[-1].minor.yy602; } break; - case 470: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy320 = createJoinTableNode(pCxt, yymsp[-4].minor.yy334, yymsp[-5].minor.yy320, yymsp[-2].minor.yy320, yymsp[0].minor.yy320); } - yymsp[-5].minor.yy320 = yylhsminor.yy320; + case 473: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy602 = createJoinTableNode(pCxt, yymsp[-4].minor.yy42, yymsp[-5].minor.yy602, yymsp[-2].minor.yy602, yymsp[0].minor.yy602); } + yymsp[-5].minor.yy602 = yylhsminor.yy602; break; - case 471: /* join_type ::= */ -{ yymsp[1].minor.yy334 = JOIN_TYPE_INNER; } + case 474: /* join_type ::= */ +{ yymsp[1].minor.yy42 = JOIN_TYPE_INNER; } break; - case 472: /* join_type ::= INNER */ -{ yymsp[0].minor.yy334 = JOIN_TYPE_INNER; } + case 475: /* join_type ::= INNER */ +{ yymsp[0].minor.yy42 = JOIN_TYPE_INNER; } break; - case 473: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 476: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-11].minor.yy320 = createSelectStmt(pCxt, yymsp[-10].minor.yy63, yymsp[-9].minor.yy570, yymsp[-8].minor.yy320); - yymsp[-11].minor.yy320 = addWhereClause(pCxt, yymsp[-11].minor.yy320, yymsp[-7].minor.yy320); - yymsp[-11].minor.yy320 = addPartitionByClause(pCxt, yymsp[-11].minor.yy320, yymsp[-6].minor.yy570); - yymsp[-11].minor.yy320 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy320, yymsp[-2].minor.yy320); - yymsp[-11].minor.yy320 = addGroupByClause(pCxt, yymsp[-11].minor.yy320, yymsp[-1].minor.yy570); - yymsp[-11].minor.yy320 = addHavingClause(pCxt, yymsp[-11].minor.yy320, yymsp[0].minor.yy320); - yymsp[-11].minor.yy320 = addRangeClause(pCxt, yymsp[-11].minor.yy320, yymsp[-5].minor.yy320); - yymsp[-11].minor.yy320 = addEveryClause(pCxt, yymsp[-11].minor.yy320, yymsp[-4].minor.yy320); - yymsp[-11].minor.yy320 = addFillClause(pCxt, yymsp[-11].minor.yy320, yymsp[-3].minor.yy320); + yymsp[-11].minor.yy602 = createSelectStmt(pCxt, yymsp[-10].minor.yy767, yymsp[-9].minor.yy874, yymsp[-8].minor.yy602); + yymsp[-11].minor.yy602 = addWhereClause(pCxt, yymsp[-11].minor.yy602, yymsp[-7].minor.yy602); + yymsp[-11].minor.yy602 = addPartitionByClause(pCxt, yymsp[-11].minor.yy602, yymsp[-6].minor.yy874); + yymsp[-11].minor.yy602 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy602, yymsp[-2].minor.yy602); + yymsp[-11].minor.yy602 = addGroupByClause(pCxt, yymsp[-11].minor.yy602, yymsp[-1].minor.yy874); + yymsp[-11].minor.yy602 = addHavingClause(pCxt, yymsp[-11].minor.yy602, yymsp[0].minor.yy602); + yymsp[-11].minor.yy602 = addRangeClause(pCxt, yymsp[-11].minor.yy602, yymsp[-5].minor.yy602); + yymsp[-11].minor.yy602 = addEveryClause(pCxt, yymsp[-11].minor.yy602, yymsp[-4].minor.yy602); + yymsp[-11].minor.yy602 = addFillClause(pCxt, yymsp[-11].minor.yy602, yymsp[-3].minor.yy602); } break; - case 476: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy63 = false; } + case 479: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy767 = false; } break; - case 479: /* select_item ::= NK_STAR */ -{ yylhsminor.yy320 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy320 = yylhsminor.yy320; + case 482: /* select_item ::= NK_STAR */ +{ yylhsminor.yy602 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 481: /* select_item ::= common_expression column_alias */ - case 491: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==491); -{ yylhsminor.yy320 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy320), &yymsp[0].minor.yy815); } - yymsp[-1].minor.yy320 = yylhsminor.yy320; + case 484: /* select_item ::= common_expression column_alias */ + case 494: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==494); +{ yylhsminor.yy602 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy602), &yymsp[0].minor.yy179); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 482: /* select_item ::= common_expression AS column_alias */ - case 492: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==492); -{ yylhsminor.yy320 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), &yymsp[0].minor.yy815); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 485: /* select_item ::= common_expression AS column_alias */ + case 495: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==495); +{ yylhsminor.yy602 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), &yymsp[0].minor.yy179); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 487: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 510: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==510); - case 529: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==529); -{ yymsp[-2].minor.yy570 = yymsp[0].minor.yy570; } + case 490: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 513: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==513); + case 532: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==532); +{ yymsp[-2].minor.yy874 = yymsp[0].minor.yy874; } break; - case 494: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy320 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy320), releaseRawExprNode(pCxt, yymsp[-1].minor.yy320)); } + case 497: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy602 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), releaseRawExprNode(pCxt, yymsp[-1].minor.yy602)); } break; - case 495: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy320 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy320)); } + case 498: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ +{ yymsp[-3].minor.yy602 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy602)); } break; - case 496: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy320 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy320), NULL, yymsp[-1].minor.yy320, yymsp[0].minor.yy320); } + case 499: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy602 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), NULL, yymsp[-1].minor.yy602, yymsp[0].minor.yy602); } break; - case 497: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy320 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy320), releaseRawExprNode(pCxt, yymsp[-3].minor.yy320), yymsp[-1].minor.yy320, yymsp[0].minor.yy320); } + case 500: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy602 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy602), releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), yymsp[-1].minor.yy602, yymsp[0].minor.yy602); } break; - case 498: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ -{ yymsp[-6].minor.yy320 = createEventWindowNode(pCxt, yymsp[-3].minor.yy320, yymsp[0].minor.yy320); } + case 501: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ +{ yymsp[-6].minor.yy602 = createEventWindowNode(pCxt, yymsp[-3].minor.yy602, yymsp[0].minor.yy602); } break; - case 502: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy320 = createFillNode(pCxt, yymsp[-1].minor.yy762, NULL); } + case 505: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy602 = createFillNode(pCxt, yymsp[-1].minor.yy324, NULL); } break; - case 503: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy320 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy570)); } + case 506: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy602 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy874)); } break; - case 504: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy762 = FILL_MODE_NONE; } + case 507: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy324 = FILL_MODE_NONE; } break; - case 505: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy762 = FILL_MODE_PREV; } + case 508: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy324 = FILL_MODE_PREV; } break; - case 506: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy762 = FILL_MODE_NULL; } + case 509: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy324 = FILL_MODE_NULL; } break; - case 507: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy762 = FILL_MODE_LINEAR; } + case 510: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy324 = FILL_MODE_LINEAR; } break; - case 508: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy762 = FILL_MODE_NEXT; } + case 511: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy324 = FILL_MODE_NEXT; } break; - case 511: /* group_by_list ::= expr_or_subquery */ -{ yylhsminor.yy570 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy320))); } - yymsp[0].minor.yy570 = yylhsminor.yy570; + case 514: /* group_by_list ::= expr_or_subquery */ +{ yylhsminor.yy874 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } + yymsp[0].minor.yy874 = yylhsminor.yy874; break; - case 512: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -{ yylhsminor.yy570 = addNodeToList(pCxt, yymsp[-2].minor.yy570, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy320))); } - yymsp[-2].minor.yy570 = yylhsminor.yy570; + case 515: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ +{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-2].minor.yy874, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } + yymsp[-2].minor.yy874 = yylhsminor.yy874; break; - case 516: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -{ yymsp[-5].minor.yy320 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy320), releaseRawExprNode(pCxt, yymsp[-1].minor.yy320)); } + case 519: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +{ yymsp[-5].minor.yy602 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), releaseRawExprNode(pCxt, yymsp[-1].minor.yy602)); } break; - case 519: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 522: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy320 = addOrderByClause(pCxt, yymsp[-3].minor.yy320, yymsp[-2].minor.yy570); - yylhsminor.yy320 = addSlimitClause(pCxt, yylhsminor.yy320, yymsp[-1].minor.yy320); - yylhsminor.yy320 = addLimitClause(pCxt, yylhsminor.yy320, yymsp[0].minor.yy320); + yylhsminor.yy602 = addOrderByClause(pCxt, yymsp[-3].minor.yy602, yymsp[-2].minor.yy874); + yylhsminor.yy602 = addSlimitClause(pCxt, yylhsminor.yy602, yymsp[-1].minor.yy602); + yylhsminor.yy602 = addLimitClause(pCxt, yylhsminor.yy602, yymsp[0].minor.yy602); } - yymsp[-3].minor.yy320 = yylhsminor.yy320; + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; - case 522: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -{ yylhsminor.yy320 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy320, yymsp[0].minor.yy320); } - yymsp[-3].minor.yy320 = yylhsminor.yy320; + case 525: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +{ yylhsminor.yy602 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy602, yymsp[0].minor.yy602); } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; - case 523: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -{ yylhsminor.yy320 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy320, yymsp[0].minor.yy320); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 526: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +{ yylhsminor.yy602 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy602, yymsp[0].minor.yy602); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 531: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 535: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==535); -{ yymsp[-1].minor.yy320 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 534: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 538: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==538); +{ yymsp[-1].minor.yy602 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 532: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 536: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==536); -{ yymsp[-3].minor.yy320 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 535: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 539: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==539); +{ yymsp[-3].minor.yy602 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 533: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 537: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==537); -{ yymsp[-3].minor.yy320 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 536: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 540: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==540); +{ yymsp[-3].minor.yy602 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 538: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy320 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy320); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 541: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy602); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 543: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy320 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy320), yymsp[-1].minor.yy162, yymsp[0].minor.yy715); } - yymsp[-2].minor.yy320 = yylhsminor.yy320; + case 546: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy602 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), yymsp[-1].minor.yy878, yymsp[0].minor.yy487); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 544: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy162 = ORDER_ASC; } + case 547: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy878 = ORDER_ASC; } break; - case 545: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy162 = ORDER_ASC; } + case 548: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy878 = ORDER_ASC; } break; - case 546: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy162 = ORDER_DESC; } + case 549: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy878 = ORDER_DESC; } break; - case 547: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy715 = NULL_ORDER_DEFAULT; } + case 550: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy487 = NULL_ORDER_DEFAULT; } break; - case 548: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy715 = NULL_ORDER_FIRST; } + case 551: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy487 = NULL_ORDER_FIRST; } break; - case 549: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy715 = NULL_ORDER_LAST; } + case 552: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy487 = NULL_ORDER_LAST; } break; default: break; /********** End reduce actions ************************************************/ }; - assert( yyrulenohasLastRow = pSelect->hasLastRowFunc; pAgg->hasLast = pSelect->hasLastFunc; pAgg->hasTimeLineFunc = pSelect->hasTimeLineFunc; + pAgg->hasGroupKeyOptimized = false; pAgg->onlyHasKeepOrderFunc = pSelect->onlyHasKeepOrderFunc; pAgg->node.groupAction = getGroupAction(pCxt, pSelect); pAgg->node.requireDataOrder = getRequireDataOrder(pAgg->hasTimeLineFunc, pSelect); diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 83341d200a..120a853741 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1538,6 +1538,11 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub code = adjustLogicNodeDataRequirement((SLogicNode*)pScan, pNode->resultDataOrder); } if (TSDB_CODE_SUCCESS == code) { + if (QUERY_NODE_LOGIC_PLAN_AGG == pNode->pParent->type) { + SAggLogicNode* pParent = (SAggLogicNode*)(pNode->pParent); + pParent->hasGroupKeyOptimized = true; + } + NODES_CLEAR_LIST(pNode->pChildren); nodesDestroyNode((SNode*)pNode); } @@ -1563,6 +1568,8 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub break; } } + pAgg->hasGroupKeyOptimized = true; + NODES_DESTORY_LIST(pAgg->pGroupKeys); if (TSDB_CODE_SUCCESS == code && start >= 0) { code = partTagsRewriteGroupTagsToFuncs(pScan->pGroupTags, start, pAgg); @@ -1571,6 +1578,7 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub if (TSDB_CODE_SUCCESS == code) { code = partTagsOptRebuildTbanme(pScan->pGroupTags); } + pCxt->optimized = true; return code; } @@ -2374,6 +2382,9 @@ static bool tagScanOptShouldBeOptimized(SLogicNode* pNode) { if (pScan->hasNormalCols) { return false; } + if (pScan->tableType == TSDB_SYSTEM_TABLE) { + return false; + } if (NULL == pNode->pParent || QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode->pParent) || 1 != LIST_LENGTH(pNode->pParent->pChildren)) { return false; diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 78ae3c1c3b..7d6238193d 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -872,6 +872,7 @@ static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, } pAgg->mergeDataBlock = (GROUP_ACTION_KEEP == pAggLogicNode->node.groupAction ? false : true); + pAgg->groupKeyOptimized = pAggLogicNode->hasGroupKeyOptimized; SNodeList* pPrecalcExprs = NULL; SNodeList* pGroupKeys = NULL; diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index f6b1babf95..6208fc172a 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -333,13 +333,23 @@ static bool stbSplHasPartTbname(SNodeList* pPartKeys) { return false; } -static bool stbSplIsPartTableAgg(SAggLogicNode* pAgg) { - if (NULL != pAgg->pGroupKeys) { - return stbSplHasPartTbname(pAgg->pGroupKeys); +static bool stbSplNotSystemScan(SLogicNode* pNode) { + if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) { + return SCAN_TYPE_SYSTEM_TABLE != ((SScanLogicNode*)pNode)->scanType; + } else if (QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode)) { + return stbSplNotSystemScan((SLogicNode*)nodesListGetNode(pNode->pChildren, 0)); + } else { + return true; } +} + +static bool stbSplIsPartTableAgg(SAggLogicNode* pAgg) { if (1 != LIST_LENGTH(pAgg->node.pChildren)) { return false; } + if (NULL != pAgg->pGroupKeys) { + return stbSplHasPartTbname(pAgg->pGroupKeys) && stbSplNotSystemScan((SLogicNode*)nodesListGetNode(pAgg->node.pChildren, 0)); + } return stbSplHasPartTbname(stbSplGetPartKeys((SLogicNode*)nodesListGetNode(pAgg->node.pChildren, 0))); } diff --git a/source/libs/qworker/inc/qwInt.h b/source/libs/qworker/inc/qwInt.h index cad01d88c3..66b8e48eb1 100644 --- a/source/libs/qworker/inc/qwInt.h +++ b/source/libs/qworker/inc/qwInt.h @@ -114,14 +114,14 @@ typedef struct SQWTaskStatus { typedef struct SQWTaskCtx { SRWLatch lock; int8_t phase; + int8_t inFetch; int8_t taskType; int8_t explain; int8_t needFetch; int8_t localExec; int32_t msgType; - int32_t fetchType; - int32_t execId; int32_t level; + uint64_t sId; bool queryGotData; bool queryRsped; @@ -221,8 +221,16 @@ typedef struct SQWorkerMgmt { #define QW_GET_PHASE(ctx) atomic_load_8(&(ctx)->phase) #define QW_SET_PHASE(ctx, _value) \ do { \ - if ((_value) != QW_PHASE_PRE_FETCH && (_value) != QW_PHASE_POST_FETCH) { \ - atomic_store_8(&(ctx)->phase, _value); \ + switch (_value) { \ + case QW_PHASE_PRE_FETCH: \ + ctx->inFetch = 1; \ + break; \ + case QW_PHASE_POST_FETCH: \ + ctx->inFetch = 0; \ + break; \ + default: \ + atomic_store_8(&(ctx)->phase, _value); \ + break; \ } \ } while (0) @@ -230,6 +238,7 @@ typedef struct SQWorkerMgmt { #define QW_UPDATE_RSP_CODE(ctx, code) atomic_val_compare_exchange_32(&(ctx)->rspCode, 0, code) #define QW_QUERY_RUNNING(ctx) (QW_GET_PHASE(ctx) == QW_PHASE_PRE_QUERY || QW_GET_PHASE(ctx) == QW_PHASE_PRE_CQUERY) +#define QW_FETCH_RUNNING(ctx) ((ctx)->inFetch) #define QW_SET_QTID(id, qId, tId, eId) \ do { \ diff --git a/source/libs/qworker/src/qwDbg.c b/source/libs/qworker/src/qwDbg.c index db6e5b19fb..7a755cd36f 100644 --- a/source/libs/qworker/src/qwDbg.c +++ b/source/libs/qworker/src/qwDbg.c @@ -124,11 +124,11 @@ void qwDbgDumpTasksInfo(SQWorker *mgmt) { void *key = taosHashGetKey(pIter, NULL); QW_GET_QTID(key, qId, tId, eId); - QW_TASK_DLOG("%p lock:%x, phase:%d, type:%d, explain:%d, needFetch:%d, localExec:%d, msgType:%d, fetchType:%d, " - "execId:%x, level:%d, queryGotData:%d, queryRsped:%d, queryEnd:%d, queryContinue:%d, queryInQueue:%d, " + QW_TASK_DLOG("%p lock:%x, phase:%d, type:%d, explain:%d, needFetch:%d, localExec:%d, msgType:%d, " + "sId:%" PRId64 ", level:%d, queryGotData:%d, queryRsped:%d, queryEnd:%d, queryContinue:%d, queryInQueue:%d, " "rspCode:%x, affectedRows:%" PRId64 ", taskHandle:%p, sinkHandle:%p, tbFName:%s, sver:%d, tver:%d, events:%d,%d,%d,%d,%d", ctx, ctx->lock, ctx->phase, ctx->taskType, ctx->explain, ctx->needFetch, ctx->localExec, ctx->msgType, - ctx->fetchType, ctx->execId, ctx->level, ctx->queryGotData, ctx->queryRsped, ctx->queryEnd, ctx->queryContinue, + ctx->sId, ctx->level, ctx->queryGotData, ctx->queryRsped, ctx->queryEnd, ctx->queryContinue, ctx->queryInQueue, ctx->rspCode, ctx->affectedRows, ctx->taskHandle, ctx->sinkHandle, ctx->tbInfo.tbFName, ctx->tbInfo.sversion, ctx->tbInfo.tversion, ctx->events[QW_EVENT_CANCEL], ctx->events[QW_EVENT_READY], ctx->events[QW_EVENT_FETCH], ctx->events[QW_EVENT_DROP], ctx->events[QW_EVENT_CQUERY]); diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index e9d9a129a0..952b87f9d7 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -507,14 +507,6 @@ int32_t qwHandlePostPhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inp } if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) { - if (QW_PHASE_POST_FETCH == phase) { - QW_TASK_WLOG("drop received at wrong phase %s", qwPhaseStr(phase)); - QW_ERR_JRET(TSDB_CODE_APP_ERROR); - } - - // qwBuildAndSendDropRsp(&ctx->ctrlConnInfo, code); - // QW_TASK_DLOG("drop rsp send, handle:%p, code:%x - %s", ctx->ctrlConnInfo.handle, code, tstrerror(code)); - QW_ERR_JRET(qwDropTask(QW_FPARAMS())); QW_ERR_JRET(ctx->rspCode); } @@ -579,6 +571,7 @@ int32_t qwPreprocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) { QW_ERR_JRET(qwAcquireTaskCtx(QW_FPARAMS(), &ctx)); ctx->ctrlConnInfo = qwMsg->connInfo; + ctx->sId = sId; ctx->phase = -1; QW_ERR_JRET(qwAddTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_INIT)); @@ -669,7 +662,7 @@ _return: qwMsg->connInfo = ctx->dataConnInfo; QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_FETCH); - qwBuildAndSendFetchRsp(ctx->fetchType, &qwMsg->connInfo, rsp, dataLen, code); + qwBuildAndSendFetchRsp(ctx->msgType + 1, &qwMsg->connInfo, rsp, dataLen, code); rsp = NULL; QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code, tstrerror(code), @@ -687,6 +680,7 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) { void *rsp = NULL; int32_t dataLen = 0; bool queryStop = false; + bool qComplete = false; do { ctx = NULL; @@ -711,17 +705,18 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) { } if (rsp) { - bool qComplete = (DS_BUF_EMPTY == sOutput.bufStatus && sOutput.queryEnd); + qComplete = (DS_BUF_EMPTY == sOutput.bufStatus && sOutput.queryEnd); qwBuildFetchRsp(rsp, &sOutput, dataLen, qComplete); if (qComplete) { atomic_store_8((int8_t *)&ctx->queryEnd, true); + atomic_store_8((int8_t *)&ctx->queryContinue, 0); } qwMsg->connInfo = ctx->dataConnInfo; QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_FETCH); - qwBuildAndSendFetchRsp(ctx->fetchType, &qwMsg->connInfo, rsp, dataLen, code); + qwBuildAndSendFetchRsp(ctx->msgType + 1, &qwMsg->connInfo, rsp, dataLen, code); rsp = NULL; QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code, @@ -743,14 +738,13 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) { rsp = NULL; qwMsg->connInfo = ctx->dataConnInfo; - qwBuildAndSendFetchRsp(ctx->fetchType, &qwMsg->connInfo, NULL, 0, code); + qwBuildAndSendFetchRsp(ctx->msgType + 1, &qwMsg->connInfo, NULL, 0, code); QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code, tstrerror(code), 0); } QW_LOCK(QW_WRITE, &ctx->lock); - if ((queryStop && (0 == atomic_load_8((int8_t *)&ctx->queryContinue))) || code || - 0 == atomic_load_8((int8_t *)&ctx->queryContinue)) { + if (qComplete || (queryStop && (0 == atomic_load_8((int8_t *)&ctx->queryContinue))) || code) { // Note: query is not running anymore QW_SET_PHASE(ctx, 0); QW_UNLOCK(QW_WRITE, &ctx->lock); @@ -1177,8 +1171,9 @@ void qWorkerStopAllTasks(void *qWorkerMgmt) { QW_DLOG("start to stop all tasks, taskNum:%d", taosHashGetSize(mgmt->ctxHash)); - uint64_t qId, tId; + uint64_t qId, tId, sId; int32_t eId; + int64_t rId = 0; void *pIter = taosHashIterate(mgmt->ctxHash, NULL); while (pIter) { SQWTaskCtx *ctx = (SQWTaskCtx *)pIter; @@ -1187,6 +1182,8 @@ void qWorkerStopAllTasks(void *qWorkerMgmt) { QW_LOCK(QW_WRITE, &ctx->lock); + sId = ctx->sId; + QW_TASK_DLOG_E("start to force stop task"); if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP) || QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) { @@ -1199,9 +1196,11 @@ void qWorkerStopAllTasks(void *qWorkerMgmt) { if (QW_QUERY_RUNNING(ctx)) { qwKillTaskHandle(ctx, TSDB_CODE_VND_STOPPED); - } else if (!QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) { + } else if (QW_FETCH_RUNNING(ctx)) { QW_UPDATE_RSP_CODE(ctx, TSDB_CODE_VND_STOPPED); - QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_DROP); + QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_DROP); + } else { + qwDropTask(QW_FPARAMS()); } QW_UNLOCK(QW_WRITE, &ctx->lock); diff --git a/source/libs/scalar/inc/sclInt.h b/source/libs/scalar/inc/sclInt.h index 0b85675c83..8278da0ed0 100644 --- a/source/libs/scalar/inc/sclInt.h +++ b/source/libs/scalar/inc/sclInt.h @@ -53,9 +53,6 @@ typedef struct SScalarCtx { #define SCL_IS_COMPARISON_OPERATOR(_opType) ((_opType) >= OP_TYPE_GREATER_THAN && (_opType) < OP_TYPE_IS_NOT_UNKNOWN) #define SCL_DOWNGRADE_DATETYPE(_type) \ ((_type) == TSDB_DATA_TYPE_BIGINT || TSDB_DATA_TYPE_DOUBLE == (_type) || (_type) == TSDB_DATA_TYPE_UBIGINT) -#define SCL_NO_NEED_CONVERT_COMPARISION(_ltype, _rtype, _optr) \ - (IS_NUMERIC_TYPE(_ltype) && IS_NUMERIC_TYPE(_rtype) && \ - ((_optr) >= OP_TYPE_GREATER_THAN && (_optr) <= OP_TYPE_NOT_EQUAL)) #define sclFatal(...) qFatal(__VA_ARGS__) #define sclError(...) qError(__VA_ARGS__) diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 3795f5ecb9..d0c27560ca 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -130,9 +130,9 @@ __compar_fn_t gDataCompare[] = {compareInt32Val, compareFloatVal, compareDoubleVal, compareLenPrefixedStr, - compareStrPatternMatch, + comparestrPatternMatch, compareChkInString, - compareWStrPatternMatch, + comparewcsPatternMatch, compareLenPrefixedWStr, compareUint8Val, compareUint16Val, @@ -142,15 +142,17 @@ __compar_fn_t gDataCompare[] = {compareInt32Val, setChkInBytes2, setChkInBytes4, setChkInBytes8, - compareStrRegexCompMatch, - compareStrRegexCompNMatch, + comparestrRegexMatch, + comparestrRegexNMatch, setChkNotInBytes1, setChkNotInBytes2, setChkNotInBytes4, setChkNotInBytes8, compareChkNotInString, - compareStrPatternNotMatch, - compareWStrPatternNotMatch}; + comparestrPatternNMatch, + comparewcsPatternNMatch, + comparewcsRegexMatch, + comparewcsRegexNMatch,}; __compar_fn_t gInt8SignCompare[] = {compareInt8Val, compareInt8Int16, compareInt8Int32, compareInt8Int64, compareInt8Float, compareInt8Double}; @@ -295,9 +297,9 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { case TSDB_DATA_TYPE_NCHAR: { if (optr == OP_TYPE_MATCH) { - comparFn = 19; + comparFn = 28; } else if (optr == OP_TYPE_NMATCH) { - comparFn = 20; + comparFn = 29; } else if (optr == OP_TYPE_LIKE) { comparFn = 9; } else if (optr == OP_TYPE_NOT_LIKE) { @@ -336,7 +338,7 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { __compar_fn_t filterGetCompFunc(int32_t type, int32_t optr) { return gDataCompare[filterGetCompFuncIdx(type, optr)]; } __compar_fn_t filterGetCompFuncEx(int32_t lType, int32_t rType, int32_t optr) { - if (TSDB_DATA_TYPE_NULL == rType) { + if (TSDB_DATA_TYPE_NULL == rType || TSDB_DATA_TYPE_JSON == rType) { return NULL; } @@ -4085,7 +4087,7 @@ bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, SC SArray *pList = taosArrayInit(1, POINTER_BYTES); taosArrayPush(pList, &pSrc); - int32_t code = scalarCalculate(info->sclCtx.node, pList, &output); + code = scalarCalculate(info->sclCtx.node, pList, &output); taosArrayDestroy(pList); FLT_ERR_RET(code); diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index a1995bdf50..8f2fe87a53 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -37,6 +37,11 @@ #define IS_HELPER_NULL(col, i) colDataIsNull_s(col, i) || IS_JSON_NULL(col->info.type, colDataGetVarData(col, i)) +bool noConvertBeforeCompare(int32_t leftType, int32_t rightType, int32_t optr) { + return IS_NUMERIC_TYPE(leftType) && IS_NUMERIC_TYPE(rightType) && + (optr >= OP_TYPE_GREATER_THAN && optr <= OP_TYPE_NOT_EQUAL); +} + void convertNumberToNumber(const void *inData, void *outData, int8_t inType, int8_t outType) { switch (outType) { case TSDB_DATA_TYPE_BOOL: { @@ -338,6 +343,7 @@ static FORCE_INLINE void varToBool(char *buf, SScalarParam *pOut, int32_t rowInd colDataAppendInt8(pOut->columnData, rowIndex, (int8_t *)&v); } +// todo remove this malloc static FORCE_INLINE void varToNchar(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) { int32_t len = 0; int32_t inputLen = varDataLen(buf); @@ -399,6 +405,8 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) { } pCtx->pOut->numOfRows = pCtx->pIn->numOfRows; + char* tmp = NULL; + for (int32_t i = pCtx->startIndex; i <= pCtx->endIndex; ++i) { if (IS_HELPER_NULL(pCtx->pIn->columnData, i)) { colDataAppendNULL(pCtx->pOut->columnData, i); @@ -421,12 +429,16 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) { continue; } } + int32_t bufSize = pCtx->pIn->columnData->info.bytes; - char *tmp = taosMemoryMalloc(varDataTLen(data)); - if (!tmp) { - sclError("out of memory in vectorConvertFromVarData"); - return TSDB_CODE_OUT_OF_MEMORY; + if (tmp == NULL) { + tmp = taosMemoryMalloc(bufSize); + if (tmp == NULL) { + sclError("out of memory in vectorConvertFromVarData"); + return TSDB_CODE_OUT_OF_MEMORY; + } } + if (vton) { memcpy(tmp, data, varDataTLen(data)); } else { @@ -434,6 +446,7 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) { memcpy(tmp, varDataVal(data), varDataLen(data)); tmp[varDataLen(data)] = 0; } else if (TSDB_DATA_TYPE_NCHAR == convertType) { + // we need to convert it to native char string, and then perform the string to numeric data ASSERT(varDataLen(data) <= bufSize); int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(data), varDataLen(data), tmp); @@ -448,9 +461,11 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) { } (*func)(tmp, pCtx->pOut, i, overflow); - taosMemoryFreeClear(tmp); } + if (tmp != NULL) { + taosMemoryFreeClear(tmp); + } return TSDB_CODE_SUCCESS; } @@ -901,9 +916,11 @@ int32_t vectorGetConvertType(int32_t type1, int32_t type2) { int32_t vectorConvertSingleCol(SScalarParam *input, SScalarParam *output, int32_t type, int32_t startIndex, int32_t numOfRows) { - SDataType t = {.type = type, .bytes = tDataTypes[type].bytes}; output->numOfRows = input->numOfRows; + SDataType t = {.type = type}; + t.bytes = IS_VAR_DATA_TYPE(t.type)? input->columnData->info.bytes:tDataTypes[type].bytes; + int32_t code = sclCreateColumnInfoData(&t, input->numOfRows, output); if (code != TSDB_CODE_SUCCESS) { return TSDB_CODE_OUT_OF_MEMORY; @@ -925,25 +942,43 @@ int32_t vectorConvertCols(SScalarParam *pLeft, SScalarParam *pRight, SScalarPara return TSDB_CODE_SUCCESS; } + int8_t type = 0; + int32_t code = 0; + SScalarParam *param1 = NULL, *paramOut1 = NULL; SScalarParam *param2 = NULL, *paramOut2 = NULL; - int32_t code = 0; - if (leftType < rightType) { + // always convert least data + if (IS_VAR_DATA_TYPE(leftType) && IS_VAR_DATA_TYPE(rightType) && (pLeft->numOfRows != pRight->numOfRows) && + leftType != TSDB_DATA_TYPE_JSON && rightType != TSDB_DATA_TYPE_JSON) { param1 = pLeft; param2 = pRight; paramOut1 = pLeftOut; paramOut2 = pRightOut; - } else { - param1 = pRight; - param2 = pLeft; - paramOut1 = pRightOut; - paramOut2 = pLeftOut; - } - int8_t type = vectorGetConvertType(GET_PARAM_TYPE(param1), GET_PARAM_TYPE(param2)); - if (0 == type) { - return TSDB_CODE_SUCCESS; + if (pLeft->numOfRows > pRight->numOfRows) { + type = leftType; + } else { + type = rightType; + } + } else { + // we only define half value in the convert-matrix, so make sure param1 always less equal than param2 + if (leftType < rightType) { + param1 = pLeft; + param2 = pRight; + paramOut1 = pLeftOut; + paramOut2 = pRightOut; + } else { + param1 = pRight; + param2 = pLeft; + paramOut1 = pRightOut; + paramOut2 = pLeftOut; + } + + type = vectorGetConvertType(GET_PARAM_TYPE(param1), GET_PARAM_TYPE(param2)); + if (0 == type) { + return TSDB_CODE_SUCCESS; + } } if (type != GET_PARAM_TYPE(param1)) { @@ -1683,23 +1718,13 @@ void vectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam * SScalarParam *param1 = NULL; SScalarParam *param2 = NULL; - if (SCL_NO_NEED_CONVERT_COMPARISION(GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), optr)) { + if (noConvertBeforeCompare(GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), optr)) { param1 = pLeft; param2 = pRight; } else { vectorConvertCols(pLeft, pRight, &pLeftOut, &pRightOut, startIndex, numOfRows); - - if (pLeftOut.columnData != NULL) { - param1 = &pLeftOut; - } else { - param1 = pLeft; - } - - if (pRightOut.columnData != NULL) { - param2 = &pRightOut; - } else { - param2 = pRight; - } + param1 = (pLeftOut.columnData != NULL) ? &pLeftOut : pLeft; + param2 = (pRightOut.columnData != NULL) ? &pRightOut : pRight; } doVectorCompare(param1, param2, pOut, startIndex, numOfRows, _ord, optr); diff --git a/source/libs/scalar/test/scalar/scalarTests.cpp b/source/libs/scalar/test/scalar/scalarTests.cpp index f5a40c9a87..97002ed9bf 100644 --- a/source/libs/scalar/test/scalar/scalarTests.cpp +++ b/source/libs/scalar/test/scalar/scalarTests.cpp @@ -344,7 +344,7 @@ TEST(constantTest, int_or_binary) { ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); SValueNode *v = (SValueNode *)res; ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BIGINT); - ASSERT_EQ(v->datum.b, scltLeftV | scltRightV); + ASSERT_EQ(v->datum.i, scltLeftV | scltRightV); nodesDestroyNode(res); } @@ -1101,7 +1101,8 @@ void makeCalculate(void *json, void *key, int32_t rightType, void *rightData, do opType == OP_TYPE_LIKE || opType == OP_TYPE_NOT_LIKE || opType == OP_TYPE_MATCH || opType == OP_TYPE_NMATCH) { printf("op:%s,3result:%d,except:%f\n", operatorTypeStr(opType), *((bool *)colDataGetData(column, 0)), exceptValue); - ASSERT_EQ(*((bool *)colDataGetData(column, 0)), exceptValue); + assert(*(bool *)colDataGetData(column, 0) == exceptValue); +// ASSERT_EQ((int) *((bool *)colDataGetData(column, 0)), (int)exceptValue); } taosArrayDestroyEx(blockList, scltFreeDataBlock); @@ -1426,7 +1427,7 @@ TEST(columnTest, json_column_logic_op) { printf("--------------------json string-- 6.6hello {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); key = "k9"; - bool eRes8[len + len1] = {false, false, false, false, false, false, false, true, true, false, true, false, true}; + bool eRes8[len + len1] = {false, false, false, false, false, false, false, true, true, false, true, true, true}; for (int i = 0; i < len; i++) { makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes8[i], op[i], false); } @@ -1437,6 +1438,9 @@ TEST(columnTest, json_column_logic_op) { for (int i = len; i < len + len1; i++) { void *rightData = prepareNchar(inputNchar[i - len]); + if (i == 11) { + printf("abc\n"); + } makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes8[i], op[i], false); taosMemoryFree(rightData); } diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index 62ba74bd23..8f63cbbd99 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -111,10 +111,14 @@ int32_t streamScanExec(SStreamTask* pTask, int32_t batchSz) { int32_t batchCnt = 0; while (1) { + if (atomic_load_8(&pTask->taskStatus) == TASK_STATUS__DROPPING) { + return 0; + } + SSDataBlock* output = NULL; uint64_t ts = 0; if (qExecTask(exec, &output, &ts) < 0) { - ASSERT(0); + return -1; } if (output == NULL) { if (qStreamRecoverScanFinished(exec)) { diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index afad78c5e5..2b22a4ed29 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -294,6 +294,7 @@ int32_t streamLoadTasks(SStreamMeta* pMeta) { tdbTbcClose(pCur); return -1; } + pTask->taskStatus = TASK_STATUS__NORMAL; } tdbFree(pKey); diff --git a/source/libs/stream/src/streamRecover.c b/source/libs/stream/src/streamRecover.c index 52777fd834..061b211ddf 100644 --- a/source/libs/stream/src/streamRecover.c +++ b/source/libs/stream/src/streamRecover.c @@ -200,7 +200,6 @@ int32_t streamBuildSourceRecover2Req(SStreamTask* pTask, SStreamRecoverStep2Req* int32_t streamSourceRecoverScanStep2(SStreamTask* pTask, int64_t ver) { void* exec = pTask->exec.executor; if (qStreamSourceRecoverStep2(exec, ver) < 0) { - ASSERT(0); } return streamScanExec(pTask, 100); } diff --git a/source/libs/sync/inc/syncIndexMgr.h b/source/libs/sync/inc/syncIndexMgr.h index 79b4fa0fbf..4e6ab284f8 100644 --- a/source/libs/sync/inc/syncIndexMgr.h +++ b/source/libs/sync/inc/syncIndexMgr.h @@ -25,29 +25,27 @@ extern "C" { // SIndexMgr ----------------------------- typedef struct SSyncIndexMgr { SRaftId (*replicas)[TSDB_MAX_REPLICA]; - SyncIndex index[TSDB_MAX_REPLICA]; - SyncTerm privateTerm[TSDB_MAX_REPLICA]; // for advanced function - - int64_t startTimeArr[TSDB_MAX_REPLICA]; - int64_t recvTimeArr[TSDB_MAX_REPLICA]; - + SyncIndex index[TSDB_MAX_REPLICA]; + SyncTerm privateTerm[TSDB_MAX_REPLICA]; // for advanced function + int64_t startTimeArr[TSDB_MAX_REPLICA]; + int64_t recvTimeArr[TSDB_MAX_REPLICA]; int32_t replicaNum; - SSyncNode *pSyncNode; + SSyncNode *pNode; } SSyncIndexMgr; -SSyncIndexMgr *syncIndexMgrCreate(SSyncNode *pSyncNode); -void syncIndexMgrUpdate(SSyncIndexMgr *pSyncIndexMgr, SSyncNode *pSyncNode); -void syncIndexMgrDestroy(SSyncIndexMgr *pSyncIndexMgr); -void syncIndexMgrClear(SSyncIndexMgr *pSyncIndexMgr); -void syncIndexMgrSetIndex(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId, SyncIndex index); -SyncIndex syncIndexMgrGetIndex(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId); +SSyncIndexMgr *syncIndexMgrCreate(SSyncNode *pNode); +void syncIndexMgrUpdate(SSyncIndexMgr *pIndexMgr, SSyncNode *pNode); +void syncIndexMgrDestroy(SSyncIndexMgr *pIndexMgr); +void syncIndexMgrClear(SSyncIndexMgr *pIndexMgr); +void syncIndexMgrSetIndex(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId, SyncIndex index); +SyncIndex syncIndexMgrGetIndex(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId); -void syncIndexMgrSetStartTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId, int64_t startTime); -int64_t syncIndexMgrGetStartTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId); -void syncIndexMgrSetRecvTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId, int64_t recvTime); -int64_t syncIndexMgrGetRecvTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId); -void syncIndexMgrSetTerm(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId, SyncTerm term); -SyncTerm syncIndexMgrGetTerm(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId); +void syncIndexMgrSetStartTime(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId, int64_t startTime); +int64_t syncIndexMgrGetStartTime(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId); +void syncIndexMgrSetRecvTime(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId, int64_t recvTime); +int64_t syncIndexMgrGetRecvTime(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId); +void syncIndexMgrSetTerm(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId, SyncTerm term); +SyncTerm syncIndexMgrGetTerm(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId); #ifdef __cplusplus } diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h index b5227152df..3bf4a8d1cd 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -53,6 +53,18 @@ typedef struct SyncPreSnapshot SyncPreSnapshot; typedef struct SSyncLogBuffer SSyncLogBuffer; typedef struct SSyncLogReplMgr SSyncLogReplMgr; +#define MAX_CONFIG_INDEX_COUNT 256 + +typedef struct SRaftCfg { + SSyncCfg cfg; + int32_t batchSize; + int8_t isStandBy; + int8_t snapshotStrategy; + SyncIndex lastConfigIndex; + int32_t configIndexCount; + SyncIndex configIndexArr[MAX_CONFIG_INDEX_COUNT]; +} SRaftCfg; + typedef struct SRaftId { SyncNodeId addr; SyncGroupId vgId; @@ -93,7 +105,7 @@ typedef struct SPeerState { typedef struct SSyncNode { // init by SSyncInfo SyncGroupId vgId; - SRaftCfg* pRaftCfg; + SRaftCfg raftCfg; char path[TSDB_FILENAME_LEN]; char raftStorePath[TSDB_FILENAME_LEN * 2]; char configPath[TSDB_FILENAME_LEN * 2]; @@ -112,6 +124,7 @@ typedef struct SSyncNode { int32_t peersNum; SNodeInfo peersNodeInfo[TSDB_MAX_REPLICA]; + SEpSet peersEpset[TSDB_MAX_REPLICA]; SRaftId peersId[TSDB_MAX_REPLICA]; int32_t replicaNum; @@ -245,7 +258,6 @@ int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode); // utils -------------- int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pSyncNode, SRpcMsg* pMsg); -int32_t syncNodeSendMsgByInfo(const SNodeInfo* nodeInfo, SSyncNode* pSyncNode, SRpcMsg* pMsg); SyncIndex syncMinMatchIndex(SSyncNode* pSyncNode); int32_t syncCacheEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry, LRUHandle** h); bool syncNodeHeartbeatReplyTimeout(SSyncNode* pSyncNode); diff --git a/source/libs/sync/inc/syncRaftCfg.h b/source/libs/sync/inc/syncRaftCfg.h index 823983e732..4f03a60fbc 100644 --- a/source/libs/sync/inc/syncRaftCfg.h +++ b/source/libs/sync/inc/syncRaftCfg.h @@ -22,64 +22,9 @@ extern "C" { #include "syncInt.h" -#define CONFIG_FILE_LEN 2048 -#define MAX_CONFIG_INDEX_COUNT 256 - -typedef struct SRaftCfgIndex { - TdFilePtr pFile; - char path[TSDB_FILENAME_LEN * 2]; - - SyncIndex configIndexArr[MAX_CONFIG_INDEX_COUNT]; - int32_t configIndexCount; -} SRaftCfgIndex; - -SRaftCfgIndex *raftCfgIndexOpen(const char *path); -int32_t raftCfgIndexClose(SRaftCfgIndex *pRaftCfgIndex); -int32_t raftCfgIndexPersist(SRaftCfgIndex *pRaftCfgIndex); -int32_t raftCfgIndexAddConfigIndex(SRaftCfgIndex *pRaftCfgIndex, SyncIndex configIndex); - -cJSON *raftCfgIndex2Json(SRaftCfgIndex *pRaftCfgIndex); -char *raftCfgIndex2Str(SRaftCfgIndex *pRaftCfgIndex); -int32_t raftCfgIndexFromJson(const cJSON *pRoot, SRaftCfgIndex *pRaftCfgIndex); -int32_t raftCfgIndexFromStr(const char *s, SRaftCfgIndex *pRaftCfgIndex); -int32_t raftCfgIndexCreateFile(const char *path); - -typedef struct SRaftCfg { - SSyncCfg cfg; - TdFilePtr pFile; - char path[TSDB_FILENAME_LEN * 2]; - int8_t isStandBy; - int32_t batchSize; - int8_t snapshotStrategy; - SyncIndex lastConfigIndex; - - SyncIndex configIndexArr[MAX_CONFIG_INDEX_COUNT]; - int32_t configIndexCount; - -} SRaftCfg; - -SRaftCfg *raftCfgOpen(const char *path); -int32_t raftCfgClose(SRaftCfg *pRaftCfg); -int32_t raftCfgPersist(SRaftCfg *pRaftCfg); -int32_t raftCfgAddConfigIndex(SRaftCfg *pRaftCfg, SyncIndex configIndex); - -void syncCfg2SimpleStr(const SSyncCfg *pCfg, char *str, int32_t bufLen); -cJSON *syncCfg2Json(SSyncCfg *pSyncCfg); -int32_t syncCfgFromJson(const cJSON *pRoot, SSyncCfg *pSyncCfg); - -cJSON *raftCfg2Json(SRaftCfg *pRaftCfg); -char *raftCfg2Str(SRaftCfg *pRaftCfg); -int32_t raftCfgFromJson(const cJSON *pRoot, SRaftCfg *pRaftCfg); -int32_t raftCfgFromStr(const char *s, SRaftCfg *pRaftCfg); - -typedef struct SRaftCfgMeta { - int8_t isStandBy; - int32_t batchSize; - int8_t snapshotStrategy; - SyncIndex lastConfigIndex; -} SRaftCfgMeta; - -int32_t raftCfgCreateFile(SSyncCfg *pCfg, SRaftCfgMeta meta, const char *path); +int32_t syncWriteCfgFile(SSyncNode *pNode); +int32_t syncReadCfgFile(SSyncNode *pNode); +int32_t syncAddCfgIndex(SSyncNode *pNode, SyncIndex cfgIndex); #ifdef __cplusplus } diff --git a/source/libs/sync/inc/syncUtil.h b/source/libs/sync/inc/syncUtil.h index 7d08585656..39c679a2ad 100644 --- a/source/libs/sync/inc/syncUtil.h +++ b/source/libs/sync/inc/syncUtil.h @@ -62,22 +62,19 @@ extern "C" { // clang-format on -uint64_t syncUtilAddr2U64(const char* host, uint16_t port); -void syncUtilU642Addr(uint64_t u64, char* host, int64_t len, uint16_t* port); -void syncUtilNodeInfo2EpSet(const SNodeInfo* pInfo, SEpSet* pEpSet); -void syncUtilRaftId2EpSet(const SRaftId* raftId, SEpSet* pEpSet); -bool syncUtilNodeInfo2RaftId(const SNodeInfo* pInfo, SyncGroupId vgId, SRaftId* raftId); -bool syncUtilSameId(const SRaftId* pId1, const SRaftId* pId2); -bool syncUtilEmptyId(const SRaftId* pId); +#define CID(pRaftId) (int32_t)(((pRaftId)->addr) >> 32) +#define DID(pRaftId) (int32_t)((pRaftId)->addr) +#define SYNC_ADDR(pInfo) (int64_t)(((pInfo)->clusterId << 32) | (pInfo)->nodeId) + +void syncUtilNodeInfo2EpSet(const SNodeInfo* pInfo, SEpSet* pEpSet); +bool syncUtilNodeInfo2RaftId(const SNodeInfo* pInfo, SyncGroupId vgId, SRaftId* raftId); +bool syncUtilSameId(const SRaftId* pId1, const SRaftId* pId2); +bool syncUtilEmptyId(const SRaftId* pId); int32_t syncUtilElectRandomMS(int32_t min, int32_t max); int32_t syncUtilQuorum(int32_t replicaNum); -cJSON* syncUtilRaftId2Json(const SRaftId* p); const char* syncStr(ESyncState state); -char* syncUtilPrintBin(char* ptr, uint32_t len); -char* syncUtilPrintBin2(char* ptr, uint32_t len); void syncUtilMsgHtoN(void* msg); -void syncUtilMsgNtoH(void* msg); bool syncUtilUserPreCommit(tmsg_t msgType); bool syncUtilUserRollback(tmsg_t msgType); diff --git a/source/libs/sync/inc/syncVoteMgr.h b/source/libs/sync/inc/syncVoteMgr.h index 066a4dd76f..6e63a2b396 100644 --- a/source/libs/sync/inc/syncVoteMgr.h +++ b/source/libs/sync/inc/syncVoteMgr.h @@ -30,12 +30,12 @@ typedef struct SVotesGranted { SyncTerm term; int32_t quorum; bool toLeader; - SSyncNode *pSyncNode; + SSyncNode *pNode; } SVotesGranted; -SVotesGranted *voteGrantedCreate(SSyncNode *pSyncNode); +SVotesGranted *voteGrantedCreate(SSyncNode *pNode); void voteGrantedDestroy(SVotesGranted *pVotesGranted); -void voteGrantedUpdate(SVotesGranted *pVotesGranted, SSyncNode *pSyncNode); +void voteGrantedUpdate(SVotesGranted *pVotesGranted, SSyncNode *pNode); bool voteGrantedMajority(SVotesGranted *pVotesGranted); void voteGrantedVote(SVotesGranted *pVotesGranted, SyncRequestVoteReply *pMsg); void voteGrantedReset(SVotesGranted *pVotesGranted, SyncTerm term); @@ -45,12 +45,12 @@ typedef struct SVotesRespond { bool isRespond[TSDB_MAX_REPLICA]; int32_t replicaNum; SyncTerm term; - SSyncNode *pSyncNode; + SSyncNode *pNode; } SVotesRespond; -SVotesRespond *votesRespondCreate(SSyncNode *pSyncNode); +SVotesRespond *votesRespondCreate(SSyncNode *pNode); void votesRespondDestory(SVotesRespond *pVotesRespond); -void votesRespondUpdate(SVotesRespond *pVotesRespond, SSyncNode *pSyncNode); +void votesRespondUpdate(SVotesRespond *pVotesRespond, SSyncNode *pNode); bool votesResponded(SVotesRespond *pVotesRespond, const SRaftId *pRaftId); void votesRespondAdd(SVotesRespond *pVotesRespond, const SyncRequestVoteReply *pMsg); void votesRespondReset(SVotesRespond *pVotesRespond, SyncTerm term); diff --git a/source/libs/sync/src/syncElection.c b/source/libs/sync/src/syncElection.c index 8d548114fb..bcc95c5f10 100644 --- a/source/libs/sync/src/syncElection.c +++ b/source/libs/sync/src/syncElection.c @@ -94,7 +94,7 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) { voteGrantedUpdate(pSyncNode->pVotesGranted, pSyncNode); votesRespondUpdate(pSyncNode->pVotesRespond, pSyncNode); - pSyncNode->quorum = syncUtilQuorum(pSyncNode->pRaftCfg->cfg.replicaNum); + pSyncNode->quorum = syncUtilQuorum(pSyncNode->raftCfg.cfg.replicaNum); syncNodeCandidate2Leader(pSyncNode); pSyncNode->pVotesGranted->toLeader = true; diff --git a/source/libs/sync/src/syncEnv.c b/source/libs/sync/src/syncEnv.c index 28ae8711a8..0d6d0f93f1 100644 --- a/source/libs/sync/src/syncEnv.c +++ b/source/libs/sync/src/syncEnv.c @@ -115,7 +115,7 @@ void syncHbTimerDataRemove(int64_t rid) { taosRemoveRef(gHbDataRefId, rid); } SSyncHbTimerData *syncHbTimerDataAcquire(int64_t rid) { SSyncHbTimerData *pData = taosAcquireRef(gHbDataRefId, rid); if (pData == NULL) { - sError("failed to acquire hb-timer-data from refId:%" PRId64, rid); + sInfo("failed to acquire hb-timer-data from refId:%" PRId64, rid); terrno = TSDB_CODE_SYN_INTERNAL_ERROR; } diff --git a/source/libs/sync/src/syncIndexMgr.c b/source/libs/sync/src/syncIndexMgr.c index 7933258e53..7ecb9d7782 100644 --- a/source/libs/sync/src/syncIndexMgr.c +++ b/source/libs/sync/src/syncIndexMgr.c @@ -17,173 +17,152 @@ #include "syncIndexMgr.h" #include "syncUtil.h" -SSyncIndexMgr *syncIndexMgrCreate(SSyncNode *pSyncNode) { - SSyncIndexMgr *pSyncIndexMgr = taosMemoryCalloc(1, sizeof(SSyncIndexMgr)); - if (pSyncIndexMgr == NULL) { +SSyncIndexMgr *syncIndexMgrCreate(SSyncNode *pNode) { + SSyncIndexMgr *pIndexMgr = taosMemoryCalloc(1, sizeof(SSyncIndexMgr)); + if (pIndexMgr == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } - pSyncIndexMgr->replicas = &(pSyncNode->replicasId); - pSyncIndexMgr->replicaNum = pSyncNode->replicaNum; - pSyncIndexMgr->pSyncNode = pSyncNode; - syncIndexMgrClear(pSyncIndexMgr); + pIndexMgr->replicas = &pNode->replicasId; + pIndexMgr->replicaNum = pNode->replicaNum; + pIndexMgr->pNode = pNode; + syncIndexMgrClear(pIndexMgr); - return pSyncIndexMgr; + return pIndexMgr; } -void syncIndexMgrUpdate(SSyncIndexMgr *pSyncIndexMgr, SSyncNode *pSyncNode) { - pSyncIndexMgr->replicas = &(pSyncNode->replicasId); - pSyncIndexMgr->replicaNum = pSyncNode->replicaNum; - pSyncIndexMgr->pSyncNode = pSyncNode; - syncIndexMgrClear(pSyncIndexMgr); +void syncIndexMgrUpdate(SSyncIndexMgr *pIndexMgr, SSyncNode *pNode) { + pIndexMgr->replicas = &pNode->replicasId; + pIndexMgr->replicaNum = pNode->replicaNum; + pIndexMgr->pNode = pNode; + syncIndexMgrClear(pIndexMgr); } -void syncIndexMgrDestroy(SSyncIndexMgr *pSyncIndexMgr) { - if (pSyncIndexMgr != NULL) { - taosMemoryFree(pSyncIndexMgr); +void syncIndexMgrDestroy(SSyncIndexMgr *pIndexMgr) { + if (pIndexMgr != NULL) { + taosMemoryFree(pIndexMgr); } } -void syncIndexMgrClear(SSyncIndexMgr *pSyncIndexMgr) { - memset(pSyncIndexMgr->index, 0, sizeof(pSyncIndexMgr->index)); - memset(pSyncIndexMgr->privateTerm, 0, sizeof(pSyncIndexMgr->privateTerm)); +void syncIndexMgrClear(SSyncIndexMgr *pIndexMgr) { + memset(pIndexMgr->index, 0, sizeof(pIndexMgr->index)); + memset(pIndexMgr->privateTerm, 0, sizeof(pIndexMgr->privateTerm)); - // int64_t timeNow = taosGetMonotonicMs(); int64_t timeNow = taosGetTimestampMs(); - for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { - pSyncIndexMgr->startTimeArr[i] = 0; - pSyncIndexMgr->recvTimeArr[i] = timeNow; + for (int i = 0; i < pIndexMgr->replicaNum; ++i) { + pIndexMgr->startTimeArr[i] = 0; + pIndexMgr->recvTimeArr[i] = timeNow; } - - /* - for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { - pSyncIndexMgr->index[i] = 0; - } - */ } -void syncIndexMgrSetIndex(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId, SyncIndex index) { - for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { - if (syncUtilSameId(&((*(pSyncIndexMgr->replicas))[i]), pRaftId)) { - (pSyncIndexMgr->index)[i] = index; +void syncIndexMgrSetIndex(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId, SyncIndex index) { + for (int i = 0; i < pIndexMgr->replicaNum; ++i) { + if (syncUtilSameId(&((*(pIndexMgr->replicas))[i]), pRaftId)) { + (pIndexMgr->index)[i] = index; return; } } - // maybe config change - // ASSERT(0); - - char host[128]; - uint16_t port; - syncUtilU642Addr(pRaftId->addr, host, sizeof(host), &port); - sError("vgId:%d, index mgr set for %s:%d, index:%" PRId64 " error", pSyncIndexMgr->pSyncNode->vgId, host, port, - index); + sError("vgId:%d, indexmgr set index:%" PRId64 " for dnode:%d cluster:%d failed", pIndexMgr->pNode->vgId, index, + DID(pRaftId), CID(pRaftId)); } -SSyncLogReplMgr *syncNodeGetLogReplMgr(SSyncNode *pNode, SRaftId *pDestId) { +SSyncLogReplMgr *syncNodeGetLogReplMgr(SSyncNode *pNode, SRaftId *pRaftId) { for (int i = 0; i < pNode->replicaNum; i++) { - if (syncUtilSameId(&(pNode->replicasId[i]), pDestId)) { + if (syncUtilSameId(&pNode->replicasId[i], pRaftId)) { return pNode->logReplMgrs[i]; } } + + sError("vgId:%d, indexmgr get replmgr from dnode:%d cluster:%d failed", pNode->vgId, DID(pRaftId), CID(pRaftId)); return NULL; } -SyncIndex syncIndexMgrGetIndex(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId) { - if (pSyncIndexMgr == NULL) { - return SYNC_INDEX_INVALID; - } - - for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { - if (syncUtilSameId(&((*(pSyncIndexMgr->replicas))[i]), pRaftId)) { - SyncIndex idx = (pSyncIndexMgr->index)[i]; +SyncIndex syncIndexMgrGetIndex(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId) { + for (int i = 0; i < pIndexMgr->replicaNum; ++i) { + if (syncUtilSameId(&((*(pIndexMgr->replicas))[i]), pRaftId)) { + SyncIndex idx = (pIndexMgr->index)[i]; return idx; } } + sError("vgId:%d, indexmgr get index from dnode:%d cluster:%d failed", pIndexMgr->pNode->vgId, DID(pRaftId), + CID(pRaftId)); return SYNC_INDEX_INVALID; } -void syncIndexMgrSetStartTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId, int64_t startTime) { - for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { - if (syncUtilSameId(&((*(pSyncIndexMgr->replicas))[i]), pRaftId)) { - (pSyncIndexMgr->startTimeArr)[i] = startTime; +void syncIndexMgrSetStartTime(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId, int64_t startTime) { + for (int i = 0; i < pIndexMgr->replicaNum; ++i) { + if (syncUtilSameId(&((*(pIndexMgr->replicas))[i]), pRaftId)) { + (pIndexMgr->startTimeArr)[i] = startTime; return; } } - // maybe config change - // ASSERT(0); - char host[128]; - uint16_t port; - syncUtilU642Addr(pRaftId->addr, host, sizeof(host), &port); - sError("vgId:%d, index mgr set for %s:%d, start-time:%" PRId64 " error", pSyncIndexMgr->pSyncNode->vgId, host, port, - startTime); + sError("vgId:%d, indexmgr set start-time:%" PRId64 " for dnode:%d cluster:%d failed", pIndexMgr->pNode->vgId, + startTime, DID(pRaftId), CID(pRaftId)); } -int64_t syncIndexMgrGetStartTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId) { - for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { - if (syncUtilSameId(&((*(pSyncIndexMgr->replicas))[i]), pRaftId)) { - int64_t startTime = (pSyncIndexMgr->startTimeArr)[i]; +int64_t syncIndexMgrGetStartTime(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId) { + for (int i = 0; i < pIndexMgr->replicaNum; ++i) { + if (syncUtilSameId(&((*(pIndexMgr->replicas))[i]), pRaftId)) { + int64_t startTime = (pIndexMgr->startTimeArr)[i]; return startTime; } } - ASSERT(0); + + sError("vgId:%d, indexmgr get start-time from dnode:%d cluster:%d failed", pIndexMgr->pNode->vgId, DID(pRaftId), + CID(pRaftId)); return -1; } -void syncIndexMgrSetRecvTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId, int64_t recvTime) { - for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { - if (syncUtilSameId(&((*(pSyncIndexMgr->replicas))[i]), pRaftId)) { - (pSyncIndexMgr->recvTimeArr)[i] = recvTime; +void syncIndexMgrSetRecvTime(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId, int64_t recvTime) { + for (int i = 0; i < pIndexMgr->replicaNum; ++i) { + if (syncUtilSameId(&((*(pIndexMgr->replicas))[i]), pRaftId)) { + (pIndexMgr->recvTimeArr)[i] = recvTime; return; } } - // maybe config change - // ASSERT(0); - char host[128]; - uint16_t port; - syncUtilU642Addr(pRaftId->addr, host, sizeof(host), &port); - sError("vgId:%d, index mgr set for %s:%d, recv-time:%" PRId64 " error", pSyncIndexMgr->pSyncNode->vgId, host, port, - recvTime); + sError("vgId:%d, indexmgr set recv-time:%" PRId64 " for dnode:%d cluster:%d failed", pIndexMgr->pNode->vgId, recvTime, + DID(pRaftId), CID(pRaftId)); } -int64_t syncIndexMgrGetRecvTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId) { - for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { - if (syncUtilSameId(&((*(pSyncIndexMgr->replicas))[i]), pRaftId)) { - int64_t recvTime = (pSyncIndexMgr->recvTimeArr)[i]; +int64_t syncIndexMgrGetRecvTime(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId) { + for (int i = 0; i < pIndexMgr->replicaNum; ++i) { + if (syncUtilSameId(&((*(pIndexMgr->replicas))[i]), pRaftId)) { + int64_t recvTime = (pIndexMgr->recvTimeArr)[i]; return recvTime; } } + sError("vgId:%d, indexmgr get recv-time from dnode:%d cluster:%d failed", pIndexMgr->pNode->vgId, DID(pRaftId), + CID(pRaftId)); return -1; } -void syncIndexMgrSetTerm(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId, SyncTerm term) { - for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { - if (syncUtilSameId(&((*(pSyncIndexMgr->replicas))[i]), pRaftId)) { - (pSyncIndexMgr->privateTerm)[i] = term; +void syncIndexMgrSetTerm(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId, SyncTerm term) { + for (int i = 0; i < pIndexMgr->replicaNum; ++i) { + if (syncUtilSameId(&((*(pIndexMgr->replicas))[i]), pRaftId)) { + (pIndexMgr->privateTerm)[i] = term; return; } } - // maybe config change - // ASSERT(0); - char host[128]; - uint16_t port; - syncUtilU642Addr(pRaftId->addr, host, sizeof(host), &port); - sError("vgId:%d, index mgr set for %s:%d, term:%" PRIu64 " error", pSyncIndexMgr->pSyncNode->vgId, host, port, term); + sError("vgId:%d, indexmgr set term:%" PRId64 " for dnode:%d cluster:%d failed", pIndexMgr->pNode->vgId, term, + DID(pRaftId), CID(pRaftId)); } -SyncTerm syncIndexMgrGetTerm(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId) { - for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { - if (syncUtilSameId(&((*(pSyncIndexMgr->replicas))[i]), pRaftId)) { - SyncTerm term = (pSyncIndexMgr->privateTerm)[i]; +SyncTerm syncIndexMgrGetTerm(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId) { + for (int i = 0; i < pIndexMgr->replicaNum; ++i) { + if (syncUtilSameId(&((*(pIndexMgr->replicas))[i]), pRaftId)) { + SyncTerm term = (pIndexMgr->privateTerm)[i]; return term; } } - ASSERT(0); + + sError("vgId:%d, indexmgr get term from dnode:%d cluster:%d failed", pIndexMgr->pNode->vgId, DID(pRaftId), + CID(pRaftId)); return -1; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 1a481a7e14..bf220178a4 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -306,15 +306,10 @@ int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex) { for (int32_t i = 0; i < pSyncNode->peersNum; ++i) { int64_t matchIndex = syncIndexMgrGetIndex(pSyncNode->pMatchIndex, &(pSyncNode->peersId[i])); if (lastApplyIndex > matchIndex) { - do { - char host[64]; - uint16_t port; - syncUtilU642Addr(pSyncNode->peersId[i].addr, host, sizeof(host), &port); - sNTrace(pSyncNode, - "new-snapshot-index:%" PRId64 " is greater than match-index:%" PRId64 - " of %s:%d, do not delete wal", - lastApplyIndex, matchIndex, host, port); - } while (0); + sNTrace(pSyncNode, + "new-snapshot-index:%" PRId64 " is greater than match-index:%" PRId64 + " of dnode:%d, do not delete wal", + lastApplyIndex, matchIndex, DID(&pSyncNode->peersId[i])); syncNodeRelease(pSyncNode); return 0; @@ -556,7 +551,7 @@ int32_t syncNodeLeaderTransferTo(SSyncNode* pSyncNode, SNodeInfo newLeader) { (void)syncBuildLeaderTransfer(&rpcMsg, pSyncNode->vgId); SyncLeaderTransfer* pMsg = rpcMsg.pCont; - pMsg->newLeaderId.addr = syncUtilAddr2U64(newLeader.nodeFqdn, newLeader.nodePort); + pMsg->newLeaderId.addr = SYNC_ADDR(&newLeader); pMsg->newLeaderId.vgId = pSyncNode->vgId; pMsg->newNodeInfo = newLeader; @@ -622,9 +617,9 @@ int32_t syncGetSnapshotMeta(int64_t rid, struct SSnapshotMeta* sMeta) { return -1; } ASSERT(rid == pSyncNode->rid); - sMeta->lastConfigIndex = pSyncNode->pRaftCfg->lastConfigIndex; + sMeta->lastConfigIndex = pSyncNode->raftCfg.lastConfigIndex; - sTrace("vgId:%d, get snapshot meta, lastConfigIndex:%" PRId64, pSyncNode->vgId, pSyncNode->pRaftCfg->lastConfigIndex); + sTrace("vgId:%d, get snapshot meta, lastConfigIndex:%" PRId64, pSyncNode->vgId, pSyncNode->raftCfg.lastConfigIndex); syncNodeRelease(pSyncNode); return 0; @@ -637,13 +632,13 @@ int32_t syncGetSnapshotMetaByIndex(int64_t rid, SyncIndex snapshotIndex, struct } ASSERT(rid == pSyncNode->rid); - ASSERT(pSyncNode->pRaftCfg->configIndexCount >= 1); - SyncIndex lastIndex = (pSyncNode->pRaftCfg->configIndexArr)[0]; + ASSERT(pSyncNode->raftCfg.configIndexCount >= 1); + SyncIndex lastIndex = (pSyncNode->raftCfg.configIndexArr)[0]; - for (int32_t i = 0; i < pSyncNode->pRaftCfg->configIndexCount; ++i) { - if ((pSyncNode->pRaftCfg->configIndexArr)[i] > lastIndex && - (pSyncNode->pRaftCfg->configIndexArr)[i] <= snapshotIndex) { - lastIndex = (pSyncNode->pRaftCfg->configIndexArr)[i]; + for (int32_t i = 0; i < pSyncNode->raftCfg.configIndexCount; ++i) { + if ((pSyncNode->raftCfg.configIndexArr)[i] > lastIndex && + (pSyncNode->raftCfg.configIndexArr)[i] <= snapshotIndex) { + lastIndex = (pSyncNode->raftCfg.configIndexArr)[i]; } } sMeta->lastConfigIndex = lastIndex; @@ -656,13 +651,13 @@ int32_t syncGetSnapshotMetaByIndex(int64_t rid, SyncIndex snapshotIndex, struct #endif SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode* pSyncNode, SyncIndex snapshotLastApplyIndex) { - ASSERT(pSyncNode->pRaftCfg->configIndexCount >= 1); - SyncIndex lastIndex = (pSyncNode->pRaftCfg->configIndexArr)[0]; + ASSERT(pSyncNode->raftCfg.configIndexCount >= 1); + SyncIndex lastIndex = (pSyncNode->raftCfg.configIndexArr)[0]; - for (int32_t i = 0; i < pSyncNode->pRaftCfg->configIndexCount; ++i) { - if ((pSyncNode->pRaftCfg->configIndexArr)[i] > lastIndex && - (pSyncNode->pRaftCfg->configIndexArr)[i] <= snapshotLastApplyIndex) { - lastIndex = (pSyncNode->pRaftCfg->configIndexArr)[i]; + for (int32_t i = 0; i < pSyncNode->raftCfg.configIndexCount; ++i) { + if ((pSyncNode->raftCfg.configIndexArr)[i] > lastIndex && + (pSyncNode->raftCfg.configIndexArr)[i] <= snapshotLastApplyIndex) { + lastIndex = (pSyncNode->raftCfg.configIndexArr)[i]; } } sTrace("vgId:%d, sync get last config index, index:%" PRId64 " lcindex:%" PRId64, pSyncNode->vgId, @@ -677,15 +672,15 @@ void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet) { SSyncNode* pSyncNode = syncNodeAcquire(rid); if (pSyncNode == NULL) return; - for (int32_t i = 0; i < pSyncNode->pRaftCfg->cfg.replicaNum; ++i) { + for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.replicaNum; ++i) { SEp* pEp = &pEpSet->eps[i]; - tstrncpy(pEp->fqdn, pSyncNode->pRaftCfg->cfg.nodeInfo[i].nodeFqdn, TSDB_FQDN_LEN); - pEp->port = (pSyncNode->pRaftCfg->cfg.nodeInfo)[i].nodePort; + tstrncpy(pEp->fqdn, pSyncNode->raftCfg.cfg.nodeInfo[i].nodeFqdn, TSDB_FQDN_LEN); + pEp->port = (pSyncNode->raftCfg.cfg.nodeInfo)[i].nodePort; pEpSet->numOfEps++; sDebug("vgId:%d, sync get retry epset, index:%d %s:%d", pSyncNode->vgId, i, pEp->fqdn, pEp->port); } if (pEpSet->numOfEps > 0) { - pEpSet->inUse = (pSyncNode->pRaftCfg->cfg.myIndex + 1) % pEpSet->numOfEps; + pEpSet->inUse = (pSyncNode->raftCfg.cfg.myIndex + 1) % pEpSet->numOfEps; } sInfo("vgId:%d, sync get retry epset numOfEps:%d inUse:%d", pSyncNode->vgId, pEpSet->numOfEps, pEpSet->inUse); @@ -849,60 +844,57 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { } } - snprintf(pSyncNode->configPath, sizeof(pSyncNode->configPath), "%s%sraft_config.json", pSyncInfo->path, TD_DIRSEP); - if (!taosCheckExistFile(pSyncNode->configPath)) { - // create a new raft config file - SRaftCfgMeta meta = {0}; - meta.isStandBy = pSyncInfo->isStandBy; - meta.snapshotStrategy = pSyncInfo->snapshotStrategy; - meta.lastConfigIndex = SYNC_INDEX_INVALID; - meta.batchSize = pSyncInfo->batchSize; - if (raftCfgCreateFile(&pSyncInfo->syncCfg, meta, pSyncNode->configPath) != 0) { - sError("vgId:%d, failed to create raft cfg file at %s", pSyncNode->vgId, pSyncNode->configPath); - goto _error; - } - if (pSyncInfo->syncCfg.replicaNum == 0) { - sInfo("vgId:%d, sync config not input", pSyncNode->vgId); - pSyncInfo->syncCfg = pSyncNode->pRaftCfg->cfg; - } - } else { - // update syncCfg by raft_config.json - pSyncNode->pRaftCfg = raftCfgOpen(pSyncNode->configPath); - if (pSyncNode->pRaftCfg == NULL) { - sError("vgId:%d, failed to open raft cfg file at %s", pSyncNode->vgId, pSyncNode->configPath); - goto _error; - } - - if (pSyncInfo->syncCfg.replicaNum > 0 && syncIsConfigChanged(&pSyncNode->pRaftCfg->cfg, &pSyncInfo->syncCfg)) { - sInfo("vgId:%d, use sync config from input options and write to cfg file", pSyncNode->vgId); - pSyncNode->pRaftCfg->cfg = pSyncInfo->syncCfg; - if (raftCfgPersist(pSyncNode->pRaftCfg) != 0) { - sError("vgId:%d, failed to persist raft cfg file at %s", pSyncNode->vgId, pSyncNode->configPath); - goto _error; - } - } else { - sInfo("vgId:%d, use sync config from raft cfg file", pSyncNode->vgId); - pSyncInfo->syncCfg = pSyncNode->pRaftCfg->cfg; - } - - raftCfgClose(pSyncNode->pRaftCfg); - pSyncNode->pRaftCfg = NULL; - } - - // init by SSyncInfo - pSyncNode->vgId = pSyncInfo->vgId; - SSyncCfg* pCfg = &pSyncInfo->syncCfg; - sInfo("vgId:%d, start to open sync node, replica:%d selfIndex:%d", pSyncNode->vgId, pCfg->replicaNum, pCfg->myIndex); - for (int32_t i = 0; i < pCfg->replicaNum; ++i) { - SNodeInfo* pNode = &pCfg->nodeInfo[i]; - sInfo("vgId:%d, index:%d ep:%s:%u", pSyncNode->vgId, i, pNode->nodeFqdn, pNode->nodePort); - } - memcpy(pSyncNode->path, pSyncInfo->path, sizeof(pSyncNode->path)); snprintf(pSyncNode->raftStorePath, sizeof(pSyncNode->raftStorePath), "%s%sraft_store.json", pSyncInfo->path, TD_DIRSEP); snprintf(pSyncNode->configPath, sizeof(pSyncNode->configPath), "%s%sraft_config.json", pSyncInfo->path, TD_DIRSEP); + if (!taosCheckExistFile(pSyncNode->configPath)) { + // create a new raft config file + sInfo("vgId:%d, create a new raft config file", pSyncNode->vgId); + pSyncNode->raftCfg.isStandBy = pSyncInfo->isStandBy; + pSyncNode->raftCfg.snapshotStrategy = pSyncInfo->snapshotStrategy; + pSyncNode->raftCfg.lastConfigIndex = SYNC_INDEX_INVALID; + pSyncNode->raftCfg.batchSize = pSyncInfo->batchSize; + pSyncNode->raftCfg.cfg = pSyncInfo->syncCfg; + pSyncNode->raftCfg.configIndexCount = 1; + pSyncNode->raftCfg.configIndexArr[0] = -1; + + if (syncWriteCfgFile(pSyncNode) != 0) { + sError("vgId:%d, failed to create sync cfg file", pSyncNode->vgId); + goto _error; + } + } else { + // update syncCfg by raft_config.json + if (syncReadCfgFile(pSyncNode) != 0) { + sError("vgId:%d, failed to read sync cfg file", pSyncNode->vgId); + goto _error; + } + + if (pSyncInfo->syncCfg.replicaNum > 0 && syncIsConfigChanged(&pSyncNode->raftCfg.cfg, &pSyncInfo->syncCfg)) { + sInfo("vgId:%d, use sync config from input options and write to cfg file", pSyncNode->vgId); + pSyncNode->raftCfg.cfg = pSyncInfo->syncCfg; + if (syncWriteCfgFile(pSyncNode) != 0) { + sError("vgId:%d, failed to write sync cfg file", pSyncNode->vgId); + goto _error; + } + } else { + sInfo("vgId:%d, use sync config from sync cfg file", pSyncNode->vgId); + pSyncInfo->syncCfg = pSyncNode->raftCfg.cfg; + } + } + + // init by SSyncInfo + pSyncNode->vgId = pSyncInfo->vgId; + SSyncCfg* pCfg = &pSyncNode->raftCfg.cfg; + sInfo("vgId:%d, start to open sync node, replica:%d selfIndex:%d", pSyncNode->vgId, pCfg->replicaNum, pCfg->myIndex); + for (int32_t i = 0; i < pCfg->replicaNum; ++i) { + SNodeInfo* pNode = &pCfg->nodeInfo[i]; + (void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); + sInfo("vgId:%d, index:%d ep:%s:%u dnode:%d cluster:%" PRId64, pSyncNode->vgId, i, pNode->nodeFqdn, pNode->nodePort, + pNode->nodeId, pNode->clusterId); + } + pSyncNode->pWal = pSyncInfo->pWal; pSyncNode->msgcb = pSyncInfo->msgcb; pSyncNode->syncSendMSg = pSyncInfo->syncSendMSg; @@ -916,26 +908,20 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { goto _error; } - // init raft config - pSyncNode->pRaftCfg = raftCfgOpen(pSyncNode->configPath); - if (pSyncNode->pRaftCfg == NULL) { - sError("vgId:%d, failed to open raft cfg file at %s", pSyncNode->vgId, pSyncNode->configPath); - goto _error; - } - // init internal - pSyncNode->myNodeInfo = pSyncNode->pRaftCfg->cfg.nodeInfo[pSyncNode->pRaftCfg->cfg.myIndex]; + pSyncNode->myNodeInfo = pSyncNode->raftCfg.cfg.nodeInfo[pSyncNode->raftCfg.cfg.myIndex]; if (!syncUtilNodeInfo2RaftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId)) { sError("vgId:%d, failed to determine my raft member id", pSyncNode->vgId); goto _error; } // init peersNum, peers, peersId - pSyncNode->peersNum = pSyncNode->pRaftCfg->cfg.replicaNum - 1; + pSyncNode->peersNum = pSyncNode->raftCfg.cfg.replicaNum - 1; int32_t j = 0; - for (int32_t i = 0; i < pSyncNode->pRaftCfg->cfg.replicaNum; ++i) { - if (i != pSyncNode->pRaftCfg->cfg.myIndex) { - pSyncNode->peersNodeInfo[j] = pSyncNode->pRaftCfg->cfg.nodeInfo[i]; + for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.replicaNum; ++i) { + if (i != pSyncNode->raftCfg.cfg.myIndex) { + pSyncNode->peersNodeInfo[j] = pSyncNode->raftCfg.cfg.nodeInfo[i]; + syncUtilNodeInfo2EpSet(&pSyncNode->peersNodeInfo[j], &pSyncNode->peersEpset[j]); j++; } } @@ -947,9 +933,9 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { } // init replicaNum, replicasId - pSyncNode->replicaNum = pSyncNode->pRaftCfg->cfg.replicaNum; - for (int32_t i = 0; i < pSyncNode->pRaftCfg->cfg.replicaNum; ++i) { - if (!syncUtilNodeInfo2RaftId(&pSyncNode->pRaftCfg->cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i])) { + pSyncNode->replicaNum = pSyncNode->raftCfg.cfg.replicaNum; + for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.replicaNum; ++i) { + if (!syncUtilNodeInfo2RaftId(&pSyncNode->raftCfg.cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i])) { sError("vgId:%d, failed to determine raft member id, replica:%d", pSyncNode->vgId, i); goto _error; } @@ -958,7 +944,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { // init raft algorithm pSyncNode->pFsm = pSyncInfo->pFsm; pSyncInfo->pFsm = NULL; - pSyncNode->quorum = syncUtilQuorum(pSyncNode->pRaftCfg->cfg.replicaNum); + pSyncNode->quorum = syncUtilQuorum(pSyncNode->raftCfg.cfg.replicaNum); pSyncNode->leaderCache = EMPTY_RAFT_ID; // init life cycle outside @@ -1293,8 +1279,6 @@ void syncNodeClose(SSyncNode* pSyncNode) { pSyncNode->pLogStore = NULL; syncLogBufferDestroy(pSyncNode->pLogBuf); pSyncNode->pLogBuf = NULL; - raftCfgClose(pSyncNode->pRaftCfg); - pSyncNode->pRaftCfg = NULL; syncNodeStopPingTimer(pSyncNode); syncNodeStopElectTimer(pSyncNode); @@ -1330,7 +1314,7 @@ void syncNodeClose(SSyncNode* pSyncNode) { taosMemoryFree(pSyncNode); } -ESyncStrategy syncNodeStrategy(SSyncNode* pSyncNode) { return pSyncNode->pRaftCfg->snapshotStrategy; } +ESyncStrategy syncNodeStrategy(SSyncNode* pSyncNode) { return pSyncNode->raftCfg.snapshotStrategy; } // timer control -------------- int32_t syncNodeStartPingTimer(SSyncNode* pSyncNode) { @@ -1392,7 +1376,7 @@ int32_t syncNodeRestartElectTimer(SSyncNode* pSyncNode, int32_t ms) { void syncNodeResetElectTimer(SSyncNode* pSyncNode) { int32_t electMS; - if (pSyncNode->pRaftCfg->isStandBy) { + if (pSyncNode->raftCfg.isStandBy) { electMS = TIMER_MAX_MS; } else { electMS = syncUtilElectRandomMS(pSyncNode->electBaseLine, 2 * pSyncNode->electBaseLine); @@ -1461,55 +1445,46 @@ int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode) { return 0; } -int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pSyncNode, SRpcMsg* pMsg) { - SEpSet epSet; - syncUtilRaftId2EpSet(destRaftId, &epSet); +int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pNode, SRpcMsg* pMsg) { + SEpSet* epSet = NULL; + for (int32_t i = 0; i < pNode->peersNum; ++i) { + if (destRaftId->addr == pNode->peersId[i].addr) { + epSet = &pNode->peersEpset[i]; + break; + } + } - if (pSyncNode->syncSendMSg != NULL) { + if (pNode->syncSendMSg != NULL && epSet != NULL) { syncUtilMsgHtoN(pMsg->pCont); pMsg->info.noResp = 1; - return pSyncNode->syncSendMSg(&epSet, pMsg); + return pNode->syncSendMSg(epSet, pMsg); } else { - sError("vgId:%d, sync send msg by id error, fp-send-msg is null", pSyncNode->vgId); + sError("vgId:%d, sync send msg by id error, fp:%p epset:%p", pNode->vgId, pNode->syncSendMSg, epSet); rpcFreeCont(pMsg->pCont); terrno = TSDB_CODE_SYN_INTERNAL_ERROR; return -1; } } -int32_t syncNodeSendMsgByInfo(const SNodeInfo* nodeInfo, SSyncNode* pSyncNode, SRpcMsg* pMsg) { - SEpSet epSet; - syncUtilNodeInfo2EpSet(nodeInfo, &epSet); - if (pSyncNode->syncSendMSg != NULL) { - // htonl - syncUtilMsgHtoN(pMsg->pCont); - - pMsg->info.noResp = 1; - pSyncNode->syncSendMSg(&epSet, pMsg); - } else { - sError("vgId:%d, sync send msg by info error, fp-send-msg is null", pSyncNode->vgId); - } - return 0; -} - -inline bool syncNodeInConfig(SSyncNode* pSyncNode, const SSyncCfg* config) { +inline bool syncNodeInConfig(SSyncNode* pNode, const SSyncCfg* pCfg) { bool b1 = false; bool b2 = false; - for (int32_t i = 0; i < config->replicaNum; ++i) { - if (strcmp((config->nodeInfo)[i].nodeFqdn, pSyncNode->myNodeInfo.nodeFqdn) == 0 && - (config->nodeInfo)[i].nodePort == pSyncNode->myNodeInfo.nodePort) { + for (int32_t i = 0; i < pCfg->replicaNum; ++i) { + if (strcmp(pCfg->nodeInfo[i].nodeFqdn, pNode->myNodeInfo.nodeFqdn) == 0 && + pCfg->nodeInfo[i].nodePort == pNode->myNodeInfo.nodePort) { b1 = true; break; } } - for (int32_t i = 0; i < config->replicaNum; ++i) { - SRaftId raftId; - raftId.addr = syncUtilAddr2U64((config->nodeInfo)[i].nodeFqdn, (config->nodeInfo)[i].nodePort); - raftId.vgId = pSyncNode->vgId; + for (int32_t i = 0; i < pCfg->replicaNum; ++i) { + SRaftId raftId = { + .addr = SYNC_ADDR(&pCfg->nodeInfo[i]), + .vgId = pNode->vgId, + }; - if (syncUtilSameId(&raftId, &(pSyncNode->myRaftId))) { + if (syncUtilSameId(&raftId, &pNode->myRaftId)) { b2 = true; break; } @@ -1533,14 +1508,14 @@ static bool syncIsConfigChanged(const SSyncCfg* pOldCfg, const SSyncCfg* pNewCfg } void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncIndex lastConfigChangeIndex) { - SSyncCfg oldConfig = pSyncNode->pRaftCfg->cfg; + SSyncCfg oldConfig = pSyncNode->raftCfg.cfg; if (!syncIsConfigChanged(&oldConfig, pNewConfig)) { sInfo("vgId:1, sync not reconfig since not changed"); return; } - pSyncNode->pRaftCfg->cfg = *pNewConfig; - pSyncNode->pRaftCfg->lastConfigIndex = lastConfigChangeIndex; + pSyncNode->raftCfg.cfg = *pNewConfig; + pSyncNode->raftCfg.lastConfigIndex = lastConfigChangeIndex; pSyncNode->configChangeNum++; @@ -1563,21 +1538,18 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde } // log begin config change - char oldCfgStr[1024] = {0}; - char newCfgStr[1024] = {0}; - syncCfg2SimpleStr(&oldConfig, oldCfgStr, sizeof(oldCfgStr)); - syncCfg2SimpleStr(pNewConfig, oldCfgStr, sizeof(oldCfgStr)); - sNInfo(pSyncNode, "begin do config change, from %s to %s", oldCfgStr, oldCfgStr); + sNInfo(pSyncNode, "begin do config change, from %d to %d", pSyncNode->vgId, oldConfig.replicaNum, + pNewConfig->replicaNum); if (IamInNew) { - pSyncNode->pRaftCfg->isStandBy = 0; // change isStandBy to normal + pSyncNode->raftCfg.isStandBy = 0; // change isStandBy to normal } if (isDrop) { - pSyncNode->pRaftCfg->isStandBy = 1; // set standby + pSyncNode->raftCfg.isStandBy = 1; // set standby } // add last config index - raftCfgAddConfigIndex(pSyncNode->pRaftCfg, lastConfigChangeIndex); + syncAddCfgIndex(pSyncNode, lastConfigChangeIndex); if (IamInNew) { //----------------------------------------- @@ -1594,15 +1566,16 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde } // init internal - pSyncNode->myNodeInfo = pSyncNode->pRaftCfg->cfg.nodeInfo[pSyncNode->pRaftCfg->cfg.myIndex]; + pSyncNode->myNodeInfo = pSyncNode->raftCfg.cfg.nodeInfo[pSyncNode->raftCfg.cfg.myIndex]; syncUtilNodeInfo2RaftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId); // init peersNum, peers, peersId - pSyncNode->peersNum = pSyncNode->pRaftCfg->cfg.replicaNum - 1; + pSyncNode->peersNum = pSyncNode->raftCfg.cfg.replicaNum - 1; int32_t j = 0; - for (int32_t i = 0; i < pSyncNode->pRaftCfg->cfg.replicaNum; ++i) { - if (i != pSyncNode->pRaftCfg->cfg.myIndex) { - pSyncNode->peersNodeInfo[j] = pSyncNode->pRaftCfg->cfg.nodeInfo[i]; + for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.replicaNum; ++i) { + if (i != pSyncNode->raftCfg.cfg.myIndex) { + pSyncNode->peersNodeInfo[j] = pSyncNode->raftCfg.cfg.nodeInfo[i]; + syncUtilNodeInfo2EpSet(&pSyncNode->peersNodeInfo[j], &pSyncNode->peersEpset[j]); j++; } } @@ -1611,13 +1584,13 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde } // init replicaNum, replicasId - pSyncNode->replicaNum = pSyncNode->pRaftCfg->cfg.replicaNum; - for (int32_t i = 0; i < pSyncNode->pRaftCfg->cfg.replicaNum; ++i) { - syncUtilNodeInfo2RaftId(&pSyncNode->pRaftCfg->cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i]); + pSyncNode->replicaNum = pSyncNode->raftCfg.cfg.replicaNum; + for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.replicaNum; ++i) { + syncUtilNodeInfo2RaftId(&pSyncNode->raftCfg.cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i]); } // update quorum first - pSyncNode->quorum = syncUtilQuorum(pSyncNode->pRaftCfg->cfg.replicaNum); + pSyncNode->quorum = syncUtilQuorum(pSyncNode->raftCfg.cfg.replicaNum); syncIndexMgrUpdate(pSyncNode->pNextIndex, pSyncNode); syncIndexMgrUpdate(pSyncNode->pMatchIndex, pSyncNode); @@ -1637,11 +1610,8 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde bool reset = false; for (int32_t j = 0; j < TSDB_MAX_REPLICA; ++j) { if (syncUtilSameId(&(pSyncNode->replicasId)[i], &oldReplicasId[j]) && oldSenders[j] != NULL) { - char host[128]; - uint16_t port; - syncUtilU642Addr((pSyncNode->replicasId)[i].addr, host, sizeof(host), &port); - sNTrace(pSyncNode, "snapshot sender reset for: %" PRId64 ", newIndex:%d, %s:%d, %p", - (pSyncNode->replicasId)[i].addr, i, host, port, oldSenders[j]); + sNTrace(pSyncNode, "snapshot sender reset for:%" PRId64 ", newIndex:%d, dnode:%d, %p", + (pSyncNode->replicasId)[i].addr, i, DID(&pSyncNode->replicasId[i]), oldSenders[j]); pSyncNode->senders[i] = oldSenders[j]; oldSenders[j] = NULL; @@ -1651,8 +1621,8 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde int32_t oldreplicaIndex = pSyncNode->senders[i]->replicaIndex; pSyncNode->senders[i]->replicaIndex = i; - sNTrace(pSyncNode, "snapshot sender udpate replicaIndex from %d to %d, %s:%d, %p, reset:%d", oldreplicaIndex, - i, host, port, pSyncNode->senders[i], reset); + sNTrace(pSyncNode, "snapshot sender udpate replicaIndex from %d to %d, dnode:%d, %p, reset:%d", + oldreplicaIndex, i, DID(&pSyncNode->replicasId[i]), pSyncNode->senders[i], reset); break; } @@ -1684,33 +1654,29 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde } // persist cfg - raftCfgPersist(pSyncNode->pRaftCfg); - - char tmpbuf[1024] = {0}; - snprintf(tmpbuf, sizeof(tmpbuf), "config change from %d to %d, index:%" PRId64 ", %s --> %s", - oldConfig.replicaNum, pNewConfig->replicaNum, lastConfigChangeIndex, oldCfgStr, newCfgStr); + syncWriteCfgFile(pSyncNode); // change isStandBy to normal (election timeout) if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { - syncNodeBecomeLeader(pSyncNode, tmpbuf); + syncNodeBecomeLeader(pSyncNode, ""); // Raft 3.6.2 Committing entries from previous terms syncNodeAppendNoop(pSyncNode); // syncMaybeAdvanceCommitIndex(pSyncNode); } else { - syncNodeBecomeFollower(pSyncNode, tmpbuf); + syncNodeBecomeFollower(pSyncNode, ""); } } else { // persist cfg - raftCfgPersist(pSyncNode->pRaftCfg); - sNInfo(pSyncNode, "do not config change from %d to %d, index:%" PRId64 ", %s --> %s", oldConfig.replicaNum, - pNewConfig->replicaNum, lastConfigChangeIndex, oldCfgStr, newCfgStr); + syncWriteCfgFile(pSyncNode); + sNInfo(pSyncNode, "do not config change from %d to %d", oldConfig.replicaNum, pNewConfig->replicaNum); } _END: // log end config change - sNInfo(pSyncNode, "end do config change, from %s to %s", oldCfgStr, newCfgStr); + sNInfo(pSyncNode, "end do config change, from %d to %d", pSyncNode->vgId, oldConfig.replicaNum, + pNewConfig->replicaNum); } // raft state change -------------- @@ -2889,9 +2855,10 @@ int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* p int32_t syncNodeUpdateNewConfigIndex(SSyncNode* ths, SSyncCfg* pNewCfg) { for (int32_t i = 0; i < pNewCfg->replicaNum; ++i) { - SRaftId raftId; - raftId.addr = syncUtilAddr2U64((pNewCfg->nodeInfo)[i].nodeFqdn, (pNewCfg->nodeInfo)[i].nodePort); - raftId.vgId = ths->vgId; + SRaftId raftId = { + .addr = SYNC_ADDR(&pNewCfg->nodeInfo[i]), + .vgId = ths->vgId, + }; if (syncUtilSameId(&(ths->myRaftId), &raftId)) { pNewCfg->myIndex = i; diff --git a/source/libs/sync/src/syncPipeline.c b/source/libs/sync/src/syncPipeline.c index ee649c268c..410986b87a 100644 --- a/source/libs/sync/src/syncPipeline.c +++ b/source/libs/sync/src/syncPipeline.c @@ -652,18 +652,15 @@ int32_t syncLogReplMgrProcessReplyInRecoveryMode(SSyncLogReplMgr* pMgr, SSyncNod SSyncLogBuffer* pBuf = pNode->pLogBuf; SRaftId destId = pMsg->srcId; ASSERT(pMgr->restored == false); - char host[64]; - uint16_t port; - syncUtilU642Addr(destId.addr, host, sizeof(host), &port); if (pMgr->endIndex == 0) { ASSERT(pMgr->startIndex == 0); ASSERT(pMgr->matchIndex == 0); if (pMsg->matchIndex < 0) { pMgr->restored = true; - sInfo("vgId:%d, sync log repl mgr restored. peer: %s:%d (%" PRIx64 "), mgr: rs(%d) [%" PRId64 " %" PRId64 + sInfo("vgId:%d, sync log repl mgr restored. peer: dnode:%d (%" PRIx64 "), mgr: rs(%d) [%" PRId64 " %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", - pNode->vgId, host, port, destId.addr, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, + pNode->vgId, DID(&destId), destId.addr, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); return 0; } @@ -678,21 +675,21 @@ int32_t syncLogReplMgrProcessReplyInRecoveryMode(SSyncLogReplMgr* pMgr, SSyncNod if (pMsg->success && pMsg->matchIndex == pMsg->lastSendIndex) { pMgr->matchIndex = pMsg->matchIndex; pMgr->restored = true; - sInfo("vgId:%d, sync log repl mgr restored. peer: %s:%d (%" PRIx64 "), mgr: rs(%d) [%" PRId64 " %" PRId64 + sInfo("vgId:%d, sync log repl mgr restored. peer: dnode:%d (%" PRIx64 "), mgr: rs(%d) [%" PRId64 " %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", - pNode->vgId, host, port, destId.addr, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, + pNode->vgId, DID(&destId), destId.addr, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); return 0; } if (pMsg->success == false && pMsg->matchIndex >= pMsg->lastSendIndex) { - sWarn("vgId:%d, failed to rollback match index. peer: %s:%d, match index: %" PRId64 ", last sent: %" PRId64, - pNode->vgId, host, port, pMsg->matchIndex, pMsg->lastSendIndex); + sWarn("vgId:%d, failed to rollback match index. peer: dnode:%d, match index: %" PRId64 ", last sent: %" PRId64, + pNode->vgId, DID(&destId), pMsg->matchIndex, pMsg->lastSendIndex); if (syncNodeStartSnapshot(pNode, &destId) < 0) { - sError("vgId:%d, failed to start snapshot for peer %s:%d", pNode->vgId, host, port); + sError("vgId:%d, failed to start snapshot for peer dnode:%d", pNode->vgId, DID(&destId)); return -1; } - sInfo("vgId:%d, snapshot replication to peer %s:%d", pNode->vgId, host, port); + sInfo("vgId:%d, snapshot replication to peer dnode:%d", pNode->vgId, DID(&destId)); return 0; } } @@ -707,10 +704,10 @@ int32_t syncLogReplMgrProcessReplyInRecoveryMode(SSyncLogReplMgr* pMgr, SSyncNod if (term < 0 || (term != pMsg->lastMatchTerm && (index + 1 == firstVer || index == firstVer))) { ASSERT(term >= 0 || terrno == TSDB_CODE_WAL_LOG_NOT_EXIST); if (syncNodeStartSnapshot(pNode, &destId) < 0) { - sError("vgId:%d, failed to start snapshot for peer %s:%d", pNode->vgId, host, port); + sError("vgId:%d, failed to start snapshot for peer dnode:%d", pNode->vgId, DID(&destId)); return -1; } - sInfo("vgId:%d, snapshot replication to peer %s:%d", pNode->vgId, host, port); + sInfo("vgId:%d, snapshot replication to peer dnode:%d", pNode->vgId, DID(&destId)); return 0; } diff --git a/source/libs/sync/src/syncRaftCfg.c b/source/libs/sync/src/syncRaftCfg.c index c609bfba93..86ea1f48cc 100644 --- a/source/libs/sync/src/syncRaftCfg.c +++ b/source/libs/sync/src/syncRaftCfg.c @@ -16,382 +16,226 @@ #define _DEFAULT_SOURCE #include "syncRaftCfg.h" #include "syncUtil.h" +#include "tjson.h" -// file must already exist! -SRaftCfgIndex *raftCfgIndexOpen(const char *path) { - SRaftCfgIndex *pRaftCfgIndex = taosMemoryMalloc(sizeof(SRaftCfg)); - snprintf(pRaftCfgIndex->path, sizeof(pRaftCfgIndex->path), "%s", path); +static int32_t syncEncodeSyncCfg(const void *pObj, SJson *pJson) { + SSyncCfg *pCfg = (SSyncCfg *)pObj; + if (tjsonAddDoubleToObject(pJson, "replicaNum", pCfg->replicaNum) < 0) return -1; + if (tjsonAddDoubleToObject(pJson, "myIndex", pCfg->myIndex) < 0) return -1; - pRaftCfgIndex->pFile = taosOpenFile(pRaftCfgIndex->path, TD_FILE_READ | TD_FILE_WRITE); - ASSERT(pRaftCfgIndex->pFile != NULL); - - taosLSeekFile(pRaftCfgIndex->pFile, 0, SEEK_SET); - - int32_t bufLen = MAX_CONFIG_INDEX_COUNT * 16; - char *pBuf = taosMemoryMalloc(bufLen); - memset(pBuf, 0, bufLen); - int64_t len = taosReadFile(pRaftCfgIndex->pFile, pBuf, bufLen); - ASSERT(len > 0); - - int32_t ret = raftCfgIndexFromStr(pBuf, pRaftCfgIndex); - ASSERT(ret == 0); - - taosMemoryFree(pBuf); - - return pRaftCfgIndex; -} - -int32_t raftCfgIndexClose(SRaftCfgIndex *pRaftCfgIndex) { - if (pRaftCfgIndex != NULL) { - int64_t ret = taosCloseFile(&(pRaftCfgIndex->pFile)); - ASSERT(ret == 0); - taosMemoryFree(pRaftCfgIndex); - } - return 0; -} - -int32_t raftCfgIndexPersist(SRaftCfgIndex *pRaftCfgIndex) { - ASSERT(pRaftCfgIndex != NULL); - - char *s = raftCfgIndex2Str(pRaftCfgIndex); - taosLSeekFile(pRaftCfgIndex->pFile, 0, SEEK_SET); - - int64_t ret = taosWriteFile(pRaftCfgIndex->pFile, s, strlen(s) + 1); - ASSERT(ret == strlen(s) + 1); - - taosMemoryFree(s); - taosFsyncFile(pRaftCfgIndex->pFile); - return 0; -} - -int32_t raftCfgIndexAddConfigIndex(SRaftCfgIndex *pRaftCfgIndex, SyncIndex configIndex) { - ASSERT(pRaftCfgIndex->configIndexCount <= MAX_CONFIG_INDEX_COUNT); - (pRaftCfgIndex->configIndexArr)[pRaftCfgIndex->configIndexCount] = configIndex; - ++(pRaftCfgIndex->configIndexCount); - return 0; -} - -cJSON *raftCfgIndex2Json(SRaftCfgIndex *pRaftCfgIndex) { - cJSON *pRoot = cJSON_CreateObject(); - - cJSON_AddNumberToObject(pRoot, "configIndexCount", pRaftCfgIndex->configIndexCount); - cJSON *pIndexArr = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "configIndexArr", pIndexArr); - for (int i = 0; i < pRaftCfgIndex->configIndexCount; ++i) { - char buf64[128]; - snprintf(buf64, sizeof(buf64), "%" PRId64, (pRaftCfgIndex->configIndexArr)[i]); - cJSON *pIndexObj = cJSON_CreateObject(); - cJSON_AddStringToObject(pIndexObj, "index", buf64); - cJSON_AddItemToArray(pIndexArr, pIndexObj); - } - - cJSON *pJson = cJSON_CreateObject(); - cJSON_AddItemToObject(pJson, "SRaftCfgIndex", pRoot); - return pJson; -} - -char *raftCfgIndex2Str(SRaftCfgIndex *pRaftCfgIndex) { - cJSON *pJson = raftCfgIndex2Json(pRaftCfgIndex); - char *serialized = cJSON_Print(pJson); - cJSON_Delete(pJson); - return serialized; -} - -int32_t raftCfgIndexFromJson(const cJSON *pRoot, SRaftCfgIndex *pRaftCfgIndex) { - cJSON *pJson = cJSON_GetObjectItem(pRoot, "SRaftCfgIndex"); - - cJSON *pJsonConfigIndexCount = cJSON_GetObjectItem(pJson, "configIndexCount"); - pRaftCfgIndex->configIndexCount = cJSON_GetNumberValue(pJsonConfigIndexCount); - - cJSON *pIndexArr = cJSON_GetObjectItem(pJson, "configIndexArr"); - int arraySize = cJSON_GetArraySize(pIndexArr); - ASSERT(arraySize == pRaftCfgIndex->configIndexCount); - - memset(pRaftCfgIndex->configIndexArr, 0, sizeof(pRaftCfgIndex->configIndexArr)); - for (int i = 0; i < arraySize; ++i) { - cJSON *pIndexObj = cJSON_GetArrayItem(pIndexArr, i); - ASSERT(pIndexObj != NULL); - - cJSON *pIndex = cJSON_GetObjectItem(pIndexObj, "index"); - ASSERT(cJSON_IsString(pIndex)); - (pRaftCfgIndex->configIndexArr)[i] = atoll(pIndex->valuestring); + SJson *nodeInfo = tjsonCreateArray(); + if (nodeInfo == NULL) return -1; + if (tjsonAddItemToObject(pJson, "nodeInfo", nodeInfo) < 0) return -1; + for (int32_t i = 0; i < pCfg->replicaNum; ++i) { + SJson *info = tjsonCreateObject(); + if (info == NULL) return -1; + if (tjsonAddDoubleToObject(info, "nodePort", pCfg->nodeInfo[i].nodePort) < 0) return -1; + if (tjsonAddStringToObject(info, "nodeFqdn", pCfg->nodeInfo[i].nodeFqdn) < 0) return -1; + if (tjsonAddIntegerToObject(info, "nodeId", pCfg->nodeInfo[i].nodeId) < 0) return -1; + if (tjsonAddIntegerToObject(info, "clusterId", pCfg->nodeInfo[i].clusterId) < 0) return -1; + if (tjsonAddItemToArray(nodeInfo, info) < 0) return -1; } return 0; } -int32_t raftCfgIndexFromStr(const char *s, SRaftCfgIndex *pRaftCfgIndex) { - cJSON *pRoot = cJSON_Parse(s); - ASSERT(pRoot != NULL); +static int32_t syncEncodeRaftCfg(const void *pObj, SJson *pJson) { + SRaftCfg *pCfg = (SRaftCfg *)pObj; + if (tjsonAddObject(pJson, "SSyncCfg", syncEncodeSyncCfg, (void *)&pCfg->cfg) < 0) return -1; + if (tjsonAddDoubleToObject(pJson, "isStandBy", pCfg->isStandBy) < 0) return -1; + if (tjsonAddDoubleToObject(pJson, "snapshotStrategy", pCfg->snapshotStrategy) < 0) return -1; + if (tjsonAddDoubleToObject(pJson, "batchSize", pCfg->batchSize) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "lastConfigIndex", pCfg->lastConfigIndex) < 0) return -1; + if (tjsonAddDoubleToObject(pJson, "configIndexCount", pCfg->configIndexCount) < 0) return -1; - int32_t ret = raftCfgIndexFromJson(pRoot, pRaftCfgIndex); - ASSERT(ret == 0); + SJson *configIndexArr = tjsonCreateArray(); + if (configIndexArr == NULL) return -1; + if (tjsonAddItemToObject(pJson, "configIndexArr", configIndexArr) < 0) return -1; + for (int32_t i = 0; i < pCfg->configIndexCount; ++i) { + SJson *configIndex = tjsonCreateObject(); + if (configIndex == NULL) return -1; + if (tjsonAddIntegerToObject(configIndex, "index", pCfg->configIndexArr[i]) < 0) return -1; + if (tjsonAddItemToArray(configIndexArr, configIndex) < 0) return -1; + } - cJSON_Delete(pRoot); return 0; } -int32_t raftCfgIndexCreateFile(const char *path) { - TdFilePtr pFile = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE); +int32_t syncWriteCfgFile(SSyncNode *pNode) { + int32_t code = -1; + char *buffer = NULL; + SJson *pJson = NULL; + TdFilePtr pFile = NULL; + const char *realfile = pNode->configPath; + SRaftCfg *pCfg = &pNode->raftCfg; + char file[PATH_MAX] = {0}; + snprintf(file, sizeof(file), "%s.bak", realfile); + + pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); if (pFile == NULL) { - int32_t err = terrno; - const char *errStr = tstrerror(err); - int32_t sysErr = errno; - const char *sysErrStr = strerror(errno); - sError("create raft cfg index file error, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", err, err, errStr, sysErr, - sysErrStr); - ASSERT(0); - - return -1; + terrno = TAOS_SYSTEM_ERROR(errno); + sError("vgId:%d, failed to open sync cfg file:%s since %s", pNode->vgId, realfile, terrstr()); + goto _OVER; } - SRaftCfgIndex raftCfgIndex; - memset(raftCfgIndex.configIndexArr, 0, sizeof(raftCfgIndex.configIndexArr)); - raftCfgIndex.configIndexCount = 1; - raftCfgIndex.configIndexArr[0] = -1; + terrno = TSDB_CODE_OUT_OF_MEMORY; + pJson = tjsonCreateObject(); + if (pJson == NULL) goto _OVER; + if (tjsonAddObject(pJson, "RaftCfg", syncEncodeRaftCfg, pCfg) < 0) goto _OVER; - char *s = raftCfgIndex2Str(&raftCfgIndex); - int64_t ret = taosWriteFile(pFile, s, strlen(s) + 1); - ASSERT(ret == strlen(s) + 1); + buffer = tjsonToString(pJson); + if (buffer == NULL) goto _OVER; - taosMemoryFree(s); + int32_t len = strlen(buffer); + if (taosWriteFile(pFile, buffer, len) <= 0) goto _OVER; + if (taosFsyncFile(pFile) < 0) goto _OVER; taosCloseFile(&pFile); - return 0; -} -// --------------------------------------- -// file must already exist! -SRaftCfg *raftCfgOpen(const char *path) { - SRaftCfg *pCfg = taosMemoryMalloc(sizeof(SRaftCfg)); - snprintf(pCfg->path, sizeof(pCfg->path), "%s", path); - - pCfg->pFile = taosOpenFile(pCfg->path, TD_FILE_READ | TD_FILE_WRITE); - ASSERT(pCfg->pFile != NULL); - - taosLSeekFile(pCfg->pFile, 0, SEEK_SET); - - char buf[CONFIG_FILE_LEN] = {0}; - int len = taosReadFile(pCfg->pFile, buf, sizeof(buf)); - ASSERT(len > 0); - - int32_t ret = raftCfgFromStr(buf, pCfg); - ASSERT(ret == 0); - - return pCfg; -} - -int32_t raftCfgClose(SRaftCfg *pRaftCfg) { - int64_t ret = taosCloseFile(&(pRaftCfg->pFile)); - ASSERT(ret == 0); - taosMemoryFree(pRaftCfg); - return 0; -} - -int32_t raftCfgPersist(SRaftCfg *pRaftCfg) { - ASSERT(pRaftCfg != NULL); - - char *s = raftCfg2Str(pRaftCfg); - taosLSeekFile(pRaftCfg->pFile, 0, SEEK_SET); - - char buf[CONFIG_FILE_LEN] = {0}; - memset(buf, 0, sizeof(buf)); - - if (strlen(s) + 1 > CONFIG_FILE_LEN) { - sError("too long config str:%s", s); - ASSERT(0); + if (taosRenameFile(file, realfile) != 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + sError("vgId:%d, failed to rename sync cfg file:%s to %s since %s", pNode->vgId, file, realfile, terrstr()); + goto _OVER; } - snprintf(buf, sizeof(buf), "%s", s); - int64_t ret = taosWriteFile(pRaftCfg->pFile, buf, sizeof(buf)); - ASSERT(ret == sizeof(buf)); + code = 0; + sInfo("vgId:%d, succeed to write sync cfg file:%s, len:%d", pNode->vgId, realfile, len); - // int64_t ret = taosWriteFile(pRaftCfg->pFile, s, strlen(s) + 1); - // ASSERT(ret == strlen(s) + 1); +_OVER: + if (pJson != NULL) tjsonDelete(pJson); + if (buffer != NULL) taosMemoryFree(buffer); + if (pFile != NULL) taosCloseFile(&pFile); - taosMemoryFree(s); - taosFsyncFile(pRaftCfg->pFile); - return 0; -} - -int32_t raftCfgAddConfigIndex(SRaftCfg *pRaftCfg, SyncIndex configIndex) { - ASSERT(pRaftCfg->configIndexCount <= MAX_CONFIG_INDEX_COUNT); - (pRaftCfg->configIndexArr)[pRaftCfg->configIndexCount] = configIndex; - ++(pRaftCfg->configIndexCount); - return 0; -} - -cJSON *syncCfg2Json(SSyncCfg *pSyncCfg) { - char u64buf[128] = {0}; - cJSON *pRoot = cJSON_CreateObject(); - - if (pSyncCfg != NULL) { - cJSON_AddNumberToObject(pRoot, "replicaNum", pSyncCfg->replicaNum); - cJSON_AddNumberToObject(pRoot, "myIndex", pSyncCfg->myIndex); - - cJSON *pNodeInfoArr = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "nodeInfo", pNodeInfoArr); - for (int i = 0; i < pSyncCfg->replicaNum; ++i) { - cJSON *pNodeInfo = cJSON_CreateObject(); - cJSON_AddNumberToObject(pNodeInfo, "nodePort", ((pSyncCfg->nodeInfo)[i]).nodePort); - cJSON_AddStringToObject(pNodeInfo, "nodeFqdn", ((pSyncCfg->nodeInfo)[i]).nodeFqdn); - cJSON_AddItemToArray(pNodeInfoArr, pNodeInfo); - } + if (code != 0) { + sError("vgId:%d, failed to write sync cfg file:%s since %s", pNode->vgId, realfile, terrstr()); } - - return pRoot; -} - -int32_t syncCfgFromJson(const cJSON *pRoot, SSyncCfg *pSyncCfg) { - memset(pSyncCfg, 0, sizeof(SSyncCfg)); - // cJSON *pJson = cJSON_GetObjectItem(pRoot, "SSyncCfg"); - const cJSON *pJson = pRoot; - - cJSON *pReplicaNum = cJSON_GetObjectItem(pJson, "replicaNum"); - ASSERT(cJSON_IsNumber(pReplicaNum)); - pSyncCfg->replicaNum = cJSON_GetNumberValue(pReplicaNum); - - cJSON *pMyIndex = cJSON_GetObjectItem(pJson, "myIndex"); - ASSERT(cJSON_IsNumber(pMyIndex)); - pSyncCfg->myIndex = cJSON_GetNumberValue(pMyIndex); - - cJSON *pNodeInfoArr = cJSON_GetObjectItem(pJson, "nodeInfo"); - int arraySize = cJSON_GetArraySize(pNodeInfoArr); - ASSERT(arraySize == pSyncCfg->replicaNum); - - for (int i = 0; i < arraySize; ++i) { - cJSON *pNodeInfo = cJSON_GetArrayItem(pNodeInfoArr, i); - ASSERT(pNodeInfo != NULL); - - cJSON *pNodePort = cJSON_GetObjectItem(pNodeInfo, "nodePort"); - ASSERT(cJSON_IsNumber(pNodePort)); - ((pSyncCfg->nodeInfo)[i]).nodePort = cJSON_GetNumberValue(pNodePort); - - cJSON *pNodeFqdn = cJSON_GetObjectItem(pNodeInfo, "nodeFqdn"); - ASSERT(cJSON_IsString(pNodeFqdn)); - snprintf(((pSyncCfg->nodeInfo)[i]).nodeFqdn, sizeof(((pSyncCfg->nodeInfo)[i]).nodeFqdn), "%s", - pNodeFqdn->valuestring); - } - - return 0; -} - -cJSON *raftCfg2Json(SRaftCfg *pRaftCfg) { - cJSON *pRoot = cJSON_CreateObject(); - cJSON_AddItemToObject(pRoot, "SSyncCfg", syncCfg2Json(&(pRaftCfg->cfg))); - cJSON_AddNumberToObject(pRoot, "isStandBy", pRaftCfg->isStandBy); - cJSON_AddNumberToObject(pRoot, "snapshotStrategy", pRaftCfg->snapshotStrategy); - cJSON_AddNumberToObject(pRoot, "batchSize", pRaftCfg->batchSize); - - char buf64[128]; - snprintf(buf64, sizeof(buf64), "%" PRId64, pRaftCfg->lastConfigIndex); - cJSON_AddStringToObject(pRoot, "lastConfigIndex", buf64); - - cJSON_AddNumberToObject(pRoot, "configIndexCount", pRaftCfg->configIndexCount); - cJSON *pIndexArr = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "configIndexArr", pIndexArr); - for (int i = 0; i < pRaftCfg->configIndexCount; ++i) { - snprintf(buf64, sizeof(buf64), "%" PRId64, (pRaftCfg->configIndexArr)[i]); - cJSON *pIndexObj = cJSON_CreateObject(); - cJSON_AddStringToObject(pIndexObj, "index", buf64); - cJSON_AddItemToArray(pIndexArr, pIndexObj); - } - - cJSON *pJson = cJSON_CreateObject(); - cJSON_AddItemToObject(pJson, "RaftCfg", pRoot); - return pJson; -} - -char *raftCfg2Str(SRaftCfg *pRaftCfg) { - cJSON *pJson = raftCfg2Json(pRaftCfg); - char *serialized = cJSON_Print(pJson); - cJSON_Delete(pJson); - return serialized; -} - -int32_t raftCfgCreateFile(SSyncCfg *pCfg, SRaftCfgMeta meta, const char *path) { - TdFilePtr pFile = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE); - if (pFile == NULL) { - int32_t err = terrno; - const char *errStr = tstrerror(err); - int32_t sysErr = errno; - const char *sysErrStr = strerror(errno); - sError("create raft cfg file error, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", err, err, errStr, sysErr, sysErrStr); - return -1; - } - - SRaftCfg raftCfg; - raftCfg.cfg = *pCfg; - raftCfg.isStandBy = meta.isStandBy; - raftCfg.batchSize = meta.batchSize; - raftCfg.snapshotStrategy = meta.snapshotStrategy; - raftCfg.lastConfigIndex = meta.lastConfigIndex; - raftCfg.configIndexCount = 1; - memset(raftCfg.configIndexArr, 0, sizeof(raftCfg.configIndexArr)); - raftCfg.configIndexArr[0] = -1; - char *s = raftCfg2Str(&raftCfg); - - char buf[CONFIG_FILE_LEN] = {0}; - memset(buf, 0, sizeof(buf)); - ASSERT(strlen(s) + 1 <= CONFIG_FILE_LEN); - snprintf(buf, sizeof(buf), "%s", s); - int64_t ret = taosWriteFile(pFile, buf, sizeof(buf)); - ASSERT(ret == sizeof(buf)); - - // int64_t ret = taosWriteFile(pFile, s, strlen(s) + 1); - // ASSERT(ret == strlen(s) + 1); - - taosMemoryFree(s); - taosCloseFile(&pFile); - return 0; -} - -int32_t raftCfgFromJson(const cJSON *pRoot, SRaftCfg *pRaftCfg) { - // memset(pRaftCfg, 0, sizeof(SRaftCfg)); - cJSON *pJson = cJSON_GetObjectItem(pRoot, "RaftCfg"); - - cJSON *pJsonIsStandBy = cJSON_GetObjectItem(pJson, "isStandBy"); - pRaftCfg->isStandBy = cJSON_GetNumberValue(pJsonIsStandBy); - - cJSON *pJsonBatchSize = cJSON_GetObjectItem(pJson, "batchSize"); - pRaftCfg->batchSize = cJSON_GetNumberValue(pJsonBatchSize); - - cJSON *pJsonSnapshotStrategy = cJSON_GetObjectItem(pJson, "snapshotStrategy"); - pRaftCfg->snapshotStrategy = cJSON_GetNumberValue(pJsonSnapshotStrategy); - - cJSON *pJsonLastConfigIndex = cJSON_GetObjectItem(pJson, "lastConfigIndex"); - pRaftCfg->lastConfigIndex = atoll(cJSON_GetStringValue(pJsonLastConfigIndex)); - - cJSON *pJsonConfigIndexCount = cJSON_GetObjectItem(pJson, "configIndexCount"); - pRaftCfg->configIndexCount = cJSON_GetNumberValue(pJsonConfigIndexCount); - - cJSON *pIndexArr = cJSON_GetObjectItem(pJson, "configIndexArr"); - int arraySize = cJSON_GetArraySize(pIndexArr); - ASSERT(arraySize == pRaftCfg->configIndexCount); - - memset(pRaftCfg->configIndexArr, 0, sizeof(pRaftCfg->configIndexArr)); - for (int i = 0; i < arraySize; ++i) { - cJSON *pIndexObj = cJSON_GetArrayItem(pIndexArr, i); - ASSERT(pIndexObj != NULL); - - cJSON *pIndex = cJSON_GetObjectItem(pIndexObj, "index"); - ASSERT(cJSON_IsString(pIndex)); - (pRaftCfg->configIndexArr)[i] = atoll(pIndex->valuestring); - } - - cJSON *pJsonSyncCfg = cJSON_GetObjectItem(pJson, "SSyncCfg"); - int32_t code = syncCfgFromJson(pJsonSyncCfg, &(pRaftCfg->cfg)); - ASSERT(code == 0); - return code; } -int32_t raftCfgFromStr(const char *s, SRaftCfg *pRaftCfg) { - cJSON *pRoot = cJSON_Parse(s); - ASSERT(pRoot != NULL); +static int32_t syncDecodeSyncCfg(const SJson *pJson, void *pObj) { + SSyncCfg *pCfg = (SSyncCfg *)pObj; + int32_t code = 0; - int32_t ret = raftCfgFromJson(pRoot, pRaftCfg); - ASSERT(ret == 0); + tjsonGetInt32ValueFromDouble(pJson, "replicaNum", pCfg->replicaNum, code); + if (code < 0) return -1; + tjsonGetInt32ValueFromDouble(pJson, "myIndex", pCfg->myIndex, code); + if (code < 0) return -1; + + SJson *nodeInfo = tjsonGetObjectItem(pJson, "nodeInfo"); + if (nodeInfo == NULL) return -1; + pCfg->replicaNum = tjsonGetArraySize(nodeInfo); + + for (int32_t i = 0; i < pCfg->replicaNum; ++i) { + SJson *info = tjsonGetArrayItem(nodeInfo, i); + if (info == NULL) return -1; + tjsonGetUInt16ValueFromDouble(info, "nodePort", pCfg->nodeInfo[i].nodePort, code); + if (code < 0) return -1; + code = tjsonGetStringValue(info, "nodeFqdn", pCfg->nodeInfo[i].nodeFqdn); + if (code < 0) return -1; + tjsonGetNumberValue(info, "nodeId", pCfg->nodeInfo[i].nodeId, code); + tjsonGetNumberValue(info, "clusterId", pCfg->nodeInfo[i].clusterId, code); + } - cJSON_Delete(pRoot); return 0; } + +static int32_t syncDecodeRaftCfg(const SJson *pJson, void *pObj) { + SRaftCfg *pCfg = (SRaftCfg *)pObj; + int32_t code = 0; + + if (tjsonToObject(pJson, "SSyncCfg", syncDecodeSyncCfg, (void *)&pCfg->cfg) < 0) return -1; + + tjsonGetInt8ValueFromDouble(pJson, "isStandBy", pCfg->isStandBy, code); + if (code < 0) return -1; + tjsonGetInt8ValueFromDouble(pJson, "snapshotStrategy", pCfg->snapshotStrategy, code); + if (code < 0) return -1; + tjsonGetInt32ValueFromDouble(pJson, "batchSize", pCfg->batchSize, code); + if (code < 0) return -1; + tjsonGetNumberValue(pJson, "lastConfigIndex", pCfg->lastConfigIndex, code); + if (code < 0) return -1; + tjsonGetInt32ValueFromDouble(pJson, "configIndexCount", pCfg->configIndexCount, code); + + SJson *configIndexArr = tjsonGetObjectItem(pJson, "configIndexArr"); + if (configIndexArr == NULL) return -1; + + pCfg->configIndexCount = tjsonGetArraySize(configIndexArr); + for (int32_t i = 0; i < pCfg->configIndexCount; ++i) { + SJson *configIndex = tjsonGetArrayItem(configIndexArr, i); + if (configIndex == NULL) return -1; + tjsonGetNumberValue(configIndex, "index", pCfg->configIndexArr[i], code); + if (code < 0) return -1; + } + + return 0; +} + +int32_t syncReadCfgFile(SSyncNode *pNode) { + int32_t code = -1; + TdFilePtr pFile = NULL; + char *pData = NULL; + SJson *pJson = NULL; + const char *file = pNode->configPath; + SRaftCfg *pCfg = &pNode->raftCfg; + + pFile = taosOpenFile(file, TD_FILE_READ); + if (pFile == NULL) { + terrno = TAOS_SYSTEM_ERROR(errno); + sError("vgId:%d, failed to open sync cfg file:%s since %s", pNode->vgId, file, terrstr()); + goto _OVER; + } + + int64_t size = 0; + if (taosFStatFile(pFile, &size, NULL) < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + sError("vgId:%d, failed to fstat sync cfg file:%s since %s", pNode->vgId, file, terrstr()); + goto _OVER; + } + + pData = taosMemoryMalloc(size + 1); + if (pData == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + + if (taosReadFile(pFile, pData, size) != size) { + terrno = TAOS_SYSTEM_ERROR(errno); + sError("vgId:%d, failed to read sync cfg file:%s since %s", pNode->vgId, file, terrstr()); + goto _OVER; + } + + pData[size] = '\0'; + + pJson = tjsonParse(pData); + if (pJson == NULL) { + terrno = TSDB_CODE_INVALID_JSON_FORMAT; + goto _OVER; + } + + if (tjsonToObject(pJson, "RaftCfg", syncDecodeRaftCfg, (void *)pCfg) < 0) { + terrno = TSDB_CODE_INVALID_JSON_FORMAT; + goto _OVER; + } + + code = 0; + sInfo("vgId:%d, succceed to read sync cfg file %s", pNode->vgId, file); + +_OVER: + if (pData != NULL) taosMemoryFree(pData); + if (pJson != NULL) cJSON_Delete(pJson); + if (pFile != NULL) taosCloseFile(&pFile); + + if (code != 0) { + sError("vgId:%d, failed to read sync cfg file:%s since %s", pNode->vgId, file, terrstr()); + } + return code; +} + +int32_t syncAddCfgIndex(SSyncNode *pNode, SyncIndex cfgIndex) { + SRaftCfg *pCfg = &pNode->raftCfg; + if (pCfg->configIndexCount <= MAX_CONFIG_INDEX_COUNT) { + return -1; + } + + pCfg->configIndexArr[pCfg->configIndexCount] = cfgIndex; + pCfg->configIndexCount++; + return 0; +} \ No newline at end of file diff --git a/source/libs/sync/src/syncRaftStore.c b/source/libs/sync/src/syncRaftStore.c index e328ed3d31..b19cda2a44 100644 --- a/source/libs/sync/src/syncRaftStore.c +++ b/source/libs/sync/src/syncRaftStore.c @@ -112,13 +112,6 @@ int32_t raftStoreSerialize(SRaftStore *pRaftStore, char *buf, size_t len) { cJSON_AddNumberToObject(pRoot, "vote_for_vgid", pRaftStore->voteFor.vgId); - uint64_t u64 = pRaftStore->voteFor.addr; - char host[128] = {0}; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pRoot, "addr_host", host); - cJSON_AddNumberToObject(pRoot, "addr_port", port); - char *serialized = cJSON_Print(pRoot); int len2 = strlen(serialized); ASSERT(len2 < len); diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index 0f56921ec7..e3058768f8 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -107,10 +107,7 @@ int32_t syncNodeReplicateOne(SSyncNode* pSyncNode, SRaftId* pDestId, bool snapsh pMsg = rpcMsg.pCont; } else { - char host[64]; - uint16_t port; - syncUtilU642Addr(pDestId->addr, host, sizeof(host), &port); - sNError(pSyncNode, "replicate to %s:%d error, next-index:%" PRId64, host, port, nextIndex); + sNError(pSyncNode, "replicate to dnode:%d error, next-index:%" PRId64, DID(pDestId), nextIndex); return -1; } } @@ -171,10 +168,7 @@ int32_t syncNodeReplicateOld(SSyncNode* pSyncNode) { SRaftId* pDestId = &(pSyncNode->peersId[i]); ret = syncNodeReplicateOne(pSyncNode, pDestId, true); if (ret != 0) { - char host[64]; - int16_t port; - syncUtilU642Addr(pDestId->addr, host, sizeof(host), &port); - sError("vgId:%d, do append entries error for %s:%d", pSyncNode->vgId, host, port); + sError("vgId:%d, do append entries error for dnode:%d", pSyncNode->vgId, DID(pDestId)); } } @@ -183,7 +177,6 @@ int32_t syncNodeReplicateOld(SSyncNode* pSyncNode) { int32_t syncNodeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg) { SyncAppendEntries* pMsg = pRpcMsg->pCont; - int32_t ret = 0; pMsg->destId = *destRaftId; syncNodeSendMsgById(destRaftId, pSyncNode, pRpcMsg); return 0; @@ -229,11 +222,7 @@ int32_t syncNodeMaybeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* dest if (syncNodeNeedSendAppendEntries(pSyncNode, destRaftId, pMsg)) { ret = syncNodeSendAppendEntries(pSyncNode, destRaftId, pRpcMsg); } else { - char logBuf[128]; - char host[64]; - int16_t port; - syncUtilU642Addr(destRaftId->addr, host, sizeof(host), &port); - sNTrace(pSyncNode, "do not repcate to %s:%d for index:%" PRId64, host, port, pMsg->prevLogIndex + 1); + sNTrace(pSyncNode, "do not repcate to dnode:%d for index:%" PRId64, DID(destRaftId), pMsg->prevLogIndex + 1); rpcFreeCont(pRpcMsg->pCont); } diff --git a/source/libs/sync/src/syncRespMgr.c b/source/libs/sync/src/syncRespMgr.c index 503c56b1e7..b55aae4c76 100644 --- a/source/libs/sync/src/syncRespMgr.c +++ b/source/libs/sync/src/syncRespMgr.c @@ -118,12 +118,12 @@ static void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) { SRespStub *pStub = (SRespStub *)taosHashIterate(pObj->pRespHash, NULL); int cnt = 0; int sum = 0; - SSyncNode *pSyncNode = pObj->data; + SSyncNode *pNode = pObj->data; SArray *delIndexArray = taosArrayInit(4, sizeof(uint64_t)); if (delIndexArray == NULL) return; - sDebug("vgId:%d, resp manager begin clean by ttl", pSyncNode->vgId); + sDebug("vgId:%d, resp manager begin clean by ttl", pNode->vgId); while (pStub) { size_t len; void *key = taosHashGetKey(pStub, &len); @@ -140,20 +140,18 @@ static void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) { .lastConfigIndex = SYNC_INDEX_INVALID, .isWeak = false, .code = TSDB_CODE_SYN_TIMEOUT, - .state = pSyncNode->state, + .state = pNode->state, .seqNum = *pSeqNum, .term = SYNC_TERM_INVALID, - .currentTerm = pSyncNode->pRaftStore->currentTerm, + .currentTerm = pNode->pRaftStore->currentTerm, .flag = 0, }; pStub->rpcMsg.pCont = NULL; pStub->rpcMsg.contLen = 0; - // TODO: and make rpcMsg body, call commit cb - // pSyncNode->pFsm->FpCommitCb(pSyncNode->pFsm, &pStub->rpcMsg, cbMeta); SRpcMsg rpcMsg = {.info = pStub->rpcMsg.info, .code = TSDB_CODE_SYN_TIMEOUT}; - sInfo("vgId:%d, message handle:%p expired, type:%s ahandle:%p", pSyncNode->vgId, rpcMsg.info.handle, + sInfo("vgId:%d, message handle:%p expired, type:%s ahandle:%p", pNode->vgId, rpcMsg.info.handle, TMSG_INFO(pStub->rpcMsg.msgType), rpcMsg.info.ahandle); rpcSendResponse(&rpcMsg); } @@ -162,12 +160,12 @@ static void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) { } int32_t arraySize = taosArrayGetSize(delIndexArray); - sDebug("vgId:%d, resp manager end clean by ttl, sum:%d, cnt:%d, array-size:%d", pSyncNode->vgId, sum, cnt, arraySize); + sDebug("vgId:%d, resp manager end clean by ttl, sum:%d, cnt:%d, array-size:%d", pNode->vgId, sum, cnt, arraySize); for (int32_t i = 0; i < arraySize; ++i) { uint64_t *pSeqNum = taosArrayGet(delIndexArray, i); taosHashRemove(pObj->pRespHash, pSeqNum, sizeof(uint64_t)); - sDebug("vgId:%d, resp manager clean by ttl, seq:%" PRId64, pSyncNode->vgId, *pSeqNum); + sDebug("vgId:%d, resp manager clean by ttl, seq:%" PRId64, pNode->vgId, *pSeqNum); } taosArrayDestroy(delIndexArray); } diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index f2da2fb2ce..b68b735f46 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -406,7 +406,7 @@ void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *p } // just set start = false -// FpSnapshotStopWrite should not be called, assert writer == NULL +// FpSnapshotStopWrite should not be called void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { sRInfo(pReceiver, "snapshot receiver stop, not apply, writer:%p", pReceiver->pWriter); diff --git a/source/libs/sync/src/syncTimeout.c b/source/libs/sync/src/syncTimeout.c index 16e593d0e4..859183db95 100644 --- a/source/libs/sync/src/syncTimeout.c +++ b/source/libs/sync/src/syncTimeout.c @@ -24,33 +24,35 @@ #include "syncUtil.h" static void syncNodeCleanConfigIndex(SSyncNode* ths) { +#if 0 int32_t newArrIndex = 0; SyncIndex newConfigIndexArr[MAX_CONFIG_INDEX_COUNT] = {0}; SSnapshot snapshot = {0}; ths->pFsm->FpGetSnapshotInfo(ths->pFsm, &snapshot); if (snapshot.lastApplyIndex != SYNC_INDEX_INVALID) { - for (int32_t i = 0; i < ths->pRaftCfg->configIndexCount; ++i) { - if (ths->pRaftCfg->configIndexArr[i] < snapshot.lastConfigIndex) { + for (int32_t i = 0; i < ths->raftCfg.configIndexCount; ++i) { + if (ths->raftCfg.configIndexArr[i] < snapshot.lastConfigIndex) { // pass } else { // save - newConfigIndexArr[newArrIndex] = ths->pRaftCfg->configIndexArr[i]; + newConfigIndexArr[newArrIndex] = ths->raftCfg.configIndexArr[i]; ++newArrIndex; } } - int32_t oldCnt = ths->pRaftCfg->configIndexCount; - ths->pRaftCfg->configIndexCount = newArrIndex; - memcpy(ths->pRaftCfg->configIndexArr, newConfigIndexArr, sizeof(newConfigIndexArr)); + int32_t oldCnt = ths->raftCfg.configIndexCount; + ths->raftCfg.configIndexCount = newArrIndex; + memcpy(ths->raftCfg.configIndexArr, newConfigIndexArr, sizeof(newConfigIndexArr)); - int32_t code = raftCfgPersist(ths->pRaftCfg); + int32_t code = syncWriteCfgFile(ths); if (code != 0) { sNFatal(ths, "failed to persist cfg"); } else { - sNTrace(ths, "clean config index arr, old-cnt:%d, new-cnt:%d", oldCnt, ths->pRaftCfg->configIndexCount); + sNTrace(ths, "clean config index arr, old-cnt:%d, new-cnt:%d", oldCnt, ths->raftCfg.configIndexCount); } } +#endif } static int32_t syncNodeTimerRoutine(SSyncNode* ths) { diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index 49a24bebde..0ec24d5326 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -21,42 +21,23 @@ #include "syncRaftStore.h" #include "syncSnapshot.h" -extern void addEpIntoEpSet(SEpSet* pEpSet, const char* fqdn, uint16_t port); +void syncCfg2SimpleStr(const SSyncCfg* pCfg, char* buf, int32_t bufLen) { + int32_t len = snprintf(buf, bufLen, "{r-num:%d, my:%d, ", pCfg->replicaNum, pCfg->myIndex); -uint64_t syncUtilAddr2U64(const char* host, uint16_t port) { - uint32_t hostU32 = taosGetIpv4FromFqdn(host); - if (hostU32 == (uint32_t)-1) { - sError("failed to resolve ipv4 addr, host:%s", host); - terrno = TSDB_CODE_TSC_INVALID_FQDN; - return -1; + for (int32_t i = 0; i < pCfg->replicaNum; ++i) { + if (i < pCfg->replicaNum - 1) { + len += snprintf(buf + len, bufLen - len, "%s:%d, ", pCfg->nodeInfo[i].nodeFqdn, pCfg->nodeInfo[i].nodePort); + } else { + len += snprintf(buf + len, bufLen - len, "%s:%d}", pCfg->nodeInfo[i].nodeFqdn, pCfg->nodeInfo[i].nodePort); + } } - - uint64_t u64 = (((uint64_t)hostU32) << 32) | (((uint32_t)port) << 16); - return u64; -} - -void syncUtilU642Addr(uint64_t u64, char* host, int64_t len, uint16_t* port) { - uint32_t hostU32 = (uint32_t)((u64 >> 32) & 0x00000000FFFFFFFF); - - struct in_addr addr = {.s_addr = hostU32}; - taosInetNtoa(addr, host, len); - *port = (uint16_t)((u64 & 0x00000000FFFF0000) >> 16); } void syncUtilNodeInfo2EpSet(const SNodeInfo* pInfo, SEpSet* pEpSet) { pEpSet->inUse = 0; - pEpSet->numOfEps = 0; - addEpIntoEpSet(pEpSet, pInfo->nodeFqdn, pInfo->nodePort); -} - -void syncUtilRaftId2EpSet(const SRaftId* raftId, SEpSet* pEpSet) { - char host[TSDB_FQDN_LEN] = {0}; - uint16_t port = 0; - - syncUtilU642Addr(raftId->addr, host, sizeof(host), &port); - pEpSet->inUse = 0; - pEpSet->numOfEps = 0; - addEpIntoEpSet(pEpSet, host, port); + pEpSet->numOfEps = 1; + pEpSet->eps[0].port = pInfo->nodePort; + tstrncpy(pEpSet->eps[0].fqdn, pInfo->nodeFqdn, TSDB_FQDN_LEN); } bool syncUtilNodeInfo2RaftId(const SNodeInfo* pInfo, SyncGroupId vgId, SRaftId* raftId) { @@ -69,13 +50,18 @@ bool syncUtilNodeInfo2RaftId(const SNodeInfo* pInfo, SyncGroupId vgId, SRaftId* char ipbuf[128] = {0}; tinet_ntoa(ipbuf, ipv4); - raftId->addr = syncUtilAddr2U64(ipbuf, pInfo->nodePort); + raftId->addr = SYNC_ADDR(pInfo); raftId->vgId = vgId; + + sInfo("vgId:%d, sync addr:%" PRIu64 ", dnode:%d cluster:%" PRId64 " fqdn:%s ip:%s port:%u ipv4:%u", vgId, + raftId->addr, pInfo->nodeId, pInfo->clusterId, pInfo->nodeFqdn, ipbuf, pInfo->nodePort, ipv4); return true; } bool syncUtilSameId(const SRaftId* pId1, const SRaftId* pId2) { - return pId1->addr == pId2->addr && pId1->vgId == pId2->vgId; + if (pId1->addr == pId2->addr && pId1->vgId == pId2->vgId) return true; + if ((CID(pId1) == 0 || CID(pId2) == 0) && (DID(pId1) == DID(pId2)) && pId1->vgId == pId2->vgId) return true; + return false; } bool syncUtilEmptyId(const SRaftId* pId) { return (pId->addr == 0 && pId->vgId == 0); } @@ -91,89 +77,16 @@ int32_t syncUtilElectRandomMS(int32_t min, int32_t max) { int32_t syncUtilQuorum(int32_t replicaNum) { return replicaNum / 2 + 1; } -cJSON* syncUtilRaftId2Json(const SRaftId* p) { - char u64buf[128] = {0}; - cJSON* pRoot = cJSON_CreateObject(); - - snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", p->addr); - cJSON_AddStringToObject(pRoot, "addr", u64buf); - char host[128] = {0}; - uint16_t port; - syncUtilU642Addr(p->addr, host, sizeof(host), &port); - cJSON_AddStringToObject(pRoot, "host", host); - cJSON_AddNumberToObject(pRoot, "port", port); - cJSON_AddNumberToObject(pRoot, "vgId", p->vgId); - - cJSON* pJson = cJSON_CreateObject(); - cJSON_AddItemToObject(pJson, "SRaftId", pRoot); - return pJson; -} - -static inline bool syncUtilCanPrint(char c) { - if (c >= 32 && c <= 126) { - return true; - } else { - return false; - } -} - -char* syncUtilPrintBin(char* ptr, uint32_t len) { - int64_t memLen = (int64_t)(len + 1); - char* s = taosMemoryMalloc(memLen); - ASSERT(s != NULL); - memset(s, 0, len + 1); - memcpy(s, ptr, len); - - for (int32_t i = 0; i < len; ++i) { - if (!syncUtilCanPrint(s[i])) { - s[i] = '.'; - } - } - return s; -} - -char* syncUtilPrintBin2(char* ptr, uint32_t len) { - uint32_t len2 = len * 4 + 1; - char* s = taosMemoryMalloc(len2); - ASSERT(s != NULL); - memset(s, 0, len2); - - char* p = s; - for (int32_t i = 0; i < len; ++i) { - int32_t n = sprintf(p, "%d,", ptr[i]); - p += n; - } - return s; -} - void syncUtilMsgHtoN(void* msg) { SMsgHead* pHead = msg; pHead->contLen = htonl(pHead->contLen); pHead->vgId = htonl(pHead->vgId); } -void syncUtilMsgNtoH(void* msg) { - SMsgHead* pHead = msg; - pHead->contLen = ntohl(pHead->contLen); - pHead->vgId = ntohl(pHead->vgId); -} - bool syncUtilUserPreCommit(tmsg_t msgType) { return msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_LEADER_TRANSFER; } bool syncUtilUserRollback(tmsg_t msgType) { return msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_LEADER_TRANSFER; } -void syncCfg2SimpleStr(const SSyncCfg* pCfg, char* buf, int32_t bufLen) { - int32_t len = snprintf(buf, bufLen, "{r-num:%d, my:%d, ", pCfg->replicaNum, pCfg->myIndex); - - for (int32_t i = 0; i < pCfg->replicaNum; ++i) { - if (i < pCfg->replicaNum - 1) { - len += snprintf(buf + len, bufLen - len, "%s:%d, ", pCfg->nodeInfo[i].nodeFqdn, pCfg->nodeInfo[i].nodePort); - } else { - len += snprintf(buf + len, bufLen - len, "%s:%d}", pCfg->nodeInfo[i].nodeFqdn, pCfg->nodeInfo[i].nodePort); - } - } -} - // for leader static void syncHearbeatReplyTime2Str(SSyncNode* pSyncNode, char* buf, int32_t bufLen) { int32_t len = 5; @@ -222,7 +135,7 @@ static void syncPeerState2Str(SSyncNode* pSyncNode, char* buf, int32_t bufLen) { } void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNode* pNode, const char* format, ...) { - if (pNode == NULL || pNode->pRaftCfg == NULL || pNode->pRaftStore == NULL || pNode->pLogStore == NULL) return; + if (pNode == NULL || pNode->pRaftStore == NULL || pNode->pLogStore == NULL) return; int64_t currentTerm = pNode->pRaftStore->currentTerm; // save error code, otherwise it will be overwritten @@ -244,11 +157,7 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo int32_t cacheMiss = pNode->pLogStore->cacheMiss; char cfgStr[1024]; - if (pNode->pRaftCfg != NULL) { - syncCfg2SimpleStr(&(pNode->pRaftCfg->cfg), cfgStr, sizeof(cfgStr)); - } else { - return; - } + syncCfg2SimpleStr(&pNode->raftCfg.cfg, cfgStr, sizeof(cfgStr)); char peerStr[1024] = "{"; syncPeerState2Str(pNode, peerStr, sizeof(peerStr)); @@ -259,8 +168,6 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo char hbTimeStr[256] = "hb:{"; syncHearbeatTime2Str(pNode, hbTimeStr, sizeof(hbTimeStr)); - int32_t quorum = syncNodeDynamicQuorum(pNode); - char eventLog[512]; // {0}; va_list argpointer; va_start(argpointer, format); @@ -275,7 +182,7 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo // restore error code terrno = errCode; - if (pNode != NULL && pNode->pRaftCfg != NULL) { + if (pNode != NULL) { taosPrintLog(flags, level, dflag, "vgId:%d, %s, sync:%s, term:%" PRIu64 ", commit-index:%" PRId64 ", first-ver:%" PRId64 ", last-ver:%" PRId64 ", min:%" PRId64 ", snap:%" PRId64 ", snap-term:%" PRIu64 @@ -286,7 +193,7 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm, pNode->electNum, pNode->becomeLeaderNum, pNode->configChangeNum, cacheHit, cacheMiss, pNode->hbSlowNum, pNode->hbrSlowNum, aqItems, pNode->snapshottingIndex, pNode->replicaNum, - pNode->pRaftCfg->lastConfigIndex, pNode->changing, pNode->restoreFinish, quorum, + pNode->raftCfg.lastConfigIndex, pNode->changing, pNode->restoreFinish, syncNodeDynamicQuorum(pNode), pNode->electTimerLogicClock, pNode->heartbeatTimerLogicClockUser, peerStr, cfgStr, hbTimeStr, hbrTimeStr); } @@ -295,7 +202,7 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dflag, SSyncSnapshotSender* pSender, const char* format, ...) { SSyncNode* pNode = pSender->pSyncNode; - if (pNode == NULL || pNode->pRaftCfg == NULL || pNode->pRaftStore == NULL || pNode->pLogStore == NULL) return; + if (pNode == NULL || pNode->pRaftStore == NULL || pNode->pLogStore == NULL) return; SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0}; if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) { @@ -310,17 +217,11 @@ void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dfla } char cfgStr[1024]; - syncCfg2SimpleStr(&(pNode->pRaftCfg->cfg), cfgStr, sizeof(cfgStr)); + syncCfg2SimpleStr(&pNode->raftCfg.cfg, cfgStr, sizeof(cfgStr)); char peerStr[1024] = "{"; syncPeerState2Str(pNode, peerStr, sizeof(peerStr)); - int32_t quorum = syncNodeDynamicQuorum(pNode); - SRaftId destId = pNode->replicasId[pSender->replicaIndex]; - char host[64]; - uint16_t port; - syncUtilU642Addr(destId.addr, host, sizeof(host), &port); - char eventLog[512]; // {0}; va_list argpointer; va_start(argpointer, format); @@ -330,24 +231,24 @@ void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dfla taosPrintLog(flags, level, dflag, "vgId:%d, %s, sync:%s, {%p s-param:%" PRId64 " e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64 " lcindex:%" PRId64 - " seq:%d ack:%d finish:%d replica-index:%d %s:%d}" + " seq:%d ack:%d finish:%d replica-index:%d dnode:%d}" ", tm:%" PRIu64 ", cmt:%" PRId64 ", fst:%" PRId64 ", lst:%" PRId64 ", min:%" PRId64 ", snap:%" PRId64 ", snap-tm:%" PRIu64 ", sby:%d, stgy:%d, bch:%d, r-num:%d, lcfg:%" PRId64 ", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s, %s", pNode->vgId, eventLog, syncStr(pNode->state), pSender, pSender->snapshotParam.start, pSender->snapshotParam.end, pSender->snapshot.lastApplyIndex, pSender->snapshot.lastApplyTerm, pSender->snapshot.lastConfigIndex, pSender->seq, pSender->ack, pSender->finish, pSender->replicaIndex, - host, port, pNode->pRaftStore->currentTerm, pNode->commitIndex, logBeginIndex, logLastIndex, - pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm, pNode->pRaftCfg->isStandBy, - pNode->pRaftCfg->snapshotStrategy, pNode->pRaftCfg->batchSize, pNode->replicaNum, - pNode->pRaftCfg->lastConfigIndex, pNode->changing, pNode->restoreFinish, quorum, + DID(&pNode->replicasId[pSender->replicaIndex]), pNode->pRaftStore->currentTerm, pNode->commitIndex, + logBeginIndex, logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm, + pNode->raftCfg.isStandBy, pNode->raftCfg.snapshotStrategy, pNode->raftCfg.batchSize, pNode->replicaNum, + pNode->raftCfg.lastConfigIndex, pNode->changing, pNode->restoreFinish, syncNodeDynamicQuorum(pNode), pNode->electTimerLogicClock, pNode->heartbeatTimerLogicClockUser, peerStr, cfgStr); } void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t dflag, SSyncSnapshotReceiver* pReceiver, const char* format, ...) { SSyncNode* pNode = pReceiver->pSyncNode; - if (pNode == NULL || pNode->pRaftCfg == NULL || pNode->pRaftStore == NULL || pNode->pLogStore == NULL) return; + if (pNode == NULL || pNode->pRaftStore == NULL || pNode->pLogStore == NULL) return; SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0}; if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) { @@ -362,17 +263,11 @@ void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t df } char cfgStr[1024]; - syncCfg2SimpleStr(&(pNode->pRaftCfg->cfg), cfgStr, sizeof(cfgStr)); + syncCfg2SimpleStr(&pNode->raftCfg.cfg, cfgStr, sizeof(cfgStr)); char peerStr[1024] = "{"; syncPeerState2Str(pNode, peerStr, sizeof(peerStr)); - int32_t quorum = syncNodeDynamicQuorum(pNode); - SRaftId fromId = pReceiver->fromId; - char host[128]; - uint16_t port; - syncUtilU642Addr(fromId.addr, host, sizeof(host), &port); - char eventLog[512]; // {0}; va_list argpointer; va_start(argpointer, format); @@ -381,19 +276,19 @@ void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t df taosPrintLog(flags, level, dflag, "vgId:%d, %s, sync:%s," - " {%p start:%d ack:%d term:%" PRIu64 " start-time:%" PRId64 " from:%s:%d s-param:%" PRId64 + " {%p start:%d ack:%d term:%" PRIu64 " start-time:%" PRId64 " from dnode:%d s-param:%" PRId64 " e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64 " lcindex:%" PRId64 "}" ", tm:%" PRIu64 ", cmt:%" PRId64 ", fst:%" PRId64 ", lst:%" PRId64 ", min:%" PRId64 ", snap:%" PRId64 ", snap-tm:%" PRIu64 ", sby:%d, stgy:%d, bch:%d, r-num:%d, lcfg:%" PRId64 ", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s, %s", pNode->vgId, eventLog, syncStr(pNode->state), pReceiver, pReceiver->start, pReceiver->ack, - pReceiver->term, pReceiver->startTime, host, port, pReceiver->snapshotParam.start, + pReceiver->term, pReceiver->startTime, DID(&pReceiver->fromId), pReceiver->snapshotParam.start, pReceiver->snapshotParam.end, pReceiver->snapshot.lastApplyIndex, pReceiver->snapshot.lastApplyTerm, pReceiver->snapshot.lastConfigIndex, pNode->pRaftStore->currentTerm, pNode->commitIndex, logBeginIndex, logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm, - pNode->pRaftCfg->isStandBy, pNode->pRaftCfg->snapshotStrategy, pNode->pRaftCfg->batchSize, - pNode->replicaNum, pNode->pRaftCfg->lastConfigIndex, pNode->changing, pNode->restoreFinish, quorum, + pNode->raftCfg.isStandBy, pNode->raftCfg.snapshotStrategy, pNode->raftCfg.batchSize, pNode->replicaNum, + pNode->raftCfg.lastConfigIndex, pNode->changing, pNode->restoreFinish, syncNodeDynamicQuorum(pNode), pNode->electTimerLogicClock, pNode->heartbeatTimerLogicClockUser, peerStr, cfgStr); } @@ -408,56 +303,37 @@ void syncLogRecvTimer(SSyncNode* pSyncNode, const SyncTimeout* pMsg, const char* } void syncLogRecvLocalCmd(SSyncNode* pSyncNode, const SyncLocalCmd* pMsg, const char* s) { - if (!(sDebugFlag & DEBUG_TRACE)) return; - sNTrace(pSyncNode, "recv sync-local-cmd {cmd:%d-%s, sd-new-term:%" PRId64 ", fc-index:%" PRId64 "}, %s", pMsg->cmd, syncLocalCmdGetStr(pMsg->cmd), pMsg->sdNewTerm, pMsg->fcIndex, s); } void syncLogSendAppendEntriesReply(SSyncNode* pSyncNode, const SyncAppendEntriesReply* pMsg, const char* s) { - if (!(sDebugFlag & DEBUG_TRACE)) return; - - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port); - sNTrace(pSyncNode, - "send sync-append-entries-reply to %s:%d, {term:%" PRId64 ", pterm:%" PRId64 + "send sync-append-entries-reply to dnode:%d, {term:%" PRId64 ", pterm:%" PRId64 ", success:%d, lsend-index:%" PRId64 ", match:%" PRId64 "}, %s", - host, port, pMsg->term, pMsg->lastMatchTerm, pMsg->success, pMsg->lastSendIndex, pMsg->matchIndex, s); + DID(&pMsg->destId), pMsg->term, pMsg->lastMatchTerm, pMsg->success, pMsg->lastSendIndex, pMsg->matchIndex, s); } void syncLogRecvAppendEntriesReply(SSyncNode* pSyncNode, const SyncAppendEntriesReply* pMsg, const char* s) { - if (!(sDebugFlag & DEBUG_TRACE)) return; - - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); - sNTrace(pSyncNode, - "recv sync-append-entries-reply from %s:%d {term:%" PRId64 ", pterm:%" PRId64 + "recv sync-append-entries-reply from dnode:%d {term:%" PRId64 ", pterm:%" PRId64 ", success:%d, lsend-index:%" PRId64 ", match:%" PRId64 "}, %s", - host, port, pMsg->term, pMsg->lastMatchTerm, pMsg->success, pMsg->lastSendIndex, pMsg->matchIndex, s); + DID(&pMsg->srcId), pMsg->term, pMsg->lastMatchTerm, pMsg->success, pMsg->lastSendIndex, pMsg->matchIndex, s); } void syncLogSendHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, bool printX, int64_t timerElapsed, int64_t execTime) { - if (!(sDebugFlag & DEBUG_TRACE)) return; - - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port); - if (printX) { sNTrace(pSyncNode, - "send sync-heartbeat to %s:%d {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 ", ts:%" PRId64 + "send sync-heartbeat to dnode:%d {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 ", ts:%" PRId64 "}, x", - host, port, pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp); + DID(&pMsg->destId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp); } else { sNTrace(pSyncNode, - "send sync-heartbeat to %s:%d {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 ", ts:%" PRId64 + "send sync-heartbeat to dnode:%d {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 ", ts:%" PRId64 "}, timer-elapsed:%" PRId64 ", next-exec:%" PRId64, - host, port, pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, timerElapsed, execTime); + DID(&pMsg->destId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, timerElapsed, + execTime); } } @@ -465,183 +341,109 @@ void syncLogRecvHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, int64 if (timeDiff > SYNC_HEARTBEAT_SLOW_MS) { pSyncNode->hbSlowNum++; - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); sNInfo(pSyncNode, - "recv sync-heartbeat from %s:%d slow {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 ", ts:%" PRId64 - "}, %s, net elapsed:%" PRId64, - host, port, pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, s, timeDiff); + "recv sync-heartbeat from dnode:%d slow {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 + ", ts:%" PRId64 "}, %s, net elapsed:%" PRId64, + DID(&pMsg->srcId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, s, timeDiff); } - if (!(sDebugFlag & DEBUG_TRACE)) return; - - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); sNTrace(pSyncNode, - "recv sync-heartbeat from %s:%d {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 ", ts:%" PRId64 + "recv sync-heartbeat from dnode:%d {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 ", ts:%" PRId64 "}, %s, net elapsed:%" PRId64, - host, port, pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, s, timeDiff); + DID(&pMsg->srcId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, s, timeDiff); } void syncLogSendHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* pMsg, const char* s) { - if (!(sDebugFlag & DEBUG_TRACE)) return; - - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port); - - sNTrace(pSyncNode, "send sync-heartbeat-reply from %s:%d {term:%" PRId64 ", ts:%" PRId64 "}, %s", host, port, - pMsg->term, pMsg->timeStamp, s); + sNTrace(pSyncNode, "send sync-heartbeat-reply from dnode:%d {term:%" PRId64 ", ts:%" PRId64 "}, %s", + DID(&pMsg->destId), pMsg->term, pMsg->timeStamp, s); } void syncLogRecvHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* pMsg, int64_t timeDiff, const char* s) { if (timeDiff > SYNC_HEARTBEAT_REPLY_SLOW_MS) { pSyncNode->hbrSlowNum++; - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); sNTrace(pSyncNode, - "recv sync-heartbeat-reply from %s:%d slow {term:%" PRId64 ", ts:%" PRId64 "}, %s, net elapsed:%" PRId64, - host, port, pMsg->term, pMsg->timeStamp, s, timeDiff); + "recv sync-heartbeat-reply from dnode:%d slow {term:%" PRId64 ", ts:%" PRId64 "}, %s, net elapsed:%" PRId64, + DID(&pMsg->srcId), pMsg->term, pMsg->timeStamp, s, timeDiff); } - if (!(sDebugFlag & DEBUG_TRACE)) return; - - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); sNTrace(pSyncNode, - "recv sync-heartbeat-reply from %s:%d {term:%" PRId64 ", ts:%" PRId64 "}, %s, net elapsed:%" PRId64, host, - port, pMsg->term, pMsg->timeStamp, s, timeDiff); + "recv sync-heartbeat-reply from dnode:%d {term:%" PRId64 ", ts:%" PRId64 "}, %s, net elapsed:%" PRId64, + DID(&pMsg->srcId), pMsg->term, pMsg->timeStamp, s, timeDiff); } void syncLogSendSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s) { - if (!(sDebugFlag & DEBUG_DEBUG)) return; - - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port); - sNDebug(pSyncNode, - "send sync-snapshot-send to %s:%u, %s, seq:%d, term:%" PRId64 ", begin:%" PRId64 ", end:%" PRId64 + "send sync-snapshot-send to dnode:%d, %s, seq:%d, term:%" PRId64 ", begin:%" PRId64 ", end:%" PRId64 ", lterm:%" PRId64 ", stime:%" PRId64, - host, port, s, pMsg->seq, pMsg->term, pMsg->beginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime); + DID(&pMsg->destId), s, pMsg->seq, pMsg->term, pMsg->beginIndex, pMsg->lastIndex, pMsg->lastTerm, + pMsg->startTime); } void syncLogRecvSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s) { - if (!(sDebugFlag & DEBUG_DEBUG)) return; - - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); - sNDebug(pSyncNode, - "recv sync-snapshot-send from %s:%u, %s, seq:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64 + "recv sync-snapshot-send from dnode:%d, %s, seq:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64 ", lterm:%" PRId64 ", stime:%" PRId64 ", len:%u", - host, port, s, pMsg->seq, pMsg->term, pMsg->beginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime, - pMsg->dataLen); + DID(&pMsg->srcId), s, pMsg->seq, pMsg->term, pMsg->beginIndex, pMsg->lastIndex, pMsg->lastTerm, + pMsg->startTime, pMsg->dataLen); } void syncLogSendSyncSnapshotRsp(SSyncNode* pSyncNode, const SyncSnapshotRsp* pMsg, const char* s) { - if (!(sDebugFlag & DEBUG_DEBUG)) return; - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port); - sNDebug(pSyncNode, - "send sync-snapshot-rsp to %s:%u, %s, ack:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64 + "send sync-snapshot-rsp to dnode:%d, %s, ack:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64 ", lterm:%" PRId64 ", stime:%" PRId64, - host, port, s, pMsg->ack, pMsg->term, pMsg->snapBeginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime); + DID(&pMsg->destId), s, pMsg->ack, pMsg->term, pMsg->snapBeginIndex, pMsg->lastIndex, pMsg->lastTerm, + pMsg->startTime); } void syncLogRecvSyncSnapshotRsp(SSyncNode* pSyncNode, const SyncSnapshotRsp* pMsg, const char* s) { - if (!(sDebugFlag & DEBUG_DEBUG)) return; - - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); - sNDebug(pSyncNode, - "recv sync-snapshot-rsp from %s:%u, %s, ack:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64 + "recv sync-snapshot-rsp from dnode:%d, %s, ack:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64 ", lterm:%" PRId64 ", stime:%" PRId64, - host, port, s, pMsg->ack, pMsg->term, pMsg->snapBeginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime); + DID(&pMsg->srcId), s, pMsg->ack, pMsg->term, pMsg->snapBeginIndex, pMsg->lastIndex, pMsg->lastTerm, + pMsg->startTime); } void syncLogRecvAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMsg, const char* s) { - if (!(sDebugFlag & DEBUG_TRACE)) return; - - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); - sNTrace(pSyncNode, - "recv sync-append-entries from %s:%d {term:%" PRId64 ", pre-index:%" PRId64 ", pre-term:%" PRId64 + "recv sync-append-entries from dnode:%d {term:%" PRId64 ", pre-index:%" PRId64 ", pre-term:%" PRId64 ", cmt:%" PRId64 ", pterm:%" PRId64 ", datalen:%d}, %s", - host, port, pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->commitIndex, pMsg->privateTerm, + DID(&pMsg->srcId), pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->commitIndex, pMsg->privateTerm, pMsg->dataLen, s); } void syncLogSendAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMsg, const char* s) { - if (!(sDebugFlag & DEBUG_TRACE)) return; - - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port); sNTrace(pSyncNode, - "send sync-append-entries to %s:%d, {term:%" PRId64 ", pre-index:%" PRId64 ", pre-term:%" PRId64 + "send sync-append-entries to dnode:%d, {term:%" PRId64 ", pre-index:%" PRId64 ", pre-term:%" PRId64 ", lsend-index:%" PRId64 ", cmt:%" PRId64 ", datalen:%d}, %s", - host, port, pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, (pMsg->prevLogIndex + 1), pMsg->commitIndex, - pMsg->dataLen, s); + DID(&pMsg->destId), pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, (pMsg->prevLogIndex + 1), + pMsg->commitIndex, pMsg->dataLen, s); } void syncLogRecvRequestVote(SSyncNode* pSyncNode, const SyncRequestVote* pMsg, int32_t voteGranted, const char* s) { - // if (!(sDebugFlag & DEBUG_TRACE)) return; - - char logBuf[256]; - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); - if (voteGranted == -1) { sNInfo(pSyncNode, - "recv sync-request-vote from %s:%d, {term:%" PRId64 ", lindex:%" PRId64 ", lterm:%" PRId64 "}, %s", host, - port, pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm, s); + "recv sync-request-vote from dnode:%d, {term:%" PRId64 ", lindex:%" PRId64 ", lterm:%" PRId64 "}, %s", + DID(&pMsg->srcId), pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm, s); } else { sNInfo(pSyncNode, - "recv sync-request-vote from %s:%d, {term:%" PRId64 ", lindex:%" PRId64 ", lterm:%" PRId64 "}, granted:%d", - host, port, pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm, voteGranted); + "recv sync-request-vote from dnode:%d, {term:%" PRId64 ", lindex:%" PRId64 ", lterm:%" PRId64 + "}, granted:%d", + DID(&pMsg->srcId), pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm, voteGranted); } } void syncLogSendRequestVote(SSyncNode* pNode, const SyncRequestVote* pMsg, const char* s) { - // if (!(sDebugFlag & DEBUG_TRACE)) return; - - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port); - sNInfo(pNode, "send sync-request-vote to %s:%d {term:%" PRId64 ", lindex:%" PRId64 ", lterm:%" PRId64 "}, %s", host, - port, pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm, s); + sNInfo(pNode, "send sync-request-vote to dnode:%d {term:%" PRId64 ", lindex:%" PRId64 ", lterm:%" PRId64 "}, %s", + DID(&pMsg->destId), pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm, s); } void syncLogRecvRequestVoteReply(SSyncNode* pSyncNode, const SyncRequestVoteReply* pMsg, const char* s) { - // if (!(sDebugFlag & DEBUG_TRACE)) return; - - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); - sNInfo(pSyncNode, "recv sync-request-vote-reply from %s:%d {term:%" PRId64 ", grant:%d}, %s", host, port, pMsg->term, - pMsg->voteGranted, s); + sNInfo(pSyncNode, "recv sync-request-vote-reply from dnode:%d {term:%" PRId64 ", grant:%d}, %s", DID(&pMsg->srcId), + pMsg->term, pMsg->voteGranted, s); } void syncLogSendRequestVoteReply(SSyncNode* pSyncNode, const SyncRequestVoteReply* pMsg, const char* s) { - // if (!(sDebugFlag & DEBUG_TRACE)) return; - - char host[64]; - uint16_t port; - syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port); - sNInfo(pSyncNode, "send sync-request-vote-reply to %s:%d {term:%" PRId64 ", grant:%d}, %s", host, port, pMsg->term, - pMsg->voteGranted, s); + sNInfo(pSyncNode, "send sync-request-vote-reply to dnode:%d {term:%" PRId64 ", grant:%d}, %s", DID(&pMsg->destId), + pMsg->term, pMsg->voteGranted, s); } diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c index 8a0a35ce33..6bd9625276 100644 --- a/source/libs/sync/src/syncVoteMgr.c +++ b/source/libs/sync/src/syncVoteMgr.c @@ -23,21 +23,21 @@ static void voteGrantedClearVotes(SVotesGranted *pVotesGranted) { pVotesGranted->votes = 0; } -SVotesGranted *voteGrantedCreate(SSyncNode *pSyncNode) { +SVotesGranted *voteGrantedCreate(SSyncNode *pNode) { SVotesGranted *pVotesGranted = taosMemoryCalloc(1, sizeof(SVotesGranted)); if (pVotesGranted == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } - pVotesGranted->replicas = &(pSyncNode->replicasId); - pVotesGranted->replicaNum = pSyncNode->replicaNum; + pVotesGranted->replicas = &pNode->replicasId; + pVotesGranted->replicaNum = pNode->replicaNum; voteGrantedClearVotes(pVotesGranted); pVotesGranted->term = 0; - pVotesGranted->quorum = pSyncNode->quorum; + pVotesGranted->quorum = pNode->quorum; pVotesGranted->toLeader = false; - pVotesGranted->pSyncNode = pSyncNode; + pVotesGranted->pNode = pNode; return pVotesGranted; } @@ -48,33 +48,33 @@ void voteGrantedDestroy(SVotesGranted *pVotesGranted) { } } -void voteGrantedUpdate(SVotesGranted *pVotesGranted, SSyncNode *pSyncNode) { - pVotesGranted->replicas = &(pSyncNode->replicasId); - pVotesGranted->replicaNum = pSyncNode->replicaNum; +void voteGrantedUpdate(SVotesGranted *pVotesGranted, SSyncNode *pNode) { + pVotesGranted->replicas = &pNode->replicasId; + pVotesGranted->replicaNum = pNode->replicaNum; voteGrantedClearVotes(pVotesGranted); pVotesGranted->term = 0; - pVotesGranted->quorum = pSyncNode->quorum; + pVotesGranted->quorum = pNode->quorum; pVotesGranted->toLeader = false; - pVotesGranted->pSyncNode = pSyncNode; + pVotesGranted->pNode = pNode; } bool voteGrantedMajority(SVotesGranted *pVotesGranted) { return pVotesGranted->votes >= pVotesGranted->quorum; } void voteGrantedVote(SVotesGranted *pVotesGranted, SyncRequestVoteReply *pMsg) { if (!pMsg->voteGranted) { - sNFatal(pVotesGranted->pSyncNode, "vote granted should be true"); + sNFatal(pVotesGranted->pNode, "vote granted should be true"); return; } if (pMsg->term != pVotesGranted->term) { - sNTrace(pVotesGranted->pSyncNode, "vote grant term:%" PRId64 " not matched with msg term:%" PRId64, - pVotesGranted->term, pMsg->term); + sNTrace(pVotesGranted->pNode, "vote grant term:%" PRId64 " not matched with msg term:%" PRId64, pVotesGranted->term, + pMsg->term); return; } - if (!syncUtilSameId(&pVotesGranted->pSyncNode->myRaftId, &pMsg->destId)) { - sNFatal(pVotesGranted->pSyncNode, "vote granted raftId not matched with msg"); + if (!syncUtilSameId(&pVotesGranted->pNode->myRaftId, &pMsg->destId)) { + sNFatal(pVotesGranted->pNode, "vote granted raftId not matched with msg"); return; } @@ -86,7 +86,7 @@ void voteGrantedVote(SVotesGranted *pVotesGranted, SyncRequestVoteReply *pMsg) { } } if ((j == -1) || !(j >= 0 && j < pVotesGranted->replicaNum)) { - sNFatal(pVotesGranted->pSyncNode, "invalid msg srcId, index:%d", j); + sNFatal(pVotesGranted->pNode, "invalid msg srcId, index:%d", j); return; } @@ -96,7 +96,7 @@ void voteGrantedVote(SVotesGranted *pVotesGranted, SyncRequestVoteReply *pMsg) { } if (pVotesGranted->votes > pVotesGranted->replicaNum) { - sNFatal(pVotesGranted->pSyncNode, "votes:%d not matched with replicaNum:%d", pVotesGranted->votes, + sNFatal(pVotesGranted->pNode, "votes:%d not matched with replicaNum:%d", pVotesGranted->votes, pVotesGranted->replicaNum); return; } @@ -108,17 +108,17 @@ void voteGrantedReset(SVotesGranted *pVotesGranted, SyncTerm term) { pVotesGranted->toLeader = false; } -SVotesRespond *votesRespondCreate(SSyncNode *pSyncNode) { +SVotesRespond *votesRespondCreate(SSyncNode *pNode) { SVotesRespond *pVotesRespond = taosMemoryCalloc(1, sizeof(SVotesRespond)); if (pVotesRespond == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } - pVotesRespond->replicas = &(pSyncNode->replicasId); - pVotesRespond->replicaNum = pSyncNode->replicaNum; + pVotesRespond->replicas = &pNode->replicasId; + pVotesRespond->replicaNum = pNode->replicaNum; pVotesRespond->term = 0; - pVotesRespond->pSyncNode = pSyncNode; + pVotesRespond->pNode = pNode; return pVotesRespond; } @@ -129,11 +129,11 @@ void votesRespondDestory(SVotesRespond *pVotesRespond) { } } -void votesRespondUpdate(SVotesRespond *pVotesRespond, SSyncNode *pSyncNode) { - pVotesRespond->replicas = &(pSyncNode->replicasId); - pVotesRespond->replicaNum = pSyncNode->replicaNum; +void votesRespondUpdate(SVotesRespond *pVotesRespond, SSyncNode *pNode) { + pVotesRespond->replicas = &pNode->replicasId; + pVotesRespond->replicaNum = pNode->replicaNum; pVotesRespond->term = 0; - pVotesRespond->pSyncNode = pSyncNode; + pVotesRespond->pNode = pNode; } bool votesResponded(SVotesRespond *pVotesRespond, const SRaftId *pRaftId) { @@ -149,7 +149,7 @@ bool votesResponded(SVotesRespond *pVotesRespond, const SRaftId *pRaftId) { void votesRespondAdd(SVotesRespond *pVotesRespond, const SyncRequestVoteReply *pMsg) { if (pVotesRespond->term != pMsg->term) { - sNTrace(pVotesRespond->pSyncNode, "vote respond add error"); + sNTrace(pVotesRespond->pNode, "vote respond add error"); return; } @@ -160,7 +160,7 @@ void votesRespondAdd(SVotesRespond *pVotesRespond, const SyncRequestVoteReply *p } } - sNFatal(pVotesRespond->pSyncNode, "votes respond not found"); + sNFatal(pVotesRespond->pNode, "votes respond not found"); } void votesRespondReset(SVotesRespond *pVotesRespond, SyncTerm term) { diff --git a/source/libs/sync/test/syncRaftCfgIndexTest.cpp b/source/libs/sync/test/syncRaftCfgIndexTest.cpp index e6d3f23b58..5400065443 100644 --- a/source/libs/sync/test/syncRaftCfgIndexTest.cpp +++ b/source/libs/sync/test/syncRaftCfgIndexTest.cpp @@ -51,26 +51,26 @@ SSyncCfg* createSyncCfg() { const char* pFile = "./raft_config_index.json"; void test1() { - int32_t code = raftCfgIndexCreateFile(pFile); - ASSERT(code == 0); + // int32_t code = raftCfgIndexCreateFile(pFile); + // ASSERT(code == 0); - SRaftCfgIndex* pRaftCfgIndex = raftCfgIndexOpen(pFile); + // SRaftCfgIndex* pRaftCfgIndex = raftCfgIndexOpen(pFile); - raftCfgIndexClose(pRaftCfgIndex); + // raftCfgIndexClose(pRaftCfgIndex); } void test2() { - SRaftCfgIndex* pRaftCfgIndex = raftCfgIndexOpen(pFile); - for (int i = 0; i < 500; ++i) { - raftCfgIndexAddConfigIndex(pRaftCfgIndex, i); - } - raftCfgIndexPersist(pRaftCfgIndex); - raftCfgIndexClose(pRaftCfgIndex); + // SRaftCfgIndex* pRaftCfgIndex = raftCfgIndexOpen(pFile); + // for (int i = 0; i < 500; ++i) { + // raftCfgIndexAddConfigIndex(pRaftCfgIndex, i); + // } + // raftCfgIndexPersist(pRaftCfgIndex); + // raftCfgIndexClose(pRaftCfgIndex); } void test3() { - SRaftCfgIndex* pRaftCfgIndex = raftCfgIndexOpen(pFile); - raftCfgIndexClose(pRaftCfgIndex); + // SRaftCfgIndex* pRaftCfgIndex = raftCfgIndexOpen(pFile); + // raftCfgIndexClose(pRaftCfgIndex); } int main() { diff --git a/source/libs/sync/test/syncRaftCfgTest.cpp b/source/libs/sync/test/syncRaftCfgTest.cpp index c841a68fde..8e63b4ca09 100644 --- a/source/libs/sync/test/syncRaftCfgTest.cpp +++ b/source/libs/sync/test/syncRaftCfgTest.cpp @@ -67,12 +67,12 @@ void test3() { if (taosCheckExistFile(s)) { printf("%s file: %s already exist! \n", (char*)__FUNCTION__, s); } else { - SRaftCfgMeta meta; - meta.isStandBy = 7; - meta.snapshotStrategy = 9; - meta.batchSize = 10; - meta.lastConfigIndex = 789; - raftCfgCreateFile(pCfg, meta, s); + // SRaftCfgMeta meta; + // meta.isStandBy = 7; + // meta.snapshotStrategy = 9; + // meta.batchSize = 10; + // meta.lastConfigIndex = 789; + // raftCfgCreateFile(pCfg, meta, s); printf("%s create json file: %s \n", (char*)__FUNCTION__, s); } @@ -80,37 +80,37 @@ void test3() { } void test4() { - SRaftCfg* pCfg = raftCfgOpen("./test3_raft_cfg.json"); - assert(pCfg != NULL); + // SRaftCfg* pCfg = raftCfgOpen("./test3_raft_cfg.json"); + // assert(pCfg != NULL); - int32_t ret = raftCfgClose(pCfg); - assert(ret == 0); + // int32_t ret = raftCfgClose(pCfg); + // assert(ret == 0); } void test5() { - SRaftCfg* pCfg = raftCfgOpen("./test3_raft_cfg.json"); - assert(pCfg != NULL); + // SRaftCfg* pCfg = raftCfgOpen("./test3_raft_cfg.json"); + // assert(pCfg != NULL); - pCfg->cfg.myIndex = taosGetTimestampSec(); - pCfg->isStandBy += 2; - pCfg->snapshotStrategy += 3; - pCfg->batchSize += 4; - pCfg->lastConfigIndex += 1000; + // pCfg->cfg.myIndex = taosGetTimestampSec(); + // pCfg->isStandBy += 2; + // pCfg->snapshotStrategy += 3; + // pCfg->batchSize += 4; + // pCfg->lastConfigIndex += 1000; - pCfg->configIndexCount = 5; - for (int i = 0; i < MAX_CONFIG_INDEX_COUNT; ++i) { - (pCfg->configIndexArr)[i] = -1; - } - for (int i = 0; i < pCfg->configIndexCount; ++i) { - (pCfg->configIndexArr)[i] = i * 100; - } + // pCfg->configIndexCount = 5; + // for (int i = 0; i < MAX_CONFIG_INDEX_COUNT; ++i) { + // (pCfg->configIndexArr)[i] = -1; + // } + // for (int i = 0; i < pCfg->configIndexCount; ++i) { + // (pCfg->configIndexArr)[i] = i * 100; + // } - raftCfgPersist(pCfg); + // // raftCfgPersist(pCfg); - printf("%s update json file: %s myIndex->%d \n", (char*)__FUNCTION__, "./test3_raft_cfg.json", pCfg->cfg.myIndex); + // printf("%s update json file: %s myIndex->%d \n", (char*)__FUNCTION__, "./test3_raft_cfg.json", pCfg->cfg.myIndex); - int32_t ret = raftCfgClose(pCfg); - assert(ret == 0); + // int32_t ret = raftCfgClose(pCfg); + // assert(ret == 0); } int main() { diff --git a/source/libs/sync/test/sync_test_lib/inc/syncTest.h b/source/libs/sync/test/sync_test_lib/inc/syncTest.h index ae4cc6ed6f..fc52e83aa7 100644 --- a/source/libs/sync/test/sync_test_lib/inc/syncTest.h +++ b/source/libs/sync/test/sync_test_lib/inc/syncTest.h @@ -474,6 +474,11 @@ void syncLocalCmdPrint2(char* s, const SyncLocalCmd* pMsg); void syncLocalCmdLog(const SyncLocalCmd* pMsg); void syncLocalCmdLog2(char* s, const SyncLocalCmd* pMsg); +char* syncUtilPrintBin(char* ptr, uint32_t len); +char* syncUtilPrintBin2(char* ptr, uint32_t len); +void syncUtilU642Addr(uint64_t u64, char* host, int64_t len, uint16_t* port); +uint64_t syncUtilAddr2U64(const char* host, uint16_t port); + #ifdef __cplusplus } #endif diff --git a/source/libs/sync/test/sync_test_lib/src/syncBatch.c b/source/libs/sync/test/sync_test_lib/src/syncBatch.c index cb4bed1e67..4e0b534671 100644 --- a/source/libs/sync/test/sync_test_lib/src/syncBatch.c +++ b/source/libs/sync/test/sync_test_lib/src/syncBatch.c @@ -311,7 +311,7 @@ cJSON* syncAppendEntriesBatch2Json(const SyncAppendEntriesBatch* pMsg) { cJSON* pTmp = pSrcId; char host[128] = {0}; uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); + // syncUtilU642Addr(u64, host, sizeof(host), &port); cJSON_AddStringToObject(pTmp, "addr_host", host); cJSON_AddNumberToObject(pTmp, "addr_port", port); } diff --git a/source/libs/sync/test/sync_test_lib/src/syncIO.c b/source/libs/sync/test/sync_test_lib/src/syncIO.c index 4b305f823f..2e00785586 100644 --- a/source/libs/sync/test/sync_test_lib/src/syncIO.c +++ b/source/libs/sync/test/sync_test_lib/src/syncIO.c @@ -73,7 +73,7 @@ int32_t syncIOSendMsg(const SEpSet *pEpSet, SRpcMsg *pMsg) { int32_t ret = 0; { - syncUtilMsgNtoH(pMsg->pCont); + // syncUtilMsgNtoH(pMsg->pCont); char logBuf[256] = {0}; snprintf(logBuf, sizeof(logBuf), "==syncIOSendMsg== %s:%d msgType:%d", pEpSet->eps[0].fqdn, pEpSet->eps[0].port, @@ -376,7 +376,7 @@ static void *syncIOConsumerFunc(void *param) { } static void syncIOProcessRequest(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) { - syncUtilMsgNtoH(pMsg->pCont); + // syncUtilMsgNtoH(pMsg->pCont); syncRpcMsgLog2((char *)"==syncIOProcessRequest==", pMsg); SSyncIO *io = pParent; @@ -432,9 +432,9 @@ static void syncIOTickQ(void *param, void *tmrId) { SSyncIO *io = (SSyncIO *)param; SRaftId srcId, destId; - srcId.addr = syncUtilAddr2U64(io->myAddr.eps[0].fqdn, io->myAddr.eps[0].port); + // srcId.addr = syncUtilAddr2U64(io->myAddr.eps[0].fqdn, io->myAddr.eps[0].port); srcId.vgId = -1; - destId.addr = syncUtilAddr2U64(io->myAddr.eps[0].fqdn, io->myAddr.eps[0].port); + // destId.addr = syncUtilAddr2U64(io->myAddr.eps[0].fqdn, io->myAddr.eps[0].port); destId.vgId = -1; SyncPingReply *pMsg = syncPingReplyBuild2(&srcId, &destId, -1, "syncIOTickQ"); @@ -454,9 +454,9 @@ static void syncIOTickPing(void *param, void *tmrId) { SSyncIO *io = (SSyncIO *)param; SRaftId srcId, destId; - srcId.addr = syncUtilAddr2U64(io->myAddr.eps[0].fqdn, io->myAddr.eps[0].port); + // srcId.addr = syncUtilAddr2U64(io->myAddr.eps[0].fqdn, io->myAddr.eps[0].port); srcId.vgId = -1; - destId.addr = syncUtilAddr2U64(io->myAddr.eps[0].fqdn, io->myAddr.eps[0].port); + // destId.addr = syncUtilAddr2U64(io->myAddr.eps[0].fqdn, io->myAddr.eps[0].port); destId.vgId = -1; SyncPing *pMsg = syncPingBuild2(&srcId, &destId, -1, "syncIOTickPing"); // SyncPing *pMsg = syncPingBuild3(&srcId, &destId); @@ -470,4 +470,68 @@ static void syncIOTickPing(void *param, void *tmrId) { taosTmrReset(syncIOTickPing, io->pingTimerMS, io, io->timerMgr, &io->pingTimer); } -void syncEntryDestory(SSyncRaftEntry* pEntry) {} \ No newline at end of file +void syncEntryDestory(SSyncRaftEntry* pEntry) {} + + +void syncUtilMsgNtoH(void* msg) { + SMsgHead* pHead = msg; + pHead->contLen = ntohl(pHead->contLen); + pHead->vgId = ntohl(pHead->vgId); +} + +static inline bool syncUtilCanPrint(char c) { + if (c >= 32 && c <= 126) { + return true; + } else { + return false; + } +} + +char* syncUtilPrintBin(char* ptr, uint32_t len) { + int64_t memLen = (int64_t)(len + 1); + char* s = taosMemoryMalloc(memLen); + ASSERT(s != NULL); + memset(s, 0, len + 1); + memcpy(s, ptr, len); + + for (int32_t i = 0; i < len; ++i) { + if (!syncUtilCanPrint(s[i])) { + s[i] = '.'; + } + } + return s; +} + +char* syncUtilPrintBin2(char* ptr, uint32_t len) { + uint32_t len2 = len * 4 + 1; + char* s = taosMemoryMalloc(len2); + ASSERT(s != NULL); + memset(s, 0, len2); + + char* p = s; + for (int32_t i = 0; i < len; ++i) { + int32_t n = sprintf(p, "%d,", ptr[i]); + p += n; + } + return s; +} + +void syncUtilU642Addr(uint64_t u64, char* host, int64_t len, uint16_t* port) { + uint32_t hostU32 = (uint32_t)((u64 >> 32) & 0x00000000FFFFFFFF); + + struct in_addr addr = {.s_addr = hostU32}; + taosInetNtoa(addr, host, len); + *port = (uint16_t)((u64 & 0x00000000FFFF0000) >> 16); +} + +uint64_t syncUtilAddr2U64(const char* host, uint16_t port) { + uint32_t hostU32 = taosGetIpv4FromFqdn(host); + if (hostU32 == (uint32_t)-1) { + sError("failed to resolve ipv4 addr, host:%s", host); + terrno = TSDB_CODE_TSC_INVALID_FQDN; + return -1; + } + + uint64_t u64 = (((uint64_t)hostU32) << 32) | (((uint32_t)port) << 16); + return u64; +} \ No newline at end of file diff --git a/source/libs/sync/test/sync_test_lib/src/syncIndexMgrDebug.c b/source/libs/sync/test/sync_test_lib/src/syncIndexMgrDebug.c index 1d3198c51d..c951eef761 100644 --- a/source/libs/sync/test/sync_test_lib/src/syncIndexMgrDebug.c +++ b/source/libs/sync/test/sync_test_lib/src/syncIndexMgrDebug.c @@ -53,7 +53,7 @@ cJSON *syncIndexMgr2Json(SSyncIndexMgr *pSyncIndexMgr) { cJSON *pReplicas = cJSON_CreateArray(); cJSON_AddItemToObject(pRoot, "replicas", pReplicas); for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { - cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pSyncIndexMgr->replicas))[i])); + // cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pSyncIndexMgr->replicas))[i])); } { @@ -76,7 +76,7 @@ cJSON *syncIndexMgr2Json(SSyncIndexMgr *pSyncIndexMgr) { cJSON_AddItemToObject(pRoot, "privateTerm", pIndex); } - snprintf(u64buf, sizeof(u64buf), "%p", pSyncIndexMgr->pSyncNode); + // snprintf(u64buf, sizeof(u64buf), "%p", pSyncIndexMgr->pSyncNode); cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); } diff --git a/source/libs/sync/test/sync_test_lib/src/syncMainDebug.c b/source/libs/sync/test/sync_test_lib/src/syncMainDebug.c index 6b461da0e5..f1db2f0204 100644 --- a/source/libs/sync/test/sync_test_lib/src/syncMainDebug.c +++ b/source/libs/sync/test/sync_test_lib/src/syncMainDebug.c @@ -23,7 +23,7 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) { if (pSyncNode != NULL) { // init by SSyncInfo cJSON_AddNumberToObject(pRoot, "vgId", pSyncNode->vgId); - cJSON_AddItemToObject(pRoot, "SRaftCfg", raftCfg2Json(pSyncNode->pRaftCfg)); + // cJSON_AddItemToObject(pRoot, "SRaftCfg", raftCfg2Json(pSyncNode->pRaftCfg)); cJSON_AddStringToObject(pRoot, "path", pSyncNode->path); cJSON_AddStringToObject(pRoot, "raftStorePath", pSyncNode->raftStorePath); cJSON_AddStringToObject(pRoot, "configPath", pSyncNode->configPath); @@ -44,8 +44,8 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) { // init internal cJSON* pMe = syncUtilNodeInfo2Json(&pSyncNode->myNodeInfo); cJSON_AddItemToObject(pRoot, "myNodeInfo", pMe); - cJSON* pRaftId = syncUtilRaftId2Json(&pSyncNode->myRaftId); - cJSON_AddItemToObject(pRoot, "myRaftId", pRaftId); + // cJSON* pRaftId = syncUtilRaftId2Json(&pSyncNode->myRaftId); + // cJSON_AddItemToObject(pRoot, "myRaftId", pRaftId); cJSON_AddNumberToObject(pRoot, "peersNum", pSyncNode->peersNum); cJSON* pPeers = cJSON_CreateArray(); @@ -56,22 +56,22 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) { cJSON* pPeersId = cJSON_CreateArray(); cJSON_AddItemToObject(pRoot, "peersId", pPeersId); for (int32_t i = 0; i < pSyncNode->peersNum; ++i) { - cJSON_AddItemToArray(pPeersId, syncUtilRaftId2Json(&pSyncNode->peersId[i])); + // cJSON_AddItemToArray(pPeersId, syncUtilRaftId2Json(&pSyncNode->peersId[i])); } cJSON_AddNumberToObject(pRoot, "replicaNum", pSyncNode->replicaNum); cJSON* pReplicasId = cJSON_CreateArray(); cJSON_AddItemToObject(pRoot, "replicasId", pReplicasId); for (int32_t i = 0; i < pSyncNode->replicaNum; ++i) { - cJSON_AddItemToArray(pReplicasId, syncUtilRaftId2Json(&pSyncNode->replicasId[i])); + // cJSON_AddItemToArray(pReplicasId, syncUtilRaftId2Json(&pSyncNode->replicasId[i])); } // raft algorithm snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pFsm); cJSON_AddStringToObject(pRoot, "pFsm", u64buf); cJSON_AddNumberToObject(pRoot, "quorum", pSyncNode->quorum); - cJSON* pLaderCache = syncUtilRaftId2Json(&pSyncNode->leaderCache); - cJSON_AddItemToObject(pRoot, "leaderCache", pLaderCache); + // cJSON* pLaderCache = syncUtilRaftId2Json(&pSyncNode->leaderCache); + // cJSON_AddItemToObject(pRoot, "leaderCache", pLaderCache); // life cycle snprintf(u64buf, sizeof(u64buf), "%" PRId64, pSyncNode->rid); @@ -200,8 +200,8 @@ inline char* syncNode2SimpleStr(const SSyncNode* pSyncNode) { "r-num:%d, " "lcfg:%" PRId64 ", chging:%d, rsto:%d", pSyncNode->vgId, syncStr(pSyncNode->state), pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, - logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum, - pSyncNode->pRaftCfg->lastConfigIndex, pSyncNode->changing, pSyncNode->restoreFinish); + logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->raftCfg.isStandBy, pSyncNode->replicaNum, + pSyncNode->raftCfg.lastConfigIndex, pSyncNode->changing, pSyncNode->restoreFinish); return s; } @@ -243,7 +243,7 @@ int32_t syncNodePingPeers(SSyncNode* pSyncNode) { int32_t syncNodePingAll(SSyncNode* pSyncNode) { int32_t ret = 0; - for (int32_t i = 0; i < pSyncNode->pRaftCfg->cfg.replicaNum; ++i) { + for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.replicaNum; ++i) { SRaftId* destId = &(pSyncNode->replicasId[i]); SyncPing* pMsg = syncPingBuild3(&pSyncNode->myRaftId, destId, pSyncNode->vgId); ret = syncNodePing(pSyncNode, destId, pMsg); diff --git a/source/libs/sync/test/sync_test_lib/src/syncMessageDebug.c b/source/libs/sync/test/sync_test_lib/src/syncMessageDebug.c index 3b6007df6b..ae83bf9ead 100644 --- a/source/libs/sync/test/sync_test_lib/src/syncMessageDebug.c +++ b/source/libs/sync/test/sync_test_lib/src/syncMessageDebug.c @@ -181,7 +181,7 @@ cJSON* syncPing2Json(const SyncPing* pMsg) { cJSON* pTmp = pSrcId; char host[128] = {0}; uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); + // syncUtilU642Addr(u64, host, sizeof(host), &port); cJSON_AddStringToObject(pTmp, "addr_host", host); cJSON_AddNumberToObject(pTmp, "addr_port", port); } @@ -748,7 +748,7 @@ cJSON* syncSnapshotSend2Json(const SyncSnapshotSend* pMsg) { snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->lastConfigIndex); cJSON_AddStringToObject(pRoot, "lastConfigIndex", u64buf); - cJSON_AddItemToObject(pRoot, "lastConfig", syncCfg2Json((SSyncCfg*)&(pMsg->lastConfig))); + // cJSON_AddItemToObject(pRoot, "lastConfig", syncCfg2Json((SSyncCfg*)&(pMsg->lastConfig))); snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->lastTerm); cJSON_AddStringToObject(pRoot, "lastTerm", u64buf); diff --git a/source/libs/sync/test/sync_test_lib/src/syncRaftCfgDebug.c b/source/libs/sync/test/sync_test_lib/src/syncRaftCfgDebug.c index 50ecc5d478..bafa22ea64 100644 --- a/source/libs/sync/test/sync_test_lib/src/syncRaftCfgDebug.c +++ b/source/libs/sync/test/sync_test_lib/src/syncRaftCfgDebug.c @@ -17,18 +17,19 @@ #include "syncTest.h" char *syncCfg2Str(SSyncCfg *pSyncCfg) { - cJSON *pJson = syncCfg2Json(pSyncCfg); - char *serialized = cJSON_Print(pJson); - cJSON_Delete(pJson); - return serialized; + // cJSON *pJson = syncCfg2Json(pSyncCfg); + // char *serialized = cJSON_Print(pJson); + // cJSON_Delete(pJson); + // return serialized; + return ""; } int32_t syncCfgFromStr(const char *s, SSyncCfg *pSyncCfg) { cJSON *pRoot = cJSON_Parse(s); ASSERT(pRoot != NULL); - int32_t ret = syncCfgFromJson(pRoot, pSyncCfg); - ASSERT(ret == 0); + // int32_t ret = syncCfgFromJson(pRoot, pSyncCfg); + // ASSERT(ret == 0); cJSON_Delete(pRoot); return 0; diff --git a/source/libs/sync/test/sync_test_lib/src/syncUtilDebug.c b/source/libs/sync/test/sync_test_lib/src/syncUtilDebug.c index b12f4e76a5..6802148578 100644 --- a/source/libs/sync/test/sync_test_lib/src/syncUtilDebug.c +++ b/source/libs/sync/test/sync_test_lib/src/syncUtilDebug.c @@ -29,8 +29,9 @@ cJSON* syncUtilNodeInfo2Json(const SNodeInfo* p) { } char* syncUtilRaftId2Str(const SRaftId* p) { - cJSON* pJson = syncUtilRaftId2Json(p); - char* serialized = cJSON_Print(pJson); - cJSON_Delete(pJson); - return serialized; + // cJSON* pJson = syncUtilRaftId2Json(p); + // char* serialized = cJSON_Print(pJson); + // cJSON_Delete(pJson); + // return serialized; + return ""; } diff --git a/source/libs/sync/test/sync_test_lib/src/syncVoteMgrDebug.c b/source/libs/sync/test/sync_test_lib/src/syncVoteMgrDebug.c index f1c26a97aa..f3ea5e07fd 100644 --- a/source/libs/sync/test/sync_test_lib/src/syncVoteMgrDebug.c +++ b/source/libs/sync/test/sync_test_lib/src/syncVoteMgrDebug.c @@ -25,7 +25,7 @@ cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) { cJSON *pReplicas = cJSON_CreateArray(); cJSON_AddItemToObject(pRoot, "replicas", pReplicas); for (int32_t i = 0; i < pVotesGranted->replicaNum; ++i) { - cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pVotesGranted->replicas))[i])); + // cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pVotesGranted->replicas))[i])); } int32_t *arr = (int32_t *)taosMemoryMalloc(sizeof(int32_t) * pVotesGranted->replicaNum); for (int32_t i = 0; i < pVotesGranted->replicaNum; ++i) { @@ -40,7 +40,7 @@ cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) { cJSON_AddStringToObject(pRoot, "term", u64buf); cJSON_AddNumberToObject(pRoot, "quorum", pVotesGranted->quorum); cJSON_AddNumberToObject(pRoot, "toLeader", pVotesGranted->toLeader); - snprintf(u64buf, sizeof(u64buf), "%p", pVotesGranted->pSyncNode); + snprintf(u64buf, sizeof(u64buf), "%p", pVotesGranted->pNode); cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); bool majority = voteGrantedMajority(pVotesGranted); @@ -68,7 +68,7 @@ cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) { cJSON *pReplicas = cJSON_CreateArray(); cJSON_AddItemToObject(pRoot, "replicas", pReplicas); for (int32_t i = 0; i < pVotesRespond->replicaNum; ++i) { - cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pVotesRespond->replicas))[i])); + // cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pVotesRespond->replicas))[i])); } int32_t respondNum = 0; int32_t *arr = (int32_t *)taosMemoryMalloc(sizeof(int32_t) * pVotesRespond->replicaNum); @@ -85,7 +85,7 @@ cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) { snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pVotesRespond->term); cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pVotesRespond->pSyncNode); + snprintf(u64buf, sizeof(u64buf), "%p", pVotesRespond->pNode); cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); } diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index 4e25d72b2b..734bac5c87 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -1788,6 +1788,10 @@ int tdbBtreeNext(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen) { } memcpy(pVal, cd.pVal, cd.vLen); + if (TDB_CELLDECODER_FREE_VAL(&cd)) { + tdbTrace("tdb/btree-next decoder: %p pVal free: %p", &cd, cd.pVal); + tdbFree(cd.pVal); + } } else { pVal = NULL; } diff --git a/source/libs/transport/src/tmsgcb.c b/source/libs/transport/src/tmsgcb.c index 95bc532994..4131619ed9 100644 --- a/source/libs/transport/src/tmsgcb.c +++ b/source/libs/transport/src/tmsgcb.c @@ -24,7 +24,6 @@ static SMsgCb defaultMsgCb; void tmsgSetDefault(const SMsgCb* msgcb) { defaultMsgCb = *msgcb; } int32_t tmsgPutToQueue(const SMsgCb* msgcb, EQueueType qtype, SRpcMsg* pMsg) { - ASSERT(msgcb != NULL); int32_t code = (*msgcb->putToQueueFp)(msgcb->mgmt, qtype, pMsg); if (code != 0) { rpcFreeCont(pMsg->pCont); @@ -59,3 +58,7 @@ void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg) { (*defaultMsgCb.registerBrokenLin void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type) { (*defaultMsgCb.releaseHandleFp)(pHandle, type); } void tmsgReportStartup(const char* name, const char* desc) { (*defaultMsgCb.reportStartupFp)(name, desc); } + +int32_t tmsgUpdateDnodeInfo(int32_t* dnodeId, int64_t* clusterId, char* fqdn, uint16_t* port) { + return (*defaultMsgCb.updateDnodeInfoFp)(defaultMsgCb.data, dnodeId, clusterId, fqdn, port); +} diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index 55c3c61b05..47b1ac5ca7 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -160,21 +160,12 @@ int rpcSendRecv(void* shandle, SEpSet* pEpSet, SRpcMsg* pMsg, SRpcMsg* pRsp) { int rpcSendResponse(const SRpcMsg* pMsg) { return transSendResponse(pMsg); } -void rpcRefHandle(void* handle, int8_t type) { - assert(type == TAOS_CONN_SERVER || type == TAOS_CONN_CLIENT); - (*taosRefHandle[type])(handle); -} +void rpcRefHandle(void* handle, int8_t type) { (*taosRefHandle[type])(handle); } -void rpcUnrefHandle(void* handle, int8_t type) { - assert(type == TAOS_CONN_SERVER || type == TAOS_CONN_CLIENT); - (*taosUnRefHandle[type])(handle); -} +void rpcUnrefHandle(void* handle, int8_t type) { (*taosUnRefHandle[type])(handle); } int rpcRegisterBrokenLinkArg(SRpcMsg* msg) { return transRegisterMsg(msg); } -int rpcReleaseHandle(void* handle, int8_t type) { - assert(type == TAOS_CONN_SERVER || type == TAOS_CONN_CLIENT); - return (*transReleaseHandle[type])(handle); -} +int rpcReleaseHandle(void* handle, int8_t type) { return (*transReleaseHandle[type])(handle); } int rpcSetDefaultAddr(void* thandle, const char* ip, const char* fqdn) { // later diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 1dc79e0cfb..2632d290e9 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -651,7 +651,6 @@ static void cliRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { return; } - assert(nread <= 0); if (nread == 0) { // ref http://docs.libuv.org/en/v1.x/stream.html?highlight=uv_read_start#c.uv_read_cb // nread might be 0, which does not indicate an error or EOF. This is equivalent to EAGAIN or EWOULDBLOCK under @@ -801,7 +800,11 @@ static void cliSendCb(uv_write_t* req, int status) { } void cliSend(SCliConn* pConn) { - assert(!transQueueEmpty(&pConn->cliMsgs)); + bool empty = transQueueEmpty(&pConn->cliMsgs); + ASSERTS(empty == false, "trans-cli get invalid msg"); + if (empty == true) { + return; + } SCliMsg* pCliMsg = NULL; CONN_GET_NEXT_SENDMSG(pConn); @@ -933,7 +936,6 @@ void cliConnCb(uv_connect_t* req, int status) { transSockInfo2Str(&sockname, pConn->src); tTrace("%s conn %p connect to server successfully", CONN_GET_INST_LABEL(pConn), pConn); - assert(pConn->stream == req->handle); cliSend(pConn); } @@ -1237,7 +1239,7 @@ bool cliRecvReleaseReq(SCliConn* conn, STransMsgHead* pHead) { for (int i = 0; ahandle == 0 && i < transQueueSize(&conn->cliMsgs); i++) { SCliMsg* cliMsg = transQueueGet(&conn->cliMsgs, i); if (cliMsg->type == Release) { - assert(pMsg == NULL); + ASSERTS(pMsg == NULL, "trans-cli recv invaid release-req"); return true; } } @@ -1665,7 +1667,8 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { if (pCtx->retryCode != TSDB_CODE_SUCCESS) { int32_t code = pResp->code; // return internal code app - if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED) { + if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || + code == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED) { pResp->code = pCtx->retryCode; } } diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 09f9a78ab8..1161ed7c00 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -134,7 +134,9 @@ int transDumpFromBuffer(SConnBuffer* connBuf, char** buf) { if (total >= HEADSIZE && !p->invalid) { *buf = taosMemoryCalloc(1, total); memcpy(*buf, p->buf, total); - transResetBuffer(connBuf); + if (transResetBuffer(connBuf) < 0) { + return -1; + } } else { total = -1; } @@ -154,7 +156,8 @@ int transResetBuffer(SConnBuffer* connBuf) { p->total = 0; p->len = 0; } else { - assert(0); + ASSERTS(0, "invalid read from sock buf"); + return -1; } return 0; } diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index 7384877313..fa8929f7d9 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -267,7 +267,10 @@ static bool uvHandleReq(SSvrConn* pConn) { tGTrace("%s handle %p conn:%p translated to app, refId:%" PRIu64, transLabel(pTransInst), transMsg.info.handle, pConn, pConn->refId); - assert(transMsg.info.handle != NULL); + ASSERTS(transMsg.info.handle != NULL, "trans-svr failed to alloc handle to msg"); + if (transMsg.info.handle == NULL) { + return false; + } if (pHead->noResp == 1) { transMsg.info.refId = -1; @@ -718,8 +721,8 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) { return; } // free memory allocated by - assert(nread == strlen(notify)); - assert(buf->base[0] == notify[0]); + ASSERTS(nread == strlen(notify), "trans-svr mem corrupted"); + ASSERTS(buf->base[0] == notify[0], "trans-svr mem corrupted"); taosMemoryFree(buf->base); SWorkThrd* pThrd = q->data; @@ -731,7 +734,6 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) { } uv_handle_type pending = uv_pipe_pending_type(pipe); - assert(pending == UV_TCP); SSvrConn* pConn = createConn(pThrd); @@ -971,19 +973,24 @@ static void uvPipeListenCb(uv_stream_t* handle, int status) { uv_pipe_t* pipe = &(srv->pipe[srv->numOfWorkerReady][0]); int ret = uv_pipe_init(srv->loop, pipe, 1); - assert(ret == 0); + ASSERTS(ret == 0, "trans-svr failed to init pipe"); + if (ret != 0) return; ret = uv_accept((uv_stream_t*)&srv->pipeListen, (uv_stream_t*)pipe); - assert(ret == 0); + ASSERTS(ret == 0, "trans-svr failed to accept pipe msg"); + if (ret != 0) return; ret = uv_is_readable((uv_stream_t*)pipe); - assert(ret == 1); + ASSERTS(ret == 1, "trans-svr pipe status corrupted"); + if (ret != 1) return; ret = uv_is_writable((uv_stream_t*)pipe); - assert(ret == 1); + ASSERTS(ret == 1, "trans-svr pipe status corrupted"); + if (ret != 1) return; ret = uv_is_closing((uv_handle_t*)pipe); - assert(ret == 0); + ASSERTS(ret == 0, "trans-svr pipe status corrupted"); + if (ret != 0) return; srv->numOfWorkerReady++; } @@ -1272,7 +1279,6 @@ int transSendResponse(const STransMsg* msg) { SExHandle* exh = msg->info.handle; int64_t refId = msg->info.refId; ASYNC_CHECK_HANDLE(exh, refId); - assert(refId != 0); STransMsg tmsg = *msg; tmsg.info.refId = refId; diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index ab9829538d..3f527e9130 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -39,14 +39,6 @@ #define _SEND_FILE_STEP_ 1000 #endif -#if defined(WINDOWS) -typedef int32_t FileFd; -typedef int32_t SocketFd; -#else -typedef int32_t FileFd; -typedef int32_t SocketFd; -#endif - typedef int32_t FileFd; typedef struct TdFile { @@ -54,19 +46,10 @@ typedef struct TdFile { int refId; FileFd fd; FILE *fp; -} * TdFilePtr, TdFile; +} TdFile; #define FILE_WITH_LOCK 1 -typedef struct AutoDelFile *AutoDelFilePtr; -typedef struct AutoDelFile { - char *name; - AutoDelFilePtr lastAutoDelFilePtr; -} AutoDelFile; -static TdThreadMutex autoDelFileLock; -static AutoDelFilePtr nowAutoDelFilePtr = NULL; -static TdThreadOnce autoDelFileInit = PTHREAD_ONCE_INIT; - void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath) { #ifdef WINDOWS const char *tdengineTmpFileNamePrefix = "tdengine-"; @@ -268,34 +251,6 @@ int32_t taosDevInoFile(TdFilePtr pFile, int64_t *stDev, int64_t *stIno) { return 0; } -void autoDelFileList() { - taosThreadMutexLock(&autoDelFileLock); - while (nowAutoDelFilePtr != NULL) { - taosRemoveFile(nowAutoDelFilePtr->name); - AutoDelFilePtr tmp = nowAutoDelFilePtr->lastAutoDelFilePtr; - taosMemoryFree(nowAutoDelFilePtr->name); - taosMemoryFree(nowAutoDelFilePtr); - nowAutoDelFilePtr = tmp; - } - taosThreadMutexUnlock(&autoDelFileLock); - taosThreadMutexDestroy(&autoDelFileLock); -} - -void autoDelFileListInit() { - taosThreadMutexInit(&autoDelFileLock, NULL); - atexit(autoDelFileList); -} - -void autoDelFileListAdd(const char *path) { - taosThreadOnce(&autoDelFileInit, autoDelFileListInit); - taosThreadMutexLock(&autoDelFileLock); - AutoDelFilePtr tmp = taosMemoryMalloc(sizeof(AutoDelFile)); - tmp->lastAutoDelFilePtr = nowAutoDelFilePtr; - tmp->name = taosMemoryStrDup(path); - nowAutoDelFilePtr = tmp; - taosThreadMutexUnlock(&autoDelFileLock); -} - TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) { int fd = -1; FILE *fp = NULL; @@ -313,7 +268,6 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) { assert(!(tdFileOptions & TD_FILE_EXCL)); fp = fopen(path, mode); if (fp == NULL) { - // terrno = TAOS_SYSTEM_ERROR(errno); return NULL; } } else { @@ -331,32 +285,44 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) { access |= (tdFileOptions & TD_FILE_TEXT) ? O_TEXT : 0; access |= (tdFileOptions & TD_FILE_EXCL) ? O_EXCL : 0; #ifdef WINDOWS - fd = _open(path, access, _S_IREAD | _S_IWRITE); + int32_t pmode = _S_IREAD | _S_IWRITE; + if (tdFileOptions & TD_FILE_AUTO_DEL) { + pmode |= _O_TEMPORARY; + } + fd = _open(path, access, pmode); #else fd = open(path, access, S_IRWXU | S_IRWXG | S_IRWXO); #endif if (fd == -1) { - // terrno = TAOS_SYSTEM_ERROR(errno); return NULL; } } TdFilePtr pFile = (TdFilePtr)taosMemoryMalloc(sizeof(TdFile)); if (pFile == NULL) { - // terrno = TSDB_CODE_OUT_OF_MEMORY; if (fd >= 0) close(fd); if (fp != NULL) fclose(fp); return NULL; } + #if FILE_WITH_LOCK taosThreadRwlockInit(&(pFile->rwlock), NULL); #endif pFile->fd = fd; pFile->fp = fp; pFile->refId = 0; + if (tdFileOptions & TD_FILE_AUTO_DEL) { - autoDelFileListAdd(path); +#ifdef WINDOWS + // do nothing, since the property of pmode is set with _O_TEMPORARY; the OS will recycle + // the file handle, as well as the space on disk. +#else + // Remove it instantly, so when the program exits normally/abnormally, the file + // will be automatically remove by OS. + unlink(path); +#endif } + return pFile; } diff --git a/source/util/src/talgo.c b/source/util/src/talgo.c index 057d3a620c..d9319485b7 100644 --- a/source/util/src/talgo.c +++ b/source/util/src/talgo.c @@ -39,7 +39,7 @@ static void median(void *src, int64_t size, int64_t s, int64_t e, const void *pa doswap(elePtrAt(src, size, s), elePtrAt(src, size, e), size, buf); } - assert(comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, s), param) <= 0 && + ASSERT(comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, s), param) <= 0 && comparFn(elePtrAt(src, size, s), elePtrAt(src, size, e), param) <= 0); #ifdef _DEBUG_VIEW diff --git a/source/util/src/tbuffer.c b/source/util/src/tbuffer.c deleted file mode 100644 index d2fac72c77..0000000000 --- a/source/util/src/tbuffer.c +++ /dev/null @@ -1,424 +0,0 @@ -/* - * Copyright (c) 2020 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#define _DEFAULT_SOURCE -#include "tbuffer.h" -#include "texception.h" - -typedef union Un4B { - uint32_t ui; - float f; -} Un4B; -#if __STDC_VERSION__ >= 201112LL -static_assert(sizeof(Un4B) == sizeof(uint32_t), "sizeof(Un4B) must equal to sizeof(uint32_t)"); -static_assert(sizeof(Un4B) == sizeof(float), "sizeof(Un4B) must equal to sizeof(float)"); -#endif - -typedef union Un8B { - uint64_t ull; - double d; -} Un8B; -#if __STDC_VERSION__ >= 201112LL -static_assert(sizeof(Un8B) == sizeof(uint64_t), "sizeof(Un8B) must equal to sizeof(uint64_t)"); -static_assert(sizeof(Un8B) == sizeof(double), "sizeof(Un8B) must equal to sizeof(double)"); -#endif - -//////////////////////////////////////////////////////////////////////////////// -// reader functions - -size_t tbufSkip(SBufferReader* buf, size_t size) { - if ((buf->pos + size) > buf->size) { - THROW(-1); - } - size_t old = buf->pos; - buf->pos += size; - return old; -} - -const char* tbufRead(SBufferReader* buf, size_t size) { - const char* ret = buf->data + buf->pos; - tbufSkip(buf, size); - return ret; -} - -void tbufReadToBuffer(SBufferReader* buf, void* dst, size_t size) { - assert(dst != NULL); - // always using memcpy, leave optimization to compiler - memcpy(dst, tbufRead(buf, size), size); -} - -static size_t tbufReadLength(SBufferReader* buf) { - // maximum length is 65535, if larger length is required - // this function and the corresponding write function need to be - // revised. - uint16_t l = tbufReadUint16(buf); - return l; -} - -const char* tbufReadString(SBufferReader* buf, size_t* len) { - size_t l = tbufReadLength(buf); - const char* ret = buf->data + buf->pos; - tbufSkip(buf, l + 1); - if (ret[l] != 0) { - THROW(-1); - } - if (len != NULL) { - *len = l; - } - return ret; -} - -size_t tbufReadToString(SBufferReader* buf, char* dst, size_t size) { - assert(dst != NULL); - size_t len; - const char* str = tbufReadString(buf, &len); - if (len >= size) { - len = size - 1; - } - memcpy(dst, str, len); - dst[len] = 0; - return len; -} - -const char* tbufReadBinary(SBufferReader* buf, size_t* len) { - size_t l = tbufReadLength(buf); - const char* ret = buf->data + buf->pos; - tbufSkip(buf, l); - if (len != NULL) { - *len = l; - } - return ret; -} - -size_t tbufReadToBinary(SBufferReader* buf, void* dst, size_t size) { - assert(dst != NULL); - size_t len; - const char* data = tbufReadBinary(buf, &len); - if (len >= size) { - len = size; - } - memcpy(dst, data, len); - return len; -} - -bool tbufReadBool(SBufferReader* buf) { - bool ret; - tbufReadToBuffer(buf, &ret, sizeof(ret)); - return ret; -} - -char tbufReadChar(SBufferReader* buf) { - char ret; - tbufReadToBuffer(buf, &ret, sizeof(ret)); - return ret; -} - -int8_t tbufReadInt8(SBufferReader* buf) { - int8_t ret; - tbufReadToBuffer(buf, &ret, sizeof(ret)); - return ret; -} - -uint8_t tbufReadUint8(SBufferReader* buf) { - uint8_t ret; - tbufReadToBuffer(buf, &ret, sizeof(ret)); - return ret; -} - -int16_t tbufReadInt16(SBufferReader* buf) { - int16_t ret; - tbufReadToBuffer(buf, &ret, sizeof(ret)); - if (buf->endian) { - return (int16_t)ntohs(ret); - } - return ret; -} - -uint16_t tbufReadUint16(SBufferReader* buf) { - uint16_t ret; - tbufReadToBuffer(buf, &ret, sizeof(ret)); - if (buf->endian) { - return ntohs(ret); - } - return ret; -} - -int32_t tbufReadInt32(SBufferReader* buf) { - int32_t ret; - tbufReadToBuffer(buf, &ret, sizeof(ret)); - if (buf->endian) { - return (int32_t)ntohl(ret); - } - return ret; -} - -uint32_t tbufReadUint32(SBufferReader* buf) { - uint32_t ret; - tbufReadToBuffer(buf, &ret, sizeof(ret)); - if (buf->endian) { - return ntohl(ret); - } - return ret; -} - -int64_t tbufReadInt64(SBufferReader* buf) { - int64_t ret; - tbufReadToBuffer(buf, &ret, sizeof(ret)); - if (buf->endian) { - return (int64_t)htobe64(ret); // TODO: ntohll - } - return ret; -} - -uint64_t tbufReadUint64(SBufferReader* buf) { - uint64_t ret; - tbufReadToBuffer(buf, &ret, sizeof(ret)); - if (buf->endian) { - return htobe64(ret); // TODO: ntohll - } - return ret; -} - -float tbufReadFloat(SBufferReader* buf) { - Un4B _un; - tbufReadToBuffer(buf, &_un, sizeof(_un)); - if (buf->endian) { - _un.ui = ntohl(_un.ui); - } - return _un.f; -} - -double tbufReadDouble(SBufferReader* buf) { - Un8B _un; - tbufReadToBuffer(buf, &_un, sizeof(_un)); - if (buf->endian) { - _un.ull = htobe64(_un.ull); - } - return _un.d; -} - -//////////////////////////////////////////////////////////////////////////////// -// writer functions - -void tbufCloseWriter(SBufferWriter* buf) { - taosMemoryFreeClear(buf->data); - // (*buf->allocator)( buf->data, 0 ); // potential memory leak. - buf->data = NULL; - buf->pos = 0; - buf->size = 0; -} - -void tbufEnsureCapacity(SBufferWriter* buf, size_t size) { - size += buf->pos; - if (size > buf->size) { - size_t nsize = size + buf->size; - char* data = (*buf->allocator)(buf->data, nsize); - // TODO: the exception should be thrown by the allocator function - if (data == NULL) { - THROW(-1); - } - buf->data = data; - buf->size = nsize; - } -} - -size_t tbufReserve(SBufferWriter* buf, size_t size) { - tbufEnsureCapacity(buf, size); - size_t old = buf->pos; - buf->pos += size; - return old; -} - -char* tbufGetData(SBufferWriter* buf, bool takeOver) { - char* ret = buf->data; - if (takeOver) { - buf->pos = 0; - buf->size = 0; - buf->data = NULL; - } - return ret; -} - -void tbufWrite(SBufferWriter* buf, const void* data, size_t size) { - assert(data != NULL); - tbufEnsureCapacity(buf, size); - memcpy(buf->data + buf->pos, data, size); - buf->pos += size; -} - -void tbufWriteAt(SBufferWriter* buf, size_t pos, const void* data, size_t size) { - assert(data != NULL); - // this function can only be called to fill the gap on previous writes, - // so 'pos + size <= buf->pos' must be true - assert(pos + size <= buf->pos); - memcpy(buf->data + pos, data, size); -} - -static void tbufWriteLength(SBufferWriter* buf, size_t len) { - // maximum length is 65535, if larger length is required - // this function and the corresponding read function need to be - // revised. - assert(len <= 0xffff); - tbufWriteUint16(buf, (uint16_t)len); -} - -void tbufWriteStringLen(SBufferWriter* buf, const char* str, size_t len) { - tbufWriteLength(buf, len); - tbufWrite(buf, str, len); - tbufWriteChar(buf, '\0'); -} - -void tbufWriteString(SBufferWriter* buf, const char* str) { tbufWriteStringLen(buf, str, strlen(str)); } - -void tbufWriteBinary(SBufferWriter* buf, const void* data, size_t len) { - tbufWriteLength(buf, len); - tbufWrite(buf, data, len); -} - -void tbufWriteBool(SBufferWriter* buf, bool data) { tbufWrite(buf, &data, sizeof(data)); } - -void tbufWriteBoolAt(SBufferWriter* buf, size_t pos, bool data) { tbufWriteAt(buf, pos, &data, sizeof(data)); } - -void tbufWriteChar(SBufferWriter* buf, char data) { tbufWrite(buf, &data, sizeof(data)); } - -void tbufWriteCharAt(SBufferWriter* buf, size_t pos, char data) { tbufWriteAt(buf, pos, &data, sizeof(data)); } - -void tbufWriteInt8(SBufferWriter* buf, int8_t data) { tbufWrite(buf, &data, sizeof(data)); } - -void tbufWriteInt8At(SBufferWriter* buf, size_t pos, int8_t data) { tbufWriteAt(buf, pos, &data, sizeof(data)); } - -void tbufWriteUint8(SBufferWriter* buf, uint8_t data) { tbufWrite(buf, &data, sizeof(data)); } - -void tbufWriteUint8At(SBufferWriter* buf, size_t pos, uint8_t data) { tbufWriteAt(buf, pos, &data, sizeof(data)); } - -void tbufWriteInt16(SBufferWriter* buf, int16_t data) { - if (buf->endian) { - data = (int16_t)htons(data); - } - tbufWrite(buf, &data, sizeof(data)); -} - -void tbufWriteInt16At(SBufferWriter* buf, size_t pos, int16_t data) { - if (buf->endian) { - data = (int16_t)htons(data); - } - tbufWriteAt(buf, pos, &data, sizeof(data)); -} - -void tbufWriteUint16(SBufferWriter* buf, uint16_t data) { - if (buf->endian) { - data = htons(data); - } - tbufWrite(buf, &data, sizeof(data)); -} - -void tbufWriteUint16At(SBufferWriter* buf, size_t pos, uint16_t data) { - if (buf->endian) { - data = htons(data); - } - tbufWriteAt(buf, pos, &data, sizeof(data)); -} - -void tbufWriteInt32(SBufferWriter* buf, int32_t data) { - if (buf->endian) { - data = (int32_t)htonl(data); - } - tbufWrite(buf, &data, sizeof(data)); -} - -void tbufWriteInt32At(SBufferWriter* buf, size_t pos, int32_t data) { - if (buf->endian) { - data = (int32_t)htonl(data); - } - tbufWriteAt(buf, pos, &data, sizeof(data)); -} - -void tbufWriteUint32(SBufferWriter* buf, uint32_t data) { - if (buf->endian) { - data = htonl(data); - } - tbufWrite(buf, &data, sizeof(data)); -} - -void tbufWriteUint32At(SBufferWriter* buf, size_t pos, uint32_t data) { - if (buf->endian) { - data = htonl(data); - } - tbufWriteAt(buf, pos, &data, sizeof(data)); -} - -void tbufWriteInt64(SBufferWriter* buf, int64_t data) { - if (buf->endian) { - data = (int64_t)htobe64(data); - } - tbufWrite(buf, &data, sizeof(data)); -} - -void tbufWriteInt64At(SBufferWriter* buf, size_t pos, int64_t data) { - if (buf->endian) { - data = (int64_t)htobe64(data); - } - tbufWriteAt(buf, pos, &data, sizeof(data)); -} - -void tbufWriteUint64(SBufferWriter* buf, uint64_t data) { - if (buf->endian) { - data = htobe64(data); - } - tbufWrite(buf, &data, sizeof(data)); -} - -void tbufWriteUint64At(SBufferWriter* buf, size_t pos, uint64_t data) { - if (buf->endian) { - data = htobe64(data); - } - tbufWriteAt(buf, pos, &data, sizeof(data)); -} - -void tbufWriteFloat(SBufferWriter* buf, float data) { - Un4B _un; - _un.f = data; - if (buf->endian) { - _un.ui = htonl(_un.ui); - } - tbufWrite(buf, &_un, sizeof(_un)); -} - -void tbufWriteFloatAt(SBufferWriter* buf, size_t pos, float data) { - Un4B _un; - _un.f = data; - if (buf->endian) { - _un.ui = htonl(_un.ui); - } - tbufWriteAt(buf, pos, &_un, sizeof(_un)); -} - -void tbufWriteDouble(SBufferWriter* buf, double data) { - Un8B _un; - _un.d = data; - if (buf->endian) { - _un.ull = htobe64(_un.ull); - } - tbufWrite(buf, &_un, sizeof(_un)); -} - -void tbufWriteDoubleAt(SBufferWriter* buf, size_t pos, double data) { - Un8B _un; - _un.d = data; - if (buf->endian) { - _un.ull = htobe64(_un.ull); - } - tbufWriteAt(buf, pos, &_un, sizeof(_un)); -} diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c index 3edd067ce2..ed254b651f 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -21,6 +21,7 @@ #include "tdef.h" #include "thash.h" #include "tlog.h" +#include "tutil.h" #include "types.h" int32_t setChkInBytes1(const void *pLeft, const void *pRight) { @@ -243,7 +244,7 @@ int32_t compareJsonVal(const void *pLeft, const void *pRight) { } else if (leftType == TSDB_DATA_TYPE_NULL) { return 0; } else { - assert(0); + ASSERTS(0, "data type unexpected"); return 0; } } @@ -997,6 +998,7 @@ int32_t compareUint64Uint32(const void *pLeft, const void *pRight) { } int32_t compareJsonValDesc(const void *pLeft, const void *pRight) { return compareJsonVal(pRight, pLeft); } + /* * Compare two strings * TSDB_MATCH: Match @@ -1007,59 +1009,63 @@ int32_t compareJsonValDesc(const void *pLeft, const void *pRight) { return compa * '_': Matches one character * */ -int32_t patternMatch(const char *patterStr, const char *str, size_t size, const SPatternCompareInfo *pInfo) { +int32_t patternMatch(const char *pattern, size_t psize, const char *str, size_t ssize, + const SPatternCompareInfo *pInfo) { char c, c1; int32_t i = 0; int32_t j = 0; - int32_t o = 0; - int32_t m = 0; + int32_t nMatchChar = 0; - while ((c = patterStr[i++]) != 0) { + while ((i < psize) && ((c = pattern[i++]) != 0)) { if (c == pInfo->matchAll) { /* Match "*" */ - while ((c = patterStr[i++]) == pInfo->matchAll || c == pInfo->matchOne) { + while ((i < psize) && ((c = pattern[i++]) == pInfo->matchAll || c == pInfo->matchOne)) { if (c == pInfo->matchOne) { - if (j > size || str[j++] == 0) { - // empty string, return not match + if (j >= ssize || str[j++] == 0) { // empty string, return not match return TSDB_PATTERN_NOWILDCARDMATCH; } else { - ++o; + ++nMatchChar; } } } - if (c == 0) { + if (i >= psize && (c == pInfo->umatchOne || c == pInfo->umatchAll)) { return TSDB_PATTERN_MATCH; /* "*" at the end of the pattern matches */ } - char next[3] = {toupper(c), tolower(c), 0}; - m = o; - while (1) { - size_t n = strcspn(str + m, next); - str += m + n; + char rejectList[2] = {toupper(c), tolower(c)}; - if (str[0] == 0 || (n >= size)) { + str += nMatchChar; + int32_t remain = ssize - nMatchChar; + while (1) { + size_t n = tstrncspn(str, remain, rejectList, 2); + + str += n; + remain -= n; + + if ((remain <= 0) || str[0] == 0) { break; } - int32_t ret = patternMatch(&patterStr[i], ++str, size - n - 1, pInfo); + int32_t ret = patternMatch(&pattern[i], psize - i, ++str, --remain, pInfo); if (ret != TSDB_PATTERN_NOMATCH) { return ret; } - m = 0; } + return TSDB_PATTERN_NOWILDCARDMATCH; } - c1 = str[j++]; - ++o; + if (j < ssize) { + c1 = str[j++]; + ++nMatchChar; - if (j <= size) { - if (c == '\\' && patterStr[i] == '_' && c1 == '_') { + if (c == '\\' && pattern[i] == '_' && c1 == '_') { i++; continue; } + if (c == c1 || tolower(c) == tolower(c1) || (c == pInfo->matchOne && c1 != 0)) { continue; } @@ -1068,39 +1074,49 @@ int32_t patternMatch(const char *patterStr, const char *str, size_t size, const return TSDB_PATTERN_NOMATCH; } - return (str[j] == 0 || j >= size) ? TSDB_PATTERN_MATCH : TSDB_PATTERN_NOMATCH; + return (j >= ssize || str[j] == 0) ? TSDB_PATTERN_MATCH : TSDB_PATTERN_NOMATCH; } -int32_t WCSPatternMatch(const TdUcs4 *patterStr, const TdUcs4 *str, size_t size, const SPatternCompareInfo *pInfo) { +int32_t wcsPatternMatch(const TdUcs4 *pattern, size_t psize, const TdUcs4 *str, size_t ssize, + const SPatternCompareInfo *pInfo) { TdUcs4 c, c1; - TdUcs4 matchOne = L'_'; // "_" - TdUcs4 matchAll = L'%'; // "%" int32_t i = 0; int32_t j = 0; + int32_t nMatchChar = 0; - while ((c = patterStr[i++]) != 0) { - if (c == matchAll) { /* Match "%" */ + while ((i < psize) && ((c = pattern[i++]) != 0)) { + if (c == pInfo->umatchAll) { /* Match "%" */ - while ((c = patterStr[i++]) == matchAll || c == matchOne) { - if (c == matchOne && (j >= size || str[j++] == 0)) { - return TSDB_PATTERN_NOWILDCARDMATCH; + while ((i < psize) && ((c = pattern[i++]) == pInfo->umatchAll || c == pInfo->umatchOne)) { + if (c == pInfo->umatchOne) { + if (j >= ssize || str[j++] == 0) { + return TSDB_PATTERN_NOWILDCARDMATCH; + } else { + ++nMatchChar; + } } } - if (c == 0) { + + if (i >= psize && (c == pInfo->umatchOne || c == pInfo->umatchAll)) { return TSDB_PATTERN_MATCH; } - TdUcs4 accept[3] = {towupper(c), towlower(c), 0}; + TdUcs4 rejectList[2] = {towupper(c), towlower(c)}; + + str += nMatchChar; + int32_t remain = ssize - nMatchChar; while (1) { - size_t n = wcscspn(str, accept); + size_t n = twcsncspn(str, remain, rejectList, 2); str += n; - if (str[0] == 0 || (n >= size)) { + remain -= n; + + if ((remain <= 0) || str[0] == 0) { break; } - int32_t ret = WCSPatternMatch(&patterStr[i], ++str, size - n - 1, pInfo); + int32_t ret = wcsPatternMatch(&pattern[i], psize - i, ++str, --remain, pInfo); if (ret != TSDB_PATTERN_NOMATCH) { return ret; } @@ -1109,10 +1125,16 @@ int32_t WCSPatternMatch(const TdUcs4 *patterStr, const TdUcs4 *str, size_t size, return TSDB_PATTERN_NOWILDCARDMATCH; } - c1 = str[j++]; + if (j < ssize) { + c1 = str[j++]; + nMatchChar++; - if (j <= size) { - if (c == c1 || towlower(c) == towlower(c1) || (c == matchOne && c1 != 0)) { + if (c == L'\\' && pattern[i] == L'_' && c1 == L'_') { + i++; + continue; + } + + if (c == c1 || towlower(c) == towlower(c1) || (c == pInfo->umatchOne && c1 != 0)) { continue; } } @@ -1120,16 +1142,39 @@ int32_t WCSPatternMatch(const TdUcs4 *patterStr, const TdUcs4 *str, size_t size, return TSDB_PATTERN_NOMATCH; } - return (j >= size || str[j] == 0) ? TSDB_PATTERN_MATCH : TSDB_PATTERN_NOMATCH; + return (j >= ssize || str[j] == 0) ? TSDB_PATTERN_MATCH : TSDB_PATTERN_NOMATCH; } -int32_t compareStrRegexCompMatch(const void *pLeft, const void *pRight) { return compareStrRegexComp(pLeft, pRight); } - -int32_t compareStrRegexCompNMatch(const void *pLeft, const void *pRight) { - return compareStrRegexComp(pLeft, pRight) ? 0 : 1; +int32_t comparestrRegexNMatch(const void *pLeft, const void *pRight) { + return comparestrRegexMatch(pLeft, pRight) ? 0 : 1; } -int32_t compareStrRegexComp(const void *pLeft, const void *pRight) { +static int32_t doExecRegexMatch(const char *pString, const char *pPattern) { + int32_t ret = 0; + regex_t regex; + char msgbuf[256] = {0}; + + int32_t cflags = REG_EXTENDED; + if ((ret = regcomp(®ex, pPattern, cflags)) != 0) { + regerror(ret, ®ex, msgbuf, tListLen(msgbuf)); + + uError("Failed to compile regex pattern %s. reason %s", pPattern, msgbuf); + regfree(®ex); + return 1; + } + + regmatch_t pmatch[1]; + ret = regexec(®ex, pString, 1, pmatch, 0); + if (ret != 0 && ret != REG_NOMATCH) { + regerror(ret, ®ex, msgbuf, sizeof(msgbuf)); + uDebug("Failed to match %s with pattern %s, reason %s", pString, pPattern, msgbuf) + } + + regfree(®ex); + return (ret == 0) ? 0 : 1; +} + +int32_t comparestrRegexMatch(const void *pLeft, const void *pRight) { size_t sz = varDataLen(pRight); char *pattern = taosMemoryMalloc(sz + 1); memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); @@ -1140,30 +1185,49 @@ int32_t compareStrRegexComp(const void *pLeft, const void *pRight) { memcpy(str, varDataVal(pLeft), sz); str[sz] = 0; - int32_t errCode = 0; - regex_t regex; - char msgbuf[256] = {0}; + int32_t ret = doExecRegexMatch(str, pattern); - int32_t cflags = REG_EXTENDED; - if ((errCode = regcomp(®ex, pattern, cflags)) != 0) { - regerror(errCode, ®ex, msgbuf, sizeof(msgbuf)); - uError("Failed to compile regex pattern %s. reason %s", pattern, msgbuf); - regfree(®ex); - taosMemoryFree(str); - taosMemoryFree(pattern); - return 1; - } - - errCode = regexec(®ex, str, 0, NULL, 0); - if (errCode != 0 && errCode != REG_NOMATCH) { - regerror(errCode, ®ex, msgbuf, sizeof(msgbuf)); - uDebug("Failed to match %s with pattern %s, reason %s", str, pattern, msgbuf) - } - int32_t result = (errCode == 0) ? 0 : 1; - regfree(®ex); taosMemoryFree(str); taosMemoryFree(pattern); - return result; + + return (ret == 0) ? 0 : 1; + ; +} + +int32_t comparewcsRegexMatch(const void *pString, const void *pPattern) { + size_t len = varDataLen(pPattern); + char *pattern = taosMemoryMalloc(len + 1); + + int convertLen = taosUcs4ToMbs((TdUcs4 *)varDataVal(pPattern), len, pattern); + if (convertLen < 0) { + taosMemoryFree(pattern); + return TSDB_CODE_APP_ERROR; + } + + pattern[convertLen] = 0; + + len = varDataLen(pString); + char *str = taosMemoryMalloc(len + 1); + convertLen = taosUcs4ToMbs((TdUcs4 *)varDataVal(pString), len, str); + if (convertLen < 0) { + taosMemoryFree(str); + taosMemoryFree(pattern); + + return TSDB_CODE_APP_ERROR; + } + + str[convertLen] = 0; + + int32_t ret = doExecRegexMatch(str, pattern); + + taosMemoryFree(str); + taosMemoryFree(pattern); + + return (ret == 0) ? 0 : 1; +} + +int32_t comparewcsRegexNMatch(const void *pLeft, const void *pRight) { + return comparewcsRegexMatch(pLeft, pRight) ? 0 : 1; } int32_t taosArrayCompareString(const void *a, const void *b) { @@ -1173,46 +1237,35 @@ int32_t taosArrayCompareString(const void *a, const void *b) { return compareLenPrefixedStr(x, y); } -int32_t compareStrPatternMatch(const void *pLeft, const void *pRight) { - SPatternCompareInfo pInfo = {'%', '_'}; - - assert(varDataLen(pRight) <= TSDB_MAX_FIELD_LEN); - char *pattern = taosMemoryCalloc(varDataLen(pRight) + 1, sizeof(char)); - memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); +int32_t comparestrPatternMatch(const void *pLeft, const void *pRight) { + SPatternCompareInfo pInfo = PATTERN_COMPARE_INFO_INITIALIZER; + ASSERT(varDataLen(pRight) <= TSDB_MAX_FIELD_LEN); + size_t pLen = varDataLen(pRight); size_t sz = varDataLen(pLeft); - char *buf = taosMemoryMalloc(sz + 1); - memcpy(buf, varDataVal(pLeft), sz); - buf[sz] = 0; - int32_t ret = patternMatch(pattern, buf, sz, &pInfo); - taosMemoryFree(buf); - taosMemoryFree(pattern); + int32_t ret = patternMatch(varDataVal(pRight), pLen, varDataVal(pLeft), sz, &pInfo); return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; } -int32_t compareStrPatternNotMatch(const void *pLeft, const void *pRight) { - return compareStrPatternMatch(pLeft, pRight) ? 0 : 1; +int32_t comparestrPatternNMatch(const void *pLeft, const void *pRight) { + return comparestrPatternMatch(pLeft, pRight) ? 0 : 1; } -int32_t compareWStrPatternMatch(const void *pLeft, const void *pRight) { - SPatternCompareInfo pInfo = {'%', '_'}; +int32_t comparewcsPatternMatch(const void *pLeft, const void *pRight) { + SPatternCompareInfo pInfo = PATTERN_COMPARE_INFO_INITIALIZER; - assert(varDataLen(pRight) <= TSDB_MAX_FIELD_LEN * TSDB_NCHAR_SIZE); - - char *pattern = taosMemoryCalloc(varDataLen(pRight) + TSDB_NCHAR_SIZE, 1); - memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); - - int32_t ret = - WCSPatternMatch((TdUcs4 *)pattern, (TdUcs4 *)varDataVal(pLeft), varDataLen(pLeft) / TSDB_NCHAR_SIZE, &pInfo); - taosMemoryFree(pattern); + size_t psize = varDataLen(pRight); + int32_t ret = wcsPatternMatch((TdUcs4 *)varDataVal(pRight), psize / TSDB_NCHAR_SIZE, (TdUcs4 *)varDataVal(pLeft), + varDataLen(pLeft) / TSDB_NCHAR_SIZE, &pInfo); return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; } -int32_t compareWStrPatternNotMatch(const void *pLeft, const void *pRight) { - return compareWStrPatternMatch(pLeft, pRight) ? 0 : 1; +int32_t comparewcsPatternNMatch(const void *pLeft, const void *pRight) { + return comparewcsPatternMatch(pLeft, pRight) ? 0 : 1; } + __compar_fn_t getComparFunc(int32_t type, int32_t optr) { __compar_fn_t comparFn = NULL; @@ -1235,7 +1288,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { case TSDB_DATA_TYPE_TIMESTAMP: return setChkInBytes8; default: - assert(0); + ASSERTS(0, "data type unexpected"); } } @@ -1258,7 +1311,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { case TSDB_DATA_TYPE_TIMESTAMP: return setChkNotInBytes8; default: - assert(0); + ASSERTS(0, "data type unexpected"); } } @@ -1285,13 +1338,13 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { break; case TSDB_DATA_TYPE_BINARY: { if (optr == OP_TYPE_MATCH) { - comparFn = compareStrRegexCompMatch; + comparFn = comparestrRegexMatch; } else if (optr == OP_TYPE_NMATCH) { - comparFn = compareStrRegexCompNMatch; + comparFn = comparestrRegexNMatch; } else if (optr == OP_TYPE_LIKE) { /* wildcard query using like operator */ - comparFn = compareStrPatternMatch; + comparFn = comparestrPatternMatch; } else if (optr == OP_TYPE_NOT_LIKE) { /* wildcard query using like operator */ - comparFn = compareStrPatternNotMatch; + comparFn = comparestrPatternNMatch; } else if (optr == OP_TYPE_IN) { comparFn = compareChkInString; } else if (optr == OP_TYPE_NOT_IN) { @@ -1305,13 +1358,13 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { case TSDB_DATA_TYPE_NCHAR: { if (optr == OP_TYPE_MATCH) { - comparFn = compareStrRegexCompMatch; + comparFn = comparewcsRegexMatch; } else if (optr == OP_TYPE_NMATCH) { - comparFn = compareStrRegexCompNMatch; + comparFn = comparewcsRegexNMatch; } else if (optr == OP_TYPE_LIKE) { - comparFn = compareWStrPatternMatch; + comparFn = comparewcsPatternMatch; } else if (optr == OP_TYPE_NOT_LIKE) { - comparFn = compareWStrPatternNotMatch; + comparFn = comparewcsPatternNMatch; } else if (optr == OP_TYPE_IN) { comparFn = compareChkInString; } else if (optr == OP_TYPE_NOT_IN) { diff --git a/source/util/src/tcompression.c b/source/util/src/tcompression.c index 18305e594b..64d550e874 100644 --- a/source/util/src/tcompression.c +++ b/source/util/src/tcompression.c @@ -273,42 +273,90 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha char bit = bit_per_integer[(int32_t)selector]; // bit = 3 int32_t elems = selector_to_elems[(int32_t)selector]; - for (int32_t i = 0; i < elems; i++) { - uint64_t zigzag_value; + // Optimize the performance, by remove the constantly switch operation. + int32_t v = 0; + uint64_t zigzag_value; - if (selector == 0 || selector == 1) { - zigzag_value = 0; - } else { - zigzag_value = ((w >> (4 + bit * i)) & INT64MASK(bit)); - } - int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); - int64_t curr_value = diff + prev_value; - prev_value = curr_value; + switch (type) { + case TSDB_DATA_TYPE_BIGINT: { + for (int32_t i = 0; i < elems; i++) { + if (selector == 0 || selector == 1) { + zigzag_value = 0; + } else { + zigzag_value = ((w >> (4 + v)) & INT64MASK(bit)); + } + + int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); + int64_t curr_value = diff + prev_value; + prev_value = curr_value; - switch (type) { - case TSDB_DATA_TYPE_BIGINT: *((int64_t *)output + _pos) = (int64_t)curr_value; _pos++; - break; - case TSDB_DATA_TYPE_INT: + + v += bit; + if ((++count) == nelements) break; + } + } break; + case TSDB_DATA_TYPE_INT: { + for (int32_t i = 0; i < elems; i++) { + if (selector == 0 || selector == 1) { + zigzag_value = 0; + } else { + zigzag_value = ((w >> (4 + v)) & INT64MASK(bit)); + } + + int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); + int64_t curr_value = diff + prev_value; + prev_value = curr_value; + *((int32_t *)output + _pos) = (int32_t)curr_value; _pos++; - break; - case TSDB_DATA_TYPE_SMALLINT: + + v += bit; + if ((++count) == nelements) break; + } + } break; + case TSDB_DATA_TYPE_SMALLINT: { + for (int32_t i = 0; i < elems; i++) { + if (selector == 0 || selector == 1) { + zigzag_value = 0; + } else { + zigzag_value = ((w >> (4 + v)) & INT64MASK(bit)); + } + + int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); + int64_t curr_value = diff + prev_value; + prev_value = curr_value; + *((int16_t *)output + _pos) = (int16_t)curr_value; _pos++; - break; - case TSDB_DATA_TYPE_TINYINT: + + v += bit; + if ((++count) == nelements) break; + } + } break; + + case TSDB_DATA_TYPE_TINYINT: { + for (int32_t i = 0; i < elems; i++) { + if (selector == 0 || selector == 1) { + zigzag_value = 0; + } else { + zigzag_value = ((w >> (4 + v)) & INT64MASK(bit)); + } + + int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); + int64_t curr_value = diff + prev_value; + prev_value = curr_value; + *((int8_t *)output + _pos) = (int8_t)curr_value; _pos++; - break; - default: - perror("Wrong integer types.\n"); - return -1; - } - count++; - if (count == nelements) break; + + v += bit; + if ((++count) == nelements) break; + } + } break; } + ip += LONG_BYTES; } @@ -470,7 +518,7 @@ int32_t tsDecompressStringImp(const char *const input, int32_t compressedSize, c // TODO: Take care here, we assumes little endian encoding. int32_t tsCompressTimestampImp(const char *const input, const int32_t nelements, char *const output) { int32_t _pos = 1; - assert(nelements >= 0); + ASSERTS(nelements >= 0, "nelements is negative"); if (nelements == 0) return 0; @@ -565,7 +613,7 @@ _exit_over: } int32_t tsDecompressTimestampImp(const char *const input, const int32_t nelements, char *const output) { - assert(nelements >= 0); + ASSERTS(nelements >= 0, "nelements is negative"); if (nelements == 0) return 0; if (input[0] == 0) { @@ -629,7 +677,7 @@ int32_t tsDecompressTimestampImp(const char *const input, const int32_t nelement } } else { - assert(0); + ASSERT(0); return -1; } } @@ -758,7 +806,7 @@ int32_t tsDecompressDoubleImp(const char *const input, const int32_t nelements, uint64_t prev_value = 0; for (int32_t i = 0; i < nelements; i++) { - if (i % 2 == 0) { + if ((i & 0x01) == 0) { flags = input[ipos++]; } @@ -2146,7 +2194,7 @@ int32_t tsCompressTimestamp(void *pIn, int32_t nIn, int32_t nEle, void *pOut, in int32_t len = tsCompressTimestampImp(pIn, nEle, pBuf); return tsCompressStringImp(pBuf, len, pOut, nOut); } else { - assert(0); + ASSERTS(0, "compress algo not one or two stage"); return -1; } } @@ -2159,7 +2207,7 @@ int32_t tsDecompressTimestamp(void *pIn, int32_t nIn, int32_t nEle, void *pOut, if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; return tsDecompressTimestampImp(pBuf, nEle, pOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2180,7 +2228,7 @@ int32_t tsCompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_ int32_t len = tsCompressFloatImp(pIn, nEle, pBuf); return tsCompressStringImp(pBuf, len, pOut, nOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } #ifdef TD_TSZ @@ -2203,7 +2251,7 @@ int32_t tsDecompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int3 if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; return tsDecompressFloatImp(pBuf, nEle, pOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } #ifdef TD_TSZ @@ -2227,7 +2275,7 @@ int32_t tsCompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32 int32_t len = tsCompressDoubleImp(pIn, nEle, pBuf); return tsCompressStringImp(pBuf, len, pOut, nOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } #ifdef TD_TSZ @@ -2250,7 +2298,7 @@ int32_t tsDecompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; return tsDecompressDoubleImp(pBuf, nEle, pOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } #ifdef TD_TSZ @@ -2281,7 +2329,7 @@ int32_t tsCompressBool(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t } return tsCompressStringImp(pBuf, len, pOut, nOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2294,7 +2342,7 @@ int32_t tsDecompressBool(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32 if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; return tsDecompressBoolImp(pBuf, nEle, pOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2308,7 +2356,7 @@ int32_t tsCompressTinyint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int3 int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_TINYINT); return tsCompressStringImp(pBuf, len, pOut, nOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2321,7 +2369,7 @@ int32_t tsDecompressTinyint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, in if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_TINYINT); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2335,7 +2383,7 @@ int32_t tsCompressSmallint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_SMALLINT); return tsCompressStringImp(pBuf, len, pOut, nOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2348,7 +2396,7 @@ int32_t tsDecompressSmallint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, i if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_SMALLINT); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2362,7 +2410,7 @@ int32_t tsCompressInt(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_INT); return tsCompressStringImp(pBuf, len, pOut, nOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2375,7 +2423,7 @@ int32_t tsDecompressInt(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_ if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_INT); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2389,7 +2437,7 @@ int32_t tsCompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32 int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_BIGINT); return tsCompressStringImp(pBuf, len, pOut, nOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2402,7 +2450,7 @@ int32_t tsDecompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_BIGINT); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } diff --git a/source/util/src/tdigest.c b/source/util/src/tdigest.c index 337ee803ff..b46a50b2dc 100644 --- a/source/util/src/tdigest.c +++ b/source/util/src/tdigest.c @@ -27,6 +27,7 @@ #include "tdigest.h" #include "os.h" #include "osMath.h" +#include "tlog.h" #define INTERPOLATE(x, x0, x1) (((x) - (x0)) / ((x1) - (x0))) //#define INTEGRATED_LOCATION(compression, q) ((compression) * (asin(2 * (q) - 1) + M_PI / 2) / M_PI) @@ -135,24 +136,24 @@ void tdigestCompress(TDigest *t) { if (a->mean <= b->mean) { mergeCentroid(&args, a); - assert(args.idx < t->size); + ASSERTS(args.idx < t->size, "idx over size"); i++; } else { mergeCentroid(&args, b); - assert(args.idx < t->size); + ASSERTS(args.idx < t->size, "idx over size"); j++; } } while (i < num_unmerged) { mergeCentroid(&args, &unmerged_centroids[i++]); - assert(args.idx < t->size); + ASSERTS(args.idx < t->size, "idx over size"); } taosMemoryFree((void *)unmerged_centroids); while (j < t->num_centroids) { mergeCentroid(&args, &t->centroids[j++]); - assert(args.idx < t->size); + ASSERTS(args.idx < t->size, "idx over size"); } if (t->total_weight > 0) { diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 7bf63abc5f..08ab43494d 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -277,8 +277,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_SUBSCRIBE_NOT_EXIST, "Subcribe not exist") TAOS_DEFINE_ERROR(TSDB_CODE_MND_OFFSET_NOT_EXIST, "Offset not exist") TAOS_DEFINE_ERROR(TSDB_CODE_MND_CONSUMER_NOT_READY, "Consumer not ready") TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOPIC_SUBSCRIBED, "Topic subscribed cannot be dropped") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOPIC_MUST_BE_DELETED, "Topic must be dropped first") TAOS_DEFINE_ERROR(TSDB_CODE_MND_CGROUP_USED, "Consumer group being used by some consumer") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOPIC_MUST_BE_DELETED, "Topic must be dropped first") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SUB_OPTION, "Invalid subscribe option") TAOS_DEFINE_ERROR(TSDB_CODE_MND_IN_REBALANCE, "Topic being rebalanced") // mnode-stream diff --git a/source/util/src/texception.c b/source/util/src/texception.c index 33befb694a..4723e34990 100644 --- a/source/util/src/texception.c +++ b/source/util/src/texception.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "texception.h" +#include "tlog.h" static threadlocal SExceptionNode* expList; @@ -71,7 +72,7 @@ static wrapper wrappers[] = { }; void cleanupPush_void_ptr_ptr(bool failOnly, void* func, void* arg1, void* arg2) { - assert(expList->numCleanupAction < expList->maxCleanupAction); + ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction"); SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++; ca->wrapper = 0; @@ -82,7 +83,7 @@ void cleanupPush_void_ptr_ptr(bool failOnly, void* func, void* arg1, void* arg2) } void cleanupPush_void_ptr_bool(bool failOnly, void* func, void* arg1, bool arg2) { - assert(expList->numCleanupAction < expList->maxCleanupAction); + ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction"); SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++; ca->wrapper = 1; @@ -93,7 +94,7 @@ void cleanupPush_void_ptr_bool(bool failOnly, void* func, void* arg1, bool arg2) } void cleanupPush_void_ptr(bool failOnly, void* func, void* arg) { - assert(expList->numCleanupAction < expList->maxCleanupAction); + ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction"); SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++; ca->wrapper = 2; @@ -103,7 +104,7 @@ void cleanupPush_void_ptr(bool failOnly, void* func, void* arg) { } void cleanupPush_int_int(bool failOnly, void* func, int32_t arg) { - assert(expList->numCleanupAction < expList->maxCleanupAction); + ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction"); SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++; ca->wrapper = 3; @@ -113,7 +114,7 @@ void cleanupPush_int_int(bool failOnly, void* func, int32_t arg) { } void cleanupPush_void(bool failOnly, void* func) { - assert(expList->numCleanupAction < expList->maxCleanupAction); + ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction"); SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++; ca->wrapper = 4; @@ -122,7 +123,7 @@ void cleanupPush_void(bool failOnly, void* func) { } void cleanupPush_int_ptr(bool failOnly, void* func, void* arg) { - assert(expList->numCleanupAction < expList->maxCleanupAction); + ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction"); SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++; ca->wrapper = 5; diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index f6f814d82b..53d0cad5ea 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -790,7 +790,7 @@ cmp_end: return ret; } -bool taosAssert(bool condition, const char *file, int32_t line, const char *format, ...) { +bool taosAssertDebug(bool condition, const char *file, int32_t line, const char *format, ...) { if (condition) return false; const char *flags = "UTL FATAL "; @@ -822,4 +822,24 @@ bool taosAssert(bool condition, const char *file, int32_t line, const char *form } return true; -} \ No newline at end of file +} + +#ifdef NDEBUG +bool taosAssertRelease(bool condition) { + if (condition) return false; + + const char *flags = "UTL FATAL "; + ELogLevel level = DEBUG_FATAL; + int32_t dflag = 255; // tsLogEmbedded ? 255 : uDebugFlag + + taosPrintLog(flags, level, dflag, "tAssert called in release mode, exit:%d", tsAssert); + taosPrintTrace(flags, level, dflag); + + if (tsAssert) { + taosMsleep(300); + abort(); + } + + return true; +} +#endif \ No newline at end of file diff --git a/source/util/src/tlosertree.c b/source/util/src/tlosertree.c index aeb9ce310b..bf99212b78 100644 --- a/source/util/src/tlosertree.c +++ b/source/util/src/tlosertree.c @@ -20,7 +20,7 @@ // Set the initial value of the multiway merge tree. static void tMergeTreeInit(SMultiwayMergeTreeInfo* pTree) { - assert((pTree->totalSources & 0x01) == 0 && (pTree->numOfSources << 1 == pTree->totalSources)); + ASSERT((pTree->totalSources & 0x01) == 0 && (pTree->numOfSources << 1 == pTree->totalSources)); for (int32_t i = 0; i < pTree->totalSources; ++i) { if (i < pTree->numOfSources) { @@ -80,7 +80,7 @@ void tMergeTreeDestroy(SMultiwayMergeTreeInfo* pTree) { } void tMergeTreeAdjust(SMultiwayMergeTreeInfo* pTree, int32_t idx) { - assert(idx <= pTree->totalSources - 1 && idx >= pTree->numOfSources && pTree->totalSources >= 2); + ASSERT(idx <= pTree->totalSources - 1 && idx >= pTree->numOfSources && pTree->totalSources >= 2); if (pTree->totalSources == 2) { pTree->pNode[0].index = 0; @@ -115,7 +115,7 @@ void tMergeTreeAdjust(SMultiwayMergeTreeInfo* pTree, int32_t idx) { } void tMergeTreeRebuild(SMultiwayMergeTreeInfo* pTree) { - assert((pTree->totalSources & 0x1) == 0); + ASSERT((pTree->totalSources & 0x1) == 0); tMergeTreeInit(pTree); for (int32_t i = pTree->totalSources - 1; i >= pTree->numOfSources; i--) { diff --git a/source/util/src/tpagedbuf.c b/source/util/src/tpagedbuf.c index ced5b4f25e..87b44b2d13 100644 --- a/source/util/src/tpagedbuf.c +++ b/source/util/src/tpagedbuf.c @@ -125,20 +125,20 @@ static FORCE_INLINE size_t getAllocPageSize(int32_t pageSize) { return pageSize * @return */ static char* doFlushPageToDisk(SDiskbasedBuf* pBuf, SPageInfo* pg) { - assert(!pg->used && pg->pData != NULL); + ASSERT(!pg->used && pg->pData != NULL); int32_t size = pBuf->pageSize; char* t = NULL; if (pg->offset == -1 || pg->dirty) { void* payload = GET_DATA_PAYLOAD(pg); t = doCompressData(payload, pBuf->pageSize, &size, pBuf); - assert(size >= 0); + ASSERTS(size >= 0, "size is negative"); } // this page is flushed to disk for the first time if (pg->dirty) { if (pg->offset == -1) { - assert(pg->dirty == true); + ASSERTS(pg->dirty == true, "pg->dirty is false"); pg->offset = allocatePositionInFile(pBuf, size); pBuf->nextPos += size; @@ -210,7 +210,7 @@ static char* doFlushPageToDisk(SDiskbasedBuf* pBuf, SPageInfo* pg) { static char* flushPageToDisk(SDiskbasedBuf* pBuf, SPageInfo* pg) { int32_t ret = TSDB_CODE_SUCCESS; - assert(((int64_t)pBuf->numOfPages * pBuf->pageSize) == pBuf->totalBufSize && pBuf->numOfPages >= pBuf->inMemPages); + ASSERT(((int64_t)pBuf->numOfPages * pBuf->pageSize) == pBuf->totalBufSize && pBuf->numOfPages >= pBuf->inMemPages); if (pBuf->pFile == NULL) { if ((ret = createDiskFile(pBuf)) != TSDB_CODE_SUCCESS) { @@ -272,7 +272,7 @@ static SListNode* getEldestUnrefedPage(SDiskbasedBuf* pBuf) { SListNode* pn = NULL; while ((pn = tdListNext(&iter)) != NULL) { SPageInfo* pageInfo = *(SPageInfo**)pn->data; - assert(pageInfo->pageId >= 0 && pageInfo->pn == pn); + ASSERT(pageInfo->pageId >= 0 && pageInfo->pn == pn); if (!pageInfo->used) { // printf("%d is chosen\n", pageInfo->pageId); @@ -303,7 +303,7 @@ static char* evacOneDataPage(SDiskbasedBuf* pBuf) { tdListPopNode(pBuf->lruList, pn); SPageInfo* d = *(SPageInfo**)pn->data; - assert(d->pn == pn); + ASSERTS(d->pn == pn, "d->pn not equal pn"); d->pn = NULL; taosMemoryFreeClear(pn); @@ -353,7 +353,7 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMem pPBuf->freePgList = tdListNew(POINTER_BYTES); // at least more than 2 pages must be in memory - assert(inMemBufSize >= pagesize * 2); + ASSERT(inMemBufSize >= pagesize * 2); pPBuf->lruList = tdListNew(POINTER_BYTES); @@ -402,7 +402,7 @@ void* getNewBufPage(SDiskbasedBuf* pBuf, int32_t* pageId) { } // add to LRU list - assert(listNEles(pBuf->lruList) < pBuf->inMemPages && pBuf->inMemPages > 0); + ASSERT(listNEles(pBuf->lruList) < pBuf->inMemPages && pBuf->inMemPages > 0); lruListPushFront(pBuf->lruList, pi); // allocate buf @@ -421,11 +421,11 @@ void* getNewBufPage(SDiskbasedBuf* pBuf, int32_t* pageId) { } void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) { - assert(pBuf != NULL && id >= 0); + ASSERT(pBuf != NULL && id >= 0); pBuf->statis.getPages += 1; SPageInfo** pi = taosHashGet(pBuf->all, &id, sizeof(int32_t)); - assert(pi != NULL && *pi != NULL); + ASSERT(pi != NULL && *pi != NULL); if ((*pi)->pData != NULL) { // it is in memory // no need to update the LRU list if only one page exists @@ -435,7 +435,7 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) { } SPageInfo** pInfo = (SPageInfo**)((*pi)->pn->data); - assert(*pInfo == *pi); + ASSERT(*pInfo == *pi); lruListMoveToFront(pBuf->lruList, (*pi)); (*pi)->used = true; @@ -444,7 +444,7 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) { #endif return (void*)(GET_DATA_PAYLOAD(*pi)); } else { // not in memory - assert((*pi)->pData == NULL && (*pi)->pn == NULL && + ASSERT((*pi)->pData == NULL && (*pi)->pn == NULL && (((*pi)->length >= 0 && (*pi)->offset >= 0) || ((*pi)->length == -1 && (*pi)->offset == -1))); char* availablePage = NULL; @@ -482,7 +482,9 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) { } void releaseBufPage(SDiskbasedBuf* pBuf, void* page) { - assert(pBuf != NULL && page != NULL); + if (ASSERTS(pBuf != NULL && page != NULL, "pBuf or page is NULL")) { + return; + } SPageInfo* ppi = getPageInfoFromPayload(page); releaseBufPageInfo(pBuf, ppi); } @@ -491,8 +493,10 @@ void releaseBufPageInfo(SDiskbasedBuf* pBuf, SPageInfo* pi) { #ifdef BUF_PAGE_DEBUG uDebug("page_releaseBufPageInfo pageId:%d, used:%d, offset:%" PRId64, pi->pageId, pi->used, pi->offset); #endif - // assert(pi->pData != NULL && pi->used == true); - assert(pi->pData != NULL); + if (ASSERTS(pi->pData != NULL, "pi->pData is NULL")) { + return; + } + pi->used = false; pBuf->statis.releasePages += 1; } diff --git a/source/util/src/trbtree.c b/source/util/src/trbtree.c index c6aea87470..ffae5441aa 100644 --- a/source/util/src/trbtree.c +++ b/source/util/src/trbtree.c @@ -14,6 +14,7 @@ */ #include "trbtree.h" +#include "tlog.h" static void tRBTreeRotateLeft(SRBTree *pTree, SRBTreeNode *x) { SRBTreeNode *y = x->right; @@ -258,7 +259,7 @@ static void rbtree_delete_fixup(rbtree_t *rbtree, rbnode_t *child, rbnode_t *chi child_parent->color = BLACK; return; } - assert(sibling != RBTREE_NULL); + ASSERTS(sibling != RBTREE_NULL, "sibling is NULL"); /* get a new sibling, by rotating at sibling. See which child of sibling is red */ @@ -288,11 +289,11 @@ static void rbtree_delete_fixup(rbtree_t *rbtree, rbnode_t *child, rbnode_t *chi sibling->color = child_parent->color; child_parent->color = BLACK; if (child_parent->right == child) { - assert(sibling->left->color == RED); + ASSERTS(sibling->left->color == RED, "slibing->left->color=%d not equal RED", sibling->left->color); sibling->left->color = BLACK; rbtree_rotate_right(rbtree, child_parent); } else { - assert(sibling->right->color == RED); + ASSERTS(sibling->right->color == RED, "slibing->right->color=%d not equal RED", sibling->right->color); sibling->right->color = BLACK; rbtree_rotate_left(rbtree, child_parent); } @@ -315,18 +316,18 @@ static void swap_np(rbnode_t **x, rbnode_t **y) { /** Update parent pointers of child trees of 'parent' */ static void change_parent_ptr(rbtree_t *rbtree, rbnode_t *parent, rbnode_t *old, rbnode_t *new) { if (parent == RBTREE_NULL) { - assert(rbtree->root == old); + ASSERTS(rbtree->root == old, "root not equal old"); if (rbtree->root == old) rbtree->root = new; return; } - assert(parent->left == old || parent->right == old || parent->left == new || parent->right == new); + ASSERT(parent->left == old || parent->right == old || parent->left == new || parent->right == new); if (parent->left == old) parent->left = new; if (parent->right == old) parent->right = new; } /** Update parent pointer of a node 'child' */ static void change_child_ptr(rbtree_t *rbtree, rbnode_t *child, rbnode_t *old, rbnode_t *new) { if (child == RBTREE_NULL) return; - assert(child->parent == old || child->parent == new); + ASSERT(child->parent == old || child->parent == new); if (child->parent == old) child->parent = new; } @@ -371,7 +372,7 @@ rbnode_t *rbtree_delete(rbtree_t *rbtree, void *key) { /* now delete to_delete (which is at the location where the smright previously was) */ } - assert(to_delete->left == RBTREE_NULL || to_delete->right == RBTREE_NULL); + ASSERT(to_delete->left == RBTREE_NULL || to_delete->right == RBTREE_NULL); if (to_delete->left != RBTREE_NULL) child = to_delete->left; diff --git a/source/util/src/tref.c b/source/util/src/tref.c index 75a16b0ad7..e70e12b37b 100644 --- a/source/util/src/tref.c +++ b/source/util/src/tref.c @@ -466,7 +466,7 @@ static void taosLockList(int64_t *lockedBy) { static void taosUnlockList(int64_t *lockedBy) { int64_t tid = taosGetSelfPthreadId(); if (atomic_val_compare_exchange_64(lockedBy, tid, 0) != tid) { - assert(false); + ASSERTS(false, "atomic_val_compare_exchange_64 tid failed"); } } diff --git a/source/util/src/ttimer.c b/source/util/src/ttimer.c index 51d0a59d00..7e99d6a35c 100644 --- a/source/util/src/ttimer.c +++ b/source/util/src/ttimer.c @@ -159,8 +159,7 @@ static void lockTimerList(timer_list_t* list) { static void unlockTimerList(timer_list_t* list) { int64_t tid = taosGetSelfPthreadId(); if (atomic_val_compare_exchange_64(&(list->lockedBy), tid, 0) != tid) { - assert(false); - tmrError("%" PRId64 " trying to unlock a timer list not locked by current thread.", tid); + ASSERTS(false, "%" PRId64 " trying to unlock a timer list not locked by current thread.", tid); } } @@ -506,7 +505,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int32_t mseconds, void* param, void* han } } - assert(timer->refCount == 1); + ASSERTS(timer->refCount == 1, "timer refCount=%d not expected 1", timer->refCount); memset(timer, 0, sizeof(*timer)); *pTmrId = (tmr_h)doStartTimer(timer, fp, mseconds, param, ctrl); diff --git a/source/util/src/tutil.c b/source/util/src/tutil.c index addb9f55ba..e94f94a00d 100644 --- a/source/util/src/tutil.c +++ b/source/util/src/tutil.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "tutil.h" +#include "tlog.h" void *tmemmem(const char *haystack, int32_t hlen, const char *needle, int32_t nlen) { const char *limit; @@ -117,7 +118,7 @@ char **strsplit(char *z, const char *delim, int32_t *num) { if ((*num) >= size) { size = (size << 1); split = taosMemoryRealloc(split, POINTER_BYTES * size); - assert(NULL != split); + ASSERTS(NULL != split, "realloc memory failed. size=%d", POINTER_BYTES * size); } } @@ -144,11 +145,23 @@ char *strnchr(const char *haystack, char needle, int32_t len, bool skipquote) { return NULL; } +TdUcs4* wcsnchr(const TdUcs4* haystack, TdUcs4 needle, size_t len) { + for(int32_t i = 0; i < len; ++i) { + if (haystack[i] == needle) { + return (TdUcs4*) &haystack[i]; + } + } + + return NULL; +} + char *strtolower(char *dst, const char *src) { int32_t esc = 0; char quote = 0, *p = dst, c; - assert(dst != NULL); + if (ASSERTS(dst != NULL, "dst is NULL")) { + return NULL; + } for (c = *src++; c; c = *src++) { if (esc) { @@ -175,7 +188,10 @@ char *strntolower(char *dst, const char *src, int32_t n) { int32_t esc = 0; char quote = 0, *p = dst, c; - assert(dst != NULL); + if (ASSERTS(dst != NULL, "dst is NULL")) { + return NULL; + } + if (n == 0) { *p = 0; return dst; @@ -204,7 +220,10 @@ char *strntolower(char *dst, const char *src, int32_t n) { char *strntolower_s(char *dst, const char *src, int32_t n) { char *p = dst, c; - assert(dst != NULL); + if (ASSERTS(dst != NULL, "dst is NULL")) { + return NULL; + } + if (n == 0) { return NULL; } @@ -376,3 +395,73 @@ void taosIp2String(uint32_t ip, char *str) { void taosIpPort2String(uint32_t ip, uint16_t port, char *str) { sprintf(str, "%u.%u.%u.%u:%u", ip & 0xFF, (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, (uint8_t)(ip >> 24), port); } + +size_t tstrncspn(const char *str, size_t size, const char *reject, size_t rsize) { + if (rsize == 0 || rsize == 1) { + char* p = strnchr(str, reject[0], size, false); + return (p == NULL)? size:(p-str); + } + + /* Use multiple small memsets to enable inlining on most targets. */ + unsigned char table[256]; + unsigned char *p = memset(table, 0, 64); + memset(p + 64, 0, 64); + memset(p + 128, 0, 64); + memset(p + 192, 0, 64); + + unsigned char *s = (unsigned char *)reject; + int32_t index = 0; + do { + p[s[index++]] = 1; + } while (index < rsize); + + s = (unsigned char*) str; + int32_t times = size >> 2; + if (times == 0) { + for(int32_t i = 0; i < size; ++i) { + if (p[s[i]]) { + return i; + } + } + + return size; + } + + index = 0; + uint32_t c0, c1, c2, c3; + for(int32_t i = 0; i < times; ++i, index += 4) { + int32_t j = index; + c0 = p[s[j]]; + c1 = p[s[j + 1]]; + c2 = p[s[j + 2]]; + c3 = p[s[j + 3]]; + + if ((c0 | c1 | c2 | c3) != 0) { + size_t count = ((i + 1) >> 2); + return (c0 | c1) != 0 ? count - c0 + 1 : count - c2 + 3; + } + } + + int32_t offset = times * 4; + for(int32_t i = offset; i < size; ++i) { + if (p[s[i]]) { + return i; + } + } + + return size; +} + +size_t twcsncspn(const TdUcs4 *wcs, size_t size, const TdUcs4 *reject, size_t rsize) { + if (rsize == 0 || rsize == 1) { + TdUcs4* p = wcsnchr(wcs, reject[0], size); + return (p == NULL)? size:(p-wcs); + } + + size_t index = 0; + while ((index < size) && (wcsnchr(reject, wcs[index], rsize) == NULL)) { + ++index; + } + + return index; +} diff --git a/source/util/test/utilTests.cpp b/source/util/test/utilTests.cpp index e69de29bb2..c56ef348cc 100644 --- a/source/util/test/utilTests.cpp +++ b/source/util/test/utilTests.cpp @@ -0,0 +1,297 @@ +#include +#include +#include +#include + +#include "tarray.h" +#include "tcompare.h" + +namespace { +} // namespace + +TEST(utilTest, wchar_pattern_match_test) { + const TdWchar* pattern = L"%1"; + + int32_t ret = 0; + SPatternCompareInfo pInfo = PATTERN_COMPARE_INFO_INITIALIZER; + + const TdWchar* str0 = L"14"; + ret = wcsPatternMatch(reinterpret_cast(pattern), 2, reinterpret_cast(str0), wcslen(str0), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const TdWchar* str1 = L"11"; + ret = wcsPatternMatch(reinterpret_cast(pattern), 2, reinterpret_cast(str1), wcslen(str1), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* str2 = L"41"; + ret = wcsPatternMatch(reinterpret_cast(pattern), 2, reinterpret_cast(str2), wcslen(str2), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern3 = L"%_"; + const TdWchar* str3 = L"88"; + ret = wcsPatternMatch(reinterpret_cast(pattern3), 2, reinterpret_cast(str3), wcslen(str3), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern4 = L"%___"; + const TdWchar* str4 = L"88"; + ret = wcsPatternMatch(reinterpret_cast(pattern4), 4, reinterpret_cast(str4), wcslen(str4), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const TdWchar* pattern5 = L"%___"; + const TdWchar* str5 = L"883391"; + ret = wcsPatternMatch(reinterpret_cast(pattern5), 4, reinterpret_cast(str5), wcslen(str5), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern6 = L"%___66"; + const TdWchar* str6 = L"88339166"; + ret = wcsPatternMatch(reinterpret_cast(pattern6), 6, reinterpret_cast(str6), wcslen(str6), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern7 = L"%____66"; + const TdWchar* str7 = L"66166"; + ret = wcsPatternMatch(reinterpret_cast(pattern7), 7, reinterpret_cast(str7), wcslen(str7), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const TdWchar* pattern8 = L"6%____66"; + const TdWchar* str8 = L"666166"; + ret = wcsPatternMatch(reinterpret_cast(pattern8), 8, reinterpret_cast(str8), wcslen(str8), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const TdWchar* pattern9 = L"6\\__6"; + const TdWchar* str9 = L"6_66"; + ret = wcsPatternMatch(reinterpret_cast(pattern9), 6, reinterpret_cast(str9), wcslen(str9), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern10 = L"%"; + const TdWchar* str10 = L""; + ret = wcsPatternMatch(reinterpret_cast(pattern10), 1, reinterpret_cast(str10), 0, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern11 = L"china%"; + const TdWchar* str11 = L"CHI "; + ret = wcsPatternMatch(reinterpret_cast(pattern11), 6, reinterpret_cast(str11), 3, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOMATCH); + + const TdWchar* pattern12 = L"abc%"; + const TdWchar* str12 = L""; + ret = wcsPatternMatch(reinterpret_cast(pattern12), 4, reinterpret_cast(str12), 0, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOMATCH); +} + +TEST(utilTest, wchar_pattern_match_no_terminated) { + const TdWchar* pattern = L"%1 "; + + int32_t ret = 0; + SPatternCompareInfo pInfo = PATTERN_COMPARE_INFO_INITIALIZER; + + const TdWchar* str0 = L"14 "; + ret = wcsPatternMatch(reinterpret_cast(pattern), 2, reinterpret_cast(str0), 2, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const TdWchar* str1 = L"11 "; + ret = wcsPatternMatch(reinterpret_cast(pattern), 2, reinterpret_cast(str1), 2, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* str2 = L"41 "; + ret = wcsPatternMatch(reinterpret_cast(pattern), 2, reinterpret_cast(str2), 2, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern3 = L"%_ "; + const TdWchar* str3 = L"88 "; + ret = wcsPatternMatch(reinterpret_cast(pattern3), 2, reinterpret_cast(str3), 2, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern4 = L"%___ "; + const TdWchar* str4 = L"88 "; + ret = wcsPatternMatch(reinterpret_cast(pattern4), 4, reinterpret_cast(str4), 2, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const TdWchar* pattern5 = L"%___ "; + const TdWchar* str5 = L"883391 "; + ret = wcsPatternMatch(reinterpret_cast(pattern5), 4, reinterpret_cast(str5), 6, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern6 = L"%___66 "; + const TdWchar* str6 = L"88339166 "; + ret = wcsPatternMatch(reinterpret_cast(pattern6), 6, reinterpret_cast(str6), 8, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern7 = L"%____66 "; + const TdWchar* str7 = L"66166 "; + ret = wcsPatternMatch(reinterpret_cast(pattern7), 7, reinterpret_cast(str7), 5, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const TdWchar* pattern8 = L"6%____66 "; + const TdWchar* str8 = L"666166 "; + ret = wcsPatternMatch(reinterpret_cast(pattern8), 8, reinterpret_cast(str8), 6, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const TdWchar* pattern9 = L"6\\_6 "; + const TdWchar* str9 = L"6_6 "; + ret = wcsPatternMatch(reinterpret_cast(pattern9), 4, reinterpret_cast(str9), 3, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern10 = L"% "; + const TdWchar* str10 = L"6_6 "; + ret = wcsPatternMatch(reinterpret_cast(pattern10), 1, reinterpret_cast(str10), 3, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); +} + +TEST(utilTest, char_pattern_match_test) { + const char* pattern = "%1"; + + int32_t ret = 0; + SPatternCompareInfo pInfo = PATTERN_COMPARE_INFO_INITIALIZER; + + const char* str0 = "14"; + ret = patternMatch(pattern, 2, str0, strlen(str0), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const char* str1 = "11"; + ret = patternMatch(pattern, 2, str1, strlen(str1), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* str2 = "41"; + ret = patternMatch(pattern, 2, str2, strlen(str2), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern3 = "%_"; + const char* str3 = "88"; + ret = patternMatch(pattern3, 2, str3, strlen(str3), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern4 = "%___"; + const char* str4 = "88"; + ret = patternMatch(pattern4, 4, str4, strlen(str4), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const char* pattern5 = "%___"; + const char* str5 = "883391"; + ret = patternMatch(pattern5, 4, str5, strlen(str5), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern6 = "%___66"; + const char* str6 = "88339166"; + ret = patternMatch(pattern6, 6, str6, strlen(str6), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern7 = "%____66"; + const char* str7 = "66166"; + ret = patternMatch(pattern7, 7, str7, strlen(str7), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const char* pattern8 = "6%____66"; + const char* str8 = "666166"; + ret = patternMatch(pattern8, 8, str8, strlen(str8), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const char* pattern9 = "6\\_6"; + const char* str9 = "6_6"; + ret = patternMatch(pattern9, 5, str9, strlen(str9), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern10 = "%"; + const char* str10 = " "; + ret = patternMatch(pattern10, 1, str10, 0, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern11 = "china%"; + const char* str11 = "abc "; + ret = patternMatch(pattern11, 6, str11, 3, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOMATCH); + + const char* pattern12 = "abc%"; + const char* str12 = NULL; + ret = patternMatch(pattern12, 4, str12, 0, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOMATCH); +} + +TEST(utilTest, char_pattern_match_no_terminated) { + const char* pattern = "%1 "; + + int32_t ret = 0; + SPatternCompareInfo pInfo = PATTERN_COMPARE_INFO_INITIALIZER; + + const char* str0 = "14"; + ret = patternMatch(pattern, 2, str0, strlen(str0), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const char* str1 = "11"; + ret = patternMatch(pattern, 2, str1, strlen(str1), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* str2 = "41"; + ret = patternMatch(pattern, 2, str2, strlen(str2), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern3 = "%_ "; + const char* str3 = "88"; + ret = patternMatch(pattern3, 2, str3, strlen(str3), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern4 = "%___ "; + const char* str4 = "88"; + ret = patternMatch(pattern4, 4, str4, strlen(str4), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const char* pattern5 = "%___ "; + const char* str5 = "883391"; + ret = patternMatch(pattern5, 4, str5, strlen(str5), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern6 = "%___66 "; + const char* str6 = "88339166"; + ret = patternMatch(pattern6, 6, str6, strlen(str6), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern7 = "%____66 "; + const char* str7 = "66166"; + ret = patternMatch(pattern7, 7, str7, strlen(str7), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const char* pattern8 = "6%____66 "; + const char* str8 = "666166"; + ret = patternMatch(pattern8, 8, str8, strlen(str8), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const char* pattern9 = "6\\_6 "; + const char* str9 = "6_6"; + ret = patternMatch(pattern9, 4, str9, strlen(str9), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern10 = "% "; + const char* str10 = "6_6"; + ret = patternMatch(pattern10, 1, str10, strlen(str10), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); +} + +TEST(utilTest, tstrncspn) { + const char* p1 = "abc"; + const char* reject = "d"; + size_t v = tstrncspn(p1, strlen(p1), reject, 1); + ASSERT_EQ(v, 3); + + const char* reject1 = "a"; + v = tstrncspn(p1, strlen(p1), reject1, 1); + ASSERT_EQ(v, 0); + + const char* reject2 = "de"; + v = tstrncspn(p1, strlen(p1), reject2, 2); + ASSERT_EQ(v, 3); + + const char* p2 = "abcdefghijklmn"; + v = tstrncspn(p2, strlen(p2), reject2, 2); + ASSERT_EQ(v, 3); + + const char* reject3 = "12345n"; + v = tstrncspn(p2, strlen(p2), reject3, 6); + ASSERT_EQ(v, 13); + + const char* reject4 = ""; + v = tstrncspn(p2, strlen(p2), reject4, 0); + ASSERT_EQ(v, 14); + + const char* reject5 = "911"; + v = tstrncspn(p2, strlen(p2), reject5, 0); + ASSERT_EQ(v, 14); +} \ No newline at end of file diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index f8911d2b29..d55e4f919b 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -175,6 +175,7 @@ ,,y,script,./test.sh -f tsim/query/session.sim ,,y,script,./test.sh -f tsim/query/udf.sim ,,y,script,./test.sh -f tsim/query/udf_with_const.sim +,,y,script,./test.sh -f tsim/query/sys_tbname.sim ,,y,script,./test.sh -f tsim/query/groupby.sim ,,y,script,./test.sh -f tsim/qnode/basic1.sim ,,y,script,./test.sh -f tsim/snode/basic1.sim @@ -408,6 +409,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShellError.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShellNetChk.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/telemetry.py +,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/backquote_check.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosdMonitor.py ,,n,system-test,python3 ./test.py -f 0-others/taosdShell.py -N 5 -M 3 -Q 3 ,,n,system-test,python3 ./test.py -f 0-others/udfTest.py @@ -616,6 +618,8 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/varchar.py -R ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/case_when.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/case_when.py -R +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/blockSMA.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/blockSMA.py -R ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/update_data.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/tb_100w_data_order.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/delete_stable.py @@ -702,8 +706,8 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsumerGroup.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqShow.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqAlterSchema.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb.py -N 3 -n 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1.py -N 3 -n 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb-1ctb.py @@ -718,11 +722,11 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDnodeRestart.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDnodeRestart1.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdate-1ctb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdateWithConsume.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdateWithConsume.py -N 3 -n 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdate-multiCtb-snapshot0.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdate-multiCtb-snapshot1.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDelete-1ctb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDelete-multiCtb.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDelete-multiCtb.py -N 3 -n 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropStb.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropStbCtb.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropNtb-snapshot0.py @@ -736,6 +740,7 @@ #,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_taosx.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/stbTagFilter-multiCtb.py ,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-19201.py +,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqSubscribeStb-r3.py -N 5 ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 6 -M 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 6 -M 3 -n 3 @@ -834,6 +839,8 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tsbsQuery.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/sml.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/case_when.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/blockSMA.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/between.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/distinct.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/varchar.py -Q 3 @@ -929,6 +936,8 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/sml.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/interp.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/case_when.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/blockSMA.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/between.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/distinct.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/varchar.py -Q 4 @@ -1034,6 +1043,8 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_null_none.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_null_none.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_null_none.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/blockSMA.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-20582.py #develop test diff --git a/tests/pytest/auto_crash_gen.py b/tests/pytest/auto_crash_gen.py index 9c134e6d64..56629ede13 100755 --- a/tests/pytest/auto_crash_gen.py +++ b/tests/pytest/auto_crash_gen.py @@ -324,7 +324,7 @@ def main(): print( " crash_gen.sh is not exists ") sys.exit(1) - git_commit = subprocess.Popen("cd %s && git log | head -n1"%crash_gen_path, shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")[8:16] + git_commit = subprocess.Popen("cd %s && git log | head -n1"%crash_gen_path, shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")[7:16] # crash_cmds = get_cmds() @@ -348,15 +348,12 @@ def main(): else: print('======== crash_gen run sucess and exit as expected ========') - - if status!=0 : - - try: - text = f"crash_gen instance exit status of docker [ {hostname} ] is : {msg_dict[status]}\n " + f" and git commit : {git_commit}" - send_msg(get_msg(text)) - except Exception as e: - print("exception:", e) - exit(status) + try: + text = f"crash_gen instance exit status of docker [ {hostname} ] is : {msg_dict[status]}\n " + f" and git commit : {git_commit}" + send_msg(get_msg(text)) + except Exception as e: + print("exception:", e) + exit(status) if __name__ == '__main__': diff --git a/tests/pytest/auto_crash_gen_valgrind.py b/tests/pytest/auto_crash_gen_valgrind.py index ce87fec684..22fc5a480f 100755 --- a/tests/pytest/auto_crash_gen_valgrind.py +++ b/tests/pytest/auto_crash_gen_valgrind.py @@ -357,7 +357,7 @@ def main(): print( " crash_gen.sh is not exists ") sys.exit(1) - git_commit = subprocess.Popen("cd %s && git log | head -n1"%crash_gen_path, shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")[8:16] + git_commit = subprocess.Popen("cd %s && git log | head -n1"%crash_gen_path, shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")[7:16] # crash_cmds = get_cmds() @@ -383,14 +383,12 @@ def main(): else: print('======== crash_gen run sucess and exit as expected ========') - if status!=0 : - - try: - text = f"crash_gen instance exit status of docker [ {hostname} ] is : {msg_dict[status]}\n " + f" and git commit : {git_commit}" - send_msg(get_msg(text)) - except Exception as e: - print("exception:", e) - exit(status) + try: + text = f"crash_gen instance exit status of docker [ {hostname} ] is : {msg_dict[status]}\n " + f" and git commit : {git_commit}" + send_msg(get_msg(text)) + except Exception as e: + print("exception:", e) + exit(status) if __name__ == '__main__': diff --git a/tests/pytest/auto_crash_gen_valgrind_cluster.py b/tests/pytest/auto_crash_gen_valgrind_cluster.py index f4afa80afe..547de9af47 100755 --- a/tests/pytest/auto_crash_gen_valgrind_cluster.py +++ b/tests/pytest/auto_crash_gen_valgrind_cluster.py @@ -357,7 +357,7 @@ def main(): print( " crash_gen.sh is not exists ") sys.exit(1) - git_commit = subprocess.Popen("cd %s && git log | head -n1"%crash_gen_path, shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")[8:16] + git_commit = subprocess.Popen("cd %s && git log | head -n1"%crash_gen_path, shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")[7:16] # crash_cmds = get_cmds() @@ -383,14 +383,12 @@ def main(): else: print('======== crash_gen run sucess and exit as expected ========') - if status!=0 : - - try: - text = f"crash_gen instance exit status of docker [ {hostname} ] is : {msg_dict[status]}\n " + f" and git commit : {git_commit}" - send_msg(get_msg(text)) - except Exception as e: - print("exception:", e) - exit(status) + try: + text = f"crash_gen instance exit status of docker [ {hostname} ] is : {msg_dict[status]}\n " + f" and git commit : {git_commit}" + send_msg(get_msg(text)) + except Exception as e: + print("exception:", e) + exit(status) if __name__ == '__main__': diff --git a/tests/script/tmp/data.sim b/tests/script/tmp/data.sim index e3bfe23c3d..e2ddd60c8c 100644 --- a/tests/script/tmp/data.sim +++ b/tests/script/tmp/data.sim @@ -53,17 +53,25 @@ endi return print =============== step2: create database -sql create database db vgroups 33 replica 3 +sql create database db vgroups 1 replica 3 sql use db; sql create table stb (ts timestamp, c int) tags (t int); sql create table t0 using stb tags (0); -sql insert into t0 values(now, 1); +$x = 0 +while $x < 28 + sql insert into t0 values(now, 1); + $x = $x + 1 +endw + sql select * from information_schema.ins_stables where db_name = 'db'; sql select * from information_schema.ins_tables where db_name = 'db'; sql show db.vgroups; +system sh/exec.sh -n dnode1 -s stop system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop +system sh/exec.sh -n dnode4 -s stop return print ======== start back diff --git a/tests/script/tsim/query/sys_tbname.sim b/tests/script/tsim/query/sys_tbname.sim new file mode 100644 index 0000000000..045e908a57 --- /dev/null +++ b/tests/script/tsim/query/sys_tbname.sim @@ -0,0 +1,89 @@ + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database sys_tbname; +sql use sys_tbname; +sql create stable st(ts timestamp, f int) tags(t int); +sql create table ct1 using st tags(1); +sql create table ct2 using st tags(2); + +sql create table t (ts timestamp, f int); +sql insert into t values(now, 1)(now+1s, 2); + + +sql create table t2 (ts timestamp, f1 int, f2 int); +sql insert into t2 values(now, 0, 0)(now+1s, 1, 1); + +sql select tbname from information_schema.ins_databases; +print $rows $data00 +if $rows != 3 then + return -1 +endi +if $data00 != @ins_databases@ then + return -1 +endi +sql select distinct tbname from information_schema.ins_databases; +print $rows $data00 +if $rows != 1 then + return -1 +endi +if $data00 != @ins_databases@ then + return -1 +endi + +sql select tbname from information_schema.ins_stables; +print $rows $data00 +if $rows != 1 then + return -1 +endi +if $data00 != @ins_stables@ then + return -1 +endi +sql select distinct tbname from information_schema.ins_stables; +print $rows $data00 +if $rows != 1 then + return -1 +endi +if $data00 != @ins_stables@ then + return -1 +endi + +sql select tbname from information_schema.ins_tables; +print $rows $data00 +if $rows != 32 then + return -1 +endi +if $data00 != @ins_tables@ then + return -1 +endi + +sql select distinct tbname from information_schema.ins_tables; +print $rows $data00 +if $rows != 1 then + return -1 +endi +if $data00 != @ins_tables@ then + return -1 +endi + +sql select tbname from information_schema.ins_tags; +print $rows $data00 +if $rows != 2 then + return -1 +endi +if $data00 != @ins_tags@ then + return -1 +endi +sql select distinct tbname from information_schema.ins_tags; +print $rows $data00 +if $rows != 1 then + return -1 +endi +if $data00 != @ins_tags@ then + return -1 +endi + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/system-test/0-others/backquote_check.py b/tests/system-test/0-others/backquote_check.py new file mode 100644 index 0000000000..3357723253 --- /dev/null +++ b/tests/system-test/0-others/backquote_check.py @@ -0,0 +1,87 @@ +################################################################### +# 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 -*- + + +from util.log import * +from util.cases import * +from util.sql import * +from util.common import * +from util.sqlset import * + +class TDTestCase: + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + self.dbname = 'db' + self.setsql = TDSetSql() + self.stbname = 'stb' + self.streamname = 'stm' + self.streamtb = 'stm_stb' + def topic_name_check(self): + tdSql.execute(f'create database if not exists {self.dbname}') + tdSql.execute(f'use {self.dbname}') + tdSql.execute(f'create stable {self.stbname} (ts timestamp,c0 int) tags(t0 int)') + for name in [self.dbname,self.stbname]: + type = '' + if name == self.dbname: + type = 'database' + elif name == self.stbname: + type = 'stable' + tdSql.execute(f'create topic if not exists {name} as {type} {name}') + tdSql.query('show topics') + tdSql.checkEqual(tdSql.queryResult[0][0],name) + tdSql.execute(f'drop topic {name}') + tdSql.execute(f'create topic if not exists `{name}` as {type} {name}') + tdSql.query('show topics') + tdSql.checkEqual(tdSql.queryResult[0][0],name) + tdSql.execute(f'drop topic {name}') + tdSql.execute(f'create topic if not exists `{name}` as {type} `{name}`') + tdSql.query('show topics') + tdSql.checkEqual(tdSql.queryResult[0][0],name) + tdSql.execute(f'drop topic {name}') + tdSql.execute(f'create topic if not exists `{name}` as {type} `{name}`') + tdSql.query('show topics') + tdSql.checkEqual(tdSql.queryResult[0][0],name) + tdSql.execute(f'drop topic `{name}`') + + def db_name_check(self): + tdSql.execute(f'create database if not exists `{self.dbname}`') + tdSql.execute(f'use `{self.dbname}`') + tdSql.execute(f'drop database {self.dbname}') + + def stream_name_check(self): + tdSql.execute(f'create database if not exists {self.dbname}') + tdSql.execute(f'use {self.dbname}') + tdSql.execute(f'create stable {self.stbname} (ts timestamp,c0 int) tags(t0 int)') + tdSql.execute(f'create stream `{self.streamname}` into `{self.streamtb}` as select count(*) from {self.stbname} interval(10s);') + tdSql.query('show streams') + tdSql.checkEqual(tdSql.queryResult[0][0],self.streamname) + tdSql.execute(f'drop stream {self.streamname}') + tdSql.execute(f'drop stable {self.streamtb}') + tdSql.execute(f'create stream {self.streamname} into `{self.streamtb}` as select count(*) from {self.stbname} interval(10s);') + tdSql.query('show streams') + tdSql.checkEqual(tdSql.queryResult[0][0],self.streamname) + tdSql.execute(f'drop stream `{self.streamname}`') + tdSql.execute(f'drop database {self.dbname}') + + def run(self): + self.topic_name_check() + self.db_name_check() + self.stream_name_check() + 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 diff --git a/tests/system-test/2-query/blockSMA.py b/tests/system-test/2-query/blockSMA.py new file mode 100644 index 0000000000..85c0189e27 --- /dev/null +++ b/tests/system-test/2-query/blockSMA.py @@ -0,0 +1,146 @@ +from wsgiref.headers import tspecials +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.rowNum = 10000 + self.ts = 1537146000000 + + def run(self): + dbname = "db" + tdSql.prepare() + + tdSql.execute(f'''create table {dbname}.ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)''') + for i in range(self.rowNum): + tdSql.execute(f"insert into {dbname}.ntb values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (self.ts + i, i % 127 + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i % 255 + 1, i + 1, i + 1, i + 1)) + + + tdSql.execute('flush database db') + + # test functions using sma result + tdSql.query(f"select count(col1),min(col1),max(col1),avg(col1),sum(col1),spread(col1),percentile(col1, 0),first(col1),last(col1) from {dbname}.ntb") + tdSql.checkData(0, 0, 10000) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 127) + tdSql.checkData(0, 3, 63.8449) + tdSql.checkData(0, 4, 638449) + tdSql.checkData(0, 5, 126.0) + tdSql.checkData(0, 6, 1.0) + tdSql.checkData(0, 7, 1) + tdSql.checkData(0, 8, 94) + + tdSql.query(f"select count(col2),min(col2),max(col2),avg(col2),sum(col2),spread(col2),percentile(col2, 0),first(col2),last(col2) from {dbname}.ntb") + tdSql.checkData(0, 0, 10000) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 10000) + tdSql.checkData(0, 3, 5000.5) + tdSql.checkData(0, 4, 50005000) + tdSql.checkData(0, 5, 9999.0) + tdSql.checkData(0, 6, 1.0) + tdSql.checkData(0, 7, 1) + tdSql.checkData(0, 8, 10000) + + tdSql.query(f"select count(col3),min(col3),max(col3),avg(col3),sum(col3),spread(col3),percentile(col3, 0),first(col3),last(col3) from {dbname}.ntb") + tdSql.checkData(0, 0, 10000) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 10000) + tdSql.checkData(0, 3, 5000.5) + tdSql.checkData(0, 4, 50005000) + tdSql.checkData(0, 5, 9999.0) + tdSql.checkData(0, 6, 1.0) + tdSql.checkData(0, 7, 1) + tdSql.checkData(0, 8, 10000) + + tdSql.query(f"select count(col4),min(col4),max(col4),avg(col4),sum(col4),spread(col4),percentile(col4, 0),first(col4),last(col4) from {dbname}.ntb") + tdSql.checkData(0, 0, 10000) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 10000) + tdSql.checkData(0, 3, 5000.5) + tdSql.checkData(0, 4, 50005000) + tdSql.checkData(0, 5, 9999.0) + tdSql.checkData(0, 6, 1.0) + tdSql.checkData(0, 7, 1) + tdSql.checkData(0, 8, 10000) + + tdSql.query(f"select count(col5),min(col5),max(col5),avg(col5),sum(col5),spread(col5),percentile(col5, 0),first(col5),last(col5) from {dbname}.ntb") + tdSql.checkData(0, 0, 10000) + tdSql.checkData(0, 1, 0.1) + tdSql.checkData(0, 2, 9999.09961) + tdSql.checkData(0, 3, 4999.599985846) + tdSql.checkData(0, 4, 49995999.858455874) + tdSql.checkData(0, 5, 9998.999609374) + tdSql.checkData(0, 6, 0.100000001) + tdSql.checkData(0, 7, 0.1) + tdSql.checkData(0, 8, 9999.09961) + + tdSql.query(f"select count(col6),min(col6),max(col6),avg(col6),sum(col6),spread(col6),percentile(col6, 0),first(col6),last(col6) from {dbname}.ntb") + tdSql.checkData(0, 0, 10000) + tdSql.checkData(0, 1, 0.1) + tdSql.checkData(0, 2, 9999.100000000) + tdSql.checkData(0, 3, 4999.600000001) + tdSql.checkData(0, 4, 49996000.000005305) + tdSql.checkData(0, 5, 9999.000000000) + tdSql.checkData(0, 6, 0.1) + tdSql.checkData(0, 7, 0.1) + tdSql.checkData(0, 8, 9999.1) + + tdSql.query(f"select count(col11),min(col11),max(col11),avg(col11),sum(col11),spread(col11),percentile(col11, 0),first(col11),last(col11) from {dbname}.ntb") + tdSql.checkData(0, 0, 10000) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 255) + tdSql.checkData(0, 3, 127.45) + tdSql.checkData(0, 4, 1274500) + tdSql.checkData(0, 5, 254.000000000) + tdSql.checkData(0, 6, 1.0) + tdSql.checkData(0, 7, 1) + tdSql.checkData(0, 8, 55) + + tdSql.query(f"select count(col12),min(col12),max(col12),avg(col12),sum(col12),spread(col12),percentile(col12, 0),first(col12),last(col12) from {dbname}.ntb") + tdSql.checkData(0, 0, 10000) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 10000) + tdSql.checkData(0, 3, 5000.5) + tdSql.checkData(0, 4, 50005000) + tdSql.checkData(0, 5, 9999.0) + tdSql.checkData(0, 6, 1.0) + tdSql.checkData(0, 7, 1) + tdSql.checkData(0, 8, 10000) + + tdSql.query(f"select count(col13),min(col13),max(col13),avg(col13),sum(col13),spread(col13),percentile(col13, 0),first(col13),last(col13) from {dbname}.ntb") + tdSql.checkData(0, 0, 10000) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 10000) + tdSql.checkData(0, 3, 5000.5) + tdSql.checkData(0, 4, 50005000) + tdSql.checkData(0, 5, 9999.0) + tdSql.checkData(0, 6, 1.0) + tdSql.checkData(0, 7, 1) + tdSql.checkData(0, 8, 10000) + + tdSql.query(f"select count(col14),min(col14),max(col14),avg(col14),sum(col14),spread(col14),percentile(col14, 0),first(col14),last(col14) from {dbname}.ntb") + tdSql.checkData(0, 0, 10000) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 10000) + tdSql.checkData(0, 3, 5000.5) + tdSql.checkData(0, 4, 50005000) + tdSql.checkData(0, 5, 9999.0) + tdSql.checkData(0, 6, 1.0) + tdSql.checkData(0, 7, 1) + tdSql.checkData(0, 8, 10000) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/7-tmq/subscribeDb1.py b/tests/system-test/7-tmq/subscribeDb1.py index ea78c90abd..c5ae44214a 100644 --- a/tests/system-test/7-tmq/subscribeDb1.py +++ b/tests/system-test/7-tmq/subscribeDb1.py @@ -61,7 +61,7 @@ class TDTestCase: def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): sql = "insert into %s.consumeinfo values "%cdbName - sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) + sql += "(now + %ds, %d, '%s', '%s', %d, %d, %d)"%(consumerId, consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) tdLog.info("consume info sql: %s"%sql) tdSql.query(sql) @@ -174,12 +174,13 @@ class TDTestCase: 'ctbNum': 10, \ 'rowsPerTbl': 5000, \ 'batchNum': 100, \ + 'replica': self.replicaVar, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath self.initConsumerTable() - - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdLog.info("create database if not exists %s vgroups %d replica %d" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() @@ -191,10 +192,11 @@ class TDTestCase: 'ctbNum': 10, \ 'rowsPerTbl': 5000, \ 'batchNum': 100, \ + 'replica': self.replicaVar, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict2['dbName'], parameterDict2['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict2['dbName'], parameterDict2['vgroups'], parameterDict2['replica'])) prepareEnvThread2 = threading.Thread(target=self.prepareEnv, kwargs=parameterDict2) prepareEnvThread2.start() @@ -259,12 +261,13 @@ class TDTestCase: 'ctbNum': 10, \ 'rowsPerTbl': 5000, \ 'batchNum': 100, \ + 'replica': self.replicaVar, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() @@ -276,10 +279,11 @@ class TDTestCase: 'ctbNum': 10, \ 'rowsPerTbl': 5000, \ 'batchNum': 100, \ + 'replica': self.replicaVar, \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict2['dbName'], parameterDict2['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict2['dbName'], parameterDict2['vgroups'], parameterDict2['replica'])) prepareEnvThread2 = threading.Thread(target=self.prepareEnv, kwargs=parameterDict2) prepareEnvThread2.start() diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py index 9bfc01529f..87832ac0ef 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py @@ -117,7 +117,7 @@ class TDTestCase: topicList = topicNameList[0] ifcheckdata = 1 ifManualCommit = 1 - keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:1000, auto.offset.reset:earliest' + keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:200, auto.offset.reset:earliest' tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor") @@ -186,7 +186,7 @@ class TDTestCase: topicList = topicNameList[0] ifcheckdata = 1 ifManualCommit = 1 - keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:1000, auto.offset.reset:earliest' + keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:200, auto.offset.reset:earliest' tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor 0") diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb.py b/tests/system-test/7-tmq/tmqConsFromTsdb.py index 975f89cbd7..9bb8c4cc0d 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb.py @@ -53,7 +53,7 @@ class TDTestCase: paraDict['rowsPerTbl'] = self.rowsPerTbl tmqCom.initConsumerTable() - tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=self.replicaVar) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") @@ -116,7 +116,7 @@ class TDTestCase: topicList = topicNameList[0] ifcheckdata = 1 ifManualCommit = 1 - keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:1000, auto.offset.reset:earliest' + keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:200, auto.offset.reset:earliest' tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor") @@ -185,7 +185,7 @@ class TDTestCase: topicList = topicNameList[0] ifcheckdata = 1 ifManualCommit = 1 - keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:1000, auto.offset.reset:earliest' + keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:200, auto.offset.reset:earliest' tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor 0") diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1.py b/tests/system-test/7-tmq/tmqConsFromTsdb1.py index c0c459d315..b910caf420 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1.py @@ -53,7 +53,7 @@ class TDTestCase: paraDict['rowsPerTbl'] = self.rowsPerTbl tmqCom.initConsumerTable() - tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=self.replicaVar) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") @@ -116,7 +116,7 @@ class TDTestCase: topicList = topicNameList[0] ifcheckdata = 1 ifManualCommit = 1 - keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:1000, auto.offset.reset:earliest' + keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:200, auto.offset.reset:earliest' tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) consumerId = 4 @@ -188,7 +188,7 @@ class TDTestCase: topicList = topicNameList[0] ifcheckdata = 1 ifManualCommit = 1 - keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:1000, auto.offset.reset:earliest' + keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:200, auto.offset.reset:earliest' tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor 0") diff --git a/tests/system-test/7-tmq/tmqDelete-multiCtb.py b/tests/system-test/7-tmq/tmqDelete-multiCtb.py index 3b72b4aea5..e59e3d6ecd 100644 --- a/tests/system-test/7-tmq/tmqDelete-multiCtb.py +++ b/tests/system-test/7-tmq/tmqDelete-multiCtb.py @@ -53,7 +53,7 @@ class TDTestCase: paraDict['rowsPerTbl'] = self.rowsPerTbl tmqCom.initConsumerTable() - tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1,wal_retention_size=-1, wal_retention_period=-1) + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=self.replicaVar,wal_retention_size=-1, wal_retention_period=-1) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") @@ -146,7 +146,7 @@ class TDTestCase: ifManualCommit = 1 keyList = 'group.id:cgrp1,\ enable.auto.commit:true,\ - auto.commit.interval.ms:1000,\ + auto.commit.interval.ms:200,\ auto.offset.reset:earliest' tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) @@ -247,7 +247,7 @@ class TDTestCase: ifManualCommit = 1 keyList = 'group.id:cgrp1,\ enable.auto.commit:true,\ - auto.commit.interval.ms:1000,\ + auto.commit.interval.ms:200,\ auto.offset.reset:earliest' tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) @@ -335,7 +335,7 @@ class TDTestCase: ifManualCommit = 1 keyList = 'group.id:cgrp1,\ enable.auto.commit:true,\ - auto.commit.interval.ms:1000,\ + auto.commit.interval.ms:200,\ auto.offset.reset:earliest' tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) diff --git a/tests/system-test/7-tmq/tmqUpdateWithConsume.py b/tests/system-test/7-tmq/tmqUpdateWithConsume.py index 49a475ff16..4f595788da 100644 --- a/tests/system-test/7-tmq/tmqUpdateWithConsume.py +++ b/tests/system-test/7-tmq/tmqUpdateWithConsume.py @@ -53,7 +53,7 @@ class TDTestCase: paraDict['rowsPerTbl'] = self.rowsPerTbl tmqCom.initConsumerTable() - tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1, wal_retention_size=-1, wal_retention_period=-1) + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=self.replicaVar, wal_retention_size=-1, wal_retention_period=-1) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") @@ -124,7 +124,7 @@ class TDTestCase: ifManualCommit = 1 keyList = 'group.id:cgrp1,\ enable.auto.commit:true,\ - auto.commit.interval.ms:1000,\ + auto.commit.interval.ms:200,\ auto.offset.reset:earliest' tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) diff --git a/tests/system-test/99-TDcase/TD-21561.py b/tests/system-test/99-TDcase/TD-21561.py new file mode 100644 index 0000000000..5b852c7766 --- /dev/null +++ b/tests/system-test/99-TDcase/TD-21561.py @@ -0,0 +1,148 @@ +################################################################### +# 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 random +import os +import time +import taos +import subprocess +from faker import Faker +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes +from util.dnodes import * + +class TDTestCase: + updatecfgDict = {'maxSQLLength':1048576,'debugFlag': 143 ,"querySmaOptimize":1} + + def init(self, conn, logSql, replicaVar): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.testcasePath = os.path.split(__file__)[0] + self.testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) + + self.db = "hyp" + + def dropandcreateDB_random(self,database,n): + ts = 1630000000000 + num_random = 10 + fake = Faker('zh_CN') + tdSql.execute('''drop database if exists %s ;''' %database) + tdSql.execute('''create database %s keep 36500 ;'''%(database)) + tdSql.execute('''use %s;'''%database) + + tdSql.execute('''create stable %s.stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ + tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);'''%database) + tdSql.execute('''create stable %s.stable_2 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ + tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);'''%database) + + for i in range(num_random): + tdSql.execute('''create table %s.table_%d \ + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp ) ;'''%(database,i)) + tdSql.execute('''create table %s.stable_1_%d using %s.stable_1 tags('stable_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' + %(database,i,database,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + + # insert data + for i in range(num_random): + for j in range(n): + tdSql.execute('''insert into %s.stable_1_%d (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts)\ + values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d) ;''' + % (database,i,ts + i*1000 + j, fake.random_int(min=-2147483647, max=2147483647, step=1), + fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i)) + + tdSql.execute('''insert into %s.table_%d (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) \ + values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d) ;''' + % (database,i,ts + i*1000 + j, fake.random_int(min=-2147483647, max=2147483647, step=1), + fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i )) + + tdSql.query("select count(*) from %s.stable_1;" %database) + tdSql.checkData(0,0,num_random*n) + tdSql.query("select count(*) from %s.table_0;"%database) + tdSql.checkData(0,0,n) + + + + def sqls(self,database,function): + sql0 = f"select {function}(q_tinyint) from {database}.stable_1 where tbname in ('stable_1_1') group by tbname ;" + + sql1 = f"select {function}(q_tinyint) from {database}.stable_1 where tbname in ('stable_1_1') group by tbname;" + + sql2 = f"select {function}(q_tinyint) from {database}.stable_1 where tbname in ('stable_1_1') and _C0 is not null and _C0 between 1600000000000 and now +1h and (q_nchar like 'nchar%' or q_binary = '0' or q_nchar = 'nchar_' ) and q_bool in (0 , 1) group by tbname ;" + + sql3 = f"select * from (select {function}(q_tinyint) from {database}.stable_1 where tbname in ('stable_1_1') and _C0 is not null and _C0 between 1600000000000 and now +1h and (q_nchar like 'nchar%' or q_binary = '0' or q_nchar = 'nchar_' ) and q_bool in (0 , 1) group by tbname) ;" + + self.constant_check(sql1,sql0) + self.constant_check(sql1,sql2) + self.constant_check(sql2,sql3) + + def check_flushdb(self,database): + functions = ['COUNT', 'HYPERLOGLOG'] + for f in functions: + for i in range(20): + self.sqls(database, f); + + tdSql.execute(" flush database %s;" %database) + tdLog.info("flush database success") + + for i in range(20): + self.sqls(database, f); + + + def constant_check(self,sql1,sql2): + tdLog.info("\n=============sql1:(%s)___sql2:(%s) ====================\n" %(sql1,sql2)) + tdSql.query(sql1) + sql1_value = tdSql.getData(0,0) + tdSql.query("reset query cache") + tdSql.query(sql2) + sql2_value = tdSql.getData(0,0) + self.value_check(sql1_value,sql2_value) + + def value_check(self,base_value,check_value): + if base_value==check_value: + tdLog.info(f"checkEqual success, base_value={base_value},check_value={check_value}") + else : + tdLog.exit(f"checkEqual error, base_value=={base_value},check_value={check_value}") + + def run(self): + + startTime = time.time() + + os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) + + self.dropandcreateDB_random("%s" %self.db, 100) + + self.check_flushdb("%s" %self.db) + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/utils/tsim/inc/simInt.h b/utils/tsim/inc/simInt.h index f512b119b4..8ff3f3b183 100644 --- a/utils/tsim/inc/simInt.h +++ b/utils/tsim/inc/simInt.h @@ -181,7 +181,7 @@ typedef struct _script_t { extern SScript *simScriptList[MAX_MAIN_SCRIPT_NUM]; extern SCommand simCmdList[]; extern int32_t simScriptPos; -extern int32_t simScriptSucced; +extern int32_t simScriptSucceed; extern int32_t simDebugFlag; extern char simScriptDir[]; extern bool abortExecution; diff --git a/utils/tsim/src/simSystem.c b/utils/tsim/src/simSystem.c index f2fefb903d..98f9217fd6 100644 --- a/utils/tsim/src/simSystem.c +++ b/utils/tsim/src/simSystem.c @@ -20,7 +20,7 @@ SScript *simScriptList[MAX_MAIN_SCRIPT_NUM]; SCommand simCmdList[SIM_CMD_END]; int32_t simScriptPos = -1; -int32_t simScriptSucced = 0; +int32_t simScriptSucceed = 0; int32_t simDebugFlag = 143; void simCloseTaosdConnect(SScript *script); char simScriptDir[PATH_MAX] = {0}; @@ -88,13 +88,13 @@ SScript *simProcessCallOver(SScript *script) { } simCloseTaosdConnect(script); - simScriptSucced++; + simScriptSucceed++; simScriptPos--; simFreeScript(script); if (simScriptPos == -1 && simExecSuccess) { simInfo("----------------------------------------------------------------------"); - simInfo("Simulation Test Done, " SUCCESS_PREFIX "%d" SUCCESS_POSTFIX " Passed:\n", simScriptSucced); + simInfo("Simulation Test Done, " SUCCESS_PREFIX "%d" SUCCESS_POSTFIX " Passed:\n", simScriptSucceed); return NULL; }