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/cmake/taosadapter_CMakeLists.txt.in b/cmake/taosadapter_CMakeLists.txt.in index 31ca6b30fa..3e2e879e38 100644 --- a/cmake/taosadapter_CMakeLists.txt.in +++ b/cmake/taosadapter_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taosadapter ExternalProject_Add(taosadapter GIT_REPOSITORY https://github.com/taosdata/taosadapter.git - GIT_TAG 5662a6d + GIT_TAG a2e9920 SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in index e23ebb104b..89d1066a43 100644 --- a/cmake/taostools_CMakeLists.txt.in +++ b/cmake/taostools_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taos-tools ExternalProject_Add(taos-tools GIT_REPOSITORY https://github.com/taosdata/taos-tools.git - GIT_TAG 11b60a4 + GIT_TAG 4efbc10 SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/include/client/taos.h b/include/client/taos.h index 647f906d4f..838d0e8266 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); @@ -218,6 +220,7 @@ DLL_EXPORT const void *taos_get_raw_block(TAOS_RES *res); DLL_EXPORT int taos_get_db_route_info(TAOS *taos, const char *db, TAOS_DB_ROUTE_INFO *dbInfo); DLL_EXPORT int taos_get_table_vgId(TAOS *taos, const char *db, const char *table, int *vgId); +DLL_EXPORT int taos_get_tables_vgId(TAOS *taos, const char *db, const char *table[], int tableNum, int *vgId); DLL_EXPORT int taos_load_table_info(TAOS *taos, const char *tableNameList); 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/common/ttypes.h b/include/common/ttypes.h index 6350057c1f..b7061300c1 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -342,8 +342,8 @@ typedef struct tDataTypeDescriptor { extern tDataTypeDescriptor tDataTypes[TSDB_DATA_TYPE_MAX]; bool isValidDataType(int32_t type); +int32_t operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type); void assignVal(char *val, const char *src, int32_t len, int32_t type); -void operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type); void *getDataMin(int32_t type, void* value); void *getDataMax(int32_t type, void* value); diff --git a/include/libs/catalog/catalog.h b/include/libs/catalog/catalog.h index 0e2d043174..fbb24d2862 100644 --- a/include/libs/catalog/catalog.h +++ b/include/libs/catalog/catalog.h @@ -210,6 +210,9 @@ int32_t catalogGetCachedTableMeta(SCatalog* pCtg, const SName* pTableName, STabl int32_t catalogGetCachedSTableMeta(SCatalog* pCtg, const SName* pTableName, STableMeta** pTableMeta); +int32_t catalogGetTablesHashVgId(SCatalog* pCtg, SRequestConnInfo* pConn, int32_t acctId, const char* pDb, const char* pTableName[], + int32_t tableNum, int32_t *vgId); + int32_t catalogGetCachedTableHashVgroup(SCatalog* pCtg, const SName* pTableName, SVgroupInfo* pVgroup, bool* exists); int32_t catalogGetCachedTableVgMeta(SCatalog* pCtg, const SName* pTableName, SVgroupInfo* pVgroup, STableMeta** pTableMeta); diff --git a/include/libs/executor/executor.h b/include/libs/executor/executor.h index cfd5bd1ed7..63e1c556de 100644 --- a/include/libs/executor/executor.h +++ b/include/libs/executor/executor.h @@ -154,6 +154,8 @@ void qCleanExecTaskBlockBuf(qTaskInfo_t tinfo); */ int32_t qAsyncKillTask(qTaskInfo_t tinfo, int32_t rspCode); +bool qTaskIsExecuting(qTaskInfo_t qinfo); + /** * destroy query info structure * @param qHandle diff --git a/include/libs/function/function.h b/include/libs/function/function.h index 0ef094b92e..16d270118c 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" @@ -137,7 +136,7 @@ typedef struct SqlFunctionCtx { int16_t functionId; // function id char *pOutput; // final result output buffer, point to sdata->data // 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 numOfParams; @@ -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; } 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 d62bdb93cf..d885665117 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 { @@ -402,6 +403,7 @@ typedef struct SAggPhysiNode { SNodeList* pGroupKeys; SNodeList* pAggFuncs; bool mergeDataBlock; + bool groupKeyOptimized; } SAggPhysiNode; typedef struct SDownstreamSourceNode { diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index 16cf960724..c00625c51c 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -392,21 +392,6 @@ static FORCE_INLINE void streamTaskInputFail(SStreamTask* pTask) { atomic_store_8(&pTask->inputStatus, TASK_INPUT_STATUS__FAILED); } -static FORCE_INLINE int32_t streamTaskOutput(SStreamTask* pTask, SStreamDataBlock* pBlock) { - if (pTask->outputType == TASK_OUTPUT__TABLE) { - pTask->tbSink.tbSinkFunc(pTask, pTask->tbSink.vnode, 0, pBlock->blocks); - taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes); - taosFreeQitem(pBlock); - } else if (pTask->outputType == TASK_OUTPUT__SMA) { - pTask->smaSink.smaSink(pTask->smaSink.vnode, pTask->smaSink.smaId, pBlock->blocks); - taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes); - taosFreeQitem(pBlock); - } else { - taosWriteQitem(pTask->outputQueue->queue, pBlock); - } - return 0; -} - typedef struct { SMsgHead head; int64_t streamId; @@ -584,6 +569,7 @@ int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp); int32_t streamTryExec(SStreamTask* pTask); int32_t streamSchedExec(SStreamTask* pTask); +int32_t streamTaskOutput(SStreamTask* pTask, SStreamDataBlock* pBlock); int32_t streamScanExec(SStreamTask* pTask, int32_t batchSz); diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index 559dc1009d..f93bf9a326 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; @@ -230,6 +232,7 @@ int64_t syncOpen(SSyncInfo* pSyncInfo); int32_t syncStart(int64_t rid); void syncStop(int64_t rid); void syncPreStop(int64_t rid); +void syncPostStop(int64_t rid); int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak, int64_t* seq); int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg); int32_t syncReconfig(int64_t rid, SSyncCfg* pCfg); diff --git a/include/os/osMemory.h b/include/os/osMemory.h index 4681ff6674..e6a4488287 100644 --- a/include/os/osMemory.h +++ b/include/os/osMemory.h @@ -22,12 +22,16 @@ extern "C" { // If the error is in a third-party library, place this header file under the third-party library header file. // When you want to use this feature, you should find or add the same function in the following sectio +#if !defined(WINDOWS) + #ifndef ALLOW_FORBID_FUNC #define malloc MALLOC_FUNC_TAOS_FORBID #define calloc CALLOC_FUNC_TAOS_FORBID #define realloc REALLOC_FUNC_TAOS_FORBID #define free FREE_FUNC_TAOS_FORBID -#endif +#endif // ifndef ALLOW_FORBID_FUNC + +#endif // if !defined(WINDOWS) void *taosMemoryMalloc(int64_t size); void *taosMemoryCalloc(int64_t num, int64_t size); diff --git a/include/os/osSysinfo.h b/include/os/osSysinfo.h index 7765a60f88..dbe4d6801e 100644 --- a/include/os/osSysinfo.h +++ b/include/os/osSysinfo.h @@ -70,6 +70,7 @@ typedef struct { SysNameInfo taosGetSysNameInfo(); bool taosCheckCurrentInDll(); +int taosGetlocalhostname(char *hostname, size_t maxLen); #ifdef __cplusplus } diff --git a/include/os/osSystem.h b/include/os/osSystem.h index 8f1f5c58d5..58f34d26f0 100644 --- a/include/os/osSystem.h +++ b/include/os/osSystem.h @@ -62,11 +62,38 @@ void taosResetTerminalMode(); taosMemoryFree(strings); \ } #else +#include +#include + +#define STACKSIZE 64 #define taosPrintTrace(flags, level, dflag) \ { \ - taosPrintLog(flags, level, dflag, \ - "backtrace not implemented on windows, so detailed stack information cannot be printed"); \ - } + unsigned int i; \ + void* stack[STACKSIZE]; \ + unsigned short frames; \ + SYMBOL_INFO* symbol; \ + HANDLE process; \ + \ + process = GetCurrentProcess(); \ + \ + SymInitialize(process, NULL, TRUE); \ + \ + frames = CaptureStackBackTrace(0, STACKSIZE, stack, NULL); \ + symbol = (SYMBOL_INFO*)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); \ + if (symbol != NULL) { \ + symbol->MaxNameLen = 255; \ + symbol->SizeOfStruct = sizeof(SYMBOL_INFO); \ + \ + if (frames > 0) { \ + taosPrintLog(flags, level, dflag, "obtained %d stack frames", frames); \ + for (i = 0; i < frames; i++) { \ + SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol); \ + taosPrintLog(flags, level, dflag, "frame:%i: %s - 0x%0X", frames - i - 1, symbol->Name, symbol->Address); \ + } \ + } \ + free(symbol); \ + } \ + } #endif #ifdef __cplusplus diff --git a/include/util/taoserror.h b/include/util/taoserror.h index b315432be1..51f336c3aa 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -345,6 +345,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/tdef.h b/include/util/tdef.h index d585912259..9626180b99 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -189,12 +189,13 @@ typedef enum ELogicConditionType { #define TSDB_MAX_COLUMNS 4096 #define TSDB_MIN_COLUMNS 2 // PRIMARY COLUMN(timestamp) + other columns -#define TSDB_NODE_NAME_LEN 64 -#define TSDB_TABLE_NAME_LEN 193 // it is a null-terminated string -#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_DB_NAME_LEN 65 -#define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN) +#define TSDB_NODE_NAME_LEN 64 +#define TSDB_TABLE_NAME_LEN 193 // it is a null-terminated string +#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_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) #define TSDB_FUNC_NAME_LEN 65 #define TSDB_FUNC_COMMENT_LEN 1024 * 1024 @@ -212,8 +213,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 @@ -310,7 +311,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/source/client/src/clientMain.c b/source/client/src/clientMain.c index 87f5e5fa40..7f79323c4c 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -1168,6 +1168,54 @@ _return: return code; } +int taos_get_tables_vgId(TAOS *taos, const char *db, const char *table[], int tableNum, int *vgId) { + if (NULL == taos) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return terrno; + } + + if (NULL == db || NULL == table || NULL == vgId || tableNum <= 0) { + tscError("invalid input param, db:%p, table:%p, vgId:%p, tbNum:%d", db, table, vgId, tableNum); + terrno = TSDB_CODE_TSC_INVALID_INPUT; + return terrno; + } + + int64_t connId = *(int64_t *)taos; + SRequestObj *pRequest = NULL; + char *sql = "taos_get_table_vgId"; + int32_t code = buildRequest(connId, sql, strlen(sql), NULL, false, &pRequest, 0); + if (code != TSDB_CODE_SUCCESS) { + return terrno; + } + + pRequest->syncQuery = true; + + STscObj *pTscObj = pRequest->pTscObj; + SCatalog *pCtg = NULL; + code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCtg); + if (code != TSDB_CODE_SUCCESS) { + goto _return; + } + + SRequestConnInfo conn = { + .pTrans = pTscObj->pAppInfo->pTransporter, .requestId = pRequest->requestId, .requestObjRefId = pRequest->self}; + + conn.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp); + + code = catalogGetTablesHashVgId(pCtg, &conn, pTscObj->acctId, db, table, tableNum, vgId); + if (code) { + goto _return; + } + +_return: + + terrno = code; + + destroyRequest(pRequest); + return code; +} + + int taos_load_table_info(TAOS *taos, const char *tableNameList) { if (NULL == taos) { terrno = TSDB_CODE_TSC_DISCONNECTED; @@ -1331,6 +1379,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 bdba83cbb2..90c405c204 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -912,10 +912,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/tdatablock.c b/source/common/src/tdatablock.c index 9c8ffa11fe..171679baae 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -22,7 +22,6 @@ #define MALLOC_ALIGN_BYTES 256 int32_t colDataGetLength(const SColumnInfoData* pColumnInfoData, int32_t numOfRows) { - ASSERT(pColumnInfoData != NULL); if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { return pColumnInfoData->varmeta.length; } else { @@ -65,8 +64,6 @@ int32_t getJsonValueLen(const char* data) { } int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull) { - ASSERT(pColumnInfoData != NULL); - if (isNull) { // There is a placehold for each NULL value of binary or nchar type. if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { @@ -177,8 +174,6 @@ static void doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t curren int32_t colDataAppendNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, uint32_t numOfRows) { - ASSERT(pData != NULL && pColumnInfoData != NULL); - int32_t len = pColumnInfoData->info.bytes; if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { len = varDataTLen(pData); @@ -236,7 +231,10 @@ static void doBitmapMerge(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, c int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int32_t* capacity, const SColumnInfoData* pSource, int32_t numOfRow2) { - ASSERT(pColumnInfoData != NULL && pSource != NULL && pColumnInfoData->info.type == pSource->info.type); + if (pColumnInfoData->info.type != pSource->info.type) { + return TSDB_CODE_FAILED; + } + if (numOfRow2 == 0) { return numOfRow1; } @@ -316,13 +314,13 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows, const SDataBlockInfo* pBlockInfo) { - ASSERT(pColumnInfoData != NULL && pSource != NULL && pColumnInfoData->info.type == pSource->info.type); - if (numOfRows <= 0) { - return numOfRows; + if (pColumnInfoData->info.type != pSource->info.type || + (pBlockInfo != NULL && pBlockInfo->capacity < numOfRows)) { + return TSDB_CODE_FAILED; } - if (pBlockInfo != NULL) { - ASSERT(pBlockInfo->capacity >= numOfRows); + if (numOfRows <= 0) { + return numOfRows; } if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { @@ -388,7 +386,6 @@ int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock, int32_t tsColumnIndex) } int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc) { - assert(pSrc != NULL && pDest != NULL); int32_t capacity = pDest->info.capacity; size_t numOfCols = taosArrayGetSize(pDest->pDataBlock); @@ -406,8 +403,6 @@ int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc) { } size_t blockDataGetSize(const SSDataBlock* pBlock) { - assert(pBlock != NULL); - size_t total = 0; size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); for (int32_t i = 0; i < numOfCols; ++i) { @@ -422,8 +417,6 @@ size_t blockDataGetSize(const SSDataBlock* pBlock) { // Actual data rows pluses the corresponding meta data must fit in one memory buffer of the given page size. int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startIndex, int32_t* stopIndex, int32_t pageSize) { - ASSERT(pBlock != NULL && stopIndex != NULL); - size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); int32_t numOfRows = pBlock->info.rows; @@ -437,7 +430,9 @@ int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startInd if (!hasVarCol) { size_t rowSize = blockDataGetRowSize(pBlock); int32_t capacity = payloadSize / (rowSize + numOfCols * bitmapChar / 8.0); - ASSERT(capacity > 0); + if (capacity <= 0) { + return TSDB_CODE_FAILED; + } *stopIndex = startIndex + capacity - 1; if (*stopIndex >= numOfRows) { @@ -469,7 +464,9 @@ int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startInd if (size > pageSize) { // pageSize must be able to hold one row *stopIndex = j - 1; - ASSERT(*stopIndex >= startIndex); + if (*stopIndex < startIndex) { + return TSDB_CODE_FAILED; + } return TSDB_CODE_SUCCESS; } @@ -540,8 +537,6 @@ SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int3 * @return */ int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock) { - ASSERT(pBlock != NULL); - // write the number of rows *(uint32_t*)buf = pBlock->info.rows; @@ -612,7 +607,9 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) { } pCol->varmeta.length = colLength; - ASSERT(pCol->varmeta.length <= pCol->varmeta.allocLen); + if (pCol->varmeta.length > pCol->varmeta.allocLen) { + return TSDB_CODE_FAILED; + } } memcpy(pCol->pData, pStart, colLength); @@ -659,7 +656,9 @@ int32_t blockDataFromBuf1(SSDataBlock* pBlock, const char* buf, size_t capacity) } pCol->varmeta.length = colLength; - ASSERT(pCol->varmeta.length <= pCol->varmeta.allocLen); + if (pCol->varmeta.length > pCol->varmeta.allocLen) { + return TSDB_CODE_FAILED; + } } if (!colDataIsNNull_s(pCol, 0, pBlock->info.rows)) { @@ -673,7 +672,6 @@ int32_t blockDataFromBuf1(SSDataBlock* pBlock, const char* buf, size_t capacity) } size_t blockDataGetRowSize(SSDataBlock* pBlock) { - ASSERT(pBlock != NULL); if (pBlock->info.rowSize == 0) { size_t rowSize = 0; @@ -702,7 +700,6 @@ size_t blockDataGetSerialMetaSize(uint32_t numOfCols) { } double blockDataGetSerialRowSize(const SSDataBlock* pBlock) { - ASSERT(pBlock != NULL); double rowSize = 0; size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); @@ -905,7 +902,6 @@ static int32_t* createTupleIndex(size_t rows) { static void destroyTupleIndex(int32_t* index) { taosMemoryFreeClear(index); } int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) { - ASSERT(pDataBlock != NULL && pOrderInfo != NULL); if (pDataBlock->info.rows <= 1) { return TSDB_CODE_SUCCESS; } @@ -1149,8 +1145,7 @@ void blockDataCleanup(SSDataBlock* pDataBlock) { void blockDataEmpty(SSDataBlock* pDataBlock) { SDataBlockInfo* pInfo = &pDataBlock->info; - ASSERT(pInfo->rows <= pDataBlock->info.capacity); - if (pInfo->capacity == 0) { + if (pInfo->capacity == 0 || pInfo->rows > pDataBlock->info.capacity) { return; } @@ -1168,8 +1163,7 @@ void blockDataEmpty(SSDataBlock* pDataBlock) { // todo temporarily disable it static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo* pBlockInfo, uint32_t numOfRows, bool clearPayload) { - ASSERT(numOfRows > 0); - if (numOfRows <= pBlockInfo->capacity) { + if (numOfRows <= 0 || numOfRows <= pBlockInfo->capacity) { return TSDB_CODE_SUCCESS; } @@ -1196,7 +1190,9 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo* int32_t oldLen = BitmapLen(existedRows); pColumn->nullbitmap = tmp; memset(&pColumn->nullbitmap[oldLen], 0, BitmapLen(numOfRows) - oldLen); - ASSERT(pColumn->info.bytes); + if (pColumn->info.bytes == 0) { + return TSDB_CODE_FAILED; + } // make sure the allocated memory is MALLOC_ALIGN_BYTES aligned tmp = taosMemoryMallocAlign(MALLOC_ALIGN_BYTES, numOfRows * pColumn->info.bytes); @@ -1214,7 +1210,9 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo* // todo remove it soon #if defined LINUX - ASSERT((((uint64_t)pColumn->pData) & (MALLOC_ALIGN_BYTES - 1)) == 0x0); + if ((((uint64_t)pColumn->pData) & (MALLOC_ALIGN_BYTES - 1)) != 0x0) { + return TSDB_CODE_FAILED; + } #endif if (clearPayload) { @@ -1308,8 +1306,6 @@ void* blockDataDestroy(SSDataBlock* pBlock) { } int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src) { - ASSERT(src != NULL); - dst->info = src->info; dst->info.rows = 0; dst->info.capacity = 0; @@ -1344,8 +1340,6 @@ int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src) { } int32_t copyDataBlock(SSDataBlock* dst, const SSDataBlock* src) { - ASSERT(src != NULL && dst != NULL); - blockDataCleanup(dst); int32_t code = blockDataEnsureCapacity(dst, src->info.rows); if (code != TSDB_CODE_SUCCESS) { @@ -1501,7 +1495,6 @@ SSDataBlock* createDataBlock() { } int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoData) { - ASSERT(pBlock != NULL && pColInfoData != NULL); if (pBlock->pDataBlock == NULL) { pBlock->pDataBlock = taosArrayInit(4, sizeof(SColumnInfoData)); if (pBlock->pDataBlock == NULL) { @@ -1536,7 +1529,6 @@ SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId) } SColumnInfoData* bdGetColumnInfoData(const SSDataBlock* pBlock, int32_t index) { - ASSERT(pBlock != NULL); if (index >= taosArrayGetSize(pBlock->pDataBlock)) { return NULL; } @@ -2142,7 +2134,6 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB case TSDB_DATA_TYPE_JSON: case TSDB_DATA_TYPE_MEDIUMBLOB: uError("the column type %" PRIi16 " is defined but not implemented yet", pColInfoData->info.type); - ASSERT(0); break; default: if (pColInfoData->info.type < TSDB_DATA_TYPE_MAX && pColInfoData->info.type > TSDB_DATA_TYPE_NULL) { @@ -2176,7 +2167,6 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB } } else { uError("the column type %" PRIi16 " is undefined\n", pColInfoData->info.type); - ASSERT(0); } break; } @@ -2222,7 +2212,10 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB } char* buildCtbNameByGroupId(const char* stbFullName, uint64_t groupId) { - ASSERT(stbFullName[0] != 0); + if (stbFullName[0] == 0) { + return NULL; + } + SArray* tags = taosArrayInit(0, sizeof(void*)); if (tags == NULL) { return NULL; @@ -2260,7 +2253,9 @@ char* buildCtbNameByGroupId(const char* stbFullName, uint64_t groupId) { taosMemoryFree(pTag); taosArrayDestroy(tags); - ASSERT(rname.ctbShortName && rname.ctbShortName[0]); + if ((rname.ctbShortName && rname.ctbShortName[0]) == 0) { + return NULL; + } return rname.ctbShortName; } diff --git a/source/common/src/tname.c b/source/common/src/tname.c index 0d47ef1e7f..5cb3fe4dc0 100644 --- a/source/common/src/tname.c +++ b/source/common/src/tname.c @@ -98,8 +98,6 @@ SName* toName(int32_t acctId, const char* pDbName, const char* pTableName, SName } int32_t tNameExtractFullName(const SName* name, char* dst) { - assert(name != NULL && dst != NULL); - // invalid full name format, abort if (!tNameIsValid(name)) { return -1; @@ -109,7 +107,7 @@ int32_t tNameExtractFullName(const SName* name, char* dst) { size_t tnameLen = strlen(name->tname); if (tnameLen > 0) { - /*assert(name->type == TSDB_TABLE_NAME_T);*/ + /*ASSERT(name->type == TSDB_TABLE_NAME_T);*/ dst[len] = TS_PATH_DELIMITER[0]; memcpy(dst + len + 1, name->tname, tnameLen); @@ -120,25 +118,21 @@ int32_t tNameExtractFullName(const SName* name, char* dst) { } int32_t tNameLen(const SName* name) { - assert(name != NULL); - char tmp[12] = {0}; int32_t len = sprintf(tmp, "%d", name->acctId); int32_t len1 = (int32_t)strlen(name->dbname); int32_t len2 = (int32_t)strlen(name->tname); if (name->type == TSDB_DB_NAME_T) { - assert(len2 == 0); + ASSERT(len2 == 0); return len + len1 + TSDB_NAME_DELIMITER_LEN; } else { - assert(len2 > 0); + ASSERT(len2 > 0); return len + len1 + len2 + TSDB_NAME_DELIMITER_LEN * 2; } } bool tNameIsValid(const SName* name) { - assert(name != NULL); - if (!VALID_NAME_TYPE(name->type)) { return false; } @@ -151,15 +145,12 @@ bool tNameIsValid(const SName* name) { } SName* tNameDup(const SName* name) { - assert(name != NULL); - SName* p = taosMemoryMalloc(sizeof(SName)); memcpy(p, name, sizeof(SName)); return p; } int32_t tNameGetDbName(const SName* name, char* dst) { - assert(name != NULL && dst != NULL); strncpy(dst, name->dbname, tListLen(name->dbname)); return 0; } @@ -167,28 +158,24 @@ int32_t tNameGetDbName(const SName* name, char* dst) { const char* tNameGetDbNameP(const SName* name) { return &name->dbname[0]; } int32_t tNameGetFullDbName(const SName* name, char* dst) { - assert(name != NULL && dst != NULL); snprintf(dst, TSDB_DB_FNAME_LEN, "%d.%s", name->acctId, name->dbname); return 0; } bool tNameIsEmpty(const SName* name) { - assert(name != NULL); return name->type == 0 || name->acctId == 0; } const char* tNameGetTableName(const SName* name) { - assert(name != NULL && name->type == TSDB_TABLE_NAME_T); + ASSERT(name != NULL && name->type == TSDB_TABLE_NAME_T); return &name->tname[0]; } void tNameAssign(SName* dst, const SName* src) { memcpy(dst, src, sizeof(SName)); } int32_t tNameSetDbName(SName* dst, int32_t acct, const char* dbName, size_t nameLen) { - assert(dst != NULL && dbName != NULL && nameLen > 0); - // too long account id or too long db name - if (nameLen >= tListLen(dst->dbname)) { + if (nameLen <= 0 || nameLen >= tListLen(dst->dbname)) { return -1; } @@ -199,8 +186,6 @@ int32_t tNameSetDbName(SName* dst, int32_t acct, const char* dbName, size_t name } int32_t tNameAddTbName(SName* dst, const char* tbName, size_t nameLen) { - assert(dst != NULL && tbName != NULL && nameLen > 0); - // too long account id or too long db name if (nameLen >= tListLen(dst->tname) || nameLen <= 0) { return -1; @@ -212,7 +197,6 @@ int32_t tNameAddTbName(SName* dst, const char* tbName, size_t nameLen) { } int32_t tNameSetAcctId(SName* dst, int32_t acctId) { - assert(dst != NULL); dst->acctId = acctId; return 0; } @@ -247,7 +231,9 @@ bool tNameTbNameEqual(SName* left, SName* right) { } int32_t tNameFromString(SName* dst, const char* str, uint32_t type) { - assert(dst != NULL && str != NULL && strlen(str) > 0); + if (strlen(str) == 0) { + return -1; + } char* p = NULL; if ((type & T_NAME_ACCT) == T_NAME_ACCT) { diff --git a/source/common/src/trow.c b/source/common/src/trow.c index ca2c056743..969da4226f 100644 --- a/source/common/src/trow.c +++ b/source/common/src/trow.c @@ -76,7 +76,6 @@ void tdSCellValPrint(SCellVal *pVal, int8_t colType) { return; } if (!pVal->val) { - ASSERT(0); printf("BadVal "); return; } @@ -490,7 +489,6 @@ bool tdSTSRowGetVal(STSRowIter *pIter, col_id_t colId, col_type_t colType, SCell int32_t tdGetBitmapValTypeII(const void *pBitmap, int16_t colIdx, TDRowValT *pValType) { if (!pBitmap || colIdx < 0) { - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -512,7 +510,6 @@ int32_t tdGetBitmapValTypeII(const void *pBitmap, int16_t colIdx, TDRowValT *pVa *pValType = ((*pDestByte) & 0x03); break; default: - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -521,7 +518,6 @@ int32_t tdGetBitmapValTypeII(const void *pBitmap, int16_t colIdx, TDRowValT *pVa int32_t tdGetBitmapValTypeI(const void *pBitmap, int16_t colIdx, TDRowValT *pValType) { if (!pBitmap || colIdx < 0) { - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -555,7 +551,6 @@ int32_t tdGetBitmapValTypeI(const void *pBitmap, int16_t colIdx, TDRowValT *pVal *pValType = ((*pDestByte) & 0x01); break; default: - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -564,7 +559,6 @@ int32_t tdGetBitmapValTypeI(const void *pBitmap, int16_t colIdx, TDRowValT *pVal int32_t tdSetBitmapValTypeI(void *pBitmap, int16_t colIdx, TDRowValT valType) { if (!pBitmap || colIdx < 0) { - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -607,7 +601,6 @@ int32_t tdSetBitmapValTypeI(void *pBitmap, int16_t colIdx, TDRowValT valType) { // *pDestByte |= (valType); break; default: - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -630,7 +623,6 @@ int32_t tdGetKvRowValOfCol(SCellVal *output, STSRow *pRow, void *pBitmap, int32_ output->val = POINTER_SHIFT(pRow, offset); } #else - ASSERT(0); if (offset < 0) { terrno = TSDB_CODE_INVALID_PARA; output->valType = TD_VTYPE_NONE; @@ -680,7 +672,6 @@ int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colTyp return terrno; } #else - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; #endif @@ -707,8 +698,8 @@ int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colTyp if (!pBuilder->hasNone) pBuilder->hasNone = true; return TSDB_CODE_SUCCESS; default: - ASSERT(0); - break; + terrno = TSDB_CODE_INVALID_PARA; + return terrno; } if (TD_IS_TP_ROW(pRow)) { @@ -722,7 +713,6 @@ int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colTyp int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowValT valType, const void *val, bool isCopyVarData, int8_t colType, int16_t colIdx, int32_t offset, col_id_t colId) { if ((offset < (int32_t)sizeof(SKvRowIdx)) || (colIdx < 1)) { - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -810,7 +800,6 @@ int32_t tdSRowSetExtendedInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBou pBuilder->nCols = nCols; pBuilder->nBoundCols = nBoundCols; if (pBuilder->flen <= 0 || pBuilder->nCols <= 0) { - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -832,7 +821,6 @@ int32_t tdSRowSetExtendedInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBou int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) { pBuilder->pBuf = (STSRow *)pBuf; if (!pBuilder->pBuf) { - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -869,7 +857,6 @@ int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) { TD_ROW_SET_NCOLS(pBuilder->pBuf, pBuilder->nBoundCols); break; default: - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -880,7 +867,6 @@ int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) { int32_t tdSRowGetBuf(SRowBuilder *pBuilder, void *pBuf) { pBuilder->pBuf = (STSRow *)pBuf; if (!pBuilder->pBuf) { - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -900,7 +886,6 @@ int32_t tdSRowGetBuf(SRowBuilder *pBuilder, void *pBuf) { #endif break; default: - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -920,7 +905,6 @@ int32_t tdSRowSetTpInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t flen) { pBuilder->flen = flen; pBuilder->nCols = nCols; if (pBuilder->flen <= 0 || pBuilder->nCols <= 0) { - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -939,7 +923,6 @@ int32_t tdSRowSetInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBoundCols, pBuilder->nCols = nCols; pBuilder->nBoundCols = nBoundCols; if (pBuilder->flen <= 0 || pBuilder->nCols <= 0) { - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -968,7 +951,6 @@ int32_t tdGetBitmapValType(const void *pBitmap, int16_t colIdx, TDRowValT *pValT tdGetBitmapValTypeI(pBitmap, colIdx, pValType); break; default: - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return TSDB_CODE_FAILED; } @@ -987,7 +969,6 @@ bool tdIsBitmapValTypeNorm(const void *pBitmap, int16_t idx, int8_t bitmapMode) int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx, TDRowValT valType) { if (!pBitmap || colIdx < 0) { - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -1014,7 +995,6 @@ int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx, TDRowValT valType) { // *pDestByte |= (valType); break; default: - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -1031,7 +1011,6 @@ int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TDRowValT valType, int tdSetBitmapValTypeI(pBitmap, colIdx, valType); break; default: - ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return TSDB_CODE_FAILED; } diff --git a/source/common/src/ttime.c b/source/common/src/ttime.c index ec05ef4c44..559ffd2aaf 100644 --- a/source/common/src/ttime.c +++ b/source/common/src/ttime.c @@ -168,12 +168,13 @@ int64_t parseFraction(char* str, char** end, int32_t timePrec) { i = MICRO_SEC_FRACTION_LEN; } times = MICRO_SEC_FRACTION_LEN - i; - } else { - assert(timePrec == TSDB_TIME_PRECISION_NANO); + } else if (timePrec == TSDB_TIME_PRECISION_NANO) { if (i >= NANO_SEC_FRACTION_LEN) { i = NANO_SEC_FRACTION_LEN; } times = NANO_SEC_FRACTION_LEN - i; + } else { + return -1; } fraction = strnatoi(str, i) * factor[times]; @@ -510,8 +511,11 @@ int64_t convertTimePrecision(int64_t utime, int32_t fromPrecision, int32_t toPre // !!!!notice: double lose precison if time is too large, for example: 1626006833631000000*1.0 = double = // 1626006833631000064 int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit) { - assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO || - fromPrecision == TSDB_TIME_PRECISION_NANO); + if (fromPrecision != TSDB_TIME_PRECISION_MILLI && fromPrecision != TSDB_TIME_PRECISION_MICRO && + fromPrecision != TSDB_TIME_PRECISION_NANO) { + return -1; + } + int64_t factors[3] = {NANOSECOND_PER_MSEC, NANOSECOND_PER_USEC, 1}; double tmp = time; switch (toUnit) { @@ -761,8 +765,7 @@ int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char } int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precision) { - if (pInterval->sliding == 0) { - assert(pInterval->interval == 0); + if (pInterval->sliding == 0 && pInterval->interval == 0) { return t; } @@ -931,7 +934,7 @@ void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precision) default: fractionLen = 0; - assert(false); + ASSERT(false); } taosLocalTime(", &ptm); diff --git a/source/common/src/ttszip.c b/source/common/src/ttszip.c index 3a6bc097c1..0faa6eb4c8 100644 --- a/source/common/src/ttszip.c +++ b/source/common/src/ttszip.c @@ -17,6 +17,7 @@ #include "ttszip.h" #include "taoserror.h" #include "tcompression.h" +#include "tlog.h" static int32_t getDataStartOffset(); static void TSBufUpdateGroupInfo(STSBuf* pTSBuf, int32_t index, STSGroupBlockInfo* pBlockInfo); @@ -202,14 +203,14 @@ void* tsBufDestroy(STSBuf* pTSBuf) { static STSGroupBlockInfoEx* tsBufGetLastGroupInfo(STSBuf* pTSBuf) { int32_t last = pTSBuf->numOfGroups - 1; - assert(last >= 0); + ASSERT(last >= 0); return &pTSBuf->pData[last]; } static STSGroupBlockInfoEx* addOneGroupInfo(STSBuf* pTSBuf, int32_t id) { if (pTSBuf->numOfAlloc <= pTSBuf->numOfGroups) { uint32_t newSize = (uint32_t)(pTSBuf->numOfAlloc * 1.5); - assert((int32_t)newSize > pTSBuf->numOfAlloc); + ASSERT((int32_t)newSize > pTSBuf->numOfAlloc); STSGroupBlockInfoEx* tmp = (STSGroupBlockInfoEx*)taosMemoryRealloc(pTSBuf->pData, sizeof(STSGroupBlockInfoEx) * newSize); @@ -233,7 +234,7 @@ static STSGroupBlockInfoEx* addOneGroupInfo(STSBuf* pTSBuf, int32_t id) { STSGroupBlockInfo* pBlockInfo = &pTSBuf->pData[pTSBuf->numOfGroups].info; pBlockInfo->id = id; pBlockInfo->offset = pTSBuf->fileSize; - assert(pBlockInfo->offset >= getDataStartOffset()); + ASSERT(pBlockInfo->offset >= getDataStartOffset()); // update vnode info in file TSBufUpdateGroupInfo(pTSBuf, pTSBuf->numOfGroups, pBlockInfo); @@ -282,7 +283,7 @@ static void writeDataToDisk(STSBuf* pTSBuf) { pTsData->allocSize, TWO_STAGE_COMP, pTSBuf->assistBuf, pTSBuf->bufSize); int64_t r = taosLSeekFile(pTSBuf->pFile, pTSBuf->fileSize, SEEK_SET); - assert(r == 0); + ASSERT(r == 0); /* * format for output data: @@ -316,7 +317,7 @@ static void writeDataToDisk(STSBuf* pTSBuf) { taosWriteFile(pTSBuf->pFile, &pBlock->compLen, sizeof(pBlock->compLen)); metaLen += (int32_t)taosWriteFile(pTSBuf->pFile, &trueLen, sizeof(pBlock->tag.nLen)); - assert(metaLen == getTagAreaLength(&pBlock->tag)); + ASSERT(metaLen == getTagAreaLength(&pBlock->tag)); int32_t blockSize = metaLen + sizeof(pBlock->numOfElem) + sizeof(pBlock->compLen) * 2 + pBlock->compLen; pTSBuf->fileSize += blockSize; @@ -379,7 +380,7 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) { size_t sz = 0; if (pBlock->tag.nType == TSDB_DATA_TYPE_BINARY || pBlock->tag.nType == TSDB_DATA_TYPE_NCHAR) { char* tp = taosMemoryRealloc(pBlock->tag.pz, pBlock->tag.nLen + 1); - assert(tp != NULL); + ASSERT(tp != NULL); memset(tp, 0, pBlock->tag.nLen + 1); pBlock->tag.pz = tp; @@ -410,14 +411,14 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) { // read the comp length at the length of comp block sz = taosReadFile(pTSBuf->pFile, &pBlock->padding, sizeof(pBlock->padding)); - assert(pBlock->padding == pBlock->compLen); + ASSERT(pBlock->padding == pBlock->compLen); int32_t n = 0; sz = taosReadFile(pTSBuf->pFile, &n, sizeof(pBlock->tag.nLen)); if (pBlock->tag.nType == TSDB_DATA_TYPE_NULL) { - assert(n == 0); + ASSERT(n == 0); } else { - assert(n == pBlock->tag.nLen); + ASSERT(n == pBlock->tag.nLen); } UNUSED(sz); @@ -477,7 +478,7 @@ void tsBufAppend(STSBuf* pTSBuf, int32_t id, SVariant* tag, const char* pData, i pBlockInfo = tsBufGetLastGroupInfo(pTSBuf); } - assert(pBlockInfo->info.id == id); + ASSERT(pBlockInfo->info.id == id); if ((taosVariantCompare(&pTSBuf->block.tag, tag) != 0) && ptsData->len > 0) { // new arrived data with different tags value, save current value into disk first @@ -596,7 +597,7 @@ static int32_t tsBufFindBlockByTag(STSBuf* pTSBuf, STSGroupBlockInfo* pBlockInfo static void tsBufGetBlock(STSBuf* pTSBuf, int32_t groupIndex, int32_t blockIndex) { STSGroupBlockInfo* pBlockInfo = &pTSBuf->pData[groupIndex].info; if (pBlockInfo->numOfBlocks <= blockIndex) { - assert(false); + ASSERT(false); } STSCursor* pCur = &pTSBuf->cur; @@ -613,7 +614,7 @@ static void tsBufGetBlock(STSBuf* pTSBuf, int32_t groupIndex, int32_t blockIndex } } else { if (tsBufFindBlock(pTSBuf, pBlockInfo, blockIndex) == -1) { - assert(false); + ASSERT(false); } } @@ -633,7 +634,7 @@ static void tsBufGetBlock(STSBuf* pTSBuf, int32_t groupIndex, int32_t blockIndex tsDecompressTimestamp(pBlock->payload, pBlock->compLen, pBlock->numOfElem, pTSBuf->tsData.rawBuf, pTSBuf->tsData.allocSize, TWO_STAGE_COMP, pTSBuf->assistBuf, pTSBuf->bufSize); - assert((pTSBuf->tsData.len / TSDB_KEYSIZE == pBlock->numOfElem) && (pTSBuf->tsData.allocSize >= pTSBuf->tsData.len)); + ASSERT((pTSBuf->tsData.len / TSDB_KEYSIZE == pBlock->numOfElem) && (pTSBuf->tsData.allocSize >= pTSBuf->tsData.len)); pCur->vgroupIndex = groupIndex; pCur->blockIndex = blockIndex; @@ -668,7 +669,9 @@ int32_t STSBufUpdateHeader(STSBuf* pTSBuf, STSBufFileHeader* pHeader) { return -1; } - assert(pHeader->tsOrder == TSDB_ORDER_ASC || pHeader->tsOrder == TSDB_ORDER_DESC); + if (pHeader->tsOrder != TSDB_ORDER_ASC && pHeader->tsOrder != TSDB_ORDER_DESC) { + return -1; + } int32_t r = taosLSeekFile(pTSBuf->pFile, 0, SEEK_SET); if (r != 0) { @@ -705,7 +708,7 @@ bool tsBufNextPos(STSBuf* pTSBuf) { } } else { // get the last timestamp record in the last block of the last vnode - assert(pTSBuf->numOfGroups > 0); + ASSERT(pTSBuf->numOfGroups > 0); int32_t groupIndex = pTSBuf->numOfGroups - 1; pCur->vgroupIndex = groupIndex; @@ -729,7 +732,7 @@ bool tsBufNextPos(STSBuf* pTSBuf) { int32_t step = pCur->order == TSDB_ORDER_ASC ? 1 : -1; while (1) { - assert(pTSBuf->tsData.len == pTSBuf->block.numOfElem * TSDB_KEYSIZE); + ASSERT(pTSBuf->tsData.len == pTSBuf->block.numOfElem * TSDB_KEYSIZE); if ((pCur->order == TSDB_ORDER_ASC && pCur->tsIndex >= pTSBuf->block.numOfElem - 1) || (pCur->order == TSDB_ORDER_DESC && pCur->tsIndex <= 0)) { @@ -810,7 +813,7 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) { } // src can only have one vnode index - assert(pSrcBuf->numOfGroups == 1); + ASSERT(pSrcBuf->numOfGroups == 1); // there are data in buffer, flush to disk first tsBufFlush(pDestBuf); @@ -853,7 +856,7 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) { } int32_t r = taosLSeekFile(pDestBuf->pFile, 0, SEEK_END); - assert(r == 0); + ASSERT(r == 0); int64_t offset = getDataStartOffset(); int32_t size = (int32_t)pSrcBuf->fileSize - (int32_t)offset; @@ -881,7 +884,7 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) { } pDestBuf->fileSize = (uint32_t)file_size; - assert(pDestBuf->fileSize == oldSize + size); + ASSERT(pDestBuf->fileSize == oldSize + size); return 0; } @@ -913,7 +916,10 @@ STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_ pTSBuf->fileSize += len; pTSBuf->tsOrder = order; - assert(order == TSDB_ORDER_ASC || order == TSDB_ORDER_DESC); + if (order != TSDB_ORDER_ASC && order != TSDB_ORDER_DESC) { + tsBufDestroy(pTSBuf); + return NULL; + } STSBufFileHeader header = { .magic = TS_COMP_FILE_MAGIC, .numOfGroup = pTSBuf->numOfGroups, .tsOrder = pTSBuf->tsOrder}; @@ -1095,7 +1101,7 @@ void tsBufGetGroupIdList(STSBuf* pTSBuf, int32_t* num, int32_t** id) { } int32_t dumpFileBlockByGroupId(STSBuf* pTSBuf, int32_t groupIndex, void* buf, int32_t* len, int32_t* numOfBlocks) { - assert(groupIndex >= 0 && groupIndex < pTSBuf->numOfGroups); + ASSERT(groupIndex >= 0 && groupIndex < pTSBuf->numOfGroups); STSGroupBlockInfo* pBlockInfo = &pTSBuf->pData[groupIndex].info; *len = 0; diff --git a/source/common/src/ttypes.c b/source/common/src/ttypes.c index d412fd89da..c83bdc0e32 100644 --- a/source/common/src/ttypes.c +++ b/source/common/src/ttypes.c @@ -140,7 +140,7 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) { } } -void operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type) { +int32_t operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type) { if (optr == OP_TYPE_ADD) { switch (type) { case TSDB_DATA_TYPE_TINYINT: @@ -177,11 +177,12 @@ void operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type) { SET_DOUBLE_VAL(dst, GET_DOUBLE_VAL(s1) + GET_DOUBLE_VAL(s2)); break; default: { - assert(0); - break; + return -1; } } } else { - assert(0); + return -1; } + + return 0; } diff --git a/source/common/src/tvariant.c b/source/common/src/tvariant.c index 65e9a767f5..de225581a6 100644 --- a/source/common/src/tvariant.c +++ b/source/common/src/tvariant.c @@ -168,7 +168,7 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) { pSrc->nType == TSDB_DATA_TYPE_JSON) { int32_t len = pSrc->nLen + TSDB_NCHAR_SIZE; char *p = taosMemoryRealloc(pDst->pz, len); - assert(p); + ASSERT(p); memset(p, 0, len); pDst->pz = p; @@ -192,7 +192,7 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) { size_t num = taosArrayGetSize(pSrc->arr); pDst->arr = taosArrayInit(num, sizeof(int64_t)); pDst->nLen = pSrc->nLen; - assert(pSrc->nLen == num); + ASSERT(pSrc->nLen == num); for (size_t i = 0; i < num; i++) { int64_t *p = taosArrayGet(pSrc->arr, i); taosArrayPush(pDst->arr, p); 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 215185c555..dc32054fd7 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmFile.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmFile.c @@ -215,7 +215,7 @@ _OVER: if (code != 0) return -1; - dInfo("successed to write %s, numOfVnodes:%d", realfile, numOfVnodes); + dInfo("succeed to write %s, numOfVnodes:%d", realfile, numOfVnodes); code = taosRenameFile(file, realfile); if (code != 0) { diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index 082fe7341b..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]; @@ -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) { diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index f808c67ef6..6b274261e5 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -118,6 +118,9 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) { dInfo("vgId:%d, all vnode queues is empty", pVnode->vgId); + dInfo("vgId:%d, post close", pVnode->vgId); + vnodePostClose(pVnode->pImpl); + vmFreeQueue(pMgmt, pVnode); vnodeClose(pVnode->pImpl); pVnode->pImpl = NULL; diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index 202dc50ac6..cd29b11550 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); } @@ -138,6 +134,13 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf } } +static void vmSendResponse(SRpcMsg *pMsg) { + if (pMsg->info.handle) { + SRpcMsg rsp = {.info = pMsg->info, .code = terrno}; + rpcSendResponse(&rsp); + } +} + static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtype) { const STraceId *trace = &pMsg->info.traceId; if (pMsg->contLen < sizeof(SMsgHead)) { @@ -146,17 +149,19 @@ 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); - return terrno != 0 ? terrno : -1; + 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); + terrno = (terrno != 0) ? terrno : -1; + vmSendResponse(pMsg); + return terrno; } switch (qtype) { 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/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index d7b16c2c8e..c7a416d444 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -1050,7 +1050,7 @@ static int32_t mndRetrieveDnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB status = "offline"; } - char b1[9] = {0}; + char b1[16] = {0}; STR_TO_VARSTR(b1, status); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, b1, false); 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 071edf992f..bf3827c090 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); @@ -723,7 +726,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/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index efce6255fb..85a92c7aef 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -884,9 +884,9 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock db = taosHashIterate(pUser->writeDbs, NULL); while (db != NULL) { cols = 0; - SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - char userName[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0}; + char userName[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(userName, pUser->user, pShow->pMeta->pSchemas[cols].bytes); + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, (const char *)userName, false); char privilege[20] = {0}; @@ -909,9 +909,9 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock char *topic = taosHashIterate(pUser->topics, NULL); while (topic != NULL) { cols = 0; - SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - char userName[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0}; + char userName[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(userName, pUser->user, pShow->pMeta->pSchemas[cols].bytes); + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, (const char *)userName, false); char privilege[20] = {0}; diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index cbee70ad03..e92daaabe8 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -54,7 +54,8 @@ int32_t vnodeAlter(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs); void vnodeDestroy(const char *path, STfs *pTfs); SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb); void vnodePreClose(SVnode *pVnode); -void vnodeSyncCheckTimeout(SVnode* pVnode); +void vnodePostClose(SVnode *pVnode); +void vnodeSyncCheckTimeout(SVnode *pVnode); void vnodeClose(SVnode *pVnode); int32_t vnodeStart(SVnode *pVnode); @@ -175,7 +176,7 @@ int32_t tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, void *pTableL void tsdbReaderClose(STsdbReader *pReader); bool tsdbNextDataBlock(STsdbReader *pReader); void tsdbRetrieveDataBlockInfo(const STsdbReader *pReader, int32_t *rows, uint64_t *uid, STimeWindow *pWindow); -int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SSDataBlock* pDataBlock, bool *allHave); +int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SSDataBlock *pDataBlock, bool *allHave); SSDataBlock *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList); int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond); int32_t tsdbGetFileBlocksDistInfo(STsdbReader *pReader, STableBlockDistInfo *pTableBlockInfo); @@ -185,7 +186,7 @@ void *tsdbGetIvtIdx(SMeta *pMeta); uint64_t getReaderMaxVersion(STsdbReader *pReader); int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, void *pTableIdList, int32_t numOfTables, int32_t numOfCols, - uint64_t suid, void **pReader, const char* idstr); + uint64_t suid, void **pReader, const char *idstr); int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray *pTableUids); void *tsdbCacherowsReaderClose(void *pReader); int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid); diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 5a63af41af..5a2e462c8c 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -772,8 +772,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/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index 28797c5361..93750ed585 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -98,6 +98,7 @@ bool vnodeShouldRollback(SVnode* pVnode); int32_t vnodeSyncOpen(SVnode* pVnode, char* path); int32_t vnodeSyncStart(SVnode* pVnode); void vnodeSyncPreClose(SVnode* pVnode); +void vnodeSyncPostClose(SVnode* pVnode); void vnodeSyncClose(SVnode* pVnode); void vnodeRedirectRpcMsg(SVnode* pVnode, SRpcMsg* pMsg, int32_t code); bool vnodeIsLeader(SVnode* pVnode); diff --git a/source/dnode/vnode/src/meta/metaEntry.c b/source/dnode/vnode/src/meta/metaEntry.c index 72f7365a1e..60df66fc01 100644 --- a/source/dnode/vnode/src/meta/metaEntry.c +++ b/source/dnode/vnode/src/meta/metaEntry.c @@ -99,7 +99,9 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) { } if (tDecodeTSma(pCoder, pME->smaEntry.tsma, true) < 0) return -1; } else { - ASSERT(0); + metaError("meta/entry: invalide table type: %" PRId8 " decode failed.", pME->type); + + return -1; } tEndDecode(pCoder); diff --git a/source/dnode/vnode/src/meta/metaSnapshot.c b/source/dnode/vnode/src/meta/metaSnapshot.c index 63d044df6e..8b023b7bc5 100644 --- a/source/dnode/vnode/src/meta/metaSnapshot.c +++ b/source/dnode/vnode/src/meta/metaSnapshot.c @@ -189,7 +189,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; @@ -198,6 +199,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 e366795fd3..1d5fae33eb 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -1112,6 +1112,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); @@ -1122,6 +1127,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); @@ -1160,6 +1169,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/tqMeta.c b/source/dnode/vnode/src/tq/tqMeta.c index f476f58b56..3ad01e2370 100644 --- a/source/dnode/vnode/src/tq/tqMeta.c +++ b/source/dnode/vnode/src/tq/tqMeta.c @@ -284,8 +284,7 @@ int32_t tqMetaRestoreHandle(STQ* pTq) { handle.pRef = walOpenRef(pTq->pVnode->pWal); if (handle.pRef == NULL) { - ASSERT(0); - return -1; + continue; } walRefVer(handle.pRef, handle.snapshotVer); diff --git a/source/dnode/vnode/src/tq/tqOffset.c b/source/dnode/vnode/src/tq/tqOffset.c index dd56c165fd..9e04b70f41 100644 --- a/source/dnode/vnode/src/tq/tqOffset.c +++ b/source/dnode/vnode/src/tq/tqOffset.c @@ -46,21 +46,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) { - ASSERT(0); - // TODO handle error + taosMemoryFree(memBuf); + return -1; } STqOffset offset; SDecoder decoder; tDecoderInit(&decoder, memBuf, size); if (tDecodeSTqOffset(&decoder, &offset) < 0) { - ASSERT(0); + taosMemoryFree(memBuf); + tDecoderClear(&decoder); + return -1; } + tDecoderClear(&decoder); if (taosHashPut(pStore->pHash, offset.subKey, strlen(offset.subKey), &offset, sizeof(STqOffset)) < 0) { - ASSERT(0); - // TODO + 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); } @@ -124,7 +140,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); - ASSERT(0); + 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 5907be576a..6d474d5aa1 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -64,7 +64,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 d811d943ed..129a2dd8b3 100644 --- a/source/dnode/vnode/src/tq/tqSnapshot.c +++ b/source/dnode/vnode/src/tq/tqSnapshot.c @@ -175,6 +175,8 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) { if (code) goto _err; } + int vgId = TD_VID(pWriter->pTq->pVnode); + taosMemoryFree(pWriter); *ppWriter = NULL; @@ -186,7 +188,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 0a7f59e429..ac27a03096 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_ptr(&SL_NODE_FORWARD(n, l))) +#define SL_GET_NODE_BACKWARD(n, l) ((SMemSkipListNode *)atomic_load_ptr(&SL_NODE_BACKWARD(n, l))) +#define SL_SET_NODE_FORWARD(n, l, p) atomic_store_ptr(&SL_NODE_FORWARD(n, l), p) +#define SL_SET_NODE_BACKWARD(n, l, p) atomic_store_ptr(&SL_NODE_BACKWARD(n, l), p) #define SL_MOVE_BACKWARD 0x1 #define SL_MOVE_FROM_POS 0x2 @@ -246,18 +250,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); } } } @@ -271,7 +275,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; } @@ -282,7 +286,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; } @@ -335,7 +339,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; @@ -408,7 +412,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) { tKey.version = pn->version; tKey.ts = pn->pTSRow->ts; @@ -418,7 +422,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); } } @@ -438,7 +442,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) { tKey.version = pn->version; tKey.ts = pn->pTSRow->ts; @@ -448,7 +452,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); } } @@ -474,58 +478,53 @@ static int32_t tbDataDoPut(SMemTable *pMemTable, STbData *pTbData, SMemSkipListN int8_t level; SMemSkipListNode *pNode; SVBufPool *pPool = pMemTable->pTsdb->pVnode->inUse; + int64_t nSize; - // node + // create node level = tsdbMemSkipListRandLevel(&pTbData->sl); - ASSERT(pPool != NULL); - pNode = (SMemSkipListNode *)vnodeBufPoolMalloc(pPool, SL_NODE_SIZE(level)); + nSize = SL_NODE_SIZE(level); + pNode = (SMemSkipListNode *)vnodeBufPoolMallocAligned(pPool, nSize + pRow->len); if (pNode == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; } pNode->level = level; pNode->version = version; - pNode->pTSRow = vnodeBufPoolMalloc(pPool, pRow->len); - if (NULL == pNode->pTSRow) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _exit; - } + pNode->pTSRow = (STSRow *)((char *)pNode + nSize); memcpy(pNode->pTSRow, pRow, pRow->len); - 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 99acc24992..7b5020d395 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 04a3e7d2f7..6c54c3cb5c 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..cea85a0c11 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; @@ -247,6 +250,8 @@ void vnodePreClose(SVnode *pVnode) { vnodeSyncPreClose(pVnode); } +void vnodePostClose(SVnode *pVnode) { vnodeSyncPostClose(pVnode); } + void vnodeClose(SVnode *pVnode) { if (pVnode) { vnodeSyncCommit(pVnode); 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/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 8d53579483..ac6406fc23 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -182,7 +182,6 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp vError("vgId:%d, duplicate write request. version: %" PRId64 ", applied: %" PRId64 "", TD_VID(pVnode), version, pVnode->state.applied); terrno = TSDB_CODE_VND_DUP_REQUEST; - pRsp->info.handle = NULL; return -1; } diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index 5697487743..65e17cfaad 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); @@ -613,6 +614,11 @@ void vnodeSyncPreClose(SVnode *pVnode) { taosThreadMutexUnlock(&pVnode->lock); } +void vnodeSyncPostClose(SVnode *pVnode) { + vInfo("vgId:%d, post close sync", pVnode->config.vgId); + syncPostStop(pVnode->sync); +} + void vnodeSyncClose(SVnode *pVnode) { vInfo("vgId:%d, close sync", pVnode->config.vgId); syncStop(pVnode->sync); diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index a6ce613882..3e8300e05d 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -776,6 +776,7 @@ void ctgFreeHandleImpl(SCatalog* pCtg); int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName* pTableName, SVgroupInfo* pVgroup); int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo* dbInfo, SCtgTbHashsCtx* pCtx, char* dbFName, SArray* pNames, bool update); +int32_t ctgGetVgIdsFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, char* dbFName, const char* pTbs[], int32_t tbNum, int32_t* vgId); void ctgResetTbMetaTask(SCtgTask* pTask); void ctgFreeDbCache(SCtgDBCache* dbCache); int32_t ctgStbVersionSortCompare(const void* key1, const void* key2); diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index acd0fb9d8c..c7af0411be 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -551,6 +551,37 @@ _return: CTG_RET(code); } +int32_t ctgGetTbsHashVgId(SCatalog* pCtg, SRequestConnInfo* pConn, int32_t acctId, const char* pDb, const char* pTbs[], int32_t tbNum, int32_t* vgId) { + if (IS_SYS_DBNAME(pDb)) { + ctgError("no valid vgInfo for db, dbname:%s", pDb); + CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); + } + + SCtgDBCache* dbCache = NULL; + int32_t code = 0; + char dbFName[TSDB_DB_FNAME_LEN] = {0}; + snprintf(dbFName, TSDB_DB_FNAME_LEN, "%d.%s", acctId, pDb); + + SDBVgInfo* vgInfo = NULL; + CTG_ERR_JRET(ctgGetDBVgInfo(pCtg, pConn, dbFName, &dbCache, &vgInfo, NULL)); + + CTG_ERR_JRET(ctgGetVgIdsFromHashValue(pCtg, vgInfo ? vgInfo : dbCache->vgCache.vgInfo, dbFName, pTbs, tbNum, vgId)); + +_return: + + if (dbCache) { + ctgRUnlockVgInfo(dbCache); + ctgReleaseDBCache(pCtg, dbCache); + } + + if (vgInfo) { + freeVgInfo(vgInfo); + } + + CTG_RET(code); +} + + int32_t ctgGetCachedTbVgMeta(SCatalog* pCtg, const SName* pTableName, SVgroupInfo* pVgroup, STableMeta** pTableMeta) { int32_t code = 0; char db[TSDB_DB_FNAME_LEN] = {0}; @@ -1141,6 +1172,13 @@ int32_t catalogGetTableHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const CTG_API_LEAVE(ctgGetTbHashVgroup(pCtg, pConn, pTableName, pVgroup, NULL)); } +int32_t catalogGetTablesHashVgId(SCatalog* pCtg, SRequestConnInfo* pConn, int32_t acctId, const char* pDb, const char* pTableName[], + int32_t tableNum, int32_t *vgId) { + CTG_API_ENTER(); + + CTG_API_LEAVE(ctgGetTbsHashVgId(pCtg, pConn, acctId, pDb, pTableName, tableNum, vgId)); +} + int32_t catalogGetCachedTableHashVgroup(SCatalog* pCtg, const SName* pTableName, SVgroupInfo* pVgroup, bool* exists) { CTG_API_ENTER(); diff --git a/source/libs/catalog/src/ctgUtil.c b/source/libs/catalog/src/ctgUtil.c index 802ecde63e..3dd40a4139 100644 --- a/source/libs/catalog/src/ctgUtil.c +++ b/source/libs/catalog/src/ctgUtil.c @@ -986,6 +986,43 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo* CTG_RET(code); } +int32_t ctgGetVgIdsFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, char* dbFName, const char* pTbs[], int32_t tbNum, int32_t* vgId) { + int32_t code = 0; + CTG_ERR_RET(ctgMakeVgArray(dbInfo)); + + int32_t vgNum = taosArrayGetSize(dbInfo->vgArray); + + if (vgNum <= 0) { + ctgError("db vgroup cache invalid, db:%s, vgroup number:%d", dbFName, vgNum); + CTG_ERR_RET(TSDB_CODE_TSC_DB_NOT_SELECTED); + } + + SVgroupInfo* vgInfo = NULL; + char tbFullName[TSDB_TABLE_FNAME_LEN]; + snprintf(tbFullName, sizeof(tbFullName), "%s.", dbFName); + int32_t offset = strlen(tbFullName); + + for (int32_t i = 0; i < tbNum; ++i) { + snprintf(tbFullName + offset, sizeof(tbFullName) - offset, "%s", pTbs[i]); + uint32_t hashValue = taosGetTbHashVal(tbFullName, (uint32_t)strlen(tbFullName), dbInfo->hashMethod, + dbInfo->hashPrefix, dbInfo->hashSuffix); + + vgInfo = taosArraySearch(dbInfo->vgArray, &hashValue, ctgHashValueComp, TD_EQ); + if (NULL == vgInfo) { + ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, dbFName, + (int32_t)taosArrayGetSize(dbInfo->vgArray)); + CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); + } + + vgId[i] = vgInfo->vgId; + + ctgDebug("Got tb %s vgId:%d", tbFullName, vgInfo->vgId); + } + + CTG_RET(code); +} + + int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2) { if (*(uint64_t*)key1 < ((SSTableVersion*)key2)->suid) { return -1; 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 e3b4b57052..fffe687ff6 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -693,7 +693,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); @@ -852,6 +852,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 346fcc9729..99d1968a5d 100644 --- a/source/libs/executor/src/dataInserter.c +++ b/source/libs/executor/src/dataInserter.c @@ -41,6 +41,7 @@ typedef struct SDataInserterHandle { SHashObj* pCols; int32_t status; bool queryEnd; + bool fullOrderColList; uint64_t useconds; uint64_t cachedSize; TdThreadMutex mutex; @@ -125,7 +126,6 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) { int64_t uid = pInserter->pNode->tableId; int64_t suid = pInserter->pNode->stableId; int32_t vgId = pInserter->pNode->vgId; - bool fullCol = (pInserter->pNode->pCols->length == pTSchema->numOfCols); SSubmitReq* ret = NULL; int32_t sz = taosArrayGetSize(pBlocks); @@ -176,7 +176,7 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) { const STColumn* pColumn = &pTSchema->columns[k]; SColumnInfoData* pColData = NULL; int16_t colIdx = k; - if (!fullCol) { + if (!pInserter->fullOrderColList) { int16_t* slotId = taosHashGet(pInserter->pCols, &pColumn->colId, sizeof(pColumn->colId)); if (NULL == slotId) { continue; @@ -212,7 +212,7 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) { tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, pColumn->offset, k); } } - if (!fullCol) { + if (!pInserter->fullOrderColList) { rb.hasNone = true; } tdSRowEnd(&rb); @@ -346,12 +346,19 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat return TSDB_CODE_OUT_OF_MEMORY; } + inserter->fullOrderColList = pInserterNode->pCols->length == inserter->pSchema->numOfCols; + inserter->pCols = taosHashInit(pInserterNode->pCols->length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK); SNode* pNode = NULL; + int32_t i = 0; FOREACH(pNode, pInserterNode->pCols) { SColumnNode* pCol = (SColumnNode*)pNode; taosHashPut(inserter->pCols, &pCol->colId, sizeof(pCol->colId), &pCol->slotId, sizeof(pCol->slotId)); + if (inserter->fullOrderColList && pCol->colId != inserter->pSchema->columns[i].colId) { + inserter->fullOrderColList = false; + } + ++i; } tsem_init(&inserter->ready, 0, 0); diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 1e4a97a0e2..857d57c6b1 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/executor.c b/source/libs/executor/src/executor.c index e5ff104d5c..814ead57f0 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -704,6 +704,15 @@ int32_t qAsyncKillTask(qTaskInfo_t qinfo, int32_t rspCode) { return TSDB_CODE_SUCCESS; } +bool qTaskIsExecuting(qTaskInfo_t qinfo) { + SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)qinfo; + if (NULL == pTaskInfo) { + return false; + } + + return 0 != atomic_load_64(&pTaskInfo->owner); +} + static void printTaskExecCostInLog(SExecTaskInfo* pTaskInfo) { STaskCostInfo* pSummary = &pTaskInfo->cost; int64_t idleTime = pSummary->start - pSummary->created; diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 2c192bb9bb..3f5ac211c0 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)) { @@ -201,6 +207,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 { @@ -209,6 +219,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); } } @@ -217,6 +231,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); } @@ -224,6 +242,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}; @@ -261,6 +282,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)) { @@ -606,9 +632,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; } @@ -1009,7 +1033,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); } } @@ -1090,6 +1114,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; @@ -1133,6 +1162,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); @@ -1451,20 +1484,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; @@ -1513,7 +1551,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; } @@ -1539,8 +1577,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); @@ -1583,7 +1621,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. @@ -1738,7 +1775,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; @@ -1750,7 +1787,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; @@ -1839,7 +1882,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; } @@ -1861,11 +1905,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 de353b4bac..926720fc65 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 0e22195afa..1d7f27d0cf 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..dc884a0581 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 { @@ -44,9 +44,10 @@ typedef struct SMinmaxResInfo { bool nullTupleSaved; int16_t type; } SMinmaxResInfo; -int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc); -STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, const STupleKey* pKey); +int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems); + +int32_t saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos); 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/builtins.c b/source/libs/function/src/builtins.c index 07e480ee1d..faf7a29dd0 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1009,7 +1009,10 @@ static bool validateHistogramBinDesc(char* binDescStr, int8_t binType, char* err intervals[0] = -INFINITY; intervals[numOfBins - 1] = INFINITY; // in case of desc bin orders, -inf/inf should be swapped - ASSERT(numOfBins >= 4); + if (numOfBins < 4) { + return false; + } + if (intervals[1] > intervals[numOfBins - 2]) { TSWAP(intervals[0], intervals[numOfBins - 1]); } @@ -1354,7 +1357,7 @@ static int32_t translateCsum(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { } else if (IS_FLOAT_TYPE(colType)) { resType = TSDB_DATA_TYPE_DOUBLE; } else { - ASSERT(0); + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } } diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index d03a7fce75..8fde27e046 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; @@ -506,7 +506,6 @@ static int32_t getNumOfElems(SqlFunctionCtx* pCtx) { SColumnInfoData* pInputCol = pInput->pData[0]; if (pInput->colDataSMAIsSet && pInput->totalRows == pInput->numOfRows && !IS_VAR_DATA_TYPE(pInputCol->info.type)) { numOfElem = pInput->numOfRows - pInput->pColumnDataAgg[0]->numOfNull; - ASSERT(numOfElem >= 0); } else { if (pInputCol->hasNull) { for (int32_t i = pInput->startRowIndex; i < pInput->startRowIndex + pInput->numOfRows; ++i) { @@ -540,7 +539,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; @@ -596,7 +595,6 @@ int32_t sumFunction(SqlFunctionCtx* pCtx) { if (pInput->colDataSMAIsSet) { numOfElem = pInput->numOfRows - pAgg->numOfNull; - ASSERT(numOfElem >= 0); if (IS_SIGNED_NUMERIC_TYPE(type)) { pSumRes->isum += pAgg->sum; @@ -661,7 +659,6 @@ int32_t sumInvertFunction(SqlFunctionCtx* pCtx) { if (pInput->colDataSMAIsSet) { numOfElem = pInput->numOfRows - pAgg->numOfNull; - ASSERT(numOfElem >= 0); if (IS_SIGNED_NUMERIC_TYPE(type)) { pSumRes->isum -= pAgg->sum; @@ -757,24 +754,33 @@ bool getMinmaxFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { } int32_t minFunction(SqlFunctionCtx* pCtx) { - int32_t numOfElems = doMinMaxHelper(pCtx, 1); + int32_t numOfElems = 0; + int32_t code = doMinMaxHelper(pCtx, 1, &numOfElems); + if (code != TSDB_CODE_SUCCESS) { + return code; + } SET_VAL(GET_RES_INFO(pCtx), numOfElems, 1); return TSDB_CODE_SUCCESS; } int32_t maxFunction(SqlFunctionCtx* pCtx) { - int32_t numOfElems = doMinMaxHelper(pCtx, 0); + int32_t numOfElems = 0; + int32_t code = doMinMaxHelper(pCtx, 0, &numOfElems); + if (code != TSDB_CODE_SUCCESS) { + return code; + } SET_VAL(GET_RES_INFO(pCtx), numOfElems, 1); return TSDB_CODE_SUCCESS; } -static void setNullSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t rowIndex); -static void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuplePos* pTuplePos, +static int32_t setNullSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t rowIndex); +static int32_t setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuplePos* pTuplePos, int32_t rowIndex); int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { - SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); + int32_t code = TSDB_CODE_SUCCESS; + SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); SMinmaxResInfo* pRes = GET_ROWCELL_INTERBUF(pEntryInfo); int32_t slotId = pCtx->pExpr->base.resSchema.slotId; @@ -784,24 +790,24 @@ 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); } if (pEntryInfo->numOfRes > 0) { - setSelectivityValue(pCtx, pBlock, &pRes->tuplePos, currentRow); + code = setSelectivityValue(pCtx, pBlock, &pRes->tuplePos, currentRow); } else { - setSelectivityValue(pCtx, pBlock, &pRes->nullTuplePos, currentRow); + code = setSelectivityValue(pCtx, pBlock, &pRes->nullTuplePos, currentRow); } - return pEntryInfo->numOfRes; + return code; } -void setNullSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t rowIndex) { +int32_t setNullSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t rowIndex) { if (pCtx->subsidiaries.num <= 0) { - return; + return TSDB_CODE_SUCCESS; } for (int32_t j = 0; j < pCtx->subsidiaries.num; ++j) { @@ -811,37 +817,47 @@ void setNullSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t SColumnInfoData* pDstCol = taosArrayGet(pBlock->pDataBlock, dstSlotId); colDataAppendNULL(pDstCol, rowIndex); } + + return TSDB_CODE_SUCCESS; } -void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuplePos* pTuplePos, int32_t rowIndex) { +int32_t setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuplePos* pTuplePos, int32_t rowIndex) { if (pCtx->subsidiaries.num <= 0) { - return; + return TSDB_CODE_SUCCESS; } - 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); + if (p == NULL) { + terrno = TSDB_CODE_NO_AVAIL_DISK; + return terrno; + } - 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); + if (nullList[j]) { + colDataAppendNULL(pDstCol, rowIndex); + } else { + colDataAppend(pDstCol, rowIndex, pStart, false); } + pStart += pDstCol->info.bytes; + } + + if (pCtx->saveHandle.pState) { + tdbFree((void*)p); } } + + return TSDB_CODE_SUCCESS; } void releaseSource(STuplePos* pPos) { @@ -873,7 +889,6 @@ void appendSelectivityValue(SqlFunctionCtx* pCtx, int32_t rowIndex, int32_t pos) int32_t dstSlotId = pc->pExpr->base.resSchema.slotId; SColumnInfoData* pDstCol = taosArrayGet(pCtx->pDstBlock->pDataBlock, dstSlotId); - ASSERT(pc->pExpr->base.resSchema.bytes == pDstCol->info.bytes); if (colDataIsNull_s(pSrcCol, rowIndex) == true) { colDataAppendNULL(pDstCol, pos); @@ -1142,7 +1157,9 @@ static void stddevTransferInfo(SStddevRes* pInput, SStddevRes* pOutput) { int32_t stddevFunctionMerge(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pCol = pInput->pData[0]; - ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); + if (pCol->info.type != TSDB_DATA_TYPE_BINARY) { + return TSDB_CODE_FUNC_FUNTION_PARA_TYPE; + } SStddevRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); @@ -1567,7 +1584,7 @@ int32_t percentileFunction(SqlFunctionCtx* pCtx) { // all data are null, set it completed if (pInfo->numOfElems == 0) { pResInfo->complete = true; - return 0; + return TSDB_CODE_SUCCESS; } else { pInfo->pMemBucket = tMemBucketCreate(pCol->info.bytes, type, pInfo->minval, pInfo->maxval); } @@ -1630,7 +1647,11 @@ int32_t percentileFunction(SqlFunctionCtx* pCtx) { char* data = colDataGetData(pCol, i); numOfElems += 1; - tMemBucketPut(pInfo->pMemBucket, data, 1); + int32_t code = tMemBucketPut(pInfo->pMemBucket, data, 1); + if (code != TSDB_CODE_SUCCESS) { + tMemBucketDestroy(pInfo->pMemBucket); + return code; + } } SET_VAL(pResInfo, numOfElems, 1); @@ -1653,6 +1674,11 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { } tMemBucketDestroy(pMemBucket); + + if (ppInfo->result < 0) { + return TSDB_CODE_NO_AVAIL_DISK; + } + return functionFinalize(pCtx, pBlock); } @@ -1768,7 +1794,10 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) { double v = 0; GET_TYPED_DATA(v, double, type, data); - tHistogramAdd(&pInfo->pHisto, v); + int32_t code = tHistogramAdd(&pInfo->pHisto, v); + if (code != 0) { + return TSDB_CODE_FAILED; + } } qDebug("%s after add %d elements into histogram, total:%" PRId64 ", numOfEntry:%d, pHisto:%p, elems: %p", @@ -1838,7 +1867,9 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pCol = pInput->pData[0]; - ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); + if (pCol->info.type != TSDB_DATA_TYPE_BINARY) { + return TSDB_CODE_FUNC_FUNTION_PARA_TYPE; + } SAPercentileInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); @@ -2006,25 +2037,26 @@ static void prepareBuf(SqlFunctionCtx* pCtx) { pCtx->subsidiaries.rowLen = rowLen + pCtx->subsidiaries.num * sizeof(bool); pCtx->subsidiaries.buf = taosMemoryMalloc(pCtx->subsidiaries.rowLen); } - - ASSERT(pCtx->subsidiaries.buf != NULL); - ASSERT(pCtx->subsidiaries.rowLen > 0); } -static void firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SqlFunctionCtx* pCtx, +static int32_t firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SqlFunctionCtx* pCtx, SFirstLastRes* pInfo) { + int32_t code = TSDB_CODE_SUCCESS; + if (pCtx->subsidiaries.num <= 0) { - return; + return TSDB_CODE_SUCCESS; } if (!pInfo->hasResult) { - pInfo->pos = saveTupleData(pCtx, rowIndex, pSrcBlock, NULL); + code = saveTupleData(pCtx, rowIndex, pSrcBlock, &pInfo->pos); } else { - updateTupleData(pCtx, rowIndex, pSrcBlock, &pInfo->pos); + code = updateTupleData(pCtx, rowIndex, pSrcBlock, &pInfo->pos); } + + return code; } -static void doSaveCurrentVal(SqlFunctionCtx* pCtx, int32_t rowIndex, int64_t currentTs, int32_t type, char* pData) { +static int32_t doSaveCurrentVal(SqlFunctionCtx* pCtx, int32_t rowIndex, int64_t currentTs, int32_t type, char* pData) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); SFirstLastRes* pInfo = GET_ROWCELL_INTERBUF(pResInfo); @@ -2034,9 +2066,13 @@ static void doSaveCurrentVal(SqlFunctionCtx* pCtx, int32_t rowIndex, int64_t cur memcpy(pInfo->buf, pData, pInfo->bytes); pInfo->ts = currentTs; - firstlastSaveTupleData(pCtx->pSrcBlock, rowIndex, pCtx, pInfo); + int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, rowIndex, pCtx, pInfo); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pInfo->hasResult = true; + return TSDB_CODE_SUCCESS; } // This ordinary first function does not care if current scan is ascending order or descending order scan @@ -2057,10 +2093,12 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { } // All null data column, return directly. - if (pInput->colDataSMAIsSet && (pInput->pColumnDataAgg[0]->numOfNull == pInput->totalRows)) { - ASSERT(pInputCol->hasNull == true); + if (pInput->colDataSMAIsSet && (pInput->pColumnDataAgg[0]->numOfNull == pInput->totalRows) && pInputCol->hasNull == true) { // save selectivity value for column consisted of all null values - firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo); + int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo); + if (code != TSDB_CODE_SUCCESS) { + return code; + } return TSDB_CODE_SUCCESS; } @@ -2071,8 +2109,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 @@ -2133,7 +2171,10 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { char* data = colDataGetData(pInputCol, i); TSKEY cts = pts[i]; if (pResInfo->numOfRes == 0 || pInfo->ts > cts) { - doSaveCurrentVal(pCtx, i, cts, pInputCol->info.type, data); + int32_t code = doSaveCurrentVal(pCtx, i, cts, pInputCol->info.type, data); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pResInfo->numOfRes = 1; } } @@ -2141,7 +2182,10 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { if (numOfElems == 0) { // save selectivity value for column consisted of all null values - firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo); + int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } SET_VAL(pResInfo, numOfElems, 1); return TSDB_CODE_SUCCESS; @@ -2165,10 +2209,12 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { } // All null data column, return directly. - if (pInput->colDataSMAIsSet && (pInput->pColumnDataAgg[0]->numOfNull == pInput->totalRows)) { - ASSERT(pInputCol->hasNull == true); + if (pInput->colDataSMAIsSet && (pInput->pColumnDataAgg[0]->numOfNull == pInput->totalRows) && pInputCol->hasNull == true) { // save selectivity value for column consisted of all null values - firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo); + int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo); + if (code != TSDB_CODE_SUCCESS) { + return code; + } return TSDB_CODE_SUCCESS; } @@ -2179,7 +2225,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 +2283,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]; @@ -2257,29 +2304,38 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { if (pResInfo->numOfRes == 0 || pInfo->ts < cts) { char* data = colDataGetData(pInputCol, chosen); - doSaveCurrentVal(pCtx, i, cts, type, data); + int32_t code = doSaveCurrentVal(pCtx, i, cts, type, data); + if (code != TSDB_CODE_SUCCESS) { + return code; + } 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; + 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); + int32_t code = doSaveCurrentVal(pCtx, i, pts[i], type, data); + if (code != TSDB_CODE_SUCCESS) { + return code; } + 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++; if (pResInfo->numOfRes == 0 || pInfo->ts < pts[i]) { char* data = colDataGetData(pInputCol, i); - doSaveCurrentVal(pCtx, i, pts[i], type, data); + int32_t code = doSaveCurrentVal(pCtx, i, pts[i], type, data); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pResInfo->numOfRes = 1; } } @@ -2290,7 +2346,10 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { // save selectivity value for column consisted of all null values if (numOfElems == 0) { - firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo); + int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } // SET_VAL(pResInfo, numOfElems, 1); @@ -2318,18 +2377,25 @@ static int32_t firstLastTransferInfoImpl(SFirstLastRes* pInput, SFirstLastRes* p return TSDB_CODE_SUCCESS; } -static void firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, SFirstLastRes* pOutput, bool isFirst, +static int32_t firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, SFirstLastRes* pOutput, bool isFirst, int32_t rowIndex) { if (TSDB_CODE_SUCCESS == firstLastTransferInfoImpl(pInput, pOutput, isFirst)) { - firstlastSaveTupleData(pCtx->pSrcBlock, rowIndex, pCtx, pOutput); + int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, rowIndex, pCtx, pOutput); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pOutput->hasResult = true; } + + return TSDB_CODE_SUCCESS; } static int32_t firstLastFunctionMergeImpl(SqlFunctionCtx* pCtx, bool isFirstQuery) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pCol = pInput->pData[0]; - ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); + if (pCol->info.type != TSDB_DATA_TYPE_BINARY) { + return TSDB_CODE_FUNC_FUNTION_PARA_TYPE; + } SFirstLastRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); @@ -2339,7 +2405,10 @@ static int32_t firstLastFunctionMergeImpl(SqlFunctionCtx* pCtx, bool isFirstQuer for (int32_t i = start; i < start + pInput->numOfRows; ++i) { char* data = colDataGetData(pCol, i); SFirstLastRes* pInputInfo = (SFirstLastRes*)varDataVal(data); - firstLastTransferInfo(pCtx, pInputInfo, pInfo, isFirstQuery, i); + int32_t code = firstLastTransferInfo(pCtx, pInputInfo, pInfo, isFirstQuery, i); + if (code != TSDB_CODE_SUCCESS) { + return code; + } if (!numOfElems) { numOfElems = pInputInfo->hasResult ? 1 : 0; } @@ -2354,6 +2423,7 @@ int32_t firstFunctionMerge(SqlFunctionCtx* pCtx) { return firstLastFunctionMerge int32_t lastFunctionMerge(SqlFunctionCtx* pCtx) { return firstLastFunctionMergeImpl(pCtx, false); } int32_t firstLastFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { + int32_t code = TSDB_CODE_SUCCESS; int32_t slotId = pCtx->pExpr->base.resSchema.slotId; SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); @@ -2364,12 +2434,14 @@ int32_t firstLastFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { colDataAppend(pCol, pBlock->info.rows, pRes->buf, pRes->isNull || pResInfo->isNullRes); // handle selectivity - setSelectivityValue(pCtx, pBlock, &pRes->pos, pBlock->info.rows); + code = setSelectivityValue(pCtx, pBlock, &pRes->pos, pBlock->info.rows); - return pResInfo->numOfRes; + return code; } int32_t firstLastPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { + int32_t code = TSDB_CODE_SUCCESS; + SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); SFirstLastRes* pRes = GET_ROWCELL_INTERBUF(pEntryInfo); @@ -2385,10 +2457,10 @@ int32_t firstLastPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); colDataAppend(pCol, pBlock->info.rows, res, false); - setSelectivityValue(pCtx, pBlock, &pRes->pos, pBlock->info.rows); + code = setSelectivityValue(pCtx, pBlock, &pRes->pos, pBlock->info.rows); taosMemoryFree(res); - return 1; + return code; } int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { @@ -2408,7 +2480,7 @@ int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { return TSDB_CODE_SUCCESS; } -static void doSaveLastrow(SqlFunctionCtx* pCtx, char* pData, int32_t rowIndex, int64_t cts, SFirstLastRes* pInfo) { +static int32_t doSaveLastrow(SqlFunctionCtx* pCtx, char* pData, int32_t rowIndex, int64_t cts, SFirstLastRes* pInfo) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pInputCol = pInput->pData[0]; @@ -2425,9 +2497,14 @@ static void doSaveLastrow(SqlFunctionCtx* pCtx, char* pData, int32_t rowIndex, i } pInfo->ts = cts; - firstlastSaveTupleData(pCtx->pSrcBlock, rowIndex, pCtx, pInfo); + int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, rowIndex, pCtx, pInfo); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pInfo->hasResult = true; + + return TSDB_CODE_SUCCESS; } int32_t lastRowFunction(SqlFunctionCtx* pCtx) { @@ -2439,7 +2516,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; @@ -2489,7 +2566,10 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) { numOfElems++; if (pResInfo->numOfRes == 0 || pInfo->ts < cts) { - doSaveLastrow(pCtx, data, i, cts, pInfo); + int32_t code = doSaveLastrow(pCtx, data, i, cts, pInfo); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pResInfo->numOfRes = 1; } } @@ -2524,7 +2604,7 @@ bool diffFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) { return true; } -static void doSetPrevVal(SDiffInfo* pDiffInfo, int32_t type, const char* pv, int64_t ts) { +static int32_t doSetPrevVal(SDiffInfo* pDiffInfo, int32_t type, const char* pv, int64_t ts) { switch (type) { case TSDB_DATA_TYPE_BOOL: pDiffInfo->prev.i64 = *(bool*)pv ? 1 : 0; @@ -2549,12 +2629,14 @@ static void doSetPrevVal(SDiffInfo* pDiffInfo, int32_t type, const char* pv, int pDiffInfo->prev.d64 = *(double*)pv; break; default: - ASSERT(0); + return TSDB_CODE_FUNC_FUNTION_PARA_TYPE; } pDiffInfo->prevTs = ts; + + return TSDB_CODE_SUCCESS; } -static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SColumnInfoData* pOutput, int32_t pos, +static int32_t doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SColumnInfoData* pOutput, int32_t pos, int32_t order, int64_t ts) { int32_t factor = (order == TSDB_ORDER_ASC) ? 1 : -1; pDiffInfo->prevTs = ts; @@ -2629,8 +2711,10 @@ static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SCo break; } default: - ASSERT(0); + return TSDB_CODE_FUNC_FUNTION_PARA_TYPE; } + + return TSDB_CODE_SUCCESS; } int32_t diffFunction(SqlFunctionCtx* pCtx) { @@ -2667,7 +2751,10 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) { if (tsList[i] == pDiffInfo->prevTs) { return TSDB_CODE_FUNC_DUP_TIMESTAMP; } - doHandleDiff(pDiffInfo, pInputCol->info.type, pv, pOutput, pos, pCtx->order, tsList[i]); + int32_t code = doHandleDiff(pDiffInfo, pInputCol->info.type, pv, pOutput, pos, pCtx->order, tsList[i]); + if (code != TSDB_CODE_SUCCESS) { + return code; + } // handle selectivity if (pCtx->subsidiaries.num > 0) { appendSelectivityValue(pCtx, i, pos); @@ -2675,7 +2762,10 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) { numOfElems++; } else { - doSetPrevVal(pDiffInfo, pInputCol->info.type, pv, tsList[i]); + int32_t code = doSetPrevVal(pDiffInfo, pInputCol->info.type, pv, tsList[i]); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } pDiffInfo->hasPrev = true; @@ -2700,7 +2790,10 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) { if (tsList[i] == pDiffInfo->prevTs) { return TSDB_CODE_FUNC_DUP_TIMESTAMP; } - doHandleDiff(pDiffInfo, pInputCol->info.type, pv, pOutput, pos, pCtx->order, tsList[i]); + int32_t code = doHandleDiff(pDiffInfo, pInputCol->info.type, pv, pOutput, pos, pCtx->order, tsList[i]); + if (code != TSDB_CODE_SUCCESS) { + return code; + } // handle selectivity if (pCtx->subsidiaries.num > 0) { appendSelectivityValue(pCtx, i, pos); @@ -2708,7 +2801,10 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) { numOfElems++; } else { - doSetPrevVal(pDiffInfo, pInputCol->info.type, pv, tsList[i]); + int32_t code = doSetPrevVal(pDiffInfo, pInputCol->info.type, pv, tsList[i]); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } pDiffInfo->hasPrev = true; @@ -2750,8 +2846,8 @@ static STopBotRes* getTopBotOutputInfo(SqlFunctionCtx* pCtx) { return pRes; } -static void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSDataBlock* pSrcBlock, uint16_t type, - uint64_t uid, SResultRowEntryInfo* pEntryInfo, bool isTopQuery); +static int32_t doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSDataBlock* pSrcBlock, uint16_t type, + uint64_t uid, SResultRowEntryInfo* pEntryInfo, bool isTopQuery); static void addResult(SqlFunctionCtx* pCtx, STopBotResItem* pSourceItem, int16_t type, bool isTopQuery); @@ -2773,11 +2869,17 @@ int32_t topFunction(SqlFunctionCtx* pCtx) { numOfElems++; char* data = colDataGetData(pCol, i); - doAddIntoResult(pCtx, data, i, pCtx->pSrcBlock, pRes->type, pInput->uid, pResInfo, true); + int32_t code = doAddIntoResult(pCtx, data, i, pCtx->pSrcBlock, pRes->type, pInput->uid, pResInfo, true); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pRes->nullTupleSaved) { - pRes->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL); + int32_t code = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, &pRes->nullTuplePos); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pRes->nullTupleSaved = true; } return TSDB_CODE_SUCCESS; @@ -2801,11 +2903,17 @@ int32_t bottomFunction(SqlFunctionCtx* pCtx) { numOfElems++; char* data = colDataGetData(pCol, i); - doAddIntoResult(pCtx, data, i, pCtx->pSrcBlock, pRes->type, pInput->uid, pResInfo, false); + int32_t code = doAddIntoResult(pCtx, data, i, pCtx->pSrcBlock, pRes->type, pInput->uid, pResInfo, false); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pRes->nullTupleSaved) { - pRes->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL); + int32_t code = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, &pRes->nullTuplePos); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pRes->nullTupleSaved = true; } @@ -2845,7 +2953,7 @@ static int32_t topBotResComparFn(const void* p1, const void* p2, const void* par return (val1->v.d > val2->v.d) ? 1 : -1; } -void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSDataBlock* pSrcBlock, uint16_t type, +int32_t doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSDataBlock* pSrcBlock, uint16_t type, uint64_t uid, SResultRowEntryInfo* pEntryInfo, bool isTopQuery) { STopBotRes* pRes = getTopBotOutputInfo(pCtx); @@ -2853,7 +2961,6 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData taosVariantCreateFromBinary(&val, pData, tDataTypes[type].bytes, type); STopBotResItem* pItems = pRes->pItems; - assert(pItems != NULL); // not full yet if (pEntryInfo->numOfRes < pRes->maxSize) { @@ -2863,7 +2970,10 @@ 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); + int32_t code = saveTupleData(pCtx, rowIndex, pSrcBlock, &pItem->tuplePos); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } #ifdef BUF_PAGE_DEBUG qDebug("page_saveTuple i:%d, item:%p,pageId:%d, offset:%d\n", pEntryInfo->numOfRes, pItem, pItem->tuplePos.pageId, @@ -2889,7 +2999,10 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData // save the data of this tuple by over writing the old data if (pCtx->subsidiaries.num > 0) { - updateTupleData(pCtx, rowIndex, pSrcBlock, &pItem->tuplePos); + int32_t code = updateTupleData(pCtx, rowIndex, pSrcBlock, &pItem->tuplePos); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } #ifdef BUF_PAGE_DEBUG qDebug("page_copyTuple pageId:%d, offset:%d", pItem->tuplePos.pageId, pItem->tuplePos.offset); @@ -2898,6 +3011,8 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData topBotResComparFn, NULL, !isTopQuery); } } + + return TSDB_CODE_SUCCESS; } /* @@ -2937,21 +3052,33 @@ 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 int32_t doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length, STupleKey key, + STuplePos* pPos) { STuplePos p = {0}; if (pHandle->pBuf != NULL) { SFilePage* pPage = NULL; if (pHandle->currentPage == -1) { pPage = getNewBufPage(pHandle->pBuf, &pHandle->currentPage); + if (pPage == NULL) { + terrno = TSDB_CODE_NO_AVAIL_DISK; + return terrno; + } pPage->num = sizeof(SFilePage); } else { pPage = getBufPage(pHandle->pBuf, pHandle->currentPage); + if (pPage == NULL) { + terrno = TSDB_CODE_NO_AVAIL_DISK; + return terrno; + } if (pPage->num + length > getBufPageSize(pHandle->pBuf)) { // current page is all used, let's prepare a new buffer page releaseBufPage(pHandle->pBuf, pPage); pPage = getNewBufPage(pHandle->pBuf, &pHandle->currentPage); + if (pPage == NULL) { + terrno = TSDB_CODE_NO_AVAIL_DISK; + return terrno; + } pPage->num = sizeof(SFilePage); } } @@ -2964,25 +3091,41 @@ 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) { - ASSERT(0); + if (streamStateFuncPut(pHandle->pState, &key, pBuf, length) >= 0) { + p.streamTupleKey = key; } - p.streamTupleKey = *pKey; } - return p; + *pPos = p; + return TSDB_CODE_SUCCESS; } -STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, const STupleKey* pKey) { +int32_t saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos) { prepareBuf(pCtx); + STupleKey key; + if (pCtx->saveHandle.pBuf == NULL) { + SColumnInfoData* pColInfo = taosArrayGet(pSrcBlock->pDataBlock, 0); + if (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, pPos); } static int32_t doUpdateTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length, STuplePos* pPos) { if (pHandle->pBuf != NULL) { SFilePage* pPage = getBufPage(pHandle->pBuf, pPos->pageId); + if (pPage == NULL) { + terrno = TSDB_CODE_NO_AVAIL_DISK; + return terrno; + } memcpy(pPage->data + pPos->offset, pBuf, length); setBufPageDirty(pPage, true); releaseBufPage(pHandle->pBuf, pPage); @@ -2997,13 +3140,15 @@ int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBloc prepareBuf(pCtx); char* buf = serializeTupleData(pSrcBlock, rowIndex, &pCtx->subsidiaries, pCtx->subsidiaries.buf); - doUpdateTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, pPos); - return TSDB_CODE_SUCCESS; + return doUpdateTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, pPos); } static char* doLoadTupleData(SSerializeDataHandle* pHandle, const STuplePos* pPos) { if (pHandle->pBuf != NULL) { SFilePage* pPage = getBufPage(pHandle->pBuf, pPos->pageId); + if (pPage == NULL) { + return NULL; + } char* p = pPage->data + pPos->offset; releaseBufPage(pHandle->pBuf, pPage); return p; @@ -3020,6 +3165,8 @@ const char* loadTupleData(SqlFunctionCtx* pCtx, const STuplePos* pPos) { } int32_t topBotFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { + int32_t code = TSDB_CODE_SUCCESS; + SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); STopBotRes* pRes = getTopBotOutputInfo(pCtx); @@ -3032,8 +3179,8 @@ int32_t topBotFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t currentRow = pBlock->info.rows; if (pEntryInfo->numOfRes <= 0) { colDataAppendNULL(pCol, currentRow); - setSelectivityValue(pCtx, pBlock, &pRes->nullTuplePos, currentRow); - return pEntryInfo->numOfRes; + code = setSelectivityValue(pCtx, pBlock, &pRes->nullTuplePos, currentRow); + return code; } for (int32_t i = 0; i < pEntryInfo->numOfRes; ++i) { STopBotResItem* pItem = &pRes->pItems[i]; @@ -3042,18 +3189,17 @@ int32_t topBotFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { qDebug("page_finalize i:%d,item:%p,pageId:%d, offset:%d\n", i, pItem, pItem->tuplePos.pageId, pItem->tuplePos.offset); #endif - setSelectivityValue(pCtx, pBlock, &pRes->pItems[i].tuplePos, currentRow); + code = setSelectivityValue(pCtx, pBlock, &pRes->pItems[i].tuplePos, currentRow); currentRow += 1; } - return pEntryInfo->numOfRes; + return code; } void addResult(SqlFunctionCtx* pCtx, STopBotResItem* pSourceItem, int16_t type, bool isTopQuery) { SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); STopBotRes* pRes = getTopBotOutputInfo(pCtx); STopBotResItem* pItems = pRes->pItems; - assert(pItems != NULL); // not full yet if (pEntryInfo->numOfRes < pRes->maxSize) { @@ -3211,7 +3357,9 @@ static void spreadTransferInfo(SSpreadInfo* pInput, SSpreadInfo* pOutput) { int32_t spreadFunctionMerge(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pCol = pInput->pData[0]; - ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); + if (pCol->info.type != TSDB_DATA_TYPE_BINARY) { + return TSDB_CODE_FUNC_FUNTION_PARA_TYPE; + } SSpreadInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); @@ -3390,7 +3538,9 @@ static void elapsedTransferInfo(SElapsedInfo* pInput, SElapsedInfo* pOutput) { int32_t elapsedFunctionMerge(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pCol = pInput->pData[0]; - ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); + if (pCol->info.type != TSDB_DATA_TYPE_BINARY) { + return TSDB_CODE_FUNC_FUNTION_PARA_TYPE; + } SElapsedInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); @@ -3560,7 +3710,9 @@ static bool getHistogramBinDesc(SHistoFuncInfo* pInfo, char* binDescStr, int8_t intervals[0] = -INFINITY; intervals[numOfBins - 1] = INFINITY; // in case of desc bin orders, -inf/inf should be swapped - ASSERT(numOfBins >= 4); + if (numOfBins < 4) { + return false; + } if (intervals[1] > intervals[numOfBins - 2]) { TSWAP(intervals[0], intervals[numOfBins - 1]); } @@ -3623,7 +3775,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); @@ -3703,7 +3855,9 @@ static void histogramTransferInfo(SHistoFuncInfo* pInput, SHistoFuncInfo* pOutpu int32_t histogramFunctionMerge(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pCol = pInput->pData[0]; - ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); + if (pCol->info.type != TSDB_DATA_TYPE_BINARY) { + return TSDB_CODE_FUNC_FUNTION_PARA_TYPE; + } SHistoFuncInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); @@ -3947,7 +4101,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); @@ -4086,7 +4239,7 @@ static bool checkStateOp(int8_t op, SColumnInfoData* pCol, int32_t index, SVaria break; } default: { - ASSERT(0); + return false; } } return false; @@ -4418,12 +4571,15 @@ static void sampleAssignResult(SSampleInfo* pInfo, char* data, int32_t index) { assignVal(pInfo->data + index * pInfo->colBytes, data, pInfo->colBytes, pInfo->colType); } -static void doReservoirSample(SqlFunctionCtx* pCtx, SSampleInfo* pInfo, char* data, int32_t index) { +static int32_t doReservoirSample(SqlFunctionCtx* pCtx, SSampleInfo* pInfo, char* data, int32_t index) { pInfo->totalPoints++; 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); + int32_t code = saveTupleData(pCtx, index, pCtx->pSrcBlock, &pInfo->tuplePos[pInfo->numSampled]); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } pInfo->numSampled++; } else { @@ -4431,10 +4587,15 @@ static void doReservoirSample(SqlFunctionCtx* pCtx, SSampleInfo* pInfo, char* da if (j < pInfo->samples) { sampleAssignResult(pInfo, data, j); if (pCtx->subsidiaries.num > 0) { - updateTupleData(pCtx, index, pCtx->pSrcBlock, &pInfo->tuplePos[j]); + int32_t code = updateTupleData(pCtx, index, pCtx->pSrcBlock, &pInfo->tuplePos[j]); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } } } + + return TSDB_CODE_SUCCESS; } int32_t sampleFunction(SqlFunctionCtx* pCtx) { @@ -4450,11 +4611,17 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) { } char* data = colDataGetData(pInputCol, i); - doReservoirSample(pCtx, pInfo, data, i); + int32_t code = doReservoirSample(pCtx, pInfo, data, i); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } if (pInfo->numSampled == 0 && pCtx->subsidiaries.num > 0 && !pInfo->nullTupleSaved) { - pInfo->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL); + int32_t code = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, &pInfo->nullTuplePos); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pInfo->nullTupleSaved = true; } @@ -4463,6 +4630,7 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) { } int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { + int32_t code = TSDB_CODE_SUCCESS; SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); SSampleInfo* pInfo = getSampleOutputInfo(pCtx); @@ -4474,15 +4642,15 @@ int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t currentRow = pBlock->info.rows; if (pInfo->numSampled == 0) { colDataAppendNULL(pCol, currentRow); - setSelectivityValue(pCtx, pBlock, &pInfo->nullTuplePos, currentRow); - return pInfo->numSampled; + code = setSelectivityValue(pCtx, pBlock, &pInfo->nullTuplePos, currentRow); + return code; } for (int32_t i = 0; i < pInfo->numSampled; ++i) { colDataAppend(pCol, currentRow + i, pInfo->data + i * pInfo->colBytes, false); - setSelectivityValue(pCtx, pBlock, &pInfo->tuplePos[i], currentRow + i); + code = setSelectivityValue(pCtx, pBlock, &pInfo->tuplePos[i], currentRow + i); } - return pInfo->numSampled; + return code; } bool getTailFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { @@ -4748,7 +4916,7 @@ bool modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) { return true; } -static void doModeAdd(SModeInfo* pInfo, int32_t rowIndex, SqlFunctionCtx* pCtx, char* data) { +static int32_t doModeAdd(SModeInfo* pInfo, int32_t rowIndex, SqlFunctionCtx* pCtx, char* data) { int32_t hashKeyBytes = IS_STR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes; SModeItem** pHashItem = taosHashGet(pInfo->pHash, data, hashKeyBytes); if (pHashItem == NULL) { @@ -4758,7 +4926,10 @@ 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); + int32_t code = saveTupleData(pCtx, rowIndex, pCtx->pSrcBlock, &pItem->tuplePos); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } taosHashPut(pInfo->pHash, data, hashKeyBytes, &pItem, sizeof(SModeItem*)); @@ -4766,9 +4937,14 @@ static void doModeAdd(SModeInfo* pInfo, int32_t rowIndex, SqlFunctionCtx* pCtx, } else { (*pHashItem)->count += 1; if (pCtx->subsidiaries.num > 0) { - updateTupleData(pCtx, rowIndex, pCtx->pSrcBlock, &((*pHashItem)->tuplePos)); + int32_t code = updateTupleData(pCtx, rowIndex, pCtx->pSrcBlock, &((*pHashItem)->tuplePos)); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } } + + return TSDB_CODE_SUCCESS; } int32_t modeFunction(SqlFunctionCtx* pCtx) { @@ -4789,7 +4965,10 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) { numOfElems++; char* data = colDataGetData(pInputCol, i); - doModeAdd(pInfo, i, pCtx, data); + int32_t code = doModeAdd(pInfo, i, pCtx, data); + if (code != TSDB_CODE_SUCCESS) { + return code; + } if (sizeof(SModeInfo) + pInfo->numOfPoints * (sizeof(SModeItem) + pInfo->colBytes) >= MODE_MAX_RESULT_SIZE) { taosHashCleanup(pInfo->pHash); @@ -4798,7 +4977,10 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) { } if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pInfo->nullTupleSaved) { - pInfo->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL); + int32_t code = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, &pInfo->nullTuplePos); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pInfo->nullTupleSaved = true; } @@ -4808,6 +4990,7 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) { } int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { + int32_t code = TSDB_CODE_SUCCESS; SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); SModeInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); int32_t slotId = pCtx->pExpr->base.resSchema.slotId; @@ -4827,15 +5010,15 @@ int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { if (maxCount != 0) { SModeItem* pResItem = (SModeItem*)(pInfo->pItems + resIndex * (sizeof(SModeItem) + pInfo->colBytes)); colDataAppend(pCol, currentRow, pResItem->data, false); - setSelectivityValue(pCtx, pBlock, &pResItem->tuplePos, currentRow); + code = setSelectivityValue(pCtx, pBlock, &pResItem->tuplePos, currentRow); } else { colDataAppendNULL(pCol, currentRow); - setSelectivityValue(pCtx, pBlock, &pInfo->nullTuplePos, currentRow); + code = setSelectivityValue(pCtx, pBlock, &pInfo->nullTuplePos, currentRow); } taosHashCleanup(pInfo->pHash); - return pResInfo->numOfRes; + return code; } bool getTwaFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv) { @@ -4887,11 +5070,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) { } int32_t i = pInput->startRowIndex; - if (pCtx->start.key != INT64_MIN) { - // ASSERT((pCtx->start.key < tsList[i] && pCtx->order == TSDB_ORDER_ASC) || - // (pCtx->start.key > tsList[i] && pCtx->order == TSDB_ORDER_DESC)); - - ASSERT(last->key == INT64_MIN); + if (pCtx->start.key != INT64_MIN && last->key == INT64_MIN) { for (; i < pInput->numOfRows + pInput->startRowIndex; ++i) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { continue; @@ -5111,7 +5290,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) { } default: - ASSERT(0); + return TSDB_CODE_FUNC_FUNTION_PARA_TYPE; } // the last interpolated time window value @@ -5138,7 +5317,6 @@ _twa_over: * is required, we simply copy to the resut ot interResBuffer. */ // void twa_function_copy(SQLFunctionCtx *pCtx) { -// assert(pCtx->inputType == TSDB_DATA_TYPE_BINARY); // SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx); // // memcpy(GET_ROWCELL_INTERBUF(pResInfo), pCtx->pInput, (size_t)pCtx->inputBytes); @@ -5299,7 +5477,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); @@ -5684,7 +5862,10 @@ int32_t cachedLastRowFunction(SqlFunctionCtx* pCtx) { TSKEY cts = getRowPTs(pInput->pPTS, i); if (pResInfo->numOfRes == 0 || pInfo->ts < cts) { - doSaveLastrow(pCtx, data, i, cts, pInfo); + int32_t code = doSaveLastrow(pCtx, data, i, cts, pInfo); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pResInfo->numOfRes = 1; } } diff --git a/source/libs/function/src/detail/tavgfunction.c b/source/libs/function/src/detail/tavgfunction.c index 8e010181d1..3a70a65ec4 100644 --- a/source/libs/function/src/detail/tavgfunction.c +++ b/source/libs/function/src/detail/tavgfunction.c @@ -366,7 +366,6 @@ bool avgFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) { static int32_t calculateAvgBySMAInfo(SAvgRes* pRes, int32_t numOfRows, int32_t type, const SColumnDataAgg* pAgg) { int32_t numOfElem = numOfRows - pAgg->numOfNull; - ASSERT(numOfElem >= 0); pRes->count += numOfElem; if (IS_SIGNED_NUMERIC_TYPE(type)) { @@ -672,7 +671,7 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) { break; } default: - ASSERT(0); + return TSDB_CODE_FUNC_FUNTION_PARA_TYPE; } } else { numOfElem = doAddNumericVector(pCol, type, pInput, pAvgRes); @@ -706,7 +705,9 @@ static void avgTransferInfo(SAvgRes* pInput, SAvgRes* pOutput) { int32_t avgFunctionMerge(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pCol = pInput->pData[0]; - ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); + if (pCol->info.type != TSDB_DATA_TYPE_BINARY) { + return TSDB_CODE_FUNC_FUNTION_PARA_TYPE; + } SAvgRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); diff --git a/source/libs/function/src/detail/tminmax.c b/source/libs/function/src/detail/tminmax.c index cb5cea3cc8..847c738655 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; @@ -699,7 +700,7 @@ static void doExtractVal(SColumnInfoData* pCol, int32_t i, int32_t end, SqlFunct } } -int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { +int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) { int32_t numOfElems = 0; SInputColumnInfoData* pInput = &pCtx->input; @@ -720,7 +721,6 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { // data in current data block are qualified to the query if (pInput->colDataSMAIsSet) { numOfElems = pInput->numOfRows - pAgg->numOfNull; - ASSERT(pInput->numOfRows == pInput->totalRows && numOfElems >= 0); if (numOfElems == 0) { goto _over; @@ -736,11 +736,19 @@ 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); + int32_t code = saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } } } else { @@ -750,11 +758,14 @@ 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); + int32_t code = saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } } } @@ -764,11 +775,14 @@ 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); + int32_t code = saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } } } @@ -778,11 +792,14 @@ 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); + int32_t code = saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } } } @@ -792,20 +809,23 @@ 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); + int32_t code = saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } } } } pBuf->assign = true; - return numOfElems; + return TSDB_CODE_SUCCESS; } int32_t start = pInput->startRowIndex; @@ -819,14 +839,16 @@ 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); + int32_t code = saveTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } pBuf->assign = true; numOfElems = 1; } if (i >= end) { - ASSERT(numOfElems == 0); goto _over; } @@ -883,9 +905,13 @@ 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); + int32_t code = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, &pBuf->nullTuplePos); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pBuf->nullTupleSaved = true; } - return numOfElems; -} \ No newline at end of file + *nElems = numOfElems; + return TSDB_CODE_SUCCESS; +} diff --git a/source/libs/function/src/tfunctionInt.c b/source/libs/function/src/tfunctionInt.c index 70378df0c3..edfd866010 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" @@ -41,8 +40,6 @@ int32_t getNumOfResult(SqlFunctionCtx* pCtx, int32_t num, SSDataBlock* pResBlock } } - assert(maxRows >= 0); - blockDataEnsureCapacity(pResBlock, maxRows); for (int32_t i = 0; i < num; ++i) { SColumnInfoData* pCol = taosArrayGet(pResBlock->pDataBlock, i); @@ -64,7 +61,6 @@ int32_t getNumOfResult(SqlFunctionCtx* pCtx, int32_t num, SSDataBlock* pResBlock } bool isRowEntryCompleted(struct SResultRowEntryInfo* pEntry) { - assert(pEntry != NULL); return pEntry->complete; } diff --git a/source/libs/function/src/thistogram.c b/source/libs/function/src/thistogram.c index b0f23f78df..e7d631f638 100644 --- a/source/libs/function/src/thistogram.c +++ b/source/libs/function/src/thistogram.c @@ -73,7 +73,10 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) { #if defined(USE_ARRAYLIST) int32_t idx = histoBinarySearch((*pHisto)->elems, (*pHisto)->numOfEntries, val); - assert(idx >= 0 && idx <= (*pHisto)->maxEntries && (*pHisto)->elems != NULL); + if (ASSERTS(idx >= 0 && idx <= (*pHisto)->maxEntries && (*pHisto)->elems != NULL, "tHistogramAdd Error, idx:%d, maxEntries:%d, elems:%p", + idx, (*pHisto)->maxEntries, (*pHisto)->elems)) { + return -1; + } if ((*pHisto)->elems[idx].val == val && idx >= 0) { (*pHisto)->elems[idx].num += 1; @@ -84,15 +87,27 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) { } else { /* insert a new slot */ if ((*pHisto)->numOfElems >= 1 && idx < (*pHisto)->numOfEntries) { if (idx > 0) { - assert((*pHisto)->elems[idx - 1].val <= val); + if (ASSERTS((*pHisto)->elems[idx - 1].val <= val, "tHistogramAdd Error, elems[%d].val:%lf, val:%lf", + idx - 1, (*pHisto)->elems[idx - 1].val, val)) { + return -1; + } } else { - assert((*pHisto)->elems[idx].val > val); + if (ASSERTS((*pHisto)->elems[idx].val > val, "tHistogramAdd Error, elems[%d].val:%lf, val:%lf", + idx, (*pHisto)->elems[idx].val, val)) { + return -1; + } } } else if ((*pHisto)->numOfElems > 0) { - assert((*pHisto)->elems[(*pHisto)->numOfEntries].val <= val); + if (ASSERTS((*pHisto)->elems[(*pHisto)->numOfEntries].val <= val, "tHistogramAdd Error, elems[%d].val:%lf, val:%lf", + (*pHisto)->numOfEntries, (*pHisto)->elems[idx].val, val)) { + return -1; + } } - histogramCreateBin(*pHisto, idx, val); + int32_t code = histogramCreateBin(*pHisto, idx, val); + if (code != 0) { + return code; + } } #else tSkipListKey key = tSkipListCreateKey(TSDB_DATA_TYPE_DOUBLE, &val, tDataTypes[TSDB_DATA_TYPE_DOUBLE].nSize); @@ -151,7 +166,6 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) { if ((*pHisto)->numOfEntries >= (*pHisto)->maxEntries + 1) { // set the right value for loser-tree - assert((*pHisto)->pLoserTree != NULL); if (!(*pHisto)->ordered) { SSkipListPrint((*pHisto)->pList, 1); @@ -203,7 +217,10 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) { tSkipListNode* pNext = pNode->pForward[0]; SHistBin* pNextEntry = (SHistBin*)pNext->pData; - assert(pNextEntry->val - pEntry->val == pEntry->delta); + if (ASSERTS(pNextEntry->val - pEntry->val == pEntry->delta, "tHistogramAdd Error, pNextEntry->val:%lf, pEntry->val:%lf, pEntry->delta:%lf", + pNextEntry->val, pEntry->val, pEntry->delta)) { + return -1; + } double newVal = (pEntry->val * pEntry->num + pNextEntry->val * pNextEntry->num) / (pEntry->num + pNextEntry->num); pEntry->val = newVal; @@ -253,7 +270,9 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) { } else { SHistBin* pEntry = (SHistBin*)pResNode->pData; - assert(pEntry->val == val); + if (ASSERTS(pEntry->val == val, "tHistogramAdd Error, pEntry->val:%lf, val:%lf")) { + return -1; + } pEntry->num += 1; } @@ -329,7 +348,10 @@ int32_t histogramCreateBin(SHistogramInfo* pHisto, int32_t index, double val) { memmove(&pHisto->elems[index + 1], &pHisto->elems[index], sizeof(SHistBin) * remain); } - assert(index >= 0 && index <= pHisto->maxEntries); + if (ASSERTS(index >= 0 && index <= pHisto->maxEntries, "histogramCreateBin Error, index:%d, maxEntries:%d", + index, pHisto->maxEntries)) { + return -1; + } pHisto->elems[index].num = 1; pHisto->elems[index].val = val; @@ -343,7 +365,11 @@ int32_t histogramCreateBin(SHistogramInfo* pHisto, int32_t index, double val) { pHisto->elems[pHisto->maxEntries].num = 0; } #endif - assert(pHisto->numOfEntries <= pHisto->maxEntries); + if (ASSERTS(pHisto->numOfEntries <= pHisto->maxEntries, "histogramCreateBin Error, numOfEntries:%d, maxEntries:%d", + pHisto->numOfEntries, pHisto->maxEntries)) { + return -1; + } + return 0; } @@ -386,12 +412,14 @@ int64_t tHistogramSum(SHistogramInfo* pHisto, double v) { if (slotIdx < 0) { slotIdx = 0; - assert(v <= pHisto->elems[slotIdx].val); + ASSERTS(v <= pHisto->elems[slotIdx].val, "tHistogramSum Error, elems[%d].val:%lf, v:%lf", + slotIdx, pHisto->elems[slotIdx].val, v); } else { - assert(v >= pHisto->elems[slotIdx].val); - + ASSERTS(v >= pHisto->elems[slotIdx].val, "tHistogramSum Error, elems[%d].val:%lf, v:%lf", + slotIdx, pHisto->elems[slotIdx].val, v); if (slotIdx + 1 < pHisto->numOfEntries) { - assert(v < pHisto->elems[slotIdx + 1].val); + ASSERTS(v < pHisto->elems[slotIdx + 1].val, "tHistogramSum Error, elems[%d].val:%lf, v:%lf", + slotIdx + 1, pHisto->elems[slotIdx + 1].val, v); } } } @@ -445,7 +473,9 @@ double* tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num) { j += 1; } - assert(total <= numOfElem && total + pHisto->elems[j + 1].num > numOfElem); + ASSERTS(total <= numOfElem && total + pHisto->elems[j + 1].num > numOfElem, + "tHistogramUniform Error, total:%d, numOfElem:%d, elems[%d].num:%d", + total, numOfElem, j + 1, pHisto->elems[j + 1].num); double delta = numOfElem - total; if (fabs(delta) < FLT_EPSILON) { @@ -502,7 +532,9 @@ double* tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num) { j += 1; } - assert(total <= numOfElem && total + pEntry->num > numOfElem); + ASSERTS(total <= numOfElem && total + pEntry->num > numOfElem, + "tHistogramUniform Error, total:%d, numOfElem:%d, pEntry->num:%d", + total, numOfElem, pEntry->num); double delta = numOfElem - total; if (fabs(delta) < FLT_EPSILON) { diff --git a/source/libs/function/src/tpercentile.c b/source/libs/function/src/tpercentile.c index 157ee08f15..04472c42ec 100644 --- a/source/libs/function/src/tpercentile.c +++ b/source/libs/function/src/tpercentile.c @@ -40,6 +40,9 @@ static SFilePage *loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx) int32_t *pageId = taosArrayGet(pIdList, i); SFilePage *pg = getBufPage(pMemBucket->pBuffer, *pageId); + if (pg == NULL) { + return NULL; + } memcpy(buffer->data + offset, pg->data, (size_t)(pg->num * pMemBucket->bytes)); offset += (int32_t)(pg->num * pMemBucket->bytes); @@ -88,7 +91,7 @@ static void resetPosInfo(SSlotInfo *pInfo) { } double findOnlyResult(tMemBucket *pMemBucket) { - assert(pMemBucket->total == 1); + ASSERT(pMemBucket->total == 1); for (int32_t i = 0; i < pMemBucket->numOfSlots; ++i) { tMemBucketSlot *pSlot = &pMemBucket->pSlots[i]; @@ -100,11 +103,14 @@ double findOnlyResult(tMemBucket *pMemBucket) { SArray **pList = taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId)); if (pList != NULL) { SArray *list = *pList; - assert(list->size == 1); + ASSERT(list->size == 1); int32_t *pageId = taosArrayGet(list, 0); SFilePage *pPage = getBufPage(pMemBucket->pBuffer, *pageId); - assert(pPage->num == 1); + if (pPage == NULL) { + return -1; + } + ASSERT(pPage->num == 1); double v = 0; GET_TYPED_DATA(v, double, pMemBucket->type, pPage->data); @@ -140,7 +146,8 @@ int32_t tBucketIntHash(tMemBucket *pBucket, const void *value) { } } - assert(index >= 0 && index < pBucket->numOfSlots); + ASSERTS(index >= 0 && index < pBucket->numOfSlots, "tBucketIntHash Error, index:%d, numOfSlots:%d", + index, pBucket->numOfSlots); return index; } @@ -167,7 +174,7 @@ int32_t tBucketUintHash(tMemBucket *pBucket, const void *value) { } } - assert(index >= 0 && index < pBucket->numOfSlots); + ASSERT(index >= 0 && index < pBucket->numOfSlots); return index; } @@ -198,7 +205,7 @@ int32_t tBucketDoubleHash(tMemBucket *pBucket, const void *value) { } } - assert(index >= 0 && index < pBucket->numOfSlots); + ASSERT(index >= 0 && index < pBucket->numOfSlots); return index; } @@ -331,7 +338,7 @@ void tMemBucketUpdateBoundingBox(MinMaxEntry *r, const char *data, int32_t dataT r->dMaxVal = v; } } else { - assert(0); + ASSERT(0); } } @@ -339,7 +346,7 @@ void tMemBucketUpdateBoundingBox(MinMaxEntry *r, const char *data, int32_t dataT * in memory bucket, we only accept data array list */ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) { - assert(pBucket != NULL && data != NULL && size > 0); + ASSERT(pBucket != NULL && data != NULL && size > 0); int32_t count = 0; int32_t bytes = pBucket->bytes; @@ -361,7 +368,7 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) { if (pSlot->info.data == NULL || pSlot->info.data->num >= pBucket->elemPerPage) { if (pSlot->info.data != NULL) { - assert(pSlot->info.data->num >= pBucket->elemPerPage && pSlot->info.size > 0); + ASSERT(pSlot->info.data->num >= pBucket->elemPerPage && pSlot->info.size > 0); // keep the pointer in memory setBufPageDirty(pSlot->info.data, true); @@ -379,6 +386,9 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) { } pSlot->info.data = getNewBufPage(pBucket->pBuffer, &pageId); + if (pSlot->info.data == NULL) { + return TSDB_CODE_NO_AVAIL_DISK; + } pSlot->info.pageId = pageId; taosArrayPush(pPageIdList, &pageId); } @@ -390,7 +400,7 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) { } pBucket->total += count; - return 0; + return TSDB_CODE_SUCCESS; } //////////////////////////////////////////////////////////////////////////////////////////// @@ -407,14 +417,14 @@ static MinMaxEntry getMinMaxEntryOfNextSlotWithData(tMemBucket *pMemBucket, int3 ++j; } - assert(j < pMemBucket->numOfSlots); + ASSERT(j < pMemBucket->numOfSlots); return pMemBucket->pSlots[j].range; } static bool isIdenticalData(tMemBucket *pMemBucket, int32_t index); static double getIdenticalDataVal(tMemBucket *pMemBucket, int32_t slotIndex) { - assert(isIdenticalData(pMemBucket, slotIndex)); + ASSERT(isIdenticalData(pMemBucket, slotIndex)); tMemBucketSlot *pSlot = &pMemBucket->pSlots[slotIndex]; @@ -461,7 +471,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction) minOfNextSlot = (double)next.dMinVal; } - assert(minOfNextSlot > maxOfThisSlot); + ASSERT(minOfNextSlot > maxOfThisSlot); double val = (1 - fraction) * maxOfThisSlot + fraction * minOfNextSlot; return val; @@ -470,6 +480,9 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction) if (pSlot->info.size <= pMemBucket->maxCapacity) { // data in buffer and file are merged together to be processed. SFilePage *buffer = loadDataFromFilePage(pMemBucket, i); + if (buffer == NULL) { + return -1; + } int32_t currentIdx = count - num; char *thisVal = buffer->data + pMemBucket->bytes * currentIdx; @@ -504,8 +517,14 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction) for (int32_t f = 0; f < list->size; ++f) { int32_t *pageId = taosArrayGet(list, f); SFilePage *pg = getBufPage(pMemBucket->pBuffer, *pageId); + if (pg == NULL) { + return -1; + } - tMemBucketPut(pMemBucket, pg->data, (int32_t)pg->num); + int32_t code = tMemBucketPut(pMemBucket, pg->data, (int32_t)pg->num); + if (code != TSDB_CODE_SUCCESS) { + return -1; + } setBufPageDirty(pg, true); releaseBufPage(pMemBucket->pBuffer, pg); } @@ -527,7 +546,9 @@ double getPercentile(tMemBucket *pMemBucket, double percent) { // if only one elements exists, return it if (pMemBucket->total == 1) { - return findOnlyResult(pMemBucket); + if (findOnlyResult(pMemBucket) < 0) { + return -1; + } } percent = fabs(percent); 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 9fcbbddf38..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)) { 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 7b1cb514a6..7b9c54ab2c 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -402,6 +402,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 1dab60876a..1a4ba8e43e 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -1829,6 +1829,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; @@ -1846,6 +1847,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; } @@ -1866,6 +1870,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 0ac2581689..dfe2f6c8b9 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 20a2520a79..5fecc95f1b 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -186,6 +186,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, @@ -193,15 +194,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); @@ -214,9 +213,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); -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 212a1c92b5..7136a555cd 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -459,8 +459,11 @@ 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); } -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) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); } +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); } @@ -657,6 +660,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 17d8297cf0..eaa72b1377 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; @@ -1509,6 +1527,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); @@ -1567,9 +1592,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); @@ -1578,10 +1605,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); @@ -1593,9 +1620,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); @@ -1607,8 +1637,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); @@ -1617,8 +1650,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; @@ -1730,9 +1766,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) { 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); @@ -1749,8 +1788,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 0a20484179..05d49bb027 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -4948,6 +4948,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; @@ -5523,7 +5527,8 @@ static void getStreamQueryFirstProjectAliasName(SHashObj* pUserAliasSet, char* a return; } -static int32_t addWstartTsToCreateStreamQueryImpl(SSelectStmt* pSelect, SHashObj* pUserAliasSet) { +static int32_t addWstartTsToCreateStreamQueryImpl(STranslateContext* pCxt, SSelectStmt* pSelect, + SHashObj* pUserAliasSet) { SNode* pProj = nodesListGetNode(pSelect->pProjectionList, 0); if (NULL == pSelect->pWindow || (QUERY_NODE_FUNCTION == nodeType(pProj) && 0 == strcmp("_wstart", ((SFunctionNode*)pProj)->functionName))) { @@ -5535,7 +5540,10 @@ static int32_t addWstartTsToCreateStreamQueryImpl(SSelectStmt* pSelect, SHashObj } strcpy(pFunc->functionName, "_wstart"); getStreamQueryFirstProjectAliasName(pUserAliasSet, pFunc->node.aliasName, sizeof(pFunc->node.aliasName)); - int32_t code = nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc); + int32_t code = getFuncInfo(pCxt, pFunc); + if (TSDB_CODE_SUCCESS == code) { + code = nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc); + } if (TSDB_CODE_SUCCESS != code) { nodesDestroyNode((SNode*)pFunc); } @@ -5547,7 +5555,7 @@ static int32_t addWstartTsToCreateStreamQuery(STranslateContext* pCxt, SNode* pS SHashObj* pUserAliasSet = NULL; int32_t code = checkProjectAlias(pCxt, pSelect->pProjectionList, &pUserAliasSet); if (TSDB_CODE_SUCCESS == code) { - code = addWstartTsToCreateStreamQueryImpl(pSelect, pUserAliasSet); + code = addWstartTsToCreateStreamQueryImpl(pCxt, pSelect, pUserAliasSet); } taosHashCleanup(pUserAliasSet); return code; @@ -5660,13 +5668,13 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStm static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SCMCreateStreamReq* pReq) { pCxt->createStream = true; - int32_t code = addWstartTsToCreateStreamQuery(pCxt, pStmt->pQuery); - if (TSDB_CODE_SUCCESS == code) { - code = addSubtableInfoToCreateStreamQuery(pCxt, pStmt); - } + int32_t code = addSubtableInfoToCreateStreamQuery(pCxt, pStmt); if (TSDB_CODE_SUCCESS == code) { code = translateQuery(pCxt, pStmt->pQuery); } + if (TSDB_CODE_SUCCESS == code) { + code = addWstartTsToCreateStreamQuery(pCxt, pStmt->pQuery); + } if (TSDB_CODE_SUCCESS == code) { code = checkStreamQuery(pCxt, pStmt); } @@ -7482,7 +7490,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 a1ebe0ac32..d3b9bf069b 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 457 +#define YYNOCODE 459 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; EOperatorType yy20; - int8_t yy33; - SAlterOption yy123; - SNode* yy148; - SToken yy199; - EFillMode yy334; - bool yy397; - SNodeList* yy404; - EJoinType yy470; - ENullOrder yy499; - int64_t yy525; - SDataType yy530; - int32_t yy706; - EOrder yy898; + SNode* yy74; + ENullOrder yy109; + SToken yy317; + EOrder yy326; + bool yy335; + int8_t yy449; + int64_t yy531; + EJoinType yy630; + SAlterOption yy767; + EFillMode yy828; + int32_t yy856; + SNodeList* yy874; + SDataType yy898; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -139,17 +139,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 708 -#define YYNRULE 538 +#define YYNSTATE 711 +#define YYNRULE 541 #define YYNTOKEN 322 -#define YY_MAX_SHIFT 707 -#define YY_MIN_SHIFTREDUCE 1048 -#define YY_MAX_SHIFTREDUCE 1585 -#define YY_ERROR_ACTION 1586 -#define YY_ACCEPT_ACTION 1587 -#define YY_NO_ACTION 1588 -#define YY_MIN_REDUCE 1589 -#define YY_MAX_REDUCE 2126 +#define YY_MAX_SHIFT 710 +#define YY_MIN_SHIFTREDUCE 1054 +#define YY_MAX_SHIFTREDUCE 1594 +#define YY_ERROR_ACTION 1595 +#define YY_ACCEPT_ACTION 1596 +#define YY_NO_ACTION 1597 +#define YY_MIN_REDUCE 1598 +#define YY_MAX_REDUCE 2138 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -216,736 +216,742 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2706) +#define YY_ACTTAB_COUNT (2723) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 458, 1795, 459, 1625, 1838, 1733, 1587, 467, 353, 459, - /* 10 */ 1625, 1632, 43, 41, 1516, 181, 1925, 1793, 1731, 399, - /* 20 */ 360, 62, 1367, 36, 35, 1081, 1960, 42, 40, 39, - /* 30 */ 38, 37, 167, 1446, 559, 1365, 1658, 42, 40, 39, - /* 40 */ 38, 37, 36, 35, 1921, 1927, 42, 40, 39, 38, - /* 50 */ 37, 33, 274, 332, 1842, 607, 464, 577, 1441, 25, - /* 60 */ 699, 545, 460, 16, 1083, 2097, 1086, 1087, 597, 375, - /* 70 */ 1373, 365, 596, 558, 1788, 1790, 597, 1942, 97, 1373, - /* 80 */ 2103, 173, 123, 43, 41, 2098, 566, 1929, 131, 497, - /* 90 */ 52, 360, 132, 1367, 596, 12, 560, 325, 1925, 1742, - /* 100 */ 1734, 512, 511, 510, 1446, 352, 1365, 1742, 1960, 128, - /* 110 */ 506, 545, 58, 155, 505, 2097, 580, 704, 1392, 504, - /* 120 */ 509, 1911, 1744, 613, 405, 503, 1921, 1927, 343, 1441, - /* 130 */ 2103, 173, 1448, 1449, 16, 2098, 566, 607, 1475, 457, - /* 140 */ 158, 1373, 462, 1631, 577, 1696, 1941, 172, 2037, 2038, - /* 150 */ 1976, 129, 2042, 100, 1943, 617, 1945, 1946, 612, 565, - /* 160 */ 607, 1422, 1431, 2097, 318, 170, 12, 2029, 476, 46, - /* 170 */ 466, 354, 2025, 462, 1631, 131, 265, 266, 564, 173, - /* 180 */ 1368, 264, 1366, 2098, 566, 175, 337, 526, 704, 1393, - /* 190 */ 1929, 36, 35, 2055, 1476, 42, 40, 39, 38, 37, - /* 200 */ 524, 1925, 522, 1448, 1449, 1371, 1372, 1513, 1421, 1424, - /* 210 */ 1425, 1426, 1427, 1428, 1429, 1430, 609, 605, 1439, 1440, - /* 220 */ 1442, 1443, 1444, 1445, 1447, 1450, 2, 58, 58, 1921, - /* 230 */ 1927, 355, 1422, 1431, 255, 2037, 576, 2101, 124, 575, - /* 240 */ 607, 80, 2097, 1789, 1790, 596, 47, 338, 1392, 336, - /* 250 */ 335, 1368, 499, 1366, 1542, 127, 501, 564, 173, 1303, - /* 260 */ 1304, 176, 2098, 566, 1737, 32, 358, 1470, 1471, 1472, - /* 270 */ 1473, 1474, 1478, 1479, 1480, 1481, 1371, 1372, 500, 1421, - /* 280 */ 1424, 1425, 1426, 1427, 1428, 1429, 1430, 609, 605, 1439, - /* 290 */ 1440, 1442, 1443, 1444, 1445, 1447, 1450, 2, 1612, 9, - /* 300 */ 43, 41, 552, 1540, 1541, 1543, 1544, 1838, 360, 584, - /* 310 */ 1367, 398, 1393, 397, 1100, 157, 1099, 1601, 183, 351, - /* 320 */ 46, 1446, 1853, 1365, 1207, 639, 638, 637, 1211, 636, - /* 330 */ 1213, 1214, 635, 1216, 632, 1590, 1222, 629, 1224, 1225, - /* 340 */ 626, 623, 1911, 1520, 169, 1101, 1441, 1086, 1087, 1392, - /* 350 */ 2102, 16, 2044, 555, 2097, 597, 113, 1782, 1373, 112, - /* 360 */ 111, 110, 109, 108, 107, 106, 105, 104, 394, 178, - /* 370 */ 2101, 43, 41, 1451, 2098, 2100, 176, 176, 2041, 360, - /* 380 */ 185, 1367, 1589, 12, 1942, 9, 1742, 7, 226, 396, - /* 390 */ 392, 577, 1446, 113, 1365, 176, 112, 111, 110, 109, - /* 400 */ 108, 107, 106, 105, 104, 704, 122, 121, 120, 119, - /* 410 */ 118, 117, 116, 115, 114, 1960, 77, 1441, 363, 76, - /* 420 */ 1448, 1449, 131, 614, 1250, 1251, 155, 1611, 1911, 1373, - /* 430 */ 613, 39, 38, 37, 1391, 1744, 561, 556, 227, 36, - /* 440 */ 35, 1772, 597, 42, 40, 39, 38, 37, 1512, 1422, - /* 450 */ 1431, 1344, 1345, 1941, 44, 167, 403, 1976, 225, 1795, - /* 460 */ 100, 1943, 617, 1945, 1946, 612, 329, 607, 1368, 176, - /* 470 */ 1366, 1911, 2117, 1742, 2029, 1793, 704, 1843, 354, 2025, - /* 480 */ 1167, 174, 2037, 2038, 441, 129, 2042, 233, 1610, 2063, - /* 490 */ 1423, 1448, 1449, 1371, 1372, 568, 1421, 1424, 1425, 1426, - /* 500 */ 1427, 1428, 1429, 1430, 609, 605, 1439, 1440, 1442, 1443, - /* 510 */ 1444, 1445, 1447, 1450, 2, 1169, 651, 597, 82, 320, - /* 520 */ 1422, 1431, 530, 707, 528, 91, 83, 512, 511, 510, - /* 530 */ 565, 123, 1911, 642, 2097, 128, 506, 281, 502, 1368, - /* 540 */ 505, 1366, 189, 188, 9, 504, 509, 1735, 1742, 564, - /* 550 */ 173, 503, 166, 1720, 2098, 566, 11, 10, 697, 693, - /* 560 */ 689, 685, 279, 663, 1371, 1372, 80, 1421, 1424, 1425, - /* 570 */ 1426, 1427, 1428, 1429, 1430, 609, 605, 1439, 1440, 1442, - /* 580 */ 1443, 1444, 1445, 1447, 1450, 2, 43, 41, 2102, 1738, - /* 590 */ 133, 1930, 2097, 2000, 360, 211, 1367, 1392, 98, 1609, - /* 600 */ 1718, 272, 1925, 1582, 649, 1727, 1942, 1446, 2101, 1365, - /* 610 */ 162, 1608, 2098, 2099, 572, 476, 493, 489, 485, 481, - /* 620 */ 208, 2044, 577, 146, 145, 646, 645, 644, 143, 258, - /* 630 */ 1921, 1927, 1441, 1795, 593, 508, 507, 1960, 675, 673, - /* 640 */ 364, 607, 1729, 1911, 1373, 614, 1100, 2040, 1099, 1793, - /* 650 */ 1911, 1489, 613, 131, 155, 1911, 81, 43, 41, 206, - /* 660 */ 1367, 210, 651, 1745, 2102, 360, 58, 1367, 85, 44, - /* 670 */ 1725, 260, 58, 1365, 230, 1941, 583, 1101, 1446, 1976, - /* 680 */ 1365, 1394, 100, 1943, 617, 1945, 1946, 612, 1338, 607, - /* 690 */ 229, 704, 134, 608, 141, 2000, 2029, 1581, 1456, 2044, - /* 700 */ 354, 2025, 569, 1441, 1392, 1394, 1448, 1449, 1373, 1838, - /* 710 */ 597, 579, 171, 2037, 2038, 1373, 129, 2042, 545, 540, - /* 720 */ 187, 1607, 2097, 641, 404, 2039, 205, 199, 1606, 204, - /* 730 */ 597, 1392, 472, 1477, 584, 1422, 1431, 2103, 173, 29, - /* 740 */ 12, 1742, 2098, 566, 413, 36, 35, 1854, 197, 42, - /* 750 */ 40, 39, 38, 37, 1368, 704, 1366, 1575, 1605, 2069, - /* 760 */ 144, 1742, 704, 36, 35, 1911, 1602, 42, 40, 39, - /* 770 */ 38, 37, 1911, 1604, 599, 1395, 2001, 1448, 1449, 1371, - /* 780 */ 1372, 1898, 1421, 1424, 1425, 1426, 1427, 1428, 1429, 1430, - /* 790 */ 609, 605, 1439, 1440, 1442, 1443, 1444, 1445, 1447, 1450, - /* 800 */ 2, 317, 1911, 1390, 30, 1603, 1422, 1431, 597, 597, - /* 810 */ 435, 366, 51, 448, 1482, 176, 447, 1911, 1368, 155, - /* 820 */ 1366, 176, 427, 428, 257, 1368, 1655, 1366, 1744, 382, - /* 830 */ 1600, 419, 1599, 449, 1598, 573, 421, 1597, 1596, 1742, - /* 840 */ 1742, 2049, 1509, 1371, 1372, 1423, 1595, 1395, 257, 1911, - /* 850 */ 1371, 1372, 553, 1421, 1424, 1425, 1426, 1427, 1428, 1429, - /* 860 */ 1430, 609, 605, 1439, 1440, 1442, 1443, 1444, 1445, 1447, - /* 870 */ 1450, 2, 1423, 601, 1911, 2001, 1911, 333, 1911, 36, - /* 880 */ 35, 1911, 1911, 42, 40, 39, 38, 37, 1719, 409, - /* 890 */ 1911, 681, 680, 679, 678, 370, 1697, 677, 676, 135, - /* 900 */ 671, 670, 669, 668, 667, 666, 665, 148, 661, 660, - /* 910 */ 659, 369, 368, 656, 655, 654, 653, 652, 235, 445, - /* 920 */ 1594, 570, 440, 439, 438, 437, 434, 433, 432, 431, - /* 930 */ 430, 426, 425, 424, 423, 334, 416, 415, 414, 517, - /* 940 */ 411, 410, 331, 156, 643, 36, 35, 1786, 294, 42, - /* 950 */ 40, 39, 38, 37, 527, 1717, 597, 1593, 1942, 6, - /* 960 */ 597, 252, 292, 66, 1911, 31, 65, 1552, 224, 209, - /* 970 */ 474, 36, 35, 1395, 475, 42, 40, 39, 38, 37, - /* 980 */ 597, 1592, 597, 520, 193, 454, 452, 1742, 514, 1960, - /* 990 */ 182, 1742, 597, 223, 1739, 649, 139, 580, 664, 501, - /* 1000 */ 1712, 1911, 1911, 373, 613, 246, 541, 647, 1795, 1825, - /* 1010 */ 1786, 1742, 597, 1742, 146, 145, 646, 645, 644, 143, - /* 1020 */ 58, 500, 67, 1742, 1794, 1911, 581, 1941, 48, 64, - /* 1030 */ 3, 1976, 63, 1532, 100, 1943, 617, 1945, 1946, 612, - /* 1040 */ 137, 607, 125, 1742, 648, 545, 170, 1786, 2029, 2097, - /* 1050 */ 36, 35, 354, 2025, 42, 40, 39, 38, 37, 99, - /* 1060 */ 406, 1942, 649, 597, 2103, 173, 357, 356, 288, 2098, - /* 1070 */ 566, 1772, 75, 407, 2056, 216, 1381, 269, 214, 597, - /* 1080 */ 1376, 146, 145, 646, 645, 644, 143, 1446, 218, 1374, - /* 1090 */ 1375, 217, 1960, 592, 1742, 1645, 1638, 74, 73, 402, - /* 1100 */ 614, 597, 180, 220, 1942, 1911, 219, 613, 1961, 60, - /* 1110 */ 1742, 222, 1441, 239, 221, 594, 234, 513, 515, 1932, - /* 1120 */ 316, 604, 597, 390, 1373, 388, 384, 380, 377, 374, - /* 1130 */ 1941, 371, 1742, 597, 1976, 1960, 595, 100, 1943, 617, - /* 1140 */ 1945, 1946, 612, 614, 607, 597, 1636, 275, 1911, 2117, - /* 1150 */ 613, 2029, 45, 1742, 372, 354, 2025, 1584, 1585, 367, - /* 1160 */ 422, 1539, 1942, 1509, 1742, 241, 2091, 1934, 518, 176, - /* 1170 */ 50, 603, 262, 1941, 140, 544, 1742, 1976, 142, 1626, - /* 1180 */ 100, 1943, 617, 1945, 1946, 612, 1847, 607, 657, 11, - /* 1190 */ 10, 658, 2117, 1960, 2029, 144, 545, 60, 354, 2025, - /* 1200 */ 2097, 614, 2059, 45, 1314, 154, 1911, 96, 613, 2048, - /* 1210 */ 1148, 1783, 45, 1146, 621, 2103, 173, 93, 142, 533, - /* 1220 */ 2098, 566, 578, 1942, 267, 254, 589, 1379, 4, 251, - /* 1230 */ 271, 1941, 376, 1129, 1382, 1976, 1377, 1378, 100, 1943, - /* 1240 */ 617, 1945, 1946, 612, 381, 607, 144, 1200, 1, 1483, - /* 1250 */ 2004, 1942, 2029, 126, 1960, 1432, 354, 2025, 330, 1385, - /* 1260 */ 1387, 545, 614, 1467, 287, 2097, 1228, 1911, 1130, 613, - /* 1270 */ 1232, 605, 1439, 1440, 1442, 1443, 1444, 1445, 1331, 186, - /* 1280 */ 2103, 173, 1960, 142, 282, 2098, 566, 408, 1395, 1848, - /* 1290 */ 614, 412, 1941, 443, 1390, 1911, 1976, 613, 1239, 100, - /* 1300 */ 1943, 617, 1945, 1946, 612, 1237, 607, 417, 429, 450, - /* 1310 */ 1840, 2002, 1942, 2029, 436, 442, 444, 354, 2025, 451, - /* 1320 */ 1941, 190, 1396, 453, 1976, 455, 456, 100, 1943, 617, - /* 1330 */ 1945, 1946, 612, 465, 607, 147, 1398, 468, 469, 600, - /* 1340 */ 196, 2029, 198, 1960, 1397, 354, 2025, 470, 1399, 201, - /* 1350 */ 471, 614, 473, 203, 78, 79, 1911, 477, 613, 207, - /* 1360 */ 1103, 496, 494, 495, 498, 1942, 103, 1732, 535, 1888, - /* 1370 */ 319, 1887, 534, 213, 532, 1728, 283, 215, 149, 150, - /* 1380 */ 542, 1941, 2075, 228, 1730, 1976, 1726, 151, 101, 1943, - /* 1390 */ 617, 1945, 1946, 612, 231, 607, 1960, 152, 2074, 554, - /* 1400 */ 587, 5, 2029, 539, 614, 2051, 2028, 2025, 549, 1911, - /* 1410 */ 245, 613, 563, 548, 2060, 2070, 550, 551, 1942, 536, - /* 1420 */ 344, 557, 345, 547, 2120, 574, 237, 571, 163, 247, - /* 1430 */ 248, 240, 253, 250, 1941, 1509, 1394, 130, 1976, 249, - /* 1440 */ 582, 101, 1943, 617, 1945, 1946, 612, 2096, 607, 1960, - /* 1450 */ 2045, 348, 259, 284, 585, 2029, 586, 614, 1859, 602, - /* 1460 */ 2025, 1942, 1911, 1858, 613, 285, 1857, 350, 590, 88, - /* 1470 */ 591, 286, 90, 1743, 57, 92, 619, 2010, 289, 1787, - /* 1480 */ 700, 278, 321, 1713, 313, 701, 322, 615, 298, 703, - /* 1490 */ 49, 1976, 1960, 1905, 101, 1943, 617, 1945, 1946, 612, - /* 1500 */ 611, 607, 312, 1904, 291, 1911, 71, 613, 2029, 293, - /* 1510 */ 302, 1903, 324, 2025, 1902, 72, 1899, 378, 1942, 379, - /* 1520 */ 1359, 1360, 179, 1897, 383, 385, 386, 1896, 387, 389, - /* 1530 */ 1941, 1895, 1894, 391, 1976, 1942, 1893, 310, 1943, 617, - /* 1540 */ 1945, 1946, 612, 610, 607, 598, 1994, 393, 1334, 1960, - /* 1550 */ 395, 1333, 1870, 1869, 400, 1868, 401, 614, 1867, 1294, - /* 1560 */ 1833, 1942, 1911, 1832, 613, 1830, 1960, 191, 136, 1829, - /* 1570 */ 1828, 1831, 1827, 1826, 614, 1824, 1823, 1822, 184, 1911, - /* 1580 */ 418, 613, 1821, 420, 1820, 1819, 1818, 1941, 138, 1805, - /* 1590 */ 1804, 1976, 1960, 1817, 159, 1943, 617, 1945, 1946, 612, - /* 1600 */ 614, 607, 1816, 1815, 1941, 1911, 1814, 613, 1976, 1813, - /* 1610 */ 1812, 160, 1943, 617, 1945, 1946, 612, 1811, 607, 1810, - /* 1620 */ 1809, 1942, 1808, 1807, 1806, 1803, 1802, 1801, 1800, 1296, - /* 1630 */ 1941, 446, 1797, 1796, 1976, 546, 2066, 101, 1943, 617, - /* 1640 */ 1945, 1946, 612, 1942, 607, 1799, 1798, 1175, 1660, 1659, - /* 1650 */ 192, 2029, 1960, 1657, 1621, 194, 2026, 69, 168, 1620, - /* 1660 */ 614, 1089, 1931, 567, 2118, 1911, 1883, 613, 461, 1088, - /* 1670 */ 195, 1877, 1866, 70, 1960, 200, 463, 202, 1865, 1850, - /* 1680 */ 1721, 1656, 614, 1654, 1652, 478, 479, 1911, 483, 613, - /* 1690 */ 1941, 1650, 482, 486, 1976, 480, 1648, 159, 1943, 617, - /* 1700 */ 1945, 1946, 612, 1122, 607, 1635, 484, 1942, 487, 488, - /* 1710 */ 490, 491, 1941, 492, 1634, 1617, 1976, 1723, 212, 304, - /* 1720 */ 1943, 617, 1945, 1946, 612, 1244, 607, 1722, 1942, 1243, - /* 1730 */ 672, 674, 1166, 1165, 1164, 1163, 1160, 1159, 1960, 2067, - /* 1740 */ 1158, 59, 1646, 1157, 339, 1639, 614, 340, 1637, 1616, - /* 1750 */ 341, 1911, 1615, 613, 516, 519, 521, 1614, 523, 1960, - /* 1760 */ 525, 102, 1882, 562, 349, 1349, 1348, 614, 53, 1351, - /* 1770 */ 529, 1942, 1911, 1876, 613, 1340, 1941, 24, 153, 1864, - /* 1780 */ 1976, 537, 1862, 160, 1943, 617, 1945, 1946, 612, 2102, - /* 1790 */ 607, 17, 14, 244, 56, 243, 18, 1941, 538, 1554, - /* 1800 */ 1932, 1976, 1960, 61, 311, 1943, 617, 1945, 1946, 612, - /* 1810 */ 611, 607, 543, 28, 26, 1911, 232, 613, 19, 236, - /* 1820 */ 1569, 161, 1942, 1568, 342, 238, 346, 15, 1538, 242, - /* 1830 */ 27, 1573, 1531, 1574, 84, 1863, 2119, 1572, 1942, 1575, - /* 1840 */ 1941, 347, 256, 54, 1976, 55, 164, 310, 1943, 617, - /* 1850 */ 1945, 1946, 612, 1960, 607, 1861, 1995, 1506, 359, 1505, - /* 1860 */ 1860, 614, 20, 1849, 261, 263, 1911, 1536, 613, 1960, - /* 1870 */ 268, 86, 588, 87, 361, 270, 89, 614, 273, 10, - /* 1880 */ 21, 1468, 1911, 93, 613, 1979, 1383, 165, 1436, 1458, - /* 1890 */ 1434, 1941, 1942, 8, 177, 1976, 1457, 1414, 311, 1943, - /* 1900 */ 617, 1945, 1946, 612, 606, 607, 34, 1941, 1433, 13, - /* 1910 */ 22, 1976, 1406, 1942, 311, 1943, 617, 1945, 1946, 612, - /* 1920 */ 23, 607, 1229, 1960, 618, 620, 362, 622, 624, 1226, - /* 1930 */ 627, 614, 625, 630, 1223, 1217, 1911, 628, 613, 631, - /* 1940 */ 616, 1215, 633, 634, 1960, 1206, 1221, 1220, 1219, 1218, - /* 1950 */ 640, 94, 614, 276, 1238, 1234, 1942, 1911, 1120, 613, - /* 1960 */ 95, 531, 68, 650, 1154, 1976, 1153, 1152, 306, 1943, - /* 1970 */ 617, 1945, 1946, 612, 1151, 607, 1150, 1942, 1149, 1147, - /* 1980 */ 1173, 1145, 1941, 1144, 1143, 1141, 1976, 1960, 662, 295, - /* 1990 */ 1943, 617, 1945, 1946, 612, 614, 607, 277, 1140, 1139, - /* 2000 */ 1911, 1138, 613, 1137, 1136, 1135, 1170, 1168, 1960, 1132, - /* 2010 */ 1131, 1128, 1127, 1126, 1653, 1125, 614, 682, 1651, 683, - /* 2020 */ 1942, 1911, 684, 613, 686, 1941, 687, 1649, 690, 1976, - /* 2030 */ 1647, 688, 296, 1943, 617, 1945, 1946, 612, 1942, 607, - /* 2040 */ 692, 694, 691, 695, 696, 1633, 1941, 698, 1078, 1613, - /* 2050 */ 1976, 1960, 702, 297, 1943, 617, 1945, 1946, 612, 614, - /* 2060 */ 607, 280, 1369, 290, 1911, 705, 613, 1588, 706, 1960, - /* 2070 */ 1588, 1588, 1588, 1588, 1588, 1588, 1588, 614, 1588, 1588, - /* 2080 */ 1588, 1588, 1911, 1588, 613, 1588, 1588, 1588, 1588, 1941, - /* 2090 */ 1588, 1588, 1588, 1976, 1588, 1588, 303, 1943, 617, 1945, - /* 2100 */ 1946, 612, 1942, 607, 1588, 1588, 1588, 1941, 1588, 1588, - /* 2110 */ 1588, 1976, 1588, 1588, 307, 1943, 617, 1945, 1946, 612, - /* 2120 */ 1588, 607, 1588, 1942, 1588, 1588, 1588, 1588, 1588, 1588, - /* 2130 */ 1588, 1588, 1588, 1960, 1588, 1588, 1588, 1588, 1588, 1588, - /* 2140 */ 1588, 614, 1588, 1588, 1588, 1588, 1911, 1588, 613, 1588, - /* 2150 */ 1588, 1588, 1588, 1588, 1960, 1588, 1588, 1588, 1588, 1588, - /* 2160 */ 1588, 1588, 614, 1588, 1588, 1588, 1942, 1911, 1588, 613, - /* 2170 */ 1588, 1941, 1588, 1588, 1588, 1976, 1588, 1588, 299, 1943, - /* 2180 */ 617, 1945, 1946, 612, 1942, 607, 1588, 1588, 1588, 1588, - /* 2190 */ 1588, 1588, 1941, 1588, 1588, 1588, 1976, 1960, 1588, 308, - /* 2200 */ 1943, 617, 1945, 1946, 612, 614, 607, 1588, 1588, 1588, - /* 2210 */ 1911, 1588, 613, 1588, 1588, 1960, 1588, 1588, 1588, 1588, - /* 2220 */ 1588, 1588, 1588, 614, 1588, 1588, 1588, 1942, 1911, 1588, - /* 2230 */ 613, 1588, 1588, 1588, 1588, 1941, 1588, 1588, 1588, 1976, - /* 2240 */ 1588, 1588, 300, 1943, 617, 1945, 1946, 612, 1588, 607, - /* 2250 */ 1588, 1588, 1588, 1941, 1588, 1588, 1588, 1976, 1960, 1588, - /* 2260 */ 309, 1943, 617, 1945, 1946, 612, 614, 607, 1588, 1588, - /* 2270 */ 1942, 1911, 1588, 613, 1588, 1588, 1588, 1588, 1588, 1588, - /* 2280 */ 1588, 1588, 1588, 1588, 1588, 1588, 1588, 1942, 1588, 1588, - /* 2290 */ 1588, 1588, 1588, 1588, 1588, 1588, 1941, 1588, 1588, 1588, - /* 2300 */ 1976, 1960, 1588, 301, 1943, 617, 1945, 1946, 612, 614, - /* 2310 */ 607, 1588, 1588, 1942, 1911, 1588, 613, 1588, 1960, 1588, - /* 2320 */ 1588, 1588, 1588, 1588, 1588, 1588, 614, 1588, 1588, 1588, - /* 2330 */ 1588, 1911, 1588, 613, 1588, 1588, 1588, 1588, 1588, 1941, - /* 2340 */ 1588, 1588, 1588, 1976, 1960, 1588, 314, 1943, 617, 1945, - /* 2350 */ 1946, 612, 614, 607, 1588, 1588, 1941, 1911, 1588, 613, - /* 2360 */ 1976, 1588, 1588, 315, 1943, 617, 1945, 1946, 612, 1588, - /* 2370 */ 607, 1588, 1942, 1588, 1588, 1588, 1588, 1588, 1588, 1588, - /* 2380 */ 1588, 1588, 1941, 1588, 1588, 1588, 1976, 1588, 1588, 1954, - /* 2390 */ 1943, 617, 1945, 1946, 612, 1588, 607, 1588, 1588, 1588, - /* 2400 */ 1588, 1588, 1588, 1960, 1588, 1588, 1588, 1588, 1588, 1588, - /* 2410 */ 1588, 614, 1588, 1588, 1588, 1942, 1911, 1588, 613, 1588, - /* 2420 */ 1588, 1588, 1588, 1588, 1588, 1588, 1588, 1588, 1588, 1588, - /* 2430 */ 1588, 1588, 1588, 1942, 1588, 1588, 1588, 1588, 1588, 1588, - /* 2440 */ 1588, 1941, 1588, 1588, 1588, 1976, 1960, 1588, 1953, 1943, - /* 2450 */ 617, 1945, 1946, 612, 614, 607, 1588, 1588, 1588, 1911, - /* 2460 */ 1588, 613, 1588, 1588, 1960, 1588, 1588, 1588, 1588, 1588, - /* 2470 */ 1588, 1588, 614, 1588, 1588, 1588, 1588, 1911, 1588, 613, - /* 2480 */ 1588, 1588, 1588, 1588, 1941, 1588, 1588, 1588, 1976, 1588, - /* 2490 */ 1588, 1952, 1943, 617, 1945, 1946, 612, 1942, 607, 1588, - /* 2500 */ 1588, 1588, 1941, 1588, 1588, 1588, 1976, 1588, 1588, 326, - /* 2510 */ 1943, 617, 1945, 1946, 612, 1588, 607, 1588, 1942, 1588, - /* 2520 */ 1588, 1588, 1588, 1588, 1588, 1588, 1588, 1588, 1960, 1588, - /* 2530 */ 1588, 1588, 1588, 1588, 1588, 1588, 614, 1588, 1588, 1588, - /* 2540 */ 1588, 1911, 1588, 613, 1588, 1588, 1588, 1588, 1588, 1960, - /* 2550 */ 1588, 1588, 1588, 1588, 1588, 1588, 1588, 614, 1588, 1588, - /* 2560 */ 1588, 1942, 1911, 1588, 613, 1588, 1941, 1588, 1588, 1588, - /* 2570 */ 1976, 1588, 1588, 327, 1943, 617, 1945, 1946, 612, 1942, - /* 2580 */ 607, 1588, 1588, 1588, 1588, 1588, 1588, 1941, 1588, 1588, - /* 2590 */ 1588, 1976, 1960, 1588, 323, 1943, 617, 1945, 1946, 612, - /* 2600 */ 614, 607, 1588, 1588, 1588, 1911, 1588, 613, 1588, 1588, - /* 2610 */ 1960, 1588, 1588, 1588, 1588, 1588, 1588, 1588, 614, 1588, - /* 2620 */ 1588, 1588, 1942, 1911, 1588, 613, 1588, 1588, 1588, 1588, - /* 2630 */ 1941, 1588, 1588, 1588, 1976, 1588, 1588, 328, 1943, 617, - /* 2640 */ 1945, 1946, 612, 1588, 607, 1588, 1588, 1588, 615, 1588, - /* 2650 */ 1588, 1588, 1976, 1960, 1588, 306, 1943, 617, 1945, 1946, - /* 2660 */ 612, 614, 607, 1588, 1588, 1588, 1911, 1588, 613, 1588, - /* 2670 */ 1588, 1588, 1588, 1588, 1588, 1588, 1588, 1588, 1588, 1588, - /* 2680 */ 1588, 1588, 1588, 1588, 1588, 1588, 1588, 1588, 1588, 1588, - /* 2690 */ 1588, 1941, 1588, 1588, 1588, 1976, 1588, 1588, 305, 1943, - /* 2700 */ 617, 1945, 1946, 612, 1588, 607, + /* 0 */ 459, 353, 460, 1634, 566, 600, 578, 2114, 2109, 155, + /* 10 */ 1940, 2109, 43, 41, 1525, 39, 38, 37, 1753, 123, + /* 20 */ 361, 1936, 1375, 565, 173, 599, 498, 2113, 2110, 567, + /* 30 */ 1954, 2110, 2112, 1455, 1400, 1373, 1751, 131, 468, 406, + /* 40 */ 460, 1634, 36, 35, 1940, 586, 42, 40, 39, 38, + /* 50 */ 37, 1932, 1938, 344, 541, 1936, 167, 578, 1450, 465, + /* 60 */ 585, 1972, 610, 16, 366, 461, 1804, 1797, 1799, 581, + /* 70 */ 1381, 599, 1401, 330, 1922, 158, 616, 333, 1851, 319, + /* 80 */ 1705, 1972, 1802, 43, 41, 1932, 1938, 356, 131, 560, + /* 90 */ 477, 361, 475, 1375, 1860, 12, 610, 326, 172, 2049, + /* 100 */ 2050, 1953, 129, 2054, 1455, 1988, 1373, 2113, 100, 1955, + /* 110 */ 620, 1957, 1958, 615, 600, 610, 1106, 707, 1105, 654, + /* 120 */ 170, 458, 2041, 599, 463, 1640, 355, 2037, 123, 1450, + /* 130 */ 559, 210, 1457, 1458, 16, 503, 33, 275, 1484, 566, + /* 140 */ 175, 1381, 157, 2109, 1610, 1751, 46, 1107, 2067, 255, + /* 150 */ 2049, 577, 578, 124, 576, 1621, 1954, 2109, 565, 173, + /* 160 */ 600, 1431, 1440, 2110, 567, 578, 12, 42, 40, 39, + /* 170 */ 38, 37, 565, 173, 52, 1309, 1310, 2110, 567, 97, + /* 180 */ 1376, 586, 1374, 131, 1256, 1257, 467, 1972, 707, 463, + /* 190 */ 1640, 1751, 1402, 132, 1485, 614, 131, 561, 46, 1922, + /* 200 */ 1922, 1743, 616, 1457, 1458, 1379, 1380, 62, 1430, 1433, + /* 210 */ 1434, 1435, 1436, 1437, 1438, 1439, 612, 608, 1448, 1449, + /* 220 */ 1451, 1452, 1453, 1454, 1456, 1459, 2, 1953, 595, 58, + /* 230 */ 1860, 1988, 1431, 1440, 311, 1955, 620, 1957, 1958, 615, + /* 240 */ 613, 610, 601, 2006, 174, 2049, 2050, 1400, 129, 2054, + /* 250 */ 338, 1376, 2056, 1374, 1798, 1799, 580, 171, 2049, 2050, + /* 260 */ 556, 129, 2054, 1620, 58, 32, 359, 1479, 1480, 1481, + /* 270 */ 1482, 1483, 1487, 1488, 1489, 1490, 1379, 1380, 2053, 1430, + /* 280 */ 1433, 1434, 1435, 1436, 1437, 1438, 1439, 612, 608, 1448, + /* 290 */ 1449, 1451, 1452, 1453, 1454, 1456, 1459, 2, 58, 9, + /* 300 */ 43, 41, 1667, 47, 1551, 1596, 1847, 1922, 361, 1529, + /* 310 */ 1375, 339, 1729, 337, 336, 1400, 500, 181, 1954, 1619, + /* 320 */ 502, 1455, 58, 1373, 1213, 642, 641, 640, 1217, 639, + /* 330 */ 1219, 1220, 638, 1222, 635, 257, 1228, 632, 1230, 1231, + /* 340 */ 629, 626, 501, 562, 557, 258, 1450, 176, 399, 1972, + /* 350 */ 398, 16, 553, 1549, 1550, 1552, 1553, 617, 1381, 1106, + /* 360 */ 1173, 1105, 1922, 1922, 616, 569, 395, 513, 512, 511, + /* 370 */ 376, 43, 41, 1460, 477, 128, 507, 400, 176, 361, + /* 380 */ 506, 1375, 58, 12, 85, 505, 510, 397, 393, 1953, + /* 390 */ 1107, 504, 1455, 1988, 1373, 1175, 100, 1955, 620, 1957, + /* 400 */ 1958, 615, 1954, 610, 80, 707, 134, 1618, 141, 2012, + /* 410 */ 2041, 600, 546, 176, 355, 2037, 2109, 1450, 127, 546, + /* 420 */ 1457, 1458, 169, 2109, 1401, 178, 226, 1746, 573, 1381, + /* 430 */ 1617, 2115, 173, 1972, 1599, 1791, 2110, 567, 2115, 173, + /* 440 */ 1375, 617, 1751, 2110, 567, 167, 1922, 176, 616, 1431, + /* 450 */ 1440, 1922, 176, 1373, 44, 113, 1432, 587, 112, 111, + /* 460 */ 110, 109, 108, 107, 106, 105, 104, 1852, 1376, 352, + /* 470 */ 1374, 176, 1864, 1953, 1922, 227, 707, 1988, 1781, 1804, + /* 480 */ 160, 1955, 620, 1957, 1958, 615, 354, 610, 1381, 1352, + /* 490 */ 1353, 1457, 1458, 1379, 1380, 1802, 1430, 1433, 1434, 1435, + /* 500 */ 1436, 1437, 1438, 1439, 612, 608, 1448, 1449, 1451, 1452, + /* 510 */ 1453, 1454, 1456, 1459, 2, 509, 508, 678, 676, 113, + /* 520 */ 1431, 1440, 112, 111, 110, 109, 108, 107, 106, 105, + /* 530 */ 104, 176, 568, 2130, 364, 707, 513, 512, 511, 1376, + /* 540 */ 367, 1374, 155, 1804, 128, 507, 1465, 1909, 155, 506, + /* 550 */ 365, 1753, 1400, 1403, 505, 510, 1728, 1753, 1954, 1802, + /* 560 */ 504, 266, 267, 1400, 1379, 1380, 265, 1430, 1433, 1434, + /* 570 */ 1435, 1436, 1437, 1438, 1439, 612, 608, 1448, 1449, 1451, + /* 580 */ 1452, 1453, 1454, 1456, 1459, 2, 43, 41, 1598, 1972, + /* 590 */ 1616, 600, 185, 527, 361, 383, 1375, 581, 1376, 1727, + /* 600 */ 1374, 1615, 1922, 1399, 616, 404, 525, 1455, 523, 1373, + /* 610 */ 1742, 600, 122, 121, 120, 119, 118, 117, 116, 115, + /* 620 */ 114, 1936, 1751, 1379, 1380, 405, 11, 10, 77, 1953, + /* 630 */ 1614, 76, 1450, 1988, 1922, 1613, 100, 1955, 620, 1957, + /* 640 */ 1958, 615, 1751, 610, 1381, 1922, 91, 80, 170, 574, + /* 650 */ 2041, 1932, 1938, 133, 355, 2037, 2012, 43, 41, 600, + /* 660 */ 518, 654, 610, 652, 2114, 361, 1954, 1375, 1744, 44, + /* 670 */ 1747, 442, 1612, 414, 1922, 528, 2068, 587, 1455, 1922, + /* 680 */ 1373, 1402, 146, 145, 649, 648, 647, 143, 29, 224, + /* 690 */ 1751, 707, 1865, 1432, 36, 35, 182, 1972, 42, 40, + /* 700 */ 39, 38, 37, 1450, 521, 617, 1457, 1458, 1609, 515, + /* 710 */ 1922, 1608, 616, 2056, 223, 1381, 1922, 1607, 2114, 36, + /* 720 */ 35, 1498, 2109, 42, 40, 39, 38, 37, 1522, 189, + /* 730 */ 188, 1403, 1641, 1486, 2056, 1431, 1440, 1953, 2113, 2052, + /* 740 */ 12, 1988, 2110, 2111, 101, 1955, 620, 1957, 1958, 615, + /* 750 */ 64, 610, 1922, 63, 1376, 1922, 1374, 1584, 2041, 31, + /* 760 */ 2051, 1922, 707, 2038, 1606, 36, 35, 1605, 225, 42, + /* 770 */ 40, 39, 38, 37, 9, 1604, 1087, 1457, 1458, 1379, + /* 780 */ 1380, 702, 1430, 1433, 1434, 1435, 1436, 1437, 1438, 1439, + /* 790 */ 612, 608, 1448, 1449, 1451, 1452, 1453, 1454, 1456, 1459, + /* 800 */ 2, 318, 1384, 1398, 30, 1603, 1431, 1440, 1922, 710, + /* 810 */ 436, 1922, 155, 449, 1491, 1089, 448, 1092, 1093, 1922, + /* 820 */ 602, 1754, 2013, 282, 257, 1376, 1664, 1374, 82, 321, + /* 830 */ 1847, 420, 531, 450, 529, 9, 422, 7, 166, 1834, + /* 840 */ 604, 183, 2013, 6, 700, 696, 692, 688, 280, 1922, + /* 850 */ 1379, 1380, 1726, 1430, 1433, 1434, 1435, 1436, 1437, 1438, + /* 860 */ 1439, 612, 608, 1448, 1449, 1451, 1452, 1453, 1454, 1456, + /* 870 */ 1459, 2, 1804, 1403, 235, 36, 35, 334, 1400, 42, + /* 880 */ 40, 39, 38, 37, 98, 1847, 607, 273, 1803, 410, + /* 890 */ 645, 684, 683, 682, 681, 371, 187, 680, 679, 135, + /* 900 */ 674, 673, 672, 671, 670, 669, 668, 148, 664, 663, + /* 910 */ 662, 370, 369, 659, 658, 657, 656, 655, 646, 446, + /* 920 */ 596, 1795, 441, 440, 439, 438, 435, 434, 433, 432, + /* 930 */ 431, 427, 426, 425, 424, 335, 417, 416, 415, 1381, + /* 940 */ 412, 411, 332, 156, 1092, 1093, 36, 35, 295, 1387, + /* 950 */ 42, 40, 39, 38, 37, 1602, 1601, 260, 1954, 652, + /* 960 */ 666, 650, 293, 66, 1795, 289, 65, 651, 1781, 1521, + /* 970 */ 1795, 667, 1740, 1721, 1346, 48, 229, 3, 146, 145, + /* 980 */ 649, 648, 647, 143, 193, 455, 453, 36, 35, 1972, + /* 990 */ 423, 42, 40, 39, 38, 37, 502, 617, 1943, 1922, + /* 1000 */ 1922, 600, 1922, 652, 616, 1736, 36, 35, 2061, 1518, + /* 1010 */ 42, 40, 39, 38, 37, 428, 234, 233, 501, 1432, + /* 1020 */ 58, 600, 146, 145, 649, 648, 647, 143, 1476, 1953, + /* 1030 */ 154, 600, 1751, 1988, 1561, 429, 100, 1955, 620, 1957, + /* 1040 */ 1958, 615, 25, 610, 144, 476, 1945, 1518, 2129, 137, + /* 1050 */ 2041, 125, 1751, 407, 355, 2037, 83, 1738, 67, 99, + /* 1060 */ 600, 1954, 1751, 36, 35, 2075, 408, 42, 40, 39, + /* 1070 */ 38, 37, 36, 35, 1748, 1734, 42, 40, 39, 38, + /* 1080 */ 37, 600, 216, 218, 570, 214, 217, 600, 1654, 1383, + /* 1090 */ 220, 1751, 1972, 219, 1647, 139, 51, 74, 73, 403, + /* 1100 */ 617, 542, 180, 600, 60, 1922, 1954, 616, 75, 1645, + /* 1110 */ 514, 222, 1751, 1941, 221, 239, 516, 582, 1751, 45, + /* 1120 */ 317, 1593, 1594, 391, 1936, 389, 385, 381, 378, 375, + /* 1130 */ 263, 519, 1953, 600, 1751, 600, 1988, 1972, 1611, 100, + /* 1140 */ 1955, 620, 1957, 1958, 615, 617, 610, 270, 140, 597, + /* 1150 */ 1922, 2129, 616, 2041, 1932, 1938, 1548, 355, 2037, 1706, + /* 1160 */ 1541, 600, 600, 230, 1751, 610, 1751, 241, 2103, 176, + /* 1170 */ 142, 1322, 611, 50, 144, 598, 276, 1953, 545, 1954, + /* 1180 */ 60, 1988, 268, 252, 100, 1955, 620, 1957, 1958, 615, + /* 1190 */ 660, 610, 1751, 1751, 358, 357, 2129, 600, 2041, 45, + /* 1200 */ 592, 45, 355, 2037, 1389, 11, 10, 661, 644, 96, + /* 1210 */ 1972, 368, 1154, 2060, 2081, 1455, 624, 1382, 617, 93, + /* 1220 */ 211, 584, 272, 1922, 374, 616, 1206, 1591, 1751, 1152, + /* 1230 */ 209, 554, 1492, 246, 1954, 162, 1386, 142, 1973, 372, + /* 1240 */ 1450, 494, 490, 486, 482, 208, 144, 1856, 1635, 126, + /* 1250 */ 1953, 1441, 1381, 288, 1988, 1792, 142, 100, 1955, 620, + /* 1260 */ 1957, 1958, 615, 546, 610, 1972, 546, 2109, 1234, 2016, + /* 1270 */ 2109, 2041, 1135, 617, 579, 355, 2037, 2071, 1922, 251, + /* 1280 */ 616, 81, 2115, 173, 206, 2115, 173, 2110, 567, 1238, + /* 1290 */ 2110, 567, 254, 1, 373, 4, 382, 331, 1245, 606, + /* 1300 */ 377, 1243, 1339, 571, 283, 1953, 186, 1136, 147, 1988, + /* 1310 */ 409, 1403, 100, 1955, 620, 1957, 1958, 615, 1857, 610, + /* 1320 */ 413, 1590, 444, 418, 2014, 1398, 2041, 430, 1849, 437, + /* 1330 */ 355, 2037, 443, 451, 452, 445, 546, 190, 454, 456, + /* 1340 */ 2109, 1404, 457, 466, 1406, 470, 1954, 534, 469, 1405, + /* 1350 */ 196, 205, 199, 198, 204, 2115, 173, 473, 471, 1407, + /* 1360 */ 2110, 567, 1390, 472, 1385, 201, 474, 203, 78, 79, + /* 1370 */ 478, 1109, 207, 197, 495, 496, 1954, 1972, 499, 497, + /* 1380 */ 103, 1741, 1899, 213, 320, 617, 1898, 1393, 1395, 546, + /* 1390 */ 1922, 1737, 616, 2109, 533, 284, 535, 215, 149, 608, + /* 1400 */ 1448, 1449, 1451, 1452, 1453, 1454, 150, 1972, 2115, 173, + /* 1410 */ 228, 536, 1739, 2110, 567, 617, 540, 1953, 1735, 151, + /* 1420 */ 1922, 1988, 616, 152, 100, 1955, 620, 1957, 1958, 615, + /* 1430 */ 231, 610, 1954, 543, 550, 537, 603, 2072, 2041, 590, + /* 1440 */ 2082, 555, 355, 2037, 5, 552, 345, 1953, 2087, 558, + /* 1450 */ 237, 1988, 1954, 240, 101, 1955, 620, 1957, 1958, 615, + /* 1460 */ 2063, 610, 2086, 1972, 564, 548, 551, 549, 2041, 572, + /* 1470 */ 250, 617, 2040, 2037, 247, 245, 1922, 346, 616, 575, + /* 1480 */ 130, 248, 1518, 1972, 249, 163, 1402, 2057, 349, 583, + /* 1490 */ 259, 617, 1408, 1861, 285, 593, 1922, 588, 616, 286, + /* 1500 */ 589, 1870, 1869, 1953, 1868, 2108, 351, 1988, 88, 1752, + /* 1510 */ 101, 1955, 620, 1957, 1958, 615, 287, 610, 90, 594, + /* 1520 */ 1954, 253, 57, 618, 2041, 2022, 2132, 1988, 605, 2037, + /* 1530 */ 101, 1955, 620, 1957, 1958, 615, 1954, 610, 92, 622, + /* 1540 */ 279, 703, 1796, 1722, 2041, 704, 290, 706, 325, 2037, + /* 1550 */ 49, 1972, 314, 322, 323, 294, 1916, 1915, 71, 617, + /* 1560 */ 72, 292, 1914, 1913, 1922, 1910, 616, 1972, 379, 299, + /* 1570 */ 1367, 313, 303, 380, 1368, 617, 179, 1908, 384, 386, + /* 1580 */ 1922, 387, 616, 388, 1907, 390, 1906, 392, 1905, 394, + /* 1590 */ 1904, 1953, 1342, 396, 1341, 1988, 1881, 1954, 159, 1955, + /* 1600 */ 620, 1957, 1958, 615, 1880, 610, 401, 1953, 402, 1879, + /* 1610 */ 1878, 1988, 1842, 1300, 159, 1955, 620, 1957, 1958, 615, + /* 1620 */ 1841, 610, 1839, 136, 1838, 1837, 1840, 1836, 1972, 184, + /* 1630 */ 419, 1830, 421, 1829, 1828, 1827, 617, 1835, 1833, 547, + /* 1640 */ 2078, 1922, 1954, 616, 1832, 1831, 1826, 1825, 1824, 1823, + /* 1650 */ 1822, 1821, 1820, 1819, 1818, 1817, 2079, 1816, 1815, 138, + /* 1660 */ 1814, 1813, 1812, 1811, 1810, 1302, 1809, 1808, 1953, 1807, + /* 1670 */ 1806, 447, 1988, 1972, 1181, 305, 1955, 620, 1957, 1958, + /* 1680 */ 615, 617, 610, 1805, 1669, 1668, 1922, 1666, 616, 1630, + /* 1690 */ 191, 1095, 1094, 1629, 192, 1894, 1888, 1877, 194, 202, + /* 1700 */ 1876, 1859, 1730, 1954, 69, 1128, 1942, 1665, 1663, 1661, + /* 1710 */ 1659, 70, 168, 1953, 479, 195, 1657, 1988, 462, 563, + /* 1720 */ 160, 1955, 620, 1957, 1958, 615, 1954, 610, 464, 200, + /* 1730 */ 480, 481, 1644, 483, 1972, 1643, 484, 1626, 485, 350, + /* 1740 */ 487, 491, 617, 489, 1732, 1249, 59, 1922, 1731, 616, + /* 1750 */ 1250, 488, 493, 1172, 1171, 1170, 1169, 1972, 675, 492, + /* 1760 */ 1166, 677, 1164, 1165, 1163, 614, 1655, 340, 1648, 341, + /* 1770 */ 1922, 1646, 616, 2131, 1953, 212, 517, 342, 1988, 1625, + /* 1780 */ 1624, 312, 1955, 620, 1957, 1958, 615, 1954, 610, 520, + /* 1790 */ 1623, 522, 524, 102, 526, 1357, 1356, 1953, 530, 1893, + /* 1800 */ 1348, 1988, 1887, 53, 311, 1955, 620, 1957, 1958, 615, + /* 1810 */ 1875, 610, 1873, 2007, 538, 1874, 2114, 1954, 1972, 17, + /* 1820 */ 1359, 14, 56, 360, 244, 24, 617, 1563, 26, 236, + /* 1830 */ 243, 1922, 238, 616, 1547, 1540, 161, 242, 1943, 28, + /* 1840 */ 1954, 27, 18, 539, 84, 61, 1583, 1584, 1972, 19, + /* 1850 */ 15, 232, 1578, 362, 343, 1577, 617, 347, 1953, 153, + /* 1860 */ 1582, 1922, 1988, 616, 1581, 312, 1955, 620, 1957, 1958, + /* 1870 */ 615, 1972, 610, 348, 256, 55, 1872, 1515, 1514, 617, + /* 1880 */ 164, 544, 1871, 261, 1922, 1954, 616, 1858, 1953, 20, + /* 1890 */ 87, 264, 1988, 262, 1545, 312, 1955, 620, 1957, 1958, + /* 1900 */ 615, 1954, 610, 269, 86, 93, 89, 274, 21, 10, + /* 1910 */ 1391, 532, 1445, 1991, 609, 1988, 1972, 271, 307, 1955, + /* 1920 */ 620, 1957, 1958, 615, 617, 610, 1443, 34, 591, 1922, + /* 1930 */ 1442, 616, 1972, 165, 13, 22, 54, 177, 1423, 1415, + /* 1940 */ 617, 23, 625, 621, 1235, 1922, 623, 616, 363, 1467, + /* 1950 */ 1232, 628, 627, 630, 1954, 1229, 1953, 1477, 631, 633, + /* 1960 */ 1988, 1223, 634, 296, 1955, 620, 1957, 1958, 615, 1221, + /* 1970 */ 610, 619, 1953, 636, 637, 1212, 1988, 1227, 643, 297, + /* 1980 */ 1955, 620, 1957, 1958, 615, 1972, 610, 8, 1226, 1225, + /* 1990 */ 1466, 1224, 94, 617, 277, 95, 1244, 1240, 1922, 1954, + /* 2000 */ 616, 68, 1160, 1126, 653, 1159, 1158, 1157, 1156, 1155, + /* 2010 */ 1179, 1153, 1151, 1150, 1149, 665, 1147, 1146, 1145, 1144, + /* 2020 */ 1143, 1142, 1141, 1174, 278, 1953, 1176, 1138, 1137, 1988, + /* 2030 */ 1972, 1134, 298, 1955, 620, 1957, 1958, 615, 617, 610, + /* 2040 */ 1133, 1132, 1131, 1922, 1662, 616, 685, 686, 687, 1660, + /* 2050 */ 689, 690, 1954, 691, 1658, 693, 694, 695, 1656, 697, + /* 2060 */ 698, 699, 1642, 701, 1084, 1622, 709, 281, 1954, 705, + /* 2070 */ 1953, 1597, 1377, 291, 1988, 1597, 708, 304, 1955, 620, + /* 2080 */ 1957, 1958, 615, 1972, 610, 1597, 1597, 1597, 1597, 1597, + /* 2090 */ 1597, 617, 1597, 1597, 1597, 1597, 1922, 1597, 616, 1972, + /* 2100 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 617, 1597, 1597, + /* 2110 */ 1597, 1597, 1922, 1954, 616, 1597, 1597, 1597, 1597, 1597, + /* 2120 */ 1597, 1597, 1597, 1953, 1597, 1597, 1597, 1988, 1597, 1597, + /* 2130 */ 308, 1955, 620, 1957, 1958, 615, 1597, 610, 1597, 1953, + /* 2140 */ 1597, 1597, 1597, 1988, 1972, 1597, 300, 1955, 620, 1957, + /* 2150 */ 1958, 615, 617, 610, 1597, 1597, 1597, 1922, 1597, 616, + /* 2160 */ 1597, 1597, 1597, 1597, 1597, 1597, 1954, 1597, 1597, 1597, + /* 2170 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, + /* 2180 */ 1597, 1597, 1954, 1597, 1953, 1597, 1597, 1597, 1988, 1597, + /* 2190 */ 1597, 309, 1955, 620, 1957, 1958, 615, 1972, 610, 1597, + /* 2200 */ 1597, 1597, 1597, 1597, 1597, 617, 1597, 1597, 1597, 1597, + /* 2210 */ 1922, 1597, 616, 1972, 1597, 1597, 1597, 1597, 1597, 1597, + /* 2220 */ 1597, 617, 1597, 1597, 1597, 1597, 1922, 1954, 616, 1597, + /* 2230 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1953, 1597, 1597, + /* 2240 */ 1597, 1988, 1597, 1597, 301, 1955, 620, 1957, 1958, 615, + /* 2250 */ 1954, 610, 1597, 1953, 1597, 1597, 1597, 1988, 1972, 1597, + /* 2260 */ 310, 1955, 620, 1957, 1958, 615, 617, 610, 1597, 1597, + /* 2270 */ 1597, 1922, 1597, 616, 1597, 1597, 1597, 1597, 1597, 1597, + /* 2280 */ 1954, 1972, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 617, + /* 2290 */ 1597, 1597, 1597, 1597, 1922, 1597, 616, 1597, 1953, 1597, + /* 2300 */ 1597, 1597, 1988, 1597, 1597, 302, 1955, 620, 1957, 1958, + /* 2310 */ 615, 1972, 610, 1597, 1597, 1597, 1597, 1597, 1597, 617, + /* 2320 */ 1597, 1953, 1597, 1597, 1922, 1988, 616, 1597, 315, 1955, + /* 2330 */ 620, 1957, 1958, 615, 1597, 610, 1597, 1597, 1597, 1597, + /* 2340 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, + /* 2350 */ 1597, 1953, 1597, 1597, 1597, 1988, 1954, 1597, 316, 1955, + /* 2360 */ 620, 1957, 1958, 615, 1597, 610, 1597, 1597, 1597, 1597, + /* 2370 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1954, 1597, + /* 2380 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1972, 1597, 1597, + /* 2390 */ 1597, 1597, 1597, 1597, 1597, 617, 1597, 1597, 1597, 1597, + /* 2400 */ 1922, 1597, 616, 1597, 1597, 1597, 1597, 1597, 1597, 1972, + /* 2410 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 617, 1597, 1597, + /* 2420 */ 1597, 1597, 1922, 1597, 616, 1597, 1597, 1953, 1597, 1597, + /* 2430 */ 1597, 1988, 1597, 1954, 1966, 1955, 620, 1957, 1958, 615, + /* 2440 */ 1597, 610, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1953, + /* 2450 */ 1597, 1597, 1597, 1988, 1597, 1597, 1965, 1955, 620, 1957, + /* 2460 */ 1958, 615, 1597, 610, 1972, 1597, 1597, 1597, 1597, 1597, + /* 2470 */ 1597, 1597, 617, 1597, 1597, 1597, 1597, 1922, 1954, 616, + /* 2480 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, + /* 2490 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, + /* 2500 */ 1597, 1597, 1597, 1597, 1953, 1597, 1597, 1597, 1988, 1972, + /* 2510 */ 1597, 1964, 1955, 620, 1957, 1958, 615, 617, 610, 1597, + /* 2520 */ 1597, 1597, 1922, 1954, 616, 1597, 1597, 1597, 1597, 1597, + /* 2530 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1954, + /* 2540 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1953, + /* 2550 */ 1597, 1597, 1597, 1988, 1972, 1597, 327, 1955, 620, 1957, + /* 2560 */ 1958, 615, 617, 610, 1597, 1597, 1597, 1922, 1597, 616, + /* 2570 */ 1972, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 617, 1597, + /* 2580 */ 1597, 1597, 1597, 1922, 1954, 616, 1597, 1597, 1597, 1597, + /* 2590 */ 1597, 1597, 1597, 1597, 1953, 1597, 1597, 1597, 1988, 1597, + /* 2600 */ 1597, 328, 1955, 620, 1957, 1958, 615, 1954, 610, 1597, + /* 2610 */ 1953, 1597, 1597, 1597, 1988, 1972, 1597, 324, 1955, 620, + /* 2620 */ 1957, 1958, 615, 617, 610, 1597, 1597, 1597, 1922, 1597, + /* 2630 */ 616, 1597, 1597, 1597, 1597, 1597, 1597, 1954, 1972, 1597, + /* 2640 */ 1597, 1597, 1597, 1597, 1597, 1597, 617, 1597, 1597, 1597, + /* 2650 */ 1597, 1922, 1597, 616, 1597, 1953, 1597, 1597, 1597, 1988, + /* 2660 */ 1597, 1597, 329, 1955, 620, 1957, 1958, 615, 1972, 610, + /* 2670 */ 1597, 1597, 1597, 1597, 1597, 1597, 617, 1597, 618, 1597, + /* 2680 */ 1597, 1922, 1988, 616, 1597, 307, 1955, 620, 1957, 1958, + /* 2690 */ 615, 1597, 610, 1597, 1597, 1597, 1597, 1597, 1597, 1597, + /* 2700 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1953, 1597, + /* 2710 */ 1597, 1597, 1988, 1597, 1597, 306, 1955, 620, 1957, 1958, + /* 2720 */ 615, 1597, 610, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 329, 356, 331, 332, 364, 358, 322, 329, 363, 331, - /* 10 */ 332, 0, 12, 13, 14, 375, 369, 372, 357, 385, - /* 20 */ 20, 4, 22, 8, 9, 4, 356, 12, 13, 14, - /* 30 */ 15, 16, 356, 33, 364, 35, 0, 12, 13, 14, - /* 40 */ 15, 16, 8, 9, 397, 398, 12, 13, 14, 15, - /* 50 */ 16, 416, 417, 377, 378, 408, 14, 333, 58, 44, - /* 60 */ 49, 427, 20, 63, 43, 431, 45, 46, 333, 385, - /* 70 */ 70, 367, 20, 403, 370, 371, 333, 325, 337, 70, - /* 80 */ 446, 447, 347, 12, 13, 451, 452, 358, 364, 354, - /* 90 */ 347, 20, 351, 22, 20, 95, 20, 63, 369, 364, - /* 100 */ 359, 65, 66, 67, 33, 348, 35, 364, 356, 73, - /* 110 */ 74, 427, 95, 356, 78, 431, 364, 117, 20, 83, - /* 120 */ 84, 369, 365, 371, 333, 89, 397, 398, 399, 58, - /* 130 */ 446, 447, 132, 133, 63, 451, 452, 408, 104, 330, - /* 140 */ 340, 70, 333, 334, 333, 345, 394, 423, 424, 425, - /* 150 */ 398, 427, 428, 401, 402, 403, 404, 405, 406, 427, - /* 160 */ 408, 161, 162, 431, 373, 413, 95, 415, 62, 95, - /* 170 */ 330, 419, 420, 333, 334, 364, 126, 127, 446, 447, - /* 180 */ 180, 131, 182, 451, 452, 433, 37, 21, 117, 20, - /* 190 */ 358, 8, 9, 441, 160, 12, 13, 14, 15, 16, - /* 200 */ 34, 369, 36, 132, 133, 205, 206, 4, 208, 209, + /* 0 */ 329, 348, 331, 332, 429, 333, 333, 429, 433, 356, + /* 10 */ 358, 433, 12, 13, 14, 14, 15, 16, 365, 347, + /* 20 */ 20, 369, 22, 448, 449, 20, 354, 449, 453, 454, + /* 30 */ 325, 453, 454, 33, 20, 35, 364, 364, 329, 333, + /* 40 */ 331, 332, 8, 9, 358, 333, 12, 13, 14, 15, + /* 50 */ 16, 399, 400, 401, 391, 369, 356, 333, 58, 14, + /* 60 */ 20, 356, 410, 63, 367, 20, 356, 370, 371, 364, + /* 70 */ 70, 20, 20, 363, 369, 340, 371, 377, 378, 373, + /* 80 */ 345, 356, 372, 12, 13, 399, 400, 401, 364, 364, + /* 90 */ 62, 20, 380, 22, 382, 95, 410, 63, 425, 426, + /* 100 */ 427, 396, 429, 430, 33, 400, 35, 3, 403, 404, + /* 110 */ 405, 406, 407, 408, 333, 410, 20, 117, 22, 62, + /* 120 */ 415, 330, 417, 20, 333, 334, 421, 422, 347, 58, + /* 130 */ 405, 35, 132, 133, 63, 354, 418, 419, 104, 429, + /* 140 */ 435, 70, 324, 433, 326, 364, 95, 51, 443, 425, + /* 150 */ 426, 427, 333, 429, 430, 325, 325, 433, 448, 449, + /* 160 */ 333, 161, 162, 453, 454, 333, 95, 12, 13, 14, + /* 170 */ 15, 16, 448, 449, 347, 161, 162, 453, 454, 337, + /* 180 */ 180, 333, 182, 364, 132, 133, 330, 356, 117, 333, + /* 190 */ 334, 364, 20, 351, 160, 364, 364, 20, 95, 369, + /* 200 */ 369, 359, 371, 132, 133, 205, 206, 4, 208, 209, /* 210 */ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, - /* 220 */ 220, 221, 222, 223, 224, 225, 226, 95, 95, 397, - /* 230 */ 398, 399, 161, 162, 423, 424, 425, 3, 427, 428, - /* 240 */ 408, 339, 431, 370, 371, 20, 95, 98, 20, 100, - /* 250 */ 101, 180, 103, 182, 205, 353, 107, 446, 447, 161, - /* 260 */ 162, 244, 451, 452, 362, 231, 232, 233, 234, 235, - /* 270 */ 236, 237, 238, 239, 240, 241, 205, 206, 129, 208, + /* 220 */ 220, 221, 222, 223, 224, 225, 226, 396, 380, 95, + /* 230 */ 382, 400, 161, 162, 403, 404, 405, 406, 407, 408, + /* 240 */ 409, 410, 411, 412, 425, 426, 427, 20, 429, 430, + /* 250 */ 37, 180, 402, 182, 370, 371, 424, 425, 426, 427, + /* 260 */ 166, 429, 430, 325, 95, 231, 232, 233, 234, 235, + /* 270 */ 236, 237, 238, 239, 240, 241, 205, 206, 428, 208, /* 280 */ 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, - /* 290 */ 219, 220, 221, 222, 223, 224, 225, 226, 325, 228, - /* 300 */ 12, 13, 253, 254, 255, 256, 257, 364, 20, 371, - /* 310 */ 22, 179, 20, 181, 20, 324, 22, 326, 375, 381, - /* 320 */ 95, 33, 384, 35, 108, 109, 110, 111, 112, 113, - /* 330 */ 114, 115, 116, 117, 118, 0, 120, 121, 122, 123, - /* 340 */ 124, 125, 369, 14, 355, 51, 58, 45, 46, 20, - /* 350 */ 427, 63, 400, 166, 431, 333, 21, 368, 70, 24, - /* 360 */ 25, 26, 27, 28, 29, 30, 31, 32, 175, 347, - /* 370 */ 447, 12, 13, 14, 451, 452, 244, 244, 426, 20, - /* 380 */ 58, 22, 0, 95, 325, 228, 364, 230, 126, 196, - /* 390 */ 197, 333, 33, 21, 35, 244, 24, 25, 26, 27, - /* 400 */ 28, 29, 30, 31, 32, 117, 24, 25, 26, 27, - /* 410 */ 28, 29, 30, 31, 32, 356, 94, 58, 348, 97, - /* 420 */ 132, 133, 364, 364, 132, 133, 356, 325, 369, 70, - /* 430 */ 371, 14, 15, 16, 20, 365, 249, 250, 349, 8, - /* 440 */ 9, 352, 333, 12, 13, 14, 15, 16, 245, 161, - /* 450 */ 162, 189, 190, 394, 95, 356, 347, 398, 127, 356, - /* 460 */ 401, 402, 403, 404, 405, 406, 363, 408, 180, 244, - /* 470 */ 182, 369, 413, 364, 415, 372, 117, 378, 419, 420, - /* 480 */ 35, 423, 424, 425, 79, 427, 428, 58, 325, 430, - /* 490 */ 161, 132, 133, 205, 206, 261, 208, 209, 210, 211, + /* 290 */ 219, 220, 221, 222, 223, 224, 225, 226, 95, 228, + /* 300 */ 12, 13, 0, 95, 205, 322, 364, 369, 20, 14, + /* 310 */ 22, 98, 0, 100, 101, 20, 103, 375, 325, 325, + /* 320 */ 107, 33, 95, 35, 108, 109, 110, 111, 112, 113, + /* 330 */ 114, 115, 116, 117, 118, 163, 120, 121, 122, 123, + /* 340 */ 124, 125, 129, 249, 250, 58, 58, 244, 179, 356, + /* 350 */ 181, 63, 253, 254, 255, 256, 257, 364, 70, 20, + /* 360 */ 35, 22, 369, 369, 371, 261, 175, 65, 66, 67, + /* 370 */ 387, 12, 13, 14, 62, 73, 74, 387, 244, 20, + /* 380 */ 78, 22, 95, 95, 97, 83, 84, 196, 197, 396, + /* 390 */ 51, 89, 33, 400, 35, 70, 403, 404, 405, 406, + /* 400 */ 407, 408, 325, 410, 339, 117, 413, 325, 415, 416, + /* 410 */ 417, 333, 429, 244, 421, 422, 433, 58, 353, 429, + /* 420 */ 132, 133, 355, 433, 20, 347, 126, 362, 44, 70, + /* 430 */ 325, 448, 449, 356, 0, 368, 453, 454, 448, 449, + /* 440 */ 22, 364, 364, 453, 454, 356, 369, 244, 371, 161, + /* 450 */ 162, 369, 244, 35, 95, 21, 161, 371, 24, 25, + /* 460 */ 26, 27, 28, 29, 30, 31, 32, 378, 180, 383, + /* 470 */ 182, 244, 386, 396, 369, 349, 117, 400, 352, 356, + /* 480 */ 403, 404, 405, 406, 407, 408, 363, 410, 70, 189, + /* 490 */ 190, 132, 133, 205, 206, 372, 208, 209, 210, 211, /* 500 */ 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, - /* 510 */ 222, 223, 224, 225, 226, 70, 62, 333, 187, 188, - /* 520 */ 161, 162, 191, 19, 193, 337, 97, 65, 66, 67, - /* 530 */ 427, 347, 369, 106, 431, 73, 74, 33, 354, 180, - /* 540 */ 78, 182, 137, 138, 228, 83, 84, 359, 364, 446, - /* 550 */ 447, 89, 48, 0, 451, 452, 1, 2, 54, 55, - /* 560 */ 56, 57, 58, 70, 205, 206, 339, 208, 209, 210, + /* 510 */ 222, 223, 224, 225, 226, 342, 343, 342, 343, 21, + /* 520 */ 161, 162, 24, 25, 26, 27, 28, 29, 30, 31, + /* 530 */ 32, 244, 455, 456, 348, 117, 65, 66, 67, 180, + /* 540 */ 348, 182, 356, 356, 73, 74, 14, 0, 356, 78, + /* 550 */ 363, 365, 20, 20, 83, 84, 0, 365, 325, 372, + /* 560 */ 89, 126, 127, 20, 205, 206, 131, 208, 209, 210, /* 570 */ 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, - /* 580 */ 221, 222, 223, 224, 225, 226, 12, 13, 427, 362, - /* 590 */ 411, 358, 431, 414, 20, 33, 22, 20, 94, 325, - /* 600 */ 0, 97, 369, 172, 107, 357, 325, 33, 447, 35, - /* 610 */ 48, 325, 451, 452, 44, 62, 54, 55, 56, 57, - /* 620 */ 58, 400, 333, 126, 127, 128, 129, 130, 131, 58, - /* 630 */ 397, 398, 58, 356, 130, 342, 343, 356, 342, 343, - /* 640 */ 363, 408, 357, 369, 70, 364, 20, 426, 22, 372, - /* 650 */ 369, 96, 371, 364, 356, 369, 94, 12, 13, 97, - /* 660 */ 22, 35, 62, 365, 3, 20, 95, 22, 97, 95, - /* 670 */ 357, 167, 95, 35, 357, 394, 385, 51, 33, 398, - /* 680 */ 35, 20, 401, 402, 403, 404, 405, 406, 184, 408, - /* 690 */ 186, 117, 411, 357, 413, 414, 415, 266, 14, 400, - /* 700 */ 419, 420, 44, 58, 20, 20, 132, 133, 70, 364, - /* 710 */ 333, 422, 423, 424, 425, 70, 427, 428, 427, 389, - /* 720 */ 375, 325, 431, 357, 347, 426, 164, 165, 325, 167, - /* 730 */ 333, 20, 170, 160, 371, 161, 162, 446, 447, 2, - /* 740 */ 95, 364, 451, 452, 347, 8, 9, 384, 186, 12, - /* 750 */ 13, 14, 15, 16, 180, 117, 182, 96, 325, 379, - /* 760 */ 44, 364, 117, 8, 9, 369, 326, 12, 13, 14, - /* 770 */ 15, 16, 369, 325, 412, 20, 414, 132, 133, 205, - /* 780 */ 206, 0, 208, 209, 210, 211, 212, 213, 214, 215, + /* 580 */ 221, 222, 223, 224, 225, 226, 12, 13, 0, 356, + /* 590 */ 325, 333, 58, 21, 20, 48, 22, 364, 180, 0, + /* 600 */ 182, 325, 369, 20, 371, 347, 34, 33, 36, 35, + /* 610 */ 358, 333, 24, 25, 26, 27, 28, 29, 30, 31, + /* 620 */ 32, 369, 364, 205, 206, 347, 1, 2, 94, 396, + /* 630 */ 325, 97, 58, 400, 369, 325, 403, 404, 405, 406, + /* 640 */ 407, 408, 364, 410, 70, 369, 337, 339, 415, 265, + /* 650 */ 417, 399, 400, 413, 421, 422, 416, 12, 13, 333, + /* 660 */ 4, 62, 410, 107, 3, 20, 325, 22, 359, 95, + /* 670 */ 362, 79, 325, 347, 369, 19, 443, 371, 33, 369, + /* 680 */ 35, 20, 126, 127, 128, 129, 130, 131, 2, 33, + /* 690 */ 364, 117, 386, 161, 8, 9, 163, 356, 12, 13, + /* 700 */ 14, 15, 16, 58, 48, 364, 132, 133, 325, 53, + /* 710 */ 369, 325, 371, 402, 58, 70, 369, 325, 429, 8, + /* 720 */ 9, 96, 433, 12, 13, 14, 15, 16, 4, 137, + /* 730 */ 138, 20, 0, 160, 402, 161, 162, 396, 449, 428, + /* 740 */ 95, 400, 453, 454, 403, 404, 405, 406, 407, 408, + /* 750 */ 94, 410, 369, 97, 180, 369, 182, 96, 417, 2, + /* 760 */ 428, 369, 117, 422, 325, 8, 9, 325, 127, 12, + /* 770 */ 13, 14, 15, 16, 228, 325, 4, 132, 133, 205, + /* 780 */ 206, 49, 208, 209, 210, 211, 212, 213, 214, 215, /* 790 */ 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, - /* 800 */ 226, 18, 369, 20, 231, 325, 161, 162, 333, 333, - /* 810 */ 27, 348, 96, 30, 241, 244, 33, 369, 180, 356, - /* 820 */ 182, 244, 347, 347, 163, 180, 0, 182, 365, 48, - /* 830 */ 325, 48, 325, 50, 325, 265, 53, 325, 325, 364, - /* 840 */ 364, 242, 243, 205, 206, 161, 325, 20, 163, 369, - /* 850 */ 205, 206, 444, 208, 209, 210, 211, 212, 213, 214, + /* 800 */ 226, 18, 35, 20, 231, 325, 161, 162, 369, 19, + /* 810 */ 27, 369, 356, 30, 241, 43, 33, 45, 46, 369, + /* 820 */ 414, 365, 416, 33, 163, 180, 0, 182, 187, 188, + /* 830 */ 364, 48, 191, 50, 193, 228, 53, 230, 48, 0, + /* 840 */ 414, 375, 416, 39, 54, 55, 56, 57, 58, 369, + /* 850 */ 205, 206, 0, 208, 209, 210, 211, 212, 213, 214, /* 860 */ 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, - /* 870 */ 225, 226, 161, 412, 369, 414, 369, 94, 369, 8, - /* 880 */ 9, 369, 369, 12, 13, 14, 15, 16, 0, 106, - /* 890 */ 369, 65, 66, 67, 68, 69, 345, 71, 72, 73, + /* 870 */ 225, 226, 356, 20, 163, 8, 9, 94, 20, 12, + /* 880 */ 13, 14, 15, 16, 94, 364, 63, 97, 372, 106, + /* 890 */ 106, 65, 66, 67, 68, 69, 375, 71, 72, 73, /* 900 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - /* 910 */ 84, 85, 86, 87, 88, 89, 90, 91, 163, 136, - /* 920 */ 325, 263, 139, 140, 141, 142, 143, 144, 145, 146, - /* 930 */ 147, 148, 149, 150, 151, 152, 153, 154, 155, 4, - /* 940 */ 157, 158, 159, 18, 366, 8, 9, 369, 23, 12, - /* 950 */ 13, 14, 15, 16, 19, 0, 333, 325, 325, 39, - /* 960 */ 333, 455, 37, 38, 369, 2, 41, 96, 33, 335, - /* 970 */ 347, 8, 9, 20, 347, 12, 13, 14, 15, 16, - /* 980 */ 333, 325, 333, 48, 59, 60, 61, 364, 53, 356, - /* 990 */ 163, 364, 333, 58, 347, 107, 347, 364, 344, 107, - /* 1000 */ 346, 369, 369, 385, 371, 438, 347, 366, 356, 0, - /* 1010 */ 369, 364, 333, 364, 126, 127, 128, 129, 130, 131, - /* 1020 */ 95, 129, 106, 364, 372, 369, 347, 394, 42, 94, - /* 1030 */ 44, 398, 97, 96, 401, 402, 403, 404, 405, 406, - /* 1040 */ 42, 408, 44, 364, 366, 427, 413, 369, 415, 431, - /* 1050 */ 8, 9, 419, 420, 12, 13, 14, 15, 16, 134, - /* 1060 */ 22, 325, 107, 333, 446, 447, 12, 13, 349, 451, - /* 1070 */ 452, 352, 156, 35, 441, 99, 22, 347, 102, 333, - /* 1080 */ 35, 126, 127, 128, 129, 130, 131, 33, 99, 35, - /* 1090 */ 35, 102, 356, 347, 364, 0, 0, 172, 173, 174, - /* 1100 */ 364, 333, 177, 99, 325, 369, 102, 371, 356, 44, - /* 1110 */ 364, 99, 58, 44, 102, 347, 163, 22, 22, 47, - /* 1120 */ 195, 63, 333, 198, 70, 200, 201, 202, 203, 204, - /* 1130 */ 394, 335, 364, 333, 398, 356, 347, 401, 402, 403, - /* 1140 */ 404, 405, 406, 364, 408, 333, 0, 347, 369, 413, - /* 1150 */ 371, 415, 44, 364, 385, 419, 420, 132, 133, 347, - /* 1160 */ 151, 96, 325, 243, 364, 96, 430, 95, 22, 244, - /* 1170 */ 163, 117, 44, 394, 44, 168, 364, 398, 44, 332, - /* 1180 */ 401, 402, 403, 404, 405, 406, 379, 408, 13, 1, - /* 1190 */ 2, 13, 413, 356, 415, 44, 427, 44, 419, 420, - /* 1200 */ 431, 364, 379, 44, 96, 163, 369, 95, 371, 430, - /* 1210 */ 35, 368, 44, 35, 44, 446, 447, 105, 44, 385, - /* 1220 */ 451, 452, 429, 325, 96, 448, 96, 182, 246, 421, - /* 1230 */ 96, 394, 396, 35, 180, 398, 182, 182, 401, 402, - /* 1240 */ 403, 404, 405, 406, 48, 408, 44, 96, 432, 96, - /* 1250 */ 413, 325, 415, 44, 356, 96, 419, 420, 395, 205, - /* 1260 */ 206, 427, 364, 205, 96, 431, 96, 369, 70, 371, - /* 1270 */ 96, 217, 218, 219, 220, 221, 222, 223, 178, 42, - /* 1280 */ 446, 447, 356, 44, 387, 451, 452, 376, 20, 379, - /* 1290 */ 364, 376, 394, 160, 20, 369, 398, 371, 96, 401, - /* 1300 */ 402, 403, 404, 405, 406, 96, 408, 374, 333, 93, - /* 1310 */ 333, 413, 325, 415, 376, 374, 374, 419, 420, 341, - /* 1320 */ 394, 333, 20, 333, 398, 333, 327, 401, 402, 403, - /* 1330 */ 404, 405, 406, 327, 408, 96, 20, 391, 371, 413, - /* 1340 */ 339, 415, 339, 356, 20, 419, 420, 334, 20, 339, - /* 1350 */ 386, 364, 334, 339, 339, 339, 369, 333, 371, 339, - /* 1360 */ 52, 327, 336, 336, 356, 325, 333, 356, 185, 369, - /* 1370 */ 327, 369, 393, 356, 194, 356, 391, 356, 356, 356, - /* 1380 */ 333, 394, 437, 337, 356, 398, 356, 356, 401, 402, - /* 1390 */ 403, 404, 405, 406, 337, 408, 356, 356, 437, 252, - /* 1400 */ 251, 258, 415, 371, 364, 440, 419, 420, 369, 369, - /* 1410 */ 439, 371, 171, 259, 379, 379, 260, 369, 325, 390, - /* 1420 */ 369, 369, 267, 247, 456, 264, 382, 262, 437, 436, - /* 1430 */ 435, 382, 449, 396, 394, 243, 20, 364, 398, 434, - /* 1440 */ 333, 401, 402, 403, 404, 405, 406, 450, 408, 356, - /* 1450 */ 400, 334, 337, 382, 369, 415, 369, 364, 369, 419, - /* 1460 */ 420, 325, 369, 369, 371, 382, 369, 369, 165, 337, - /* 1470 */ 380, 352, 337, 364, 95, 95, 360, 418, 333, 369, - /* 1480 */ 36, 337, 383, 346, 392, 328, 383, 394, 350, 327, - /* 1490 */ 388, 398, 356, 0, 401, 402, 403, 404, 405, 406, - /* 1500 */ 364, 408, 350, 0, 338, 369, 187, 371, 415, 323, - /* 1510 */ 350, 0, 419, 420, 0, 42, 0, 35, 325, 199, - /* 1520 */ 35, 35, 35, 0, 199, 35, 35, 0, 199, 199, - /* 1530 */ 394, 0, 0, 35, 398, 325, 0, 401, 402, 403, - /* 1540 */ 404, 405, 406, 407, 408, 409, 410, 22, 182, 356, - /* 1550 */ 35, 180, 0, 0, 176, 0, 175, 364, 0, 47, - /* 1560 */ 0, 325, 369, 0, 371, 0, 356, 58, 42, 0, - /* 1570 */ 0, 0, 0, 0, 364, 0, 0, 0, 151, 369, - /* 1580 */ 35, 371, 0, 151, 0, 0, 0, 394, 42, 0, - /* 1590 */ 0, 398, 356, 0, 401, 402, 403, 404, 405, 406, - /* 1600 */ 364, 408, 0, 0, 394, 369, 0, 371, 398, 0, - /* 1610 */ 0, 401, 402, 403, 404, 405, 406, 0, 408, 0, - /* 1620 */ 0, 325, 0, 0, 0, 0, 0, 0, 0, 22, - /* 1630 */ 394, 135, 0, 0, 398, 442, 443, 401, 402, 403, - /* 1640 */ 404, 405, 406, 325, 408, 0, 0, 35, 0, 0, - /* 1650 */ 58, 415, 356, 0, 0, 42, 420, 39, 44, 0, - /* 1660 */ 364, 14, 47, 453, 454, 369, 0, 371, 47, 14, - /* 1670 */ 40, 0, 0, 39, 356, 39, 47, 171, 0, 0, - /* 1680 */ 0, 0, 364, 0, 0, 35, 48, 369, 48, 371, - /* 1690 */ 394, 0, 35, 35, 398, 39, 0, 401, 402, 403, - /* 1700 */ 404, 405, 406, 64, 408, 0, 39, 325, 48, 39, - /* 1710 */ 35, 48, 394, 39, 0, 0, 398, 0, 102, 401, - /* 1720 */ 402, 403, 404, 405, 406, 35, 408, 0, 325, 22, - /* 1730 */ 44, 44, 35, 35, 35, 35, 35, 35, 356, 443, - /* 1740 */ 22, 104, 0, 35, 22, 0, 364, 22, 0, 0, - /* 1750 */ 22, 369, 0, 371, 50, 35, 35, 0, 35, 356, - /* 1760 */ 22, 20, 0, 445, 361, 35, 35, 364, 163, 96, - /* 1770 */ 192, 325, 369, 0, 371, 35, 394, 95, 183, 0, - /* 1780 */ 398, 22, 0, 401, 402, 403, 404, 405, 406, 3, - /* 1790 */ 408, 44, 248, 47, 44, 44, 248, 394, 163, 96, - /* 1800 */ 47, 398, 356, 3, 401, 402, 403, 404, 405, 406, - /* 1810 */ 364, 408, 169, 44, 95, 369, 165, 371, 44, 95, - /* 1820 */ 35, 95, 325, 35, 163, 96, 35, 248, 96, 95, - /* 1830 */ 95, 35, 96, 96, 95, 0, 454, 35, 325, 96, - /* 1840 */ 394, 35, 47, 242, 398, 44, 47, 401, 402, 403, - /* 1850 */ 404, 405, 406, 356, 408, 0, 410, 96, 361, 96, - /* 1860 */ 0, 364, 95, 0, 96, 95, 369, 96, 371, 356, - /* 1870 */ 95, 95, 166, 39, 361, 164, 95, 364, 47, 2, - /* 1880 */ 44, 205, 369, 105, 371, 95, 22, 47, 96, 227, - /* 1890 */ 96, 394, 325, 229, 47, 398, 227, 22, 401, 402, - /* 1900 */ 403, 404, 405, 406, 95, 408, 95, 394, 96, 95, - /* 1910 */ 95, 398, 96, 325, 401, 402, 403, 404, 405, 406, - /* 1920 */ 95, 408, 96, 356, 106, 35, 35, 95, 35, 96, - /* 1930 */ 35, 364, 95, 35, 96, 96, 369, 95, 371, 95, - /* 1940 */ 207, 96, 35, 95, 356, 22, 119, 119, 119, 119, - /* 1950 */ 107, 95, 364, 44, 35, 22, 325, 369, 64, 371, - /* 1960 */ 95, 394, 95, 63, 35, 398, 35, 35, 401, 402, - /* 1970 */ 403, 404, 405, 406, 35, 408, 35, 325, 35, 35, - /* 1980 */ 70, 35, 394, 35, 35, 35, 398, 356, 92, 401, - /* 1990 */ 402, 403, 404, 405, 406, 364, 408, 44, 35, 35, - /* 2000 */ 369, 22, 371, 35, 35, 35, 70, 35, 356, 35, - /* 2010 */ 35, 35, 35, 22, 0, 35, 364, 35, 0, 48, - /* 2020 */ 325, 369, 39, 371, 35, 394, 48, 0, 35, 398, - /* 2030 */ 0, 39, 401, 402, 403, 404, 405, 406, 325, 408, - /* 2040 */ 39, 35, 48, 48, 39, 0, 394, 35, 35, 0, - /* 2050 */ 398, 356, 21, 401, 402, 403, 404, 405, 406, 364, - /* 2060 */ 408, 22, 22, 22, 369, 21, 371, 457, 20, 356, - /* 2070 */ 457, 457, 457, 457, 457, 457, 457, 364, 457, 457, - /* 2080 */ 457, 457, 369, 457, 371, 457, 457, 457, 457, 394, - /* 2090 */ 457, 457, 457, 398, 457, 457, 401, 402, 403, 404, - /* 2100 */ 405, 406, 325, 408, 457, 457, 457, 394, 457, 457, - /* 2110 */ 457, 398, 457, 457, 401, 402, 403, 404, 405, 406, - /* 2120 */ 457, 408, 457, 325, 457, 457, 457, 457, 457, 457, - /* 2130 */ 457, 457, 457, 356, 457, 457, 457, 457, 457, 457, - /* 2140 */ 457, 364, 457, 457, 457, 457, 369, 457, 371, 457, - /* 2150 */ 457, 457, 457, 457, 356, 457, 457, 457, 457, 457, - /* 2160 */ 457, 457, 364, 457, 457, 457, 325, 369, 457, 371, - /* 2170 */ 457, 394, 457, 457, 457, 398, 457, 457, 401, 402, - /* 2180 */ 403, 404, 405, 406, 325, 408, 457, 457, 457, 457, - /* 2190 */ 457, 457, 394, 457, 457, 457, 398, 356, 457, 401, - /* 2200 */ 402, 403, 404, 405, 406, 364, 408, 457, 457, 457, - /* 2210 */ 369, 457, 371, 457, 457, 356, 457, 457, 457, 457, - /* 2220 */ 457, 457, 457, 364, 457, 457, 457, 325, 369, 457, - /* 2230 */ 371, 457, 457, 457, 457, 394, 457, 457, 457, 398, - /* 2240 */ 457, 457, 401, 402, 403, 404, 405, 406, 457, 408, - /* 2250 */ 457, 457, 457, 394, 457, 457, 457, 398, 356, 457, - /* 2260 */ 401, 402, 403, 404, 405, 406, 364, 408, 457, 457, - /* 2270 */ 325, 369, 457, 371, 457, 457, 457, 457, 457, 457, - /* 2280 */ 457, 457, 457, 457, 457, 457, 457, 325, 457, 457, - /* 2290 */ 457, 457, 457, 457, 457, 457, 394, 457, 457, 457, - /* 2300 */ 398, 356, 457, 401, 402, 403, 404, 405, 406, 364, - /* 2310 */ 408, 457, 457, 325, 369, 457, 371, 457, 356, 457, - /* 2320 */ 457, 457, 457, 457, 457, 457, 364, 457, 457, 457, - /* 2330 */ 457, 369, 457, 371, 457, 457, 457, 457, 457, 394, - /* 2340 */ 457, 457, 457, 398, 356, 457, 401, 402, 403, 404, - /* 2350 */ 405, 406, 364, 408, 457, 457, 394, 369, 457, 371, - /* 2360 */ 398, 457, 457, 401, 402, 403, 404, 405, 406, 457, - /* 2370 */ 408, 457, 325, 457, 457, 457, 457, 457, 457, 457, - /* 2380 */ 457, 457, 394, 457, 457, 457, 398, 457, 457, 401, - /* 2390 */ 402, 403, 404, 405, 406, 457, 408, 457, 457, 457, - /* 2400 */ 457, 457, 457, 356, 457, 457, 457, 457, 457, 457, - /* 2410 */ 457, 364, 457, 457, 457, 325, 369, 457, 371, 457, - /* 2420 */ 457, 457, 457, 457, 457, 457, 457, 457, 457, 457, - /* 2430 */ 457, 457, 457, 325, 457, 457, 457, 457, 457, 457, - /* 2440 */ 457, 394, 457, 457, 457, 398, 356, 457, 401, 402, - /* 2450 */ 403, 404, 405, 406, 364, 408, 457, 457, 457, 369, - /* 2460 */ 457, 371, 457, 457, 356, 457, 457, 457, 457, 457, - /* 2470 */ 457, 457, 364, 457, 457, 457, 457, 369, 457, 371, - /* 2480 */ 457, 457, 457, 457, 394, 457, 457, 457, 398, 457, - /* 2490 */ 457, 401, 402, 403, 404, 405, 406, 325, 408, 457, - /* 2500 */ 457, 457, 394, 457, 457, 457, 398, 457, 457, 401, - /* 2510 */ 402, 403, 404, 405, 406, 457, 408, 457, 325, 457, - /* 2520 */ 457, 457, 457, 457, 457, 457, 457, 457, 356, 457, - /* 2530 */ 457, 457, 457, 457, 457, 457, 364, 457, 457, 457, - /* 2540 */ 457, 369, 457, 371, 457, 457, 457, 457, 457, 356, - /* 2550 */ 457, 457, 457, 457, 457, 457, 457, 364, 457, 457, - /* 2560 */ 457, 325, 369, 457, 371, 457, 394, 457, 457, 457, - /* 2570 */ 398, 457, 457, 401, 402, 403, 404, 405, 406, 325, - /* 2580 */ 408, 457, 457, 457, 457, 457, 457, 394, 457, 457, - /* 2590 */ 457, 398, 356, 457, 401, 402, 403, 404, 405, 406, - /* 2600 */ 364, 408, 457, 457, 457, 369, 457, 371, 457, 457, - /* 2610 */ 356, 457, 457, 457, 457, 457, 457, 457, 364, 457, - /* 2620 */ 457, 457, 325, 369, 457, 371, 457, 457, 457, 457, - /* 2630 */ 394, 457, 457, 457, 398, 457, 457, 401, 402, 403, - /* 2640 */ 404, 405, 406, 457, 408, 457, 457, 457, 394, 457, - /* 2650 */ 457, 457, 398, 356, 457, 401, 402, 403, 404, 405, - /* 2660 */ 406, 364, 408, 457, 457, 457, 369, 457, 371, 457, - /* 2670 */ 457, 457, 457, 457, 457, 457, 457, 457, 457, 457, - /* 2680 */ 457, 457, 457, 457, 457, 457, 457, 457, 457, 457, - /* 2690 */ 457, 394, 457, 457, 457, 398, 457, 457, 401, 402, - /* 2700 */ 403, 404, 405, 406, 457, 408, + /* 910 */ 84, 85, 86, 87, 88, 89, 90, 91, 366, 136, + /* 920 */ 130, 369, 139, 140, 141, 142, 143, 144, 145, 146, + /* 930 */ 147, 148, 149, 150, 151, 152, 153, 154, 155, 70, + /* 940 */ 157, 158, 159, 18, 45, 46, 8, 9, 23, 182, + /* 950 */ 12, 13, 14, 15, 16, 325, 325, 167, 325, 107, + /* 960 */ 70, 366, 37, 38, 369, 349, 41, 366, 352, 245, + /* 970 */ 369, 344, 357, 346, 184, 42, 186, 44, 126, 127, + /* 980 */ 128, 129, 130, 131, 59, 60, 61, 8, 9, 356, + /* 990 */ 151, 12, 13, 14, 15, 16, 107, 364, 47, 369, + /* 1000 */ 369, 333, 369, 107, 371, 357, 8, 9, 242, 243, + /* 1010 */ 12, 13, 14, 15, 16, 347, 163, 58, 129, 161, + /* 1020 */ 95, 333, 126, 127, 128, 129, 130, 131, 205, 396, + /* 1030 */ 163, 333, 364, 400, 96, 347, 403, 404, 405, 406, + /* 1040 */ 407, 408, 44, 410, 44, 347, 95, 243, 415, 42, + /* 1050 */ 417, 44, 364, 22, 421, 422, 97, 357, 106, 134, + /* 1060 */ 333, 325, 364, 8, 9, 432, 35, 12, 13, 14, + /* 1070 */ 15, 16, 8, 9, 347, 357, 12, 13, 14, 15, + /* 1080 */ 16, 333, 99, 99, 44, 102, 102, 333, 0, 35, + /* 1090 */ 99, 364, 356, 102, 0, 347, 96, 172, 173, 174, + /* 1100 */ 364, 347, 177, 333, 44, 369, 325, 371, 156, 0, + /* 1110 */ 22, 99, 364, 358, 102, 44, 22, 347, 364, 44, + /* 1120 */ 195, 132, 133, 198, 369, 200, 201, 202, 203, 204, + /* 1130 */ 44, 22, 396, 333, 364, 333, 400, 356, 326, 403, + /* 1140 */ 404, 405, 406, 407, 408, 364, 410, 347, 44, 347, + /* 1150 */ 369, 415, 371, 417, 399, 400, 96, 421, 422, 345, + /* 1160 */ 96, 333, 333, 357, 364, 410, 364, 96, 432, 244, + /* 1170 */ 44, 96, 357, 163, 44, 347, 347, 396, 168, 325, + /* 1180 */ 44, 400, 96, 457, 403, 404, 405, 406, 407, 408, + /* 1190 */ 13, 410, 364, 364, 12, 13, 415, 333, 417, 44, + /* 1200 */ 96, 44, 421, 422, 22, 1, 2, 13, 357, 95, + /* 1210 */ 356, 347, 35, 432, 379, 33, 44, 35, 364, 105, + /* 1220 */ 33, 387, 96, 369, 387, 371, 96, 172, 364, 35, + /* 1230 */ 335, 446, 96, 440, 325, 48, 182, 44, 356, 335, + /* 1240 */ 58, 54, 55, 56, 57, 58, 44, 379, 332, 44, + /* 1250 */ 396, 96, 70, 96, 400, 368, 44, 403, 404, 405, + /* 1260 */ 406, 407, 408, 429, 410, 356, 429, 433, 96, 415, + /* 1270 */ 433, 417, 35, 364, 431, 421, 422, 379, 369, 423, + /* 1280 */ 371, 94, 448, 449, 97, 448, 449, 453, 454, 96, + /* 1290 */ 453, 454, 450, 434, 387, 246, 48, 397, 96, 117, + /* 1300 */ 398, 96, 178, 263, 389, 396, 42, 70, 96, 400, + /* 1310 */ 376, 20, 403, 404, 405, 406, 407, 408, 379, 410, + /* 1320 */ 376, 266, 160, 374, 415, 20, 417, 333, 333, 376, + /* 1330 */ 421, 422, 374, 93, 341, 374, 429, 333, 333, 333, + /* 1340 */ 433, 20, 327, 327, 20, 371, 325, 387, 393, 20, + /* 1350 */ 339, 164, 165, 339, 167, 448, 449, 170, 334, 20, + /* 1360 */ 453, 454, 180, 388, 182, 339, 334, 339, 339, 339, + /* 1370 */ 333, 52, 339, 186, 336, 336, 325, 356, 356, 327, + /* 1380 */ 333, 356, 369, 356, 327, 364, 369, 205, 206, 429, + /* 1390 */ 369, 356, 371, 433, 194, 393, 395, 356, 356, 217, + /* 1400 */ 218, 219, 220, 221, 222, 223, 356, 356, 448, 449, + /* 1410 */ 337, 185, 356, 453, 454, 364, 371, 396, 356, 356, + /* 1420 */ 369, 400, 371, 356, 403, 404, 405, 406, 407, 408, + /* 1430 */ 337, 410, 325, 333, 369, 392, 415, 379, 417, 251, + /* 1440 */ 379, 252, 421, 422, 258, 369, 369, 396, 439, 369, + /* 1450 */ 384, 400, 325, 384, 403, 404, 405, 406, 407, 408, + /* 1460 */ 442, 410, 439, 356, 171, 247, 260, 259, 417, 262, + /* 1470 */ 398, 364, 421, 422, 438, 441, 369, 267, 371, 264, + /* 1480 */ 364, 437, 243, 356, 436, 439, 20, 402, 334, 333, + /* 1490 */ 337, 364, 20, 382, 384, 165, 369, 369, 371, 384, + /* 1500 */ 369, 369, 369, 396, 369, 452, 369, 400, 337, 364, + /* 1510 */ 403, 404, 405, 406, 407, 408, 352, 410, 337, 381, + /* 1520 */ 325, 451, 95, 396, 417, 420, 458, 400, 421, 422, + /* 1530 */ 403, 404, 405, 406, 407, 408, 325, 410, 95, 360, + /* 1540 */ 337, 36, 369, 346, 417, 328, 333, 327, 421, 422, + /* 1550 */ 390, 356, 394, 385, 385, 323, 0, 0, 187, 364, + /* 1560 */ 42, 338, 0, 0, 369, 0, 371, 356, 35, 350, + /* 1570 */ 35, 350, 350, 199, 35, 364, 35, 0, 199, 35, + /* 1580 */ 369, 35, 371, 199, 0, 199, 0, 35, 0, 22, + /* 1590 */ 0, 396, 182, 35, 180, 400, 0, 325, 403, 404, + /* 1600 */ 405, 406, 407, 408, 0, 410, 176, 396, 175, 0, + /* 1610 */ 0, 400, 0, 47, 403, 404, 405, 406, 407, 408, + /* 1620 */ 0, 410, 0, 42, 0, 0, 0, 0, 356, 151, + /* 1630 */ 35, 0, 151, 0, 0, 0, 364, 0, 0, 444, + /* 1640 */ 445, 369, 325, 371, 0, 0, 0, 0, 0, 0, + /* 1650 */ 0, 0, 0, 0, 0, 0, 445, 0, 0, 42, + /* 1660 */ 0, 0, 0, 0, 0, 22, 0, 0, 396, 0, + /* 1670 */ 0, 135, 400, 356, 35, 403, 404, 405, 406, 407, + /* 1680 */ 408, 364, 410, 0, 0, 0, 369, 0, 371, 0, + /* 1690 */ 58, 14, 14, 0, 58, 0, 0, 0, 42, 171, + /* 1700 */ 0, 0, 0, 325, 39, 64, 47, 0, 0, 0, + /* 1710 */ 0, 39, 44, 396, 35, 40, 0, 400, 47, 447, + /* 1720 */ 403, 404, 405, 406, 407, 408, 325, 410, 47, 39, + /* 1730 */ 48, 39, 0, 35, 356, 0, 48, 0, 39, 361, + /* 1740 */ 35, 35, 364, 39, 0, 22, 104, 369, 0, 371, + /* 1750 */ 35, 48, 39, 35, 35, 35, 35, 356, 44, 48, + /* 1760 */ 35, 44, 22, 35, 35, 364, 0, 22, 0, 22, + /* 1770 */ 369, 0, 371, 456, 396, 102, 50, 22, 400, 0, + /* 1780 */ 0, 403, 404, 405, 406, 407, 408, 325, 410, 35, + /* 1790 */ 0, 35, 35, 20, 22, 35, 35, 396, 192, 0, + /* 1800 */ 35, 400, 0, 163, 403, 404, 405, 406, 407, 408, + /* 1810 */ 0, 410, 0, 412, 22, 0, 3, 325, 356, 44, + /* 1820 */ 96, 248, 44, 361, 47, 95, 364, 96, 95, 95, + /* 1830 */ 44, 369, 96, 371, 96, 96, 95, 95, 47, 44, + /* 1840 */ 325, 95, 248, 163, 95, 3, 96, 96, 356, 44, + /* 1850 */ 248, 165, 35, 361, 163, 35, 364, 35, 396, 183, + /* 1860 */ 35, 369, 400, 371, 35, 403, 404, 405, 406, 407, + /* 1870 */ 408, 356, 410, 35, 47, 44, 0, 96, 96, 364, + /* 1880 */ 47, 169, 0, 47, 369, 325, 371, 0, 396, 95, + /* 1890 */ 39, 95, 400, 96, 96, 403, 404, 405, 406, 407, + /* 1900 */ 408, 325, 410, 95, 95, 105, 95, 47, 44, 2, + /* 1910 */ 22, 396, 96, 95, 95, 400, 356, 164, 403, 404, + /* 1920 */ 405, 406, 407, 408, 364, 410, 96, 95, 166, 369, + /* 1930 */ 96, 371, 356, 47, 95, 95, 242, 47, 22, 96, + /* 1940 */ 364, 95, 95, 106, 96, 369, 35, 371, 35, 227, + /* 1950 */ 96, 95, 35, 35, 325, 96, 396, 205, 95, 35, + /* 1960 */ 400, 96, 95, 403, 404, 405, 406, 407, 408, 96, + /* 1970 */ 410, 207, 396, 35, 95, 22, 400, 119, 107, 403, + /* 1980 */ 404, 405, 406, 407, 408, 356, 410, 229, 119, 119, + /* 1990 */ 227, 119, 95, 364, 44, 95, 35, 22, 369, 325, + /* 2000 */ 371, 95, 35, 64, 63, 35, 35, 35, 35, 35, + /* 2010 */ 70, 35, 35, 35, 35, 92, 35, 35, 35, 22, + /* 2020 */ 35, 35, 35, 35, 44, 396, 70, 35, 35, 400, + /* 2030 */ 356, 35, 403, 404, 405, 406, 407, 408, 364, 410, + /* 2040 */ 35, 22, 35, 369, 0, 371, 35, 48, 39, 0, + /* 2050 */ 35, 48, 325, 39, 0, 35, 48, 39, 0, 35, + /* 2060 */ 48, 39, 0, 35, 35, 0, 20, 22, 325, 21, + /* 2070 */ 396, 459, 22, 22, 400, 459, 21, 403, 404, 405, + /* 2080 */ 406, 407, 408, 356, 410, 459, 459, 459, 459, 459, + /* 2090 */ 459, 364, 459, 459, 459, 459, 369, 459, 371, 356, + /* 2100 */ 459, 459, 459, 459, 459, 459, 459, 364, 459, 459, + /* 2110 */ 459, 459, 369, 325, 371, 459, 459, 459, 459, 459, + /* 2120 */ 459, 459, 459, 396, 459, 459, 459, 400, 459, 459, + /* 2130 */ 403, 404, 405, 406, 407, 408, 459, 410, 459, 396, + /* 2140 */ 459, 459, 459, 400, 356, 459, 403, 404, 405, 406, + /* 2150 */ 407, 408, 364, 410, 459, 459, 459, 369, 459, 371, + /* 2160 */ 459, 459, 459, 459, 459, 459, 325, 459, 459, 459, + /* 2170 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459, + /* 2180 */ 459, 459, 325, 459, 396, 459, 459, 459, 400, 459, + /* 2190 */ 459, 403, 404, 405, 406, 407, 408, 356, 410, 459, + /* 2200 */ 459, 459, 459, 459, 459, 364, 459, 459, 459, 459, + /* 2210 */ 369, 459, 371, 356, 459, 459, 459, 459, 459, 459, + /* 2220 */ 459, 364, 459, 459, 459, 459, 369, 325, 371, 459, + /* 2230 */ 459, 459, 459, 459, 459, 459, 459, 396, 459, 459, + /* 2240 */ 459, 400, 459, 459, 403, 404, 405, 406, 407, 408, + /* 2250 */ 325, 410, 459, 396, 459, 459, 459, 400, 356, 459, + /* 2260 */ 403, 404, 405, 406, 407, 408, 364, 410, 459, 459, + /* 2270 */ 459, 369, 459, 371, 459, 459, 459, 459, 459, 459, + /* 2280 */ 325, 356, 459, 459, 459, 459, 459, 459, 459, 364, + /* 2290 */ 459, 459, 459, 459, 369, 459, 371, 459, 396, 459, + /* 2300 */ 459, 459, 400, 459, 459, 403, 404, 405, 406, 407, + /* 2310 */ 408, 356, 410, 459, 459, 459, 459, 459, 459, 364, + /* 2320 */ 459, 396, 459, 459, 369, 400, 371, 459, 403, 404, + /* 2330 */ 405, 406, 407, 408, 459, 410, 459, 459, 459, 459, + /* 2340 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459, + /* 2350 */ 459, 396, 459, 459, 459, 400, 325, 459, 403, 404, + /* 2360 */ 405, 406, 407, 408, 459, 410, 459, 459, 459, 459, + /* 2370 */ 459, 459, 459, 459, 459, 459, 459, 459, 325, 459, + /* 2380 */ 459, 459, 459, 459, 459, 459, 459, 356, 459, 459, + /* 2390 */ 459, 459, 459, 459, 459, 364, 459, 459, 459, 459, + /* 2400 */ 369, 459, 371, 459, 459, 459, 459, 459, 459, 356, + /* 2410 */ 459, 459, 459, 459, 459, 459, 459, 364, 459, 459, + /* 2420 */ 459, 459, 369, 459, 371, 459, 459, 396, 459, 459, + /* 2430 */ 459, 400, 459, 325, 403, 404, 405, 406, 407, 408, + /* 2440 */ 459, 410, 459, 459, 459, 459, 459, 459, 459, 396, + /* 2450 */ 459, 459, 459, 400, 459, 459, 403, 404, 405, 406, + /* 2460 */ 407, 408, 459, 410, 356, 459, 459, 459, 459, 459, + /* 2470 */ 459, 459, 364, 459, 459, 459, 459, 369, 325, 371, + /* 2480 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459, + /* 2490 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459, + /* 2500 */ 459, 459, 459, 459, 396, 459, 459, 459, 400, 356, + /* 2510 */ 459, 403, 404, 405, 406, 407, 408, 364, 410, 459, + /* 2520 */ 459, 459, 369, 325, 371, 459, 459, 459, 459, 459, + /* 2530 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 325, + /* 2540 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 396, + /* 2550 */ 459, 459, 459, 400, 356, 459, 403, 404, 405, 406, + /* 2560 */ 407, 408, 364, 410, 459, 459, 459, 369, 459, 371, + /* 2570 */ 356, 459, 459, 459, 459, 459, 459, 459, 364, 459, + /* 2580 */ 459, 459, 459, 369, 325, 371, 459, 459, 459, 459, + /* 2590 */ 459, 459, 459, 459, 396, 459, 459, 459, 400, 459, + /* 2600 */ 459, 403, 404, 405, 406, 407, 408, 325, 410, 459, + /* 2610 */ 396, 459, 459, 459, 400, 356, 459, 403, 404, 405, + /* 2620 */ 406, 407, 408, 364, 410, 459, 459, 459, 369, 459, + /* 2630 */ 371, 459, 459, 459, 459, 459, 459, 325, 356, 459, + /* 2640 */ 459, 459, 459, 459, 459, 459, 364, 459, 459, 459, + /* 2650 */ 459, 369, 459, 371, 459, 396, 459, 459, 459, 400, + /* 2660 */ 459, 459, 403, 404, 405, 406, 407, 408, 356, 410, + /* 2670 */ 459, 459, 459, 459, 459, 459, 364, 459, 396, 459, + /* 2680 */ 459, 369, 400, 371, 459, 403, 404, 405, 406, 407, + /* 2690 */ 408, 459, 410, 459, 459, 459, 459, 459, 459, 459, + /* 2700 */ 459, 459, 459, 459, 459, 459, 459, 459, 396, 459, + /* 2710 */ 459, 459, 400, 459, 459, 403, 404, 405, 406, 407, + /* 2720 */ 408, 459, 410, }; -#define YY_SHIFT_COUNT (707) +#define YY_SHIFT_COUNT (710) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2049) +#define YY_SHIFT_MAX (2065) static const unsigned short int yy_shift_ofst[] = { /* 0 */ 925, 0, 71, 0, 288, 288, 288, 288, 288, 288, /* 10 */ 288, 288, 288, 359, 574, 574, 645, 574, 574, 574, /* 20 */ 574, 574, 574, 574, 574, 574, 574, 574, 574, 574, /* 30 */ 574, 574, 574, 574, 574, 574, 574, 574, 574, 574, - /* 40 */ 574, 574, 574, 574, 574, 574, 225, 577, 74, 132, - /* 50 */ 571, 133, 151, 133, 74, 74, 1054, 1054, 133, 1054, - /* 60 */ 1054, 17, 133, 52, 52, 21, 21, 98, 292, 42, - /* 70 */ 42, 52, 52, 52, 52, 52, 52, 52, 52, 52, - /* 80 */ 52, 106, 52, 52, 76, 52, 169, 52, 52, 228, - /* 90 */ 52, 52, 228, 52, 228, 228, 228, 52, 454, 783, - /* 100 */ 34, 34, 372, 462, 638, 638, 638, 638, 638, 638, - /* 110 */ 638, 638, 638, 638, 638, 638, 638, 638, 638, 638, - /* 120 */ 638, 638, 638, 149, 661, 98, 292, 553, 445, 685, - /* 130 */ 685, 685, 600, 157, 157, 445, 414, 414, 414, 427, - /* 140 */ 169, 316, 228, 9, 228, 9, 9, 427, 493, 216, - /* 150 */ 216, 216, 216, 216, 216, 216, 504, 335, 36, 755, - /* 160 */ 431, 49, 626, 187, 329, 684, 294, 827, 302, 892, - /* 170 */ 953, 599, 920, 234, 599, 986, 203, 711, 982, 1196, - /* 180 */ 1100, 1237, 1268, 1237, 1133, 1274, 1274, 1237, 1133, 1133, - /* 190 */ 1216, 1274, 1274, 1274, 1302, 1302, 1316, 106, 169, 106, - /* 200 */ 1324, 1328, 106, 1324, 106, 106, 106, 1274, 106, 1308, - /* 210 */ 1308, 1302, 228, 228, 228, 228, 228, 228, 228, 228, - /* 220 */ 228, 228, 228, 1274, 1302, 9, 9, 1180, 1316, 454, - /* 230 */ 1183, 169, 454, 1274, 1268, 1268, 9, 1147, 1149, 9, - /* 240 */ 1147, 1149, 9, 9, 228, 1143, 1241, 1147, 1156, 1154, - /* 250 */ 1176, 982, 1155, 1161, 1165, 1192, 414, 1416, 1274, 1324, - /* 260 */ 454, 1149, 9, 9, 9, 9, 9, 1149, 9, 1303, - /* 270 */ 454, 427, 454, 414, 1379, 1380, 9, 493, 1274, 454, - /* 280 */ 1444, 1302, 2706, 2706, 2706, 2706, 2706, 2706, 2706, 2706, - /* 290 */ 2706, 826, 562, 382, 935, 871, 15, 937, 888, 737, - /* 300 */ 963, 1042, 955, 183, 183, 183, 183, 183, 183, 183, - /* 310 */ 183, 183, 497, 331, 25, 25, 193, 322, 405, 166, - /* 320 */ 262, 50, 50, 417, 555, 573, 417, 417, 417, 716, - /* 330 */ 781, 1038, 998, 916, 1009, 976, 989, 1004, 1012, 1095, - /* 340 */ 1096, 1146, 429, 1065, 1069, 1025, 658, 570, 1007, 1108, - /* 350 */ 1128, 1130, 1134, 1151, 1188, 1153, 1045, 1055, 1058, 1159, - /* 360 */ 1072, 1168, 1170, 1174, 1202, 1209, 1239, 1112, 1175, 1178, - /* 370 */ 1198, 11, 1493, 1503, 1319, 1511, 1514, 1473, 1516, 1482, - /* 380 */ 1320, 1485, 1486, 1487, 1325, 1523, 1490, 1491, 1329, 1527, - /* 390 */ 1330, 1531, 1498, 1532, 1525, 1536, 1515, 1366, 1371, 1552, - /* 400 */ 1553, 1378, 1381, 1555, 1558, 1512, 1560, 1563, 1565, 1526, - /* 410 */ 1569, 1570, 1571, 1572, 1573, 1575, 1576, 1577, 1427, 1545, - /* 420 */ 1582, 1432, 1584, 1585, 1586, 1593, 1602, 1603, 1606, 1609, - /* 430 */ 1610, 1617, 1619, 1620, 1622, 1623, 1624, 1546, 1589, 1590, - /* 440 */ 1625, 1626, 1627, 1607, 1628, 1645, 1646, 1496, 1632, 1633, - /* 450 */ 1612, 1648, 1509, 1649, 1592, 1653, 1654, 1613, 1618, 1614, - /* 460 */ 1615, 1647, 1621, 1655, 1629, 1659, 1630, 1634, 1666, 1671, - /* 470 */ 1672, 1636, 1506, 1678, 1679, 1680, 1639, 1681, 1683, 1650, - /* 480 */ 1638, 1656, 1684, 1657, 1640, 1667, 1691, 1658, 1660, 1670, - /* 490 */ 1696, 1675, 1663, 1674, 1705, 1714, 1715, 1717, 1637, 1616, - /* 500 */ 1690, 1707, 1727, 1697, 1698, 1699, 1700, 1686, 1687, 1701, - /* 510 */ 1702, 1718, 1708, 1742, 1722, 1745, 1725, 1704, 1748, 1728, - /* 520 */ 1720, 1749, 1721, 1752, 1723, 1757, 1738, 1741, 1730, 1731, - /* 530 */ 1578, 1673, 1682, 1762, 1605, 1740, 1773, 1595, 1759, 1635, - /* 540 */ 1651, 1779, 1782, 1661, 1643, 1786, 1747, 1544, 1719, 1703, - /* 550 */ 1724, 1729, 1750, 1732, 1726, 1734, 1735, 1736, 1751, 1746, - /* 560 */ 1753, 1739, 1769, 1548, 1737, 1743, 1800, 1774, 1579, 1785, - /* 570 */ 1788, 1791, 1796, 1802, 1806, 1761, 1763, 1795, 1601, 1801, - /* 580 */ 1799, 1835, 1855, 1860, 1767, 1768, 1771, 1770, 1775, 1706, - /* 590 */ 1776, 1863, 1834, 1711, 1781, 1778, 1615, 1831, 1836, 1662, - /* 600 */ 1664, 1669, 1877, 1864, 1676, 1790, 1792, 1809, 1794, 1811, - /* 610 */ 1812, 1840, 1814, 1815, 1847, 1816, 1875, 1733, 1825, 1818, - /* 620 */ 1826, 1890, 1891, 1832, 1833, 1893, 1837, 1838, 1895, 1842, - /* 630 */ 1839, 1898, 1844, 1845, 1907, 1848, 1827, 1828, 1829, 1830, - /* 640 */ 1923, 1843, 1856, 1909, 1865, 1919, 1867, 1909, 1909, 1933, - /* 650 */ 1894, 1900, 1929, 1931, 1932, 1939, 1941, 1943, 1944, 1946, - /* 660 */ 1948, 1949, 1910, 1896, 1953, 1950, 1963, 1964, 1979, 1968, - /* 670 */ 1969, 1970, 1936, 1686, 1972, 1687, 1974, 1975, 1976, 1977, - /* 680 */ 1991, 1980, 2014, 1982, 1971, 1983, 2018, 1989, 1978, 1992, - /* 690 */ 2027, 1993, 1994, 2001, 2030, 2006, 1995, 2005, 2045, 2012, - /* 700 */ 2013, 2049, 2039, 2031, 2040, 2041, 2044, 2048, + /* 40 */ 574, 574, 574, 574, 574, 574, 103, 227, 51, 169, + /* 50 */ 287, 134, 208, 134, 51, 51, 1182, 1182, 134, 1182, + /* 60 */ 1182, 203, 134, 5, 5, 772, 772, 14, 52, 45, + /* 70 */ 45, 5, 5, 5, 5, 5, 5, 5, 40, 5, + /* 80 */ 5, 28, 5, 5, 177, 5, 404, 5, 40, 543, + /* 90 */ 5, 5, 543, 5, 543, 543, 543, 5, 57, 783, + /* 100 */ 34, 34, 498, 471, 418, 418, 418, 418, 418, 418, + /* 110 */ 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, + /* 120 */ 418, 418, 418, 213, 661, 14, 52, 312, 325, 172, + /* 130 */ 172, 172, 599, 607, 607, 325, 583, 583, 583, 784, + /* 140 */ 404, 546, 543, 869, 543, 869, 869, 784, 890, 216, + /* 150 */ 216, 216, 216, 216, 216, 216, 790, 434, 302, 711, + /* 160 */ 1055, 99, 96, 94, 295, 532, 339, 533, 899, 889, + /* 170 */ 853, 766, 804, 104, 766, 933, 724, 858, 1049, 1248, + /* 180 */ 1124, 1264, 1291, 1264, 1162, 1305, 1305, 1264, 1162, 1162, + /* 190 */ 1240, 1305, 1305, 1305, 1321, 1321, 1324, 28, 404, 28, + /* 200 */ 1329, 1339, 28, 1329, 28, 28, 28, 1305, 28, 1319, + /* 210 */ 1319, 1321, 543, 543, 543, 543, 543, 543, 543, 543, + /* 220 */ 543, 543, 543, 1305, 1321, 869, 869, 1200, 1324, 57, + /* 230 */ 1226, 404, 57, 1305, 1291, 1291, 869, 1189, 1188, 869, + /* 240 */ 1189, 1188, 869, 869, 543, 1186, 1293, 1189, 1206, 1208, + /* 250 */ 1218, 1049, 1210, 1215, 1207, 1239, 583, 1466, 1305, 1329, + /* 260 */ 57, 1472, 1188, 869, 869, 869, 869, 869, 1188, 869, + /* 270 */ 1330, 57, 784, 57, 583, 1427, 1443, 869, 890, 1305, + /* 280 */ 57, 1505, 1321, 2723, 2723, 2723, 2723, 2723, 2723, 2723, + /* 290 */ 2723, 2723, 826, 1187, 588, 656, 938, 998, 1064, 556, + /* 300 */ 686, 757, 867, 852, 979, 979, 979, 979, 979, 979, + /* 310 */ 979, 979, 979, 896, 641, 155, 155, 191, 534, 592, + /* 320 */ 572, 300, 435, 435, 1, 625, 573, 1, 1, 1, + /* 330 */ 1000, 547, 1031, 1007, 952, 839, 983, 984, 991, 1012, + /* 340 */ 1088, 1094, 1109, 959, 1060, 1071, 989, 1040, 384, 1010, + /* 350 */ 1075, 1086, 1104, 1126, 1130, 1204, 1136, 767, 1054, 823, + /* 360 */ 1155, 951, 1157, 1172, 1193, 1202, 1205, 1212, 1114, 1177, + /* 370 */ 1194, 1237, 732, 1556, 1557, 1371, 1562, 1563, 1518, 1565, + /* 380 */ 1533, 1374, 1535, 1539, 1541, 1379, 1577, 1544, 1546, 1384, + /* 390 */ 1584, 1386, 1586, 1552, 1588, 1567, 1590, 1558, 1410, 1414, + /* 400 */ 1596, 1604, 1430, 1433, 1609, 1610, 1566, 1612, 1620, 1622, + /* 410 */ 1581, 1624, 1625, 1626, 1627, 1637, 1638, 1644, 1645, 1478, + /* 420 */ 1595, 1631, 1481, 1633, 1634, 1635, 1646, 1647, 1648, 1649, + /* 430 */ 1650, 1651, 1652, 1653, 1654, 1655, 1657, 1658, 1617, 1660, + /* 440 */ 1661, 1662, 1663, 1664, 1643, 1666, 1667, 1669, 1536, 1670, + /* 450 */ 1683, 1639, 1684, 1632, 1685, 1636, 1687, 1689, 1656, 1665, + /* 460 */ 1668, 1659, 1677, 1671, 1678, 1681, 1693, 1675, 1672, 1695, + /* 470 */ 1696, 1697, 1690, 1528, 1700, 1701, 1702, 1641, 1707, 1708, + /* 480 */ 1679, 1682, 1692, 1709, 1698, 1688, 1699, 1710, 1705, 1703, + /* 490 */ 1704, 1716, 1706, 1711, 1713, 1732, 1735, 1737, 1744, 1642, + /* 500 */ 1673, 1715, 1723, 1748, 1718, 1719, 1720, 1721, 1714, 1717, + /* 510 */ 1725, 1728, 1740, 1729, 1766, 1745, 1768, 1747, 1726, 1771, + /* 520 */ 1755, 1754, 1779, 1756, 1780, 1757, 1790, 1772, 1773, 1760, + /* 530 */ 1761, 1606, 1724, 1730, 1799, 1640, 1765, 1802, 1676, 1792, + /* 540 */ 1680, 1686, 1810, 1812, 1691, 1712, 1813, 1775, 1573, 1733, + /* 550 */ 1731, 1734, 1736, 1778, 1738, 1741, 1742, 1746, 1739, 1786, + /* 560 */ 1777, 1791, 1749, 1795, 1594, 1750, 1751, 1842, 1805, 1602, + /* 570 */ 1817, 1820, 1822, 1825, 1829, 1838, 1781, 1782, 1827, 1694, + /* 580 */ 1831, 1833, 1815, 1876, 1882, 1659, 1836, 1794, 1797, 1798, + /* 590 */ 1796, 1808, 1762, 1809, 1887, 1851, 1753, 1811, 1800, 1659, + /* 600 */ 1860, 1864, 1722, 1758, 1763, 1907, 1888, 1752, 1818, 1816, + /* 610 */ 1819, 1830, 1832, 1834, 1886, 1839, 1840, 1890, 1843, 1916, + /* 620 */ 1764, 1846, 1837, 1848, 1911, 1913, 1847, 1854, 1917, 1856, + /* 630 */ 1859, 1918, 1863, 1865, 1924, 1867, 1873, 1938, 1879, 1858, + /* 640 */ 1869, 1870, 1872, 1953, 1871, 1897, 1950, 1900, 1961, 1906, + /* 650 */ 1950, 1950, 1975, 1939, 1941, 1967, 1970, 1971, 1972, 1973, + /* 660 */ 1974, 1976, 1977, 1978, 1979, 1940, 1923, 1980, 1981, 1982, + /* 670 */ 1983, 1997, 1985, 1986, 1987, 1956, 1714, 1988, 1717, 1992, + /* 680 */ 1993, 1996, 2005, 2019, 2007, 2044, 2011, 1999, 2009, 2049, + /* 690 */ 2015, 2003, 2014, 2054, 2020, 2008, 2018, 2058, 2024, 2012, + /* 700 */ 2022, 2062, 2028, 2029, 2065, 2045, 2048, 2050, 2051, 2055, + /* 710 */ 2046, }; -#define YY_REDUCE_COUNT (290) -#define YY_REDUCE_MIN (-366) -#define YY_REDUCE_MAX (2297) +#define YY_REDUCE_COUNT (291) +#define YY_REDUCE_MIN (-425) +#define YY_REDUCE_MAX (2312) static const short yy_reduce_ofst[] = { - /* 0 */ -316, -248, 281, 633, 59, 736, 779, 837, 898, 926, - /* 10 */ 987, 1040, 1093, 1136, 1193, 1210, 1236, 1296, 1318, 1382, - /* 20 */ 1403, 1446, 1497, 1513, 1567, 1588, 1631, 1652, 1695, 1713, - /* 30 */ 1777, 1798, 1841, 1859, 1902, 1945, 1962, 1988, 2047, 2090, - /* 40 */ 2108, 2172, 2193, 2236, 2254, 2297, -189, 103, 289, -366, - /* 50 */ 291, 618, 769, 834, -276, 58, -271, -168, -268, -353, - /* 60 */ 233, -77, 161, -265, 184, -329, -322, -324, -296, -191, - /* 70 */ -160, -257, 22, 109, 377, 397, 475, 476, 623, 627, - /* 80 */ 647, -98, 649, 659, -330, 679, -62, 730, 746, -243, - /* 90 */ 768, 789, -355, 800, 70, 277, 463, 812, -259, -209, - /* 100 */ -365, -365, -9, -200, -27, 102, 163, 274, 286, 396, - /* 110 */ 403, 433, 448, 480, 505, 507, 509, 512, 513, 521, - /* 120 */ 595, 632, 656, -11, -48, 99, -127, 227, 293, -48, - /* 130 */ 221, 299, 188, 362, 461, 296, -360, -57, 345, 89, - /* 140 */ 363, 179, 298, 578, 652, 641, 678, 719, 654, -339, - /* 150 */ 248, 285, 313, 317, 336, 366, 330, 440, 551, 380, - /* 160 */ 506, 408, 634, 567, 752, 752, 796, 807, 847, 843, - /* 170 */ 823, 793, 793, 777, 793, 808, 816, 752, 836, 863, - /* 180 */ 897, 911, 910, 915, 933, 975, 977, 938, 941, 942, - /* 190 */ 978, 988, 990, 992, 999, 1006, 946, 1001, 967, 1003, - /* 200 */ 1013, 964, 1010, 1018, 1014, 1015, 1016, 1024, 1020, 1026, - /* 210 */ 1027, 1034, 1008, 1011, 1017, 1019, 1021, 1022, 1023, 1028, - /* 220 */ 1030, 1031, 1041, 1033, 1043, 1000, 1002, 979, 985, 1046, - /* 230 */ 1029, 1032, 1057, 1047, 1035, 1036, 1039, 945, 1044, 1048, - /* 240 */ 961, 1049, 1051, 1052, 752, 965, 971, 991, 993, 995, - /* 250 */ 1005, 1037, 968, 997, 983, 793, 1073, 1050, 1107, 1117, - /* 260 */ 1115, 1071, 1085, 1087, 1089, 1094, 1097, 1083, 1098, 1090, - /* 270 */ 1132, 1119, 1135, 1109, 1059, 1116, 1110, 1137, 1145, 1144, - /* 280 */ 1157, 1162, 1102, 1092, 1099, 1103, 1138, 1152, 1160, 1166, - /* 290 */ 1186, + /* 0 */ -17, -295, -7, 233, 633, 736, 781, 854, 909, 1021, + /* 10 */ 1051, 1107, 1127, -169, 1195, 77, 341, 1211, 1272, 1317, + /* 20 */ 1378, 1401, 1462, 1492, 1515, 1560, 1576, 1629, 1674, 1727, + /* 30 */ 1743, 1788, 1841, 1857, 1902, 1925, 1955, 2031, 2053, 2108, + /* 40 */ 2153, 2198, 2214, 2259, 2282, 2312, -276, -290, -168, -10, + /* 50 */ 834, 837, 907, 960, -327, -181, -348, -314, -425, 252, + /* 60 */ 755, -422, 289, -328, -219, -329, -291, -300, -303, -209, + /* 70 */ -144, -173, 78, 258, 278, 326, 668, 688, -288, 698, + /* 80 */ 727, 65, 748, 754, -275, 770, 86, 800, -152, -347, + /* 90 */ 802, 828, 123, 829, 186, 187, 192, 864, -158, -294, + /* 100 */ -282, -282, -182, -265, -170, -62, -6, 82, 105, 265, + /* 110 */ 276, 305, 310, 347, 383, 386, 392, 439, 442, 450, + /* 120 */ 480, 630, 631, 67, -150, 89, -116, 308, 173, -150, + /* 130 */ 311, 332, 309, 406, 426, 175, -58, 466, 521, 126, + /* 140 */ 306, 240, 456, 552, 516, 595, 601, 616, 627, 615, + /* 150 */ 648, 700, 718, 806, 815, 851, -337, 812, 814, 835, + /* 160 */ 726, 785, 895, 793, 882, 882, 904, 868, 916, 887, + /* 170 */ 898, 843, 843, 842, 843, 856, 859, 882, 902, 900, + /* 180 */ 915, 934, 939, 944, 949, 994, 995, 953, 958, 961, + /* 190 */ 993, 1004, 1005, 1006, 1015, 1016, 955, 1011, 974, 1014, + /* 200 */ 1024, 975, 1026, 1032, 1028, 1029, 1030, 1037, 1033, 1038, + /* 210 */ 1039, 1052, 1022, 1025, 1027, 1035, 1041, 1042, 1050, 1056, + /* 220 */ 1062, 1063, 1067, 1047, 1057, 1013, 1017, 1001, 1002, 1073, + /* 230 */ 1043, 1045, 1093, 1100, 1058, 1061, 1065, 1009, 1066, 1076, + /* 240 */ 1023, 1069, 1077, 1080, 882, 1018, 1034, 1046, 1036, 1044, + /* 250 */ 1048, 1072, 1068, 1053, 1070, 843, 1116, 1085, 1156, 1154, + /* 260 */ 1153, 1111, 1110, 1128, 1131, 1132, 1133, 1135, 1115, 1137, + /* 270 */ 1138, 1171, 1164, 1181, 1145, 1105, 1179, 1173, 1197, 1213, + /* 280 */ 1203, 1217, 1220, 1160, 1158, 1168, 1169, 1219, 1221, 1222, + /* 290 */ 1223, 1232, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 10 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 20 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 30 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 40 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 50 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 60 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1841, 1586, 1586, - /* 70 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 80 */ 1586, 1664, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 90 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1662, 1834, - /* 100 */ 2031, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 110 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 120 */ 1586, 1586, 1586, 1586, 2043, 1586, 1586, 1664, 1586, 2043, - /* 130 */ 2043, 2043, 1662, 2003, 2003, 1586, 1586, 1586, 1586, 1771, - /* 140 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1771, 1586, 1586, - /* 150 */ 1586, 1586, 1586, 1586, 1586, 1586, 1878, 1586, 1586, 2068, - /* 160 */ 2121, 1586, 1586, 2071, 1586, 1586, 1586, 1846, 1586, 1724, - /* 170 */ 2058, 2035, 2049, 2105, 2036, 2033, 2052, 1586, 2062, 1586, - /* 180 */ 1871, 1839, 1586, 1839, 1836, 1586, 1586, 1839, 1836, 1836, - /* 190 */ 1715, 1586, 1586, 1586, 1586, 1586, 1586, 1664, 1586, 1664, - /* 200 */ 1586, 1586, 1664, 1586, 1664, 1664, 1664, 1586, 1664, 1643, - /* 210 */ 1643, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 220 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1891, 1586, 1662, - /* 230 */ 1880, 1586, 1662, 1586, 1586, 1586, 1586, 2078, 2076, 1586, - /* 240 */ 2078, 2076, 1586, 1586, 1586, 2090, 2086, 2078, 2094, 2092, - /* 250 */ 2064, 2062, 2124, 2111, 2107, 2049, 1586, 1586, 1586, 1586, - /* 260 */ 1662, 2076, 1586, 1586, 1586, 1586, 1586, 2076, 1586, 1586, - /* 270 */ 1662, 1586, 1662, 1586, 1586, 1740, 1586, 1586, 1586, 1662, - /* 280 */ 1618, 1586, 1873, 1884, 1856, 1856, 1774, 1774, 1774, 1665, - /* 290 */ 1591, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 300 */ 1586, 1586, 1586, 2089, 2088, 1959, 1586, 2007, 2006, 2005, - /* 310 */ 1996, 1958, 1736, 1586, 1957, 1956, 1586, 1586, 1586, 1586, - /* 320 */ 1586, 1852, 1851, 1950, 1586, 1586, 1951, 1949, 1948, 1586, - /* 330 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 340 */ 1586, 1586, 1586, 1586, 1586, 1586, 2108, 2112, 1586, 1586, - /* 350 */ 1586, 1586, 1586, 1586, 2032, 1586, 1586, 1586, 1586, 1586, - /* 360 */ 1933, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 370 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 380 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 390 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 400 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 410 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 420 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 430 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 440 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 450 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1623, - /* 460 */ 1938, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 470 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 480 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 490 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 500 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1703, 1702, 1586, - /* 510 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 520 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 530 */ 1586, 1941, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 540 */ 1586, 1586, 1586, 1586, 1586, 2104, 2065, 1586, 1586, 1586, - /* 550 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 560 */ 1933, 1586, 2087, 1586, 1586, 2102, 1586, 2106, 1586, 1586, - /* 570 */ 1586, 1586, 1586, 1586, 1586, 2042, 2038, 1586, 1586, 2034, - /* 580 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 590 */ 1586, 1586, 1586, 1586, 1586, 1586, 1932, 1586, 1993, 1586, - /* 600 */ 1586, 1586, 2027, 1586, 1586, 1978, 1586, 1586, 1586, 1586, - /* 610 */ 1586, 1586, 1586, 1586, 1586, 1941, 1586, 1944, 1586, 1586, - /* 620 */ 1586, 1586, 1586, 1768, 1586, 1586, 1586, 1586, 1586, 1586, - /* 630 */ 1586, 1586, 1586, 1586, 1586, 1586, 1753, 1751, 1750, 1749, - /* 640 */ 1586, 1746, 1586, 1781, 1586, 1586, 1586, 1777, 1776, 1586, - /* 650 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 660 */ 1586, 1586, 1586, 1586, 1683, 1586, 1586, 1586, 1586, 1586, - /* 670 */ 1586, 1586, 1586, 1675, 1586, 1674, 1586, 1586, 1586, 1586, - /* 680 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 690 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, - /* 700 */ 1586, 1586, 1586, 1586, 1586, 1586, 1586, 1586, + /* 0 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 10 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 20 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 30 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 40 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 50 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 60 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1850, 1595, 1595, + /* 70 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 80 */ 1595, 1673, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 90 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1671, 1843, + /* 100 */ 2043, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 110 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 120 */ 1595, 1595, 1595, 1595, 2055, 1595, 1595, 1673, 1595, 2055, + /* 130 */ 2055, 2055, 1671, 2015, 2015, 1595, 1595, 1595, 1595, 1780, + /* 140 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1780, 1595, 1595, + /* 150 */ 1595, 1595, 1595, 1595, 1595, 1595, 1889, 1595, 1595, 2080, + /* 160 */ 2133, 1595, 1595, 2083, 1595, 1595, 1595, 1855, 1595, 1733, + /* 170 */ 2070, 2047, 2061, 2117, 2048, 2045, 2064, 1595, 2074, 1595, + /* 180 */ 1882, 1848, 1595, 1848, 1845, 1595, 1595, 1848, 1845, 1845, + /* 190 */ 1724, 1595, 1595, 1595, 1595, 1595, 1595, 1673, 1595, 1673, + /* 200 */ 1595, 1595, 1673, 1595, 1673, 1673, 1673, 1595, 1673, 1652, + /* 210 */ 1652, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 220 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1902, 1595, 1671, + /* 230 */ 1891, 1595, 1671, 1595, 1595, 1595, 1595, 2090, 2088, 1595, + /* 240 */ 2090, 2088, 1595, 1595, 1595, 2102, 2098, 2090, 2106, 2104, + /* 250 */ 2076, 2074, 2136, 2123, 2119, 2061, 1595, 1595, 1595, 1595, + /* 260 */ 1671, 1595, 2088, 1595, 1595, 1595, 1595, 1595, 2088, 1595, + /* 270 */ 1595, 1671, 1595, 1671, 1595, 1595, 1749, 1595, 1595, 1595, + /* 280 */ 1671, 1627, 1595, 1884, 1895, 1867, 1867, 1783, 1783, 1783, + /* 290 */ 1674, 1600, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 300 */ 1595, 1595, 1595, 1595, 2101, 2100, 1971, 1595, 2019, 2018, + /* 310 */ 2017, 2008, 1970, 1745, 1595, 1969, 1968, 1595, 1595, 1595, + /* 320 */ 1595, 1595, 1863, 1862, 1962, 1595, 1595, 1963, 1961, 1960, + /* 330 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 340 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 2120, 2124, 1595, + /* 350 */ 1595, 1595, 1595, 1595, 1595, 2044, 1595, 1595, 1595, 1595, + /* 360 */ 1595, 1944, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 370 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 380 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 390 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 400 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 410 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 420 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 430 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 440 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 450 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 460 */ 1632, 1949, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 470 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 480 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 490 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 500 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1712, 1711, + /* 510 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 520 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 530 */ 1595, 1595, 1953, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 540 */ 1595, 1595, 1595, 1595, 1595, 1595, 2116, 2077, 1595, 1595, + /* 550 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 560 */ 1595, 1944, 1595, 2099, 1595, 1595, 2114, 1595, 2118, 1595, + /* 570 */ 1595, 1595, 1595, 1595, 1595, 1595, 2054, 2050, 1595, 1595, + /* 580 */ 2046, 1595, 1595, 1595, 1595, 1952, 1595, 1595, 1595, 1595, + /* 590 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1943, + /* 600 */ 1595, 2005, 1595, 1595, 1595, 2039, 1595, 1595, 1990, 1595, + /* 610 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1953, 1595, + /* 620 */ 1956, 1595, 1595, 1595, 1595, 1595, 1777, 1595, 1595, 1595, + /* 630 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1762, + /* 640 */ 1760, 1759, 1758, 1595, 1755, 1595, 1790, 1595, 1595, 1595, + /* 650 */ 1786, 1785, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 660 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1692, 1595, 1595, + /* 670 */ 1595, 1595, 1595, 1595, 1595, 1595, 1684, 1595, 1683, 1595, + /* 680 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 690 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 700 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, + /* 710 */ 1595, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1754,83 +1760,85 @@ static const char *const yyTokenName[] = { /* 377 */ "tag_list_opt", /* 378 */ "tag_item", /* 379 */ "column_alias", - /* 380 */ "index_options", - /* 381 */ "func_list", - /* 382 */ "sliding_opt", - /* 383 */ "sma_stream_opt", - /* 384 */ "func", - /* 385 */ "query_or_subquery", - /* 386 */ "cgroup_name", - /* 387 */ "analyze_opt", - /* 388 */ "explain_options", - /* 389 */ "agg_func_opt", - /* 390 */ "bufsize_opt", - /* 391 */ "stream_name", - /* 392 */ "stream_options", - /* 393 */ "subtable_opt", - /* 394 */ "expression", - /* 395 */ "dnode_list", - /* 396 */ "where_clause_opt", - /* 397 */ "signed", - /* 398 */ "literal_func", - /* 399 */ "literal_list", - /* 400 */ "table_alias", - /* 401 */ "expr_or_subquery", - /* 402 */ "pseudo_column", - /* 403 */ "column_reference", - /* 404 */ "function_expression", - /* 405 */ "case_when_expression", - /* 406 */ "star_func", - /* 407 */ "star_func_para_list", - /* 408 */ "noarg_func", - /* 409 */ "other_para_list", - /* 410 */ "star_func_para", - /* 411 */ "when_then_list", - /* 412 */ "case_when_else_opt", - /* 413 */ "common_expression", - /* 414 */ "when_then_expr", - /* 415 */ "predicate", - /* 416 */ "compare_op", - /* 417 */ "in_op", - /* 418 */ "in_predicate_value", - /* 419 */ "boolean_value_expression", - /* 420 */ "boolean_primary", - /* 421 */ "from_clause_opt", - /* 422 */ "table_reference_list", - /* 423 */ "table_reference", - /* 424 */ "table_primary", - /* 425 */ "joined_table", - /* 426 */ "alias_opt", - /* 427 */ "subquery", - /* 428 */ "parenthesized_joined_table", - /* 429 */ "join_type", - /* 430 */ "search_condition", - /* 431 */ "query_specification", - /* 432 */ "set_quantifier_opt", - /* 433 */ "select_list", - /* 434 */ "partition_by_clause_opt", - /* 435 */ "range_opt", - /* 436 */ "every_opt", - /* 437 */ "fill_opt", - /* 438 */ "twindow_clause_opt", - /* 439 */ "group_by_clause_opt", - /* 440 */ "having_clause_opt", - /* 441 */ "select_item", - /* 442 */ "partition_list", - /* 443 */ "partition_item", - /* 444 */ "fill_mode", - /* 445 */ "group_by_list", - /* 446 */ "query_expression", - /* 447 */ "query_simple", - /* 448 */ "order_by_clause_opt", - /* 449 */ "slimit_clause_opt", - /* 450 */ "limit_clause_opt", - /* 451 */ "union_query_expression", - /* 452 */ "query_simple_or_subquery", - /* 453 */ "sort_specification_list", - /* 454 */ "sort_specification", - /* 455 */ "ordering_specification_opt", - /* 456 */ "null_ordering_opt", + /* 380 */ "full_index_name", + /* 381 */ "index_options", + /* 382 */ "index_name", + /* 383 */ "func_list", + /* 384 */ "sliding_opt", + /* 385 */ "sma_stream_opt", + /* 386 */ "func", + /* 387 */ "query_or_subquery", + /* 388 */ "cgroup_name", + /* 389 */ "analyze_opt", + /* 390 */ "explain_options", + /* 391 */ "agg_func_opt", + /* 392 */ "bufsize_opt", + /* 393 */ "stream_name", + /* 394 */ "stream_options", + /* 395 */ "subtable_opt", + /* 396 */ "expression", + /* 397 */ "dnode_list", + /* 398 */ "where_clause_opt", + /* 399 */ "signed", + /* 400 */ "literal_func", + /* 401 */ "literal_list", + /* 402 */ "table_alias", + /* 403 */ "expr_or_subquery", + /* 404 */ "pseudo_column", + /* 405 */ "column_reference", + /* 406 */ "function_expression", + /* 407 */ "case_when_expression", + /* 408 */ "star_func", + /* 409 */ "star_func_para_list", + /* 410 */ "noarg_func", + /* 411 */ "other_para_list", + /* 412 */ "star_func_para", + /* 413 */ "when_then_list", + /* 414 */ "case_when_else_opt", + /* 415 */ "common_expression", + /* 416 */ "when_then_expr", + /* 417 */ "predicate", + /* 418 */ "compare_op", + /* 419 */ "in_op", + /* 420 */ "in_predicate_value", + /* 421 */ "boolean_value_expression", + /* 422 */ "boolean_primary", + /* 423 */ "from_clause_opt", + /* 424 */ "table_reference_list", + /* 425 */ "table_reference", + /* 426 */ "table_primary", + /* 427 */ "joined_table", + /* 428 */ "alias_opt", + /* 429 */ "subquery", + /* 430 */ "parenthesized_joined_table", + /* 431 */ "join_type", + /* 432 */ "search_condition", + /* 433 */ "query_specification", + /* 434 */ "set_quantifier_opt", + /* 435 */ "select_list", + /* 436 */ "partition_by_clause_opt", + /* 437 */ "range_opt", + /* 438 */ "every_opt", + /* 439 */ "fill_opt", + /* 440 */ "twindow_clause_opt", + /* 441 */ "group_by_clause_opt", + /* 442 */ "having_clause_opt", + /* 443 */ "select_item", + /* 444 */ "partition_list", + /* 445 */ "partition_item", + /* 446 */ "fill_mode", + /* 447 */ "group_by_list", + /* 448 */ "query_expression", + /* 449 */ "query_simple", + /* 450 */ "order_by_clause_opt", + /* 451 */ "slimit_clause_opt", + /* 452 */ "limit_clause_opt", + /* 453 */ "union_query_expression", + /* 454 */ "query_simple_or_subquery", + /* 455 */ "sort_specification_list", + /* 456 */ "sort_specification", + /* 457 */ "ordering_specification_opt", + /* 458 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -2098,284 +2106,287 @@ static const char *const yyRuleName[] = { /* 257 */ "tag_item ::= column_name", /* 258 */ "tag_item ::= column_name column_alias", /* 259 */ "tag_item ::= column_name AS column_alias", - /* 260 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options", - /* 261 */ "cmd ::= DROP INDEX exists_opt full_table_name", - /* 262 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 263 */ "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", - /* 264 */ "func_list ::= func", - /* 265 */ "func_list ::= func_list NK_COMMA func", - /* 266 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 267 */ "sma_stream_opt ::=", - /* 268 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", - /* 269 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", - /* 270 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", - /* 271 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", - /* 272 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", - /* 273 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", - /* 274 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", - /* 275 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", - /* 276 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 277 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 278 */ "cmd ::= DESC full_table_name", - /* 279 */ "cmd ::= DESCRIBE full_table_name", - /* 280 */ "cmd ::= RESET QUERY CACHE", - /* 281 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", - /* 282 */ "analyze_opt ::=", - /* 283 */ "analyze_opt ::= ANALYZE", - /* 284 */ "explain_options ::=", - /* 285 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 286 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 287 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", - /* 288 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 289 */ "agg_func_opt ::=", - /* 290 */ "agg_func_opt ::= AGGREGATE", - /* 291 */ "bufsize_opt ::=", - /* 292 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 293 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery", - /* 294 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 295 */ "stream_options ::=", - /* 296 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 297 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 298 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 299 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 300 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 301 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", - /* 302 */ "subtable_opt ::=", - /* 303 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 304 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 305 */ "cmd ::= KILL QUERY NK_STRING", - /* 306 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 307 */ "cmd ::= BALANCE VGROUP", - /* 308 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 309 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 310 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 311 */ "dnode_list ::= DNODE NK_INTEGER", - /* 312 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 313 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 314 */ "cmd ::= query_or_subquery", - /* 315 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 316 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", - /* 317 */ "literal ::= NK_INTEGER", - /* 318 */ "literal ::= NK_FLOAT", - /* 319 */ "literal ::= NK_STRING", - /* 320 */ "literal ::= NK_BOOL", - /* 321 */ "literal ::= TIMESTAMP NK_STRING", - /* 322 */ "literal ::= duration_literal", - /* 323 */ "literal ::= NULL", - /* 324 */ "literal ::= NK_QUESTION", - /* 325 */ "duration_literal ::= NK_VARIABLE", - /* 326 */ "signed ::= NK_INTEGER", - /* 327 */ "signed ::= NK_PLUS NK_INTEGER", - /* 328 */ "signed ::= NK_MINUS NK_INTEGER", - /* 329 */ "signed ::= NK_FLOAT", - /* 330 */ "signed ::= NK_PLUS NK_FLOAT", - /* 331 */ "signed ::= NK_MINUS NK_FLOAT", - /* 332 */ "signed_literal ::= signed", - /* 333 */ "signed_literal ::= NK_STRING", - /* 334 */ "signed_literal ::= NK_BOOL", - /* 335 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 336 */ "signed_literal ::= duration_literal", - /* 337 */ "signed_literal ::= NULL", - /* 338 */ "signed_literal ::= literal_func", - /* 339 */ "signed_literal ::= NK_QUESTION", - /* 340 */ "literal_list ::= signed_literal", - /* 341 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 342 */ "db_name ::= NK_ID", - /* 343 */ "table_name ::= NK_ID", - /* 344 */ "column_name ::= NK_ID", - /* 345 */ "function_name ::= NK_ID", - /* 346 */ "table_alias ::= NK_ID", - /* 347 */ "column_alias ::= NK_ID", - /* 348 */ "user_name ::= NK_ID", - /* 349 */ "topic_name ::= NK_ID", - /* 350 */ "stream_name ::= NK_ID", - /* 351 */ "cgroup_name ::= NK_ID", - /* 352 */ "expr_or_subquery ::= expression", - /* 353 */ "expression ::= literal", - /* 354 */ "expression ::= pseudo_column", - /* 355 */ "expression ::= column_reference", - /* 356 */ "expression ::= function_expression", - /* 357 */ "expression ::= case_when_expression", - /* 358 */ "expression ::= NK_LP expression NK_RP", - /* 359 */ "expression ::= NK_PLUS expr_or_subquery", - /* 360 */ "expression ::= NK_MINUS expr_or_subquery", - /* 361 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 362 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 363 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 364 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 365 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 366 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 367 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 368 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 369 */ "expression_list ::= expr_or_subquery", - /* 370 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 371 */ "column_reference ::= column_name", - /* 372 */ "column_reference ::= table_name NK_DOT column_name", - /* 373 */ "pseudo_column ::= ROWTS", - /* 374 */ "pseudo_column ::= TBNAME", - /* 375 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 376 */ "pseudo_column ::= QSTART", - /* 377 */ "pseudo_column ::= QEND", - /* 378 */ "pseudo_column ::= QDURATION", - /* 379 */ "pseudo_column ::= WSTART", - /* 380 */ "pseudo_column ::= WEND", - /* 381 */ "pseudo_column ::= WDURATION", - /* 382 */ "pseudo_column ::= IROWTS", - /* 383 */ "pseudo_column ::= QTAGS", - /* 384 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 385 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 386 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 387 */ "function_expression ::= literal_func", - /* 388 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 389 */ "literal_func ::= NOW", - /* 390 */ "noarg_func ::= NOW", - /* 391 */ "noarg_func ::= TODAY", - /* 392 */ "noarg_func ::= TIMEZONE", - /* 393 */ "noarg_func ::= DATABASE", - /* 394 */ "noarg_func ::= CLIENT_VERSION", - /* 395 */ "noarg_func ::= SERVER_VERSION", - /* 396 */ "noarg_func ::= SERVER_STATUS", - /* 397 */ "noarg_func ::= CURRENT_USER", - /* 398 */ "noarg_func ::= USER", - /* 399 */ "star_func ::= COUNT", - /* 400 */ "star_func ::= FIRST", - /* 401 */ "star_func ::= LAST", - /* 402 */ "star_func ::= LAST_ROW", - /* 403 */ "star_func_para_list ::= NK_STAR", - /* 404 */ "star_func_para_list ::= other_para_list", - /* 405 */ "other_para_list ::= star_func_para", - /* 406 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 407 */ "star_func_para ::= expr_or_subquery", - /* 408 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 409 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 410 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 411 */ "when_then_list ::= when_then_expr", - /* 412 */ "when_then_list ::= when_then_list when_then_expr", - /* 413 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 414 */ "case_when_else_opt ::=", - /* 415 */ "case_when_else_opt ::= ELSE common_expression", - /* 416 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 417 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 418 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 419 */ "predicate ::= expr_or_subquery IS NULL", - /* 420 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 421 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 422 */ "compare_op ::= NK_LT", - /* 423 */ "compare_op ::= NK_GT", - /* 424 */ "compare_op ::= NK_LE", - /* 425 */ "compare_op ::= NK_GE", - /* 426 */ "compare_op ::= NK_NE", - /* 427 */ "compare_op ::= NK_EQ", - /* 428 */ "compare_op ::= LIKE", - /* 429 */ "compare_op ::= NOT LIKE", - /* 430 */ "compare_op ::= MATCH", - /* 431 */ "compare_op ::= NMATCH", - /* 432 */ "compare_op ::= CONTAINS", - /* 433 */ "in_op ::= IN", - /* 434 */ "in_op ::= NOT IN", - /* 435 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 436 */ "boolean_value_expression ::= boolean_primary", - /* 437 */ "boolean_value_expression ::= NOT boolean_primary", - /* 438 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 439 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 440 */ "boolean_primary ::= predicate", - /* 441 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 442 */ "common_expression ::= expr_or_subquery", - /* 443 */ "common_expression ::= boolean_value_expression", - /* 444 */ "from_clause_opt ::=", - /* 445 */ "from_clause_opt ::= FROM table_reference_list", - /* 446 */ "table_reference_list ::= table_reference", - /* 447 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 448 */ "table_reference ::= table_primary", - /* 449 */ "table_reference ::= joined_table", - /* 450 */ "table_primary ::= table_name alias_opt", - /* 451 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 452 */ "table_primary ::= subquery alias_opt", - /* 453 */ "table_primary ::= parenthesized_joined_table", - /* 454 */ "alias_opt ::=", - /* 455 */ "alias_opt ::= table_alias", - /* 456 */ "alias_opt ::= AS table_alias", - /* 457 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 458 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 459 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 460 */ "join_type ::=", - /* 461 */ "join_type ::= INNER", - /* 462 */ "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", - /* 463 */ "set_quantifier_opt ::=", - /* 464 */ "set_quantifier_opt ::= DISTINCT", - /* 465 */ "set_quantifier_opt ::= ALL", - /* 466 */ "select_list ::= select_item", - /* 467 */ "select_list ::= select_list NK_COMMA select_item", - /* 468 */ "select_item ::= NK_STAR", - /* 469 */ "select_item ::= common_expression", - /* 470 */ "select_item ::= common_expression column_alias", - /* 471 */ "select_item ::= common_expression AS column_alias", - /* 472 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 473 */ "where_clause_opt ::=", - /* 474 */ "where_clause_opt ::= WHERE search_condition", - /* 475 */ "partition_by_clause_opt ::=", - /* 476 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 477 */ "partition_list ::= partition_item", - /* 478 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 479 */ "partition_item ::= expr_or_subquery", - /* 480 */ "partition_item ::= expr_or_subquery column_alias", - /* 481 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 482 */ "twindow_clause_opt ::=", - /* 483 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 484 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 485 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 486 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 487 */ "sliding_opt ::=", - /* 488 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 489 */ "fill_opt ::=", - /* 490 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 491 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 492 */ "fill_mode ::= NONE", - /* 493 */ "fill_mode ::= PREV", - /* 494 */ "fill_mode ::= NULL", - /* 495 */ "fill_mode ::= LINEAR", - /* 496 */ "fill_mode ::= NEXT", - /* 497 */ "group_by_clause_opt ::=", - /* 498 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 499 */ "group_by_list ::= expr_or_subquery", - /* 500 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 501 */ "having_clause_opt ::=", - /* 502 */ "having_clause_opt ::= HAVING search_condition", - /* 503 */ "range_opt ::=", - /* 504 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 505 */ "every_opt ::=", - /* 506 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 507 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 508 */ "query_simple ::= query_specification", - /* 509 */ "query_simple ::= union_query_expression", - /* 510 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 511 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 512 */ "query_simple_or_subquery ::= query_simple", - /* 513 */ "query_simple_or_subquery ::= subquery", - /* 514 */ "query_or_subquery ::= query_expression", - /* 515 */ "query_or_subquery ::= subquery", - /* 516 */ "order_by_clause_opt ::=", - /* 517 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 518 */ "slimit_clause_opt ::=", - /* 519 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 520 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 521 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 522 */ "limit_clause_opt ::=", - /* 523 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 524 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 525 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 526 */ "subquery ::= NK_LP query_expression NK_RP", - /* 527 */ "subquery ::= NK_LP subquery NK_RP", - /* 528 */ "search_condition ::= common_expression", - /* 529 */ "sort_specification_list ::= sort_specification", - /* 530 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 531 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 532 */ "ordering_specification_opt ::=", - /* 533 */ "ordering_specification_opt ::= ASC", - /* 534 */ "ordering_specification_opt ::= DESC", - /* 535 */ "null_ordering_opt ::=", - /* 536 */ "null_ordering_opt ::= NULLS FIRST", - /* 537 */ "null_ordering_opt ::= NULLS LAST", + /* 260 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options", + /* 261 */ "cmd ::= DROP INDEX exists_opt full_index_name", + /* 262 */ "full_index_name ::= index_name", + /* 263 */ "full_index_name ::= db_name NK_DOT index_name", + /* 264 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 265 */ "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", + /* 266 */ "func_list ::= func", + /* 267 */ "func_list ::= func_list NK_COMMA func", + /* 268 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 269 */ "sma_stream_opt ::=", + /* 270 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", + /* 271 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", + /* 272 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", + /* 273 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", + /* 274 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", + /* 275 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", + /* 276 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", + /* 277 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", + /* 278 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 279 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 280 */ "cmd ::= DESC full_table_name", + /* 281 */ "cmd ::= DESCRIBE full_table_name", + /* 282 */ "cmd ::= RESET QUERY CACHE", + /* 283 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", + /* 284 */ "analyze_opt ::=", + /* 285 */ "analyze_opt ::= ANALYZE", + /* 286 */ "explain_options ::=", + /* 287 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 288 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 289 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 290 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 291 */ "agg_func_opt ::=", + /* 292 */ "agg_func_opt ::= AGGREGATE", + /* 293 */ "bufsize_opt ::=", + /* 294 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 295 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery", + /* 296 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 297 */ "stream_options ::=", + /* 298 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 299 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 300 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 301 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 302 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", + /* 303 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", + /* 304 */ "subtable_opt ::=", + /* 305 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 306 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 307 */ "cmd ::= KILL QUERY NK_STRING", + /* 308 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 309 */ "cmd ::= BALANCE VGROUP", + /* 310 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 311 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 312 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 313 */ "dnode_list ::= DNODE NK_INTEGER", + /* 314 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 315 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 316 */ "cmd ::= query_or_subquery", + /* 317 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 318 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", + /* 319 */ "literal ::= NK_INTEGER", + /* 320 */ "literal ::= NK_FLOAT", + /* 321 */ "literal ::= NK_STRING", + /* 322 */ "literal ::= NK_BOOL", + /* 323 */ "literal ::= TIMESTAMP NK_STRING", + /* 324 */ "literal ::= duration_literal", + /* 325 */ "literal ::= NULL", + /* 326 */ "literal ::= NK_QUESTION", + /* 327 */ "duration_literal ::= NK_VARIABLE", + /* 328 */ "signed ::= NK_INTEGER", + /* 329 */ "signed ::= NK_PLUS NK_INTEGER", + /* 330 */ "signed ::= NK_MINUS NK_INTEGER", + /* 331 */ "signed ::= NK_FLOAT", + /* 332 */ "signed ::= NK_PLUS NK_FLOAT", + /* 333 */ "signed ::= NK_MINUS NK_FLOAT", + /* 334 */ "signed_literal ::= signed", + /* 335 */ "signed_literal ::= NK_STRING", + /* 336 */ "signed_literal ::= NK_BOOL", + /* 337 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 338 */ "signed_literal ::= duration_literal", + /* 339 */ "signed_literal ::= NULL", + /* 340 */ "signed_literal ::= literal_func", + /* 341 */ "signed_literal ::= NK_QUESTION", + /* 342 */ "literal_list ::= signed_literal", + /* 343 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 344 */ "db_name ::= NK_ID", + /* 345 */ "table_name ::= NK_ID", + /* 346 */ "column_name ::= NK_ID", + /* 347 */ "function_name ::= NK_ID", + /* 348 */ "table_alias ::= NK_ID", + /* 349 */ "column_alias ::= NK_ID", + /* 350 */ "user_name ::= NK_ID", + /* 351 */ "topic_name ::= NK_ID", + /* 352 */ "stream_name ::= NK_ID", + /* 353 */ "cgroup_name ::= NK_ID", + /* 354 */ "index_name ::= NK_ID", + /* 355 */ "expr_or_subquery ::= expression", + /* 356 */ "expression ::= literal", + /* 357 */ "expression ::= pseudo_column", + /* 358 */ "expression ::= column_reference", + /* 359 */ "expression ::= function_expression", + /* 360 */ "expression ::= case_when_expression", + /* 361 */ "expression ::= NK_LP expression NK_RP", + /* 362 */ "expression ::= NK_PLUS expr_or_subquery", + /* 363 */ "expression ::= NK_MINUS expr_or_subquery", + /* 364 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 365 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 366 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 367 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 368 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 369 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 370 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 371 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 372 */ "expression_list ::= expr_or_subquery", + /* 373 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 374 */ "column_reference ::= column_name", + /* 375 */ "column_reference ::= table_name NK_DOT column_name", + /* 376 */ "pseudo_column ::= ROWTS", + /* 377 */ "pseudo_column ::= TBNAME", + /* 378 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 379 */ "pseudo_column ::= QSTART", + /* 380 */ "pseudo_column ::= QEND", + /* 381 */ "pseudo_column ::= QDURATION", + /* 382 */ "pseudo_column ::= WSTART", + /* 383 */ "pseudo_column ::= WEND", + /* 384 */ "pseudo_column ::= WDURATION", + /* 385 */ "pseudo_column ::= IROWTS", + /* 386 */ "pseudo_column ::= QTAGS", + /* 387 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 388 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 389 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 390 */ "function_expression ::= literal_func", + /* 391 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 392 */ "literal_func ::= NOW", + /* 393 */ "noarg_func ::= NOW", + /* 394 */ "noarg_func ::= TODAY", + /* 395 */ "noarg_func ::= TIMEZONE", + /* 396 */ "noarg_func ::= DATABASE", + /* 397 */ "noarg_func ::= CLIENT_VERSION", + /* 398 */ "noarg_func ::= SERVER_VERSION", + /* 399 */ "noarg_func ::= SERVER_STATUS", + /* 400 */ "noarg_func ::= CURRENT_USER", + /* 401 */ "noarg_func ::= USER", + /* 402 */ "star_func ::= COUNT", + /* 403 */ "star_func ::= FIRST", + /* 404 */ "star_func ::= LAST", + /* 405 */ "star_func ::= LAST_ROW", + /* 406 */ "star_func_para_list ::= NK_STAR", + /* 407 */ "star_func_para_list ::= other_para_list", + /* 408 */ "other_para_list ::= star_func_para", + /* 409 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 410 */ "star_func_para ::= expr_or_subquery", + /* 411 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 412 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 413 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 414 */ "when_then_list ::= when_then_expr", + /* 415 */ "when_then_list ::= when_then_list when_then_expr", + /* 416 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 417 */ "case_when_else_opt ::=", + /* 418 */ "case_when_else_opt ::= ELSE common_expression", + /* 419 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 420 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 421 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 422 */ "predicate ::= expr_or_subquery IS NULL", + /* 423 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 424 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 425 */ "compare_op ::= NK_LT", + /* 426 */ "compare_op ::= NK_GT", + /* 427 */ "compare_op ::= NK_LE", + /* 428 */ "compare_op ::= NK_GE", + /* 429 */ "compare_op ::= NK_NE", + /* 430 */ "compare_op ::= NK_EQ", + /* 431 */ "compare_op ::= LIKE", + /* 432 */ "compare_op ::= NOT LIKE", + /* 433 */ "compare_op ::= MATCH", + /* 434 */ "compare_op ::= NMATCH", + /* 435 */ "compare_op ::= CONTAINS", + /* 436 */ "in_op ::= IN", + /* 437 */ "in_op ::= NOT IN", + /* 438 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 439 */ "boolean_value_expression ::= boolean_primary", + /* 440 */ "boolean_value_expression ::= NOT boolean_primary", + /* 441 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 442 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 443 */ "boolean_primary ::= predicate", + /* 444 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 445 */ "common_expression ::= expr_or_subquery", + /* 446 */ "common_expression ::= boolean_value_expression", + /* 447 */ "from_clause_opt ::=", + /* 448 */ "from_clause_opt ::= FROM table_reference_list", + /* 449 */ "table_reference_list ::= table_reference", + /* 450 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 451 */ "table_reference ::= table_primary", + /* 452 */ "table_reference ::= joined_table", + /* 453 */ "table_primary ::= table_name alias_opt", + /* 454 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 455 */ "table_primary ::= subquery alias_opt", + /* 456 */ "table_primary ::= parenthesized_joined_table", + /* 457 */ "alias_opt ::=", + /* 458 */ "alias_opt ::= table_alias", + /* 459 */ "alias_opt ::= AS table_alias", + /* 460 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 461 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 462 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 463 */ "join_type ::=", + /* 464 */ "join_type ::= INNER", + /* 465 */ "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", + /* 466 */ "set_quantifier_opt ::=", + /* 467 */ "set_quantifier_opt ::= DISTINCT", + /* 468 */ "set_quantifier_opt ::= ALL", + /* 469 */ "select_list ::= select_item", + /* 470 */ "select_list ::= select_list NK_COMMA select_item", + /* 471 */ "select_item ::= NK_STAR", + /* 472 */ "select_item ::= common_expression", + /* 473 */ "select_item ::= common_expression column_alias", + /* 474 */ "select_item ::= common_expression AS column_alias", + /* 475 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 476 */ "where_clause_opt ::=", + /* 477 */ "where_clause_opt ::= WHERE search_condition", + /* 478 */ "partition_by_clause_opt ::=", + /* 479 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 480 */ "partition_list ::= partition_item", + /* 481 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 482 */ "partition_item ::= expr_or_subquery", + /* 483 */ "partition_item ::= expr_or_subquery column_alias", + /* 484 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 485 */ "twindow_clause_opt ::=", + /* 486 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 487 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 488 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 489 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 490 */ "sliding_opt ::=", + /* 491 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 492 */ "fill_opt ::=", + /* 493 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 494 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 495 */ "fill_mode ::= NONE", + /* 496 */ "fill_mode ::= PREV", + /* 497 */ "fill_mode ::= NULL", + /* 498 */ "fill_mode ::= LINEAR", + /* 499 */ "fill_mode ::= NEXT", + /* 500 */ "group_by_clause_opt ::=", + /* 501 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 502 */ "group_by_list ::= expr_or_subquery", + /* 503 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 504 */ "having_clause_opt ::=", + /* 505 */ "having_clause_opt ::= HAVING search_condition", + /* 506 */ "range_opt ::=", + /* 507 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 508 */ "every_opt ::=", + /* 509 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 510 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 511 */ "query_simple ::= query_specification", + /* 512 */ "query_simple ::= union_query_expression", + /* 513 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 514 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 515 */ "query_simple_or_subquery ::= query_simple", + /* 516 */ "query_simple_or_subquery ::= subquery", + /* 517 */ "query_or_subquery ::= query_expression", + /* 518 */ "query_or_subquery ::= subquery", + /* 519 */ "order_by_clause_opt ::=", + /* 520 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 521 */ "slimit_clause_opt ::=", + /* 522 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 523 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 524 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 525 */ "limit_clause_opt ::=", + /* 526 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 527 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 528 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 529 */ "subquery ::= NK_LP query_expression NK_RP", + /* 530 */ "subquery ::= NK_LP subquery NK_RP", + /* 531 */ "search_condition ::= common_expression", + /* 532 */ "sort_specification_list ::= sort_specification", + /* 533 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 534 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 535 */ "ordering_specification_opt ::=", + /* 536 */ "ordering_specification_opt ::= ASC", + /* 537 */ "ordering_specification_opt ::= DESC", + /* 538 */ "null_ordering_opt ::=", + /* 539 */ "null_ordering_opt ::= NULLS FIRST", + /* 540 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2523,63 +2534,64 @@ static void yy_destructor( case 375: /* table_name_cond */ case 376: /* from_db_opt */ case 378: /* tag_item */ - case 380: /* index_options */ - case 382: /* sliding_opt */ - case 383: /* sma_stream_opt */ - case 384: /* func */ - case 385: /* query_or_subquery */ - case 388: /* explain_options */ - case 392: /* stream_options */ - case 393: /* subtable_opt */ - case 394: /* expression */ - case 396: /* where_clause_opt */ - case 397: /* signed */ - case 398: /* literal_func */ - case 401: /* expr_or_subquery */ - case 402: /* pseudo_column */ - case 403: /* column_reference */ - case 404: /* function_expression */ - case 405: /* case_when_expression */ - case 410: /* star_func_para */ - case 412: /* case_when_else_opt */ - case 413: /* common_expression */ - case 414: /* when_then_expr */ - case 415: /* predicate */ - case 418: /* in_predicate_value */ - case 419: /* boolean_value_expression */ - case 420: /* boolean_primary */ - case 421: /* from_clause_opt */ - case 422: /* table_reference_list */ - case 423: /* table_reference */ - case 424: /* table_primary */ - case 425: /* joined_table */ - case 427: /* subquery */ - case 428: /* parenthesized_joined_table */ - case 430: /* search_condition */ - case 431: /* query_specification */ - case 435: /* range_opt */ - case 436: /* every_opt */ - case 437: /* fill_opt */ - case 438: /* twindow_clause_opt */ - case 440: /* having_clause_opt */ - case 441: /* select_item */ - case 443: /* partition_item */ - case 446: /* query_expression */ - case 447: /* query_simple */ - case 449: /* slimit_clause_opt */ - case 450: /* limit_clause_opt */ - case 451: /* union_query_expression */ - case 452: /* query_simple_or_subquery */ - case 454: /* sort_specification */ + case 380: /* full_index_name */ + case 381: /* index_options */ + case 384: /* sliding_opt */ + case 385: /* sma_stream_opt */ + case 386: /* func */ + case 387: /* query_or_subquery */ + case 390: /* explain_options */ + case 394: /* stream_options */ + case 395: /* subtable_opt */ + case 396: /* expression */ + case 398: /* where_clause_opt */ + case 399: /* signed */ + case 400: /* literal_func */ + case 403: /* expr_or_subquery */ + case 404: /* pseudo_column */ + case 405: /* column_reference */ + case 406: /* function_expression */ + case 407: /* case_when_expression */ + case 412: /* star_func_para */ + case 414: /* case_when_else_opt */ + case 415: /* common_expression */ + case 416: /* when_then_expr */ + case 417: /* predicate */ + case 420: /* in_predicate_value */ + case 421: /* boolean_value_expression */ + case 422: /* boolean_primary */ + case 423: /* from_clause_opt */ + case 424: /* table_reference_list */ + case 425: /* table_reference */ + case 426: /* table_primary */ + case 427: /* joined_table */ + case 429: /* subquery */ + case 430: /* parenthesized_joined_table */ + case 432: /* search_condition */ + case 433: /* query_specification */ + case 437: /* range_opt */ + case 438: /* every_opt */ + case 439: /* fill_opt */ + case 440: /* twindow_clause_opt */ + case 442: /* having_clause_opt */ + case 443: /* select_item */ + case 445: /* partition_item */ + case 448: /* query_expression */ + case 449: /* query_simple */ + case 451: /* slimit_clause_opt */ + case 452: /* limit_clause_opt */ + case 453: /* union_query_expression */ + case 454: /* query_simple_or_subquery */ + case 456: /* sort_specification */ { - nodesDestroyNode((yypminor->yy148)); + nodesDestroyNode((yypminor->yy74)); } break; case 323: /* account_options */ case 324: /* alter_account_options */ case 326: /* alter_account_option */ case 341: /* speed_opt */ - case 390: /* bufsize_opt */ + case 392: /* bufsize_opt */ { } @@ -2593,12 +2605,13 @@ static void yy_destructor( case 364: /* table_name */ case 371: /* function_name */ case 379: /* column_alias */ - case 386: /* cgroup_name */ - case 391: /* stream_name */ - case 400: /* table_alias */ - case 406: /* star_func */ - case 408: /* noarg_func */ - case 426: /* alias_opt */ + case 382: /* index_name */ + case 388: /* cgroup_name */ + case 393: /* stream_name */ + case 402: /* table_alias */ + case 408: /* star_func */ + case 410: /* noarg_func */ + case 428: /* alias_opt */ { } @@ -2618,9 +2631,9 @@ static void yy_destructor( case 336: /* force_opt */ case 337: /* not_exists_opt */ case 339: /* exists_opt */ - case 387: /* analyze_opt */ - case 389: /* agg_func_opt */ - case 432: /* set_quantifier_opt */ + case 389: /* analyze_opt */ + case 391: /* agg_func_opt */ + case 434: /* set_quantifier_opt */ { } @@ -2639,21 +2652,21 @@ static void yy_destructor( case 366: /* duration_list */ case 367: /* rollup_func_list */ case 377: /* tag_list_opt */ - case 381: /* func_list */ - case 395: /* dnode_list */ - case 399: /* literal_list */ - case 407: /* star_func_para_list */ - case 409: /* other_para_list */ - case 411: /* when_then_list */ - case 433: /* select_list */ - case 434: /* partition_by_clause_opt */ - case 439: /* group_by_clause_opt */ - case 442: /* partition_list */ - case 445: /* group_by_list */ - case 448: /* order_by_clause_opt */ - case 453: /* sort_specification_list */ + case 383: /* func_list */ + case 397: /* dnode_list */ + case 401: /* literal_list */ + case 409: /* star_func_para_list */ + case 411: /* other_para_list */ + case 413: /* when_then_list */ + case 435: /* select_list */ + case 436: /* partition_by_clause_opt */ + case 441: /* group_by_clause_opt */ + case 444: /* partition_list */ + case 447: /* group_by_list */ + case 450: /* order_by_clause_opt */ + case 455: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy404)); + nodesDestroyList((yypminor->yy874)); } break; case 345: /* alter_db_option */ @@ -2667,28 +2680,28 @@ static void yy_destructor( } break; - case 416: /* compare_op */ - case 417: /* in_op */ + case 418: /* compare_op */ + case 419: /* in_op */ { } break; - case 429: /* join_type */ + case 431: /* join_type */ { } break; - case 444: /* fill_mode */ + case 446: /* fill_mode */ { } break; - case 455: /* ordering_specification_opt */ + case 457: /* ordering_specification_opt */ { } break; - case 456: /* null_ordering_opt */ + case 458: /* null_ordering_opt */ { } @@ -3247,284 +3260,287 @@ static const struct { { 378, -1 }, /* (257) tag_item ::= column_name */ { 378, -2 }, /* (258) tag_item ::= column_name column_alias */ { 378, -3 }, /* (259) tag_item ::= column_name AS column_alias */ - { 322, -8 }, /* (260) cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ - { 322, -4 }, /* (261) cmd ::= DROP INDEX exists_opt full_table_name */ - { 380, -10 }, /* (262) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - { 380, -12 }, /* (263) 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 */ - { 381, -1 }, /* (264) func_list ::= func */ - { 381, -3 }, /* (265) func_list ::= func_list NK_COMMA func */ - { 384, -4 }, /* (266) func ::= function_name NK_LP expression_list NK_RP */ - { 383, 0 }, /* (267) sma_stream_opt ::= */ - { 383, -3 }, /* (268) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - { 383, -3 }, /* (269) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - { 383, -3 }, /* (270) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - { 322, -6 }, /* (271) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - { 322, -7 }, /* (272) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 322, -9 }, /* (273) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ - { 322, -7 }, /* (274) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 322, -9 }, /* (275) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ - { 322, -4 }, /* (276) cmd ::= DROP TOPIC exists_opt topic_name */ - { 322, -7 }, /* (277) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 322, -2 }, /* (278) cmd ::= DESC full_table_name */ - { 322, -2 }, /* (279) cmd ::= DESCRIBE full_table_name */ - { 322, -3 }, /* (280) cmd ::= RESET QUERY CACHE */ - { 322, -4 }, /* (281) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - { 387, 0 }, /* (282) analyze_opt ::= */ - { 387, -1 }, /* (283) analyze_opt ::= ANALYZE */ - { 388, 0 }, /* (284) explain_options ::= */ - { 388, -3 }, /* (285) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 388, -3 }, /* (286) explain_options ::= explain_options RATIO NK_FLOAT */ - { 322, -10 }, /* (287) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 322, -4 }, /* (288) cmd ::= DROP FUNCTION exists_opt function_name */ - { 389, 0 }, /* (289) agg_func_opt ::= */ - { 389, -1 }, /* (290) agg_func_opt ::= AGGREGATE */ - { 390, 0 }, /* (291) bufsize_opt ::= */ - { 390, -2 }, /* (292) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 322, -11 }, /* (293) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery */ - { 322, -4 }, /* (294) cmd ::= DROP STREAM exists_opt stream_name */ - { 392, 0 }, /* (295) stream_options ::= */ - { 392, -3 }, /* (296) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 392, -3 }, /* (297) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 392, -4 }, /* (298) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 392, -3 }, /* (299) stream_options ::= stream_options WATERMARK duration_literal */ - { 392, -4 }, /* (300) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - { 392, -3 }, /* (301) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - { 393, 0 }, /* (302) subtable_opt ::= */ - { 393, -4 }, /* (303) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - { 322, -3 }, /* (304) cmd ::= KILL CONNECTION NK_INTEGER */ - { 322, -3 }, /* (305) cmd ::= KILL QUERY NK_STRING */ - { 322, -3 }, /* (306) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 322, -2 }, /* (307) cmd ::= BALANCE VGROUP */ - { 322, -4 }, /* (308) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 322, -4 }, /* (309) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 322, -3 }, /* (310) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 395, -2 }, /* (311) dnode_list ::= DNODE NK_INTEGER */ - { 395, -3 }, /* (312) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 322, -4 }, /* (313) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 322, -1 }, /* (314) cmd ::= query_or_subquery */ - { 322, -7 }, /* (315) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - { 322, -4 }, /* (316) cmd ::= INSERT INTO full_table_name query_or_subquery */ - { 325, -1 }, /* (317) literal ::= NK_INTEGER */ - { 325, -1 }, /* (318) literal ::= NK_FLOAT */ - { 325, -1 }, /* (319) literal ::= NK_STRING */ - { 325, -1 }, /* (320) literal ::= NK_BOOL */ - { 325, -2 }, /* (321) literal ::= TIMESTAMP NK_STRING */ - { 325, -1 }, /* (322) literal ::= duration_literal */ - { 325, -1 }, /* (323) literal ::= NULL */ - { 325, -1 }, /* (324) literal ::= NK_QUESTION */ - { 369, -1 }, /* (325) duration_literal ::= NK_VARIABLE */ - { 397, -1 }, /* (326) signed ::= NK_INTEGER */ - { 397, -2 }, /* (327) signed ::= NK_PLUS NK_INTEGER */ - { 397, -2 }, /* (328) signed ::= NK_MINUS NK_INTEGER */ - { 397, -1 }, /* (329) signed ::= NK_FLOAT */ - { 397, -2 }, /* (330) signed ::= NK_PLUS NK_FLOAT */ - { 397, -2 }, /* (331) signed ::= NK_MINUS NK_FLOAT */ - { 358, -1 }, /* (332) signed_literal ::= signed */ - { 358, -1 }, /* (333) signed_literal ::= NK_STRING */ - { 358, -1 }, /* (334) signed_literal ::= NK_BOOL */ - { 358, -2 }, /* (335) signed_literal ::= TIMESTAMP NK_STRING */ - { 358, -1 }, /* (336) signed_literal ::= duration_literal */ - { 358, -1 }, /* (337) signed_literal ::= NULL */ - { 358, -1 }, /* (338) signed_literal ::= literal_func */ - { 358, -1 }, /* (339) signed_literal ::= NK_QUESTION */ - { 399, -1 }, /* (340) literal_list ::= signed_literal */ - { 399, -3 }, /* (341) literal_list ::= literal_list NK_COMMA signed_literal */ - { 333, -1 }, /* (342) db_name ::= NK_ID */ - { 364, -1 }, /* (343) table_name ::= NK_ID */ - { 356, -1 }, /* (344) column_name ::= NK_ID */ - { 371, -1 }, /* (345) function_name ::= NK_ID */ - { 400, -1 }, /* (346) table_alias ::= NK_ID */ - { 379, -1 }, /* (347) column_alias ::= NK_ID */ - { 327, -1 }, /* (348) user_name ::= NK_ID */ - { 334, -1 }, /* (349) topic_name ::= NK_ID */ - { 391, -1 }, /* (350) stream_name ::= NK_ID */ - { 386, -1 }, /* (351) cgroup_name ::= NK_ID */ - { 401, -1 }, /* (352) expr_or_subquery ::= expression */ - { 394, -1 }, /* (353) expression ::= literal */ - { 394, -1 }, /* (354) expression ::= pseudo_column */ - { 394, -1 }, /* (355) expression ::= column_reference */ - { 394, -1 }, /* (356) expression ::= function_expression */ - { 394, -1 }, /* (357) expression ::= case_when_expression */ - { 394, -3 }, /* (358) expression ::= NK_LP expression NK_RP */ - { 394, -2 }, /* (359) expression ::= NK_PLUS expr_or_subquery */ - { 394, -2 }, /* (360) expression ::= NK_MINUS expr_or_subquery */ - { 394, -3 }, /* (361) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - { 394, -3 }, /* (362) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - { 394, -3 }, /* (363) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - { 394, -3 }, /* (364) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - { 394, -3 }, /* (365) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - { 394, -3 }, /* (366) expression ::= column_reference NK_ARROW NK_STRING */ - { 394, -3 }, /* (367) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - { 394, -3 }, /* (368) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - { 361, -1 }, /* (369) expression_list ::= expr_or_subquery */ - { 361, -3 }, /* (370) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - { 403, -1 }, /* (371) column_reference ::= column_name */ - { 403, -3 }, /* (372) column_reference ::= table_name NK_DOT column_name */ - { 402, -1 }, /* (373) pseudo_column ::= ROWTS */ - { 402, -1 }, /* (374) pseudo_column ::= TBNAME */ - { 402, -3 }, /* (375) pseudo_column ::= table_name NK_DOT TBNAME */ - { 402, -1 }, /* (376) pseudo_column ::= QSTART */ - { 402, -1 }, /* (377) pseudo_column ::= QEND */ - { 402, -1 }, /* (378) pseudo_column ::= QDURATION */ - { 402, -1 }, /* (379) pseudo_column ::= WSTART */ - { 402, -1 }, /* (380) pseudo_column ::= WEND */ - { 402, -1 }, /* (381) pseudo_column ::= WDURATION */ - { 402, -1 }, /* (382) pseudo_column ::= IROWTS */ - { 402, -1 }, /* (383) pseudo_column ::= QTAGS */ - { 404, -4 }, /* (384) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 404, -4 }, /* (385) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 404, -6 }, /* (386) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - { 404, -1 }, /* (387) function_expression ::= literal_func */ - { 398, -3 }, /* (388) literal_func ::= noarg_func NK_LP NK_RP */ - { 398, -1 }, /* (389) literal_func ::= NOW */ - { 408, -1 }, /* (390) noarg_func ::= NOW */ - { 408, -1 }, /* (391) noarg_func ::= TODAY */ - { 408, -1 }, /* (392) noarg_func ::= TIMEZONE */ - { 408, -1 }, /* (393) noarg_func ::= DATABASE */ - { 408, -1 }, /* (394) noarg_func ::= CLIENT_VERSION */ - { 408, -1 }, /* (395) noarg_func ::= SERVER_VERSION */ - { 408, -1 }, /* (396) noarg_func ::= SERVER_STATUS */ - { 408, -1 }, /* (397) noarg_func ::= CURRENT_USER */ - { 408, -1 }, /* (398) noarg_func ::= USER */ - { 406, -1 }, /* (399) star_func ::= COUNT */ - { 406, -1 }, /* (400) star_func ::= FIRST */ - { 406, -1 }, /* (401) star_func ::= LAST */ - { 406, -1 }, /* (402) star_func ::= LAST_ROW */ - { 407, -1 }, /* (403) star_func_para_list ::= NK_STAR */ - { 407, -1 }, /* (404) star_func_para_list ::= other_para_list */ - { 409, -1 }, /* (405) other_para_list ::= star_func_para */ - { 409, -3 }, /* (406) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 410, -1 }, /* (407) star_func_para ::= expr_or_subquery */ - { 410, -3 }, /* (408) star_func_para ::= table_name NK_DOT NK_STAR */ - { 405, -4 }, /* (409) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - { 405, -5 }, /* (410) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - { 411, -1 }, /* (411) when_then_list ::= when_then_expr */ - { 411, -2 }, /* (412) when_then_list ::= when_then_list when_then_expr */ - { 414, -4 }, /* (413) when_then_expr ::= WHEN common_expression THEN common_expression */ - { 412, 0 }, /* (414) case_when_else_opt ::= */ - { 412, -2 }, /* (415) case_when_else_opt ::= ELSE common_expression */ - { 415, -3 }, /* (416) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - { 415, -5 }, /* (417) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - { 415, -6 }, /* (418) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - { 415, -3 }, /* (419) predicate ::= expr_or_subquery IS NULL */ - { 415, -4 }, /* (420) predicate ::= expr_or_subquery IS NOT NULL */ - { 415, -3 }, /* (421) predicate ::= expr_or_subquery in_op in_predicate_value */ - { 416, -1 }, /* (422) compare_op ::= NK_LT */ - { 416, -1 }, /* (423) compare_op ::= NK_GT */ - { 416, -1 }, /* (424) compare_op ::= NK_LE */ - { 416, -1 }, /* (425) compare_op ::= NK_GE */ - { 416, -1 }, /* (426) compare_op ::= NK_NE */ - { 416, -1 }, /* (427) compare_op ::= NK_EQ */ - { 416, -1 }, /* (428) compare_op ::= LIKE */ - { 416, -2 }, /* (429) compare_op ::= NOT LIKE */ - { 416, -1 }, /* (430) compare_op ::= MATCH */ - { 416, -1 }, /* (431) compare_op ::= NMATCH */ - { 416, -1 }, /* (432) compare_op ::= CONTAINS */ - { 417, -1 }, /* (433) in_op ::= IN */ - { 417, -2 }, /* (434) in_op ::= NOT IN */ - { 418, -3 }, /* (435) in_predicate_value ::= NK_LP literal_list NK_RP */ - { 419, -1 }, /* (436) boolean_value_expression ::= boolean_primary */ - { 419, -2 }, /* (437) boolean_value_expression ::= NOT boolean_primary */ - { 419, -3 }, /* (438) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 419, -3 }, /* (439) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 420, -1 }, /* (440) boolean_primary ::= predicate */ - { 420, -3 }, /* (441) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 413, -1 }, /* (442) common_expression ::= expr_or_subquery */ - { 413, -1 }, /* (443) common_expression ::= boolean_value_expression */ - { 421, 0 }, /* (444) from_clause_opt ::= */ - { 421, -2 }, /* (445) from_clause_opt ::= FROM table_reference_list */ - { 422, -1 }, /* (446) table_reference_list ::= table_reference */ - { 422, -3 }, /* (447) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 423, -1 }, /* (448) table_reference ::= table_primary */ - { 423, -1 }, /* (449) table_reference ::= joined_table */ - { 424, -2 }, /* (450) table_primary ::= table_name alias_opt */ - { 424, -4 }, /* (451) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 424, -2 }, /* (452) table_primary ::= subquery alias_opt */ - { 424, -1 }, /* (453) table_primary ::= parenthesized_joined_table */ - { 426, 0 }, /* (454) alias_opt ::= */ - { 426, -1 }, /* (455) alias_opt ::= table_alias */ - { 426, -2 }, /* (456) alias_opt ::= AS table_alias */ - { 428, -3 }, /* (457) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 428, -3 }, /* (458) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 425, -6 }, /* (459) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 429, 0 }, /* (460) join_type ::= */ - { 429, -1 }, /* (461) join_type ::= INNER */ - { 431, -12 }, /* (462) 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 */ - { 432, 0 }, /* (463) set_quantifier_opt ::= */ - { 432, -1 }, /* (464) set_quantifier_opt ::= DISTINCT */ - { 432, -1 }, /* (465) set_quantifier_opt ::= ALL */ - { 433, -1 }, /* (466) select_list ::= select_item */ - { 433, -3 }, /* (467) select_list ::= select_list NK_COMMA select_item */ - { 441, -1 }, /* (468) select_item ::= NK_STAR */ - { 441, -1 }, /* (469) select_item ::= common_expression */ - { 441, -2 }, /* (470) select_item ::= common_expression column_alias */ - { 441, -3 }, /* (471) select_item ::= common_expression AS column_alias */ - { 441, -3 }, /* (472) select_item ::= table_name NK_DOT NK_STAR */ - { 396, 0 }, /* (473) where_clause_opt ::= */ - { 396, -2 }, /* (474) where_clause_opt ::= WHERE search_condition */ - { 434, 0 }, /* (475) partition_by_clause_opt ::= */ - { 434, -3 }, /* (476) partition_by_clause_opt ::= PARTITION BY partition_list */ - { 442, -1 }, /* (477) partition_list ::= partition_item */ - { 442, -3 }, /* (478) partition_list ::= partition_list NK_COMMA partition_item */ - { 443, -1 }, /* (479) partition_item ::= expr_or_subquery */ - { 443, -2 }, /* (480) partition_item ::= expr_or_subquery column_alias */ - { 443, -3 }, /* (481) partition_item ::= expr_or_subquery AS column_alias */ - { 438, 0 }, /* (482) twindow_clause_opt ::= */ - { 438, -6 }, /* (483) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 438, -4 }, /* (484) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - { 438, -6 }, /* (485) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 438, -8 }, /* (486) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 382, 0 }, /* (487) sliding_opt ::= */ - { 382, -4 }, /* (488) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 437, 0 }, /* (489) fill_opt ::= */ - { 437, -4 }, /* (490) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 437, -6 }, /* (491) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 444, -1 }, /* (492) fill_mode ::= NONE */ - { 444, -1 }, /* (493) fill_mode ::= PREV */ - { 444, -1 }, /* (494) fill_mode ::= NULL */ - { 444, -1 }, /* (495) fill_mode ::= LINEAR */ - { 444, -1 }, /* (496) fill_mode ::= NEXT */ - { 439, 0 }, /* (497) group_by_clause_opt ::= */ - { 439, -3 }, /* (498) group_by_clause_opt ::= GROUP BY group_by_list */ - { 445, -1 }, /* (499) group_by_list ::= expr_or_subquery */ - { 445, -3 }, /* (500) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - { 440, 0 }, /* (501) having_clause_opt ::= */ - { 440, -2 }, /* (502) having_clause_opt ::= HAVING search_condition */ - { 435, 0 }, /* (503) range_opt ::= */ - { 435, -6 }, /* (504) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - { 436, 0 }, /* (505) every_opt ::= */ - { 436, -4 }, /* (506) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 446, -4 }, /* (507) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 447, -1 }, /* (508) query_simple ::= query_specification */ - { 447, -1 }, /* (509) query_simple ::= union_query_expression */ - { 451, -4 }, /* (510) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - { 451, -3 }, /* (511) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - { 452, -1 }, /* (512) query_simple_or_subquery ::= query_simple */ - { 452, -1 }, /* (513) query_simple_or_subquery ::= subquery */ - { 385, -1 }, /* (514) query_or_subquery ::= query_expression */ - { 385, -1 }, /* (515) query_or_subquery ::= subquery */ - { 448, 0 }, /* (516) order_by_clause_opt ::= */ - { 448, -3 }, /* (517) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 449, 0 }, /* (518) slimit_clause_opt ::= */ - { 449, -2 }, /* (519) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 449, -4 }, /* (520) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 449, -4 }, /* (521) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 450, 0 }, /* (522) limit_clause_opt ::= */ - { 450, -2 }, /* (523) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 450, -4 }, /* (524) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 450, -4 }, /* (525) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 427, -3 }, /* (526) subquery ::= NK_LP query_expression NK_RP */ - { 427, -3 }, /* (527) subquery ::= NK_LP subquery NK_RP */ - { 430, -1 }, /* (528) search_condition ::= common_expression */ - { 453, -1 }, /* (529) sort_specification_list ::= sort_specification */ - { 453, -3 }, /* (530) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 454, -3 }, /* (531) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - { 455, 0 }, /* (532) ordering_specification_opt ::= */ - { 455, -1 }, /* (533) ordering_specification_opt ::= ASC */ - { 455, -1 }, /* (534) ordering_specification_opt ::= DESC */ - { 456, 0 }, /* (535) null_ordering_opt ::= */ - { 456, -2 }, /* (536) null_ordering_opt ::= NULLS FIRST */ - { 456, -2 }, /* (537) null_ordering_opt ::= NULLS LAST */ + { 322, -8 }, /* (260) cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */ + { 322, -4 }, /* (261) cmd ::= DROP INDEX exists_opt full_index_name */ + { 380, -1 }, /* (262) full_index_name ::= index_name */ + { 380, -3 }, /* (263) full_index_name ::= db_name NK_DOT index_name */ + { 381, -10 }, /* (264) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + { 381, -12 }, /* (265) 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 */ + { 383, -1 }, /* (266) func_list ::= func */ + { 383, -3 }, /* (267) func_list ::= func_list NK_COMMA func */ + { 386, -4 }, /* (268) func ::= function_name NK_LP expression_list NK_RP */ + { 385, 0 }, /* (269) sma_stream_opt ::= */ + { 385, -3 }, /* (270) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + { 385, -3 }, /* (271) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + { 385, -3 }, /* (272) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + { 322, -6 }, /* (273) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + { 322, -7 }, /* (274) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 322, -9 }, /* (275) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 322, -7 }, /* (276) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 322, -9 }, /* (277) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 322, -4 }, /* (278) cmd ::= DROP TOPIC exists_opt topic_name */ + { 322, -7 }, /* (279) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 322, -2 }, /* (280) cmd ::= DESC full_table_name */ + { 322, -2 }, /* (281) cmd ::= DESCRIBE full_table_name */ + { 322, -3 }, /* (282) cmd ::= RESET QUERY CACHE */ + { 322, -4 }, /* (283) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + { 389, 0 }, /* (284) analyze_opt ::= */ + { 389, -1 }, /* (285) analyze_opt ::= ANALYZE */ + { 390, 0 }, /* (286) explain_options ::= */ + { 390, -3 }, /* (287) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 390, -3 }, /* (288) explain_options ::= explain_options RATIO NK_FLOAT */ + { 322, -10 }, /* (289) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 322, -4 }, /* (290) cmd ::= DROP FUNCTION exists_opt function_name */ + { 391, 0 }, /* (291) agg_func_opt ::= */ + { 391, -1 }, /* (292) agg_func_opt ::= AGGREGATE */ + { 392, 0 }, /* (293) bufsize_opt ::= */ + { 392, -2 }, /* (294) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 322, -11 }, /* (295) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery */ + { 322, -4 }, /* (296) cmd ::= DROP STREAM exists_opt stream_name */ + { 394, 0 }, /* (297) stream_options ::= */ + { 394, -3 }, /* (298) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 394, -3 }, /* (299) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 394, -4 }, /* (300) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 394, -3 }, /* (301) stream_options ::= stream_options WATERMARK duration_literal */ + { 394, -4 }, /* (302) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + { 394, -3 }, /* (303) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + { 395, 0 }, /* (304) subtable_opt ::= */ + { 395, -4 }, /* (305) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + { 322, -3 }, /* (306) cmd ::= KILL CONNECTION NK_INTEGER */ + { 322, -3 }, /* (307) cmd ::= KILL QUERY NK_STRING */ + { 322, -3 }, /* (308) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 322, -2 }, /* (309) cmd ::= BALANCE VGROUP */ + { 322, -4 }, /* (310) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 322, -4 }, /* (311) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 322, -3 }, /* (312) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 397, -2 }, /* (313) dnode_list ::= DNODE NK_INTEGER */ + { 397, -3 }, /* (314) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 322, -4 }, /* (315) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 322, -1 }, /* (316) cmd ::= query_or_subquery */ + { 322, -7 }, /* (317) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + { 322, -4 }, /* (318) cmd ::= INSERT INTO full_table_name query_or_subquery */ + { 325, -1 }, /* (319) literal ::= NK_INTEGER */ + { 325, -1 }, /* (320) literal ::= NK_FLOAT */ + { 325, -1 }, /* (321) literal ::= NK_STRING */ + { 325, -1 }, /* (322) literal ::= NK_BOOL */ + { 325, -2 }, /* (323) literal ::= TIMESTAMP NK_STRING */ + { 325, -1 }, /* (324) literal ::= duration_literal */ + { 325, -1 }, /* (325) literal ::= NULL */ + { 325, -1 }, /* (326) literal ::= NK_QUESTION */ + { 369, -1 }, /* (327) duration_literal ::= NK_VARIABLE */ + { 399, -1 }, /* (328) signed ::= NK_INTEGER */ + { 399, -2 }, /* (329) signed ::= NK_PLUS NK_INTEGER */ + { 399, -2 }, /* (330) signed ::= NK_MINUS NK_INTEGER */ + { 399, -1 }, /* (331) signed ::= NK_FLOAT */ + { 399, -2 }, /* (332) signed ::= NK_PLUS NK_FLOAT */ + { 399, -2 }, /* (333) signed ::= NK_MINUS NK_FLOAT */ + { 358, -1 }, /* (334) signed_literal ::= signed */ + { 358, -1 }, /* (335) signed_literal ::= NK_STRING */ + { 358, -1 }, /* (336) signed_literal ::= NK_BOOL */ + { 358, -2 }, /* (337) signed_literal ::= TIMESTAMP NK_STRING */ + { 358, -1 }, /* (338) signed_literal ::= duration_literal */ + { 358, -1 }, /* (339) signed_literal ::= NULL */ + { 358, -1 }, /* (340) signed_literal ::= literal_func */ + { 358, -1 }, /* (341) signed_literal ::= NK_QUESTION */ + { 401, -1 }, /* (342) literal_list ::= signed_literal */ + { 401, -3 }, /* (343) literal_list ::= literal_list NK_COMMA signed_literal */ + { 333, -1 }, /* (344) db_name ::= NK_ID */ + { 364, -1 }, /* (345) table_name ::= NK_ID */ + { 356, -1 }, /* (346) column_name ::= NK_ID */ + { 371, -1 }, /* (347) function_name ::= NK_ID */ + { 402, -1 }, /* (348) table_alias ::= NK_ID */ + { 379, -1 }, /* (349) column_alias ::= NK_ID */ + { 327, -1 }, /* (350) user_name ::= NK_ID */ + { 334, -1 }, /* (351) topic_name ::= NK_ID */ + { 393, -1 }, /* (352) stream_name ::= NK_ID */ + { 388, -1 }, /* (353) cgroup_name ::= NK_ID */ + { 382, -1 }, /* (354) index_name ::= NK_ID */ + { 403, -1 }, /* (355) expr_or_subquery ::= expression */ + { 396, -1 }, /* (356) expression ::= literal */ + { 396, -1 }, /* (357) expression ::= pseudo_column */ + { 396, -1 }, /* (358) expression ::= column_reference */ + { 396, -1 }, /* (359) expression ::= function_expression */ + { 396, -1 }, /* (360) expression ::= case_when_expression */ + { 396, -3 }, /* (361) expression ::= NK_LP expression NK_RP */ + { 396, -2 }, /* (362) expression ::= NK_PLUS expr_or_subquery */ + { 396, -2 }, /* (363) expression ::= NK_MINUS expr_or_subquery */ + { 396, -3 }, /* (364) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + { 396, -3 }, /* (365) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + { 396, -3 }, /* (366) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + { 396, -3 }, /* (367) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + { 396, -3 }, /* (368) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + { 396, -3 }, /* (369) expression ::= column_reference NK_ARROW NK_STRING */ + { 396, -3 }, /* (370) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + { 396, -3 }, /* (371) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + { 361, -1 }, /* (372) expression_list ::= expr_or_subquery */ + { 361, -3 }, /* (373) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + { 405, -1 }, /* (374) column_reference ::= column_name */ + { 405, -3 }, /* (375) column_reference ::= table_name NK_DOT column_name */ + { 404, -1 }, /* (376) pseudo_column ::= ROWTS */ + { 404, -1 }, /* (377) pseudo_column ::= TBNAME */ + { 404, -3 }, /* (378) pseudo_column ::= table_name NK_DOT TBNAME */ + { 404, -1 }, /* (379) pseudo_column ::= QSTART */ + { 404, -1 }, /* (380) pseudo_column ::= QEND */ + { 404, -1 }, /* (381) pseudo_column ::= QDURATION */ + { 404, -1 }, /* (382) pseudo_column ::= WSTART */ + { 404, -1 }, /* (383) pseudo_column ::= WEND */ + { 404, -1 }, /* (384) pseudo_column ::= WDURATION */ + { 404, -1 }, /* (385) pseudo_column ::= IROWTS */ + { 404, -1 }, /* (386) pseudo_column ::= QTAGS */ + { 406, -4 }, /* (387) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 406, -4 }, /* (388) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 406, -6 }, /* (389) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + { 406, -1 }, /* (390) function_expression ::= literal_func */ + { 400, -3 }, /* (391) literal_func ::= noarg_func NK_LP NK_RP */ + { 400, -1 }, /* (392) literal_func ::= NOW */ + { 410, -1 }, /* (393) noarg_func ::= NOW */ + { 410, -1 }, /* (394) noarg_func ::= TODAY */ + { 410, -1 }, /* (395) noarg_func ::= TIMEZONE */ + { 410, -1 }, /* (396) noarg_func ::= DATABASE */ + { 410, -1 }, /* (397) noarg_func ::= CLIENT_VERSION */ + { 410, -1 }, /* (398) noarg_func ::= SERVER_VERSION */ + { 410, -1 }, /* (399) noarg_func ::= SERVER_STATUS */ + { 410, -1 }, /* (400) noarg_func ::= CURRENT_USER */ + { 410, -1 }, /* (401) noarg_func ::= USER */ + { 408, -1 }, /* (402) star_func ::= COUNT */ + { 408, -1 }, /* (403) star_func ::= FIRST */ + { 408, -1 }, /* (404) star_func ::= LAST */ + { 408, -1 }, /* (405) star_func ::= LAST_ROW */ + { 409, -1 }, /* (406) star_func_para_list ::= NK_STAR */ + { 409, -1 }, /* (407) star_func_para_list ::= other_para_list */ + { 411, -1 }, /* (408) other_para_list ::= star_func_para */ + { 411, -3 }, /* (409) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 412, -1 }, /* (410) star_func_para ::= expr_or_subquery */ + { 412, -3 }, /* (411) star_func_para ::= table_name NK_DOT NK_STAR */ + { 407, -4 }, /* (412) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + { 407, -5 }, /* (413) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + { 413, -1 }, /* (414) when_then_list ::= when_then_expr */ + { 413, -2 }, /* (415) when_then_list ::= when_then_list when_then_expr */ + { 416, -4 }, /* (416) when_then_expr ::= WHEN common_expression THEN common_expression */ + { 414, 0 }, /* (417) case_when_else_opt ::= */ + { 414, -2 }, /* (418) case_when_else_opt ::= ELSE common_expression */ + { 417, -3 }, /* (419) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + { 417, -5 }, /* (420) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + { 417, -6 }, /* (421) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + { 417, -3 }, /* (422) predicate ::= expr_or_subquery IS NULL */ + { 417, -4 }, /* (423) predicate ::= expr_or_subquery IS NOT NULL */ + { 417, -3 }, /* (424) predicate ::= expr_or_subquery in_op in_predicate_value */ + { 418, -1 }, /* (425) compare_op ::= NK_LT */ + { 418, -1 }, /* (426) compare_op ::= NK_GT */ + { 418, -1 }, /* (427) compare_op ::= NK_LE */ + { 418, -1 }, /* (428) compare_op ::= NK_GE */ + { 418, -1 }, /* (429) compare_op ::= NK_NE */ + { 418, -1 }, /* (430) compare_op ::= NK_EQ */ + { 418, -1 }, /* (431) compare_op ::= LIKE */ + { 418, -2 }, /* (432) compare_op ::= NOT LIKE */ + { 418, -1 }, /* (433) compare_op ::= MATCH */ + { 418, -1 }, /* (434) compare_op ::= NMATCH */ + { 418, -1 }, /* (435) compare_op ::= CONTAINS */ + { 419, -1 }, /* (436) in_op ::= IN */ + { 419, -2 }, /* (437) in_op ::= NOT IN */ + { 420, -3 }, /* (438) in_predicate_value ::= NK_LP literal_list NK_RP */ + { 421, -1 }, /* (439) boolean_value_expression ::= boolean_primary */ + { 421, -2 }, /* (440) boolean_value_expression ::= NOT boolean_primary */ + { 421, -3 }, /* (441) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 421, -3 }, /* (442) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 422, -1 }, /* (443) boolean_primary ::= predicate */ + { 422, -3 }, /* (444) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 415, -1 }, /* (445) common_expression ::= expr_or_subquery */ + { 415, -1 }, /* (446) common_expression ::= boolean_value_expression */ + { 423, 0 }, /* (447) from_clause_opt ::= */ + { 423, -2 }, /* (448) from_clause_opt ::= FROM table_reference_list */ + { 424, -1 }, /* (449) table_reference_list ::= table_reference */ + { 424, -3 }, /* (450) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 425, -1 }, /* (451) table_reference ::= table_primary */ + { 425, -1 }, /* (452) table_reference ::= joined_table */ + { 426, -2 }, /* (453) table_primary ::= table_name alias_opt */ + { 426, -4 }, /* (454) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 426, -2 }, /* (455) table_primary ::= subquery alias_opt */ + { 426, -1 }, /* (456) table_primary ::= parenthesized_joined_table */ + { 428, 0 }, /* (457) alias_opt ::= */ + { 428, -1 }, /* (458) alias_opt ::= table_alias */ + { 428, -2 }, /* (459) alias_opt ::= AS table_alias */ + { 430, -3 }, /* (460) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 430, -3 }, /* (461) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 427, -6 }, /* (462) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 431, 0 }, /* (463) join_type ::= */ + { 431, -1 }, /* (464) join_type ::= INNER */ + { 433, -12 }, /* (465) 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 */ + { 434, 0 }, /* (466) set_quantifier_opt ::= */ + { 434, -1 }, /* (467) set_quantifier_opt ::= DISTINCT */ + { 434, -1 }, /* (468) set_quantifier_opt ::= ALL */ + { 435, -1 }, /* (469) select_list ::= select_item */ + { 435, -3 }, /* (470) select_list ::= select_list NK_COMMA select_item */ + { 443, -1 }, /* (471) select_item ::= NK_STAR */ + { 443, -1 }, /* (472) select_item ::= common_expression */ + { 443, -2 }, /* (473) select_item ::= common_expression column_alias */ + { 443, -3 }, /* (474) select_item ::= common_expression AS column_alias */ + { 443, -3 }, /* (475) select_item ::= table_name NK_DOT NK_STAR */ + { 398, 0 }, /* (476) where_clause_opt ::= */ + { 398, -2 }, /* (477) where_clause_opt ::= WHERE search_condition */ + { 436, 0 }, /* (478) partition_by_clause_opt ::= */ + { 436, -3 }, /* (479) partition_by_clause_opt ::= PARTITION BY partition_list */ + { 444, -1 }, /* (480) partition_list ::= partition_item */ + { 444, -3 }, /* (481) partition_list ::= partition_list NK_COMMA partition_item */ + { 445, -1 }, /* (482) partition_item ::= expr_or_subquery */ + { 445, -2 }, /* (483) partition_item ::= expr_or_subquery column_alias */ + { 445, -3 }, /* (484) partition_item ::= expr_or_subquery AS column_alias */ + { 440, 0 }, /* (485) twindow_clause_opt ::= */ + { 440, -6 }, /* (486) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 440, -4 }, /* (487) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + { 440, -6 }, /* (488) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 440, -8 }, /* (489) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 384, 0 }, /* (490) sliding_opt ::= */ + { 384, -4 }, /* (491) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 439, 0 }, /* (492) fill_opt ::= */ + { 439, -4 }, /* (493) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 439, -6 }, /* (494) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 446, -1 }, /* (495) fill_mode ::= NONE */ + { 446, -1 }, /* (496) fill_mode ::= PREV */ + { 446, -1 }, /* (497) fill_mode ::= NULL */ + { 446, -1 }, /* (498) fill_mode ::= LINEAR */ + { 446, -1 }, /* (499) fill_mode ::= NEXT */ + { 441, 0 }, /* (500) group_by_clause_opt ::= */ + { 441, -3 }, /* (501) group_by_clause_opt ::= GROUP BY group_by_list */ + { 447, -1 }, /* (502) group_by_list ::= expr_or_subquery */ + { 447, -3 }, /* (503) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + { 442, 0 }, /* (504) having_clause_opt ::= */ + { 442, -2 }, /* (505) having_clause_opt ::= HAVING search_condition */ + { 437, 0 }, /* (506) range_opt ::= */ + { 437, -6 }, /* (507) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + { 438, 0 }, /* (508) every_opt ::= */ + { 438, -4 }, /* (509) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 448, -4 }, /* (510) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 449, -1 }, /* (511) query_simple ::= query_specification */ + { 449, -1 }, /* (512) query_simple ::= union_query_expression */ + { 453, -4 }, /* (513) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + { 453, -3 }, /* (514) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + { 454, -1 }, /* (515) query_simple_or_subquery ::= query_simple */ + { 454, -1 }, /* (516) query_simple_or_subquery ::= subquery */ + { 387, -1 }, /* (517) query_or_subquery ::= query_expression */ + { 387, -1 }, /* (518) query_or_subquery ::= subquery */ + { 450, 0 }, /* (519) order_by_clause_opt ::= */ + { 450, -3 }, /* (520) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 451, 0 }, /* (521) slimit_clause_opt ::= */ + { 451, -2 }, /* (522) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 451, -4 }, /* (523) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 451, -4 }, /* (524) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 452, 0 }, /* (525) limit_clause_opt ::= */ + { 452, -2 }, /* (526) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 452, -4 }, /* (527) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 452, -4 }, /* (528) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 429, -3 }, /* (529) subquery ::= NK_LP query_expression NK_RP */ + { 429, -3 }, /* (530) subquery ::= NK_LP subquery NK_RP */ + { 432, -1 }, /* (531) search_condition ::= common_expression */ + { 455, -1 }, /* (532) sort_specification_list ::= sort_specification */ + { 455, -3 }, /* (533) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 456, -3 }, /* (534) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + { 457, 0 }, /* (535) ordering_specification_opt ::= */ + { 457, -1 }, /* (536) ordering_specification_opt ::= ASC */ + { 457, -1 }, /* (537) ordering_specification_opt ::= DESC */ + { 458, 0 }, /* (538) null_ordering_opt ::= */ + { 458, -2 }, /* (539) null_ordering_opt ::= NULLS FIRST */ + { 458, -2 }, /* (540) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3661,77 +3677,77 @@ static YYACTIONTYPE yy_reduce( yy_destructor(yypParser,325,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy199, &yymsp[-1].minor.yy0, yymsp[0].minor.yy33); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy317, &yymsp[-1].minor.yy0, yymsp[0].minor.yy449); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy199, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy317, 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.yy199, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy317, 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.yy199, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy317, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 28: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy199); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy317); } break; case 29: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy33 = 1; } +{ yymsp[1].minor.yy449 = 1; } break; case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy33 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy449 = 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.yy525, &yymsp[-2].minor.yy199, &yymsp[0].minor.yy199); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy531, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy317); } break; case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy525, &yymsp[-2].minor.yy199, &yymsp[0].minor.yy199); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy531, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy317); } break; case 33: /* privileges ::= ALL */ -{ yymsp[0].minor.yy525 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy531 = PRIVILEGE_TYPE_ALL; } break; case 34: /* privileges ::= priv_type_list */ case 36: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==36); -{ yylhsminor.yy525 = yymsp[0].minor.yy525; } - yymsp[0].minor.yy525 = yylhsminor.yy525; +{ yylhsminor.yy531 = yymsp[0].minor.yy531; } + yymsp[0].minor.yy531 = yylhsminor.yy531; break; case 35: /* privileges ::= SUBSCRIBE */ -{ yymsp[0].minor.yy525 = PRIVILEGE_TYPE_SUBSCRIBE; } +{ yymsp[0].minor.yy531 = PRIVILEGE_TYPE_SUBSCRIBE; } break; case 37: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy525 = yymsp[-2].minor.yy525 | yymsp[0].minor.yy525; } - yymsp[-2].minor.yy525 = yylhsminor.yy525; +{ yylhsminor.yy531 = yymsp[-2].minor.yy531 | yymsp[0].minor.yy531; } + yymsp[-2].minor.yy531 = yylhsminor.yy531; break; case 38: /* priv_type ::= READ */ -{ yymsp[0].minor.yy525 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy531 = PRIVILEGE_TYPE_READ; } break; case 39: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy525 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy531 = PRIVILEGE_TYPE_WRITE; } break; case 40: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy199 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy199 = yylhsminor.yy199; +{ yylhsminor.yy317 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy317 = yylhsminor.yy317; break; case 41: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy199 = yymsp[-2].minor.yy199; } - yymsp[-2].minor.yy199 = yylhsminor.yy199; +{ yylhsminor.yy317 = yymsp[-2].minor.yy317; } + yymsp[-2].minor.yy317 = yylhsminor.yy317; break; case 42: /* priv_level ::= topic_name */ - case 455: /* alias_opt ::= table_alias */ yytestcase(yyruleno==455); -{ yylhsminor.yy199 = yymsp[0].minor.yy199; } - yymsp[0].minor.yy199 = yylhsminor.yy199; + case 458: /* alias_opt ::= table_alias */ yytestcase(yyruleno==458); +{ yylhsminor.yy317 = yymsp[0].minor.yy317; } + yymsp[0].minor.yy317 = yylhsminor.yy317; break; case 43: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy199, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy317, NULL); } break; case 44: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy199, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy317, &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.yy397); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy335); } break; case 46: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy199, yymsp[0].minor.yy397); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy317, yymsp[0].minor.yy335); } break; case 47: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3748,45 +3764,46 @@ 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 342: /* db_name ::= NK_ID */ yytestcase(yyruleno==342); - case 343: /* table_name ::= NK_ID */ yytestcase(yyruleno==343); - case 344: /* column_name ::= NK_ID */ yytestcase(yyruleno==344); - case 345: /* function_name ::= NK_ID */ yytestcase(yyruleno==345); - case 346: /* table_alias ::= NK_ID */ yytestcase(yyruleno==346); - case 347: /* column_alias ::= NK_ID */ yytestcase(yyruleno==347); - case 348: /* user_name ::= NK_ID */ yytestcase(yyruleno==348); - case 349: /* topic_name ::= NK_ID */ yytestcase(yyruleno==349); - case 350: /* stream_name ::= NK_ID */ yytestcase(yyruleno==350); - case 351: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==351); - case 390: /* noarg_func ::= NOW */ yytestcase(yyruleno==390); - case 391: /* noarg_func ::= TODAY */ yytestcase(yyruleno==391); - case 392: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==392); - case 393: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==393); - case 394: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==394); - case 395: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==395); - case 396: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==396); - case 397: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==397); - case 398: /* noarg_func ::= USER */ yytestcase(yyruleno==398); - case 399: /* star_func ::= COUNT */ yytestcase(yyruleno==399); - case 400: /* star_func ::= FIRST */ yytestcase(yyruleno==400); - case 401: /* star_func ::= LAST */ yytestcase(yyruleno==401); - case 402: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==402); -{ yylhsminor.yy199 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy199 = yylhsminor.yy199; + case 344: /* db_name ::= NK_ID */ yytestcase(yyruleno==344); + case 345: /* table_name ::= NK_ID */ yytestcase(yyruleno==345); + case 346: /* column_name ::= NK_ID */ yytestcase(yyruleno==346); + case 347: /* function_name ::= NK_ID */ yytestcase(yyruleno==347); + case 348: /* table_alias ::= NK_ID */ yytestcase(yyruleno==348); + case 349: /* column_alias ::= NK_ID */ yytestcase(yyruleno==349); + case 350: /* user_name ::= NK_ID */ yytestcase(yyruleno==350); + case 351: /* topic_name ::= NK_ID */ yytestcase(yyruleno==351); + case 352: /* stream_name ::= NK_ID */ yytestcase(yyruleno==352); + case 353: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==353); + case 354: /* index_name ::= NK_ID */ yytestcase(yyruleno==354); + case 393: /* noarg_func ::= NOW */ yytestcase(yyruleno==393); + case 394: /* noarg_func ::= TODAY */ yytestcase(yyruleno==394); + case 395: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==395); + case 396: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==396); + case 397: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==397); + case 398: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==398); + case 399: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==399); + case 400: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==400); + case 401: /* noarg_func ::= USER */ yytestcase(yyruleno==401); + case 402: /* star_func ::= COUNT */ yytestcase(yyruleno==402); + case 403: /* star_func ::= FIRST */ yytestcase(yyruleno==403); + case 404: /* star_func ::= LAST */ yytestcase(yyruleno==404); + case 405: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==405); +{ yylhsminor.yy317 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy317 = yylhsminor.yy317; break; case 54: /* force_opt ::= */ case 73: /* not_exists_opt ::= */ yytestcase(yyruleno==73); case 75: /* exists_opt ::= */ yytestcase(yyruleno==75); - case 282: /* analyze_opt ::= */ yytestcase(yyruleno==282); - case 289: /* agg_func_opt ::= */ yytestcase(yyruleno==289); - case 463: /* set_quantifier_opt ::= */ yytestcase(yyruleno==463); -{ yymsp[1].minor.yy397 = false; } + case 284: /* analyze_opt ::= */ yytestcase(yyruleno==284); + case 291: /* agg_func_opt ::= */ yytestcase(yyruleno==291); + case 466: /* set_quantifier_opt ::= */ yytestcase(yyruleno==466); +{ yymsp[1].minor.yy335 = false; } break; case 55: /* force_opt ::= FORCE */ - case 283: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==283); - case 290: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==290); - case 464: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==464); -{ yymsp[0].minor.yy397 = true; } + case 285: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==285); + case 292: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==292); + case 467: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==467); +{ yymsp[0].minor.yy335 = true; } break; case 56: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3819,206 +3836,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.yy397, &yymsp[-1].minor.yy199, yymsp[0].minor.yy148); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy335, &yymsp[-1].minor.yy317, yymsp[0].minor.yy74); } break; case 67: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy397, &yymsp[0].minor.yy199); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy335, &yymsp[0].minor.yy317); } break; case 68: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy199); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy317); } break; case 69: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy199, yymsp[0].minor.yy148); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy317, yymsp[0].minor.yy74); } break; case 70: /* cmd ::= FLUSH DATABASE db_name */ -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy199); } +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy317); } break; case 71: /* cmd ::= TRIM DATABASE db_name speed_opt */ -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy199, yymsp[0].minor.yy706); } +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy317, yymsp[0].minor.yy856); } break; case 72: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy397 = true; } +{ yymsp[-2].minor.yy335 = true; } break; case 74: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy397 = true; } +{ yymsp[-1].minor.yy335 = true; } break; case 76: /* db_options ::= */ -{ yymsp[1].minor.yy148 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy74 = createDefaultDatabaseOptions(pCxt); } break; case 77: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 78: /* db_options ::= db_options CACHEMODEL NK_STRING */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 79: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 80: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 81: /* db_options ::= db_options DURATION NK_INTEGER */ case 82: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==82); -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 83: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 84: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 85: /* db_options ::= db_options KEEP integer_list */ case 86: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==86); -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_KEEP, yymsp[0].minor.yy404); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_KEEP, yymsp[0].minor.yy874); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 87: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 88: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 89: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 90: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 91: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 92: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 93: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 94: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_RETENTIONS, yymsp[0].minor.yy404); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_RETENTIONS, yymsp[0].minor.yy874); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 95: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 96: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 97: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 98: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; 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.yy148 = setDatabaseOption(pCxt, yymsp[-3].minor.yy148, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-3].minor.yy74, DB_OPTION_WAL_RETENTION_PERIOD, &t); } - yymsp[-3].minor.yy148 = yylhsminor.yy148; + yymsp[-3].minor.yy74 = yylhsminor.yy74; break; case 100: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; 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.yy148 = setDatabaseOption(pCxt, yymsp[-3].minor.yy148, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-3].minor.yy74, DB_OPTION_WAL_RETENTION_SIZE, &t); } - yymsp[-3].minor.yy148 = yylhsminor.yy148; + yymsp[-3].minor.yy74 = yylhsminor.yy74; break; case 102: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 103: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 104: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 105: /* db_options ::= db_options TABLE_PREFIX NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 106: /* db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ -{ yylhsminor.yy148 = setDatabaseOption(pCxt, yymsp[-2].minor.yy148, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 107: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy148 = createAlterDatabaseOptions(pCxt); yylhsminor.yy148 = setAlterDatabaseOption(pCxt, yylhsminor.yy148, &yymsp[0].minor.yy123); } - yymsp[0].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createAlterDatabaseOptions(pCxt); yylhsminor.yy74 = setAlterDatabaseOption(pCxt, yylhsminor.yy74, &yymsp[0].minor.yy767); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; case 108: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy148 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy148, &yymsp[0].minor.yy123); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy74, &yymsp[0].minor.yy767); } + yymsp[-1].minor.yy74 = yylhsminor.yy74; break; case 109: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy123.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy123.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy767.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } break; case 110: /* alter_db_option ::= CACHEMODEL NK_STRING */ -{ yymsp[-1].minor.yy123.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy123.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy767.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } break; case 111: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -{ yymsp[-1].minor.yy123.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy123.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy767.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } break; case 112: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy123.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy123.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy767.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy767.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.yy123.type = DB_OPTION_KEEP; yymsp[-1].minor.yy123.pList = yymsp[0].minor.yy404; } +{ yymsp[-1].minor.yy767.type = DB_OPTION_KEEP; yymsp[-1].minor.yy767.pList = yymsp[0].minor.yy874; } break; case 115: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy123.type = DB_OPTION_PAGES; yymsp[-1].minor.yy123.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy767.type = DB_OPTION_PAGES; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } break; case 116: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy123.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy123.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy767.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } break; case 117: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -{ yymsp[-1].minor.yy123.type = DB_OPTION_WAL; yymsp[-1].minor.yy123.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy767.type = DB_OPTION_WAL; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } break; case 118: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ -{ yymsp[-1].minor.yy123.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy123.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy767.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } break; case 119: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy404 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy404 = yylhsminor.yy404; +{ 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 312: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==312); -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy404 = yylhsminor.yy404; + case 314: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==314); +{ 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.yy404 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy404 = yylhsminor.yy404; +{ 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.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy404 = yylhsminor.yy404; +{ 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); @@ -4027,287 +4044,287 @@ 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 253: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==253); - case 264: /* func_list ::= func */ yytestcase(yyruleno==264); - case 340: /* literal_list ::= signed_literal */ yytestcase(yyruleno==340); - case 405: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==405); - case 411: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==411); - case 466: /* select_list ::= select_item */ yytestcase(yyruleno==466); - case 477: /* partition_list ::= partition_item */ yytestcase(yyruleno==477); - case 529: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==529); -{ yylhsminor.yy404 = createNodeList(pCxt, yymsp[0].minor.yy148); } - yymsp[0].minor.yy404 = yylhsminor.yy404; + case 266: /* func_list ::= func */ yytestcase(yyruleno==266); + case 342: /* literal_list ::= signed_literal */ yytestcase(yyruleno==342); + case 408: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==408); + case 414: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==414); + case 469: /* select_list ::= select_item */ yytestcase(yyruleno==469); + case 480: /* partition_list ::= partition_item */ yytestcase(yyruleno==480); + case 532: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==532); +{ yylhsminor.yy874 = createNodeList(pCxt, yymsp[0].minor.yy74); } + 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 254: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==254); - case 265: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==265); - case 341: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==341); - case 406: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==406); - case 467: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==467); - case 478: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==478); - case 530: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==530); -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, yymsp[0].minor.yy148); } - yymsp[-2].minor.yy404 = yylhsminor.yy404; + case 267: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==267); + case 343: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==343); + case 409: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==409); + case 470: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==470); + case 481: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==481); + case 533: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==533); +{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-2].minor.yy874, yymsp[0].minor.yy74); } + yymsp[-2].minor.yy874 = yylhsminor.yy874; break; case 125: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy148 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 126: /* speed_opt ::= */ - case 291: /* bufsize_opt ::= */ yytestcase(yyruleno==291); -{ yymsp[1].minor.yy706 = 0; } + case 293: /* bufsize_opt ::= */ yytestcase(yyruleno==293); +{ yymsp[1].minor.yy856 = 0; } break; case 127: /* speed_opt ::= MAX_SPEED NK_INTEGER */ - case 292: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==292); -{ yymsp[-1].minor.yy706 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + case 294: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==294); +{ yymsp[-1].minor.yy856 = 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.yy397, yymsp[-5].minor.yy148, yymsp[-3].minor.yy404, yymsp[-1].minor.yy404, yymsp[0].minor.yy148); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy335, yymsp[-5].minor.yy74, yymsp[-3].minor.yy874, yymsp[-1].minor.yy874, yymsp[0].minor.yy74); } break; case 129: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy404); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy874); } break; case 131: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy404); } +{ 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.yy397, yymsp[0].minor.yy148); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy335, yymsp[0].minor.yy74); } break; case 133: /* cmd ::= ALTER TABLE alter_table_clause */ - case 314: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==314); -{ pCxt->pRootNode = yymsp[0].minor.yy148; } + case 316: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==316); +{ pCxt->pRootNode = yymsp[0].minor.yy74; } break; case 134: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy148); } +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy74); } break; case 135: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy148 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy148, yymsp[0].minor.yy148); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy74, yymsp[0].minor.yy74); } + yymsp[-1].minor.yy74 = yylhsminor.yy74; break; case 136: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy148 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy148, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy199, yymsp[0].minor.yy530); } - yymsp[-4].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy74, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy317, yymsp[0].minor.yy898); } + yymsp[-4].minor.yy74 = yylhsminor.yy74; break; case 137: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy148 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy148, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy199); } - yymsp[-3].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy74, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy317); } + yymsp[-3].minor.yy74 = yylhsminor.yy74; break; case 138: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy148 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy148, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy199, yymsp[0].minor.yy530); } - yymsp[-4].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy74, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy317, yymsp[0].minor.yy898); } + yymsp[-4].minor.yy74 = yylhsminor.yy74; break; case 139: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy148 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy148, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy199, &yymsp[0].minor.yy199); } - yymsp[-4].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy74, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy317, &yymsp[0].minor.yy317); } + yymsp[-4].minor.yy74 = yylhsminor.yy74; break; case 140: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy148 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy148, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy199, yymsp[0].minor.yy530); } - yymsp[-4].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy74, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy317, yymsp[0].minor.yy898); } + yymsp[-4].minor.yy74 = yylhsminor.yy74; break; case 141: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy148 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy148, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy199); } - yymsp[-3].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy74, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy317); } + yymsp[-3].minor.yy74 = yylhsminor.yy74; break; case 142: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy148 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy148, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy199, yymsp[0].minor.yy530); } - yymsp[-4].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy74, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy317, yymsp[0].minor.yy898); } + yymsp[-4].minor.yy74 = yylhsminor.yy74; break; case 143: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy148 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy148, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy199, &yymsp[0].minor.yy199); } - yymsp[-4].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy74, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy317, &yymsp[0].minor.yy317); } + yymsp[-4].minor.yy74 = yylhsminor.yy74; break; case 144: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy148 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy148, &yymsp[-2].minor.yy199, yymsp[0].minor.yy148); } - yymsp[-5].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy74, &yymsp[-2].minor.yy317, yymsp[0].minor.yy74); } + yymsp[-5].minor.yy74 = yylhsminor.yy74; 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 412: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==412); -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-1].minor.yy404, yymsp[0].minor.yy148); } - yymsp[-1].minor.yy404 = yylhsminor.yy404; + case 415: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==415); +{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-1].minor.yy874, yymsp[0].minor.yy74); } + 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.yy148 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy397, yymsp[-8].minor.yy148, yymsp[-6].minor.yy148, yymsp[-5].minor.yy404, yymsp[-2].minor.yy404, yymsp[0].minor.yy148); } - yymsp[-9].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy335, yymsp[-8].minor.yy74, yymsp[-6].minor.yy74, yymsp[-5].minor.yy874, yymsp[-2].minor.yy874, yymsp[0].minor.yy74); } + yymsp[-9].minor.yy74 = yylhsminor.yy74; break; case 150: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy148 = createDropTableClause(pCxt, yymsp[-1].minor.yy397, yymsp[0].minor.yy148); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createDropTableClause(pCxt, yymsp[-1].minor.yy335, yymsp[0].minor.yy74); } + yymsp[-1].minor.yy74 = yylhsminor.yy74; break; case 151: /* specific_cols_opt ::= */ case 182: /* tags_def_opt ::= */ yytestcase(yyruleno==182); case 252: /* tag_list_opt ::= */ yytestcase(yyruleno==252); - case 475: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==475); - case 497: /* group_by_clause_opt ::= */ yytestcase(yyruleno==497); - case 516: /* order_by_clause_opt ::= */ yytestcase(yyruleno==516); -{ yymsp[1].minor.yy404 = NULL; } + case 478: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==478); + case 500: /* group_by_clause_opt ::= */ yytestcase(yyruleno==500); + case 519: /* order_by_clause_opt ::= */ yytestcase(yyruleno==519); +{ yymsp[1].minor.yy874 = NULL; } break; case 152: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy404 = yymsp[-1].minor.yy404; } +{ yymsp[-2].minor.yy874 = yymsp[-1].minor.yy874; } break; case 153: /* full_table_name ::= table_name */ -{ yylhsminor.yy148 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy199, NULL); } - yymsp[0].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy317, NULL); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; case 154: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy148 = createRealTableNode(pCxt, &yymsp[-2].minor.yy199, &yymsp[0].minor.yy199, NULL); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createRealTableNode(pCxt, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy317, NULL); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 157: /* column_def ::= column_name type_name */ -{ yylhsminor.yy148 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy199, yymsp[0].minor.yy530, NULL); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy317, yymsp[0].minor.yy898, NULL); } + yymsp[-1].minor.yy74 = yylhsminor.yy74; break; case 158: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy148 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy199, yymsp[-2].minor.yy530, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy317, yymsp[-2].minor.yy898, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy74 = yylhsminor.yy74; break; case 159: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy530 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 160: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy530 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 161: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy530 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 162: /* type_name ::= INT */ case 163: /* type_name ::= INTEGER */ yytestcase(yyruleno==163); -{ yymsp[0].minor.yy530 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_INT); } break; case 164: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy530 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 165: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy530 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 166: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy530 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 167: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy530 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy898 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 168: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy530 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 169: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy530 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy898 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 170: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy530 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy898 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 171: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy530 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy898 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 172: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy530 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy898 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 173: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy530 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy898 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 174: /* type_name ::= JSON */ -{ yymsp[0].minor.yy530 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 175: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy530 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy898 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 176: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy530 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 177: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy530 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 178: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy530 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy898 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 179: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy530 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 180: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy530 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy898 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 181: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy530 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy898 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 183: /* tags_def_opt ::= tags_def */ - case 404: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==404); -{ yylhsminor.yy404 = yymsp[0].minor.yy404; } - yymsp[0].minor.yy404 = yylhsminor.yy404; + case 407: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==407); +{ 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.yy404 = yymsp[-1].minor.yy404; } +{ yymsp[-3].minor.yy874 = yymsp[-1].minor.yy874; } break; case 185: /* table_options ::= */ -{ yymsp[1].minor.yy148 = createDefaultTableOptions(pCxt); } +{ yymsp[1].minor.yy74 = createDefaultTableOptions(pCxt); } break; case 186: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy148 = setTableOption(pCxt, yymsp[-2].minor.yy148, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setTableOption(pCxt, yymsp[-2].minor.yy74, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 187: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy148 = setTableOption(pCxt, yymsp[-2].minor.yy148, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy404); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setTableOption(pCxt, yymsp[-2].minor.yy74, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy874); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 188: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy148 = setTableOption(pCxt, yymsp[-2].minor.yy148, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy404); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setTableOption(pCxt, yymsp[-2].minor.yy74, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy874); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 189: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy148 = setTableOption(pCxt, yymsp[-4].minor.yy148, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy404); } - yymsp[-4].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setTableOption(pCxt, yymsp[-4].minor.yy74, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy874); } + yymsp[-4].minor.yy74 = yylhsminor.yy74; break; case 190: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy148 = setTableOption(pCxt, yymsp[-2].minor.yy148, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setTableOption(pCxt, yymsp[-2].minor.yy74, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 191: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy148 = setTableOption(pCxt, yymsp[-4].minor.yy148, TABLE_OPTION_SMA, yymsp[-1].minor.yy404); } - yymsp[-4].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setTableOption(pCxt, yymsp[-4].minor.yy74, TABLE_OPTION_SMA, yymsp[-1].minor.yy874); } + yymsp[-4].minor.yy74 = yylhsminor.yy74; break; case 192: /* table_options ::= table_options DELETE_MARK duration_list */ -{ yylhsminor.yy148 = setTableOption(pCxt, yymsp[-2].minor.yy148, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy404); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setTableOption(pCxt, yymsp[-2].minor.yy74, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy874); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; case 193: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy148 = createAlterTableOptions(pCxt); yylhsminor.yy148 = setTableOption(pCxt, yylhsminor.yy148, yymsp[0].minor.yy123.type, &yymsp[0].minor.yy123.val); } - yymsp[0].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createAlterTableOptions(pCxt); yylhsminor.yy74 = setTableOption(pCxt, yylhsminor.yy74, yymsp[0].minor.yy767.type, &yymsp[0].minor.yy767.val); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; case 194: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy148 = setTableOption(pCxt, yymsp[-1].minor.yy148, yymsp[0].minor.yy123.type, &yymsp[0].minor.yy123.val); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setTableOption(pCxt, yymsp[-1].minor.yy74, yymsp[0].minor.yy767.type, &yymsp[0].minor.yy767.val); } + yymsp[-1].minor.yy74 = yylhsminor.yy74; break; case 195: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy123.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy123.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy767.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } break; case 196: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy123.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy123.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy767.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } break; case 197: /* duration_list ::= duration_literal */ - case 369: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==369); -{ yylhsminor.yy404 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy148)); } - yymsp[0].minor.yy404 = yylhsminor.yy404; + case 372: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==372); +{ yylhsminor.yy874 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy74)); } + yymsp[0].minor.yy874 = yylhsminor.yy874; break; case 198: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 370: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==370); -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, releaseRawExprNode(pCxt, yymsp[0].minor.yy148)); } - yymsp[-2].minor.yy404 = yylhsminor.yy404; + case 373: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==373); +{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-2].minor.yy874, releaseRawExprNode(pCxt, yymsp[0].minor.yy74)); } + yymsp[-2].minor.yy874 = yylhsminor.yy874; break; case 201: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy148 = createFunctionNode(pCxt, &yymsp[0].minor.yy199, NULL); } - yymsp[0].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createFunctionNode(pCxt, &yymsp[0].minor.yy317, NULL); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; case 202: /* rollup_func_name ::= FIRST */ case 203: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==203); case 256: /* tag_item ::= QTAGS */ yytestcase(yyruleno==256); -{ yylhsminor.yy148 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; case 206: /* col_name ::= column_name */ case 257: /* tag_item ::= column_name */ yytestcase(yyruleno==257); -{ yylhsminor.yy148 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy199); } - yymsp[0].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy317); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; case 207: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } @@ -4322,13 +4339,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.yy148, yymsp[0].minor.yy148, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy74, yymsp[0].minor.yy74, 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.yy148, yymsp[0].minor.yy148, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy74, yymsp[0].minor.yy74, 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.yy148, NULL, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy74, NULL, OP_TYPE_LIKE); } break; case 214: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } @@ -4340,7 +4357,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.yy148, yymsp[-1].minor.yy148, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy74, yymsp[-1].minor.yy74, OP_TYPE_EQUAL); } break; case 218: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } @@ -4359,13 +4376,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.yy199); } +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy317); } break; case 225: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy148); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy74); } break; case 226: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy148); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy74); } break; case 227: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } @@ -4384,7 +4401,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.yy148); } +{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy74); } break; case 234: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } @@ -4399,7 +4416,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.yy148); } +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy74); } break; case 239: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } @@ -4408,10 +4425,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.yy148, yymsp[-1].minor.yy148, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy74, yymsp[-1].minor.yy74, 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.yy148, yymsp[0].minor.yy148, yymsp[-3].minor.yy404); } +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy74, yymsp[0].minor.yy74, 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); } @@ -4421,733 +4438,741 @@ static YYACTIONTYPE yy_reduce( break; case 245: /* db_name_cond_opt ::= */ case 250: /* from_db_opt ::= */ yytestcase(yyruleno==250); -{ yymsp[1].minor.yy148 = createDefaultDatabaseCondValue(pCxt); } +{ yymsp[1].minor.yy74 = createDefaultDatabaseCondValue(pCxt); } break; case 246: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy148 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy199); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy317); } + yymsp[-1].minor.yy74 = yylhsminor.yy74; break; case 247: /* like_pattern_opt ::= */ - case 302: /* subtable_opt ::= */ yytestcase(yyruleno==302); - case 414: /* case_when_else_opt ::= */ yytestcase(yyruleno==414); - case 444: /* from_clause_opt ::= */ yytestcase(yyruleno==444); - case 473: /* where_clause_opt ::= */ yytestcase(yyruleno==473); - case 482: /* twindow_clause_opt ::= */ yytestcase(yyruleno==482); - case 487: /* sliding_opt ::= */ yytestcase(yyruleno==487); - case 489: /* fill_opt ::= */ yytestcase(yyruleno==489); - case 501: /* having_clause_opt ::= */ yytestcase(yyruleno==501); - case 503: /* range_opt ::= */ yytestcase(yyruleno==503); - case 505: /* every_opt ::= */ yytestcase(yyruleno==505); - case 518: /* slimit_clause_opt ::= */ yytestcase(yyruleno==518); - case 522: /* limit_clause_opt ::= */ yytestcase(yyruleno==522); -{ yymsp[1].minor.yy148 = NULL; } + case 304: /* subtable_opt ::= */ yytestcase(yyruleno==304); + case 417: /* case_when_else_opt ::= */ yytestcase(yyruleno==417); + case 447: /* from_clause_opt ::= */ yytestcase(yyruleno==447); + case 476: /* where_clause_opt ::= */ yytestcase(yyruleno==476); + case 485: /* twindow_clause_opt ::= */ yytestcase(yyruleno==485); + case 490: /* sliding_opt ::= */ yytestcase(yyruleno==490); + case 492: /* fill_opt ::= */ yytestcase(yyruleno==492); + case 504: /* having_clause_opt ::= */ yytestcase(yyruleno==504); + case 506: /* range_opt ::= */ yytestcase(yyruleno==506); + case 508: /* every_opt ::= */ yytestcase(yyruleno==508); + case 521: /* slimit_clause_opt ::= */ yytestcase(yyruleno==521); + case 525: /* limit_clause_opt ::= */ yytestcase(yyruleno==525); +{ yymsp[1].minor.yy74 = NULL; } break; case 248: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy148 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; case 249: /* table_name_cond ::= table_name */ -{ yylhsminor.yy148 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy199); } - yymsp[0].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy317); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; case 251: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy148 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy199); } +{ yymsp[-1].minor.yy74 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy317); } break; case 255: /* tag_item ::= TBNAME */ -{ yylhsminor.yy148 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } - yymsp[0].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; case 258: /* tag_item ::= column_name column_alias */ -{ yylhsminor.yy148 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy199), &yymsp[0].minor.yy199); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy317), &yymsp[0].minor.yy317); } + yymsp[-1].minor.yy74 = yylhsminor.yy74; break; case 259: /* tag_item ::= column_name AS column_alias */ -{ yylhsminor.yy148 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy199), &yymsp[0].minor.yy199); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; +{ yylhsminor.yy74 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy317), &yymsp[0].minor.yy317); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 260: /* 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.yy397, yymsp[-3].minor.yy148, yymsp[-1].minor.yy148, NULL, yymsp[0].minor.yy148); } + case 260: /* 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.yy335, yymsp[-3].minor.yy74, yymsp[-1].minor.yy74, NULL, yymsp[0].minor.yy74); } break; - case 261: /* cmd ::= DROP INDEX exists_opt full_table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy397, yymsp[0].minor.yy148); } + case 261: /* cmd ::= DROP INDEX exists_opt full_index_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy335, yymsp[0].minor.yy74); } break; - case 262: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy148 = createIndexOption(pCxt, yymsp[-7].minor.yy404, releaseRawExprNode(pCxt, yymsp[-3].minor.yy148), NULL, yymsp[-1].minor.yy148, yymsp[0].minor.yy148); } + case 262: /* full_index_name ::= index_name */ +{ yylhsminor.yy74 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy317); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 263: /* 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.yy148 = createIndexOption(pCxt, yymsp[-9].minor.yy404, releaseRawExprNode(pCxt, yymsp[-5].minor.yy148), releaseRawExprNode(pCxt, yymsp[-3].minor.yy148), yymsp[-1].minor.yy148, yymsp[0].minor.yy148); } + case 263: /* full_index_name ::= db_name NK_DOT index_name */ +{ yylhsminor.yy74 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy317); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 266: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy148 = createFunctionNode(pCxt, &yymsp[-3].minor.yy199, yymsp[-1].minor.yy404); } - yymsp[-3].minor.yy148 = yylhsminor.yy148; + case 264: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-9].minor.yy74 = createIndexOption(pCxt, yymsp[-7].minor.yy874, releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), NULL, yymsp[-1].minor.yy74, yymsp[0].minor.yy74); } break; - case 267: /* sma_stream_opt ::= */ - case 295: /* stream_options ::= */ yytestcase(yyruleno==295); -{ yymsp[1].minor.yy148 = createStreamOptions(pCxt); } + case 265: /* 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.yy74 = createIndexOption(pCxt, yymsp[-9].minor.yy874, releaseRawExprNode(pCxt, yymsp[-5].minor.yy74), releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), yymsp[-1].minor.yy74, yymsp[0].minor.yy74); } break; - case 268: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - case 299: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==299); -{ ((SStreamOptions*)yymsp[-2].minor.yy148)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy148); yylhsminor.yy148 = yymsp[-2].minor.yy148; } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 268: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy74 = createFunctionNode(pCxt, &yymsp[-3].minor.yy317, yymsp[-1].minor.yy874); } + yymsp[-3].minor.yy74 = yylhsminor.yy74; break; - case 269: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy148)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy148); yylhsminor.yy148 = yymsp[-2].minor.yy148; } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 269: /* sma_stream_opt ::= */ + case 297: /* stream_options ::= */ yytestcase(yyruleno==297); +{ yymsp[1].minor.yy74 = createStreamOptions(pCxt); } break; - case 270: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy148)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy148); yylhsminor.yy148 = yymsp[-2].minor.yy148; } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 270: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + case 301: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==301); +{ ((SStreamOptions*)yymsp[-2].minor.yy74)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy74); yylhsminor.yy74 = yymsp[-2].minor.yy74; } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 271: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy397, &yymsp[-2].minor.yy199, yymsp[0].minor.yy148); } + case 271: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy74)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy74); yylhsminor.yy74 = yymsp[-2].minor.yy74; } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 272: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy397, &yymsp[-3].minor.yy199, &yymsp[0].minor.yy199, false); } + case 272: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy74)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy74); yylhsminor.yy74 = yymsp[-2].minor.yy74; } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 273: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy397, &yymsp[-5].minor.yy199, &yymsp[0].minor.yy199, true); } + case 273: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy335, &yymsp[-2].minor.yy317, yymsp[0].minor.yy74); } break; - case 274: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy397, &yymsp[-3].minor.yy199, yymsp[0].minor.yy148, false); } + case 274: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy335, &yymsp[-3].minor.yy317, &yymsp[0].minor.yy317, false); } break; - case 275: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy397, &yymsp[-5].minor.yy199, yymsp[0].minor.yy148, true); } + case 275: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy335, &yymsp[-5].minor.yy317, &yymsp[0].minor.yy317, true); } break; - case 276: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy397, &yymsp[0].minor.yy199); } + case 276: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy335, &yymsp[-3].minor.yy317, yymsp[0].minor.yy74, false); } break; - case 277: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy397, &yymsp[-2].minor.yy199, &yymsp[0].minor.yy199); } + case 277: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy335, &yymsp[-5].minor.yy317, yymsp[0].minor.yy74, true); } break; - case 278: /* cmd ::= DESC full_table_name */ - case 279: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==279); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy148); } + case 278: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy335, &yymsp[0].minor.yy317); } break; - case 280: /* cmd ::= RESET QUERY CACHE */ + case 279: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy335, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy317); } + break; + case 280: /* cmd ::= DESC full_table_name */ + case 281: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==281); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy74); } + break; + case 282: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 281: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy397, yymsp[-1].minor.yy148, yymsp[0].minor.yy148); } + case 283: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy335, yymsp[-1].minor.yy74, yymsp[0].minor.yy74); } break; - case 284: /* explain_options ::= */ -{ yymsp[1].minor.yy148 = createDefaultExplainOptions(pCxt); } + case 286: /* explain_options ::= */ +{ yymsp[1].minor.yy74 = createDefaultExplainOptions(pCxt); } break; - case 285: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy148 = setExplainVerbose(pCxt, yymsp[-2].minor.yy148, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 287: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy74 = setExplainVerbose(pCxt, yymsp[-2].minor.yy74, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 286: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy148 = setExplainRatio(pCxt, yymsp[-2].minor.yy148, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 288: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy74 = setExplainRatio(pCxt, yymsp[-2].minor.yy74, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 287: /* 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.yy397, yymsp[-8].minor.yy397, &yymsp[-5].minor.yy199, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy530, yymsp[0].minor.yy706); } + case 289: /* 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.yy335, yymsp[-8].minor.yy335, &yymsp[-5].minor.yy317, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy898, yymsp[0].minor.yy856); } break; - case 288: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy397, &yymsp[0].minor.yy199); } + case 290: /* cmd ::= DROP FUNCTION exists_opt function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy335, &yymsp[0].minor.yy317); } break; - case 293: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-8].minor.yy397, &yymsp[-7].minor.yy199, yymsp[-4].minor.yy148, yymsp[-6].minor.yy148, yymsp[-3].minor.yy404, yymsp[-2].minor.yy148, yymsp[0].minor.yy148); } + case 295: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-8].minor.yy335, &yymsp[-7].minor.yy317, yymsp[-4].minor.yy74, yymsp[-6].minor.yy74, yymsp[-3].minor.yy874, yymsp[-2].minor.yy74, yymsp[0].minor.yy74); } break; - case 294: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy397, &yymsp[0].minor.yy199); } + case 296: /* cmd ::= DROP STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy335, &yymsp[0].minor.yy317); } break; - case 296: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy148)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy148 = yymsp[-2].minor.yy148; } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 298: /* stream_options ::= stream_options TRIGGER AT_ONCE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy74)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy74 = yymsp[-2].minor.yy74; } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 297: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy148)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy148 = yymsp[-2].minor.yy148; } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 299: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy74)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy74 = yymsp[-2].minor.yy74; } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 298: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-3].minor.yy148)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy148)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy148); yylhsminor.yy148 = yymsp[-3].minor.yy148; } - yymsp[-3].minor.yy148 = yylhsminor.yy148; + case 300: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-3].minor.yy74)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy74)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy74); yylhsminor.yy74 = yymsp[-3].minor.yy74; } + yymsp[-3].minor.yy74 = yylhsminor.yy74; break; - case 300: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -{ ((SStreamOptions*)yymsp[-3].minor.yy148)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy148 = yymsp[-3].minor.yy148; } - yymsp[-3].minor.yy148 = yylhsminor.yy148; + case 302: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ +{ ((SStreamOptions*)yymsp[-3].minor.yy74)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy74 = yymsp[-3].minor.yy74; } + yymsp[-3].minor.yy74 = yylhsminor.yy74; break; - case 301: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ -{ ((SStreamOptions*)yymsp[-2].minor.yy148)->fillHistory = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy148 = yymsp[-2].minor.yy148; } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 303: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ +{ ((SStreamOptions*)yymsp[-2].minor.yy74)->fillHistory = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy74 = yymsp[-2].minor.yy74; } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 303: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 488: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==488); - case 506: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==506); -{ yymsp[-3].minor.yy148 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy148); } + case 305: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 491: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==491); + case 509: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==509); +{ yymsp[-3].minor.yy74 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy74); } break; - case 304: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 306: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 305: /* cmd ::= KILL QUERY NK_STRING */ + case 307: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 306: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 308: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 307: /* cmd ::= BALANCE VGROUP */ + case 309: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 308: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 310: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 309: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy404); } + case 311: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy874); } break; - case 310: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 312: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 311: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy404 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 313: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy874 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 313: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy148, yymsp[0].minor.yy148); } + case 315: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy74, yymsp[0].minor.yy74); } break; - case 315: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy148, yymsp[-2].minor.yy404, yymsp[0].minor.yy148); } + case 317: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy74, yymsp[-2].minor.yy874, yymsp[0].minor.yy74); } break; - case 316: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy148, NULL, yymsp[0].minor.yy148); } + case 318: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy74, NULL, yymsp[0].minor.yy74); } break; - case 317: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy148 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 319: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 318: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy148 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 320: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 319: /* literal ::= NK_STRING */ -{ yylhsminor.yy148 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 321: /* literal ::= NK_STRING */ +{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 320: /* literal ::= NK_BOOL */ -{ yylhsminor.yy148 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 322: /* literal ::= NK_BOOL */ +{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 321: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy148 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; + case 323: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy74 = yylhsminor.yy74; break; - case 322: /* literal ::= duration_literal */ - case 332: /* signed_literal ::= signed */ yytestcase(yyruleno==332); - case 352: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==352); - case 353: /* expression ::= literal */ yytestcase(yyruleno==353); - case 354: /* expression ::= pseudo_column */ yytestcase(yyruleno==354); - case 355: /* expression ::= column_reference */ yytestcase(yyruleno==355); - case 356: /* expression ::= function_expression */ yytestcase(yyruleno==356); - case 357: /* expression ::= case_when_expression */ yytestcase(yyruleno==357); - case 387: /* function_expression ::= literal_func */ yytestcase(yyruleno==387); - case 436: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==436); - case 440: /* boolean_primary ::= predicate */ yytestcase(yyruleno==440); - case 442: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==442); - case 443: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==443); - case 446: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==446); - case 448: /* table_reference ::= table_primary */ yytestcase(yyruleno==448); - case 449: /* table_reference ::= joined_table */ yytestcase(yyruleno==449); - case 453: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==453); - case 508: /* query_simple ::= query_specification */ yytestcase(yyruleno==508); - case 509: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==509); - case 512: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==512); - case 514: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==514); -{ yylhsminor.yy148 = yymsp[0].minor.yy148; } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 324: /* literal ::= duration_literal */ + case 334: /* signed_literal ::= signed */ yytestcase(yyruleno==334); + case 355: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==355); + case 356: /* expression ::= literal */ yytestcase(yyruleno==356); + case 357: /* expression ::= pseudo_column */ yytestcase(yyruleno==357); + case 358: /* expression ::= column_reference */ yytestcase(yyruleno==358); + case 359: /* expression ::= function_expression */ yytestcase(yyruleno==359); + case 360: /* expression ::= case_when_expression */ yytestcase(yyruleno==360); + case 390: /* function_expression ::= literal_func */ yytestcase(yyruleno==390); + case 439: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==439); + case 443: /* boolean_primary ::= predicate */ yytestcase(yyruleno==443); + case 445: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==445); + case 446: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==446); + case 449: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==449); + case 451: /* table_reference ::= table_primary */ yytestcase(yyruleno==451); + case 452: /* table_reference ::= joined_table */ yytestcase(yyruleno==452); + case 456: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==456); + case 511: /* query_simple ::= query_specification */ yytestcase(yyruleno==511); + case 512: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==512); + case 515: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==515); + case 517: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==517); +{ yylhsminor.yy74 = yymsp[0].minor.yy74; } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 323: /* literal ::= NULL */ -{ yylhsminor.yy148 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 325: /* literal ::= NULL */ +{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 324: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy148 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 326: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 325: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy148 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 327: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 326: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy148 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 328: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 327: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy148 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + case 329: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } break; - case 328: /* signed ::= NK_MINUS NK_INTEGER */ + case 330: /* 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.yy148 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; + yymsp[-1].minor.yy74 = yylhsminor.yy74; break; - case 329: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy148 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 331: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 330: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy148 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 332: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 331: /* signed ::= NK_MINUS NK_FLOAT */ + case 333: /* 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.yy148 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; + yymsp[-1].minor.yy74 = yylhsminor.yy74; break; - case 333: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy148 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 335: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 334: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy148 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 336: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 335: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy148 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 337: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 336: /* signed_literal ::= duration_literal */ - case 338: /* signed_literal ::= literal_func */ yytestcase(yyruleno==338); - case 407: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==407); - case 469: /* select_item ::= common_expression */ yytestcase(yyruleno==469); - case 479: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==479); - case 513: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==513); - case 515: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==515); - case 528: /* search_condition ::= common_expression */ yytestcase(yyruleno==528); -{ yylhsminor.yy148 = releaseRawExprNode(pCxt, yymsp[0].minor.yy148); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 338: /* signed_literal ::= duration_literal */ + case 340: /* signed_literal ::= literal_func */ yytestcase(yyruleno==340); + case 410: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==410); + case 472: /* select_item ::= common_expression */ yytestcase(yyruleno==472); + case 482: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==482); + case 516: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==516); + case 518: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==518); + case 531: /* search_condition ::= common_expression */ yytestcase(yyruleno==531); +{ yylhsminor.yy74 = releaseRawExprNode(pCxt, yymsp[0].minor.yy74); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 337: /* signed_literal ::= NULL */ -{ yylhsminor.yy148 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 339: /* signed_literal ::= NULL */ +{ yylhsminor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 339: /* signed_literal ::= NK_QUESTION */ -{ yylhsminor.yy148 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 341: /* signed_literal ::= NK_QUESTION */ +{ yylhsminor.yy74 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 358: /* expression ::= NK_LP expression NK_RP */ - case 441: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==441); - case 527: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==527); -{ yylhsminor.yy148 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy148)); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 361: /* expression ::= NK_LP expression NK_RP */ + case 444: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==444); + case 530: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==530); +{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy74)); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 359: /* expression ::= NK_PLUS expr_or_subquery */ + case 362: /* expression ::= NK_PLUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy148)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy74)); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; + yymsp[-1].minor.yy74 = yylhsminor.yy74; break; - case 360: /* expression ::= NK_MINUS expr_or_subquery */ + case 363: /* expression ::= NK_MINUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy148), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy74), NULL)); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; + yymsp[-1].minor.yy74 = yylhsminor.yy74; break; - case 361: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + case 364: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy148); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), releaseRawExprNode(pCxt, yymsp[0].minor.yy148))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 362: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + case 365: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy148); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), releaseRawExprNode(pCxt, yymsp[0].minor.yy148))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 363: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + case 366: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy148); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), releaseRawExprNode(pCxt, yymsp[0].minor.yy148))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 364: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + case 367: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy148); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), releaseRawExprNode(pCxt, yymsp[0].minor.yy148))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 365: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ + case 368: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy148); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), releaseRawExprNode(pCxt, yymsp[0].minor.yy148))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 366: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 369: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 367: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + case 370: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy148); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), releaseRawExprNode(pCxt, yymsp[0].minor.yy148))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 368: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + case 371: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy148); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), releaseRawExprNode(pCxt, yymsp[0].minor.yy148))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 371: /* column_reference ::= column_name */ -{ yylhsminor.yy148 = createRawExprNode(pCxt, &yymsp[0].minor.yy199, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy199)); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 374: /* column_reference ::= column_name */ +{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy317, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy317)); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 372: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy148 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy199, &yymsp[0].minor.yy199, createColumnNode(pCxt, &yymsp[-2].minor.yy199, &yymsp[0].minor.yy199)); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 375: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy317, createColumnNode(pCxt, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy317)); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 373: /* pseudo_column ::= ROWTS */ - case 374: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==374); - case 376: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==376); - case 377: /* pseudo_column ::= QEND */ yytestcase(yyruleno==377); - case 378: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==378); - case 379: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==379); - case 380: /* pseudo_column ::= WEND */ yytestcase(yyruleno==380); - case 381: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==381); - case 382: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==382); - case 383: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==383); - case 389: /* literal_func ::= NOW */ yytestcase(yyruleno==389); -{ yylhsminor.yy148 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 376: /* pseudo_column ::= ROWTS */ + case 377: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==377); + case 379: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==379); + case 380: /* pseudo_column ::= QEND */ yytestcase(yyruleno==380); + case 381: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==381); + case 382: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==382); + case 383: /* pseudo_column ::= WEND */ yytestcase(yyruleno==383); + case 384: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==384); + case 385: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==385); + case 386: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==386); + case 392: /* literal_func ::= NOW */ yytestcase(yyruleno==392); +{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 375: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy148 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy199, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy199)))); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 378: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy317)))); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 384: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 385: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==385); -{ yylhsminor.yy148 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy199, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy199, yymsp[-1].minor.yy404)); } - yymsp[-3].minor.yy148 = yylhsminor.yy148; + case 387: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 388: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==388); +{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy317, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy317, yymsp[-1].minor.yy874)); } + yymsp[-3].minor.yy74 = yylhsminor.yy74; break; - case 386: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ -{ yylhsminor.yy148 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy148), yymsp[-1].minor.yy530)); } - yymsp[-5].minor.yy148 = yylhsminor.yy148; + case 389: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ +{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), yymsp[-1].minor.yy898)); } + yymsp[-5].minor.yy74 = yylhsminor.yy74; break; - case 388: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy148 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy199, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy199, NULL)); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 391: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy317, NULL)); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 403: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy404 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy404 = yylhsminor.yy404; + case 406: /* 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 408: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 472: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==472); -{ yylhsminor.yy148 = createColumnNode(pCxt, &yymsp[-2].minor.yy199, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 411: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 475: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==475); +{ yylhsminor.yy74 = createColumnNode(pCxt, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 409: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -{ yylhsminor.yy148 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy404, yymsp[-1].minor.yy148)); } - yymsp[-3].minor.yy148 = yylhsminor.yy148; + case 412: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ +{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy874, yymsp[-1].minor.yy74)); } + yymsp[-3].minor.yy74 = yylhsminor.yy74; break; - case 410: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -{ yylhsminor.yy148 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy148), yymsp[-2].minor.yy404, yymsp[-1].minor.yy148)); } - yymsp[-4].minor.yy148 = yylhsminor.yy148; + case 413: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ +{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), yymsp[-2].minor.yy874, yymsp[-1].minor.yy74)); } + yymsp[-4].minor.yy74 = yylhsminor.yy74; break; - case 413: /* when_then_expr ::= WHEN common_expression THEN common_expression */ -{ yymsp[-3].minor.yy148 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), releaseRawExprNode(pCxt, yymsp[0].minor.yy148)); } + case 416: /* when_then_expr ::= WHEN common_expression THEN common_expression */ +{ yymsp[-3].minor.yy74 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74)); } break; - case 415: /* case_when_else_opt ::= ELSE common_expression */ -{ yymsp[-1].minor.yy148 = releaseRawExprNode(pCxt, yymsp[0].minor.yy148); } + case 418: /* case_when_else_opt ::= ELSE common_expression */ +{ yymsp[-1].minor.yy74 = releaseRawExprNode(pCxt, yymsp[0].minor.yy74); } break; - case 416: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 421: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==421); + case 419: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 424: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==424); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy148); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy20, releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), releaseRawExprNode(pCxt, yymsp[0].minor.yy148))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy20, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 417: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + case 420: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy148); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy148), releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), releaseRawExprNode(pCxt, yymsp[0].minor.yy148))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy74); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy74), releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); } - yymsp[-4].minor.yy148 = yylhsminor.yy148; + yymsp[-4].minor.yy74 = yylhsminor.yy74; break; - case 418: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + case 421: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy148); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy148), releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), releaseRawExprNode(pCxt, yymsp[0].minor.yy148))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy74); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy74), releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); } - yymsp[-5].minor.yy148 = yylhsminor.yy148; + yymsp[-5].minor.yy74 = yylhsminor.yy74; break; - case 419: /* predicate ::= expr_or_subquery IS NULL */ + case 422: /* predicate ::= expr_or_subquery IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), NULL)); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 420: /* predicate ::= expr_or_subquery IS NOT NULL */ + case 423: /* predicate ::= expr_or_subquery IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy148), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), NULL)); } - yymsp[-3].minor.yy148 = yylhsminor.yy148; + yymsp[-3].minor.yy74 = yylhsminor.yy74; break; - case 422: /* compare_op ::= NK_LT */ + case 425: /* compare_op ::= NK_LT */ { yymsp[0].minor.yy20 = OP_TYPE_LOWER_THAN; } break; - case 423: /* compare_op ::= NK_GT */ + case 426: /* compare_op ::= NK_GT */ { yymsp[0].minor.yy20 = OP_TYPE_GREATER_THAN; } break; - case 424: /* compare_op ::= NK_LE */ + case 427: /* compare_op ::= NK_LE */ { yymsp[0].minor.yy20 = OP_TYPE_LOWER_EQUAL; } break; - case 425: /* compare_op ::= NK_GE */ + case 428: /* compare_op ::= NK_GE */ { yymsp[0].minor.yy20 = OP_TYPE_GREATER_EQUAL; } break; - case 426: /* compare_op ::= NK_NE */ + case 429: /* compare_op ::= NK_NE */ { yymsp[0].minor.yy20 = OP_TYPE_NOT_EQUAL; } break; - case 427: /* compare_op ::= NK_EQ */ + case 430: /* compare_op ::= NK_EQ */ { yymsp[0].minor.yy20 = OP_TYPE_EQUAL; } break; - case 428: /* compare_op ::= LIKE */ + case 431: /* compare_op ::= LIKE */ { yymsp[0].minor.yy20 = OP_TYPE_LIKE; } break; - case 429: /* compare_op ::= NOT LIKE */ + case 432: /* compare_op ::= NOT LIKE */ { yymsp[-1].minor.yy20 = OP_TYPE_NOT_LIKE; } break; - case 430: /* compare_op ::= MATCH */ + case 433: /* compare_op ::= MATCH */ { yymsp[0].minor.yy20 = OP_TYPE_MATCH; } break; - case 431: /* compare_op ::= NMATCH */ + case 434: /* compare_op ::= NMATCH */ { yymsp[0].minor.yy20 = OP_TYPE_NMATCH; } break; - case 432: /* compare_op ::= CONTAINS */ + case 435: /* compare_op ::= CONTAINS */ { yymsp[0].minor.yy20 = OP_TYPE_JSON_CONTAINS; } break; - case 433: /* in_op ::= IN */ + case 436: /* in_op ::= IN */ { yymsp[0].minor.yy20 = OP_TYPE_IN; } break; - case 434: /* in_op ::= NOT IN */ + case 437: /* in_op ::= NOT IN */ { yymsp[-1].minor.yy20 = OP_TYPE_NOT_IN; } break; - case 435: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -{ yylhsminor.yy148 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy404)); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 438: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy874)); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 437: /* boolean_value_expression ::= NOT boolean_primary */ + case 440: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy148), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy74), NULL)); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; + yymsp[-1].minor.yy74 = yylhsminor.yy74; break; - case 438: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 441: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy148); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), releaseRawExprNode(pCxt, yymsp[0].minor.yy148))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 439: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 442: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy148); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy148); - yylhsminor.yy148 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), releaseRawExprNode(pCxt, yymsp[0].minor.yy148))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); + yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 445: /* from_clause_opt ::= FROM table_reference_list */ - case 474: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==474); - case 502: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==502); -{ yymsp[-1].minor.yy148 = yymsp[0].minor.yy148; } + case 448: /* from_clause_opt ::= FROM table_reference_list */ + case 477: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==477); + case 505: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==505); +{ yymsp[-1].minor.yy74 = yymsp[0].minor.yy74; } break; - case 447: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy148 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy148, yymsp[0].minor.yy148, NULL); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 450: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy74 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy74, yymsp[0].minor.yy74, NULL); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 450: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy148 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy199, &yymsp[0].minor.yy199); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; + case 453: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy74 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy317, &yymsp[0].minor.yy317); } + yymsp[-1].minor.yy74 = yylhsminor.yy74; break; - case 451: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy148 = createRealTableNode(pCxt, &yymsp[-3].minor.yy199, &yymsp[-1].minor.yy199, &yymsp[0].minor.yy199); } - yymsp[-3].minor.yy148 = yylhsminor.yy148; + case 454: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy74 = createRealTableNode(pCxt, &yymsp[-3].minor.yy317, &yymsp[-1].minor.yy317, &yymsp[0].minor.yy317); } + yymsp[-3].minor.yy74 = yylhsminor.yy74; break; - case 452: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy148 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy148), &yymsp[0].minor.yy199); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; + case 455: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy74 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy74), &yymsp[0].minor.yy317); } + yymsp[-1].minor.yy74 = yylhsminor.yy74; break; - case 454: /* alias_opt ::= */ -{ yymsp[1].minor.yy199 = nil_token; } + case 457: /* alias_opt ::= */ +{ yymsp[1].minor.yy317 = nil_token; } break; - case 456: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy199 = yymsp[0].minor.yy199; } + case 459: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy317 = yymsp[0].minor.yy317; } break; - case 457: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 458: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==458); -{ yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148; } + case 460: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 461: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==461); +{ yymsp[-2].minor.yy74 = yymsp[-1].minor.yy74; } break; - case 459: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy148 = createJoinTableNode(pCxt, yymsp[-4].minor.yy470, yymsp[-5].minor.yy148, yymsp[-2].minor.yy148, yymsp[0].minor.yy148); } - yymsp[-5].minor.yy148 = yylhsminor.yy148; + case 462: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy74 = createJoinTableNode(pCxt, yymsp[-4].minor.yy630, yymsp[-5].minor.yy74, yymsp[-2].minor.yy74, yymsp[0].minor.yy74); } + yymsp[-5].minor.yy74 = yylhsminor.yy74; break; - case 460: /* join_type ::= */ -{ yymsp[1].minor.yy470 = JOIN_TYPE_INNER; } + case 463: /* join_type ::= */ +{ yymsp[1].minor.yy630 = JOIN_TYPE_INNER; } break; - case 461: /* join_type ::= INNER */ -{ yymsp[0].minor.yy470 = JOIN_TYPE_INNER; } + case 464: /* join_type ::= INNER */ +{ yymsp[0].minor.yy630 = JOIN_TYPE_INNER; } break; - case 462: /* 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 465: /* 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.yy148 = createSelectStmt(pCxt, yymsp[-10].minor.yy397, yymsp[-9].minor.yy404, yymsp[-8].minor.yy148); - yymsp[-11].minor.yy148 = addWhereClause(pCxt, yymsp[-11].minor.yy148, yymsp[-7].minor.yy148); - yymsp[-11].minor.yy148 = addPartitionByClause(pCxt, yymsp[-11].minor.yy148, yymsp[-6].minor.yy404); - yymsp[-11].minor.yy148 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy148, yymsp[-2].minor.yy148); - yymsp[-11].minor.yy148 = addGroupByClause(pCxt, yymsp[-11].minor.yy148, yymsp[-1].minor.yy404); - yymsp[-11].minor.yy148 = addHavingClause(pCxt, yymsp[-11].minor.yy148, yymsp[0].minor.yy148); - yymsp[-11].minor.yy148 = addRangeClause(pCxt, yymsp[-11].minor.yy148, yymsp[-5].minor.yy148); - yymsp[-11].minor.yy148 = addEveryClause(pCxt, yymsp[-11].minor.yy148, yymsp[-4].minor.yy148); - yymsp[-11].minor.yy148 = addFillClause(pCxt, yymsp[-11].minor.yy148, yymsp[-3].minor.yy148); + yymsp[-11].minor.yy74 = createSelectStmt(pCxt, yymsp[-10].minor.yy335, yymsp[-9].minor.yy874, yymsp[-8].minor.yy74); + yymsp[-11].minor.yy74 = addWhereClause(pCxt, yymsp[-11].minor.yy74, yymsp[-7].minor.yy74); + yymsp[-11].minor.yy74 = addPartitionByClause(pCxt, yymsp[-11].minor.yy74, yymsp[-6].minor.yy874); + yymsp[-11].minor.yy74 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy74, yymsp[-2].minor.yy74); + yymsp[-11].minor.yy74 = addGroupByClause(pCxt, yymsp[-11].minor.yy74, yymsp[-1].minor.yy874); + yymsp[-11].minor.yy74 = addHavingClause(pCxt, yymsp[-11].minor.yy74, yymsp[0].minor.yy74); + yymsp[-11].minor.yy74 = addRangeClause(pCxt, yymsp[-11].minor.yy74, yymsp[-5].minor.yy74); + yymsp[-11].minor.yy74 = addEveryClause(pCxt, yymsp[-11].minor.yy74, yymsp[-4].minor.yy74); + yymsp[-11].minor.yy74 = addFillClause(pCxt, yymsp[-11].minor.yy74, yymsp[-3].minor.yy74); } break; - case 465: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy397 = false; } + case 468: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy335 = false; } break; - case 468: /* select_item ::= NK_STAR */ -{ yylhsminor.yy148 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy148 = yylhsminor.yy148; + case 471: /* select_item ::= NK_STAR */ +{ yylhsminor.yy74 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy74 = yylhsminor.yy74; break; - case 470: /* select_item ::= common_expression column_alias */ - case 480: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==480); -{ yylhsminor.yy148 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy148), &yymsp[0].minor.yy199); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; + case 473: /* select_item ::= common_expression column_alias */ + case 483: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==483); +{ yylhsminor.yy74 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy74), &yymsp[0].minor.yy317); } + yymsp[-1].minor.yy74 = yylhsminor.yy74; break; - case 471: /* select_item ::= common_expression AS column_alias */ - case 481: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==481); -{ yylhsminor.yy148 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), &yymsp[0].minor.yy199); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 474: /* select_item ::= common_expression AS column_alias */ + case 484: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==484); +{ yylhsminor.yy74 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), &yymsp[0].minor.yy317); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 476: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 498: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==498); - case 517: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==517); -{ yymsp[-2].minor.yy404 = yymsp[0].minor.yy404; } + case 479: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 501: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==501); + case 520: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==520); +{ yymsp[-2].minor.yy874 = yymsp[0].minor.yy874; } break; - case 483: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy148 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy148), releaseRawExprNode(pCxt, yymsp[-1].minor.yy148)); } + case 486: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy74 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), releaseRawExprNode(pCxt, yymsp[-1].minor.yy74)); } break; - case 484: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy148 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy148)); } + case 487: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ +{ yymsp[-3].minor.yy74 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy74)); } break; - case 485: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy148 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy148), NULL, yymsp[-1].minor.yy148, yymsp[0].minor.yy148); } + case 488: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy74 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), NULL, yymsp[-1].minor.yy74, yymsp[0].minor.yy74); } break; - case 486: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy148 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy148), releaseRawExprNode(pCxt, yymsp[-3].minor.yy148), yymsp[-1].minor.yy148, yymsp[0].minor.yy148); } + case 489: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy74 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy74), releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), yymsp[-1].minor.yy74, yymsp[0].minor.yy74); } break; - case 490: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy148 = createFillNode(pCxt, yymsp[-1].minor.yy334, NULL); } + case 493: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy74 = createFillNode(pCxt, yymsp[-1].minor.yy828, NULL); } break; - case 491: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy148 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy404)); } + case 494: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy74 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy874)); } break; - case 492: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy334 = FILL_MODE_NONE; } + case 495: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy828 = FILL_MODE_NONE; } break; - case 493: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy334 = FILL_MODE_PREV; } + case 496: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy828 = FILL_MODE_PREV; } break; - case 494: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy334 = FILL_MODE_NULL; } + case 497: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy828 = FILL_MODE_NULL; } break; - case 495: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy334 = FILL_MODE_LINEAR; } + case 498: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy828 = FILL_MODE_LINEAR; } break; - case 496: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy334 = FILL_MODE_NEXT; } + case 499: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy828 = FILL_MODE_NEXT; } break; - case 499: /* group_by_list ::= expr_or_subquery */ -{ yylhsminor.yy404 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy148))); } - yymsp[0].minor.yy404 = yylhsminor.yy404; + case 502: /* group_by_list ::= expr_or_subquery */ +{ yylhsminor.yy874 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); } + yymsp[0].minor.yy874 = yylhsminor.yy874; break; - case 500: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy148))); } - yymsp[-2].minor.yy404 = yylhsminor.yy404; + case 503: /* 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.yy74))); } + yymsp[-2].minor.yy874 = yylhsminor.yy874; break; - case 504: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -{ yymsp[-5].minor.yy148 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy148), releaseRawExprNode(pCxt, yymsp[-1].minor.yy148)); } + case 507: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +{ yymsp[-5].minor.yy74 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), releaseRawExprNode(pCxt, yymsp[-1].minor.yy74)); } break; - case 507: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 510: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy148 = addOrderByClause(pCxt, yymsp[-3].minor.yy148, yymsp[-2].minor.yy404); - yylhsminor.yy148 = addSlimitClause(pCxt, yylhsminor.yy148, yymsp[-1].minor.yy148); - yylhsminor.yy148 = addLimitClause(pCxt, yylhsminor.yy148, yymsp[0].minor.yy148); + yylhsminor.yy74 = addOrderByClause(pCxt, yymsp[-3].minor.yy74, yymsp[-2].minor.yy874); + yylhsminor.yy74 = addSlimitClause(pCxt, yylhsminor.yy74, yymsp[-1].minor.yy74); + yylhsminor.yy74 = addLimitClause(pCxt, yylhsminor.yy74, yymsp[0].minor.yy74); } - yymsp[-3].minor.yy148 = yylhsminor.yy148; + yymsp[-3].minor.yy74 = yylhsminor.yy74; break; - case 510: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -{ yylhsminor.yy148 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy148, yymsp[0].minor.yy148); } - yymsp[-3].minor.yy148 = yylhsminor.yy148; + case 513: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +{ yylhsminor.yy74 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy74, yymsp[0].minor.yy74); } + yymsp[-3].minor.yy74 = yylhsminor.yy74; break; - case 511: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -{ yylhsminor.yy148 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy148, yymsp[0].minor.yy148); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 514: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +{ yylhsminor.yy74 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy74, yymsp[0].minor.yy74); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 519: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 523: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==523); -{ yymsp[-1].minor.yy148 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 522: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 526: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==526); +{ yymsp[-1].minor.yy74 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 520: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 524: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==524); -{ yymsp[-3].minor.yy148 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 523: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 527: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==527); +{ yymsp[-3].minor.yy74 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 521: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 525: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==525); -{ yymsp[-3].minor.yy148 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 524: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 528: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==528); +{ yymsp[-3].minor.yy74 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 526: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy148 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy148); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 529: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy74); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 531: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy148 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy148), yymsp[-1].minor.yy898, yymsp[0].minor.yy499); } - yymsp[-2].minor.yy148 = yylhsminor.yy148; + case 534: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy74 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), yymsp[-1].minor.yy326, yymsp[0].minor.yy109); } + yymsp[-2].minor.yy74 = yylhsminor.yy74; break; - case 532: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy898 = ORDER_ASC; } + case 535: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy326 = ORDER_ASC; } break; - case 533: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy898 = ORDER_ASC; } + case 536: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy326 = ORDER_ASC; } break; - case 534: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy898 = ORDER_DESC; } + case 537: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy326 = ORDER_DESC; } break; - case 535: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy499 = NULL_ORDER_DEFAULT; } + case 538: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy109 = NULL_ORDER_DEFAULT; } break; - case 536: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy499 = NULL_ORDER_FIRST; } + case 539: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy109 = NULL_ORDER_FIRST; } break; - case 537: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy499 = NULL_ORDER_LAST; } + case 540: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy109 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index daefa60af3..55e8dc7b49 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -545,6 +545,7 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, pAgg->hasLastRow = 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 e1687fc3a5..03e0275d7d 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1544,6 +1544,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); } @@ -1569,6 +1574,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); @@ -1577,6 +1584,7 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub if (TSDB_CODE_SUCCESS == code) { code = partTagsOptRebuildTbanme(pScan->pGroupTags); } + pCxt->optimized = true; return code; } @@ -2380,6 +2388,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 e5675310b5..df10fe8ee3 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 f5782dc937..a7eac2c853 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 eb6091d605..35b2479a51 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 81f73b1226..dcb7c02580 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -202,6 +202,15 @@ _return: QW_RET(code); } +bool qwTaskNotInExec(SQWTaskCtx *ctx) { + qTaskInfo_t taskHandle = ctx->taskHandle; + if (NULL == taskHandle || !qTaskIsExecuting(taskHandle)) { + return true; + } + + return false; +} + int32_t qwGenerateSchHbRsp(SQWorker *mgmt, SQWSchStatus *sch, SQWHbInfo *hbInfo) { int32_t taskNum = 0; @@ -508,16 +517,10 @@ 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); + if (QW_PHASE_POST_FETCH != phase || qwTaskNotInExec(ctx)) { + QW_ERR_JRET(qwDropTask(QW_FPARAMS())); + QW_ERR_JRET(ctx->rspCode); } - - // 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); } if (ctx->rspCode) { @@ -580,6 +583,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)); @@ -670,7 +674,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), @@ -688,6 +692,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; @@ -712,17 +717,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, @@ -744,14 +750,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); @@ -1178,8 +1183,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; @@ -1188,6 +1194,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)) { @@ -1200,9 +1208,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/src/filter.c b/source/libs/scalar/src/filter.c index d0c27560ca..de660ae958 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -90,7 +90,7 @@ rangeCompFunc gRangeCompare[] = {filterRangeCompee, filterRangeCompei, filterRan int8_t filterGetRangeCompFuncFromOptrs(uint8_t optr, uint8_t optr2) { if (optr2) { - assert(optr2 == OP_TYPE_LOWER_THAN || optr2 == OP_TYPE_LOWER_EQUAL); + ASSERT(optr2 == OP_TYPE_LOWER_THAN || optr2 == OP_TYPE_LOWER_EQUAL); if (optr == OP_TYPE_GREATER_THAN) { if (optr2 == OP_TYPE_LOWER_THAN) { @@ -705,7 +705,7 @@ int32_t filterAddRangeImpl(void *h, SFilterRange *ra, int32_t optr) { int32_t filterAddRange(void *h, SFilterRange *ra, int32_t optr) { SFilterRangeCtx *ctx = (SFilterRangeCtx *)h; int64_t tmp = 0; - + if (FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL)) { SIMPLE_COPY_VALUES(&ra->s, getDataMin(ctx->type, &tmp)); // FILTER_CLR_FLAG(ra->sflag, RA_NULL); @@ -723,7 +723,7 @@ int32_t filterAddRangeCtx(void *dst, void *src, int32_t optr) { SFilterRangeCtx *dctx = (SFilterRangeCtx *)dst; SFilterRangeCtx *sctx = (SFilterRangeCtx *)src; - assert(optr == LOGIC_COND_TYPE_OR); + ASSERT(optr == LOGIC_COND_TYPE_OR); if (sctx->rs == NULL) { return TSDB_CODE_SUCCESS; @@ -778,7 +778,10 @@ int32_t filterFinishRange(void *h) { while (r && r->next) { int64_t tmp = 1; - operateVal(&tmp, &r->ra.e, &tmp, OP_TYPE_ADD, ctx->type); + int32_t code = operateVal(&tmp, &r->ra.e, &tmp, OP_TYPE_ADD, ctx->type); + if (code != 0) { + return TSDB_CODE_APP_ERROR; + } if (ctx->pCompareFunc(&tmp, &r->next->ra.s) == 0) { rn = r->next; SIMPLE_COPY_VALUES((char *)&r->next->ra.s, (char *)&r->ra.s); @@ -1122,7 +1125,7 @@ int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, if (u->right.type == FLD_TYPE_VALUE) { SFilterField *val = FILTER_UNIT_RIGHT_FIELD(info, u); - assert(FILTER_GET_FLAG(val->flag, FLD_TYPE_VALUE)); + ASSERT(FILTER_GET_FLAG(val->flag, FLD_TYPE_VALUE)); } else { int32_t paramNum = scalarGetOperatorParamNum(optr); if (1 != paramNum) { @@ -1132,7 +1135,7 @@ int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, } SFilterField *col = FILTER_UNIT_LEFT_FIELD(info, u); - assert(FILTER_GET_FLAG(col->flag, FLD_TYPE_COLUMN)); + ASSERT(FILTER_GET_FLAG(col->flag, FLD_TYPE_COLUMN)); info->units[info->unitNum].compare.type = FILTER_GET_COL_FIELD_TYPE(col); info->units[info->unitNum].compare.precision = FILTER_GET_COL_FIELD_PRECISION(col); @@ -1292,29 +1295,29 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan if (optr == LOGIC_COND_TYPE_AND) { if (ctx->isnull) { - assert(ctx->notnull == false && ctx->isrange == false); + ASSERT(ctx->notnull == false && ctx->isrange == false); filterAddUnit(dst, OP_TYPE_IS_NULL, &left, NULL, &uidx); filterAddUnitToGroup(g, uidx); return TSDB_CODE_SUCCESS; } if (ctx->notnull) { - assert(ctx->isnull == false && ctx->isrange == false); + ASSERT(ctx->isnull == false && ctx->isrange == false); filterAddUnit(dst, OP_TYPE_IS_NOT_NULL, &left, NULL, &uidx); filterAddUnitToGroup(g, uidx); return TSDB_CODE_SUCCESS; } if (!ctx->isrange) { - assert(ctx->isnull || ctx->notnull); + ASSERT(ctx->isnull || ctx->notnull); return TSDB_CODE_SUCCESS; } - assert(ctx->rs && ctx->rs->next == NULL); + ASSERT(ctx->rs && ctx->rs->next == NULL); SFilterRange *ra = &ctx->rs->ra; - assert(!((FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL)) && (FILTER_GET_FLAG(ra->eflag, RANGE_FLG_NULL)))); + ASSERT(!((FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL)) && (FILTER_GET_FLAG(ra->eflag, RANGE_FLG_NULL)))); if ((!FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL)) && (!FILTER_GET_FLAG(ra->eflag, RANGE_FLG_NULL))) { __compar_fn_t func = getComparFunc(type, 0); @@ -1368,7 +1371,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan SFilterGroup ng = {0}; g = &ng; - assert(ctx->isnull || ctx->notnull || ctx->isrange); + ASSERT(ctx->isnull || ctx->notnull || ctx->isrange); if (ctx->isnull) { filterAddUnit(dst, OP_TYPE_IS_NULL, &left, NULL, &uidx); @@ -1377,7 +1380,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan } if (ctx->notnull) { - assert(!ctx->isrange); + ASSERT(!ctx->isrange); memset(g, 0, sizeof(*g)); filterAddUnit(dst, OP_TYPE_IS_NOT_NULL, &left, NULL, &uidx); @@ -1386,7 +1389,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan } if (!ctx->isrange) { - assert(ctx->isnull || ctx->notnull); + ASSERT(ctx->isnull || ctx->notnull); g->unitNum = 0; return TSDB_CODE_SUCCESS; } @@ -1444,7 +1447,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan filterAddUnitToGroup(g, uidx); } - assert(g->unitNum > 0); + ASSERT(g->unitNum > 0); taosArrayPush(res, g); @@ -1900,7 +1903,7 @@ void filterFreeInfo(SFilterInfo *info) { } int32_t filterHandleValueExtInfo(SFilterUnit *unit, char extInfo) { - assert(extInfo > 0 || extInfo < 0); + ASSERT(extInfo > 0 || extInfo < 0); uint8_t optr = FILTER_UNIT_OPTR(unit); switch (optr) { @@ -1916,7 +1919,8 @@ int32_t filterHandleValueExtInfo(SFilterUnit *unit, char extInfo) { unit->compare.optr = FILTER_DUMMY_EMPTY_OPTR; break; default: - assert(0); + fltError("unsupported operator type"); + return TSDB_CODE_APP_ERROR; } return TSDB_CODE_SUCCESS; @@ -1926,13 +1930,13 @@ int32_t fltInitValFieldData(SFilterInfo *info) { for (uint32_t i = 0; i < info->unitNum; ++i) { SFilterUnit *unit = &info->units[i]; if (unit->right.type != FLD_TYPE_VALUE) { - assert(unit->compare.optr == FILTER_DUMMY_EMPTY_OPTR || scalarGetOperatorParamNum(unit->compare.optr) == 1); + ASSERT(unit->compare.optr == FILTER_DUMMY_EMPTY_OPTR || scalarGetOperatorParamNum(unit->compare.optr) == 1); continue; } SFilterField *right = FILTER_UNIT_RIGHT_FIELD(info, unit); - assert(FILTER_GET_FLAG(right->flag, FLD_TYPE_VALUE)); + ASSERT(FILTER_GET_FLAG(right->flag, FLD_TYPE_VALUE)); uint32_t type = FILTER_UNIT_DATA_TYPE(unit); int8_t precision = FILTER_UNIT_DATA_PRECISION(unit); @@ -1940,7 +1944,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) { SValueNode *var = (SValueNode *)fi->desc; if (var == NULL) { - assert(fi->data != NULL); + ASSERT(fi->data != NULL); continue; } @@ -2068,7 +2072,8 @@ bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right) } default: - assert(false); + fltError("unsupported operator type"); + return false; } return true; @@ -2101,7 +2106,7 @@ int32_t filterAddUnitRange(SFilterInfo *info, SFilterUnit *u, SFilterRangeCtx *c FILTER_SET_FLAG(ra.sflag, RANGE_FLG_NULL); break; case OP_TYPE_NOT_EQUAL: - assert(type == TSDB_DATA_TYPE_BOOL); + ASSERT(type == TSDB_DATA_TYPE_BOOL); if (GET_INT8_VAL(val)) { SIMPLE_COPY_VALUES(&ra.s, &tmp); SIMPLE_COPY_VALUES(&ra.e, &tmp); @@ -2116,7 +2121,8 @@ int32_t filterAddUnitRange(SFilterInfo *info, SFilterUnit *u, SFilterRangeCtx *c SIMPLE_COPY_VALUES(&ra.e, val); break; default: - assert(0); + fltError("unsupported operator type"); + return TSDB_CODE_APP_ERROR; } filterAddRange(ctx, &ra, optr); @@ -2368,8 +2374,8 @@ int32_t filterMergeTwoGroupsImpl(SFilterInfo *info, SFilterRangeCtx **ctx, int32 filterReuseRangeCtx(*ctx, type, 0); } - assert(gRes2->colInfo[cidx].type == RANGE_TYPE_MR_CTX); - assert(gRes1->colInfo[cidx].type == RANGE_TYPE_MR_CTX); + ASSERT(gRes2->colInfo[cidx].type == RANGE_TYPE_MR_CTX); + ASSERT(gRes1->colInfo[cidx].type == RANGE_TYPE_MR_CTX); filterCopyRangeCtx(*ctx, gRes2->colInfo[cidx].info); filterSourceRangeFromCtx(*ctx, gRes1->colInfo[cidx].info, optr, empty, all); @@ -2405,7 +2411,7 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx **gRes1, SFilter continue; } - assert(idx1 == idx2); + ASSERT(idx1 == idx2); ++merNum; @@ -2455,15 +2461,15 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx **gRes1, SFilter } } - assert(merNum > 0); + ASSERT(merNum > 0); SFilterColInfo *colInfo = NULL; - assert(merNum == equal1 || merNum == equal2); + ASSERT(merNum == equal1 || merNum == equal2); filterFreeGroupCtx(*gRes2); *gRes2 = NULL; - assert(colCtxs && taosArrayGetSize(colCtxs) > 0); + ASSERT(colCtxs && taosArrayGetSize(colCtxs) > 0); int32_t ctxSize = (int32_t)taosArrayGetSize(colCtxs); SFilterColCtx *pctx = NULL; @@ -2520,7 +2526,7 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t *gR if (pColNum > 0) { for (int32_t m = 0; m <= pEnd; ++m) { for (int32_t n = cStart; n <= cEnd; ++n) { - assert(m < n); + ASSERT(m < n); filterMergeTwoGroups(info, &gRes[m], &gRes[n], &all); FLT_CHK_JMP(all); @@ -2541,7 +2547,7 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t *gR for (int32_t m = cStart; m < cEnd; ++m) { for (int32_t n = m + 1; n <= cEnd; ++n) { - assert(m < n); + ASSERT(m < n); filterMergeTwoGroups(info, &gRes[m], &gRes[n], &all); FLT_CHK_JMP(all); @@ -2636,7 +2642,7 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t gResNum for (uint32_t m = 0; m < res->colNum; ++m) { colInfo = &res->colInfo[res->colIdx[m]]; if (FILTER_NO_MERGE_DATA_TYPE(colInfo->dataType)) { - assert(colInfo->type == RANGE_TYPE_UNIT); + ASSERT(colInfo->type == RANGE_TYPE_UNIT); int32_t usize = (int32_t)taosArrayGetSize((SArray *)colInfo->info); for (int32_t n = 0; n < usize; ++n) { @@ -2649,7 +2655,7 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t gResNum continue; } - assert(colInfo->type == RANGE_TYPE_MR_CTX); + ASSERT(colInfo->type == RANGE_TYPE_MR_CTX); filterAddGroupUnitFromCtx(info, &oinfo, colInfo->info, res->colIdx[m], &ng, optr, group); } @@ -2690,7 +2696,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_ continue; } - assert(idxNum[i] == gResNum); + ASSERT(idxNum[i] == gResNum); if (idxs == NULL) { idxs = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(*idxs)); @@ -2714,7 +2720,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_ continue; } - assert(res->colIdx[n] == idxs[m]); + ASSERT(res->colIdx[n] == idxs[m]); SFilterColInfo *colInfo = &res->colInfo[res->colIdx[n]]; if (info->colRange[m] == NULL) { @@ -2723,7 +2729,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_ info->colRange[m]->colId = FILTER_GET_COL_FIELD_ID(fi); } - assert(colInfo->type == RANGE_TYPE_MR_CTX); + ASSERT(colInfo->type == RANGE_TYPE_MR_CTX); bool all = false; filterSourceRangeFromCtx(info->colRange[m], colInfo->info, LOGIC_COND_TYPE_OR, NULL, &all); @@ -2971,7 +2977,7 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3 unitIdx = pGroupIdx; --info->blkGroupNum; - assert(empty || all); + ASSERT(empty || all); if (empty) { FILTER_SET_FLAG(info->blkFlag, FI_STATUS_BLK_EMPTY); @@ -3077,7 +3083,7 @@ int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, SColumn goto _return; } - assert(info->unitNum > 1); + ASSERT(info->unitNum > 1); *all = filterExecuteBasedOnStatisImpl(info, numOfRows, p, statis, numOfCols); goto _return; diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index debc210f0f..c1e958b055 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -327,7 +327,10 @@ int32_t sclInitParam(SNode *node, SScalarParam *param, SScalarCtx *ctx, int32_t case QUERY_NODE_VALUE: { SValueNode *valueNode = (SValueNode *)node; - ASSERT(param->columnData == NULL); + if (param->columnData != NULL) { + sclError("columnData should be NULL"); + SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } param->numOfRows = 1; int32_t code = sclCreateColumnInfoData(&valueNode->node.resType, 1, param); if (code != TSDB_CODE_SUCCESS) { diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 1de8a35308..411b9b7ab5 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -361,7 +361,6 @@ static int32_t doLengthFunction(SScalarParam *pInput, int32_t inputNum, SScalarP SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; - ASSERT(pOutputData->info.type == TSDB_DATA_TYPE_BIGINT); int64_t *out = (int64_t *)pOutputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { @@ -1729,37 +1728,31 @@ bool getTimePseudoFuncEnv(SFunctionNode *UNUSED_PARAM(pFunc), SFuncExecEnv *pEnv } int32_t qStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - ASSERT(inputNum == 1); colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 0)); return TSDB_CODE_SUCCESS; } int32_t qEndTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - ASSERT(inputNum == 1); colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 1)); return TSDB_CODE_SUCCESS; } int32_t winDurFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - ASSERT(inputNum == 1); colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 2)); return TSDB_CODE_SUCCESS; } int32_t winStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - ASSERT(inputNum == 1); colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 3)); return TSDB_CODE_SUCCESS; } int32_t winEndTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - ASSERT(inputNum == 1); colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 4)); return TSDB_CODE_SUCCESS; } int32_t qTbnameFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - ASSERT(inputNum == 1); char* p = colDataGetVarData(pInput->columnData, 0); colDataAppendNItems(pOutput->columnData, pOutput->numOfRows, p, pInput->numOfRows); @@ -2598,7 +2591,7 @@ static bool checkStateOp(int8_t op, SColumnInfoData *pCol, int32_t index, SScala break; } default: { - ASSERT(0); + return false; } } return false; @@ -2771,7 +2764,9 @@ static bool getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *bin intervals[0] = -INFINITY; intervals[numOfBins - 1] = INFINITY; // in case of desc bin orders, -inf/inf should be swapped - ASSERT(numOfBins >= 4); + if (numOfBins < 4) { + return false; + } if (intervals[1] > intervals[numOfBins - 2]) { TSWAP(intervals[0], intervals[numOfBins - 1]); } diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index 8f2fe87a53..e9f345215e 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -389,18 +389,18 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) { func = varToUnsigned; } else if (IS_FLOAT_TYPE(pCtx->outType)) { func = varToFloat; - } else if (pCtx->outType == TSDB_DATA_TYPE_BINARY) { // nchar -> binary - ASSERT(pCtx->inType == TSDB_DATA_TYPE_NCHAR); + } else if (pCtx->outType == TSDB_DATA_TYPE_VARCHAR && + pCtx->inType == TSDB_DATA_TYPE_NCHAR) { // nchar -> binary func = ncharToVar; vton = true; - } else if (pCtx->outType == TSDB_DATA_TYPE_NCHAR) { // binary -> nchar - ASSERT(pCtx->inType == TSDB_DATA_TYPE_VARCHAR); + } else if (pCtx->outType == TSDB_DATA_TYPE_NCHAR && + pCtx->inType == TSDB_DATA_TYPE_VARCHAR) { // binary -> nchar func = varToNchar; vton = true; } else if (TSDB_DATA_TYPE_TIMESTAMP == pCtx->outType) { func = varToTimestamp; } else { - sclError("invalid convert outType:%d", pCtx->outType); + sclError("invalid convert outType:%d, inType:%d", pCtx->outType, pCtx->inType); return TSDB_CODE_APP_ERROR; } @@ -416,12 +416,10 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) { char *data = colDataGetVarData(pCtx->pIn->columnData, i); int32_t convertType = pCtx->inType; if (pCtx->inType == TSDB_DATA_TYPE_JSON) { - if (*data == TSDB_DATA_TYPE_NULL) { - ASSERT(0); - } else if (*data == TSDB_DATA_TYPE_NCHAR) { + if (*data == TSDB_DATA_TYPE_NCHAR) { data += CHAR_BYTES; convertType = TSDB_DATA_TYPE_NCHAR; - } else if (tTagIsJson(data)) { + } else if (tTagIsJson(data) || *data == TSDB_DATA_TYPE_NULL) { terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR; return terrno; } else { @@ -447,7 +445,11 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) { 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); + if (varDataLen(data) > bufSize) { + sclError("castConvert convert buffer size too small"); + taosMemoryFreeClear(tmp); + return TSDB_CODE_APP_ERROR; + } int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(data), varDataLen(data), tmp); if (len < 0) { @@ -557,27 +559,17 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t *fp = filterGetCompFunc(type, optr); if (IS_NUMERIC_TYPE(type)) { - if (typeLeft == TSDB_DATA_TYPE_NCHAR) { - ASSERT(0); - // convertNcharToDouble(*pLeftData, pLeftOut); - // *pLeftData = pLeftOut; - } else if (typeLeft == TSDB_DATA_TYPE_BINARY) { - ASSERT(0); - // convertBinaryToDouble(*pLeftData, pLeftOut); - // *pLeftData = pLeftOut; + if (typeLeft == TSDB_DATA_TYPE_NCHAR || + typeLeft == TSDB_DATA_TYPE_VARCHAR) { + return false; } else if (typeLeft != type) { convertNumberToNumber(*pLeftData, pLeftOut, typeLeft, type); *pLeftData = pLeftOut; } - if (typeRight == TSDB_DATA_TYPE_NCHAR) { - ASSERT(0); - // convertNcharToDouble(*pRightData, pRightOut); - // *pRightData = pRightOut; - } else if (typeRight == TSDB_DATA_TYPE_BINARY) { - ASSERT(0); - // convertBinaryToDouble(*pRightData, pRightOut); - // *pRightData = pRightOut; + if (typeRight == TSDB_DATA_TYPE_NCHAR || + typeRight == TSDB_DATA_TYPE_VARCHAR) { + return false; } else if (typeRight != type) { convertNumberToNumber(*pRightData, pRightOut, typeRight, type); *pRightData = pRightOut; @@ -592,7 +584,7 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t *freeRight = true; } } else { - ASSERT(0); + return false; } return true; @@ -683,7 +675,10 @@ int32_t vectorConvertSingleColImpl(const SScalarParam *pIn, SScalarParam *pOut, } if (overflow) { - ASSERT(1 == pIn->numOfRows); + if (1 != pIn->numOfRows) { + sclError("invalid numOfRows %d", pIn->numOfRows); + return TSDB_CODE_APP_ERROR; + } pOut->numOfRows = 0; @@ -1938,7 +1933,6 @@ _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binFunctionId) { case OP_TYPE_JSON_CONTAINS: return vectorJsonContains; default: - ASSERT(0); return NULL; } } diff --git a/source/libs/stream/src/stream.c b/source/libs/stream/src/stream.c index 5b542dd54b..60729c4d0e 100644 --- a/source/libs/stream/src/stream.c +++ b/source/libs/stream/src/stream.c @@ -187,6 +187,23 @@ int32_t streamTaskEnqueueRetrieve(SStreamTask* pTask, SStreamRetrieveReq* pReq, return status == TASK_INPUT_STATUS__NORMAL ? 0 : -1; } +int32_t streamTaskOutput(SStreamTask* pTask, SStreamDataBlock* pBlock) { + if (pTask->outputType == TASK_OUTPUT__TABLE) { + pTask->tbSink.tbSinkFunc(pTask, pTask->tbSink.vnode, 0, pBlock->blocks); + taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes); + taosFreeQitem(pBlock); + } else if (pTask->outputType == TASK_OUTPUT__SMA) { + pTask->smaSink.smaSink(pTask->smaSink.vnode, pTask->smaSink.smaId, pBlock->blocks); + taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes); + taosFreeQitem(pBlock); + } else { + ASSERT(pTask->outputType == TASK_OUTPUT__FIXED_DISPATCH || pTask->outputType == TASK_OUTPUT__SHUFFLE_DISPATCH); + taosWriteQitem(pTask->outputQueue->queue, pBlock); + streamDispatch(pTask); + } + return 0; +} + int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, SRpcMsg* pRsp, bool exec) { qDebug("task %d receive dispatch req from node %d task %d", pTask->taskId, pReq->upstreamNodeId, pReq->upstreamTaskId); @@ -199,9 +216,9 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S return -1; } - if (pTask->outputType == TASK_OUTPUT__FIXED_DISPATCH || pTask->outputType == TASK_OUTPUT__SHUFFLE_DISPATCH) { - streamDispatch(pTask); - } + /*if (pTask->outputType == TASK_OUTPUT__FIXED_DISPATCH || pTask->outputType == TASK_OUTPUT__SHUFFLE_DISPATCH) {*/ + /*streamDispatch(pTask);*/ + /*}*/ } else { streamSchedExec(pTask); } @@ -237,9 +254,9 @@ int32_t streamProcessRunReq(SStreamTask* pTask) { return -1; } - if (pTask->outputType == TASK_OUTPUT__FIXED_DISPATCH || pTask->outputType == TASK_OUTPUT__SHUFFLE_DISPATCH) { - streamDispatch(pTask); - } + /*if (pTask->outputType == TASK_OUTPUT__FIXED_DISPATCH || pTask->outputType == TASK_OUTPUT__SHUFFLE_DISPATCH) {*/ + /*streamDispatch(pTask);*/ + /*}*/ return 0; } diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index 3d42f759cb..786ee9d079 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -110,10 +110,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..6793430923 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; @@ -215,6 +228,7 @@ int32_t syncNodeStart(SSyncNode* pSyncNode); int32_t syncNodeStartStandBy(SSyncNode* pSyncNode); void syncNodeClose(SSyncNode* pSyncNode); void syncNodePreClose(SSyncNode* pSyncNode); +void syncNodePostClose(SSyncNode* pSyncNode); int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak, int64_t *seq); int32_t syncNodeRestore(SSyncNode* pSyncNode); void syncHbTimerDataFree(SSyncHbTimerData* pData); @@ -245,7 +259,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/syncSnapshot.h b/source/libs/sync/inc/syncSnapshot.h index 974a8f968e..5277e7818f 100644 --- a/source/libs/sync/inc/syncSnapshot.h +++ b/source/libs/sync/inc/syncSnapshot.h @@ -57,7 +57,6 @@ void snapshotSenderDestroy(SSyncSnapshotSender *pSender); bool snapshotSenderIsStart(SSyncSnapshotSender *pSender); int32_t snapshotSenderStart(SSyncSnapshotSender *pSender); void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish); -int32_t snapshotSend(SSyncSnapshotSender *pSender); int32_t snapshotReSend(SSyncSnapshotSender *pSender); typedef struct SSyncSnapshotReceiver { @@ -82,7 +81,6 @@ void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver) void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pBeginMsg); void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver); bool snapshotReceiverIsStart(SSyncSnapshotReceiver *pReceiver); -void snapshotReceiverForceStop(SSyncSnapshotReceiver *pReceiver); // on message int32_t syncNodeOnSnapshot(SSyncNode *ths, const SRpcMsg *pMsg); 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..91a05e78b0 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -124,6 +124,14 @@ void syncPreStop(int64_t rid) { } } +void syncPostStop(int64_t rid) { + SSyncNode* pSyncNode = syncNodeAcquire(rid); + if (pSyncNode != NULL) { + syncNodePostClose(pSyncNode); + syncNodeRelease(pSyncNode); + } +} + static bool syncNodeCheckNewConfig(SSyncNode* pSyncNode, const SSyncCfg* pCfg) { if (!syncNodeInConfig(pSyncNode, pCfg)) return false; return abs(pCfg->replicaNum - pSyncNode->replicaNum) <= 1; @@ -306,15 +314,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 +559,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 +625,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 +640,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 +659,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 +680,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 +852,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 +916,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 +941,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 +952,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 @@ -1250,9 +1244,10 @@ void syncNodePreClose(SSyncNode* pSyncNode) { } } +#if 0 if (pSyncNode->pNewNodeReceiver != NULL) { if (snapshotReceiverIsStart(pSyncNode->pNewNodeReceiver)) { - snapshotReceiverForceStop(pSyncNode->pNewNodeReceiver); + snapshotReceiverStop(pSyncNode->pNewNodeReceiver); } sDebug("vgId:%d, snapshot receiver destroy while preclose sync node, data:%p", pSyncNode->vgId, @@ -1260,12 +1255,29 @@ void syncNodePreClose(SSyncNode* pSyncNode) { snapshotReceiverDestroy(pSyncNode->pNewNodeReceiver); pSyncNode->pNewNodeReceiver = NULL; } +#endif // stop elect timer syncNodeStopElectTimer(pSyncNode); // stop heartbeat timer syncNodeStopHeartbeatTimer(pSyncNode); + + // clean rsp + syncRespCleanRsp(pSyncNode->pSyncRespMgr); +} + +void syncNodePostClose(SSyncNode* pSyncNode) { + if (pSyncNode->pNewNodeReceiver != NULL) { + if (snapshotReceiverIsStart(pSyncNode->pNewNodeReceiver)) { + snapshotReceiverStop(pSyncNode->pNewNodeReceiver); + } + + sDebug("vgId:%d, snapshot receiver destroy while preclose sync node, data:%p", pSyncNode->vgId, + pSyncNode->pNewNodeReceiver); + snapshotReceiverDestroy(pSyncNode->pNewNodeReceiver); + pSyncNode->pNewNodeReceiver = NULL; + } } void syncHbTimerDataFree(SSyncHbTimerData* pData) { taosMemoryFree(pData); } @@ -1293,8 +1305,6 @@ void syncNodeClose(SSyncNode* pSyncNode) { pSyncNode->pLogStore = NULL; syncLogBufferDestroy(pSyncNode->pLogBuf); pSyncNode->pLogBuf = NULL; - raftCfgClose(pSyncNode->pRaftCfg); - pSyncNode->pRaftCfg = NULL; syncNodeStopPingTimer(pSyncNode); syncNodeStopElectTimer(pSyncNode); @@ -1315,7 +1325,7 @@ void syncNodeClose(SSyncNode* pSyncNode) { if (pSyncNode->pNewNodeReceiver != NULL) { if (snapshotReceiverIsStart(pSyncNode->pNewNodeReceiver)) { - snapshotReceiverForceStop(pSyncNode->pNewNodeReceiver); + snapshotReceiverStop(pSyncNode->pNewNodeReceiver); } sDebug("vgId:%d, snapshot receiver destroy while close, data:%p", pSyncNode->vgId, pSyncNode->pNewNodeReceiver); @@ -1330,7 +1340,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 +1402,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 +1471,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 +1534,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 +1564,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 +1592,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 +1610,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 +1636,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 +1647,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 +1680,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 -------------- @@ -1863,7 +1855,7 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) { // close receiver if (pSyncNode != NULL && pSyncNode->pNewNodeReceiver != NULL && snapshotReceiverIsStart(pSyncNode->pNewNodeReceiver)) { - snapshotReceiverForceStop(pSyncNode->pNewNodeReceiver); + snapshotReceiverStop(pSyncNode->pNewNodeReceiver); } // stop elect timer @@ -2701,16 +2693,12 @@ int32_t syncNodeOnClientRequest(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIn } int32_t code = syncNodeAppend(ths, pEntry); - if (code < 0) { - sNError(ths, "failed to append blocking msg"); - } return code; } else { syncEntryDestroy(pEntry); pEntry = NULL; + return -1; } - - return -1; } int32_t syncNodeOnClientRequestOld(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIndex) { @@ -2889,9 +2877,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..defb7402f4 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -150,7 +150,7 @@ void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { // when sender receive ack, call this function to send msg from seq // seq = ack + 1, already updated -int32_t snapshotSend(SSyncSnapshotSender *pSender) { +static int32_t snapshotSend(SSyncSnapshotSender *pSender) { // free memory last time (current seq - 1) if (pSender->pCurrentBlock != NULL) { taosMemoryFree(pSender->pCurrentBlock); @@ -342,23 +342,6 @@ void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver) { bool snapshotReceiverIsStart(SSyncSnapshotReceiver *pReceiver) { return pReceiver->start; } -// force stop -void snapshotReceiverForceStop(SSyncSnapshotReceiver *pReceiver) { - sRInfo(pReceiver, "snapshot receiver force stop, writer:%p"); - - // force close, abandon incomplete data - if (pReceiver->pWriter != NULL) { - int32_t ret = pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, false, - &pReceiver->snapshot); - if (ret != 0) { - sRInfo(pReceiver, "snapshot receiver force stop failed since %s", terrstr()); - } - pReceiver->pWriter = NULL; - } - - pReceiver->start = false; -} - static int32_t snapshotReceiverStartWriter(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pBeginMsg) { if (pReceiver->pWriter != NULL) { sRError(pReceiver, "vgId:%d, snapshot receiver writer is not null"); @@ -406,7 +389,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); @@ -590,7 +573,7 @@ _START_RECEIVER: if (snapshotReceiverIsStart(pReceiver)) { sRInfo(pReceiver, "snapshot receiver already start and force stop pre one"); - snapshotReceiverForceStop(pReceiver); + snapshotReceiverStop(pReceiver); } snapshotReceiverStart(pReceiver, pMsg); // set start-time same with sender @@ -842,7 +825,7 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_FORCE_CLOSE) { // force close, no response syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process force stop"); - snapshotReceiverForceStop(pReceiver); + snapshotReceiverStop(pReceiver); } else if (pMsg->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pMsg->seq < SYNC_SNAPSHOT_SEQ_END) { syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process seq data"); code = syncNodeOnSnapshotReceive(pSyncNode, pMsg); @@ -989,6 +972,13 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { return syncNodeOnSnapshotPreRsp(pSyncNode, pSender, pMsg); } + if (pSender->pReader == NULL || pSender->finish) { + syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "snapshot sender invalid"); + sSError(pSender, "snapshot sender invalid, pReader:%p finish:%d", pMsg->code, pSender->pReader, pSender->finish); + terrno = pMsg->code; + goto _ERROR; + } + if (pMsg->ack == SYNC_SNAPSHOT_SEQ_BEGIN) { syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq begin"); if (snapshotSenderUpdateProgress(pSender, pMsg) != 0) { 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 5c1f264460..79d37b7674 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -1742,6 +1742,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/CMakeLists.txt b/source/os/CMakeLists.txt index b7cb20896b..3aac5e9775 100644 --- a/source/os/CMakeLists.txt +++ b/source/os/CMakeLists.txt @@ -41,9 +41,13 @@ target_link_libraries( ) if(TD_WINDOWS) target_link_libraries( - os PUBLIC ws2_32 iconv msvcregex wcwidth winmm crashdump + os PUBLIC ws2_32 iconv msvcregex wcwidth winmm crashdump dbghelp ) elseif(TD_DARWIN_64) + find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation) + target_link_libraries(os PUBLIC ${CORE_FOUNDATION_FRAMEWORK}) + find_library(SYSTEM_CONFIGURATION_FRAMEWORK SystemConfiguration) + target_link_libraries(os PUBLIC ${SYSTEM_CONFIGURATION_FRAMEWORK}) target_link_libraries( os PUBLIC dl m iconv ) @@ -55,4 +59,8 @@ endif() IF (JEMALLOC_ENABLED) target_link_libraries(os PUBLIC -ljemalloc) -ENDIF () \ No newline at end of file +ENDIF () + +if(${BUILD_TEST}) + add_subdirectory(test) +endif(${BUILD_TEST}) \ No newline at end of file diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index fce276bc35..3f527e9130 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -526,6 +526,21 @@ int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) { int32_t taosLockFile(TdFilePtr pFile) { #ifdef WINDOWS + BOOL fSuccess = FALSE; + LARGE_INTEGER fileSize; + OVERLAPPED overlapped = {0}; + + HANDLE hFile = (HANDLE)_get_osfhandle(pFile->fd); + + fSuccess = LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, + 0, // reserved + ~0, // number of bytes to lock low + ~0, // number of bytes to lock high + &overlapped // overlapped structure + ); + if (!fSuccess) { + return GetLastError(); + } return 0; #else assert(pFile->fd >= 0); // Please check if you have closed the file. @@ -536,6 +551,14 @@ int32_t taosLockFile(TdFilePtr pFile) { int32_t taosUnLockFile(TdFilePtr pFile) { #ifdef WINDOWS + BOOL fSuccess = FALSE; + OVERLAPPED overlapped = {0}; + HANDLE hFile = (HANDLE)_get_osfhandle(pFile->fd); + + fSuccess = UnlockFileEx(hFile, 0, ~0, ~0, &overlapped); + if (!fSuccess) { + return GetLastError(); + } return 0; #else assert(pFile->fd >= 0); // Please check if you have closed the file. diff --git a/source/os/src/osMath.c b/source/os/src/osMath.c index cd2acac261..dddadd5ff6 100644 --- a/source/os/src/osMath.c +++ b/source/os/src/osMath.c @@ -16,6 +16,7 @@ #define ALLOW_FORBID_FUNC #define _DEFAULT_SOURCE #include "os.h" +#include #ifdef WINDOWS void swapStr(char* j, char* J, int width) { @@ -33,16 +34,5 @@ void swapStr(char* j, char* J, int width) { // todo refactor: 1) move away; 2) use merge sort instead; 3) qsort is not a stable sort actually. void taosSort(void* arr, int64_t sz, int64_t width, __compar_fn_t compar) { -#ifdef WINDOWS - int64_t i, j; - for (i = 0; i < sz - 1; i++) { - for (j = 0; j < sz - 1 - i; j++) { - if (compar((char*)arr + j * width, (char*)arr + (j + 1) * width) > 0.00) { - swapStr((char*)arr + j * width, (char*)arr + (j + 1) * width, width); - } - } - } -#else qsort(arr, sz, width, compar); -#endif } diff --git a/source/os/src/osSocket.c b/source/os/src/osSocket.c index db2a9937b5..6611a937f2 100644 --- a/source/os/src/osSocket.c +++ b/source/os/src/osSocket.c @@ -988,7 +988,7 @@ int32_t taosGetFqdn(char *fqdn) { #endif char hostname[1024]; hostname[1023] = '\0'; - if (gethostname(hostname, 1023) == -1) { + if (taosGetlocalhostname(hostname, 1023) == -1) { #ifdef WINDOWS printf("failed to get hostname, reason:%s\n", strerror(WSAGetLastError())); #else @@ -998,30 +998,28 @@ int32_t taosGetFqdn(char *fqdn) { return -1; } - struct addrinfo hints = {0}; - struct addrinfo *result = NULL; #ifdef __APPLE__ // on macosx, hostname -f has the form of xxx.local // which will block getaddrinfo for a few seconds if AI_CANONNAME is set // thus, we choose AF_INET (ipv4 for the moment) to make getaddrinfo return // immediately - hints.ai_family = AF_INET; + // hints.ai_family = AF_INET; + strcpy(fqdn, hostname); + strcpy(fqdn+strlen(hostname), ".local"); #else // __APPLE__ + struct addrinfo hints = {0}; + struct addrinfo *result = NULL; hints.ai_flags = AI_CANONNAME; -#endif // __APPLE__ + int32_t ret = getaddrinfo(hostname, NULL, &hints, &result); if (!result) { fprintf(stderr, "failed to get fqdn, code:%d, reason:%s\n", ret, gai_strerror(ret)); return -1; } - -#ifdef __APPLE__ - // refer to comments above - strcpy(fqdn, hostname); -#else // __APPLE__ strcpy(fqdn, result->ai_canonname); -#endif // __APPLE__ freeaddrinfo(result); +#endif // __APPLE__ + return 0; } diff --git a/source/os/src/osSysinfo.c b/source/os/src/osSysinfo.c index 704b1b9738..7521ae4e0f 100644 --- a/source/os/src/osSysinfo.c +++ b/source/os/src/osSysinfo.c @@ -98,6 +98,9 @@ LONG WINAPI exceptionHandler(LPEXCEPTION_POINTERS exception); #include #include #include +#include +#include +#include #else @@ -1003,6 +1006,11 @@ SysNameInfo taosGetSysNameInfo() { tstrncpy(info.machine, uts.machine, sizeof(info.machine)); } + char localHostName[512]; + taosGetlocalhostname(localHostName, 512); + TdCmdPtr pCmd = taosOpenCmd("scutil --get LocalHostName"); + tstrncpy(info.nodename, localHostName, sizeof(info.nodename)); + return info; #else SysNameInfo info = {0}; @@ -1038,3 +1046,46 @@ bool taosCheckCurrentInDll() { return false; #endif } + +#ifdef _TD_DARWIN_64 +int taosGetMaclocalhostnameByCommand(char *hostname, size_t maxLen) { + TdCmdPtr pCmd = taosOpenCmd("scutil --get LocalHostName"); + if (pCmd != NULL) { + if (taosGetsCmd(pCmd, maxLen - 1, hostname) > 0) { + int len = strlen(hostname); + if (hostname[len - 1] == '\n') { + hostname[len - 1] = '\0'; + } + return 0; + } + taosCloseCmd(&pCmd); + } + return -1; +} + +int getMacLocalHostNameBySCD(char *hostname, size_t maxLen) { + SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR(""), NULL, NULL); + CFStringRef hostname_cfstr = SCDynamicStoreCopyLocalHostName(store); + if (hostname_cfstr != NULL) { + CFStringGetCString(hostname_cfstr, hostname, maxLen - 1, kCFStringEncodingMacRoman); + CFRelease(hostname_cfstr); + } else { + return -1; + } + CFRelease(store); + return 0; +} +#endif + +int taosGetlocalhostname(char *hostname, size_t maxLen) { +#ifdef _TD_DARWIN_64 + int res = getMacLocalHostNameBySCD(hostname, maxLen); + if (res != 0) { + return taosGetMaclocalhostnameByCommand(hostname, maxLen); + } else { + return 0; + } +#else + return gethostname(hostname, maxLen); +#endif +} diff --git a/source/os/test/CMakeLists.txt b/source/os/test/CMakeLists.txt new file mode 100644 index 0000000000..21fb2ee630 --- /dev/null +++ b/source/os/test/CMakeLists.txt @@ -0,0 +1,24 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20) +PROJECT(TDengine) + +FIND_PATH(HEADER_GTEST_INCLUDE_DIR gtest.h /usr/include/gtest /usr/local/include/gtest) +FIND_LIBRARY(LIB_GTEST_STATIC_DIR libgtest.a /usr/lib/ /usr/local/lib /usr/lib64) +FIND_LIBRARY(LIB_GTEST_SHARED_DIR libgtest.so /usr/lib/ /usr/local/lib /usr/lib64) + +IF (HEADER_GTEST_INCLUDE_DIR AND (LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) + MESSAGE(STATUS "gTest library found, build os test") + + INCLUDE_DIRECTORIES(${HEADER_GTEST_INCLUDE_DIR}) + AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) + +ENDIF() + +INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/src/util/inc) + +# osTests +add_executable(osTests "osTests.cpp") +target_link_libraries(osTests os util gtest_main) +add_test( + NAME osTests + COMMAND osTests +) \ No newline at end of file diff --git a/source/os/test/osTests.cpp b/source/os/test/osTests.cpp index e69de29bb2..f831f457f9 100644 --- a/source/os/test/osTests.cpp +++ b/source/os/test/osTests.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include +#include + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wwrite-strings" +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wformat" +#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" +#pragma GCC diagnostic ignored "-Wpointer-arith" + +#include "os.h" +#include "tlog.h" + +TEST(osTest, osSystem) { + const char *flags = "UTL FATAL "; + ELogLevel level = DEBUG_FATAL; + int32_t dflag = 255; // tsLogEmbedded ? 255 : uDebugFlag + taosPrintTrace(flags, level, dflag); +} + +void fileOperateOnFree(void *param) { + char * fname = (char *)param; + TdFilePtr pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE); + printf("On free thread open file\n"); + ASSERT_NE(pFile, nullptr); + + int ret = taosLockFile(pFile); + printf("On free thread lock file ret:%d\n", ret); + ASSERT_EQ(ret, 0); + + ret = taosUnLockFile(pFile); + printf("On free thread unlock file ret:%d\n", ret); + ASSERT_EQ(ret, 0); + + ret = taosCloseFile(&pFile); + ASSERT_EQ(ret, 0); + printf("On free thread close file ret:%d\n", ret); +} +void *fileOperateOnFreeThread(void *param) { + fileOperateOnFree(param); + return NULL; +} +void fileOperateOnBusy(void *param) { + char * fname = (char *)param; + TdFilePtr pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE); + printf("On busy thread open file\n"); + ASSERT_NE(pFile, nullptr); + + int ret = taosLockFile(pFile); + printf("On busy thread lock file ret:%d\n", ret); + ASSERT_NE(ret, 0); + + ret = taosUnLockFile(pFile); + printf("On busy thread unlock file ret:%d\n", ret); +#ifdef _TD_DARWIN_64 + ASSERT_EQ(ret, 0); +#else + ASSERT_NE(ret, 0); +#endif + + ret = taosCloseFile(&pFile); + printf("On busy thread close file ret:%d\n", ret); + ASSERT_EQ(ret, 0); +} +void *fileOperateOnBusyThread(void *param) { + fileOperateOnBusy(param); + return NULL; +} + +TEST(osTest, osFile) { + char *fname = "./osfiletest1.txt"; + + TdFilePtr pOutFD = taosCreateFile(fname, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC); + ASSERT_NE(pOutFD, nullptr); + printf("create file success\n"); + + TdFilePtr pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE); + printf("open file\n"); + ASSERT_NE(pFile, nullptr); + + int ret = taosLockFile(pFile); + printf("lock file ret:%d\n", ret); + ASSERT_EQ(ret, 0); + + TdThreadAttr thattr; + taosThreadAttrInit(&thattr); + + TdThread thread1, thread2; + taosThreadCreate(&(thread1), &thattr, fileOperateOnBusyThread, (void *)fname); + taosThreadAttrDestroy(&thattr); + + taosThreadJoin(thread1, NULL); + taosThreadClear(&thread1); + + ret = taosUnLockFile(pFile); + printf("unlock file ret:%d\n", ret); + ASSERT_EQ(ret, 0); + + ret = taosCloseFile(&pFile); + printf("close file ret:%d\n", ret); + ASSERT_EQ(ret, 0); + + taosThreadCreate(&(thread2), &thattr, fileOperateOnFreeThread, (void *)fname); + taosThreadAttrDestroy(&thattr); + + taosThreadJoin(thread2, NULL); + taosThreadClear(&thread2); + + //int ret = taosRemoveFile(fname); + //ASSERT_EQ(ret, 0); + //printf("remove file success"); +} + +#pragma GCC diagnostic pop 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 ca8b64fe1e..7a52991e81 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -23,6 +23,7 @@ #include "thash.h" #include "tlog.h" #include "types.h" +#include "osString.h" int32_t setChkInBytes1(const void *pLeft, const void *pRight) { return NULL != taosHashGet((SHashObj *)pRight, pLeft, 1) ? 1 : 0; @@ -208,16 +209,16 @@ int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight) { int32_t len1 = varDataLen(pLeft); int32_t len2 = varDataLen(pRight); - if (len1 != len2) { - return len1 > len2 ? 1 : -1; - } else { - int32_t ret = memcmp((TdUcs4 *)pLeft, (TdUcs4 *)pRight, len1); - if (ret == 0) { + int32_t ret = tasoUcs4Compare((TdUcs4 *)varDataVal(pLeft), (TdUcs4 *)varDataVal(pRight), len1>len2 ? len2:len1); + if (ret == 0) { + if (len1 > len2) + return 1; + else if(len1 < len2) + return -1; + else return 0; - } else { - return ret > 0 ? 1 : -1; - } } + return (ret < 0) ? -1 : 1; } int32_t compareLenPrefixedWStrDesc(const void *pLeft, const void *pRight) { @@ -244,7 +245,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; } } @@ -1285,7 +1286,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"); } } @@ -1308,7 +1309,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"); } } diff --git a/source/util/src/tcompression.c b/source/util/src/tcompression.c index b46d0ebc3d..e2f8cab281 100644 --- a/source/util/src/tcompression.c +++ b/source/util/src/tcompression.c @@ -661,7 +661,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; @@ -756,7 +756,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) { @@ -820,7 +820,7 @@ int32_t tsDecompressTimestampImp(const char *const input, const int32_t nelement } } else { - assert(0); + ASSERT(0); return -1; } } @@ -2337,7 +2337,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; } } @@ -2350,7 +2350,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; } } @@ -2371,7 +2371,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 @@ -2394,7 +2394,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 @@ -2418,7 +2418,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 @@ -2441,7 +2441,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 @@ -2472,7 +2472,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; } } @@ -2485,7 +2485,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; } } @@ -2499,7 +2499,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; } } @@ -2512,7 +2512,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; } } @@ -2526,7 +2526,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; } } @@ -2539,7 +2539,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; } } @@ -2553,7 +2553,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; } } @@ -2566,7 +2566,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; } } @@ -2580,7 +2580,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; } } @@ -2593,7 +2593,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 6f8b0d8e04..14c3df38a7 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -276,8 +276,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/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 984474ceaa..f84da15110 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); @@ -399,7 +399,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 @@ -418,11 +418,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 @@ -432,7 +432,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; @@ -441,7 +441,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; @@ -479,7 +479,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); } @@ -488,8 +490,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 cf1d3be3a6..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); } } @@ -158,7 +159,9 @@ 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) { @@ -185,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; @@ -214,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; } diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index f5f04ff1e9..1205da31b3 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 @@ -698,8 +702,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 @@ -714,11 +718,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 @@ -732,6 +736,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 @@ -830,6 +835,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 @@ -925,6 +932,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 @@ -1030,6 +1039,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/api/dbTableRoute.c b/tests/script/api/dbTableRoute.c index 2cf721875a..bbf17c41e4 100644 --- a/tests/script/api/dbTableRoute.c +++ b/tests/script/api/dbTableRoute.c @@ -26,7 +26,10 @@ #include #include "taos.h" -int rtTables = 20; +#define RT_TABLE_NUM 100 + +int rtTables = RT_TABLE_NUM; +int rtTableUs[RT_TABLE_NUM] = {0}; char hostName[128]; static void rtExecSQL(TAOS *taos, char *command) { @@ -101,6 +104,22 @@ int rtPrepare(TAOS ** p, int prefix, int suffix) { return 0; } +int32_t rtGetTimeOfDay(struct timeval *tv) { + return gettimeofday(tv, NULL); +} +static int64_t rtGetTimestampMs() { + struct timeval systemTime; + rtGetTimeOfDay(&systemTime); + return (int64_t)systemTime.tv_sec * 1000LL + (int64_t)systemTime.tv_usec/1000; +} + +static int64_t rtGetTimestampUs() { + struct timeval systemTime; + rtGetTimeOfDay(&systemTime); + return (int64_t)systemTime.tv_sec * 1000000LL + (int64_t)systemTime.tv_usec; +} + + int rtGetDbRouteInfo(TAOS * taos) { TAOS_DB_ROUTE_INFO dbInfo; int code = taos_get_db_route_info(taos, "db1", &dbInfo); @@ -126,7 +145,10 @@ int rtGetTableRouteInfo(TAOS * taos) { char sql[1024] = {0}; for (int32_t i = 0; i < rtTables; ++i) { sprintf(table, "tb%d", i); + int64_t startTs = rtGetTimestampUs(); int code = taos_get_table_vgId(taos, "db1", table, &vgId1); + int64_t endTs = rtGetTimestampUs(); + rtTableUs[i] = (int)(endTs - startTs); if (code) { rtExit("taos_get_table_vgId", taos_errstr(NULL)); } @@ -142,9 +164,61 @@ int rtGetTableRouteInfo(TAOS * taos) { } } + printf("table vgId use us:"); + + for (int32_t i = 0; i < rtTables; ++i) { + printf("%d ", rtTableUs[i]); + } + + printf("\n"); + return 0; } +int rtGetTablesRouteInfo(TAOS * taos) { + char *table = {0}; + int *vgId1 = malloc(rtTables * sizeof(int)); + int vgId2 = 0; + char sql[1024] = {0}; + const char *tbs[RT_TABLE_NUM] = {0}; + + for (int32_t i = 0; i < rtTables; ++i) { + table = malloc(10); + sprintf(table, "tb%d", i); + tbs[i] = table; + } + + int64_t startTs = rtGetTimestampUs(); + int code = taos_get_tables_vgId(taos, "db1", tbs, rtTables, vgId1); + int64_t endTs = rtGetTimestampUs(); + rtTableUs[0] = (int)(endTs - startTs); + if (code) { + rtExit("taos_get_tables_vgId", taos_errstr(NULL)); + } + + for (int32_t i = 0; i < rtTables; ++i) { + sprintf(sql, "select vgroup_id from information_schema.ins_tables where table_name=\"tb%d\"", i); + + rtFetchVgId(taos, sql, &vgId2); + if (vgId1[i] != vgId2) { + fprintf(stderr, "!!!! table tb%d vgId mis-match, vgId(api):%d, vgId(sys):%d\n", i, vgId1[i], vgId2); + exit(1); + } else { + printf("table tb%d vgId %d\n", i, vgId1[i]); + } + } + + printf("tables vgId use us:%d\n", rtTableUs[0]); + + for (int32_t i = 0; i < rtTables; ++i) { + free((void*)tbs[i]); + } + free(vgId1); + + return 0; +} + + void rtClose(TAOS * taos) { taos_close(taos); } @@ -170,6 +244,16 @@ int rtRunCase2(void) { return 0; } +int rtRunCase3(void) { + TAOS *taos = NULL; + rtPrepare(&taos, 0, 0); + rtGetTablesRouteInfo(taos); + rtClose(taos); + + return 0; +} + + int main(int argc, char *argv[]) { if (argc != 2) { printf("usage: %s server-ip\n", argv[0]); @@ -182,6 +266,7 @@ int main(int argc, char *argv[]) { rtRunCase1(); rtRunCase2(); + rtRunCase3(); int32_t l = 5; while (l) { 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/insert/insert_select.sim b/tests/script/tsim/insert/insert_select.sim index e3374ee277..333964b1d6 100644 --- a/tests/script/tsim/insert/insert_select.sim +++ b/tests/script/tsim/insert/insert_select.sim @@ -42,4 +42,24 @@ if $rows != 2 then return -1 endi +print ======== step2 +sql drop database if exists db1; +sql create database db1 vgroups 1; +sql use db1; +sql create table t1(ts timestamp, a int, b int ); +sql create table t2(ts timestamp, a int, b int ); +sql insert into t1 values(1648791211000,1,2); +sql insert into t2 (ts, b, a) select ts, a, b from t1; +sql select * from t2; +if $rows != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 1 then + return -1 +endi + + system sh/exec.sh -n dnode1 -s stop -x SIGINT 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/script/tsim/stream/basic3.sim b/tests/script/tsim/stream/basic3.sim index 41e19b19af..e598919e34 100644 --- a/tests/script/tsim/stream/basic3.sim +++ b/tests/script/tsim/stream/basic3.sim @@ -1,6 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c debugflag 131 +system sh/cfg.sh -n dnode1 -c debugflag -v 131 +system sh/cfg.sh -n dnode1 -c keepColumnName -v 1 system sh/exec.sh -n dnode1 -s start sleep 5000 @@ -9,7 +10,7 @@ sql connect print ========== interval\session\state window -sql CREATE DATABASE test1 BUFFER 96 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 14400m WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 KEEP 5256000m,5256000m,5256000m PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 STRICT 'off' WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0; +sql CREATE DATABASE test1 VGROUPS 2; sql use test1; sql CREATE STABLE st (time TIMESTAMP, ca DOUBLE, cb DOUBLE, cc int) TAGS (ta VARCHAR(10) ); @@ -29,6 +30,76 @@ sql create stream streamd4 into streamt4 as select tbname, _wstart,_wend, count( sql create stream streamd5 into streamt5 as select tbname, _wstart,_wend, count(*), max(ca), min(cb) from st where time > "2022-01-01 00:00:00" and time < "2032-01-01 00:00:00" partition by tbname state_window(cc); sql create stream streamd6 into streamt6 as select ca, _wstart,_wend, count(*), max(ca), min(cb) from t1 where time > "2022-01-01 00:00:00" and time < "2032-01-01 00:00:00" partition by ca state_window(cc); + +sql alter local 'keepColumnName' '1' + +sql CREATE STABLE `meters_test_data` (`ts` TIMESTAMP, `close` FLOAT, `parttime` TIMESTAMP, `parttime_str` VARCHAR(32)) TAGS (`id` VARCHAR(32)); + +sql_error create stream realtime_meters fill_history 1 into realtime_meters as select last(parttime),first(close),last(close) from meters_test_data partition by tbname state_window(parttime_str); +sql_error create stream streamd7 into streamt7 as select _wstart, _wend, count(*), first(ca), last(ca) from t1 interval(10s); +sql_error create stream streamd71 into streamt71 as select _wstart, _wend, count(*) as ca, first(ca), last(ca) as c2 from t1 interval(10s); + +sql create stream streamd8 into streamt8 as select _wstart, _wend, count(*), first(ca) as c1, last(ca) as c2 from t1 interval(10s); +sql desc streamt8; + +if $rows == 0 then + return -1 +endi + +sql create stream streamd9 into streamt9 as select _wstart, _wend, count(*), first(ca) as c1, last(ca) from t1 interval(10s); +sql desc streamt9; + +if $rows == 0 then + return -1 +endi + +sql_error create stream streamd11 into streamd11 as select _wstart, _wend, count(*), last(ca), last(ca) from t1 interval(10s); + +sql alter local 'keepColumnName' '0' + +sql create stream realtime_meters fill_history 1 into realtime_meters as select last(parttime),first(close),last(close) from meters_test_data partition by tbname state_window(parttime_str); + +sql desc realtime_meters; + +if $rows == 0 then + return -1 +endi + +sql create stream streamd7 into streamt7 as select _wstart, _wend, count(*), first(ca), last(ca) from t1 interval(10s); + +sql desc streamt7; + +if $rows == 0 then + return -1 +endi + +sql create stream streamd71 into streamt71 as select _wstart, _wend, count(*) as ca, first(ca), last(ca) as c2 from t1 interval(10s); + +sql desc streamt71; + +if $rows == 0 then + return -1 +endi + +sql create stream streamd10 into streamd10 as select _wstart, _wend, count(*), first(ca), last(cb) as c2 from t1 interval(10s); + +sql desc streamd10; + +if $rows == 0 then + return -1 +endi + +sql_error create stream streamd11 into streamd11 as select _wstart, _wend, count(*), last(ca), last(ca) from t1 interval(10s); + + +sql create stream streamd12 into streamd12 as select _wstart, _wend, count(*), last(ca), last(cb) as c2 from t1 interval(10s); + +sql desc streamd12; + +if $rows == 0 then + return -1 +endi + sleep 3000 sql drop stream if exists streamd1; 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/2-query/json_tag.py b/tests/system-test/2-query/json_tag.py index 1c2a6055bc..df460df5c3 100644 --- a/tests/system-test/2-query/json_tag.py +++ b/tests/system-test/2-query/json_tag.py @@ -408,8 +408,8 @@ class TDTestCase: # test group by & order by json tag tdSql.query(f"select ts,jtag->'tag1' from {dbname}.jsons1 partition by jtag->'tag1' order by jtag->'tag1' desc") tdSql.checkRows(11) - tdSql.checkData(0, 1, '"femail"') - tdSql.checkData(2, 1, '"收到货"') + tdSql.checkData(0, 1, '"收到货"') + tdSql.checkData(2, 1, '"femail"') tdSql.checkData(7, 1, "false") @@ -421,9 +421,10 @@ class TDTestCase: tdSql.query(f"select count(*),jtag->'tag1' from {dbname}.jsons1 group by jtag->'tag1' order by jtag->'tag1' desc") tdSql.checkRows(8) tdSql.checkData(0, 0, 2) - tdSql.checkData(0, 1, '"femail"') + tdSql.checkData(0, 1, '"收到货"') + tdSql.checkData(1, 1, '"femail"') tdSql.checkData(1, 0, 2) - tdSql.checkData(1, 1, '"收到货"') + tdSql.checkData(2, 0, 1) tdSql.checkData(2, 1, "11.000000000") tdSql.checkData(5, 0, 1) @@ -437,7 +438,7 @@ class TDTestCase: tdSql.checkData(5, 0, 1) tdSql.checkData(5, 1, "11.000000000") tdSql.checkData(7, 0, 2) - tdSql.checkData(7, 1, '"femail"') + tdSql.checkData(7, 1, '"收到货"') # test stddev with group by json tag tdSql.query(f"select stddev(dataint),jtag->'tag1' from {dbname}.jsons1 group by jtag->'tag1' order by jtag->'tag1'") @@ -445,8 +446,8 @@ class TDTestCase: tdSql.checkData(0, 1, None) tdSql.checkData(4, 0, 0) tdSql.checkData(4, 1, "5.000000000") - tdSql.checkData(7, 0, 11) - tdSql.checkData(7, 1, '"femail"') + tdSql.checkData(6, 0, 11) + tdSql.checkData(7, 1, '"收到货"') res = tdSql.getColNameList(f"select stddev(dataint),jsons1.jtag->'tag1' from {dbname}.jsons1 group by jsons1.jtag->'tag1' order by jtag->'tag1'") cname_list = [] 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; }