diff --git a/cmake/cmake.define b/cmake/cmake.define index a739a77d21c40d6b9b5a9ccafe0e3254d9a0d215..10f217254152db82518099560ef902b2ebabf499 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -118,12 +118,18 @@ ELSE () IF (${BUILD_SANITIZER}) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0") - MESSAGE(STATUS "Will compile with Address Sanitizer!") + MESSAGE(STATUS "Compile with Address Sanitizer!") ELSE () SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k") ENDIF () + # disable all assert + IF ((${DISABLE_ASSERT} MATCHES "true") OR (${DISABLE_ASSERTS} MATCHES "true")) + ADD_DEFINITIONS(-DDISABLE_ASSERT) + MESSAGE(STATUS "Disable all asserts") + ENDIF() + INCLUDE(CheckCCompilerFlag) IF (TD_ARM_64 OR TD_ARM_32) SET(COMPILER_SUPPORT_SSE42 false) @@ -156,7 +162,7 @@ ELSE () SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2") ENDIF() - MESSAGE(STATUS "SIMD instructions (AVX/AVX2) is ACTIVATED") + MESSAGE(STATUS "SIMD instructions (FMA/AVX/AVX2) is ACTIVATED") ENDIF() ENDIF () diff --git a/cmake/cmake.version b/cmake/cmake.version index f43465bf1de9722cd1c4243bd22e91fa457ddc05..ba85a3d99b8280a49d9d6e6475cbeb3807090d28 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 31ca6b30fa1ccc5058276ace1429354d26fb3941..3e2e879e389fc7f6686949efab43bc5fada33f3a 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 e23ebb104bdea622267ce94a30fc14d3b4d94f53..115e2fc674c982c755397a8dd745057e14e0ac50 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 4776778 SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/docs/zh/12-taos-sql/29-changes.md b/docs/zh/12-taos-sql/29-changes.md index 1ab7f4f0169932576edf9087a825367573713b03..1e421f95e15f2465b0d71a48947f540a994baa71 100644 --- a/docs/zh/12-taos-sql/29-changes.md +++ b/docs/zh/12-taos-sql/29-changes.md @@ -94,6 +94,7 @@ description: "TDengine 3.0 版本的语法变更说明" | 9 | SAMPLE | 增强 | 可以直接用于超级表了。没有PARTITION BY时,超级表的数据会被合并成一条时间线。 | 10 | STATECOUNT | 增强 | 可以直接用于超级表了。没有PARTITION BY时,超级表的数据会被合并成一条时间线。 | 11 | STATEDURATION | 增强 | 可以直接用于超级表了。没有PARTITION BY时,超级表的数据会被合并成一条时间线。 +| 12 | TIMETRUNCATE | 增强 | 增加ignore_timezone参数,可选是否使用,默认值为1. ## SCHEMALESS 变更 diff --git a/include/client/taos.h b/include/client/taos.h index 647f906d4fc8490f44b025cda30c3cf86867835c..e54300e33e838bb04d74ad8854225be323421672 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -161,6 +161,8 @@ DLL_EXPORT int taos_stmt_set_tags(TAOS_STMT *stmt, TAOS_MULTI_BIND *tags) DLL_EXPORT int taos_stmt_set_sub_tbname(TAOS_STMT *stmt, const char *name); DLL_EXPORT int taos_stmt_get_tag_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields); DLL_EXPORT int taos_stmt_get_col_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields); +// let stmt to reclaim TAOS_FIELD_E that was allocated by `taos_stmt_get_tag_fields`/`taos_stmt_get_col_fields` +DLL_EXPORT void taos_stmt_reclaim_fields(TAOS_STMT *stmt, TAOS_FIELD_E *fields); DLL_EXPORT int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert); DLL_EXPORT int taos_stmt_num_params(TAOS_STMT *stmt, int *nums); diff --git a/include/common/taosdef.h b/include/common/taosdef.h index bf4de9d4ded1d0955bef05b1e3000be0bf34d8aa..d1ca446904594fa57d54031d5b39e529795d70da 100644 --- a/include/common/taosdef.h +++ b/include/common/taosdef.h @@ -30,6 +30,11 @@ typedef int64_t tb_uid_t; #define IS_TSWINDOW_SPECIFIED(win) (((win).skey != INT64_MIN) || ((win).ekey != INT64_MAX)) #define TSWINDOW_IS_EQUAL(t1, t2) (((t1).skey == (t2).skey) && ((t1).ekey == (t2).ekey)) +//define show cluster alive and show db.alive +#define SHOW_STATUS_NOT_AVAILABLE 0 +#define SHOW_STATUS_AVAILABLE 1 +#define SHOW_STATUS_HALF_AVAILABLE 2 + typedef enum { TSDB_SUPER_TABLE = 1, // super table TSDB_CHILD_TABLE = 2, // table created from super table diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 9ecbd2f839411ffe8e93946713941c39ac718d60..2643273555f0ed3addc5f733dc81b5e3a002bad1 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -292,6 +292,7 @@ typedef struct STableBlockDistInfo { uint16_t numOfFiles; uint32_t numOfTables; uint32_t numOfBlocks; + uint32_t numOfVgroups; uint64_t totalSize; uint64_t totalRows; int32_t maxRows; diff --git a/include/common/tmsgcb.h b/include/common/tmsgcb.h index 32d00bb4227c8b153e4112851ba6004b5ab7c88d..a1ebd855cdc7cd2a80280bc074b0b3da41a95e75 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 6a71a8844ed54baa45836d16f2c3ccf9b114cc0a..8332c10ed278936ca77453e485d8dbb3147b4850 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/ttokendef.h b/include/common/ttokendef.h index 8aafe4bb4fc94a52d0c7ae7a78a4aaeabcd20a9e..9c4343eaada33d5d869aa71ee1fa7878c548b90c 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -176,170 +176,171 @@ #define TK_CONSUMERS 158 #define TK_SUBSCRIPTIONS 159 #define TK_VNODES 160 -#define TK_LIKE 161 -#define TK_TBNAME 162 -#define TK_QTAGS 163 -#define TK_AS 164 -#define TK_INDEX 165 -#define TK_FUNCTION 166 -#define TK_INTERVAL 167 -#define TK_COUNT 168 -#define TK_LAST_ROW 169 -#define TK_TOPIC 170 -#define TK_WITH 171 -#define TK_META 172 -#define TK_CONSUMER 173 -#define TK_GROUP 174 -#define TK_DESC 175 -#define TK_DESCRIBE 176 -#define TK_RESET 177 -#define TK_QUERY 178 -#define TK_CACHE 179 -#define TK_EXPLAIN 180 -#define TK_ANALYZE 181 -#define TK_VERBOSE 182 -#define TK_NK_BOOL 183 -#define TK_RATIO 184 -#define TK_NK_FLOAT 185 -#define TK_OUTPUTTYPE 186 -#define TK_AGGREGATE 187 -#define TK_BUFSIZE 188 -#define TK_STREAM 189 -#define TK_INTO 190 -#define TK_TRIGGER 191 -#define TK_AT_ONCE 192 -#define TK_WINDOW_CLOSE 193 -#define TK_IGNORE 194 -#define TK_EXPIRED 195 -#define TK_FILL_HISTORY 196 -#define TK_SUBTABLE 197 -#define TK_KILL 198 -#define TK_CONNECTION 199 -#define TK_TRANSACTION 200 -#define TK_BALANCE 201 -#define TK_VGROUP 202 -#define TK_MERGE 203 -#define TK_REDISTRIBUTE 204 -#define TK_SPLIT 205 -#define TK_DELETE 206 -#define TK_INSERT 207 -#define TK_NULL 208 -#define TK_NK_QUESTION 209 -#define TK_NK_ARROW 210 -#define TK_ROWTS 211 -#define TK_QSTART 212 -#define TK_QEND 213 -#define TK_QDURATION 214 -#define TK_WSTART 215 -#define TK_WEND 216 -#define TK_WDURATION 217 -#define TK_IROWTS 218 -#define TK_ISFILLED 219 -#define TK_CAST 220 -#define TK_NOW 221 -#define TK_TODAY 222 -#define TK_TIMEZONE 223 -#define TK_CLIENT_VERSION 224 -#define TK_SERVER_VERSION 225 -#define TK_SERVER_STATUS 226 -#define TK_CURRENT_USER 227 -#define TK_CASE 228 -#define TK_END 229 -#define TK_WHEN 230 -#define TK_THEN 231 -#define TK_ELSE 232 -#define TK_BETWEEN 233 -#define TK_IS 234 -#define TK_NK_LT 235 -#define TK_NK_GT 236 -#define TK_NK_LE 237 -#define TK_NK_GE 238 -#define TK_NK_NE 239 -#define TK_MATCH 240 -#define TK_NMATCH 241 -#define TK_CONTAINS 242 -#define TK_IN 243 -#define TK_JOIN 244 -#define TK_INNER 245 -#define TK_SELECT 246 -#define TK_DISTINCT 247 -#define TK_WHERE 248 -#define TK_PARTITION 249 -#define TK_BY 250 -#define TK_SESSION 251 -#define TK_STATE_WINDOW 252 -#define TK_EVENT_WINDOW 253 -#define TK_START 254 -#define TK_SLIDING 255 -#define TK_FILL 256 -#define TK_VALUE 257 -#define TK_NONE 258 -#define TK_PREV 259 -#define TK_LINEAR 260 -#define TK_NEXT 261 -#define TK_HAVING 262 -#define TK_RANGE 263 -#define TK_EVERY 264 -#define TK_ORDER 265 -#define TK_SLIMIT 266 -#define TK_SOFFSET 267 -#define TK_LIMIT 268 -#define TK_OFFSET 269 -#define TK_ASC 270 -#define TK_NULLS 271 -#define TK_ABORT 272 -#define TK_AFTER 273 -#define TK_ATTACH 274 -#define TK_BEFORE 275 -#define TK_BEGIN 276 -#define TK_BITAND 277 -#define TK_BITNOT 278 -#define TK_BITOR 279 -#define TK_BLOCKS 280 -#define TK_CHANGE 281 -#define TK_COMMA 282 -#define TK_CONCAT 283 -#define TK_CONFLICT 284 -#define TK_COPY 285 -#define TK_DEFERRED 286 -#define TK_DELIMITERS 287 -#define TK_DETACH 288 -#define TK_DIVIDE 289 -#define TK_DOT 290 -#define TK_EACH 291 -#define TK_FAIL 292 -#define TK_FILE 293 -#define TK_FOR 294 -#define TK_GLOB 295 -#define TK_ID 296 -#define TK_IMMEDIATE 297 -#define TK_IMPORT 298 -#define TK_INITIALLY 299 -#define TK_INSTEAD 300 -#define TK_ISNULL 301 -#define TK_KEY 302 -#define TK_MODULES 303 -#define TK_NK_BITNOT 304 -#define TK_NK_SEMI 305 -#define TK_NOTNULL 306 -#define TK_OF 307 -#define TK_PLUS 308 -#define TK_PRIVILEGE 309 -#define TK_RAISE 310 -#define TK_REPLACE 311 -#define TK_RESTRICT 312 -#define TK_ROW 313 -#define TK_SEMI 314 -#define TK_STAR 315 -#define TK_STATEMENT 316 -#define TK_STRICT 317 -#define TK_STRING 318 -#define TK_TIMES 319 -#define TK_UPDATE 320 -#define TK_VALUES 321 -#define TK_VARIABLE 322 -#define TK_VIEW 323 -#define TK_WAL 324 +#define TK_ALIVE 161 +#define TK_LIKE 162 +#define TK_TBNAME 163 +#define TK_QTAGS 164 +#define TK_AS 165 +#define TK_INDEX 166 +#define TK_FUNCTION 167 +#define TK_INTERVAL 168 +#define TK_COUNT 169 +#define TK_LAST_ROW 170 +#define TK_TOPIC 171 +#define TK_WITH 172 +#define TK_META 173 +#define TK_CONSUMER 174 +#define TK_GROUP 175 +#define TK_DESC 176 +#define TK_DESCRIBE 177 +#define TK_RESET 178 +#define TK_QUERY 179 +#define TK_CACHE 180 +#define TK_EXPLAIN 181 +#define TK_ANALYZE 182 +#define TK_VERBOSE 183 +#define TK_NK_BOOL 184 +#define TK_RATIO 185 +#define TK_NK_FLOAT 186 +#define TK_OUTPUTTYPE 187 +#define TK_AGGREGATE 188 +#define TK_BUFSIZE 189 +#define TK_STREAM 190 +#define TK_INTO 191 +#define TK_TRIGGER 192 +#define TK_AT_ONCE 193 +#define TK_WINDOW_CLOSE 194 +#define TK_IGNORE 195 +#define TK_EXPIRED 196 +#define TK_FILL_HISTORY 197 +#define TK_SUBTABLE 198 +#define TK_KILL 199 +#define TK_CONNECTION 200 +#define TK_TRANSACTION 201 +#define TK_BALANCE 202 +#define TK_VGROUP 203 +#define TK_MERGE 204 +#define TK_REDISTRIBUTE 205 +#define TK_SPLIT 206 +#define TK_DELETE 207 +#define TK_INSERT 208 +#define TK_NULL 209 +#define TK_NK_QUESTION 210 +#define TK_NK_ARROW 211 +#define TK_ROWTS 212 +#define TK_QSTART 213 +#define TK_QEND 214 +#define TK_QDURATION 215 +#define TK_WSTART 216 +#define TK_WEND 217 +#define TK_WDURATION 218 +#define TK_IROWTS 219 +#define TK_ISFILLED 220 +#define TK_CAST 221 +#define TK_NOW 222 +#define TK_TODAY 223 +#define TK_TIMEZONE 224 +#define TK_CLIENT_VERSION 225 +#define TK_SERVER_VERSION 226 +#define TK_SERVER_STATUS 227 +#define TK_CURRENT_USER 228 +#define TK_CASE 229 +#define TK_END 230 +#define TK_WHEN 231 +#define TK_THEN 232 +#define TK_ELSE 233 +#define TK_BETWEEN 234 +#define TK_IS 235 +#define TK_NK_LT 236 +#define TK_NK_GT 237 +#define TK_NK_LE 238 +#define TK_NK_GE 239 +#define TK_NK_NE 240 +#define TK_MATCH 241 +#define TK_NMATCH 242 +#define TK_CONTAINS 243 +#define TK_IN 244 +#define TK_JOIN 245 +#define TK_INNER 246 +#define TK_SELECT 247 +#define TK_DISTINCT 248 +#define TK_WHERE 249 +#define TK_PARTITION 250 +#define TK_BY 251 +#define TK_SESSION 252 +#define TK_STATE_WINDOW 253 +#define TK_EVENT_WINDOW 254 +#define TK_START 255 +#define TK_SLIDING 256 +#define TK_FILL 257 +#define TK_VALUE 258 +#define TK_NONE 259 +#define TK_PREV 260 +#define TK_LINEAR 261 +#define TK_NEXT 262 +#define TK_HAVING 263 +#define TK_RANGE 264 +#define TK_EVERY 265 +#define TK_ORDER 266 +#define TK_SLIMIT 267 +#define TK_SOFFSET 268 +#define TK_LIMIT 269 +#define TK_OFFSET 270 +#define TK_ASC 271 +#define TK_NULLS 272 +#define TK_ABORT 273 +#define TK_AFTER 274 +#define TK_ATTACH 275 +#define TK_BEFORE 276 +#define TK_BEGIN 277 +#define TK_BITAND 278 +#define TK_BITNOT 279 +#define TK_BITOR 280 +#define TK_BLOCKS 281 +#define TK_CHANGE 282 +#define TK_COMMA 283 +#define TK_CONCAT 284 +#define TK_CONFLICT 285 +#define TK_COPY 286 +#define TK_DEFERRED 287 +#define TK_DELIMITERS 288 +#define TK_DETACH 289 +#define TK_DIVIDE 290 +#define TK_DOT 291 +#define TK_EACH 292 +#define TK_FAIL 293 +#define TK_FILE 294 +#define TK_FOR 295 +#define TK_GLOB 296 +#define TK_ID 297 +#define TK_IMMEDIATE 298 +#define TK_IMPORT 299 +#define TK_INITIALLY 300 +#define TK_INSTEAD 301 +#define TK_ISNULL 302 +#define TK_KEY 303 +#define TK_MODULES 304 +#define TK_NK_BITNOT 305 +#define TK_NK_SEMI 306 +#define TK_NOTNULL 307 +#define TK_OF 308 +#define TK_PLUS 309 +#define TK_PRIVILEGE 310 +#define TK_RAISE 311 +#define TK_REPLACE 312 +#define TK_RESTRICT 313 +#define TK_ROW 314 +#define TK_SEMI 315 +#define TK_STAR 316 +#define TK_STATEMENT 317 +#define TK_STRICT 318 +#define TK_STRING 319 +#define TK_TIMES 320 +#define TK_UPDATE 321 +#define TK_VALUES 322 +#define TK_VARIABLE 323 +#define TK_VIEW 324 +#define TK_WAL 325 #define TK_NK_SPACE 600 #define TK_NK_COMMENT 601 diff --git a/include/libs/command/command.h b/include/libs/command/command.h index b3339a417ba463212c3abc163b57519194953c10..a8b1a0902acac276080d905554a3773f68e66b1c 100644 --- a/include/libs/command/command.h +++ b/include/libs/command/command.h @@ -22,7 +22,7 @@ typedef struct SExplainCtx SExplainCtx; -int32_t qExecCommand(bool sysInfoUser, SNode *pStmt, SRetrieveTableRsp **pRsp); +int32_t qExecCommand(int64_t* pConnId, bool sysInfoUser, SNode *pStmt, SRetrieveTableRsp **pRsp); int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp); int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int64_t startTs); diff --git a/include/libs/function/function.h b/include/libs/function/function.h index 32b8cc7389b96e7479697b2c864e98543d92e9a1..32db6773e07ce61ad1ef100713b3bb696a36f09d 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -20,7 +20,6 @@ extern "C" { #endif -#include "tbuffer.h" #include "tcommon.h" #include "tvariant.h" @@ -138,7 +137,7 @@ typedef struct SqlFunctionCtx { char *pOutput; // final result output buffer, point to sdata->data int32_t numOfParams; // input parameter, e.g., top(k, 20), the number of results of top query is kept in param - SFunctParam *param; + SFunctParam *param; // corresponding output buffer for timestamp of each result, e.g., diff/csum SColumnInfoData *pTsOutput; int32_t offset; @@ -152,6 +151,7 @@ typedef struct SqlFunctionCtx { struct SSDataBlock *pSrcBlock; struct SSDataBlock *pDstBlock; // used by indefinite rows function to set selectivity SSerializeDataHandle saveHandle; + int32_t exprIdx; char udfName[TSDB_FUNC_NAME_LEN]; } SqlFunctionCtx; @@ -182,9 +182,9 @@ struct SScalarParam { int32_t numOfQualified; // number of qualified elements in the final results }; -void cleanupResultRowEntry(struct SResultRowEntryInfo *pCell); -bool isRowEntryCompleted(struct SResultRowEntryInfo *pEntry); -bool isRowEntryInitialized(struct SResultRowEntryInfo *pEntry); +void cleanupResultRowEntry(struct SResultRowEntryInfo *pCell); +bool isRowEntryCompleted(struct SResultRowEntryInfo *pEntry); +bool isRowEntryInitialized(struct SResultRowEntryInfo *pEntry); typedef struct SPoint { int64_t key; diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 94f26ebae1b1226b1b32919d649306db34970815..016a9e8281e54488664f4553a029b9b5d36f8bad 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -40,6 +40,7 @@ extern "C" { #define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE) #define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE) +#define SHOW_ALIVE_RESULT_COLS 1 #define PRIVILEGE_TYPE_MASK(n) (1 << n) #define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0) @@ -267,6 +268,11 @@ typedef struct SShowCreateDatabaseStmt { void* pCfg; // SDbCfgInfo } SShowCreateDatabaseStmt; +typedef struct SShowAliveStmt { + ENodeType type; + char dbName[TSDB_DB_NAME_LEN]; +} SShowAliveStmt; + typedef struct SShowCreateTableStmt { ENodeType type; char dbName[TSDB_DB_NAME_LEN]; @@ -406,6 +412,7 @@ typedef struct SCreateStreamStmt { SNode* pQuery; SNodeList* pTags; SNode* pSubtable; + SNodeList* pCols; } SCreateStreamStmt; typedef struct SDropStreamStmt { diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 26622b255681b892133210b94f38277d679622bd..a2e4c76adccc91d5a1f8689643f3d7a93089eba0 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -208,6 +208,8 @@ typedef enum ENodeType { QUERY_NODE_DELETE_STMT, QUERY_NODE_INSERT_STMT, QUERY_NODE_QUERY, + QUERY_NODE_SHOW_DB_ALIVE_STMT, + QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT, // logic plan node QUERY_NODE_LOGIC_PLAN_SCAN = 1000, diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 6f700c75edf82a9eddb23ef82f0dade1c89680b2..3602225789f5d2b5586e592646763e8f651f9dcf 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -121,6 +121,7 @@ typedef struct SAggLogicNode { bool hasLast; bool hasTimeLineFunc; bool onlyHasKeepOrderFunc; + bool hasGroupKeyOptimized; } SAggLogicNode; typedef struct SProjectLogicNode { @@ -409,6 +410,7 @@ typedef struct SAggPhysiNode { SNodeList* pGroupKeys; SNodeList* pAggFuncs; bool mergeDataBlock; + bool groupKeyOptimized; } SAggPhysiNode; typedef struct SDownstreamSourceNode { diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index 559dc1009dcdc5795df28b24d529ae90038900f3..d37f8f76c28288c48ef297007142df19a761f289 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -78,6 +78,8 @@ typedef enum { } ESyncState; typedef struct SNodeInfo { + int64_t clusterId; + int32_t nodeId; uint16_t nodePort; char nodeFqdn[TSDB_FQDN_LEN]; } SNodeInfo; diff --git a/include/os/osMemory.h b/include/os/osMemory.h index 4681ff66741d4781c88dba5ccc950094c96f6769..e6a4488287816f21ca9eeee76a3208ff6e6ff12d 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/osSystem.h b/include/os/osSystem.h index 8f1f5c58d5200d22583dcc7cc8c13663ce070941..58f34d26f07dafc55e7ab0c9526581545bdb8171 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 1bfcae56813e139f6076b192588fbd54c86897fa..9d594d150795627053c58726ddbb3bf8066dafba 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -346,6 +346,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_TOPIC_SUBSCRIBED TAOS_DEF_ERROR_CODE(0, 0x03EB) #define TSDB_CODE_MND_CGROUP_USED TAOS_DEF_ERROR_CODE(0, 0x03EC) #define TSDB_CODE_MND_TOPIC_MUST_BE_DELETED TAOS_DEF_ERROR_CODE(0, 0x03ED) +#define TSDB_CODE_MND_INVALID_SUB_OPTION TAOS_DEF_ERROR_CODE(0, 0x03EE) #define TSDB_CODE_MND_IN_REBALANCE TAOS_DEF_ERROR_CODE(0, 0x03EF) // mnode-stream diff --git a/include/util/tbuffer.h b/include/util/tbuffer.h deleted file mode 100644 index 2ed1b7326bdb27ffe182b30d67a9369680898d23..0000000000000000000000000000000000000000 --- a/include/util/tbuffer.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2020 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_UTIL_BUFFER_H_ -#define _TD_UTIL_BUFFER_H_ - -#include "os.h" - -#ifdef __cplusplus -extern "C" { -#endif - -//////////////////////////////////////////////////////////////////////////////// -// usage example -/* -#include -#include "texception.h" - -int32_t main( int32_t argc, char** argv ) { - SBufferWriter bw = tbufInitWriter( NULL, false ); - - TRY( 1 ) { - //--------------------- write ------------------------ - // reserve 1024 bytes for the buffer to improve performance - tbufEnsureCapacity( &bw, 1024 ); - - // reserve space for the interger count - size_t pos = tbufReserve( &bw, sizeof(int32_t) ); - // write 5 integers to the buffer - for( int32_t i = 0; i < 5; i++) { - tbufWriteInt32( &bw, i ); - } - // write the integer count to buffer at reserved position - tbufWriteInt32At( &bw, pos, 5 ); - - // write a string to the buffer - tbufWriteString( &bw, "this is a string.\n" ); - // acquire the result and close the write buffer - size_t size = tbufTell( &bw ); - char* data = tbufGetData( &bw, false ); - - //------------------------ read ----------------------- - SBufferReader br = tbufInitReader( data, size, false ); - // read & print out all integers - int32_t count = tbufReadInt32( &br ); - for( int32_t i = 0; i < count; i++ ) { - printf( "%d\n", tbufReadInt32(&br) ); - } - // read & print out a string - puts( tbufReadString(&br, NULL) ); - // try read another integer, this result in an error as there no this integer - tbufReadInt32( &br ); - printf( "you should not see this message.\n" ); - } CATCH( code ) { - printf( "exception code is: %d, you will see this message after print out 5 integers and a string.\n", code ); - } END_TRY - - tbufCloseWriter( &bw ); - return 0; -} -*/ - -typedef struct SBufferReader { - bool endian; - const char* data; - size_t pos; - size_t size; -} SBufferReader; - -typedef struct SBufferWriter { - bool endian; - char* data; - size_t pos; - size_t size; - void* (*allocator)(void*, size_t); -} SBufferWriter; - -// common functions & macros for both reader & writer - -#define tbufTell(buf) ((buf)->pos) - -/* ------------------------ BUFFER WRITER FUNCTIONS AND MACROS ------------------------ */ -// *Allocator*, function to allocate memory, will use 'realloc' if NULL -// *Endian*, if true, writer functions of primitive types will do 'hton' automatically -#define tbufInitWriter(Allocator, Endian) \ - { .endian = (Endian), .data = NULL, .pos = 0, .size = 0, .allocator = ((Allocator) == NULL ? realloc : (Allocator)) } - -void tbufCloseWriter(SBufferWriter* buf); -void tbufEnsureCapacity(SBufferWriter* buf, size_t size); -size_t tbufReserve(SBufferWriter* buf, size_t size); -char* tbufGetData(SBufferWriter* buf, bool takeOver); -void tbufWrite(SBufferWriter* buf, const void* data, size_t size); -void tbufWriteAt(SBufferWriter* buf, size_t pos, const void* data, size_t size); -void tbufWriteStringLen(SBufferWriter* buf, const char* str, size_t len); -void tbufWriteString(SBufferWriter* buf, const char* str); -// the prototype of tbufWriteBinary and tbufWrite are identical -// the difference is: tbufWriteBinary writes the length of the data to the buffer -// first, then the actual data, which means the reader don't need to know data -// size before read. Write only write the data itself, which means the reader -// need to know data size before read. -void tbufWriteBinary(SBufferWriter* buf, const void* data, size_t len); -void tbufWriteBool(SBufferWriter* buf, bool data); -void tbufWriteBoolAt(SBufferWriter* buf, size_t pos, bool data); -void tbufWriteChar(SBufferWriter* buf, char data); -void tbufWriteCharAt(SBufferWriter* buf, size_t pos, char data); -void tbufWriteInt8(SBufferWriter* buf, int8_t data); -void tbufWriteInt8At(SBufferWriter* buf, size_t pos, int8_t data); -void tbufWriteUint8(SBufferWriter* buf, uint8_t data); -void tbufWriteUint8At(SBufferWriter* buf, size_t pos, uint8_t data); -void tbufWriteInt16(SBufferWriter* buf, int16_t data); -void tbufWriteInt16At(SBufferWriter* buf, size_t pos, int16_t data); -void tbufWriteUint16(SBufferWriter* buf, uint16_t data); -void tbufWriteUint16At(SBufferWriter* buf, size_t pos, uint16_t data); -void tbufWriteInt32(SBufferWriter* buf, int32_t data); -void tbufWriteInt32At(SBufferWriter* buf, size_t pos, int32_t data); -void tbufWriteUint32(SBufferWriter* buf, uint32_t data); -void tbufWriteUint32At(SBufferWriter* buf, size_t pos, uint32_t data); -void tbufWriteInt64(SBufferWriter* buf, int64_t data); -void tbufWriteInt64At(SBufferWriter* buf, size_t pos, int64_t data); -void tbufWriteUint64(SBufferWriter* buf, uint64_t data); -void tbufWriteUint64At(SBufferWriter* buf, size_t pos, uint64_t data); -void tbufWriteFloat(SBufferWriter* buf, float data); -void tbufWriteFloatAt(SBufferWriter* buf, size_t pos, float data); -void tbufWriteDouble(SBufferWriter* buf, double data); -void tbufWriteDoubleAt(SBufferWriter* buf, size_t pos, double data); - -/* ------------------------ BUFFER READER FUNCTIONS AND MACROS ------------------------ */ -// *Endian*, if true, reader functions of primitive types will do 'ntoh' automatically -#define tbufInitReader(Data, Size, Endian) \ - { .endian = (Endian), .data = (Data), .pos = 0, .size = ((Data) == NULL ? 0 : (Size)) } - -size_t tbufSkip(SBufferReader* buf, size_t size); -const char* tbufRead(SBufferReader* buf, size_t size); -void tbufReadToBuffer(SBufferReader* buf, void* dst, size_t size); -const char* tbufReadString(SBufferReader* buf, size_t* len); -size_t tbufReadToString(SBufferReader* buf, char* dst, size_t size); -const char* tbufReadBinary(SBufferReader* buf, size_t* len); -size_t tbufReadToBinary(SBufferReader* buf, void* dst, size_t size); -bool tbufReadBool(SBufferReader* buf); -char tbufReadChar(SBufferReader* buf); -int8_t tbufReadInt8(SBufferReader* buf); -uint8_t tbufReadUint8(SBufferReader* buf); -int16_t tbufReadInt16(SBufferReader* buf); -uint16_t tbufReadUint16(SBufferReader* buf); -int32_t tbufReadInt32(SBufferReader* buf); -uint32_t tbufReadUint32(SBufferReader* buf); -int64_t tbufReadInt64(SBufferReader* buf); -uint64_t tbufReadUint64(SBufferReader* buf); -float tbufReadFloat(SBufferReader* buf); -double tbufReadDouble(SBufferReader* buf); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_UTIL_BUFFER_H_*/ diff --git a/include/util/tcompare.h b/include/util/tcompare.h index c7a3ca20f222c7d919460b31e9f3c55a79325f46..f92e1c3970a828fdfe109ee51a8e1f52f1ae0389 100644 --- a/include/util/tcompare.h +++ b/include/util/tcompare.h @@ -36,17 +36,18 @@ extern "C" { #define FLT_GREATEREQUAL(_x, _y) (FLT_EQUAL((_x), (_y)) || ((_x) > (_y))) #define FLT_LESSEQUAL(_x, _y) (FLT_EQUAL((_x), (_y)) || ((_x) < (_y))) -#define PATTERN_COMPARE_INFO_INITIALIZER \ - { '%', '_' } +#define PATTERN_COMPARE_INFO_INITIALIZER { '%', '_', L'%', L'_' } typedef struct SPatternCompareInfo { - char matchAll; // symbol for match all wildcard, default: '%' - char matchOne; // symbol for match one wildcard, default: '_' + char matchAll; // symbol for match all wildcard, default: '%' + char matchOne; // symbol for match one wildcard, default: '_' + TdUcs4 umatchAll; // unicode version matchAll + TdUcs4 umatchOne; // unicode version matchOne } SPatternCompareInfo; -int32_t patternMatch(const char *pattern, const char *str, size_t size, const SPatternCompareInfo *pInfo); +int32_t patternMatch(const char *pattern, size_t psize, const char *str, size_t ssize, const SPatternCompareInfo *pInfo); -int32_t WCSPatternMatch(const TdUcs4 *pattern, const TdUcs4 *str, size_t size, const SPatternCompareInfo *pInfo); +int32_t wcsPatternMatch(const TdUcs4 *pattern, size_t psize, const TdUcs4 *str, size_t ssize, const SPatternCompareInfo *pInfo); int32_t taosArrayCompareString(const void *a, const void *b); @@ -79,9 +80,11 @@ int32_t compareDoubleVal(const void *pLeft, const void *pRight); int32_t compareLenPrefixedStr(const void *pLeft, const void *pRight); int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight); -int32_t compareStrRegexComp(const void *pLeft, const void *pRight); -int32_t compareStrRegexCompMatch(const void *pLeft, const void *pRight); -int32_t compareStrRegexCompNMatch(const void *pLeft, const void *pRight); +int32_t comparestrRegexMatch(const void *pLeft, const void *pRight); +int32_t comparestrRegexNMatch(const void *pLeft, const void *pRight); + +int32_t comparewcsRegexMatch(const void *pLeft, const void *pRight); +int32_t comparewcsRegexNMatch(const void *pLeft, const void *pRight); int32_t compareInt8ValDesc(const void *pLeft, const void *pRight); int32_t compareInt16ValDesc(const void *pLeft, const void *pRight); @@ -99,11 +102,11 @@ int32_t compareUint64ValDesc(const void *pLeft, const void *pRight); int32_t compareLenPrefixedStrDesc(const void *pLeft, const void *pRight); int32_t compareLenPrefixedWStrDesc(const void *pLeft, const void *pRight); -int32_t compareStrPatternMatch(const void *pLeft, const void *pRight); -int32_t compareStrPatternNotMatch(const void *pLeft, const void *pRight); +int32_t comparestrPatternMatch(const void *pLeft, const void *pRight); +int32_t comparestrPatternNMatch(const void *pLeft, const void *pRight); -int32_t compareWStrPatternMatch(const void *pLeft, const void *pRight); -int32_t compareWStrPatternNotMatch(const void *pLeft, const void *pRight); +int32_t comparewcsPatternMatch(const void *pLeft, const void *pRight); +int32_t comparewcsPatternNMatch(const void *pLeft, const void *pRight); int32_t compareInt8Int16(const void *pLeft, const void *pRight); int32_t compareInt8Int32(const void *pLeft, const void *pRight); diff --git a/include/util/tdef.h b/include/util/tdef.h index 4cf4f73b9bfe02320594bd112568406629c8e895..f2e2ab42844d006cbab0ee18cf11957ef3247eb4 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -194,6 +194,7 @@ typedef enum ELogicConditionType { #define TSDB_TOPIC_NAME_LEN 193 // it is a null-terminated string #define TSDB_CGROUP_LEN 193 // it is a null-terminated string #define TSDB_USER_CGROUP_LEN (TSDB_USER_LEN + TSDB_CGROUP_LEN) // it is a null-terminated string +#define TSDB_STREAM_NAME_LEN 193 // it is a null-terminated string #define TSDB_DB_NAME_LEN 65 #define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN) @@ -213,8 +214,8 @@ typedef enum ELogicConditionType { #define TSDB_INDEX_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_INDEX_NAME_LEN + TSDB_NAME_DELIMITER_LEN) #define TSDB_TYPE_STR_MAX_LEN 32 #define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN) -#define TSDB_TOPIC_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN) -#define TSDB_STREAM_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN) +#define TSDB_TOPIC_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_TOPIC_NAME_LEN + TSDB_NAME_DELIMITER_LEN) +#define TSDB_STREAM_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_STREAM_NAME_LEN + TSDB_NAME_DELIMITER_LEN) #define TSDB_SUBSCRIBE_KEY_LEN (TSDB_CGROUP_LEN + TSDB_TOPIC_FNAME_LEN + 2) #define TSDB_PARTITION_KEY_LEN (TSDB_SUBSCRIBE_KEY_LEN + 20) #define TSDB_COL_NAME_LEN 65 @@ -311,7 +312,7 @@ typedef enum ELogicConditionType { #define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute #define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved. #define TSDB_MAX_KEEP_NS (365 * 292 * 1440) // data in db to be reserved. -#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years +#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years #define TSDB_MIN_MINROWS_FBLOCK 10 #define TSDB_MAX_MINROWS_FBLOCK 1000 #define TSDB_DEFAULT_MINROWS_FBLOCK 100 diff --git a/include/util/tjson.h b/include/util/tjson.h index df433227ca83ce51e63a1265db9ac28ed0897954..6922930c13625e0a5722bc07af1578feee42c7ff 100644 --- a/include/util/tjson.h +++ b/include/util/tjson.h @@ -30,6 +30,27 @@ extern "C" { val = _tmp; \ } while (0) +#define tjsonGetInt32ValueFromDouble(pJson, pName, val, code) \ + do { \ + double _tmp = 0; \ + code = tjsonGetDoubleValue(pJson, pName, &_tmp); \ + val = (int32_t)_tmp; \ + } while (0) + +#define tjsonGetInt8ValueFromDouble(pJson, pName, val, code) \ + do { \ + double _tmp = 0; \ + code = tjsonGetDoubleValue(pJson, pName, &_tmp); \ + val = (int8_t)_tmp; \ + } while (0) + +#define tjsonGetUInt16ValueFromDouble(pJson, pName, val, code) \ + do { \ + double _tmp = 0; \ + code = tjsonGetDoubleValue(pJson, pName, &_tmp); \ + val = (uint16_t)_tmp; \ + } while (0) + typedef void SJson; SJson* tjsonCreateObject(); diff --git a/include/util/tlog.h b/include/util/tlog.h index e6ef7f388ff7af4bab6c29a8a62d39d01d31f256..6e9b304e1d78a2dac22f7f1a0057312e0d3a4413 100644 --- a/include/util/tlog.h +++ b/include/util/tlog.h @@ -83,9 +83,21 @@ void taosPrintLongString(const char *flags, ELogLevel level, int32_t dflag, cons #endif ; -bool taosAssert(bool condition, const char *file, int32_t line, const char *format, ...); -#define ASSERTS(condition, ...) taosAssert(condition, __FILE__, __LINE__, __VA_ARGS__) -#define ASSERT(condition) ASSERTS(condition, "assert info not provided") +bool taosAssertDebug(bool condition, const char *file, int32_t line, const char *format, ...); +bool taosAssertRelease(bool condition); + +// Disable all asserts that may compromise the performance. +#if defined DISABLE_ASSERT +#define ASSERT(condition) +#define ASSERTS(condition, ...) +#else +#define ASSERTS(condition, ...) taosAssertDebug(condition, __FILE__, __LINE__, __VA_ARGS__) +#ifdef NDEBUG +#define ASSERT(condition) taosAssertRelease(condition) +#else +#define ASSERT(condition) taosAssertDebug(condition, __FILE__, __LINE__, "assert info not provided") +#endif +#endif // clang-format off #define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", DEBUG_FATAL, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }} diff --git a/include/util/tutil.h b/include/util/tutil.h index de963001557519b7dd9355187122535c77b3f17a..9fb68aebdc2943b37cb082f758deca40a8feab6b 100644 --- a/include/util/tutil.h +++ b/include/util/tutil.h @@ -29,11 +29,17 @@ extern "C" { int32_t strdequote(char *src); size_t strtrim(char *src); char *strnchr(const char *haystack, char needle, int32_t len, bool skipquote); +TdUcs4* wcsnchr(const TdUcs4* haystack, TdUcs4 needle, size_t len); + char **strsplit(char *src, const char *delim, int32_t *num); char *strtolower(char *dst, const char *src); char *strntolower(char *dst, const char *src, int32_t n); char *strntolower_s(char *dst, const char *src, int32_t n); int64_t strnatoi(char *num, int32_t len); + +size_t tstrncspn(const char *str, size_t ssize, const char *reject, size_t rsize); +size_t twcsncspn(const TdUcs4 *wcs, size_t size, const TdUcs4 *reject, size_t rsize); + char *strbetween(char *string, char *begin, char *end); char *paGetToken(char *src, char **token, int32_t *tokenLen); diff --git a/source/client/inc/clientSml.h b/source/client/inc/clientSml.h index b74d0b34943af7e5a61e3c0fd8d4bc481736c9d6..11f72efeaf7a769b0421394edb73ca33f3a2d497 100644 --- a/source/client/inc/clientSml.h +++ b/source/client/inc/clientSml.h @@ -69,6 +69,7 @@ extern "C" { #define VALUE "_value" #define VALUE_LEN 6 +#define OTD_JSON_FIELDS_NUM 4 #define MAX_RETRY_TIMES 5 typedef TSDB_SML_PROTOCOL_TYPE SMLProtocolType; @@ -177,12 +178,14 @@ typedef struct { int32_t lineNum; SSmlMsgBuf msgBuf; -// cJSON *root; // for parse json - int8_t offset[4]; + cJSON *root; // for parse json + int8_t offset[OTD_JSON_FIELDS_NUM]; SSmlLineInfo *lines; // element is SSmlLineInfo + bool parseJsonByLib; // SArray *preLineTagKV; + SArray *maxTagKVs; SArray *preLineColKV; SSmlLineInfo preLine; @@ -197,7 +200,7 @@ typedef struct { #define IS_SAME_SUPER_TABLE (elements->measureLen == info->preLine.measureLen \ && memcmp(elements->measure, info->preLine.measure, elements->measureLen) == 0) -#define IS_SAME_KEY (preKV->keyLen == kv.keyLen && memcmp(preKV->key, kv.key, kv.keyLen) == 0) +#define IS_SAME_KEY (maxKV->keyLen == kv.keyLen && memcmp(maxKV->key, kv.key, kv.keyLen) == 0) extern int64_t smlFactorNS[3]; extern int64_t smlFactorS[3]; @@ -206,9 +209,9 @@ typedef int32_t (*_equal_fn_sml)(const void *, const void *); SSmlHandle *smlBuildSmlInfo(TAOS *taos); void smlDestroyInfo(SSmlHandle *info); -void smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset); -void smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset); -SArray *smlJsonParseTags(char *start, char *end); +int smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset); +int smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset); +//SArray *smlJsonParseTags(char *start, char *end); bool smlParseNumberOld(SSmlKv *kvVal, SSmlMsgBuf *msg); void* nodeListGet(NodeList* list, const void *key, int32_t len, _equal_fn_sml fn); int nodeListSet(NodeList** list, const void *key, int32_t len, void* value, _equal_fn_sml fn); @@ -226,6 +229,7 @@ int32_t is_same_child_table_telnet(const void *a, const void *b); int64_t smlParseOpenTsdbTime(SSmlHandle *info, const char *data, int32_t len); int32_t smlClearForRerun(SSmlHandle *info); int32_t smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg); +uint8_t smlGetTimestampLen(int64_t num); int32_t smlParseInfluxString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLineInfo *elements); int32_t smlParseTelnetString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLineInfo *elements); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 6f61d59846a7acb5afc4ff61bfaf60af5ae6917c..75288cfa143266cb09800cb2f6ecfe34adec1d77 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -272,7 +272,7 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtC int32_t execLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { SRetrieveTableRsp* pRsp = NULL; - int32_t code = qExecCommand(pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp); + int32_t code = qExecCommand(&pRequest->pTscObj->id, pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp); if (TSDB_CODE_SUCCESS == code && NULL != pRsp) { code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false, true); } @@ -310,7 +310,7 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { return; } - int32_t code = qExecCommand(pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp); + int32_t code = qExecCommand(&pRequest->pTscObj->id ,pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp); if (TSDB_CODE_SUCCESS == code && NULL != pRsp) { code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false, true); } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 896d1d6ca6f34b06e359334eabaf4eb53434b1d5..36126d6468ae75d97d168174e64b0a72c1e070f6 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -1330,6 +1330,14 @@ int taos_stmt_get_col_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fiel return stmtGetColFields(stmt, fieldNum, fields); } +// let stmt to reclaim TAOS_FIELD_E that was allocated by `taos_stmt_get_tag_fields`/`taos_stmt_get_col_fields` +void taos_stmt_reclaim_fields(TAOS_STMT *stmt, TAOS_FIELD_E *fields) +{ + (void)stmt; + if (!fields) return; + taosMemoryFree(fields); +} + int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) { if (stmt == NULL || bind == NULL) { tscError("NULL parameter for %s", __FUNCTION__); diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index ba154c95bde3e6c8c3b2b9201b2b2c65a96b077c..ca6395b52bc9df51a063522ab95135e0c396c364 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -1008,12 +1008,16 @@ static int32_t smlUpdateMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols return TSDB_CODE_SUCCESS; } -static void smlDestroyTableInfo(SSmlTableInfo *tag) { +static void smlDestroyTableInfo(SSmlHandle *info, SSmlTableInfo *tag) { for (size_t i = 0; i < taosArrayGetSize(tag->cols); i++) { SHashObj *kvHash = (SHashObj *)taosArrayGetP(tag->cols, i); taosHashCleanup(kvHash); } + if(info->parseJsonByLib){ + SSmlLineInfo *key = (SSmlLineInfo *)(tag->key); + if(key != NULL) taosMemoryFree(key->tags); + } taosMemoryFree(tag->key); taosArrayDestroy(tag->cols); taosArrayDestroy(tag->tags); @@ -1028,7 +1032,7 @@ void smlDestroyInfo(SSmlHandle *info) { NodeList *tmp = info->childTables; while (tmp) { if (tmp->data.used) { - smlDestroyTableInfo((SSmlTableInfo *)tmp->data.value); + smlDestroyTableInfo(info, (SSmlTableInfo *)tmp->data.value); } NodeList *t = tmp->next; taosMemoryFree(tmp); @@ -1050,11 +1054,15 @@ void smlDestroyInfo(SSmlHandle *info) { taosHashCleanup(info->pVgHash); taosArrayDestroy(info->preLineTagKV); + taosArrayDestroy(info->maxTagKVs); taosArrayDestroy(info->preLineColKV); if (!info->dataFormat) { for (int i = 0; i < info->lineNum; i++) { taosArrayDestroy(info->lines[i].colArray); + if(info->parseJsonByLib){ + taosMemoryFree(info->lines[i].tags); + } } taosMemoryFree(info->lines); } @@ -1083,6 +1091,7 @@ SSmlHandle *smlBuildSmlInfo(TAOS *taos) { info->dataFormat = true; info->preLineTagKV = taosArrayInit(8, sizeof(SSmlKv)); + info->maxTagKVs = taosArrayInit(8, sizeof(SSmlKv)); info->preLineColKV = taosArrayInit(8, sizeof(SSmlKv)); if (NULL == info->pVgHash) { @@ -1251,7 +1260,7 @@ int32_t smlClearForRerun(SSmlHandle *info) { NodeList *pList = info->childTables; while (pList) { if (pList->data.used) { - smlDestroyTableInfo((SSmlTableInfo *)pList->data.value); + smlDestroyTableInfo(info, (SSmlTableInfo *)pList->data.value); pList->data.used = false; } pList = pList->next; @@ -1267,11 +1276,13 @@ int32_t smlClearForRerun(SSmlHandle *info) { pList = pList->next; } - if (unlikely(info->lines != NULL)) { - uError("SML:0x%" PRIx64 " info->lines != NULL", info->id); - return TSDB_CODE_SML_INVALID_DATA; + if (!info->dataFormat){ + if (unlikely(info->lines != NULL)) { + uError("SML:0x%" PRIx64 " info->lines != NULL", info->id); + return TSDB_CODE_SML_INVALID_DATA; + } + info->lines = (SSmlLineInfo *)taosMemoryCalloc(info->lineNum, sizeof(SSmlLineInfo)); } - info->lines = (SSmlLineInfo *)taosMemoryCalloc(info->lineNum, sizeof(SSmlLineInfo)); memset(&info->preLine, 0, sizeof(SSmlLineInfo)); info->currSTableMeta = NULL; diff --git a/source/client/src/clientSmlJson.c b/source/client/src/clientSmlJson.c index 3de1397f72533c2ee35df832116e5e81e45686e2..60e29638f59cf1b0a5b4724379f26e91a9f243a0 100644 --- a/source/client/src/clientSmlJson.c +++ b/source/client/src/clientSmlJson.c @@ -19,6 +19,8 @@ #include #include "clientSml.h" +#define OTD_JSON_SUB_FIELDS_NUM 2 + #define JUMP_JSON_SPACE(start) \ while(*(start)){\ if(unlikely(*(start) > 32))\ @@ -27,188 +29,193 @@ while(*(start)){\ (start)++;\ } -SArray *smlJsonParseTags(char *start, char *end){ - SArray *tags = taosArrayInit(4, sizeof(SSmlKv)); - while(start < end){ - SSmlKv kv = {0}; - kv.type = TSDB_DATA_TYPE_NCHAR; - bool isInQuote = false; - while(start < end){ - if(unlikely(!isInQuote && *start == '"')){ - start++; - kv.key = start; - isInQuote = true; - continue; - } - if(unlikely(isInQuote && *start == '"')){ - kv.keyLen = start - kv.key; - start++; - break; - } - start++; - } - bool hasColon = false; - while(start < end){ - if(unlikely(!hasColon && *start == ':')){ - start++; - hasColon = true; - continue; - } - if(unlikely(hasColon && kv.value == NULL && (*start > 32 && *start != '"'))){ - kv.value = start; - start++; - continue; - } - - if(unlikely(hasColon && kv.value != NULL && (*start == '"' || *start == ',' || *start == '}'))){ - kv.length = start - kv.value; - taosArrayPush(tags, &kv); - start++; - break; - } - start++; - } - } - return tags; -} - -static int32_t smlParseTagsFromJSON(SSmlHandle *info, SSmlLineInfo *elements) { - int32_t ret = TSDB_CODE_SUCCESS; - - if(is_same_child_table_telnet(elements, &info->preLine) == 0){ - return TSDB_CODE_SUCCESS; - } - - bool isSameMeasure = IS_SAME_SUPER_TABLE; - - int cnt = 0; - SArray *preLineKV = info->preLineTagKV; - bool isSuperKVInit = true; - SArray *superKV = NULL; - if(info->dataFormat){ - if(unlikely(!isSameMeasure)){ - SSmlSTableMeta *sMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL); - - if(unlikely(sMeta == NULL)){ - sMeta = smlBuildSTableMeta(info->dataFormat); - STableMeta * pTableMeta = smlGetMeta(info, elements->measure, elements->measureLen); - sMeta->tableMeta = pTableMeta; - if(pTableMeta == NULL){ - info->dataFormat = false; - info->reRun = true; - return TSDB_CODE_SUCCESS; - } - nodeListSet(&info->superTables, elements->measure, elements->measureLen, sMeta, NULL); - } - info->currSTableMeta = sMeta->tableMeta; - superKV = sMeta->tags; - - if(unlikely(taosArrayGetSize(superKV) == 0)){ - isSuperKVInit = false; - } - taosArraySetSize(preLineKV, 0); - } - }else{ - taosArraySetSize(preLineKV, 0); - } - - SArray *tags = smlJsonParseTags(elements->tags, elements->tags + elements->tagsLen); - int32_t tagNum = taosArrayGetSize(tags); - for (int32_t i = 0; i < tagNum; ++i) { - SSmlKv kv = *(SSmlKv*)taosArrayGet(tags, i); - - if(info->dataFormat){ - if(unlikely(cnt + 1 > info->currSTableMeta->tableInfo.numOfTags)){ - info->dataFormat = false; - info->reRun = true; - taosArrayDestroy(tags); - return TSDB_CODE_SUCCESS; - } - - if(isSameMeasure){ - if(unlikely(cnt >= taosArrayGetSize(preLineKV))) { - info->dataFormat = false; - info->reRun = true; - taosArrayDestroy(tags); - return TSDB_CODE_SUCCESS; - } - SSmlKv *preKV = (SSmlKv *)taosArrayGet(preLineKV, cnt); - if(unlikely(kv.length > preKV->length)){ - preKV->length = kv.length; - SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL); - ASSERT(tableMeta != NULL); - - SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->tags, cnt); - oldKV->length = kv.length; - info->needModifySchema = true; - } - if(unlikely(!IS_SAME_KEY)){ - info->dataFormat = false; - info->reRun = true; - taosArrayDestroy(tags); - return TSDB_CODE_SUCCESS; - } - }else{ - if(isSuperKVInit){ - if(unlikely(cnt >= taosArrayGetSize(superKV))) { - info->dataFormat = false; - info->reRun = true; - taosArrayDestroy(tags); - return TSDB_CODE_SUCCESS; - } - SSmlKv *preKV = (SSmlKv *)taosArrayGet(superKV, cnt); - if(unlikely(kv.length > preKV->length)) { - preKV->length = kv.length; - }else{ - kv.length = preKV->length; - } - info->needModifySchema = true; - - if(unlikely(!IS_SAME_KEY)){ - info->dataFormat = false; - info->reRun = true; - taosArrayDestroy(tags); - return TSDB_CODE_SUCCESS; - } - }else{ - taosArrayPush(superKV, &kv); - } - taosArrayPush(preLineKV, &kv); - } - }else{ - taosArrayPush(preLineKV, &kv); - } - cnt++; - } - taosArrayDestroy(tags); - - SSmlTableInfo *tinfo = (SSmlTableInfo *)nodeListGet(info->childTables, elements, POINTER_BYTES, is_same_child_table_telnet); - if (unlikely(tinfo == NULL)) { - tinfo = smlBuildTableInfo(1, elements->measure, elements->measureLen); - if (unlikely(!tinfo)) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tinfo->tags = taosArrayDup(preLineKV, NULL); +//SArray *smlJsonParseTags(char *start, char *end){ +// SArray *tags = taosArrayInit(4, sizeof(SSmlKv)); +// while(start < end){ +// SSmlKv kv = {0}; +// kv.type = TSDB_DATA_TYPE_NCHAR; +// bool isInQuote = false; +// while(start < end){ +// if(unlikely(!isInQuote && *start == '"')){ +// start++; +// kv.key = start; +// isInQuote = true; +// continue; +// } +// if(unlikely(isInQuote && *start == '"')){ +// kv.keyLen = start - kv.key; +// start++; +// break; +// } +// start++; +// } +// bool hasColon = false; +// while(start < end){ +// if(unlikely(!hasColon && *start == ':')){ +// start++; +// hasColon = true; +// continue; +// } +// if(unlikely(hasColon && kv.value == NULL && (*start > 32 && *start != '"'))){ +// kv.value = start; +// start++; +// continue; +// } +// +// if(unlikely(hasColon && kv.value != NULL && (*start == '"' || *start == ',' || *start == '}'))){ +// kv.length = start - kv.value; +// taosArrayPush(tags, &kv); +// start++; +// break; +// } +// start++; +// } +// } +// return tags; +//} - smlSetCTableName(tinfo); - if (info->dataFormat) { - info->currSTableMeta->uid = tinfo->uid; - tinfo->tableDataCtx = smlInitTableDataCtx(info->pQuery, info->currSTableMeta); - if (tinfo->tableDataCtx == NULL) { - smlBuildInvalidDataMsg(&info->msgBuf, "smlInitTableDataCtx error", NULL); - return TSDB_CODE_SML_INVALID_DATA; - } - } - - SSmlLineInfo *key = (SSmlLineInfo *)taosMemoryMalloc(sizeof(SSmlLineInfo)); - *key = *elements; - tinfo->key = key; - nodeListSet(&info->childTables, key, POINTER_BYTES, tinfo, is_same_child_table_telnet); - } - if (info->dataFormat) info->currTableDataCtx = tinfo->tableDataCtx; - - return ret; -} +//static int32_t smlParseTagsFromJSON(SSmlHandle *info, SSmlLineInfo *elements) { +// int32_t ret = TSDB_CODE_SUCCESS; +// +// if(is_same_child_table_telnet(elements, &info->preLine) == 0){ +// return TSDB_CODE_SUCCESS; +// } +// +// bool isSameMeasure = IS_SAME_SUPER_TABLE; +// +// int cnt = 0; +// SArray *preLineKV = info->preLineTagKV; +// bool isSuperKVInit = true; +// SArray *superKV = NULL; +// if(info->dataFormat){ +// if(unlikely(!isSameMeasure)){ +// SSmlSTableMeta *sMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL); +// +// if(unlikely(sMeta == NULL)){ +// sMeta = smlBuildSTableMeta(info->dataFormat); +// STableMeta * pTableMeta = smlGetMeta(info, elements->measure, elements->measureLen); +// sMeta->tableMeta = pTableMeta; +// if(pTableMeta == NULL){ +// info->dataFormat = false; +// info->reRun = true; +// return TSDB_CODE_SUCCESS; +// } +// nodeListSet(&info->superTables, elements->measure, elements->measureLen, sMeta, NULL); +// } +// info->currSTableMeta = sMeta->tableMeta; +// superKV = sMeta->tags; +// +// if(unlikely(taosArrayGetSize(superKV) == 0)){ +// isSuperKVInit = false; +// } +// taosArraySetSize(preLineKV, 0); +// } +// }else{ +// taosArraySetSize(preLineKV, 0); +// } +// +// SArray *tags = smlJsonParseTags(elements->tags, elements->tags + elements->tagsLen); +// int32_t tagNum = taosArrayGetSize(tags); +// if (tagNum == 0) { +// uError("SML:tag is empty:%s", elements->tags) +// taosArrayDestroy(tags); +// return TSDB_CODE_SML_INVALID_DATA; +// } +// for (int32_t i = 0; i < tagNum; ++i) { +// SSmlKv kv = *(SSmlKv*)taosArrayGet(tags, i); +// +// if(info->dataFormat){ +// if(unlikely(cnt + 1 > info->currSTableMeta->tableInfo.numOfTags)){ +// info->dataFormat = false; +// info->reRun = true; +// taosArrayDestroy(tags); +// return TSDB_CODE_SUCCESS; +// } +// +// if(isSameMeasure){ +// if(unlikely(cnt >= taosArrayGetSize(preLineKV))) { +// info->dataFormat = false; +// info->reRun = true; +// taosArrayDestroy(tags); +// return TSDB_CODE_SUCCESS; +// } +// SSmlKv *preKV = (SSmlKv *)taosArrayGet(preLineKV, cnt); +// if(unlikely(kv.length > preKV->length)){ +// preKV->length = kv.length; +// SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL); +// ASSERT(tableMeta != NULL); +// +// SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->tags, cnt); +// oldKV->length = kv.length; +// info->needModifySchema = true; +// } +// if(unlikely(!IS_SAME_KEY)){ +// info->dataFormat = false; +// info->reRun = true; +// taosArrayDestroy(tags); +// return TSDB_CODE_SUCCESS; +// } +// }else{ +// if(isSuperKVInit){ +// if(unlikely(cnt >= taosArrayGetSize(superKV))) { +// info->dataFormat = false; +// info->reRun = true; +// taosArrayDestroy(tags); +// return TSDB_CODE_SUCCESS; +// } +// SSmlKv *preKV = (SSmlKv *)taosArrayGet(superKV, cnt); +// if(unlikely(kv.length > preKV->length)) { +// preKV->length = kv.length; +// }else{ +// kv.length = preKV->length; +// } +// info->needModifySchema = true; +// +// if(unlikely(!IS_SAME_KEY)){ +// info->dataFormat = false; +// info->reRun = true; +// taosArrayDestroy(tags); +// return TSDB_CODE_SUCCESS; +// } +// }else{ +// taosArrayPush(superKV, &kv); +// } +// taosArrayPush(preLineKV, &kv); +// } +// }else{ +// taosArrayPush(preLineKV, &kv); +// } +// cnt++; +// } +// taosArrayDestroy(tags); +// +// SSmlTableInfo *tinfo = (SSmlTableInfo *)nodeListGet(info->childTables, elements, POINTER_BYTES, is_same_child_table_telnet); +// if (unlikely(tinfo == NULL)) { +// tinfo = smlBuildTableInfo(1, elements->measure, elements->measureLen); +// if (unlikely(!tinfo)) { +// return TSDB_CODE_OUT_OF_MEMORY; +// } +// tinfo->tags = taosArrayDup(preLineKV, NULL); +// +// smlSetCTableName(tinfo); +// if (info->dataFormat) { +// info->currSTableMeta->uid = tinfo->uid; +// tinfo->tableDataCtx = smlInitTableDataCtx(info->pQuery, info->currSTableMeta); +// if (tinfo->tableDataCtx == NULL) { +// smlBuildInvalidDataMsg(&info->msgBuf, "smlInitTableDataCtx error", NULL); +// return TSDB_CODE_SML_INVALID_DATA; +// } +// } +// +// SSmlLineInfo *key = (SSmlLineInfo *)taosMemoryMalloc(sizeof(SSmlLineInfo)); +// *key = *elements; +// tinfo->key = key; +// nodeListSet(&info->childTables, key, POINTER_BYTES, tinfo, is_same_child_table_telnet); +// } +// if (info->dataFormat) info->currTableDataCtx = tinfo->tableDataCtx; +// +// return ret; +//} static char* smlJsonGetObj(char *payload){ int leftBracketCnt = 0; @@ -233,7 +240,7 @@ static char* smlJsonGetObj(char *payload){ return NULL; } -void smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset){ +int smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset){ int index = 0; while(*(*start)){ if((*start)[0] != '"'){ @@ -241,10 +248,11 @@ void smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset){ continue; } - if(unlikely(index >= 4)) { - uError("index >= 4, %s", *start) + if(unlikely(index >= OTD_JSON_FIELDS_NUM)) { + uError("index >= %d, %s", OTD_JSON_FIELDS_NUM, *start) break; } + char *sTmp = *start; if((*start)[1] == 'm' && (*start)[2] == 'e' && (*start)[3] == 't' && (*start)[4] == 'r' && (*start)[5] == 'i' && (*start)[6] == 'c' && (*start)[7] == '"'){ @@ -333,9 +341,15 @@ void smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset){ } (*start)++; } + + if(unlikely(index != OTD_JSON_FIELDS_NUM) || element->tags == NULL || element->cols == NULL || element->measure == NULL || element->timestamp == NULL) { + uError("elements != %d or element parse null", OTD_JSON_FIELDS_NUM) + return -1; + } + return 0; } -void smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset){ +int smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset){ int index = 0; while(*(*start)){ if((*start)[0] != '"'){ @@ -343,10 +357,11 @@ void smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset){ continue; } - if(unlikely(index >= 4)) { - uError("index >= 4, %s", *start) + if(unlikely(index >= OTD_JSON_FIELDS_NUM)) { + uError("index >= %d, %s", OTD_JSON_FIELDS_NUM, *start) break; } + if((*start)[1] == 'm'){ (*start) += offset[index++]; element->measure = *start; @@ -393,30 +408,716 @@ void smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset){ } (*start)++; } + + if(unlikely(index != 0 && index != OTD_JSON_FIELDS_NUM)) { + uError("elements != %d", OTD_JSON_FIELDS_NUM) + return -1; + } + return 0; +} + +static inline int32_t smlParseMetricFromJSON(SSmlHandle *info, cJSON *metric, SSmlLineInfo *elements) { + elements->measureLen = strlen(metric->valuestring); + if (IS_INVALID_TABLE_LEN(elements->measureLen)) { + uError("OTD:0x%" PRIx64 " Metric lenght is 0 or large than 192", info->id); + return TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH; + } + + elements->measure = metric->valuestring; + return TSDB_CODE_SUCCESS; +} + +const char *jsonName[OTD_JSON_FIELDS_NUM] = {"metric", "timestamp", "value", "tags"}; +static int32_t smlGetJsonElements(cJSON *root, cJSON ***marks){ + for (int i = 0; i < OTD_JSON_FIELDS_NUM; ++i) { + cJSON *child = root->child; + while(child != NULL) + { + if(strcasecmp(child->string, jsonName[i]) == 0){ + *marks[i] = child; + break; + } + child = child->next; + } + if(*marks[i] == NULL){ + uError("smlGetJsonElements error, not find mark:%d:%s", i, jsonName[i]); + return -1; + } + } + return TSDB_CODE_SUCCESS; +} + +static int32_t smlConvertJSONBool(SSmlKv *pVal, char *typeStr, cJSON *value) { + if (strcasecmp(typeStr, "bool") != 0) { + uError("OTD:invalid type(%s) for JSON Bool", typeStr); + return TSDB_CODE_TSC_INVALID_JSON_TYPE; + } + pVal->type = TSDB_DATA_TYPE_BOOL; + pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->i = value->valueint; + + return TSDB_CODE_SUCCESS; +} + +static int32_t smlConvertJSONNumber(SSmlKv *pVal, char *typeStr, cJSON *value) { + // tinyint + if (strcasecmp(typeStr, "i8") == 0 || strcasecmp(typeStr, "tinyint") == 0) { + if (!IS_VALID_TINYINT(value->valuedouble)) { + uError("OTD:JSON value(%f) cannot fit in type(tinyint)", value->valuedouble); + return TSDB_CODE_TSC_VALUE_OUT_OF_RANGE; + } + pVal->type = TSDB_DATA_TYPE_TINYINT; + pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->i = value->valuedouble; + return TSDB_CODE_SUCCESS; + } + // smallint + if (strcasecmp(typeStr, "i16") == 0 || strcasecmp(typeStr, "smallint") == 0) { + if (!IS_VALID_SMALLINT(value->valuedouble)) { + uError("OTD:JSON value(%f) cannot fit in type(smallint)", value->valuedouble); + return TSDB_CODE_TSC_VALUE_OUT_OF_RANGE; + } + pVal->type = TSDB_DATA_TYPE_SMALLINT; + pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->i = value->valuedouble; + return TSDB_CODE_SUCCESS; + } + // int + if (strcasecmp(typeStr, "i32") == 0 || strcasecmp(typeStr, "int") == 0) { + if (!IS_VALID_INT(value->valuedouble)) { + uError("OTD:JSON value(%f) cannot fit in type(int)", value->valuedouble); + return TSDB_CODE_TSC_VALUE_OUT_OF_RANGE; + } + pVal->type = TSDB_DATA_TYPE_INT; + pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->i = value->valuedouble; + return TSDB_CODE_SUCCESS; + } + // bigint + if (strcasecmp(typeStr, "i64") == 0 || strcasecmp(typeStr, "bigint") == 0) { + pVal->type = TSDB_DATA_TYPE_BIGINT; + pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + if (value->valuedouble >= (double)INT64_MAX) { + pVal->i = INT64_MAX; + } else if (value->valuedouble <= (double)INT64_MIN) { + pVal->i = INT64_MIN; + } else { + pVal->i = value->valuedouble; + } + return TSDB_CODE_SUCCESS; + } + // float + if (strcasecmp(typeStr, "f32") == 0 || strcasecmp(typeStr, "float") == 0) { + if (!IS_VALID_FLOAT(value->valuedouble)) { + uError("OTD:JSON value(%f) cannot fit in type(float)", value->valuedouble); + return TSDB_CODE_TSC_VALUE_OUT_OF_RANGE; + } + pVal->type = TSDB_DATA_TYPE_FLOAT; + pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->f = value->valuedouble; + return TSDB_CODE_SUCCESS; + } + // double + if (strcasecmp(typeStr, "f64") == 0 || strcasecmp(typeStr, "double") == 0) { + pVal->type = TSDB_DATA_TYPE_DOUBLE; + pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->d = value->valuedouble; + return TSDB_CODE_SUCCESS; + } + + // if reach here means type is unsupported + uError("OTD:invalid type(%s) for JSON Number", typeStr); + return TSDB_CODE_TSC_INVALID_JSON_TYPE; +} + +static int32_t smlConvertJSONString(SSmlKv *pVal, char *typeStr, cJSON *value) { + if (strcasecmp(typeStr, "binary") == 0) { + pVal->type = TSDB_DATA_TYPE_BINARY; + } else if (strcasecmp(typeStr, "nchar") == 0) { + pVal->type = TSDB_DATA_TYPE_NCHAR; + } else { + uError("OTD:invalid type(%s) for JSON String", typeStr); + return TSDB_CODE_TSC_INVALID_JSON_TYPE; + } + pVal->length = (int16_t)strlen(value->valuestring); + + if (pVal->type == TSDB_DATA_TYPE_BINARY && pVal->length > TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE) { + return TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN; + } + if (pVal->type == TSDB_DATA_TYPE_NCHAR && + pVal->length > (TSDB_MAX_NCHAR_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { + return TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN; + } + + pVal->value = value->valuestring; + return TSDB_CODE_SUCCESS; +} + +static int32_t smlParseValueFromJSONObj(cJSON *root, SSmlKv *kv) { + int32_t ret = TSDB_CODE_SUCCESS; + int32_t size = cJSON_GetArraySize(root); + + if (size != OTD_JSON_SUB_FIELDS_NUM) { + return TSDB_CODE_TSC_INVALID_JSON; + } + + cJSON *value = cJSON_GetObjectItem(root, "value"); + if (value == NULL) { + return TSDB_CODE_TSC_INVALID_JSON; + } + + cJSON *type = cJSON_GetObjectItem(root, "type"); + if (!cJSON_IsString(type)) { + return TSDB_CODE_TSC_INVALID_JSON; + } + + switch (value->type) { + case cJSON_True: + case cJSON_False: { + ret = smlConvertJSONBool(kv, type->valuestring, value); + if (ret != TSDB_CODE_SUCCESS) { + return ret; + } + break; + } + case cJSON_Number: { + ret = smlConvertJSONNumber(kv, type->valuestring, value); + if (ret != TSDB_CODE_SUCCESS) { + return ret; + } + break; + } + case cJSON_String: { + ret = smlConvertJSONString(kv, type->valuestring, value); + if (ret != TSDB_CODE_SUCCESS) { + return ret; + } + break; + } + default: + return TSDB_CODE_TSC_INVALID_JSON_TYPE; + } + + return TSDB_CODE_SUCCESS; +} + +static int32_t smlParseValueFromJSON(cJSON *root, SSmlKv *kv) { + switch (root->type) { + case cJSON_True: + case cJSON_False: { + kv->type = TSDB_DATA_TYPE_BOOL; + kv->length = (int16_t)tDataTypes[kv->type].bytes; + kv->i = root->valueint; + break; + } + case cJSON_Number: { + kv->type = TSDB_DATA_TYPE_DOUBLE; + kv->length = (int16_t)tDataTypes[kv->type].bytes; + kv->d = root->valuedouble; + break; + } + case cJSON_String: { + /* set default JSON type to binary/nchar according to + * user configured parameter tsDefaultJSONStrType + */ + + char *tsDefaultJSONStrType = "nchar"; // todo + smlConvertJSONString(kv, tsDefaultJSONStrType, root); + break; + } + case cJSON_Object: { + int32_t ret = smlParseValueFromJSONObj(root, kv); + if (ret != TSDB_CODE_SUCCESS) { + uError("OTD:Failed to parse value from JSON Obj"); + return ret; + } + break; + } + default: + return TSDB_CODE_TSC_INVALID_JSON; + } + + return TSDB_CODE_SUCCESS; +} + +static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo *elements) { + int32_t ret = TSDB_CODE_SUCCESS; + + bool isSameMeasure = IS_SAME_SUPER_TABLE; + + int cnt = 0; + SArray *preLineKV = info->preLineTagKV; + SArray *maxKVs = info->maxTagKVs; + bool isSuperKVInit = true; + SArray *superKV = NULL; + if(info->dataFormat){ + if(unlikely(!isSameMeasure)){ + SSmlSTableMeta *sMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL); + + if(unlikely(sMeta == NULL)){ + sMeta = smlBuildSTableMeta(info->dataFormat); + STableMeta * pTableMeta = smlGetMeta(info, elements->measure, elements->measureLen); + sMeta->tableMeta = pTableMeta; + if(pTableMeta == NULL){ + info->dataFormat = false; + info->reRun = true; + return TSDB_CODE_SUCCESS; + } + nodeListSet(&info->superTables, elements->measure, elements->measureLen, sMeta, NULL); + } + info->currSTableMeta = sMeta->tableMeta; + superKV = sMeta->tags; + + if(unlikely(taosArrayGetSize(superKV) == 0)){ + isSuperKVInit = false; + } + taosArraySetSize(maxKVs, 0); + } + }else{ + taosArraySetSize(maxKVs, 0); + } + taosArraySetSize(preLineKV, 0); + + int32_t tagNum = cJSON_GetArraySize(tags); + if(unlikely(tagNum == 0)){ + uError("SML:Tag should not be empty"); + return TSDB_CODE_TSC_INVALID_JSON; + } + for (int32_t i = 0; i < tagNum; ++i) { + cJSON *tag = cJSON_GetArrayItem(tags, i); + if (unlikely(tag == NULL)) { + return TSDB_CODE_TSC_INVALID_JSON; + } +// if(unlikely(tag == cMeasure)) continue; + size_t keyLen = strlen(tag->string); + if (unlikely(IS_INVALID_COL_LEN(keyLen))) { + uError("OTD:Tag key length is 0 or too large than 64"); + return TSDB_CODE_TSC_INVALID_COLUMN_LENGTH; + } + + // add kv to SSmlKv + SSmlKv kv ={.key = tag->string, .keyLen = keyLen}; + // value + ret = smlParseValueFromJSON(tag, &kv); + if (unlikely(ret != TSDB_CODE_SUCCESS)) { + return ret; + } + + if(info->dataFormat){ + if(unlikely(cnt + 1 > info->currSTableMeta->tableInfo.numOfTags)){ + info->dataFormat = false; + info->reRun = true; + return TSDB_CODE_SUCCESS; + } + + if(isSameMeasure){ + if(unlikely(cnt >= taosArrayGetSize(maxKVs))) { + info->dataFormat = false; + info->reRun = true; + return TSDB_CODE_SUCCESS; + } + SSmlKv *maxKV = (SSmlKv *)taosArrayGet(maxKVs, cnt); + if(unlikely(kv.length > maxKV->length)){ + maxKV->length = kv.length; + SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL); + ASSERT(tableMeta != NULL); + + SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->tags, cnt); + oldKV->length = kv.length; + info->needModifySchema = true; + } + if(unlikely(!IS_SAME_KEY)){ + info->dataFormat = false; + info->reRun = true; + return TSDB_CODE_SUCCESS; + } + }else{ + if(isSuperKVInit){ + if(unlikely(cnt >= taosArrayGetSize(superKV))) { + info->dataFormat = false; + info->reRun = true; + return TSDB_CODE_SUCCESS; + } + SSmlKv *maxKV = (SSmlKv *)taosArrayGet(superKV, cnt); + if(unlikely(kv.length > maxKV->length)) { + maxKV->length = kv.length; + }else{ + kv.length = maxKV->length; + } + info->needModifySchema = true; + + if(unlikely(!IS_SAME_KEY)){ + info->dataFormat = false; + info->reRun = true; + return TSDB_CODE_SUCCESS; + } + }else{ + taosArrayPush(superKV, &kv); + } + taosArrayPush(maxKVs, &kv); + } + }else{ + taosArrayPush(maxKVs, &kv); + } + taosArrayPush(preLineKV, &kv); + cnt++; + } + + SSmlTableInfo *tinfo = (SSmlTableInfo *)nodeListGet(info->childTables, elements, POINTER_BYTES, is_same_child_table_telnet); + if (unlikely(tinfo == NULL)) { + tinfo = smlBuildTableInfo(1, elements->measure, elements->measureLen); + if (unlikely(!tinfo)) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tinfo->tags = taosArrayDup(preLineKV, NULL); + + smlSetCTableName(tinfo); + if (info->dataFormat) { + info->currSTableMeta->uid = tinfo->uid; + tinfo->tableDataCtx = smlInitTableDataCtx(info->pQuery, info->currSTableMeta); + if (tinfo->tableDataCtx == NULL) { + smlBuildInvalidDataMsg(&info->msgBuf, "smlInitTableDataCtx error", NULL); + return TSDB_CODE_SML_INVALID_DATA; + } + } + + SSmlLineInfo *key = (SSmlLineInfo *)taosMemoryMalloc(sizeof(SSmlLineInfo)); + *key = *elements; + if(info->parseJsonByLib){ + key->tags = taosMemoryMalloc(elements->tagsLen + 1); + memcpy(key->tags, elements->tags, elements->tagsLen); + key->tags[elements->tagsLen] = 0; + } + tinfo->key = key; + nodeListSet(&info->childTables, key, POINTER_BYTES, tinfo, is_same_child_table_telnet); + } + if (info->dataFormat) info->currTableDataCtx = tinfo->tableDataCtx; + + return ret; +} + +static int64_t smlParseTSFromJSONObj(SSmlHandle *info, cJSON *root, int32_t toPrecision) { + int32_t size = cJSON_GetArraySize(root); + if (unlikely(size != OTD_JSON_SUB_FIELDS_NUM)) { + smlBuildInvalidDataMsg(&info->msgBuf, "invalidate json", NULL); + return -1; + } + + cJSON *value = cJSON_GetObjectItem(root, "value"); + if (unlikely(!cJSON_IsNumber(value))) { + smlBuildInvalidDataMsg(&info->msgBuf, "invalidate json", NULL); + return -1; + } + + cJSON *type = cJSON_GetObjectItem(root, "type"); + if (unlikely(!cJSON_IsString(type))) { + smlBuildInvalidDataMsg(&info->msgBuf, "invalidate json", NULL); + return -1; + } + + double timeDouble = value->valuedouble; + if (unlikely(smlDoubleToInt64OverFlow(timeDouble))) { + smlBuildInvalidDataMsg(&info->msgBuf, "timestamp is too large", NULL); + return -1; + } + + if (timeDouble == 0) { + return taosGetTimestampNs()/smlFactorNS[toPrecision]; + } + + if (timeDouble < 0) { + return timeDouble; + } + + int64_t tsInt64 = timeDouble; + size_t typeLen = strlen(type->valuestring); + if (typeLen == 1 && (type->valuestring[0] == 's' || type->valuestring[0] == 'S')) { + // seconds + int8_t fromPrecision = TSDB_TIME_PRECISION_SECONDS; + if(smlFactorS[toPrecision] < INT64_MAX / tsInt64){ + return tsInt64 * smlFactorS[toPrecision]; + } + return -1; + } else if (typeLen == 2 && (type->valuestring[1] == 's' || type->valuestring[1] == 'S')) { + switch (type->valuestring[0]) { + case 'm': + case 'M': + // milliseconds + return convertTimePrecision(tsInt64, TSDB_TIME_PRECISION_MILLI, toPrecision); + break; + case 'u': + case 'U': + // microseconds + return convertTimePrecision(tsInt64, TSDB_TIME_PRECISION_MICRO, toPrecision); + break; + case 'n': + case 'N': + return convertTimePrecision(tsInt64, TSDB_TIME_PRECISION_NANO, toPrecision); + break; + default: + return -1; + } + } else { + return -1; + } +} + +uint8_t smlGetTimestampLen(int64_t num) { + uint8_t len = 0; + while ((num /= 10) != 0) { + len++; + } + len++; + return len; +} + +static int64_t smlParseTSFromJSON(SSmlHandle *info, cJSON *timestamp) { + // Timestamp must be the first KV to parse + int32_t toPrecision = info->currSTableMeta ? info->currSTableMeta->tableInfo.precision : TSDB_TIME_PRECISION_NANO; + if (cJSON_IsNumber(timestamp)) { + // timestamp value 0 indicates current system time + double timeDouble = timestamp->valuedouble; + if (unlikely(smlDoubleToInt64OverFlow(timeDouble))) { + smlBuildInvalidDataMsg(&info->msgBuf, "timestamp is too large", NULL); + return -1; + } + + if (unlikely(timeDouble < 0)) { + smlBuildInvalidDataMsg(&info->msgBuf, + "timestamp is negative", NULL); + return timeDouble; + }else if (unlikely(timeDouble == 0)) { + return taosGetTimestampNs()/smlFactorNS[toPrecision]; + } + + uint8_t tsLen = smlGetTimestampLen((int64_t)timeDouble); + + int8_t fromPrecision = smlGetTsTypeByLen(tsLen); + if (unlikely(fromPrecision == -1)) { + smlBuildInvalidDataMsg(&info->msgBuf, + "timestamp precision can only be seconds(10 digits) or milli seconds(13 digits)", NULL); + return -1; + } + int64_t tsInt64 = timeDouble; + if(fromPrecision == TSDB_TIME_PRECISION_SECONDS){ + if(smlFactorS[toPrecision] < INT64_MAX / tsInt64){ + return tsInt64 * smlFactorS[toPrecision]; + } + return -1; + }else{ + return convertTimePrecision(timeDouble, fromPrecision, toPrecision); + } + } else if (cJSON_IsObject(timestamp)) { + return smlParseTSFromJSONObj(info, timestamp, toPrecision); + } else { + smlBuildInvalidDataMsg(&info->msgBuf, + "invalidate json", NULL); + return -1; + } +} + +static int32_t smlParseJSONStringExt(SSmlHandle *info, cJSON *root, SSmlLineInfo *elements) { + int32_t ret = TSDB_CODE_SUCCESS; + + cJSON *metricJson = NULL; + cJSON *tsJson = NULL; + cJSON *valueJson = NULL; + cJSON *tagsJson = NULL; + char* rootStr = cJSON_PrintUnformatted(root); + uError("rootStr:%s", rootStr); + taosMemoryFree(rootStr); + + int32_t size = cJSON_GetArraySize(root); + // outmost json fields has to be exactly 4 + if (size != OTD_JSON_FIELDS_NUM) { + uError("OTD:0x%" PRIx64 " Invalid number of JSON fields in data point %d", info->id, size); + return TSDB_CODE_TSC_INVALID_JSON; + } + + cJSON **marks[OTD_JSON_FIELDS_NUM] = {&metricJson, &tsJson, &valueJson, &tagsJson}; + ret = smlGetJsonElements(root, marks); + if (unlikely(ret != TSDB_CODE_SUCCESS)) { + return ret; + } + + // Parse metric + ret = smlParseMetricFromJSON(info, metricJson, elements); + if (unlikely(ret != TSDB_CODE_SUCCESS)) { + uError("OTD:0x%" PRIx64 " Unable to parse metric from JSON payload", info->id); + return ret; + } + + // Parse metric value + SSmlKv kv = {.key = VALUE, .keyLen = VALUE_LEN}; + ret = smlParseValueFromJSON(valueJson, &kv); + if (unlikely(ret)) { + uError("OTD:0x%" PRIx64 " Unable to parse metric value from JSON payload", info->id); + return ret; + } + + // Parse tags + elements->tags = cJSON_PrintUnformatted(tagsJson); + elements->tagsLen = strlen(elements->tags); + if(is_same_child_table_telnet(elements, &info->preLine) != 0) { + ret = smlParseTagsFromJSON(info, tagsJson, elements); + if (unlikely(ret)) { + uError("OTD:0x%" PRIx64 " Unable to parse tags from JSON payload", info->id); + taosMemoryFree(elements->tags); + elements->tags = NULL; + return ret; + } + } + + if(info->dataFormat){ + taosMemoryFree(elements->tags); + elements->tags = NULL; + } + + if(unlikely(info->reRun)){ + return TSDB_CODE_SUCCESS; + } + + // Parse timestamp + // notice!!! put ts back to tag to ensure get meta->precision + int64_t ts = smlParseTSFromJSON(info, tsJson); + if (unlikely(ts < 0)) { + uError("OTD:0x%" PRIx64 " Unable to parse timestamp from JSON payload", info->id); + return TSDB_CODE_INVALID_TIMESTAMP; + } + SSmlKv kvTs = { .key = TS, .keyLen = TS_LEN, .type = TSDB_DATA_TYPE_TIMESTAMP, .i = ts, .length = (size_t)tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes}; + + if(info->dataFormat){ + ret = smlBuildCol(info->currTableDataCtx, info->currSTableMeta->schema, &kvTs, 0); + if(ret == TSDB_CODE_SUCCESS){ + ret = smlBuildCol(info->currTableDataCtx, info->currSTableMeta->schema, &kv, 1); + } + if(ret == TSDB_CODE_SUCCESS){ + ret = smlBuildRow(info->currTableDataCtx); + } + if (unlikely(ret != TSDB_CODE_SUCCESS)) { + smlBuildInvalidDataMsg(&info->msgBuf, "smlBuildCol error", NULL); + return ret; + } + }else{ + if(elements->colArray == NULL){ + elements->colArray = taosArrayInit(16, sizeof(SSmlKv)); + } + taosArrayPush(elements->colArray, &kvTs); + taosArrayPush(elements->colArray, &kv); + } + info->preLine = *elements; + + return TSDB_CODE_SUCCESS; +} + +static int32_t smlParseJSONExt(SSmlHandle *info, char *payload) { + int32_t payloadNum = 0; + int32_t ret = TSDB_CODE_SUCCESS; + + if (unlikely(payload == NULL)) { + uError("SML:0x%" PRIx64 " empty JSON Payload", info->id); + return TSDB_CODE_TSC_INVALID_JSON; + } + + info->root = cJSON_Parse(payload); + if (unlikely(info->root == NULL)) { + uError("SML:0x%" PRIx64 " parse json failed:%s", info->id, payload); + return TSDB_CODE_TSC_INVALID_JSON; + } + + // multiple data points must be sent in JSON array + if (cJSON_IsArray(info->root)) { + payloadNum = cJSON_GetArraySize(info->root); + } else if (cJSON_IsObject(info->root)) { + payloadNum = 1; + } else { + uError("SML:0x%" PRIx64 " Invalid JSON Payload 3:%s", info->id, payload); + return TSDB_CODE_TSC_INVALID_JSON; + } + + info->lineNum = payloadNum; + info->dataFormat = true; + if (unlikely(info->lines != NULL)) { + taosMemoryFree(info->lines); + info->lines = NULL; + } + ret = smlClearForRerun(info); + if(ret != TSDB_CODE_SUCCESS){ + return ret; + } + + info->parseJsonByLib = true; + cJSON *head = (payloadNum == 1 && cJSON_IsObject(info->root)) ? info->root : info->root->child; + + int cnt = 0; + cJSON *dataPoint = head; + while (dataPoint) { + if(info->dataFormat) { + SSmlLineInfo element = {0}; + ret = smlParseJSONStringExt(info, dataPoint, &element); + }else{ + ret = smlParseJSONStringExt(info, dataPoint, info->lines + cnt); + } + if (unlikely(ret != TSDB_CODE_SUCCESS)) { + uError("SML:0x%" PRIx64 " Invalid JSON Payload 2:%s", info->id, payload); + return ret; + } + + if(unlikely(info->reRun)){ + cnt = 0; + dataPoint = head; + info->lineNum = payloadNum; + ret = smlClearForRerun(info); + if(ret != TSDB_CODE_SUCCESS){ + return ret; + } + continue; + } + cnt++; + dataPoint = dataPoint->next; + } + + return TSDB_CODE_SUCCESS; } static int32_t smlParseJSONString(SSmlHandle *info, char **start, SSmlLineInfo *elements) { int32_t ret = TSDB_CODE_SUCCESS; if(info->offset[0] == 0){ - smlJsonParseObjFirst(start, elements, info->offset); + ret = smlJsonParseObjFirst(start, elements, info->offset); }else{ - smlJsonParseObj(start, elements, info->offset); + ret = smlJsonParseObj(start, elements, info->offset); + } + + if (ret != TSDB_CODE_SUCCESS) { + return TSDB_CODE_TSC_INVALID_VALUE; } - if(**start == '\0') return TSDB_CODE_SUCCESS; + + if(unlikely(**start == '\0' && elements->measure == NULL)) return TSDB_CODE_SUCCESS; SSmlKv kv = {.key = VALUE, .keyLen = VALUE_LEN, .value = elements->cols, .length = (size_t)elements->colsLen}; - if (smlParseNumber(&kv, &info->msgBuf)) { - kv.length = (int16_t)tDataTypes[kv.type].bytes; - }else{ + if (elements->colsLen == 0 || smlParseValue(&kv, &info->msgBuf) != TSDB_CODE_SUCCESS) { + uError("SML:cols invalidate:%s", elements->cols); return TSDB_CODE_TSC_INVALID_VALUE; } // Parse tags - ret = smlParseTagsFromJSON(info, elements); - if (unlikely(ret)) { - uError("OTD:0x%" PRIx64 " Unable to parse tags from JSON payload", info->id); - return ret; + if(is_same_child_table_telnet(elements, &info->preLine) != 0){ + char tmp = *(elements->tags + elements->tagsLen); + *(elements->tags + elements->tagsLen) = 0; + cJSON* tagsJson = cJSON_Parse(elements->tags); + *(elements->tags + elements->tagsLen) = tmp; + if (unlikely(tagsJson == NULL)) { + uError("SML:0x%" PRIx64 " parse json failed:%s", info->id, elements->tags); + return TSDB_CODE_TSC_INVALID_JSON; + } + + ret = smlParseTagsFromJSON(info, tagsJson, elements); + cJSON_free(tagsJson); + if (unlikely(ret)) { + uError("OTD:0x%" PRIx64 " Unable to parse tags from JSON payload", info->id); + return ret; + } } if(unlikely(info->reRun)){ @@ -460,6 +1161,7 @@ int32_t smlParseJSON(SSmlHandle *info, char *payload) { int32_t payloadNum = 1 << 15; int32_t ret = TSDB_CODE_SUCCESS; + uDebug("SML:0x%" PRIx64 "json:%s", info->id, payload); int cnt = 0; char *dataPointStart = payload; while (1) { @@ -472,17 +1174,16 @@ int32_t smlParseJSON(SSmlHandle *info, char *payload) { void* tmp = taosMemoryRealloc(info->lines, payloadNum * sizeof(SSmlLineInfo)); if(tmp != NULL){ info->lines = (SSmlLineInfo*)tmp; + memset(info->lines + cnt, 0, (payloadNum - cnt) * sizeof(SSmlLineInfo)); } } ret = smlParseJSONString(info, &dataPointStart, info->lines + cnt); } if (unlikely(ret != TSDB_CODE_SUCCESS)) { - uError("SML:0x%" PRIx64 " Invalid JSON Payload", info->id); - return ret; + uError("SML:0x%" PRIx64 " Invalid JSON Payload 1:%s", info->id, payload); + return smlParseJSONExt(info, payload); } - if(*dataPointStart == '\0') break; - if(unlikely(info->reRun)){ cnt = 0; dataPointStart = payload; @@ -493,6 +1194,8 @@ int32_t smlParseJSON(SSmlHandle *info, char *payload) { } continue; } + + if(*dataPointStart == '\0') break; cnt++; } info->lineNum = cnt; diff --git a/source/client/src/clientSmlLine.c b/source/client/src/clientSmlLine.c index f56ad34fc52bc1687ce42aa38256b01eb4724f68..d93fdf198fac69541aace7d1c2bb398aed63ebfa 100644 --- a/source/client/src/clientSmlLine.c +++ b/source/client/src/clientSmlLine.c @@ -57,52 +57,6 @@ uint8_t smlPrecisionConvert[7] = {TSDB_TIME_PRECISION_NANO, TSDB_TIME_PRECISION_ TSDB_TIME_PRECISION_SECONDS, TSDB_TIME_PRECISION_MILLI, TSDB_TIME_PRECISION_MICRO, TSDB_TIME_PRECISION_NANO}; -static bool smlParseBool(SSmlKv *kvVal) { - const char *pVal = kvVal->value; - int32_t len = kvVal->length; - if ((len == 1) && (pVal[0] == 't' || pVal[0] == 'T')) { - kvVal->i = TSDB_TRUE; - return true; - } - - if ((len == 1) && (pVal[0] == 'f' || pVal[0] == 'F')) { - kvVal->i = TSDB_FALSE; - return true; - } - - if ((len == 4) && !strncasecmp(pVal, "true", len)) { - kvVal->i = TSDB_TRUE; - return true; - } - if ((len == 5) && !strncasecmp(pVal, "false", len)) { - kvVal->i = TSDB_FALSE; - return true; - } - return false; -} - -static bool smlIsBinary(const char *pVal, uint16_t len) { - // binary: "abc" - if (len < 2) { - return false; - } - if (pVal[0] == '"' && pVal[len - 1] == '"') { - return true; - } - return false; -} - -static bool smlIsNchar(const char *pVal, uint16_t len) { - // nchar: L"abc" - if (len < 3) { - return false; - } - if (pVal[1] == '"' && pVal[len - 1] == '"' && (pVal[0] == 'l' || pVal[0] == 'L')) { - return true; - } - return false; -} - static int64_t smlParseInfluxTime(SSmlHandle *info, const char *data, int32_t len) { uint8_t toPrecision = info->currSTableMeta ? info->currSTableMeta->tableInfo.precision : TSDB_TIME_PRECISION_NANO; @@ -189,6 +143,7 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd, int cnt = 0; SArray *preLineKV = info->preLineTagKV; + SArray *maxKVs = info->maxTagKVs; bool isSuperKVInit = true; SArray *superKV = NULL; if(info->dataFormat){ @@ -212,12 +167,12 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd, if(unlikely(taosArrayGetSize(superKV) == 0)){ isSuperKVInit = false; } - taosArraySetSize(preLineKV, 0); + taosArraySetSize(maxKVs, 0); } }else{ - taosArraySetSize(preLineKV, 0); + taosArraySetSize(maxKVs, 0); } - + taosArraySetSize(preLineKV, 0); while (*sql < sqlEnd) { if (unlikely(IS_SPACE(*sql))) { @@ -295,14 +250,14 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd, } if(isSameMeasure){ - if(unlikely(cnt >= taosArrayGetSize(preLineKV))) { + if(unlikely(cnt >= taosArrayGetSize(maxKVs))) { info->dataFormat = false; info->reRun = true; return TSDB_CODE_SUCCESS; } - SSmlKv *preKV = (SSmlKv *)taosArrayGet(preLineKV, cnt); - if(unlikely(kv.length > preKV->length)){ - preKV->length = kv.length; + SSmlKv *maxKV = (SSmlKv *)taosArrayGet(maxKVs, cnt); + if(unlikely(kv.length > maxKV->length)){ + maxKV->length = kv.length; SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, currElement->measure, currElement->measureLen, NULL); ASSERT(tableMeta != NULL); @@ -322,11 +277,11 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd, info->reRun = true; return TSDB_CODE_SUCCESS; } - SSmlKv *preKV = (SSmlKv *)taosArrayGet(superKV, cnt); - if(unlikely(kv.length > preKV->length)) { - preKV->length = kv.length; + SSmlKv *maxKV = (SSmlKv *)taosArrayGet(superKV, cnt); + if(unlikely(kv.length > maxKV->length)) { + maxKV->length = kv.length; }else{ - kv.length = preKV->length; + kv.length = maxKV->length; } info->needModifySchema = true; @@ -338,11 +293,12 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd, }else{ taosArrayPush(superKV, &kv); } - taosArrayPush(preLineKV, &kv); + taosArrayPush(maxKVs, &kv); } }else{ - taosArrayPush(preLineKV, &kv); + taosArrayPush(maxKVs, &kv); } + taosArrayPush(preLineKV, &kv); cnt++; if(IS_SPACE(*sql)){ @@ -518,15 +474,15 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd, info->reRun = true; return TSDB_CODE_SUCCESS; } - SSmlKv *preKV = (SSmlKv *)taosArrayGet(preLineKV, cnt); - if(kv.type != preKV->type){ + SSmlKv *maxKV = (SSmlKv *)taosArrayGet(preLineKV, cnt); + if(kv.type != maxKV->type){ info->dataFormat = false; info->reRun = true; return TSDB_CODE_SUCCESS; } - if(unlikely(IS_VAR_DATA_TYPE(kv.type) && kv.length > preKV->length)){ - preKV->length = kv.length; + if(unlikely(IS_VAR_DATA_TYPE(kv.type) && kv.length > maxKV->length)){ + maxKV->length = kv.length; SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, currElement->measure, currElement->measureLen, NULL); ASSERT(tableMeta != NULL); @@ -546,18 +502,18 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd, info->reRun = true; return TSDB_CODE_SUCCESS; } - SSmlKv *preKV = (SSmlKv *)taosArrayGet(superKV, cnt); - if(unlikely(kv.type != preKV->type)){ + SSmlKv *maxKV = (SSmlKv *)taosArrayGet(superKV, cnt); + if(unlikely(kv.type != maxKV->type)){ info->dataFormat = false; info->reRun = true; return TSDB_CODE_SUCCESS; } if(IS_VAR_DATA_TYPE(kv.type)){ - if(kv.length > preKV->length) { - preKV->length = kv.length; + if(kv.length > maxKV->length) { + maxKV->length = kv.length; }else{ - kv.length = preKV->length; + kv.length = maxKV->length; } info->needModifySchema = true; } diff --git a/source/client/src/clientSmlTelnet.c b/source/client/src/clientSmlTelnet.c index 53a7e3e81e99b8d3a5107964fe7a15c41a2a2420..71d4e2140078bade7662e419ccf212562314c115 100644 --- a/source/client/src/clientSmlTelnet.c +++ b/source/client/src/clientSmlTelnet.c @@ -23,6 +23,11 @@ int32_t is_same_child_table_telnet(const void *a, const void *b){ SSmlLineInfo *t1 = (SSmlLineInfo *)a; SSmlLineInfo *t2 = (SSmlLineInfo *)b; +// uError("is_same_child_table_telnet len:%d,%d %s,%s @@@ len:%d,%d %s,%s", t1->measureLen, t2->measureLen, +// t1->measure, t2->measure, t1->tagsLen, t2->tagsLen, t1->tags, t2->tags); + if(t1 == NULL || t2 == NULL || t1->measure == NULL || t2->measure == NULL + || t1->tags == NULL || t2->tags == NULL) + return 1; return (((t1->measureLen == t2->measureLen) && memcmp(t1->measure, t2->measure, t1->measureLen) == 0) && ((t1->tagsLen == t2->tagsLen) && memcmp(t1->tags, t2->tags, t1->tagsLen) == 0)) ? 0 : 1; } @@ -73,6 +78,7 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS int cnt = 0; SArray *preLineKV = info->preLineTagKV; + SArray *maxKVs = info->maxTagKVs; bool isSuperKVInit = true; SArray *superKV = NULL; if(info->dataFormat){ @@ -96,12 +102,13 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS if(unlikely(taosArrayGetSize(superKV) == 0)){ isSuperKVInit = false; } - taosArraySetSize(preLineKV, 0); + taosArraySetSize(maxKVs, 0); } }else{ - taosArraySetSize(preLineKV, 0); + taosArraySetSize(maxKVs, 0); } + taosArraySetSize(preLineKV, 0); const char *sql = data; while (sql < sqlEnd) { JUMP_SPACE(sql, sqlEnd) @@ -168,14 +175,14 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS } if(isSameMeasure){ - if(unlikely(cnt >= taosArrayGetSize(preLineKV))) { + if(unlikely(cnt >= taosArrayGetSize(maxKVs))) { info->dataFormat = false; info->reRun = true; return TSDB_CODE_SUCCESS; } - SSmlKv *preKV = (SSmlKv *)taosArrayGet(preLineKV, cnt); - if(unlikely(kv.length > preKV->length)){ - preKV->length = kv.length; + SSmlKv *maxKV = (SSmlKv *)taosArrayGet(maxKVs, cnt); + if(unlikely(kv.length > maxKV->length)){ + maxKV->length = kv.length; SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL); ASSERT(tableMeta != NULL); @@ -195,11 +202,11 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS info->reRun = true; return TSDB_CODE_SUCCESS; } - SSmlKv *preKV = (SSmlKv *)taosArrayGet(superKV, cnt); - if(unlikely(kv.length > preKV->length)) { - preKV->length = kv.length; + SSmlKv *maxKV = (SSmlKv *)taosArrayGet(superKV, cnt); + if(unlikely(kv.length > maxKV->length)) { + maxKV->length = kv.length; }else{ - kv.length = preKV->length; + kv.length = maxKV->length; } info->needModifySchema = true; @@ -211,11 +218,12 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS }else{ taosArrayPush(superKV, &kv); } - taosArrayPush(preLineKV, &kv); + taosArrayPush(maxKVs, &kv); } }else{ - taosArrayPush(preLineKV, &kv); + taosArrayPush(maxKVs, &kv); } + taosArrayPush(preLineKV, &kv); cnt++; } SSmlTableInfo *tinfo = (SSmlTableInfo *)nodeListGet(info->childTables, elements, POINTER_BYTES, is_same_child_table_telnet); diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index 8905dc21320322695aa0cb64c8433206fca5bec1..a3754d06952fc24199d6dd3ab576bee889374318 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -909,10 +909,12 @@ void tmqFreeImpl(void* handle) { tmq_t* tmq = (tmq_t*)handle; // TODO stop timer - tmqClearUnhandleMsg(tmq); - if (tmq->mqueue) taosCloseQueue(tmq->mqueue); + if (tmq->mqueue) { + tmqClearUnhandleMsg(tmq); + taosCloseQueue(tmq->mqueue); + } if (tmq->delayedTask) taosCloseQueue(tmq->delayedTask); - if (tmq->qall) taosFreeQall(tmq->qall); + taosFreeQall(tmq->qall); tsem_destroy(&tmq->rspSem); diff --git a/source/client/test/smlTest.cpp b/source/client/test/smlTest.cpp index d608447506778cad1e964cdd79183d87be0a88e8..76911e229a569403ccdcc36b4b90470d3f02618e 100644 --- a/source/client/test/smlTest.cpp +++ b/source/client/test/smlTest.cpp @@ -411,28 +411,28 @@ TEST(testCase, smlParseCols_Test) { smlDestroyInfo(info); } -//TEST(testCase, smlGetTimestampLen_Test) { -// uint8_t len = smlGetTimestampLen(0); -// ASSERT_EQ(len, 1); -// -// len = smlGetTimestampLen(1); -// ASSERT_EQ(len, 1); -// -// len = smlGetTimestampLen(10); -// ASSERT_EQ(len, 2); -// -// len = smlGetTimestampLen(390); -// ASSERT_EQ(len, 3); -// -// len = smlGetTimestampLen(-1); -// ASSERT_EQ(len, 1); -// -// len = smlGetTimestampLen(-10); -// ASSERT_EQ(len, 2); -// -// len = smlGetTimestampLen(-390); -// ASSERT_EQ(len, 3); -//} +TEST(testCase, smlGetTimestampLen_Test) { + uint8_t len = smlGetTimestampLen(0); + ASSERT_EQ(len, 1); + + len = smlGetTimestampLen(1); + ASSERT_EQ(len, 1); + + len = smlGetTimestampLen(10); + ASSERT_EQ(len, 2); + + len = smlGetTimestampLen(390); + ASSERT_EQ(len, 3); + + len = smlGetTimestampLen(-1); + ASSERT_EQ(len, 1); + + len = smlGetTimestampLen(-10); + ASSERT_EQ(len, 2); + + len = smlGetTimestampLen(-390); + ASSERT_EQ(len, 3); +} TEST(testCase, smlParseNumber_Test) { SSmlKv kv = {0}; @@ -503,35 +503,35 @@ TEST(testCase, smlParseTelnetLine_Test) { smlDestroyInfo(info); } -TEST(testCase, smlParseTelnetLine_diff_json_type2_Test) { - SSmlHandle *info = smlBuildSmlInfo(NULL); - info->protocol = TSDB_SML_JSON_PROTOCOL; - ASSERT_NE(info, nullptr); - - const char *sql[] = { - "[{\"metric\":\"sys.cpu.nice\",\"timestamp\": 1346846400,\"value\": 18,\"tags\": {\"host\": \"lga\"}},{\"metric\": \"sys.sdfa\",\"timestamp\": 1346846400,\"value\": \"18\",\"tags\": {\"host\": 8932}},]", - }; - for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) { - char *dataPointStart = (char *)sql[i]; - int8_t offset[4] = {0}; - while (1) { - SSmlLineInfo elements = {0}; - if(offset[0] == 0){ - smlJsonParseObjFirst(&dataPointStart, &elements, offset); - }else{ - smlJsonParseObj(&dataPointStart, &elements, offset); - } - if(*dataPointStart == '\0') break; - - SArray *tags = smlJsonParseTags(elements.tags, elements.tags + elements.tagsLen); - size_t num = taosArrayGetSize(tags); - ASSERT_EQ(num, 1); - - taosArrayDestroy(tags); - } - } - smlDestroyInfo(info); -} +//TEST(testCase, smlParseTelnetLine_diff_json_type2_Test) { +// SSmlHandle *info = smlBuildSmlInfo(NULL); +// info->protocol = TSDB_SML_JSON_PROTOCOL; +// ASSERT_NE(info, nullptr); +// +// const char *sql[] = { +// "[{\"metric\":\"sys.cpu.nice\",\"timestamp\": 1346846400,\"value\": 18,\"tags\": {\"host\": \"lga\"}},{\"metric\": \"sys.sdfa\",\"timestamp\": 1346846400,\"value\": \"18\",\"tags\": {\"host\": 8932}},]", +// }; +// for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) { +// char *dataPointStart = (char *)sql[i]; +// int8_t offset[4] = {0}; +// while (1) { +// SSmlLineInfo elements = {0}; +// if(offset[0] == 0){ +// smlJsonParseObjFirst(&dataPointStart, &elements, offset); +// }else{ +// smlJsonParseObj(&dataPointStart, &elements, offset); +// } +// if(*dataPointStart == '\0') break; +// +// SArray *tags = smlJsonParseTags(elements.tags, elements.tags + elements.tagsLen); +// size_t num = taosArrayGetSize(tags); +// ASSERT_EQ(num, 1); +// +// taosArrayDestroy(tags); +// } +// } +// smlDestroyInfo(info); +//} TEST(testCase, smlParseNumber_performance_Test) { char msg[256] = {0}; diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 4373f309ca39e1f3f42908db1cfc3a1b11c41c08..3dfa32ccc54f324ccb6d88499046592ef97411ac 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1879,7 +1879,7 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) { char pBuf[128] = {0}; int32_t sz = taosArrayGetSize(dataBlocks); for (int32_t i = 0; i < sz; i++) { - SSDataBlock* pDataBlock = taosArrayGetP(dataBlocks, i); + SSDataBlock* pDataBlock = taosArrayGet(dataBlocks, i); size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock); int32_t rows = pDataBlock->info.rows; @@ -1891,21 +1891,37 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) { for (int32_t k = 0; k < numOfCols; k++) { SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k); void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes); + if (k == 0) { + printf("cols:%d |", (int32_t)numOfCols); + } if (colDataIsNull(pColInfoData, rows, j, NULL)) { printf(" %15s |", "NULL"); continue; } + switch (pColInfoData->info.type) { case TSDB_DATA_TYPE_TIMESTAMP: formatTimestamp(pBuf, *(uint64_t*)var, TSDB_TIME_PRECISION_MILLI); printf(" %25s |", pBuf); break; case TSDB_DATA_TYPE_BOOL: - printf(" %15d |", *(int32_t*)var); + printf(" %15" PRIi8 " |", *(int8_t*)var); + break; + case TSDB_DATA_TYPE_TINYINT: + printf(" %15" PRIi8 " |", *(int8_t*)var); + break; + case TSDB_DATA_TYPE_SMALLINT: + printf(" %15" PRIi16 " |", *(int16_t*)var); break; case TSDB_DATA_TYPE_INT: printf(" %15d |", *(int32_t*)var); break; + case TSDB_DATA_TYPE_UTINYINT: + printf(" %15" PRIu8 " |", *(uint8_t*)var); + break; + case TSDB_DATA_TYPE_USMALLINT: + printf(" %15" PRIu16 " |", *(uint16_t*)var); + break; case TSDB_DATA_TYPE_UINT: printf(" %15u |", *(uint32_t*)var); break; diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 98b9b566ecc0c0f8d8ea2fdb8866efc5e1c22769..deefa65595ef50c9b136e70265acf02e96fd8b1e 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -715,6 +715,8 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsNumOfSnodeWriteThreads = cfgGetItem(pCfg, "numOfSnodeUniqueThreads")->i32; tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64; + tsSIMDBuiltins = (bool) cfgGetItem(pCfg, "SIMD-builtins")->bval; + tsEnableMonitor = cfgGetItem(pCfg, "monitor")->bval; tsMonitorInterval = cfgGetItem(pCfg, "monitorInterval")->i32; tstrncpy(tsMonitorFqdn, cfgGetItem(pCfg, "monitorFqdn")->str, TSDB_FQDN_LEN); diff --git a/source/common/src/ttypes.c b/source/common/src/ttypes.c index 7b5d0a8805ed77ac580d5c4c2f02d699338012f7..d412fd89da36730f2fda350340d6499110f5720d 100644 --- a/source/common/src/ttypes.c +++ b/source/common/src/ttypes.c @@ -131,7 +131,10 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) { varDataCopy(val, src); break; default: { - memcpy(val, src, len); + if (len > 0) { + memcpy(val, src, len); + } + break; } } diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index a432201413c93d3df9a1898289bb326b51affd38..d308d3e618f132eecc82e482f7c4fe120c013bf4 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 c5ddb9f021c65a2ac7f616a9236bced7954a2aa0..f736ffd0c8ec4f4a4517f50080ecdac7f06c922d 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 9bd5be520196caea28c13aa9c860c05d28ac7248..e8402eb7c02ff8be9cd5d83b838aa46f6f4f4779 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 a49e855e39ec1f635e48dd9c47b9a4f942864655..dc32054fd7ea2510b5f1e51843511a2a656195dc 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmFile.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmFile.c @@ -16,7 +16,7 @@ #define _DEFAULT_SOURCE #include "vmInt.h" -#define MAX_CONTENT_LEN 1024 * 1024 +#define MAX_CONTENT_LEN 2 * 1024 * 1024 SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) { taosThreadRwlockRdlock(&pMgmt->lock); @@ -60,7 +60,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t pFile = taosOpenFile(file, TD_FILE_READ); if (pFile == NULL) { - dDebug("file %s not exist", file); + dInfo("file %s not exist", file); code = 0; goto _OVER; } @@ -133,7 +133,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes = vnodesNum; code = 0; - dDebug("succcessed to read file %s, numOfVnodes:%d", file, vnodesNum); + dInfo("succcessed to read file %s, numOfVnodes:%d", file, vnodesNum); _OVER: if (content != NULL) taosMemoryFree(content); @@ -163,6 +163,7 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) { if (ppVnodes == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; code = -1; + dError("failed to write %s while get vnodelist", file); goto _OVER; } @@ -172,6 +173,7 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) { if (content == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; code = -1; + dError("failed to write %s while malloc content", file); goto _OVER; } @@ -213,6 +215,12 @@ _OVER: if (code != 0) return -1; - dDebug("successed to write %s, numOfVnodes:%d", realfile, numOfVnodes); - return taosRenameFile(file, realfile); + dInfo("succeed to write %s, numOfVnodes:%d", realfile, numOfVnodes); + code = taosRenameFile(file, realfile); + + if (code != 0) { + dError("failed to rename %s to %s", file, realfile); + } + + return code; } \ No newline at end of file diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index bc4677285808e3d8fd76d9f8d65da7e3ab7249f6..3ce37a5f8e817ec9121503088b1292d3eb0299e8 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -132,10 +132,12 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { pCfg->syncCfg.myIndex = pCreate->selfIndex; pCfg->syncCfg.replicaNum = pCreate->replica; memset(&pCfg->syncCfg.nodeInfo, 0, sizeof(pCfg->syncCfg.nodeInfo)); - for (int i = 0; i < pCreate->replica; ++i) { + for (int32_t i = 0; i < pCreate->replica; ++i) { SNodeInfo *pNode = &pCfg->syncCfg.nodeInfo[i]; + pNode->nodeId = pCreate->replicas[i].id; pNode->nodePort = pCreate->replicas[i].port; - tstrncpy(pNode->nodeFqdn, pCreate->replicas[i].fqdn, sizeof(pNode->nodeFqdn)); + tstrncpy(pNode->nodeFqdn, pCreate->replicas[i].fqdn, TSDB_FQDN_LEN); + (void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); } } @@ -188,8 +190,8 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { req.walRollPeriod, req.walSegmentSize, req.hashMethod, req.hashBegin, req.hashEnd, req.hashPrefix, req.hashSuffix, req.replica, req.selfIndex, req.strict); for (int32_t i = 0; i < req.replica; ++i) { - dInfo("vgId:%d, replica:%d id:%d fqdn:%s port:%u", req.vgId, i, req.replicas[i].id, req.replicas[i].fqdn, - req.replicas[i].port); + dInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d", req.vgId, i, req.replicas[i].fqdn, req.replicas[i].port, + req.replicas[i].id); } SReplica *pReplica = &req.replicas[req.selfIndex]; @@ -213,7 +215,7 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { SVnodeObj *pVnode = vmAcquireVnode(pMgmt, req.vgId); if (pVnode != NULL) { - dDebug("vgId:%d, already exist", req.vgId); + dInfo("vgId:%d, already exist", req.vgId); tFreeSCreateVnodeReq(&req); vmReleaseVnode(pMgmt, pVnode); terrno = TSDB_CODE_VND_ALREADY_EXIST; @@ -286,7 +288,8 @@ int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { dInfo("vgId:%d, start to alter vnode, replica:%d selfIndex:%d strict:%d", alterReq.vgId, alterReq.replica, alterReq.selfIndex, alterReq.strict); for (int32_t i = 0; i < alterReq.replica; ++i) { - dInfo("vgId:%d, replica:%d ep:%s:%u", alterReq.vgId, i, alterReq.replicas[i].fqdn, alterReq.replicas[i].port); + SReplica *pReplica = &alterReq.replicas[i]; + dInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d", alterReq.vgId, i, pReplica->fqdn, pReplica->port, pReplica->port); } if (alterReq.replica <= 0 || alterReq.selfIndex < 0 || alterReq.selfIndex >= alterReq.replica) { @@ -358,7 +361,7 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { } int32_t vgId = dropReq.vgId; - dDebug("vgId:%d, start to drop vnode", vgId); + dInfo("vgId:%d, start to drop vnode", vgId); if (dropReq.dnodeId != pMgmt->pData->dnodeId) { terrno = TSDB_CODE_INVALID_MSG; @@ -368,7 +371,7 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { SVnodeObj *pVnode = vmAcquireVnode(pMgmt, vgId); if (pVnode == NULL) { - dDebug("vgId:%d, failed to drop since %s", vgId, terrstr()); + dInfo("vgId:%d, failed to drop since %s", vgId, terrstr()); terrno = TSDB_CODE_VND_NOT_EXIST; return -1; } @@ -383,6 +386,7 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { vmCloseVnode(pMgmt, pVnode); vmWriteVnodeListToFile(pMgmt); + dInfo("vgId:%d, is dropped", vgId); return 0; } diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index 313a88fc5c60f3ac2ae84b1ca6cf811033f5779c..f808c67ef66a31f143c0555afade9ff8b31a2163 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -138,7 +138,7 @@ static void *vmOpenVnodeInThread(void *param) { SVnodeMgmt *pMgmt = pThread->pMgmt; char path[TSDB_FILENAME_LEN]; - dDebug("thread:%d, start to open %d vnodes", pThread->threadIndex, pThread->vnodeNum); + dInfo("thread:%d, start to open %d vnodes", pThread->threadIndex, pThread->vnodeNum); setThreadName("open-vnodes"); for (int32_t v = 0; v < pThread->vnodeNum; ++v) { @@ -156,14 +156,14 @@ static void *vmOpenVnodeInThread(void *param) { pThread->failed++; } else { vmOpenVnode(pMgmt, pCfg, pImpl); - dDebug("vgId:%d, is opened by thread:%d", pCfg->vgId, pThread->threadIndex); + dInfo("vgId:%d, is opened by thread:%d", pCfg->vgId, pThread->threadIndex); pThread->opened++; atomic_add_fetch_32(&pMgmt->state.openVnodes, 1); } } - dDebug("thread:%d, numOfVnodes:%d, opened:%d failed:%d", pThread->threadIndex, pThread->vnodeNum, pThread->opened, - pThread->failed); + dInfo("thread:%d, numOfVnodes:%d, opened:%d failed:%d", pThread->threadIndex, pThread->vnodeNum, pThread->opened, + pThread->failed); return NULL; } @@ -496,7 +496,7 @@ static void *vmRestoreVnodeInThread(void *param) { dError("vgId:%d, failed to restore vnode by thread:%d", pVnode->vgId, pThread->threadIndex); pThread->failed++; } else { - dDebug("vgId:%d, is restored by thread:%d", pVnode->vgId, pThread->threadIndex); + dInfo("vgId:%d, is restored by thread:%d", pVnode->vgId, pThread->threadIndex); pThread->opened++; atomic_add_fetch_32(&pMgmt->state.openVnodes, 1); } diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index 202dc50ac6de75c550e651d2ad3e599b0900eedf..642ca1ebc1880632821bb453fec511f7bfda6755 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c @@ -86,12 +86,8 @@ static void vmProcessStreamQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, pMsg, pInfo); if (code != 0) { if (terrno != 0) code = terrno; - if (pMsg) { - dGError("vgId:%d, msg:%p failed to process stream msg %s since %s", pVnode->vgId, pMsg, TMSG_INFO(pMsg->msgType), - terrstr(code)); - } else { - dGError("vgId:%d, msg:%p failed to process stream empty msg since %s", pVnode->vgId, pMsg, terrstr(code)); - } + dGError("vgId:%d, msg:%p failed to process stream msg %s since %s", pVnode->vgId, pMsg, TMSG_INFO(pMsg->msgType), + terrstr(code)); vmSendRsp(pMsg, code); } @@ -146,16 +142,16 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp return -1; } - SMsgHead *pHead = pMsg->pCont; - int32_t code = 0; + SMsgHead *pHead = pMsg->pCont; + int32_t code = 0; pHead->contLen = ntohl(pHead->contLen); pHead->vgId = ntohl(pHead->vgId); SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pHead->vgId); if (pVnode == NULL) { - dGError("vgId:%d, msg:%p failed to put into vnode queue since %s, type:%s qtype:%d contLen:%d", pHead->vgId, pMsg, terrstr(), - TMSG_INFO(pMsg->msgType), qtype, pHead->contLen); + dGError("vgId:%d, msg:%p failed to put into vnode queue since %s, type:%s qtype:%d contLen:%d", pHead->vgId, pMsg, + terrstr(), TMSG_INFO(pMsg->msgType), qtype, pHead->contLen); return terrno != 0 ? terrno : -1; } diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index 0ff41d429edf5fb1afd37d643f38462dd67128ce..dcb63f65246cfc103790c2e46b2ca4c8bd4beafe 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 2124b387ec926a3add0c5efe3a51f43bdf9ae47c..92b66230e3ee8714c014777a39288cb2f2b28df3 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 2ced9a350d8d95f1d30371317b30795fdcdec4c1..a7a63fbacadf472f3b8c5dd318e47021d27f3791 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 d387fe4a3f52400e3dcb5521d4c7a94c8802d607..2eb1462efcc5aa490a9c0e7e51f0ef9eaae54b87 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 50ebb2a7dc9ea1a42913c514358b2c00f9ad9102..c44c2f948bc5c7d32ff7fb901fe7f7f62f214b27 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) @@ -367,6 +366,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 b5c2fb05b3adb3f3e7d0c3ce19f3da055fabdb3c..a5f77513de9f6de359acf129612136af1762fa68 100644 --- a/source/dnode/mnode/impl/src/mndDef.c +++ b/source/dnode/mnode/impl/src/mndDef.c @@ -489,7 +489,7 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) { tlen += tEncodeSMqConsumerEp(buf, pConsumerEp); cnt++; } - ASSERT(cnt == sz); + if(cnt != sz) return -1; tlen += taosEncodeArray(buf, pSub->unassignedVgs, (FEncode)tEncodeSMqVgEp); tlen += taosEncodeString(buf, pSub->dbName); return tlen; diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index b9448797eafd6570dcdcbaf04fe15379ae8f2bec..c8c8e06c5ed5a3b041161cf7b3d573053f1a93ec 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 6a7e2aaa51b2f7603c186ac75529e231561f442a..7a8de4099f0a11f313552a6f2629c797fda06f39 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 2d1f6eb5054c978195a2cb40341bef268e3f0fd1..141bb1df601fe7d1e3c27090170e37d6769d879f 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 54b3202d246adde7d2bd053d8969554fcb7d0bce..d504a94700096162d636390ee6eb5e2d2f77f139 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 418474baa6c9759a2c4fb604e07e99af272539ae..b8ef185199c5b93c57ab4d2e68d30bb12c797373 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 54d8aa7f609faae5dcc4e0789a03d1fca89d0446..93c9192bed7c498221b28d6258608d0b1e4ca1af 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 1d3209691adae6c917f430a2e6eb716951aefedf..b0b49b42dce114ffdf223f16eaad59abd822d700 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 7f5ebd4a9042a69def1952190b6456e03e7d44e8..ce04c723442c65b1ff721f626d8170ffce63e170 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -384,7 +384,11 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq * topicObj.subType = pCreate->subType; topicObj.withMeta = pCreate->withMeta; if (topicObj.withMeta) { - ASSERT(topicObj.subType != TOPIC_SUB_TYPE__COLUMN); + if (topicObj.subType == TOPIC_SUB_TYPE__COLUMN) { + terrno = TSDB_CODE_MND_INVALID_TOPIC_OPTION; + mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); + return -1; + } } if (pCreate->subType == TOPIC_SUB_TYPE__COLUMN) { @@ -499,7 +503,6 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq * if (code < 0) { sdbRelease(pSdb, pVgroup); mndTransDrop(pTrans); - ASSERT(0); return -1; } void *buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len); @@ -718,7 +721,6 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) { // TODO check if rebalancing if (mndDropSubByTopic(pMnode, pTrans, dropReq.name) < 0) { - /*ASSERT(0);*/ mError("topic:%s, failed to drop since %s", pTopic->name, terrstr()); mndTransDrop(pTrans); mndReleaseTopic(pMnode, pTopic); diff --git a/source/dnode/vnode/src/inc/tq.h b/source/dnode/vnode/src/inc/tq.h index 9a89c732bd4bb0fa595360fc72ac71a7f2fd156e..104e0945ba978815e38f17ecf107ff73c2f2905a 100644 --- a/source/dnode/vnode/src/inc/tq.h +++ b/source/dnode/vnode/src/inc/tq.h @@ -182,9 +182,9 @@ int32_t tqOffsetDelete(STqOffsetStore* pStore, const char* subscribeKey) int32_t tqOffsetCommitFile(STqOffsetStore* pStore); // tqSink -// void tqSinkToTableMerge(SStreamTask* pTask, void* vnode, int64_t ver, void* data); -// void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* data); -void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void* data); +int32_t tqBuildDeleteReq(SVnode* pVnode, const char* stbFullName, const SSDataBlock* pDataBlock, + SBatchDeleteReq* deleteReq); +void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void* data); // tqOffset char* tqOffsetBuildFName(const char* path, int32_t fVer); diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 905bf6c411fd2758116a5fea94d8b898647dd3cc..7eea4a8d1da2dbb29956b30453b8bc944df85f93 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -788,8 +788,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/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 1cea8d7cb588dd16e3f8e6b9c688698f48003a4f..a06b0c76b2556326392c47f74ba38ad7f1983b5b 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -203,10 +203,6 @@ int32_t tqProcessTaskRecoverFinishReq(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskRecoverFinishRsp(STQ* pTq, SRpcMsg* pMsg); int32_t tqCheckLogInWal(STQ* pTq, int64_t version); -int32_t tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pSchema, - SSchemaWrapper* pTagSchemaWrapper, bool createTb, int64_t suid, const char* stbFullName, - SBatchDeleteReq* pDeleteReq, void** ppData, int32_t* pLen); - // sma int32_t smaInit(); void smaCleanUp(); diff --git a/source/dnode/vnode/src/meta/metaSnapshot.c b/source/dnode/vnode/src/meta/metaSnapshot.c index 4dcb7f4ec0842d8d45bc15e29e4755f88d05129a..6e505dfde512e53607e7410dbf5f31c61f5ffdd6 100644 --- a/source/dnode/vnode/src/meta/metaSnapshot.c +++ b/source/dnode/vnode/src/meta/metaSnapshot.c @@ -192,7 +192,8 @@ int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) SDecoder* pDecoder = &(SDecoder){0}; tDecoderInit(pDecoder, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr)); - metaDecodeEntry(pDecoder, &metaEntry); + code = metaDecodeEntry(pDecoder, &metaEntry); + if (code) goto _err; code = metaHandleEntry(pMeta, &metaEntry); if (code) goto _err; @@ -201,6 +202,7 @@ int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) return code; _err: + tDecoderClear(pDecoder); metaError("vgId:%d, vnode snapshot meta write failed since %s", TD_VID(pMeta->pVnode), tstrerror(code)); return code; } diff --git a/source/dnode/vnode/src/sma/smaCommit.c b/source/dnode/vnode/src/sma/smaCommit.c index 8b43de7421a6329273ede2eefb0a047d94ba5c98..0aa20e9e1d0a69a776d5c73412c4d99d3177bb5b 100644 --- a/source/dnode/vnode/src/sma/smaCommit.c +++ b/source/dnode/vnode/src/sma/smaCommit.c @@ -116,68 +116,6 @@ _exit: return code; } -// SQTaskFile ====================================================== - -/** - * @brief At most time, there is only one qtaskinfo file committed latest in aTaskFile. Sometimes, there would be - * multiple qtaskinfo files supporting snapshot replication. - * - * @param pSma - * @param pStat - * @return int32_t - */ -static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pStat) { -#if 0 - SVnode *pVnode = pSma->pVnode; - SRSmaFS *pFS = RSMA_FS(pStat); - int64_t committed = pStat->commitAppliedVer; - int64_t fsMaxVer = -1; - char qTaskInfoFullName[TSDB_FILENAME_LEN]; - - taosWLockLatch(RSMA_FS_LOCK(pStat)); - - for (int32_t i = 0; i < taosArrayGetSize(pFS->aQTaskInf);) { - SQTaskFile *pTaskF = taosArrayGet(pFS->aQTaskInf, i); - int32_t oldVal = atomic_fetch_sub_32(&pTaskF->nRef, 1); - if ((oldVal <= 1) && (pTaskF->version < committed)) { - tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), pTaskF->version, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName); - if (taosRemoveFile(qTaskInfoFullName) < 0) { - smaWarn("vgId:%d, cleanup qinf, committed %" PRIi64 ", failed to remove %s since %s", TD_VID(pVnode), committed, - qTaskInfoFullName, tstrerror(TAOS_SYSTEM_ERROR(errno))); - } else { - smaDebug("vgId:%d, cleanup qinf, committed %" PRIi64 ", success to remove %s", TD_VID(pVnode), committed, - qTaskInfoFullName); - } - taosArrayRemove(pFS->aQTaskInf, i); - continue; - } - ++i; - } - - if (taosArrayGetSize(pFS->aQTaskInf) > 0) { - fsMaxVer = ((SQTaskFile *)taosArrayGetLast(pFS->aQTaskInf))->version; - } - - if (fsMaxVer < committed) { - tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), committed, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName); - if (taosCheckExistFile(qTaskInfoFullName)) { - SQTaskFile qFile = {.nRef = 1, .padding = 0, .version = committed, .size = 0}; - if (!taosArrayPush(pFS->aQTaskInf, &qFile)) { - taosWUnLockLatch(RSMA_FS_LOCK(pStat)); - terrno = TSDB_CODE_OUT_OF_MEMORY; - return TSDB_CODE_FAILED; - } - } - } else { - smaDebug("vgId:%d, update qinf, no need as committed %" PRIi64 " not larger than fsMaxVer %" PRIi64, TD_VID(pVnode), - committed, fsMaxVer); - } - - taosWUnLockLatch(RSMA_FS_LOCK(pStat)); -#endif - return TSDB_CODE_SUCCESS; -} - /** * @brief Rsma async commit implementation(only do some necessary light weighted task) * 1) set rsma stat TASK_TRIGGER_STAT_PAUSED @@ -187,7 +125,8 @@ static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pStat) { * @return int32_t */ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) { - int32_t code = 0; + int32_t code = 0; + int32_t lino = 0; SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); if (!pEnv) { @@ -208,7 +147,11 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) { } } pRSmaStat->commitAppliedVer = pSma->pVnode->state.applied; - // ASSERT(pRSmaStat->commitAppliedVer > 0); + if (ASSERTS(pRSmaStat->commitAppliedVer >= 0, "commit applied version %" PRIi64 " < 0", + pRSmaStat->commitAppliedVer)) { + code = TSDB_CODE_APP_ERROR; + TSDB_CHECK_CODE(code, lino, _exit); + } // step 2: wait for all triggered fetch tasks to finish nLoops = 0; @@ -242,9 +185,9 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) { } } smaInfo("vgId:%d, rsma commit, all items are consumed, TID:%p", SMA_VID(pSma), (void *)taosGetSelfPthreadId()); - if ((code = tdRSmaPersistExecImpl(pRSmaStat, RSMA_INFO_HASH(pRSmaStat))) != 0) { - return code; - } + code = tdRSmaPersistExecImpl(pRSmaStat, RSMA_INFO_HASH(pRSmaStat)); + TSDB_CHECK_CODE(code, lino, _exit); + smaInfo("vgId:%d, rsma commit, operator state committed, TID:%p", SMA_VID(pSma), (void *)taosGetSelfPthreadId()); #if 0 // consuming task of qTaskInfo clone @@ -252,8 +195,6 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) { // lock taosWLockLatch(SMA_ENV_LOCK(pEnv)); - ASSERT(RSMA_INFO_HASH(pRSmaStat)); - void *pIter = taosHashIterate(RSMA_INFO_HASH(pRSmaStat), NULL); while (pIter) { @@ -271,9 +212,19 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) { // all rsma results are written completely STsdb *pTsdb = NULL; - if ((pTsdb = VND_RSMA1(pSma->pVnode))) tsdbPrepareCommit(pTsdb); - if ((pTsdb = VND_RSMA2(pSma->pVnode))) tsdbPrepareCommit(pTsdb); + if ((pTsdb = VND_RSMA1(pSma->pVnode))) { + code = tsdbPrepareCommit(pTsdb); + TSDB_CHECK_CODE(code, lino, _exit); + } + if ((pTsdb = VND_RSMA2(pSma->pVnode))) { + code = tsdbPrepareCommit(pTsdb); + TSDB_CHECK_CODE(code, lino, _exit); + } +_exit: + if (code) { + smaError("vgId:%d, %s failed at line %d since %s", SMA_VID(pSma), __func__, lino, tstrerror(code)); + } return code; } @@ -360,8 +311,6 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) { taosWUnLockLatch(SMA_ENV_LOCK(pEnv)); } - tdUpdateQTaskInfoFiles(pSma, pRSmaStat); - atomic_store_8(RSMA_COMMIT_STAT(pRSmaStat), 0); return TSDB_CODE_SUCCESS; diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index e613b5833fa76dbfe2adc03e0a57d32261ec6156..a980b653a9c9d7e2e3f71c2502464e0fe68ff986 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -131,7 +131,7 @@ static int32_t tdNewSmaEnv(SSma *pSma, int8_t smaType, SSmaEnv **ppEnv) { (smaType == TSDB_SMA_TYPE_TIME_RANGE) ? atomic_store_ptr(&SMA_TSMA_ENV(pSma), *ppEnv) : atomic_store_ptr(&SMA_RSMA_ENV(pSma), *ppEnv); - if (tdInitSmaStat(&SMA_ENV_STAT(pEnv), smaType, pSma) != TSDB_CODE_SUCCESS) { + if ((terrno = tdInitSmaStat(&SMA_ENV_STAT(pEnv), smaType, pSma)) != TSDB_CODE_SUCCESS) { tdFreeSmaEnv(pEnv); *ppEnv = NULL; (smaType == TSDB_SMA_TYPE_TIME_RANGE) ? atomic_store_ptr(&SMA_TSMA_ENV(pSma), NULL) @@ -193,10 +193,16 @@ static void tRSmaInfoHashFreeNode(void *data) { } static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pSma) { - ASSERT(pSmaStat != NULL); + int32_t code = 0; + int32_t lino = 0; + + if (ASSERTS(pSmaStat != NULL, "pSmaStat is NULL")) { + terrno = TSDB_CODE_RSMA_INVALID_ENV; + TSDB_CHECK_CODE(code, lino, _exit); + } if (*pSmaStat) { // no lock - return TSDB_CODE_SUCCESS; + return code; // success, return directly } /** @@ -207,8 +213,8 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS if (!(*pSmaStat)) { *pSmaStat = (SSmaStat *)taosMemoryCalloc(1, sizeof(SSmaStat) + sizeof(TdThread) * tsNumOfVnodeRsmaThreads); if (!(*pSmaStat)) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return TSDB_CODE_FAILED; + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); } if (smaType == TSDB_SMA_TYPE_ROLLUP) { @@ -224,7 +230,8 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS if (refId < 0) { smaError("vgId:%d, taosAddRef refId:%" PRIi64 " to rsetId rsetId:%d max:%d failed since:%s", SMA_VID(pSma), refId, smaMgmt.rsetId, SMA_MGMT_REF_NUM, tstrerror(terrno)); - return TSDB_CODE_FAILED; + code = terrno; + TSDB_CHECK_CODE(code, lino, _exit); } else { smaDebug("vgId:%d, taosAddRef refId:%" PRIi64 " to rsetId rsetId:%d max:%d succeed", SMA_VID(pSma), refId, smaMgmt.rsetId, SMA_MGMT_REF_NUM); @@ -235,22 +242,30 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS RSMA_INFO_HASH(pRSmaStat) = taosHashInit( RSMA_TASK_INFO_HASH_SLOT, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK); if (!RSMA_INFO_HASH(pRSmaStat)) { - return TSDB_CODE_FAILED; + code = terrno; + TSDB_CHECK_CODE(code, lino, _exit); } taosHashSetFreeFp(RSMA_INFO_HASH(pRSmaStat), tRSmaInfoHashFreeNode); if (tdRsmaStartExecutor(pSma) < 0) { - return TSDB_CODE_FAILED; + code = terrno; + TSDB_CHECK_CODE(code, lino, _exit); } taosInitRWLatch(RSMA_FS_LOCK(pRSmaStat)); } else if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { // TODO } else { - ASSERT(0); + ASSERTS(0, "unknown smaType:%" PRIi8, smaType); + code = TSDB_CODE_APP_ERROR; + TSDB_CHECK_CODE(code, lino, _exit); } } - return TSDB_CODE_SUCCESS; +_exit: + if (code) { + smaError("vgId:%d, %s failed at line %d since %s", SMA_VID(pSma), __func__, lino, tstrerror(code)); + } + return code; } static void tdDestroyTSmaStat(STSmaStat *pStat) { @@ -339,7 +354,10 @@ static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) { smaDebug("vgId:%d, remove refId:%" PRIi64 " from rsmaRef:%" PRIi32 " succeed", vid, refId, smaMgmt.rsetId); } } else { - ASSERT(0); + ASSERTS(0, "unknown smaType:%" PRIi8, smaType); + terrno = TSDB_CODE_APP_ERROR; + smaError("%s failed at line %d since %s", __func__, __LINE__, terrstr()); + return -1; } } return 0; @@ -348,7 +366,7 @@ static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) { int32_t tdLockSma(SSma *pSma) { int code = taosThreadMutexLock(&pSma->mutex); if (code != 0) { - smaError("vgId:%d, failed to lock td since %s", SMA_VID(pSma), strerror(errno)); + smaError("vgId:%d, failed to lock since %s", SMA_VID(pSma), strerror(errno)); terrno = TAOS_SYSTEM_ERROR(code); return -1; } @@ -357,12 +375,17 @@ int32_t tdLockSma(SSma *pSma) { } int32_t tdUnLockSma(SSma *pSma) { - ASSERT(SMA_LOCKED(pSma)); + if (ASSERTS(SMA_LOCKED(pSma), "pSma %p is not locked:%d", pSma, pSma->locked)) { + terrno = TSDB_CODE_APP_ERROR; + smaError("vgId:%d, failed to unlock since %s", SMA_VID(pSma), tstrerror(terrno)); + return -1; + } + pSma->locked = false; int code = taosThreadMutexUnlock(&pSma->mutex); if (code != 0) { - smaError("vgId:%d, failed to unlock td since %s", SMA_VID(pSma), strerror(errno)); terrno = TAOS_SYSTEM_ERROR(code); + smaError("vgId:%d, failed to unlock since %s", SMA_VID(pSma), strerror(errno)); return -1; } return 0; diff --git a/source/dnode/vnode/src/sma/smaFS.c b/source/dnode/vnode/src/sma/smaFS.c index b7c2538b416ac59e7173c7ad7e8b0df9c59f9234..ef872d055e5eec598af61bb9f410f6361b01c024 100644 --- a/source/dnode/vnode/src/sma/smaFS.c +++ b/source/dnode/vnode/src/sma/smaFS.c @@ -77,7 +77,7 @@ static int32_t tsdbBinaryToFS(uint8_t *pData, int64_t nData, SRSmaFS *pFS) { int32_t nt = tdRSmaGetQTaskF(pData + n, &qTaskF); if (nt < 0) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_FILE_CORRUPTED; goto _exit; } @@ -88,7 +88,11 @@ static int32_t tsdbBinaryToFS(uint8_t *pData, int64_t nData, SRSmaFS *pFS) { } } - ASSERT(n + sizeof(TSCKSUM) == nData); + if (ASSERTS(n + sizeof(TSCKSUM) == nData, "n:%d + sizeof(TSCKSUM):%d != nData:%d", n, (int32_t)sizeof(TSCKSUM), + nData)) { + code = TSDB_CODE_FILE_CORRUPTED; + goto _exit; + } _exit: return code; @@ -545,87 +549,6 @@ int32_t tdRSmaFSUpsertQTaskFile(SSma *pSma, SRSmaFS *pFS, SQTaskFile *qTaskFile, _exit: return code; } -#if 0 -int32_t tdRSmaFSRef(SSma *pSma, SRSmaStat *pStat, int64_t suid, int8_t level, int64_t version) { - SArray *aQTaskInf = RSMA_FS(pStat)->aQTaskInf; - SQTaskFile qTaskF = {.level = level, .suid = suid, .version = version}; - SQTaskFile *pTaskF = NULL; - int32_t oldVal = 0; - - taosRLockLatch(RSMA_FS_LOCK(pStat)); - if (suid > 0 && level > 0) { - ASSERT(version > 0); - if ((pTaskF = taosArraySearch(aQTaskInf, &qTaskF, tdQTaskInfCmprFn1, TD_EQ))) { - oldVal = atomic_fetch_add_32(&pTaskF->nRef, 1); - ASSERT(oldVal > 0); - } - } else { - // ref all - int32_t size = taosArrayGetSize(aQTaskInf); - for (int32_t i = 0; i < size; ++i) { - pTaskF = TARRAY_GET_ELEM(aQTaskInf, i); - oldVal = atomic_fetch_add_32(&pTaskF->nRef, 1); - ASSERT(oldVal > 0); - } - } - taosRUnLockLatch(RSMA_FS_LOCK(pStat)); - return oldVal; -} - -void tdRSmaFSUnRef(SSma *pSma, SRSmaStat *pStat, int64_t suid, int8_t level, int64_t version) { - SVnode *pVnode = pSma->pVnode; - SArray *aQTaskInf = RSMA_FS(pStat)->aQTaskInf; - char qTaskFullName[TSDB_FILENAME_LEN]; - SQTaskFile qTaskF = {.level = level, .suid = suid, .version = version}; - SQTaskFile *pTaskF = NULL; - int32_t idx = -1; - - taosWLockLatch(RSMA_FS_LOCK(pStat)); - if (suid > 0 && level > 0) { - ASSERT(version > 0); - if ((idx = taosArraySearchIdx(aQTaskInf, &qTaskF, tdQTaskInfCmprFn1, TD_EQ)) >= 0) { - ASSERT(idx < taosArrayGetSize(aQTaskInf)); - pTaskF = taosArrayGet(aQTaskInf, idx); - if (atomic_sub_fetch_32(&pTaskF->nRef, 1) <= 0) { - tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), pTaskF->suid, level, pTaskF->version, - tfsGetPrimaryPath(pVnode->pTfs), qTaskFullName); - if (taosRemoveFile(qTaskFullName) < 0) { - smaWarn("vgId:%d, failed to remove %s since %s", TD_VID(pVnode), qTaskFullName, - tstrerror(TAOS_SYSTEM_ERROR(errno))); - } else { - smaDebug("vgId:%d, success to remove %s", TD_VID(pVnode), qTaskFullName); - } - taosArrayRemove(aQTaskInf, idx); - } - } - } else { - for (int32_t i = 0; i < taosArrayGetSize(aQTaskInf);) { - pTaskF = TARRAY_GET_ELEM(aQTaskInf, i); - int32_t nRef = INT32_MAX; - if (pTaskF->version == version) { - nRef = atomic_sub_fetch_32(&pTaskF->nRef, 1); - } else if (pTaskF->version < version) { - nRef = atomic_load_32(&pTaskF->nRef); - } - if (nRef <= 0) { - tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), pTaskF->suid, pTaskF->level, pTaskF->version, - tfsGetPrimaryPath(pVnode->pTfs), qTaskFullName); - if (taosRemoveFile(qTaskFullName) < 0) { - smaWarn("vgId:%d, failed to remove %s since %s", TD_VID(pVnode), qTaskFullName, - tstrerror(TAOS_SYSTEM_ERROR(errno))); - } else { - smaDebug("vgId:%d, success to remove %s", TD_VID(pVnode), qTaskFullName); - } - taosArrayRemove(aQTaskInf, i); - continue; - } - ++i; - } - } - - taosWUnLockLatch(RSMA_FS_LOCK(pStat)); -} -#endif int32_t tdRSmaFSRef(SSma *pSma, SRSmaFS *pFS) { int32_t code = 0; diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c index 3923a5dd5b37c3787ba64543b15071c4b73bba43..ed33e0fd7b2cedfb2cacca97b248bde0491bf799 100644 --- a/source/dnode/vnode/src/sma/smaOpen.c +++ b/source/dnode/vnode/src/sma/smaOpen.c @@ -34,13 +34,16 @@ static int32_t rsmaRestore(SSma *pSma); SRetention *r = (SRetention *)VND_RETENTIONS(v) + l; \ if (!RETENTION_VALID(r)) { \ if (l == 0) { \ - goto _err; \ + code = TSDB_CODE_INVALID_PARA; \ + TSDB_CHECK_CODE(code, lino, _exit); \ } \ break; \ } \ - smaSetKeepCfg(v, &keepCfg, pCfg, TSDB_TYPE_RSMA_L##l); \ + code = smaSetKeepCfg(v, &keepCfg, pCfg, TSDB_TYPE_RSMA_L##l); \ + TSDB_CHECK_CODE(code, lino, _exit); \ if (tsdbOpen(v, &SMA_RSMA_TSDB##l(pSma), VNODE_RSMA##l##_DIR, &keepCfg, rollback) < 0) { \ - goto _err; \ + code = terrno; \ + TSDB_CHECK_CODE(code, lino, _exit); \ } \ } while (0) @@ -68,12 +71,10 @@ static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t p days = keepDuration; } - if (level == TSDB_RETENTION_L0) { - goto end; + if (level < TSDB_RETENTION_L1 || level > TSDB_RETENTION_L2) { + goto _exit; } - ASSERT(level >= TSDB_RETENTION_L1 && level <= TSDB_RETENTION_L2); - freqDuration = convertTimeFromPrecisionToUnit((r + level)->freq, precision, TIME_UNIT_MINUTE); keepDuration = convertTimeFromPrecisionToUnit((r + level)->keep, precision, TIME_UNIT_MINUTE); @@ -91,16 +92,18 @@ static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t p if (days < freqDuration) { days = freqDuration; } -end: +_exit: smaInfo("vgId:%d, evaluated duration for level %d is %d, raw val:%d", TD_VID(pVnode), level + 1, days, duration); return days; } int smaSetKeepCfg(SVnode *pVnode, STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg, int type) { + terrno = 0; pKeepCfg->precision = pCfg->precision; switch (type) { case TSDB_TYPE_TSMA: - ASSERT(0); + ASSERTS(0, "undefined smaType:%d", (int32_t)type); + terrno = TSDB_CODE_APP_ERROR; break; case TSDB_TYPE_RSMA_L0: SMA_SET_KEEP_CFG(pVnode, 0); @@ -112,19 +115,22 @@ int smaSetKeepCfg(SVnode *pVnode, STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg, int ty SMA_SET_KEEP_CFG(pVnode, 2); break; default: - ASSERT(0); + ASSERTS(0, "unknown smaType:%d", (int32_t)type); + terrno = TSDB_CODE_APP_ERROR; break; } - return 0; + return terrno; } int32_t smaOpen(SVnode *pVnode, int8_t rollback) { + int32_t code = 0; + int32_t lino = 0; STsdbCfg *pCfg = &pVnode->config.tsdbCfg; SSma *pSma = taosMemoryCalloc(1, sizeof(SSma)); if (!pSma) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); } pVnode->pSma = pSma; @@ -143,21 +149,24 @@ int32_t smaOpen(SVnode *pVnode, int8_t rollback) { } else if (i == TSDB_RETENTION_L2) { SMA_OPEN_RSMA_IMPL(pVnode, 2); } else { - terrno = TSDB_CODE_APP_ERROR; - smaError("vgId:%d, sma open failed since %s, level:%d", TD_VID(pVnode), terrstr(), i); - goto _err; + code = TSDB_CODE_APP_ERROR; + smaError("vgId:%d, sma open failed since %s, level:%d", TD_VID(pVnode), tstrerror(code), i); + TSDB_CHECK_CODE(code, lino, _exit); } } // restore the rsma if (tdRSmaRestore(pSma, RSMA_RESTORE_REBOOT, pVnode->state.committed, rollback) < 0) { - goto _err; + code = terrno; + TSDB_CHECK_CODE(code, lino, _exit); } } - return 0; -_err: - return -1; +_exit: + if (code) { + smaError("vgId:%d, %s failed at line %d since %s", TD_VID(pVnode), __func__, lino, tstrerror(code)); + } + return code; } int32_t smaClose(SSma *pSma) { diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 4138605a5b35c678a5dbd872683ba056001ee3f4..809e553ab665b9473e833759c7f0b278df62354e 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -129,12 +129,17 @@ void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree) { } static FORCE_INLINE int32_t tdUidStoreInit(STbUidStore **pStore) { - ASSERT(*pStore == NULL); + if (ASSERTS(*pStore == NULL, "*pStore:%p != NULL", *pStore)) { + terrno = TSDB_CODE_APP_ERROR; + return TSDB_CODE_FAILED; + } + *pStore = taosMemoryCalloc(1, sizeof(STbUidStore)); if (*pStore == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_FAILED; } + return TSDB_CODE_SUCCESS; } @@ -163,15 +168,14 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids, for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { if (pRSmaInfo->taskInfo[i]) { - if (((terrno = qUpdateQualifiedTableId(pRSmaInfo->taskInfo[i], tbUids, isAdd)) < 0)) { + if ((terrno = qUpdateQualifiedTableId(pRSmaInfo->taskInfo[i], tbUids, isAdd)) < 0) { tdReleaseRSmaInfo(pSma, pRSmaInfo); smaError("vgId:%d, update tbUidList failed for uid:%" PRIi64 " level %d since %s", SMA_VID(pSma), *suid, i, terrstr()); return TSDB_CODE_FAILED; - } else { - smaDebug("vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%" PRIi64 " uid:%" PRIi64 " level %d", - SMA_VID(pSma), pRSmaInfo->taskInfo[0], *suid, *(int64_t *)taosArrayGet(tbUids, 0), i); } + smaDebug("vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%" PRIi64 " uid:%" PRIi64 " level %d", + SMA_VID(pSma), pRSmaInfo->taskInfo[i], *suid, *(int64_t *)taosArrayGet(tbUids, 0), i); } } @@ -232,8 +236,6 @@ int32_t tdFetchTbUidList(SSma *pSma, STbUidStore **ppStore, tb_uid_t suid, tb_ui return TSDB_CODE_SUCCESS; } - ASSERT(ppStore != NULL); - if (!(*ppStore)) { if (tdUidStoreInit(ppStore) < 0) { return TSDB_CODE_FAILED; @@ -300,12 +302,15 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat } pItem->level = idx == 0 ? TSDB_RETENTION_L1 : TSDB_RETENTION_L2; - ASSERT(pItem->level > 0); + + if (ASSERTS(pItem->level > 0, "pItem level:%" PRIi8 " should > 0", pItem->level)) { + terrno = TSDB_CODE_APP_ERROR; + return TSDB_CODE_FAILED; + } SRSmaRef rsmaRef = {.refId = pStat->refId, .suid = pRSmaInfo->suid}; taosHashPut(smaMgmt.refHash, &pItem, POINTER_BYTES, &rsmaRef, sizeof(rsmaRef)); - pItem->fetchLevel = pItem->level; taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId); smaInfo("vgId:%d, item:%p table:%" PRIi64 " level:%" PRIi8 " maxdelay:%" PRIi64 " watermark:%" PRIi64 @@ -831,50 +836,51 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t msgSize, static int32_t tdCloneQTaskInfo(SSma *pSma, qTaskInfo_t dstTaskInfo, qTaskInfo_t srcTaskInfo, SRSmaParam *param, tb_uid_t suid, int8_t idx) { + int32_t code = 0; + int32_t lino = 0; SVnode *pVnode = pSma->pVnode; char *pOutput = NULL; int32_t len = 0; if (!srcTaskInfo) { - terrno = TSDB_CODE_INVALID_PTR; + code = TSDB_CODE_INVALID_PTR; smaWarn("vgId:%d, rsma clone, table %" PRIi64 ", no need since srcTaskInfo is NULL", TD_VID(pVnode), suid); - return TSDB_CODE_FAILED; + TSDB_CHECK_CODE(code, lino, _exit); } - if ((terrno = qSerializeTaskStatus(srcTaskInfo, &pOutput, &len)) < 0) { - smaError("vgId:%d, rsma clone, table %" PRIi64 " serialize qTaskInfo failed since %s", TD_VID(pVnode), suid, - terrstr()); - goto _err; - } + code = qSerializeTaskStatus(srcTaskInfo, &pOutput, &len); + TSDB_CHECK_CODE(code, lino, _exit); SReadHandle handle = { .meta = pVnode->pMeta, .vnode = pVnode, .initTqReader = 1, }; - ASSERT(!dstTaskInfo); + + if (ASSERTS(!dstTaskInfo, "dstTaskInfo:%p is not NULL", dstTaskInfo)) { + code = TSDB_CODE_APP_ERROR; + TSDB_CHECK_CODE(code, lino, _exit); + } + dstTaskInfo = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle); if (!dstTaskInfo) { - terrno = TSDB_CODE_RSMA_QTASKINFO_CREATE; - goto _err; + code = TSDB_CODE_RSMA_QTASKINFO_CREATE; + TSDB_CHECK_CODE(code, lino, _exit); } - if (qDeserializeTaskStatus(dstTaskInfo, pOutput, len) < 0) { - smaError("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " failed since %s", TD_VID(pVnode), suid, - terrstr()); - goto _err; - } + code = qDeserializeTaskStatus(dstTaskInfo, pOutput, len); + TSDB_CHECK_CODE(code, lino, _exit); smaDebug("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " succeed", TD_VID(pVnode), suid); +_exit: taosMemoryFreeClear(pOutput); - return TSDB_CODE_SUCCESS; -_err: - taosMemoryFreeClear(pOutput); - tdRSmaQTaskInfoFree(dstTaskInfo, TD_VID(pVnode), idx + 1); - smaError("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " failed since %s", TD_VID(pVnode), suid, - terrstr()); - return TSDB_CODE_FAILED; + if (code) { + tdRSmaQTaskInfoFree(dstTaskInfo, TD_VID(pVnode), idx + 1); + smaError("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " failed since %s", TD_VID(pVnode), suid, + terrstr()); + } + return code; } /** @@ -885,43 +891,53 @@ _err: * @return int32_t */ static int32_t tdRSmaInfoClone(SSma *pSma, SRSmaInfo *pInfo) { + int32_t code = 0; + int32_t lino = 0; SRSmaParam *param = NULL; + SMetaReader mr = {0}; + if (!pInfo) { return TSDB_CODE_SUCCESS; } - SMetaReader mr = {0}; metaReaderInit(&mr, SMA_META(pSma), 0); smaDebug("vgId:%d, rsma clone qTaskInfo for suid:%" PRIi64, SMA_VID(pSma), pInfo->suid); if (metaGetTableEntryByUidCache(&mr, pInfo->suid) < 0) { - smaError("vgId:%d, rsma clone, failed to get table meta for %" PRIi64 " since %s", SMA_VID(pSma), pInfo->suid, - terrstr()); - goto _err; + code = terrno; + TSDB_CHECK_CODE(code, lino, _exit); } - ASSERT(mr.me.type == TSDB_SUPER_TABLE); - ASSERT(mr.me.uid == pInfo->suid); + + if (mr.me.type != TSDB_SUPER_TABLE) { + code = TSDB_CODE_RSMA_INVALID_SCHEMA; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (mr.me.uid != pInfo->suid) { + code = TSDB_CODE_RSMA_INVALID_SCHEMA; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (TABLE_IS_ROLLUP(mr.me.flags)) { param = &mr.me.stbEntry.rsmaParam; for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { if (!pInfo->iTaskInfo[i]) { continue; } - if (tdCloneQTaskInfo(pSma, pInfo->taskInfo[i], pInfo->iTaskInfo[i], param, pInfo->suid, i) < 0) { - goto _err; - } + code = tdCloneQTaskInfo(pSma, pInfo->taskInfo[i], pInfo->iTaskInfo[i], param, pInfo->suid, i); + TSDB_CHECK_CODE(code, lino, _exit); } smaDebug("vgId:%d, rsma clone env success for %" PRIi64, SMA_VID(pSma), pInfo->suid); } else { - terrno = TSDB_CODE_RSMA_INVALID_SCHEMA; - goto _err; + code = TSDB_CODE_RSMA_INVALID_SCHEMA; + TSDB_CHECK_CODE(code, lino, _exit); } +_exit: + if (code) { + smaError("vgId:%d, %s failed at line %d since %s, suid:%" PRIi64 ", flags:%" PRIi8 ",type:%" PRIi8 ", uid:%" PRIi64, + SMA_VID(pSma), __func__, lino, tstrerror(code), pInfo->suid, mr.me.flags, mr.me.type, mr.me.uid); + } metaReaderClear(&mr); - return TSDB_CODE_SUCCESS; -_err: - metaReaderClear(&mr); - smaError("vgId:%d, rsma clone env failed for %" PRIi64 " since %s", SMA_VID(pSma), pInfo->suid, terrstr()); - return TSDB_CODE_FAILED; + return code; } /** @@ -932,10 +948,14 @@ _err: * @return SRSmaInfo* */ static SRSmaInfo *tdAcquireRSmaInfoBySuid(SSma *pSma, int64_t suid) { + int32_t code = 0; + int32_t lino = 0; SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); SRSmaStat *pStat = NULL; SRSmaInfo *pRSmaInfo = NULL; + terrno = 0; + if (!pEnv) { terrno = TSDB_CODE_RSMA_INVALID_ENV; return NULL; @@ -955,14 +975,17 @@ static SRSmaInfo *tdAcquireRSmaInfoBySuid(SSma *pSma, int64_t suid) { return NULL; } if (!pRSmaInfo->taskInfo[0]) { - if (tdRSmaInfoClone(pSma, pRSmaInfo) < 0) { + if ((terrno = tdRSmaInfoClone(pSma, pRSmaInfo)) < 0) { taosRUnLockLatch(SMA_ENV_LOCK(pEnv)); return NULL; } } tdRefRSmaInfo(pSma, pRSmaInfo); taosRUnLockLatch(SMA_ENV_LOCK(pEnv)); - ASSERT(pRSmaInfo->suid == suid); + if (ASSERTS(pRSmaInfo->suid == suid, "suid:%" PRIi64 " != %" PRIi64, pRSmaInfo->suid, suid)) { + terrno = TSDB_CODE_APP_ERROR; + return NULL; + } return pRSmaInfo; } taosRUnLockLatch(SMA_ENV_LOCK(pEnv)); @@ -1010,7 +1033,11 @@ static int32_t tdExecuteRSmaAsync(SSma *pSma, int64_t version, const void *pMsg, } } } else { - ASSERT(0); + terrno = TSDB_CODE_APP_ERROR; + tdReleaseRSmaInfo(pSma, pRSmaInfo); + smaError("vgId:%d, execute rsma, failed for suid:%" PRIu64 " since %s, type:%d", SMA_VID(pSma), suid, + tstrerror(terrno), inputType); + return TSDB_CODE_FAILED; } tdReleaseRSmaInfo(pSma, pRSmaInfo); @@ -1063,19 +1090,22 @@ _err: * @return int32_t */ static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables) { + int32_t code = 0; + int32_t lino = 0; SVnode *pVnode = pSma->pVnode; SArray *suidList = NULL; STbUidStore uidStore = {0}; SMetaReader mr = {0}; + tb_uid_t suid = 0; if (!(suidList = taosArrayInit(1, sizeof(tb_uid_t)))) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - goto _err; + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); } if (vnodeGetStbIdList(pSma->pVnode, 0, suidList) < 0) { - smaError("vgId:%d, failed to restore rsma env since get stb id list error: %s", TD_VID(pVnode), terrstr()); - goto _err; + code = terrno; + TSDB_CHECK_CODE(code, lino, _exit); } int64_t arrSize = taosArrayGetSize(suidList); @@ -1092,19 +1122,26 @@ static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables) { int64_t nRsmaTables = 0; metaReaderInit(&mr, SMA_META(pSma), 0); if (!(uidStore.tbUids = taosArrayInit(1024, sizeof(tb_uid_t)))) { - goto _err; + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); } + for (int64_t i = 0; i < arrSize; ++i) { - tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i); + suid = *(tb_uid_t *)taosArrayGet(suidList, i); smaDebug("vgId:%d, rsma restore, suid is %" PRIi64, TD_VID(pVnode), suid); if (metaGetTableEntryByUidCache(&mr, suid) < 0) { - smaError("vgId:%d, rsma restore, failed to get table meta for %" PRIi64 " since %s", TD_VID(pVnode), suid, - terrstr()); - goto _err; + code = terrno; + TSDB_CHECK_CODE(code, lino, _exit); } tDecoderClear(&mr.coder); - ASSERT(mr.me.type == TSDB_SUPER_TABLE); - ASSERT(mr.me.uid == suid); + if (mr.me.type != TSDB_SUPER_TABLE) { + code = TSDB_CODE_RSMA_INVALID_SCHEMA; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (mr.me.uid != suid) { + code = TSDB_CODE_RSMA_INVALID_SCHEMA; + TSDB_CHECK_CODE(code, lino, _exit); + } if (TABLE_IS_ROLLUP(mr.me.flags)) { ++nRsmaTables; SRSmaParam *param = &mr.me.stbEntry.rsmaParam; @@ -1114,22 +1151,20 @@ static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables) { TD_VID(pVnode), suid, i, param->maxdelay[i], param->watermark[i], param->qmsgLen[i]); } if (tdRSmaProcessCreateImpl(pSma, &mr.me.stbEntry.rsmaParam, suid, mr.me.name) < 0) { - smaError("vgId:%d, rsma restore env failed for %" PRIi64 " since %s", TD_VID(pVnode), suid, terrstr()); - goto _err; + code = terrno; + TSDB_CHECK_CODE(code, lino, _exit); } // reload all ctbUids for suid uidStore.suid = suid; if (vnodeGetCtbIdList(pVnode, suid, uidStore.tbUids) < 0) { - smaError("vgId:%d, rsma restore, get ctb idlist failed for %" PRIi64 " since %s", TD_VID(pVnode), suid, - terrstr()); - goto _err; + code = terrno; + TSDB_CHECK_CODE(code, lino, _exit); } if (tdUpdateTbUidList(pVnode->pSma, &uidStore, true) < 0) { - smaError("vgId:%d, rsma restore, update tb uid list failed for %" PRIi64 " since %s", TD_VID(pVnode), suid, - terrstr()); - goto _err; + code = terrno; + TSDB_CHECK_CODE(code, lino, _exit); } taosArrayClear(uidStore.tbUids); @@ -1138,21 +1173,18 @@ static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables) { } } - metaReaderClear(&mr); - taosArrayDestroy(suidList); - tdUidStoreDestory(&uidStore); - if (nTables) { *nTables = nRsmaTables; } - - return TSDB_CODE_SUCCESS; -_err: +_exit: + if (code) { + smaError("vgId:%d, %s failed at line %d since %s, suid:%" PRIi64 ", type:%" PRIi8 ", uid:%" PRIi64, TD_VID(pVnode), + __func__, lino, tstrerror(code), suid, mr.me.type, mr.me.uid); + } metaReaderClear(&mr); taosArrayDestroy(suidList); tdUidStoreDestory(&uidStore); - - return TSDB_CODE_FAILED; + return code; } /** @@ -1254,7 +1286,6 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) { code = TAOS_SYSTEM_ERROR(errno); TSDB_CHECK_CODE(code, lino, _exit); } - ASSERT(size > 0); int64_t offset = 0; if (taosFSendFile(pOutFD, pInFD, &offset, size) < 0) { @@ -1374,10 +1405,11 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { // async process pItem->fetchLevel = pItem->level; #if 0 + // debugging codes SRSmaInfo *qInfo = tdAcquireRSmaInfoBySuid(pSma, pRSmaInfo->suid); SRSmaInfoItem *qItem = RSMA_INFO_ITEM(qInfo, pItem->level - 1); - ASSERT(qItem->level == pItem->level); - ASSERT(qItem->fetchLevel == pItem->fetchLevel); + make sure(qItem->level == pItem->level); + make sure(qItem->fetchLevel == pItem->fetchLevel); #endif if (atomic_load_8(&pRSmaInfo->assigned) == 0) { tsem_post(&(pStat->notEmpty)); @@ -1524,6 +1556,8 @@ _err: */ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { + int32_t code = 0; + int32_t lino = 0; SVnode *pVnode = pSma->pVnode; SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); SRSmaStat *pRSmaStat = (SRSmaStat *)SMA_ENV_STAT(pEnv); @@ -1532,14 +1566,14 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { bool isFetchAll = false; if (!pRSmaStat || !(infoHash = RSMA_INFO_HASH(pRSmaStat))) { - terrno = TSDB_CODE_RSMA_INVALID_STAT; - goto _err; + code = TSDB_CODE_RSMA_INVALID_STAT; + TSDB_CHECK_CODE(code, lino, _exit); } if (!(pSubmitArr = taosArrayInit(TMIN(RSMA_SUBMIT_BATCH_SIZE, atomic_load_64(&pRSmaStat->nBufItems)), sizeof(SPackedData)))) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - goto _err; + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); } while (true) { @@ -1570,7 +1604,11 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { if (oldStat == 0 || ((oldStat == 2) && atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat)) < TASK_TRIGGER_STAT_PAUSED)) { int32_t oldVal = atomic_fetch_add_32(&pRSmaStat->nFetchAll, 1); - ASSERT(oldVal >= 0); + + if (ASSERTS(oldVal >= 0, "oldVal of nFetchAll: %d < 0", oldVal)) { + code = TSDB_CODE_APP_ERROR; + TSDB_CHECK_CODE(code, lino, _exit); + } int8_t curStat = atomic_load_8(RSMA_COMMIT_STAT(pRSmaStat)); if (curStat == 1) { @@ -1600,7 +1638,9 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { } } } else { - ASSERT(0); + ASSERTS(0, "unknown rsma exec type:%d", (int32_t)type); + code = TSDB_CODE_APP_ERROR; + TSDB_CHECK_CODE(code, lino, _exit); } if (atomic_load_64(&pRSmaStat->nBufItems) <= 0) { @@ -1619,10 +1659,10 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { } // end of while(true) -_end: - taosArrayDestroy(pSubmitArr); - return TSDB_CODE_SUCCESS; -_err: +_exit: taosArrayDestroy(pSubmitArr); - return TSDB_CODE_FAILED; + if (code) { + smaError("vgId:%d, %s failed at line %d since %s", TD_VID(pVnode), __func__, lino, tstrerror(code)); + } + return code; } diff --git a/source/dnode/vnode/src/sma/smaTimeRange.c b/source/dnode/vnode/src/sma/smaTimeRange.c index e633d93de69465673a08e530bdc647c9f372a87a..65c3bf3095e223f78166ebbd7c8b0d161d51e43d 100644 --- a/source/dnode/vnode/src/sma/smaTimeRange.c +++ b/source/dnode/vnode/src/sma/smaTimeRange.c @@ -14,6 +14,7 @@ */ #include "sma.h" +#include "tq.h" #include "tsdb.h" #define SMA_STORAGE_MINUTES_MAX 86400 @@ -155,6 +156,200 @@ _exit: return code; } +int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema *pTSchema, + SSchemaWrapper *pTagSchemaWrapper, bool createTb, int64_t suid, const char *stbFullName, + SBatchDeleteReq *pDeleteReq, void **ppData, int32_t *pLen) { + void *pBuf = NULL; + int32_t len = 0; + SSubmitReq2 *pReq = NULL; + SArray *tagArray = NULL; + SArray *createTbArray = NULL; + SArray *pVals = NULL; + + int32_t sz = taosArrayGetSize(pBlocks); + + if (!(tagArray = taosArrayInit(1, sizeof(STagVal)))) { + goto _end; + } + + if (!(createTbArray = taosArrayInit(sz, POINTER_BYTES))) { + goto _end; + } + + if (!(pReq = taosMemoryCalloc(1, sizeof(SSubmitReq2)))) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _end; + } + + if (!(pReq->aSubmitTbData = taosArrayInit(1, sizeof(SSubmitTbData)))) { + goto _end; + } + + // create table req + if (createTb) { + for (int32_t i = 0; i < sz; ++i) { + SSDataBlock *pDataBlock = taosArrayGet(pBlocks, i); + SVCreateTbReq *pCreateTbReq = NULL; + if (pDataBlock->info.type == STREAM_DELETE_RESULT) { + taosArrayPush(createTbArray, &pCreateTbReq); + continue; + } + + if (!(pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateStbReq)))) { + goto _end; + }; + + // don't move to the end of loop as to destroy in the end of func when error occur + taosArrayPush(createTbArray, &pCreateTbReq); + + // set const + pCreateTbReq->flags = 0; + pCreateTbReq->type = TSDB_CHILD_TABLE; + pCreateTbReq->ctb.suid = suid; + + // set super table name + SName name = {0}; + tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + pCreateTbReq->ctb.stbName = strdup((char *)tNameGetTableName(&name)); // strdup(stbFullName); + + // set tag content + taosArrayClear(tagArray); + STagVal tagVal = { + .cid = taosArrayGetSize(pDataBlock->pDataBlock) + 1, + .type = TSDB_DATA_TYPE_UBIGINT, + .i64 = (int64_t)pDataBlock->info.id.groupId, + }; + taosArrayPush(tagArray, &tagVal); + pCreateTbReq->ctb.tagNum = taosArrayGetSize(tagArray); + + STag *pTag = NULL; + tTagNew(tagArray, 1, false, &pTag); + if (pTag == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _end; + } + pCreateTbReq->ctb.pTag = (uint8_t *)pTag; + + // set tag name + SArray *tagName = taosArrayInit(1, TSDB_COL_NAME_LEN); + char tagNameStr[TSDB_COL_NAME_LEN] = {0}; + strcpy(tagNameStr, "group_id"); + taosArrayPush(tagName, tagNameStr); + pCreateTbReq->ctb.tagName = tagName; + + // set table name + if (pDataBlock->info.parTbName[0]) { + pCreateTbReq->name = strdup(pDataBlock->info.parTbName); + } else { + pCreateTbReq->name = buildCtbNameByGroupId(stbFullName, pDataBlock->info.id.groupId); + } + } + } + + // SSubmitTbData req + for (int32_t i = 0; i < sz; ++i) { + SSDataBlock *pDataBlock = taosArrayGet(pBlocks, i); + if (pDataBlock->info.type == STREAM_DELETE_RESULT) { + pDeleteReq->suid = suid; + pDeleteReq->deleteReqs = taosArrayInit(0, sizeof(SSingleDeleteReq)); + tqBuildDeleteReq(pVnode, stbFullName, pDataBlock, pDeleteReq); + continue; + } + + int32_t rows = pDataBlock->info.rows; + + SSubmitTbData *pTbData = (SSubmitTbData *)taosMemoryCalloc(1, sizeof(SSubmitTbData)); + if (!pTbData) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _end; + } + + if (!(pTbData->aRowP = taosArrayInit(rows, sizeof(SRow *)))) { + taosMemoryFree(pTbData); + goto _end; + } + pTbData->suid = suid; + pTbData->uid = 0; // uid is assigned by vnode + pTbData->sver = pTSchema->version; + + if (createTb) { + pTbData->pCreateTbReq = taosArrayGetP(createTbArray, i); + if (pTbData->pCreateTbReq) pTbData->flags = SUBMIT_REQ_AUTO_CREATE_TABLE; + } + + if (!pVals && !(pVals = taosArrayInit(pTSchema->numOfCols, sizeof(SColVal)))) { + taosArrayDestroy(pTbData->aRowP); + taosMemoryFree(pTbData); + goto _end; + } + + for (int32_t j = 0; j < rows; ++j) { + taosArrayClear(pVals); + for (int32_t k = 0; k < pTSchema->numOfCols; k++) { + const STColumn *pCol = &pTSchema->columns[k]; + SColumnInfoData *pColData = taosArrayGet(pDataBlock->pDataBlock, k); + if (colDataIsNull_s(pColData, j)) { + SColVal cv = COL_VAL_NULL(pCol->colId, pCol->type); + taosArrayPush(pVals, &cv); + } else { + void *data = colDataGetData(pColData, j); + if (IS_STR_DATA_TYPE(pCol->type)) { + SValue sv = (SValue){.nData = varDataLen(data), .pData = varDataVal(data)}; // address copy, no value + SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv); + taosArrayPush(pVals, &cv); + } else { + SValue sv; + memcpy(&sv.val, data, tDataTypes[pCol->type].bytes); + SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv); + taosArrayPush(pVals, &cv); + } + } + } + SRow *pRow = NULL; + if ((terrno = tRowBuild(pVals, (STSchema *)pTSchema, &pRow)) < 0) { + tDestroySSubmitTbData(pTbData, TSDB_MSG_FLG_ENCODE); + goto _end; + } + ASSERT(pRow); + taosArrayPush(pTbData->aRowP, &pRow); + } + + taosArrayPush(pReq->aSubmitTbData, pTbData); + } + + // encode + tEncodeSize(tEncodeSSubmitReq2, pReq, len, terrno); + if (TSDB_CODE_SUCCESS == terrno) { + SEncoder encoder; + len += sizeof(SMsgHead); + pBuf = rpcMallocCont(len); + if (NULL == pBuf) { + goto _end; + } + ((SMsgHead *)pBuf)->vgId = TD_VID(pVnode); + ((SMsgHead *)pBuf)->contLen = htonl(len); + tEncoderInit(&encoder, POINTER_SHIFT(pBuf, sizeof(SMsgHead)), len - sizeof(SMsgHead)); + if (tEncodeSSubmitReq2(&encoder, pReq) < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + /*vError("failed to encode submit req since %s", terrstr());*/ + } + tEncoderClear(&encoder); + } +_end: + taosArrayDestroy(tagArray); + taosArrayDestroy(pVals); + tDestroySSubmitReq2(pReq, TSDB_MSG_FLG_ENCODE); + + if (terrno != 0) { + rpcFreeCont(pBuf); + taosArrayDestroy(pDeleteReq->deleteReqs); + return TSDB_CODE_FAILED; + } + if (ppData) *ppData = pBuf; + if (pLen) *pLen = len; + return TSDB_CODE_SUCCESS; +} + /** * @brief Insert/Update Time-range-wise SMA data. * @@ -220,8 +415,9 @@ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char void *pSubmitReq = NULL; int32_t contLen = 0; - if (tqBlockToSubmit(pSma->pVnode, (const SArray *)msg, pTsmaStat->pTSchema, &pTsmaStat->pTSma->schemaTag, true, - pTsmaStat->pTSma->dstTbUid, pTsmaStat->pTSma->dstTbName, &deleteReq, &pSubmitReq, &contLen) < 0) { + if (smaBlockToSubmit(pSma->pVnode, (const SArray *)msg, pTsmaStat->pTSchema, &pTsmaStat->pTSma->schemaTag, true, + pTsmaStat->pTSma->dstTbUid, pTsmaStat->pTSma->dstTbName, &deleteReq, &pSubmitReq, + &contLen) < 0) { smaError("vgId:%d, failed to gen submit msg while tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma), indexUid, tstrerror(terrno)); goto _err; @@ -241,7 +437,7 @@ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char SRpcMsg submitReqMsg = { .msgType = TDMT_VND_SUBMIT, .pCont = pSubmitReq, - .contLen = ntohl(contLen), + .contLen = contLen, }; if (tmsgPutToQueue(&pSma->pVnode->msgCb, WRITE_QUEUE, &submitReqMsg) < 0) { diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index d0017e4ba227d197d72a88a487bac26e4868c3f5..141f79ee41e32bb14411ebe6239243e94d284ca2 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -1117,6 +1117,11 @@ int32_t tqProcessTaskRecover1Req(STQ* pTq, SRpcMsg* pMsg) { // do recovery step 1 streamSourceRecoverScanStep1(pTask); + if (atomic_load_8(&pTask->taskStatus) == TASK_STATUS__DROPPING) { + streamMetaReleaseTask(pTq->pStreamMeta, pTask); + return 0; + } + // build msg to launch next step SStreamRecoverStep2Req req; code = streamBuildSourceRecover2Req(pTask, &req); @@ -1127,6 +1132,10 @@ int32_t tqProcessTaskRecover1Req(STQ* pTq, SRpcMsg* pMsg) { streamMetaReleaseTask(pTq->pStreamMeta, pTask); + if (atomic_load_8(&pTask->taskStatus) == TASK_STATUS__DROPPING) { + return 0; + } + // serialize msg int32_t len = sizeof(SStreamRecoverStep1Req); @@ -1165,6 +1174,11 @@ int32_t tqProcessTaskRecover2Req(STQ* pTq, int64_t version, char* msg, int32_t m return -1; } + if (atomic_load_8(&pTask->taskStatus) == TASK_STATUS__DROPPING) { + streamMetaReleaseTask(pTq->pStreamMeta, pTask); + return 0; + } + // restore param code = streamRestoreParam(pTask); if (code < 0) { diff --git a/source/dnode/vnode/src/tq/tqOffset.c b/source/dnode/vnode/src/tq/tqOffset.c index 5a4d414ab7f9591a095148635634fb350f8f078d..66d1ac2c7e530e4b8c732deaaa83afc6191b5e44 100644 --- a/source/dnode/vnode/src/tq/tqOffset.c +++ b/source/dnode/vnode/src/tq/tqOffset.c @@ -45,19 +45,37 @@ int32_t tqOffsetRestoreFromFile(STqOffsetStore* pStore, const char* fname) { } int32_t size = htonl(head.size); void* memBuf = taosMemoryCalloc(1, size); + if (memBuf == NULL) { + return -1; + } if ((code = taosReadFile(pFile, memBuf, size)) != size) { + taosMemoryFree(memBuf); return -1; } STqOffset offset; SDecoder decoder; tDecoderInit(&decoder, memBuf, size); if (tDecodeSTqOffset(&decoder, &offset) < 0) { + taosMemoryFree(memBuf); + tDecoderClear(&decoder); return -1; } + tDecoderClear(&decoder); if (taosHashPut(pStore->pHash, offset.subKey, strlen(offset.subKey), &offset, sizeof(STqOffset)) < 0) { return -1; } + + if (offset.val.type == TMQ_OFFSET__LOG) { + STqHandle* pHandle = taosHashGet(pStore->pTq->pHandle, offset.subKey, strlen(offset.subKey)); + if (pHandle) { + if (walRefVer(pHandle->pRef, offset.val.version) < 0) { + tqError("vgId: %d, tq handle %s ref ver %" PRId64 "error", pStore->pTq->pVnode->config.vgId, + pHandle->subKey, offset.val.version); + } + } + } + taosMemoryFree(memBuf); } @@ -123,6 +141,7 @@ int32_t tqOffsetCommitFile(STqOffsetStore* pStore) { const char* sysErrStr = strerror(errno); tqError("vgId:%d, cannot open file %s when commit offset since %s", pStore->pTq->pVnode->config.vgId, fname, sysErrStr); + taosMemoryFree(fname); return -1; } taosMemoryFree(fname); diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index e8f2555f177470b6aef444ee28ccb2a8b6e0b53d..75c0c0659e0f245d69b0efaed07e22d15f8cd255 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -63,7 +63,7 @@ int32_t tqBuildDeleteReq(SVnode* pVnode, const char* stbFullName, const SSDataBl .startTs = startTs, .endTs = endTs, }; - strncpy(req.tbname, name, TSDB_TABLE_NAME_LEN); + strncpy(req.tbname, name, TSDB_TABLE_NAME_LEN - 1); taosMemoryFree(name); /*tqDebug("stream delete msg, active: vgId:%d, ts:%" PRId64 " name:%s", pVnode->config.vgId, ts, name);*/ taosArrayPush(deleteReq->deleteReqs, &req); @@ -71,427 +71,6 @@ int32_t tqBuildDeleteReq(SVnode* pVnode, const char* stbFullName, const SSDataBl return 0; } -#if 0 -SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pTSchema, - SSchemaWrapper* pTagSchemaWrapper, bool createTb, int64_t suid, const char* stbFullName, - SBatchDeleteReq* pDeleteReq) { - SSubmitReq* ret = NULL; - SArray* schemaReqs = NULL; - SArray* schemaReqSz = NULL; - SArray* tagArray = taosArrayInit(1, sizeof(STagVal)); - if (!tagArray) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; - } - - int32_t sz = taosArrayGetSize(pBlocks); - - if (createTb) { - schemaReqs = taosArrayInit(sz, sizeof(void*)); - schemaReqSz = taosArrayInit(sz, sizeof(int32_t)); - for (int32_t i = 0; i < sz; i++) { - SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i); - if (pDataBlock->info.type == STREAM_DELETE_RESULT) { - int32_t padding1 = 0; - void* padding2 = NULL; - taosArrayPush(schemaReqSz, &padding1); - taosArrayPush(schemaReqs, &padding2); - continue; - } - - // STag* pTag = NULL; - // taosArrayClear(tagArray); - // SArray *tagName = taosArrayInit(1, TSDB_COL_NAME_LEN); - // for(int j = 0; j < pTagSchemaWrapper->nCols; j++){ - // STagVal tagVal = { - // .cid = pTagSchemaWrapper->pSchema[j].colId, - // .type = pTagSchemaWrapper->pSchema[j].type, - // .i64 = (int64_t)pDataBlock->info.id.groupId, - // }; - // taosArrayPush(tagArray, &tagVal); - // taosArrayPush(tagName, pTagSchemaWrapper->pSchema[j].name); - // } - // - // tTagNew(tagArray, 1, false, &pTag); - // if (pTag == NULL) { - // terrno = TSDB_CODE_OUT_OF_MEMORY; - // taosArrayDestroy(tagArray); - // taosArrayDestroy(tagName); - // return NULL; - // } - - SVCreateTbReq createTbReq = {0}; - - // set const - createTbReq.flags = 0; - createTbReq.type = TSDB_CHILD_TABLE; - createTbReq.ctb.suid = suid; - - // set super table name - SName name = {0}; - tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); - createTbReq.ctb.stbName = strdup((char*)tNameGetTableName(&name)); // strdup(stbFullName); - - // set tag content - taosArrayClear(tagArray); - STagVal tagVal = { - .cid = taosArrayGetSize(pDataBlock->pDataBlock) + 1, - .type = TSDB_DATA_TYPE_UBIGINT, - .i64 = (int64_t)pDataBlock->info.id.groupId, - }; - taosArrayPush(tagArray, &tagVal); - createTbReq.ctb.tagNum = taosArrayGetSize(tagArray); - - STag* pTag = NULL; - tTagNew(tagArray, 1, false, &pTag); - if (pTag == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - taosArrayDestroy(tagArray); - taosArrayDestroyP(schemaReqs, taosMemoryFree); - taosArrayDestroy(schemaReqSz); - return NULL; - } - createTbReq.ctb.pTag = (uint8_t*)pTag; - - // set tag name - SArray* tagName = taosArrayInit(1, TSDB_COL_NAME_LEN); - char tagNameStr[TSDB_COL_NAME_LEN] = {0}; - strcpy(tagNameStr, "group_id"); - taosArrayPush(tagName, tagNameStr); - createTbReq.ctb.tagName = tagName; - - // set table name - if (pDataBlock->info.parTbName[0]) { - createTbReq.name = strdup(pDataBlock->info.parTbName); - } else { - createTbReq.name = buildCtbNameByGroupId(stbFullName, pDataBlock->info.id.groupId); - } - - // save schema len - int32_t code; - int32_t schemaLen; - tEncodeSize(tEncodeSVCreateTbReq, &createTbReq, schemaLen, code); - if (code < 0) { - tdDestroySVCreateTbReq(&createTbReq); - taosArrayDestroy(tagArray); - taosArrayDestroyP(schemaReqs, taosMemoryFree); - taosArrayDestroy(schemaReqSz); - return NULL; - } - taosArrayPush(schemaReqSz, &schemaLen); - - // save schema str - void* schemaStr = taosMemoryMalloc(schemaLen); - if (schemaStr == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - tdDestroySVCreateTbReq(&createTbReq); - taosArrayDestroy(tagArray); - taosArrayDestroyP(schemaReqs, taosMemoryFree); - taosArrayDestroy(schemaReqSz); - return NULL; - } - taosArrayPush(schemaReqs, &schemaStr); - - SEncoder encoder = {0}; - tEncoderInit(&encoder, schemaStr, schemaLen); - code = tEncodeSVCreateTbReq(&encoder, &createTbReq); - if (code < 0) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - tdDestroySVCreateTbReq(&createTbReq); - taosArrayDestroy(tagArray); - taosArrayDestroyP(schemaReqs, taosMemoryFree); - taosArrayDestroy(schemaReqSz); - tEncoderClear(&encoder); - return NULL; - } - tEncoderClear(&encoder); - tdDestroySVCreateTbReq(&createTbReq); - } - } - taosArrayDestroy(tagArray); - - // cal size - int32_t cap = sizeof(SSubmitReq); - for (int32_t i = 0; i < sz; i++) { - SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i); - if (pDataBlock->info.type == STREAM_DELETE_RESULT) { - continue; - } - int32_t rows = pDataBlock->info.rows; - /*int32_t rowSize = pDataBlock->info.rowSize;*/ - int32_t maxLen = TD_ROW_MAX_BYTES_FROM_SCHEMA(pTSchema); - - int32_t schemaLen = 0; - if (createTb) { - schemaLen = *(int32_t*)taosArrayGet(schemaReqSz, i); - } - cap += sizeof(SSubmitBlk) + schemaLen + rows * maxLen; - } - - // assign data - ret = rpcMallocCont(cap); - ret->header.vgId = pVnode->config.vgId; - ret->length = sizeof(SSubmitReq); - ret->numOfBlocks = htonl(sz); - - SSubmitBlk* blkHead = POINTER_SHIFT(ret, sizeof(SSubmitReq)); - for (int32_t i = 0; i < sz; i++) { - SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i); - if (pDataBlock->info.type == STREAM_DELETE_RESULT) { - pDeleteReq->suid = suid; - pDeleteReq->deleteReqs = taosArrayInit(0, sizeof(SSingleDeleteReq)); - tqBuildDeleteReq(pVnode, stbFullName, pDataBlock, pDeleteReq); - continue; - } - - blkHead->numOfRows = htonl(pDataBlock->info.rows); - blkHead->sversion = htonl(pTSchema->version); - blkHead->suid = htobe64(suid); - // uid is assigned by vnode - blkHead->uid = 0; - - int32_t rows = pDataBlock->info.rows; - - int32_t dataLen = 0; - int32_t schemaLen = 0; - void* blkSchema = POINTER_SHIFT(blkHead, sizeof(SSubmitBlk)); - if (createTb) { - schemaLen = *(int32_t*)taosArrayGet(schemaReqSz, i); - void* schemaStr = taosArrayGetP(schemaReqs, i); - memcpy(blkSchema, schemaStr, schemaLen); - } - blkHead->schemaLen = htonl(schemaLen); - - STSRow* rowData = POINTER_SHIFT(blkSchema, schemaLen); - for (int32_t j = 0; j < rows; j++) { - SRowBuilder rb = {0}; - tdSRowInit(&rb, pTSchema->version); - tdSRowSetTpInfo(&rb, pTSchema->numOfCols, pTSchema->flen); - tdSRowResetBuf(&rb, rowData); - - for (int32_t k = 0; k < pTSchema->numOfCols; k++) { - const STColumn* pColumn = &pTSchema->columns[k]; - SColumnInfoData* pColData = taosArrayGet(pDataBlock->pDataBlock, k); - if (colDataIsNull_s(pColData, j)) { - tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, pColumn->offset, k); - } else { - void* data = colDataGetData(pColData, j); - tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, pColumn->offset, k); - } - } - tdSRowEnd(&rb); - int32_t rowLen = TD_ROW_LEN(rowData); - rowData = POINTER_SHIFT(rowData, rowLen); - dataLen += rowLen; - } - blkHead->dataLen = htonl(dataLen); - - ret->length += sizeof(SSubmitBlk) + schemaLen + dataLen; - blkHead = POINTER_SHIFT(blkHead, sizeof(SSubmitBlk) + schemaLen + dataLen); - } - - ret->length = htonl(ret->length); - - taosArrayDestroyP(schemaReqs, taosMemoryFree); - taosArrayDestroy(schemaReqSz); - - return ret; -} -#endif - -int32_t tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pTSchema, - SSchemaWrapper* pTagSchemaWrapper, bool createTb, int64_t suid, const char* stbFullName, - SBatchDeleteReq* pDeleteReq, void** ppData, int32_t* pLen) { - void* pBuf = NULL; - int32_t len = 0; - SSubmitReq2* pReq = NULL; - SArray* tagArray = NULL; - SArray* createTbArray = NULL; - SArray* pVals = NULL; - - int32_t sz = taosArrayGetSize(pBlocks); - - if (!(tagArray = taosArrayInit(1, sizeof(STagVal)))) { - goto _end; - } - - if (!(createTbArray = taosArrayInit(sz, POINTER_BYTES))) { - goto _end; - } - - if (!(pReq = taosMemoryCalloc(1, sizeof(SSubmitReq2)))) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - goto _end; - } - - if (!(pReq->aSubmitTbData = taosArrayInit(1, sizeof(SSubmitTbData)))) { - goto _end; - } - - // create table req - if (createTb) { - for (int32_t i = 0; i < sz; ++i) { - SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i); - SVCreateTbReq* pCreateTbReq = NULL; - if (pDataBlock->info.type == STREAM_DELETE_RESULT) { - taosArrayPush(createTbArray, &pCreateTbReq); - continue; - } - - if (!(pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateStbReq)))) { - goto _end; - }; - - // don't move to the end of loop as to destroy in the end of func when error occur - taosArrayPush(createTbArray, &pCreateTbReq); - - // set const - pCreateTbReq->flags = 0; - pCreateTbReq->type = TSDB_CHILD_TABLE; - pCreateTbReq->ctb.suid = suid; - - // set super table name - SName name = {0}; - tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); - pCreateTbReq->ctb.stbName = strdup((char*)tNameGetTableName(&name)); // strdup(stbFullName); - - // set tag content - taosArrayClear(tagArray); - STagVal tagVal = { - .cid = taosArrayGetSize(pDataBlock->pDataBlock) + 1, - .type = TSDB_DATA_TYPE_UBIGINT, - .i64 = (int64_t)pDataBlock->info.id.groupId, - }; - taosArrayPush(tagArray, &tagVal); - pCreateTbReq->ctb.tagNum = taosArrayGetSize(tagArray); - - STag* pTag = NULL; - tTagNew(tagArray, 1, false, &pTag); - if (pTag == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - goto _end; - } - pCreateTbReq->ctb.pTag = (uint8_t*)pTag; - - // set tag name - SArray* tagName = taosArrayInit(1, TSDB_COL_NAME_LEN); - char tagNameStr[TSDB_COL_NAME_LEN] = {0}; - strcpy(tagNameStr, "group_id"); - taosArrayPush(tagName, tagNameStr); - pCreateTbReq->ctb.tagName = tagName; - - // set table name - if (pDataBlock->info.parTbName[0]) { - pCreateTbReq->name = strdup(pDataBlock->info.parTbName); - } else { - pCreateTbReq->name = buildCtbNameByGroupId(stbFullName, pDataBlock->info.id.groupId); - } - } - } - - // SSubmitTbData req - for (int32_t i = 0; i < sz; ++i) { - SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i); - if (pDataBlock->info.type == STREAM_DELETE_RESULT) { - pDeleteReq->suid = suid; - pDeleteReq->deleteReqs = taosArrayInit(0, sizeof(SSingleDeleteReq)); - tqBuildDeleteReq(pVnode, stbFullName, pDataBlock, pDeleteReq); - continue; - } - - int32_t rows = pDataBlock->info.rows; - - SSubmitTbData* pTbData = (SSubmitTbData*)taosMemoryCalloc(1, sizeof(SSubmitTbData)); - if (!pTbData) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - goto _end; - } - - if (!(pTbData->aRowP = taosArrayInit(rows, sizeof(SRow*)))) { - taosMemoryFree(pTbData); - goto _end; - } - pTbData->suid = suid; - pTbData->uid = 0; // uid is assigned by vnode - pTbData->sver = pTSchema->version; - - if (createTb) { - pTbData->pCreateTbReq = taosArrayGetP(createTbArray, i); - if (pTbData->pCreateTbReq) pTbData->flags = SUBMIT_REQ_AUTO_CREATE_TABLE; - } - - if (!pVals && !(pVals = taosArrayInit(pTSchema->numOfCols, sizeof(SColVal)))) { - taosArrayDestroy(pTbData->aRowP); - taosMemoryFree(pTbData); - goto _end; - } - - for (int32_t j = 0; j < rows; j++) { - taosArrayClear(pVals); - for (int32_t k = 0; k < pTSchema->numOfCols; k++) { - const STColumn* pCol = &pTSchema->columns[k]; - SColumnInfoData* pColData = taosArrayGet(pDataBlock->pDataBlock, k); - if (colDataIsNull_s(pColData, j)) { - SColVal cv = COL_VAL_NULL(pCol->colId, pCol->type); - taosArrayPush(pVals, &cv); - } else { - void* data = colDataGetData(pColData, j); - if (IS_STR_DATA_TYPE(pCol->type)) { - SValue sv = (SValue){.nData = varDataLen(data), .pData = varDataVal(data)}; // address copy, no value - SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv); - taosArrayPush(pVals, &cv); - } else { - SValue sv; - memcpy(&sv.val, data, tDataTypes[pCol->type].bytes); - SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv); - taosArrayPush(pVals, &cv); - } - } - } - SRow* pRow = NULL; - if ((terrno = tRowBuild(pVals, (STSchema*)pTSchema, &pRow)) < 0) { - tDestroySSubmitTbData(pTbData, TSDB_MSG_FLG_ENCODE); - goto _end; - } - ASSERT(pRow); - taosArrayPush(pTbData->aRowP, &pRow); - } - - taosArrayPush(pReq->aSubmitTbData, pTbData); - } - - // encode - tEncodeSize(tEncodeSSubmitReq2, pReq, len, terrno); - if (TSDB_CODE_SUCCESS == terrno) { - SEncoder encoder; - len += sizeof(SMsgHead); - pBuf = rpcMallocCont(len); - if (NULL == pBuf) { - goto _end; - } - ((SMsgHead*)pBuf)->vgId = htonl(TD_VID(pVnode)); - ((SMsgHead*)pBuf)->contLen = htonl(len); - tEncoderInit(&encoder, POINTER_SHIFT(pBuf, sizeof(SMsgHead)), len - sizeof(SMsgHead)); - if (tEncodeSSubmitReq2(&encoder, pReq) < 0) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - tqError("failed to encode submit req since %s", terrstr()); - } - tEncoderClear(&encoder); - } -_end: - taosArrayDestroy(tagArray); - taosArrayDestroy(pVals); - tDestroySSubmitReq2(pReq, TSDB_MSG_FLG_ENCODE); - - if (terrno != 0) { - rpcFreeCont(pBuf); - taosArrayDestroy(pDeleteReq->deleteReqs); - return TSDB_CODE_FAILED; - } - if (ppData) *ppData = pBuf; - if (pLen) *pLen = len; - return TSDB_CODE_SUCCESS; -} void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* data) { const SArray* pBlocks = (const SArray*)data; @@ -984,56 +563,3 @@ _end: taosArrayDestroy(pVals); // TODO: change } - -#if 0 -void tqSinkToTableMerge(SStreamTask* pTask, void* vnode, int64_t ver, void* data) { - const SArray* pRes = (const SArray*)data; - SVnode* pVnode = (SVnode*)vnode; - SBatchDeleteReq deleteReq = {0}; - - tqDebug("vgId:%d, task %d write into table, block num: %d", TD_VID(pVnode), pTask->taskId, (int32_t)pRes->size); - - deleteReq.deleteReqs = taosArrayInit(0, sizeof(SSingleDeleteReq)); - SSubmitReq* submitReq = tqBlockToSubmit(pVnode, pRes, pTask->tbSink.pTSchema, pTask->tbSink.pSchemaWrapper, true, - pTask->tbSink.stbUid, pTask->tbSink.stbFullName, &deleteReq); - - tqDebug("vgId:%d, task %d convert blocks over, put into write-queue", TD_VID(pVnode), pTask->taskId); - - if (taosArrayGetSize(deleteReq.deleteReqs) != 0) { - int32_t code; - int32_t len; - tEncodeSize(tEncodeSBatchDeleteReq, &deleteReq, len, code); - SEncoder encoder; - void* serializedDeleteReq = rpcMallocCont(len + sizeof(SMsgHead)); - void* abuf = POINTER_SHIFT(serializedDeleteReq, sizeof(SMsgHead)); - tEncoderInit(&encoder, abuf, len); - tEncodeSBatchDeleteReq(&encoder, &deleteReq); - tEncoderClear(&encoder); - - ((SMsgHead*)serializedDeleteReq)->vgId = pVnode->config.vgId; - - SRpcMsg msg = { - .msgType = TDMT_VND_BATCH_DEL, - .pCont = serializedDeleteReq, - .contLen = len + sizeof(SMsgHead), - }; - if (tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &msg) != 0) { - rpcFreeCont(serializedDeleteReq); - tqDebug("failed to put into write-queue since %s", terrstr()); - } - } - taosArrayDestroy(deleteReq.deleteReqs); - - /*tPrintFixedSchemaSubmitReq(pReq, pTask->tbSink.pTSchema);*/ - // build write msg - SRpcMsg msg = { - .msgType = TDMT_VND_SUBMIT, - .pCont = submitReq, - .contLen = ntohl(submitReq->length), - }; - - if (tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &msg) != 0) { - tqDebug("failed to put into write-queue since %s", terrstr()); - } -} -#endif diff --git a/source/dnode/vnode/src/tq/tqSnapshot.c b/source/dnode/vnode/src/tq/tqSnapshot.c index ab7093a701e0a5207b5f64072350ba5bc2bae703..5c0649c10985b05dc1f5677fa9bfe1812dd07808 100644 --- a/source/dnode/vnode/src/tq/tqSnapshot.c +++ b/source/dnode/vnode/src/tq/tqSnapshot.c @@ -173,6 +173,8 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) { if (code) goto _err; } + int vgId = TD_VID(pWriter->pTq->pVnode); + taosMemoryFree(pWriter); *ppWriter = NULL; @@ -184,7 +186,7 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) { return code; _err: - tqError("vgId:%d, tq snapshot writer close failed since %s", TD_VID(pWriter->pTq->pVnode), tstrerror(code)); + tqError("vgId:%d, tq snapshot writer close failed since %s", vgId, tstrerror(code)); return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index 007ae871a0e20d84d729f2d8123c0e7500591423..953b4884a3cf873f6a894ccfc386c9e2ddf257e9 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -19,9 +19,13 @@ #define SL_MAX_LEVEL 5 // sizeof(SMemSkipListNode) + sizeof(SMemSkipListNode *) * (l) * 2 -#define SL_NODE_SIZE(l) (sizeof(SMemSkipListNode) + ((l) << 4)) -#define SL_NODE_FORWARD(n, l) ((n)->forwards[l]) -#define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)]) +#define SL_NODE_SIZE(l) (sizeof(SMemSkipListNode) + ((l) << 4)) +#define SL_NODE_FORWARD(n, l) ((n)->forwards[l]) +#define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)]) +#define SL_GET_NODE_FORWARD(n, l) ((SMemSkipListNode *)atomic_load_64((int64_t *)&SL_NODE_FORWARD(n, l))) +#define SL_GET_NODE_BACKWARD(n, l) ((SMemSkipListNode *)atomic_load_64((int64_t *)&SL_NODE_BACKWARD(n, l))) +#define SL_SET_NODE_FORWARD(n, l, p) atomic_store_64((int64_t *)&SL_NODE_FORWARD(n, l), (int64_t)(p)) +#define SL_SET_NODE_BACKWARD(n, l, p) atomic_store_64((int64_t *)&SL_NODE_BACKWARD(n, l), (int64_t)(p)) #define SL_MOVE_BACKWARD 0x1 #define SL_MOVE_FROM_POS 0x2 @@ -250,18 +254,18 @@ void tsdbTbDataIterOpen(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDa if (pFrom == NULL) { // create from head or tail if (backward) { - pIter->pNode = SL_NODE_BACKWARD(pTbData->sl.pTail, 0); + pIter->pNode = SL_GET_NODE_BACKWARD(pTbData->sl.pTail, 0); } else { - pIter->pNode = SL_NODE_FORWARD(pTbData->sl.pHead, 0); + pIter->pNode = SL_GET_NODE_FORWARD(pTbData->sl.pHead, 0); } } else { // create from a key if (backward) { tbDataMovePosTo(pTbData, pos, pFrom, SL_MOVE_BACKWARD); - pIter->pNode = SL_NODE_BACKWARD(pos[0], 0); + pIter->pNode = SL_GET_NODE_BACKWARD(pos[0], 0); } else { tbDataMovePosTo(pTbData, pos, pFrom, 0); - pIter->pNode = SL_NODE_FORWARD(pos[0], 0); + pIter->pNode = SL_GET_NODE_FORWARD(pos[0], 0); } } } @@ -275,7 +279,7 @@ bool tsdbTbDataIterNext(STbDataIter *pIter) { return false; } - pIter->pNode = SL_NODE_BACKWARD(pIter->pNode, 0); + pIter->pNode = SL_GET_NODE_BACKWARD(pIter->pNode, 0); if (pIter->pNode == pIter->pTbData->sl.pHead) { return false; } @@ -286,7 +290,7 @@ bool tsdbTbDataIterNext(STbDataIter *pIter) { return false; } - pIter->pNode = SL_NODE_FORWARD(pIter->pNode, 0); + pIter->pNode = SL_GET_NODE_FORWARD(pIter->pNode, 0); if (pIter->pNode == pIter->pTbData->sl.pTail) { return false; } @@ -339,7 +343,7 @@ static int32_t tsdbGetOrCreateTbData(SMemTable *pMemTable, tb_uid_t suid, tb_uid int8_t maxLevel = pMemTable->pTsdb->pVnode->config.tsdbCfg.slLevel; ASSERT(pPool != NULL); - pTbData = vnodeBufPoolMalloc(pPool, sizeof(*pTbData) + SL_NODE_SIZE(maxLevel) * 2); + pTbData = vnodeBufPoolMallocAligned(pPool, sizeof(*pTbData) + SL_NODE_SIZE(maxLevel) * 2); if (pTbData == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; @@ -412,7 +416,7 @@ static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *p if (fromPos) px = pos[pTbData->sl.level - 1]; for (int8_t iLevel = pTbData->sl.level - 1; iLevel >= 0; iLevel--) { - pn = SL_NODE_BACKWARD(px, iLevel); + pn = SL_GET_NODE_BACKWARD(px, iLevel); while (pn != pTbData->sl.pHead) { if (pn->flag == TSDBROW_ROW_FMT) { tKey.version = pn->version; @@ -427,7 +431,7 @@ static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *p break; } else { px = pn; - pn = SL_NODE_BACKWARD(px, iLevel); + pn = SL_GET_NODE_BACKWARD(px, iLevel); } } @@ -447,7 +451,7 @@ static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *p if (fromPos) px = pos[pTbData->sl.level - 1]; for (int8_t iLevel = pTbData->sl.level - 1; iLevel >= 0; iLevel--) { - pn = SL_NODE_FORWARD(px, iLevel); + pn = SL_GET_NODE_FORWARD(px, iLevel); while (pn != pTbData->sl.pTail) { if (pn->flag == TSDBROW_ROW_FMT) { tKey.version = pn->version; @@ -462,7 +466,7 @@ static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *p break; } else { px = pn; - pn = SL_NODE_FORWARD(px, iLevel); + pn = SL_GET_NODE_FORWARD(px, iLevel); } } @@ -488,26 +492,28 @@ static int32_t tbDataDoPut(SMemTable *pMemTable, STbData *pTbData, SMemSkipListN int8_t level; SMemSkipListNode *pNode; SVBufPool *pPool = pMemTable->pTsdb->pVnode->inUse; + int64_t nSize; - ASSERT(pPool != NULL); - - // node + // create node level = tsdbMemSkipListRandLevel(&pTbData->sl); - pNode = (SMemSkipListNode *)vnodeBufPoolMalloc(pPool, SL_NODE_SIZE(level)); + nSize = SL_NODE_SIZE(level); + if (pRow->type == TSDBROW_ROW_FMT) { + pNode = (SMemSkipListNode *)vnodeBufPoolMallocAligned(pPool, nSize + pRow->pTSRow->len); + } else if (pRow->type == TSDBROW_COL_FMT) { + pNode = (SMemSkipListNode *)vnodeBufPoolMallocAligned(pPool, nSize); + } else { + ASSERT(0); + } if (pNode == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; } + pNode->level = level; pNode->flag = pRow->type; - if (pRow->type == TSDBROW_ROW_FMT) { pNode->version = pRow->version; - pNode->pData = vnodeBufPoolMalloc(pPool, pRow->pTSRow->len); - if (NULL == pNode->pData) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _exit; - } + pNode->pData = (char *)pNode + nSize; memcpy(pNode->pData, pRow->pTSRow, pRow->pTSRow->len); } else if (pRow->type == TSDBROW_COL_FMT) { pNode->iRow = pRow->iRow; @@ -516,40 +522,38 @@ static int32_t tbDataDoPut(SMemTable *pMemTable, STbData *pTbData, SMemSkipListN ASSERT(0); } - for (int8_t iLevel = level - 1; iLevel >= 0; iLevel--) { - SMemSkipListNode *pn = pos[iLevel]; - SMemSkipListNode *px; - - if (forward) { - px = SL_NODE_FORWARD(pn, iLevel); - - SL_NODE_BACKWARD(pNode, iLevel) = pn; - SL_NODE_FORWARD(pNode, iLevel) = px; - } else { - px = SL_NODE_BACKWARD(pn, iLevel); - - SL_NODE_BACKWARD(pNode, iLevel) = px; - SL_NODE_FORWARD(pNode, iLevel) = pn; + // set node + if (forward) { + for (int8_t iLevel = 0; iLevel < level; iLevel++) { + SL_NODE_FORWARD(pNode, iLevel) = SL_NODE_FORWARD(pos[iLevel], iLevel); + SL_NODE_BACKWARD(pNode, iLevel) = pos[iLevel]; + } + } else { + for (int8_t iLevel = 0; iLevel < level; iLevel++) { + SL_NODE_FORWARD(pNode, iLevel) = pos[iLevel]; + SL_NODE_BACKWARD(pNode, iLevel) = SL_NODE_BACKWARD(pos[iLevel], iLevel); } } - for (int8_t iLevel = level - 1; iLevel >= 0; iLevel--) { - SMemSkipListNode *pn = pos[iLevel]; - SMemSkipListNode *px; + // set forward and backward + if (forward) { + for (int8_t iLevel = level - 1; iLevel >= 0; iLevel--) { + SMemSkipListNode *pNext = pos[iLevel]->forwards[iLevel]; - if (forward) { - px = SL_NODE_FORWARD(pn, iLevel); + SL_SET_NODE_FORWARD(pos[iLevel], iLevel, pNode); + SL_SET_NODE_BACKWARD(pNext, iLevel, pNode); - SL_NODE_FORWARD(pn, iLevel) = pNode; - SL_NODE_BACKWARD(px, iLevel) = pNode; - } else { - px = SL_NODE_BACKWARD(pn, iLevel); - - SL_NODE_FORWARD(px, iLevel) = pNode; - SL_NODE_BACKWARD(pn, iLevel) = pNode; + pos[iLevel] = pNode; } + } else { + for (int8_t iLevel = level - 1; iLevel >= 0; iLevel--) { + SMemSkipListNode *pPrev = pos[iLevel]->forwards[pos[iLevel]->level + iLevel]; - pos[iLevel] = pNode; + SL_SET_NODE_FORWARD(pPrev, iLevel, pNode); + SL_SET_NODE_BACKWARD(pos[iLevel], iLevel, pNode); + + pos[iLevel] = pNode; + } } pTbData->sl.size++; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index d629be2fef308fd2cbbb1fe9cf74c9df834666b9..1938f751a26ee4056101cc781bdf0102a6aeaaf2 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -4271,6 +4271,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa int32_t code = TSDB_CODE_SUCCESS; pTableBlockInfo->totalSize = 0; pTableBlockInfo->totalRows = 0; + pTableBlockInfo->numOfVgroups = 1; // find the start data block in file SReaderStatus* pStatus = &pReader->status; diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index f0d9412a3cf47e0261bc0628662fd16a267d53c8..6f56539b4f136e64b481140be2301ed2b44c598e 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -75,6 +75,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); @@ -82,7 +83,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); @@ -92,13 +93,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; @@ -107,7 +108,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); @@ -138,7 +139,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); @@ -147,7 +148,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]; @@ -168,13 +169,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; } @@ -317,12 +318,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; @@ -337,17 +340,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) { @@ -359,21 +362,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; @@ -384,11 +388,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; } @@ -404,7 +408,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++) { @@ -421,7 +425,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); @@ -448,11 +452,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; } @@ -590,44 +592,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 782cc69d30709c16a328cd056a8b52f6b42a5a6f..69af536a4454909be7816ebda880e99e648656c3 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 bfe6e469ff8882a3e6a2e3b14ef522f051af3dbc..e6a2a32ce0f5c6f97d84b31151d8d0b932b03fc3 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 @@ 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 e09fafb75690f13dd160763126d139dd21ae8c1b..bec5d2977b8db7b4c11efd7c977264b2b5800372 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -48,6 +48,7 @@ int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) { info.state.applied = -1; info.state.commitID = 0; + vInfo("vgId:%d, save config while create", pCfg->vgId); if (vnodeSaveInfo(dir, &info) < 0 || vnodeCommitInfo(dir, &info) < 0) { vError("vgId:%d, failed to save vnode config since %s", pCfg ? pCfg->vgId : 0, tstrerror(terrno)); return -1; @@ -79,12 +80,14 @@ int32_t vnodeAlter(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs) { pCfg->replicaNum = pReq->replica; memset(&pCfg->nodeInfo, 0, sizeof(pCfg->nodeInfo)); - vInfo("vgId:%d, save config, replicas:%d selfIndex:%d", pReq->vgId, pCfg->replicaNum, pCfg->myIndex); + vInfo("vgId:%d, save config while alter, replicas:%d selfIndex:%d", pReq->vgId, pCfg->replicaNum, pCfg->myIndex); for (int i = 0; i < pReq->replica; ++i) { SNodeInfo *pNode = &pCfg->nodeInfo[i]; + pNode->nodeId = pReq->replicas[i].id; pNode->nodePort = pReq->replicas[i].port; tstrncpy(pNode->nodeFqdn, pReq->replicas[i].fqdn, sizeof(pNode->nodeFqdn)); - vInfo("vgId:%d, save config, replica:%d ep:%s:%u", pReq->vgId, i, pNode->nodeFqdn, pNode->nodePort); + (void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); + vInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d", pReq->vgId, i, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId); } info.config.syncCfg = *pCfg; diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index 2fc06fba86331882df27197bd9405cf72c98088c..cc22668b299db87d0701c507f75f79258be7a178 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -405,6 +405,10 @@ static int32_t vnodeSnapWriteInfo(SVSnapWriter *pWriter, uint8_t *pData, uint32_ } else { snprintf(dir, TSDB_FILENAME_LEN, "%s", pWriter->pVnode->path); } + + SVnode *pVnode = pWriter->pVnode; + pWriter->info.config = pVnode->config; + vDebug("vgId:%d, save config while write snapshot", pWriter->pVnode->config.vgId); if (vnodeSaveInfo(dir, &pWriter->info) < 0) { code = terrno; goto _exit; diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index 5697487743d30c5c1f76da4907ffd30bf30d1c7f..749c81224c44810a8961ab2e5577e5599ec06854 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -578,7 +578,8 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) { vInfo("vgId:%d, start to open sync, replica:%d selfIndex:%d", pVnode->config.vgId, pCfg->replicaNum, pCfg->myIndex); for (int32_t i = 0; i < pCfg->replicaNum; ++i) { SNodeInfo *pNode = &pCfg->nodeInfo[i]; - vInfo("vgId:%d, index:%d ep:%s:%u", pVnode->config.vgId, i, pNode->nodeFqdn, pNode->nodePort); + vInfo("vgId:%d, index:%d ep:%s:%u dnode:%d cluster:%" PRId64, pVnode->config.vgId, i, pNode->nodeFqdn, pNode->nodePort, + pNode->nodeId, pNode->clusterId); } pVnode->sync = syncOpen(&syncInfo); diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index a6ce613882daeda0ea99898e104cf184b4c5add6..9cbad139bfe957b81c0afcbd7ad9be48999b60b0 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -582,34 +582,34 @@ typedef struct SCtgOperation { #define CTG_LOCK(type, _lock) \ do { \ if (CTG_READ == (type)) { \ - assert(atomic_load_32((_lock)) >= 0); \ + ASSERTS(atomic_load_32((_lock)) >= 0, "invalid lock value before read lock"); \ CTG_LOCK_DEBUG("CTG RLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ taosRLockLatch(_lock); \ CTG_LOCK_DEBUG("CTG RLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) > 0); \ + ASSERTS(atomic_load_32((_lock)) > 0, "invalid lock value after read lock"); \ } else { \ - assert(atomic_load_32((_lock)) >= 0); \ + ASSERTS(atomic_load_32((_lock)) >= 0, "invalid lock value before write lock"); \ CTG_LOCK_DEBUG("CTG WLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ taosWLockLatch(_lock); \ CTG_LOCK_DEBUG("CTG WLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \ + ASSERTS(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY, "invalid lock value after write lock"); \ } \ } while (0) #define CTG_UNLOCK(type, _lock) \ do { \ if (CTG_READ == (type)) { \ - assert(atomic_load_32((_lock)) > 0); \ + ASSERTS(atomic_load_32((_lock)) > 0, "invalid lock value before read unlock"); \ CTG_LOCK_DEBUG("CTG RULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ taosRUnLockLatch(_lock); \ CTG_LOCK_DEBUG("CTG RULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) >= 0); \ + ASSERTS(atomic_load_32((_lock)) >= 0, "invalid lock value after read unlock"); \ } else { \ - assert(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \ + ASSERTS(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY, "invalid lock value before write unlock"); \ CTG_LOCK_DEBUG("CTG WULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ taosWUnLockLatch(_lock); \ CTG_LOCK_DEBUG("CTG WULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) >= 0); \ + ASSERTS(atomic_load_32((_lock)) >= 0, "invalid lock value after write unlock"); \ } \ } while (0) diff --git a/source/libs/catalog/src/ctgDbg.c b/source/libs/catalog/src/ctgDbg.c index b6ff1c8b987278ee8ef223577e91771c12cefde8..a6c0d1c40157f31f8002b11e7d4ce0e95a6f3f21 100644 --- a/source/libs/catalog/src/ctgDbg.c +++ b/source/libs/catalog/src/ctgDbg.c @@ -22,7 +22,6 @@ extern SCatalogMgmt gCtgMgmt; SCtgDebug gCTGDebug = {0}; void ctgdUserCallback(SMetaData *pResult, void *param, int32_t code) { - ASSERT(*(int32_t *)param == 1); taosMemoryFree(param); qDebug("async call result: %s", tstrerror(code)); diff --git a/source/libs/catalog/src/ctgRemote.c b/source/libs/catalog/src/ctgRemote.c index 7cc6c90d303c4c425358800eb646f986417cefdd..3b037e206290ff767a1f879e0b46aadf8b3e4f20 100644 --- a/source/libs/catalog/src/ctgRemote.c +++ b/source/libs/catalog/src/ctgRemote.c @@ -40,7 +40,9 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu msgNum = taosArrayGetSize(batchRsp.pRsps); } - ASSERT(taskNum == msgNum || 0 == msgNum); + if (ASSERTS(taskNum == msgNum || 0 == msgNum, "taskNum %d mis-match msgNum %d", taskNum, msgNum)) { + msgNum = 0; + } ctgDebug("QID:0x%" PRIx64 " ctg got batch %d rsp %s", pJob->queryId, cbParam->batchId, TMSG_INFO(cbParam->reqType + 1)); @@ -58,11 +60,19 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu if (msgNum > 0) { pRsp = taosArrayGet(batchRsp.pRsps, i); - taskMsg.msgType = pRsp->reqType; - taskMsg.pData = pRsp->msg; - taskMsg.len = pRsp->msgLen; - - ASSERT(pRsp->msgIdx == *msgIdx); + if (ASSERTS(pRsp->msgIdx == *msgIdx, "rsp msgIdx %d mis-match msgIdx %d", pRsp->msgIdx, *msgIdx)) { + pRsp = &rsp; + pRsp->msgIdx = *msgIdx; + pRsp->reqType = -1; + pRsp->rspCode = 0; + taskMsg.msgType = -1; + taskMsg.pData = NULL; + taskMsg.len = 0; + } else { + taskMsg.msgType = pRsp->reqType; + taskMsg.pData = pRsp->msg; + taskMsg.len = pRsp->msgLen; + } } else { pRsp = &rsp; pRsp->msgIdx = *msgIdx; diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index a179ec24f91cf7b5564862796633d4ad4f965f85..c87f6953eb5fbb2515b2db54ab1e85854111eeb2 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -21,6 +21,7 @@ #include "tdatablock.h" #include "tglobal.h" #include "tgrant.h" +#include "taosdef.h" extern SConfig* tsCfg; @@ -40,7 +41,6 @@ static int32_t buildRetrieveTableRsp(SSDataBlock* pBlock, int32_t numOfCols, SRe (*pRsp)->numOfCols = htonl(numOfCols); int32_t len = blockEncode(pBlock, (*pRsp)->data, numOfCols); - ASSERT(len == rspSize - sizeof(SRetrieveTableRsp)); return TSDB_CODE_SUCCESS; } @@ -154,6 +154,23 @@ static int32_t buildCreateDBResultDataBlock(SSDataBlock** pOutput) { return code; } +static int32_t buildAliveResultDataBlock(SSDataBlock** pOutput) { + SSDataBlock* pBlock = createDataBlock(); + if (NULL == pBlock) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + SColumnInfoData infoData = createColumnInfoData(TSDB_DATA_TYPE_INT, sizeof(int32_t), 1); + int32_t code = blockDataAppendColInfo(pBlock, &infoData); + + if (TSDB_CODE_SUCCESS == code) { + *pOutput = pBlock; + } else { + blockDataDestroy(pBlock); + } + return code; +} + int64_t getValOfDiffPrecision(int8_t unit, int64_t val) { int64_t v = 0; switch (unit) { @@ -281,6 +298,108 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbFName, S colDataAppend(pCol2, 0, buf2, false); } +#define CHECK_LEADER(n) (row[n] && (fields[n].type == TSDB_DATA_TYPE_VARCHAR && strncasecmp(row[n], "leader", varDataLen((char *)row[n] - VARSTR_HEADER_SIZE)) == 0)) +// on this row, if have leader return true else return false +bool existLeaderRole(TAOS_ROW row, TAOS_FIELD* fields, int nFields) { + // vgroup_id | db_name | tables | v1_dnode | v1_status | v2_dnode | v2_status | v3_dnode | v3_status | v4_dnode | + // v4_status | cacheload | tsma | + if (nFields != 13) { + return false; + } + + // check have leader on cloumn v*_status on 4 6 8 10 + if (CHECK_LEADER(4) || CHECK_LEADER(6) || CHECK_LEADER(8) || CHECK_LEADER(10)) { + return true; + } + + return false; +} + +// get db alive status, return 1 is alive else return 0 +int32_t getAliveStatusFromApi(int64_t* pConnId, char* dbName, int32_t* pStatus) { + char sql[128 + TSDB_DB_NAME_LEN] = "select * from information_schema.ins_vgroups"; + int32_t code; + + // filter with db name + if (dbName && dbName[0] != 0) { + char str[64 + TSDB_DB_NAME_LEN] = ""; + // test db name exist + sprintf(str, "show create database %s ;", dbName); + TAOS_RES* dbRes = taos_query(pConnId, str); + code = taos_errno(dbRes); + if (code != TSDB_CODE_SUCCESS) { + taos_free_result(dbRes); + return code; + } + taos_free_result(dbRes); + + sprintf(str, " where db_name='%s' ;", dbName); + strcat(sql, str); + } + + TAOS_RES* res = taos_query(pConnId, sql); + code = taos_errno(res); + if (code != TSDB_CODE_SUCCESS) { + taos_free_result(res); + return code; + } + + TAOS_ROW row = NULL; + TAOS_FIELD* fields = taos_fetch_fields(res); + int32_t nFields = taos_num_fields(res); + int32_t nAvailble = 0; + int32_t nUnAvailble = 0; + + while ((row = taos_fetch_row(res)) != NULL) { + if (existLeaderRole(row, fields, nFields)) { + nAvailble++; + } else { + nUnAvailble++; + } + } + taos_free_result(res); + + int32_t status = 0; + if (nAvailble + nUnAvailble == 0 || nUnAvailble == 0) { + status = SHOW_STATUS_AVAILABLE; + } else if (nAvailble > 0 && nUnAvailble > 0) { + status = SHOW_STATUS_HALF_AVAILABLE; + } else { + status = SHOW_STATUS_NOT_AVAILABLE; + } + + if (pStatus) { + *pStatus = status; + } + return TSDB_CODE_SUCCESS; +} + +static int32_t setAliveResultIntoDataBlock(int64_t* pConnId, SSDataBlock* pBlock, char* dbName) { + blockDataEnsureCapacity(pBlock, 1); + pBlock->info.rows = 1; + + SColumnInfoData* pCol1 = taosArrayGet(pBlock->pDataBlock, 0); + int32_t status = 0; + int32_t code = getAliveStatusFromApi(pConnId, dbName, &status); + if (code == TSDB_CODE_SUCCESS) { + colDataAppend(pCol1, 0, (const char*)&status, false); + } + return code; +} + +static int32_t execShowAliveStatus(int64_t* pConnId, SShowAliveStmt* pStmt, SRetrieveTableRsp** pRsp) { + SSDataBlock* pBlock = NULL; + int32_t code = buildAliveResultDataBlock(&pBlock); + if (TSDB_CODE_SUCCESS == code) { + code = setAliveResultIntoDataBlock(pConnId, pBlock, pStmt->dbName); + } + if (TSDB_CODE_SUCCESS == code) { + code = buildRetrieveTableRsp(pBlock, SHOW_ALIVE_RESULT_COLS, pRsp); + } + blockDataDestroy(pBlock); + return code; +} + static int32_t execShowCreateDatabase(SShowCreateDatabaseStmt* pStmt, SRetrieveTableRsp** pRsp) { SSDataBlock* pBlock = NULL; int32_t code = buildCreateDBResultDataBlock(&pBlock); @@ -736,7 +855,7 @@ static int32_t execSelectWithoutFrom(SSelectStmt* pSelect, SRetrieveTableRsp** p return code; } -int32_t qExecCommand(bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp** pRsp) { +int32_t qExecCommand(int64_t* pConnId, bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp** pRsp) { switch (nodeType(pStmt)) { case QUERY_NODE_DESCRIBE_STMT: return execDescribe(sysInfoUser, pStmt, pRsp); @@ -754,6 +873,9 @@ int32_t qExecCommand(bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp** pRsp) { return execShowLocalVariables(pRsp); case QUERY_NODE_SELECT_STMT: return execSelectWithoutFrom((SSelectStmt*)pStmt, pRsp); + case QUERY_NODE_SHOW_DB_ALIVE_STMT: + case QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT: + return execShowAliveStatus(pConnId, (SShowAliveStmt*)pStmt, pRsp); default: break; } diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index 253718048dcebb71b64ca4d4b48b3004c6d9ea3a..38222112a19a447a4a7294a6082bf8bd9edd18ce 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -1666,7 +1666,6 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) { rsp->numOfRows = htobe64((int64_t)rowNum); int32_t len = blockEncode(pBlock, rsp->data, taosArrayGetSize(pBlock->pDataBlock)); - ASSERT(len == rspSize - sizeof(SRetrieveTableRsp)); rsp->compLen = htonl(len); diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index 51150ede3c6b31c1a75dd4dd1197a4fe4f7d20a1..e0d2276e6fceed6aa31bdf22cd551e73a58dc4dc 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 44202b541288cccf6dc38246069a30bda655ef11..45cfcba8b5b4c3d52d168ce03434dcf5b0d98b7b 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -696,7 +696,7 @@ void cleanupExprSupp(SExprSupp* pSup); void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs); int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize, - const char* pkey); + const char* pkey, void* pState); void cleanupAggSup(SAggSupporter* pAggSup); void initResultSizeInfo(SResultInfo* pResultInfo, int32_t numOfRows); @@ -855,6 +855,8 @@ int32_t releaseOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResul int32_t saveOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResult, int32_t resSize); void getNextIntervalWindow(SInterval* pInterval, STimeWindow* tw, int32_t order); int32_t qAppendTaskStopInfo(SExecTaskInfo* pTaskInfo, SExchangeOpStopInfo* pInfo); +int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn_t searchFn, TSKEY ekey, int32_t pos, + int32_t order, int64_t* pData); #ifdef __cplusplus } diff --git a/source/libs/executor/src/dataInserter.c b/source/libs/executor/src/dataInserter.c index ca6149d42c90b21a7b1359348220d9611351dbf6..f78e3c22e13c8b99885c451cd16f76ed038b79a1 100644 --- a/source/libs/executor/src/dataInserter.c +++ b/source/libs/executor/src/dataInserter.c @@ -25,8 +25,8 @@ extern SDataSinkStat gDataSinkStat; typedef struct SSubmitRes { - int64_t affectedRows; - int32_t code; + int64_t affectedRows; + int32_t code; SSubmitRsp2* pRsp; } SSubmitRes; @@ -41,6 +41,7 @@ typedef struct SDataInserterHandle { SHashObj* pCols; int32_t status; bool queryEnd; + bool fullOrderColList; uint64_t useconds; uint64_t cachedSize; TdThreadMutex mutex; @@ -84,7 +85,7 @@ int32_t inserterCallback(void* param, SDataBuf* pMsg, int32_t code) { } pInserter->submitRes.affectedRows += pInserter->submitRes.pRsp->affectedRows; - qDebug("submit rsp received, affectedRows:%d, total:%"PRId64, pInserter->submitRes.pRsp->affectedRows, + qDebug("submit rsp received, affectedRows:%d, total:%" PRId64, pInserter->submitRes.pRsp->affectedRows, pInserter->submitRes.affectedRows); tDecoderClear(&coder); taosMemoryFree(pInserter->submitRes.pRsp); @@ -96,7 +97,8 @@ _return: return TSDB_CODE_SUCCESS; } -static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, void* pMsg, int32_t msgLen, void* pTransporter, SEpSet* pEpset) { +static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, void* pMsg, int32_t msgLen, void* pTransporter, + SEpSet* pEpset) { // send the fetch remote task result reques SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == pMsgSendInfo) { @@ -120,9 +122,9 @@ static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, void* pMsg, int } static int32_t submitReqToMsg(int32_t vgId, SSubmitReq2* pReq, void** pData, int32_t* pLen) { - int32_t code = TSDB_CODE_SUCCESS; + int32_t code = TSDB_CODE_SUCCESS; int32_t len = 0; - void* pBuf = NULL; + void* pBuf = NULL; tEncodeSize(tEncodeSSubmitReq2, pReq, len, code); if (TSDB_CODE_SUCCESS == code) { SEncoder encoder; @@ -147,13 +149,11 @@ static int32_t submitReqToMsg(int32_t vgId, SSubmitReq2* pReq, void** pData, int return code; } - -int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** ppReq, const SSDataBlock* pDataBlock, const STSchema* pTSchema, - int64_t uid, int32_t vgId, tb_uid_t suid) { +int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** ppReq, const SSDataBlock* pDataBlock, + const STSchema* pTSchema, int64_t uid, int32_t vgId, tb_uid_t suid) { SSubmitReq2* pReq = *ppReq; SArray* pVals = NULL; int32_t numOfBlks = 0; - bool fullCol = (pInserter->pNode->pCols->length == pTSchema->numOfCols); terrno = TSDB_CODE_SUCCESS; @@ -194,9 +194,9 @@ int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** pp int32_t offset = 0; for (int32_t k = 0; k < pTSchema->numOfCols; ++k) { // iterate by column - int16_t colIdx = k; - const STColumn* pCol = &pTSchema->columns[k]; - if (!fullCol) { + int16_t colIdx = k; + const STColumn* pCol = &pTSchema->columns[k]; + if (!pInserter->fullOrderColList) { int16_t* slotId = taosHashGet(pInserter->pCols, &pCol->colId, sizeof(pCol->colId)); if (NULL == slotId) { continue; @@ -204,7 +204,7 @@ int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** pp colIdx = *slotId; } - + SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, colIdx); void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes); @@ -246,7 +246,7 @@ int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** pp lastTs = *(int64_t*)var; } } - + SValue sv; memcpy(&sv.val, var, tDataTypes[pCol->type].bytes); SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv); @@ -268,7 +268,7 @@ int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** pp ignoreRow = false; continue; } - + SRow* pRow = NULL; if ((terrno = tRowBuild(pVals, pTSchema, &pRow)) < 0) { tDestroySSubmitTbData(&tbData, TSDB_MSG_FLG_ENCODE); @@ -286,7 +286,6 @@ int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** pp taosArrayPush(pReq->aSubmitTbData, &tbData); - _end: taosArrayDestroy(pVals); if (terrno != 0) { @@ -301,7 +300,6 @@ _end: return TSDB_CODE_SUCCESS; } - int32_t dataBlocksToSubmitReq(SDataInserterHandle* pInserter, void** pMsg, int32_t* msgLen) { const SArray* pBlocks = pInserter->pDataBlocks; const STSchema* pTSchema = pInserter->pSchema; @@ -310,7 +308,7 @@ int32_t dataBlocksToSubmitReq(SDataInserterHandle* pInserter, void** pMsg, int32 int32_t vgId = pInserter->pNode->vgId; int32_t sz = taosArrayGetSize(pBlocks); int32_t code = 0; - SSubmitReq2 *pReq = NULL; + SSubmitReq2* pReq = NULL; for (int32_t i = 0; i < sz; i++) { SSDataBlock* pDataBlock = taosArrayGetP(pBlocks, i); @@ -329,23 +327,24 @@ int32_t dataBlocksToSubmitReq(SDataInserterHandle* pInserter, void** pMsg, int32 code = submitReqToMsg(vgId, pReq, pMsg, msgLen); tDestroySSubmitReq2(pReq, TSDB_MSG_FLG_ENCODE); taosMemoryFree(pReq); - + return code; } static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput, bool* pContinue) { SDataInserterHandle* pInserter = (SDataInserterHandle*)pHandle; taosArrayPush(pInserter->pDataBlocks, &pInput->pData); - void* pMsg = NULL; + void* pMsg = NULL; int32_t msgLen = 0; - int32_t code = dataBlocksToSubmitReq(pInserter, &pMsg, &msgLen); + int32_t code = dataBlocksToSubmitReq(pInserter, &pMsg, &msgLen); if (code) { return code; } taosArrayClear(pInserter->pDataBlocks); - - code = sendSubmitRequest(pInserter, pMsg, msgLen, pInserter->pParam->readHandle->pMsgCb->clientRpc, &pInserter->pNode->epSet); + + code = sendSubmitRequest(pInserter, pMsg, msgLen, pInserter->pParam->readHandle->pMsgCb->clientRpc, + &pInserter->pNode->epSet); if (code) { return code; } @@ -439,12 +438,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; + 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 fc3cfbd0f65bc7668679fc23aa8466a11ee9ac81..a5468008aa8b6ce4fd9c52ca4a7f4965c1f0dbc8 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -1726,8 +1726,10 @@ STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowI return w; } - w = getResultRowByPos(pBuf, &pResultRowInfo->cur, false)->win; - + SResultRow* pRow = getResultRowByPos(pBuf, &pResultRowInfo->cur, false); + if (pRow) { + w = pRow->win; + } // in case of typical time window, we can calculate time window directly. if (w.skey > ts || w.ekey < ts) { w = doCalculateTimeWindow(ts, pInterval); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 149efef884b10149bf005407e150380f9f1f0979..72419d8fe414d1be199f6994df061b0ba35694ec 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -83,6 +83,7 @@ typedef struct SAggOperatorInfo { uint64_t groupId; SGroupResInfo groupResInfo; SExprSupp scalarExprSup; + bool groupKeyOptimized; } SAggOperatorInfo; static void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pBlock); @@ -149,6 +150,11 @@ SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, i pData->num = sizeof(SFilePage); } else { pData = getBufPage(pResultBuf, *currentPageId); + if (pData == NULL) { + qError("failed to get buffer, code:%s", tstrerror(terrno)); + return NULL; + } + pageId = *currentPageId; if (pData->num + interBufSize > getBufPageSize(pResultBuf)) { @@ -199,6 +205,10 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR if (isIntervalQuery) { if (p1 != NULL) { // the *p1 may be NULL in case of sliding+offset exists. pResult = getResultRowByPos(pResultBuf, p1, true); + if (NULL == pResult) { + T_LONG_JMP(pTaskInfo->env, terrno); + } + ASSERT(pResult->pageId == p1->pageId && pResult->offset == p1->offset); } } else { @@ -207,6 +217,10 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR if (p1 != NULL) { // todo pResult = getResultRowByPos(pResultBuf, p1, true); + if (NULL == pResult) { + T_LONG_JMP(pTaskInfo->env, terrno); + } + ASSERT(pResult->pageId == p1->pageId && pResult->offset == p1->offset); } } @@ -215,6 +229,10 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR if (pResultRowInfo->cur.pageId != -1 && ((pResult == NULL) || (pResult->pageId != pResultRowInfo->cur.pageId))) { SResultRowPosition pos = pResultRowInfo->cur; SFilePage* pPage = getBufPage(pResultBuf, pos.pageId); + if (pPage == NULL) { + qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo)); + T_LONG_JMP(pTaskInfo->env, terrno); + } releaseBufPage(pResultBuf, pPage); } @@ -222,6 +240,9 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR if (pResult == NULL) { ASSERT(pSup->resultRowSize > 0); pResult = getNewResultRow(pResultBuf, &pSup->currentPageId, pSup->resultRowSize); + if (pResult == NULL) { + T_LONG_JMP(pTaskInfo->env, terrno); + } // add a new result set for a new group SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset}; @@ -259,6 +280,11 @@ static int32_t addNewWindowResultBuf(SResultRow* pWindowRes, SDiskbasedBuf* pRes } else { SPageInfo* pi = getLastPageInfo(list); pData = getBufPage(pResultBuf, getPageId(pi)); + if (pData == NULL) { + qError("failed to get buffer, code:%s", tstrerror(terrno)); + return terrno; + } + pageId = getPageId(pi); if (pData->num + size > getBufPageSize(pResultBuf)) { @@ -604,9 +630,7 @@ void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock* pB } } -bool isTaskKilled(SExecTaskInfo* pTaskInfo) { - return (0 != pTaskInfo->code) ? true : false; -} +bool isTaskKilled(SExecTaskInfo* pTaskInfo) { return (0 != pTaskInfo->code) ? true : false; } void setTaskKilled(SExecTaskInfo* pTaskInfo, int32_t rspCode) { pTaskInfo->code = rspCode; } @@ -913,7 +937,7 @@ void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uin if (pResultRow->pageId == -1) { int32_t ret = addNewWindowResultBuf(pResultRow, pAggInfo->aggSup.pResultBuf, pAggInfo->binfo.pRes->info.rowSize); if (ret != TSDB_CODE_SUCCESS) { - return; + T_LONG_JMP(pTaskInfo->env, terrno); } } @@ -994,6 +1018,11 @@ static void doCopyResultToDataBlock(SExprInfo* pExprInfo, int32_t numOfExprs, SR int32_t finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, SExprSupp* pSup, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) { SFilePage* page = getBufPage(pBuf, resultRowPosition->pageId); + if (page == NULL) { + qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo)); + T_LONG_JMP(pTaskInfo->env, terrno); + } + SResultRow* pRow = (SResultRow*)((char*)page + resultRowPosition->offset); SqlFunctionCtx* pCtx = pSup->pCtx; @@ -1037,6 +1066,10 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprS for (int32_t i = pGroupResInfo->index; i < numOfRows; i += 1) { SResKeyPos* pPos = taosArrayGetP(pGroupResInfo->pRows, i); SFilePage* page = getBufPage(pBuf, pPos->pos.pageId); + if (page == NULL) { + qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo)); + T_LONG_JMP(pTaskInfo->env, terrno); + } SResultRow* pRow = (SResultRow*)((char*)page + pPos->pos.offset); @@ -1349,20 +1382,25 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan } } -static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBlock **ppBlock) { +static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBlock** ppBlock) { if (!tsCountAlwaysReturnValue) { return TSDB_CODE_SUCCESS; } + SAggOperatorInfo* pAggInfo = pOperator->info; + if (pAggInfo->groupKeyOptimized) { + return TSDB_CODE_SUCCESS; + } + SOperatorInfo* downstream = pOperator->pDownstream[0]; if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_PARTITION || (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN && - ((STableScanInfo *)downstream->info)->hasGroupByTag == true)) { + ((STableScanInfo*)downstream->info)->hasGroupByTag == true)) { return TSDB_CODE_SUCCESS; } SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx; - bool hasCountFunc = false; + bool hasCountFunc = false; for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) { const char* pName = pCtx[i].pExpr->pExpr->_function.functionName; @@ -1411,7 +1449,7 @@ static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBloc return TSDB_CODE_SUCCESS; } -static void destroyDataBlockForEmptyInput(bool blockAllocated, SSDataBlock **ppBlock) { +static void destroyDataBlockForEmptyInput(bool blockAllocated, SSDataBlock** ppBlock) { if (!blockAllocated) { return; } @@ -1437,8 +1475,8 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { int32_t order = TSDB_ORDER_ASC; int32_t scanFlag = MAIN_SCAN; - bool hasValidBlock = false; - bool blockAllocated = false; + bool hasValidBlock = false; + bool blockAllocated = false; while (1) { SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); @@ -1481,7 +1519,6 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { } destroyDataBlockForEmptyInput(blockAllocated, &pBlock); - } // the downstream operator may return with error code, so let's check the code before generating results. @@ -1636,7 +1673,7 @@ void cleanupAggSup(SAggSupporter* pAggSup) { } int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize, - const char* pkey) { + const char* pkey, void* pState) { int32_t code = initExprSupp(pSup, pExprInfo, numOfCols); if (code != TSDB_CODE_SUCCESS) { return code; @@ -1648,7 +1685,13 @@ int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo } for (int32_t i = 0; i < numOfCols; ++i) { - pSup->pCtx[i].saveHandle.pBuf = pAggSup->pResultBuf; + if (pState) { + pSup->pCtx[i].saveHandle.pBuf = NULL; + pSup->pCtx[i].saveHandle.pState = pState; + pSup->pCtx[i].exprIdx = i; + } else { + pSup->pCtx[i].saveHandle.pBuf = pAggSup->pResultBuf; + } } return TSDB_CODE_SUCCESS; @@ -1733,7 +1776,8 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiN int32_t num = 0; SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num); - int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str); + int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str, + pTaskInfo->streamInfo.pState); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -1755,11 +1799,13 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiN } pInfo->binfo.mergeResultBlock = pAggNode->mergeDataBlock; + pInfo->groupKeyOptimized = pAggNode->groupKeyOptimized; pInfo->groupId = UINT64_MAX; setOperatorInfo(pOperator, "TableAggregate", QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, true, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, destroyAggOperatorInfo, optrDefaultBufFn, NULL); + pOperator->fpSet = createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, destroyAggOperatorInfo, + optrDefaultBufFn, NULL); if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) { STableScanInfo* pTableScanInfo = downstream->info; diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 59266dad7eef4040f79cb3383974453eb4727324..5676e19cdfa1173bd71f5d33ea05c015e05194ae 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 0cccc75ef56a96e590e09d478d908106e8cc5492..2a90f24346ceae26cbf6bfa27abfc1c5b06d2f99 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 b2aa2269a2fc5f23ed8e7fa86b2fd355bdf5cead..a7f5eb9b22ea09fbcaa8c5d9b85772a27c438e91 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 a88f673e0b33135f41c1fa5e868d61c66942ee9f..ac32b54f56d77795629760e4ebbc15d1bdab2d45 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,84 +1316,112 @@ 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) { - 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)); + pBlock = sysTableScanFromMNode(pOperator, pInfo, name, pTaskInfo); + } - int32_t contLen = tSerializeSRetrieveTableReq(NULL, 0, &pInfo->req); - char* buf1 = taosMemoryCalloc(1, contLen); - tSerializeSRetrieveTableReq(buf1, contLen, &pInfo->req); + return sysTableScanFillTbName(pOperator, pInfo, name, pBlock); +} - // 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; +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; + } +} - int32_t msgType = (strcasecmp(name, TSDB_INS_TABLE_DNODE_VARIABLES) == 0) ? TDMT_DND_SYSTABLE_RETRIEVE - : TDMT_MND_SYSTABLE_RETRIEVE; +static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableScanInfo* pInfo, const char* name, + SExecTaskInfo* pTaskInfo) { + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } - pMsgSendInfo->param = pOperator; - pMsgSendInfo->msgInfo.pData = buf1; - pMsgSendInfo->msgInfo.len = contLen; - pMsgSendInfo->msgType = msgType; - pMsgSendInfo->fp = loadSysTableCallback; - pMsgSendInfo->requestId = pTaskInfo->id.queryId; + 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)); - int64_t transporterId = 0; - int32_t code = - asyncSendMsgToServer(pInfo->readHandle.pMsgCb->clientRpc, &pInfo->epSet, &transporterId, pMsgSendInfo); - tsem_wait(&pInfo->ready); + int32_t contLen = tSerializeSRetrieveTableReq(NULL, 0, &pInfo->req); + char* buf1 = taosMemoryCalloc(1, contLen); + tSerializeSRetrieveTableReq(buf1, contLen, &pInfo->req); - 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; - } + // 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; + } - SRetrieveMetaTableRsp* pRsp = pInfo->pRsp; - pInfo->req.showId = pRsp->handle; + int32_t msgType = (strcasecmp(name, TSDB_INS_TABLE_DNODE_VARIABLES) == 0) ? TDMT_DND_SYSTABLE_RETRIEVE + : TDMT_MND_SYSTABLE_RETRIEVE; - 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); + pMsgSendInfo->param = pOperator; + pMsgSendInfo->msgInfo.pData = buf1; + pMsgSendInfo->msgInfo.len = contLen; + pMsgSendInfo->msgType = msgType; + pMsgSendInfo->fp = loadSysTableCallback; + pMsgSendInfo->requestId = pTaskInfo->id.queryId; - if (pRsp->numOfRows == 0) { - taosMemoryFree(pRsp); - return NULL; - } - } + int64_t transporterId = 0; + int32_t code = + asyncSendMsgToServer(pInfo->readHandle.pMsgCb->clientRpc, &pInfo->epSet, &transporterId, pMsgSendInfo); + tsem_wait(&pInfo->ready); - char* pStart = pRsp->data; - extractDataBlockFromFetchRsp(pInfo->pRes, pRsp->data, pInfo->matchInfo.pList, &pStart); - updateLoadRemoteInfo(&pInfo->loadInfo, pRsp->numOfRows, pRsp->compLen, startTs, pOperator); + 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; + } - // 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) { + 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; + } } } @@ -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 ab1feabf60b235f3df62c6b8e487dff3e7071350..2d921d43d34726b64b0be3dde97a52a95cf19f61 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 0de38fe50083c18bed26f0be5241507bb66e1724..d78e9c4edf06329ccdb6fe1817a67c318ee3041d 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 fa0cdb394377d9308c7fcbb6dfa0b0b553663401..06ef36664a574ea1ff44c3300f5570c37963bed6 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 2efd06f4401b94968e493aa79775544e01bf11b7..913aae6cc3ae489aa725ea255ce9ecce4482a13d 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 a7ac53fab61593240a0859d16b44f4dd27a49ddd..cbda8dc472c2a8e49880b8770b21eccbb0a8eecc 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -32,7 +32,7 @@ typedef struct SSumRes { int16_t type; int64_t prevTs; bool isPrevTsSet; - bool overflow; // if overflow is true, dsum to be used for any type; + bool overflow; // if overflow is true, dsum to be used for any type; } SSumRes; typedef struct SMinmaxResInfo { @@ -46,7 +46,7 @@ typedef struct SMinmaxResInfo { } SMinmaxResInfo; int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc); -STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, const STupleKey* pKey); +STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock); int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos); const char* loadTupleData(SqlFunctionCtx* pCtx, const STuplePos* pPos); diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index d03a7fce75e95f3866c34a44f0da7ff63d5fd9fd..51945d6a0a492509357f1d8198f279c17e1a9e9e 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -41,15 +41,15 @@ #define HLL_BUCKET_MASK (HLL_BUCKETS - 1) #define HLL_ALPHA_INF 0.721347520444481703680 // constant for 0.5/ln(2) -//typedef struct SMinmaxResInfo { -// bool assign; // assign the first value or not -// int64_t v; -// STuplePos tuplePos; +// typedef struct SMinmaxResInfo { +// bool assign; // assign the first value or not +// int64_t v; +// STuplePos tuplePos; // -// STuplePos nullTuplePos; -// bool nullTupleSaved; -// int16_t type; -//} SMinmaxResInfo; +// STuplePos nullTuplePos; +// bool nullTupleSaved; +// int16_t type; +// } SMinmaxResInfo; typedef struct STopBotResItem { SVariant v; @@ -540,7 +540,7 @@ int32_t countFunction(SqlFunctionCtx* pCtx) { if (IS_NULL_TYPE(type)) { // select count(NULL) returns 0 numOfElem = 1; - *((int64_t*)buf) = 0; + *((int64_t*)buf) += 0; } else { numOfElem = getNumOfElems(pCtx); *((int64_t*)buf) += numOfElem; @@ -784,7 +784,7 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { pEntryInfo->isNullRes = (pEntryInfo->numOfRes == 0) ? 1 : 0; if (pCol->info.type == TSDB_DATA_TYPE_FLOAT) { - float v = *(float*)&pRes->v; + float v = GET_FLOAT_VAL(&pRes->v); colDataAppend(pCol, currentRow, (const char*)&v, pEntryInfo->isNullRes); } else { colDataAppend(pCol, currentRow, (const char*)&pRes->v, pEntryInfo->isNullRes); @@ -818,28 +818,31 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple return; } - if (pCtx->saveHandle.pBuf != NULL) { - if (pTuplePos->pageId != -1) { - int32_t numOfCols = pCtx->subsidiaries.num; - const char* p = loadTupleData(pCtx, pTuplePos); + if ((pCtx->saveHandle.pBuf != NULL && pTuplePos->pageId != -1) || + (pCtx->saveHandle.pState && pTuplePos->streamTupleKey.ts > 0)) { + int32_t numOfCols = pCtx->subsidiaries.num; + const char* p = loadTupleData(pCtx, pTuplePos); - bool* nullList = (bool*)p; - char* pStart = (char*)(nullList + numOfCols * sizeof(bool)); + bool* nullList = (bool*)p; + char* pStart = (char*)(nullList + numOfCols * sizeof(bool)); - // todo set the offset value to optimize the performance. - for (int32_t j = 0; j < numOfCols; ++j) { - SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j]; - int32_t dstSlotId = pc->pExpr->base.resSchema.slotId; + // todo set the offset value to optimize the performance. + for (int32_t j = 0; j < numOfCols; ++j) { + SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j]; + int32_t dstSlotId = pc->pExpr->base.resSchema.slotId; - SColumnInfoData* pDstCol = taosArrayGet(pBlock->pDataBlock, dstSlotId); - ASSERT(pc->pExpr->base.resSchema.bytes == pDstCol->info.bytes); - if (nullList[j]) { - colDataAppendNULL(pDstCol, rowIndex); - } else { - colDataAppend(pDstCol, rowIndex, pStart, false); - } - pStart += pDstCol->info.bytes; + SColumnInfoData* pDstCol = taosArrayGet(pBlock->pDataBlock, dstSlotId); + ASSERT(pc->pExpr->base.resSchema.bytes == pDstCol->info.bytes); + if (nullList[j]) { + colDataAppendNULL(pDstCol, rowIndex); + } else { + colDataAppend(pDstCol, rowIndex, pStart, false); } + pStart += pDstCol->info.bytes; + } + + if (pCtx->saveHandle.pState) { + tdbFree((void*)p); } } } @@ -2018,7 +2021,7 @@ static void firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowInde } if (!pInfo->hasResult) { - pInfo->pos = saveTupleData(pCtx, rowIndex, pSrcBlock, NULL); + pInfo->pos = saveTupleData(pCtx, rowIndex, pSrcBlock); } else { updateTupleData(pCtx, rowIndex, pSrcBlock, &pInfo->pos); } @@ -2071,8 +2074,8 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC; - // please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first function. - // we will use this opt implementation in an new version that is only available in scan subplan + // please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first + // function. we will use this opt implementation in an new version that is only available in scan subplan #if 0 if (blockDataOrder == TSDB_ORDER_ASC) { // filter according to current result firstly @@ -2179,7 +2182,8 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC; - // please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first function. + // please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first + // function. #if 0 if (blockDataOrder == TSDB_ORDER_ASC) { for (int32_t i = pInput->numOfRows + pInput->startRowIndex - 1; i >= pInput->startRowIndex; --i) { @@ -2236,9 +2240,9 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { int32_t round = pInput->numOfRows >> 2; int32_t reminder = pInput->numOfRows & 0x03; - for (int32_t i = pInput->startRowIndex, tick = 0; tick < round; i += 4, tick += 1) { - int64_t cts = pts[i]; - int32_t chosen = i; + for (int32_t i = pInput->startRowIndex, tick = 0; tick < round; i += 4, tick += 1) { + int64_t cts = pts[i]; + int32_t chosen = i; if (cts < pts[i + 1]) { cts = pts[i + 1]; @@ -2262,18 +2266,18 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { } } - for (int32_t i = pInput->startRowIndex + round * 4; i < pInput->startRowIndex + pInput->numOfRows; ++i) { - if (pResInfo->numOfRes == 0 || pInfo->ts < pts[i]) { - char* data = colDataGetData(pInputCol, i); - doSaveCurrentVal(pCtx, i, pts[i], type, data); - pResInfo->numOfRes = 1; - } + for (int32_t i = pInput->startRowIndex + round * 4; i < pInput->startRowIndex + pInput->numOfRows; ++i) { + if (pResInfo->numOfRes == 0 || pInfo->ts < pts[i]) { + char* data = colDataGetData(pInputCol, i); + doSaveCurrentVal(pCtx, i, pts[i], type, data); + pResInfo->numOfRes = 1; + } + } + } else { + for (int32_t i = pInput->startRowIndex; i < pInput->startRowIndex + pInput->numOfRows; ++i) { + if (colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) { + continue; } - } else { - for (int32_t i = pInput->startRowIndex; i < pInput->startRowIndex + pInput->numOfRows; ++i) { - if (colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) { - continue; - } numOfElems++; @@ -2439,7 +2443,7 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pInputCol = pInput->pData[0]; - int32_t type = pInputCol->info.type; + int32_t type = pInputCol->info.type; int32_t bytes = pInputCol->info.bytes; pInfo->bytes = bytes; @@ -2777,7 +2781,7 @@ int32_t topFunction(SqlFunctionCtx* pCtx) { } if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pRes->nullTupleSaved) { - pRes->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL); + pRes->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock); pRes->nullTupleSaved = true; } return TSDB_CODE_SUCCESS; @@ -2805,7 +2809,7 @@ int32_t bottomFunction(SqlFunctionCtx* pCtx) { } if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pRes->nullTupleSaved) { - pRes->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL); + pRes->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock); pRes->nullTupleSaved = true; } @@ -2863,7 +2867,7 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData // save the data of this tuple if (pCtx->subsidiaries.num > 0) { - pItem->tuplePos = saveTupleData(pCtx, rowIndex, pSrcBlock, NULL); + pItem->tuplePos = saveTupleData(pCtx, rowIndex, pSrcBlock); } #ifdef BUF_PAGE_DEBUG qDebug("page_saveTuple i:%d, item:%p,pageId:%d, offset:%d\n", pEntryInfo->numOfRes, pItem, pItem->tuplePos.pageId, @@ -2937,8 +2941,7 @@ void* serializeTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SSubsid return buf; } -static STuplePos doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length, - const STupleKey* pKey) { +static STuplePos doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length, STupleKey key) { STuplePos p = {0}; if (pHandle->pBuf != NULL) { SFilePage* pPage = NULL; @@ -2964,20 +2967,31 @@ static STuplePos doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf releaseBufPage(pHandle->pBuf, pPage); } else { // other tuple save policy - if (streamStateFuncPut(pHandle->pState, pKey, pBuf, length) < 0) { + if (streamStateFuncPut(pHandle->pState, &key, pBuf, length) < 0) { ASSERT(0); } - p.streamTupleKey = *pKey; + p.streamTupleKey = key; } return p; } -STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, const STupleKey* pKey) { +STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock) { prepareBuf(pCtx); + STupleKey key; + if (pCtx->saveHandle.pBuf == NULL) { + SColumnInfoData* pColInfo = taosArrayGet(pSrcBlock->pDataBlock, 0); + ASSERT(pColInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP); + int64_t skey = *(int64_t*)colDataGetData(pColInfo, rowIndex); + + key.groupId = pSrcBlock->info.id.groupId; + key.ts = skey; + key.exprIdx = pCtx->exprIdx; + } + char* buf = serializeTupleData(pSrcBlock, rowIndex, &pCtx->subsidiaries, pCtx->subsidiaries.buf); - return doSaveTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, pKey); + return doSaveTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, key); } static int32_t doUpdateTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length, STuplePos* pPos) { @@ -3623,7 +3637,7 @@ bool histogramFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultIn pInfo->totalCount = 0; pInfo->normalized = 0; - char *binTypeStr = strndup(varDataVal(pCtx->param[1].param.pz), varDataLen(pCtx->param[1].param.pz)); + char* binTypeStr = strndup(varDataVal(pCtx->param[1].param.pz), varDataLen(pCtx->param[1].param.pz)); int8_t binType = getHistogramBinType(binTypeStr); taosMemoryFree(binTypeStr); @@ -3947,7 +3961,6 @@ int32_t hllFunctionMerge(SqlFunctionCtx* pCtx) { int32_t start = pInput->startRowIndex; - for (int32_t i = start; i < start + pInput->numOfRows; ++i) { char* data = colDataGetData(pCol, i); SHLLInfo* pInputInfo = (SHLLInfo*)varDataVal(data); @@ -4423,7 +4436,7 @@ static void doReservoirSample(SqlFunctionCtx* pCtx, SSampleInfo* pInfo, char* da if (pInfo->numSampled < pInfo->samples) { sampleAssignResult(pInfo, data, pInfo->numSampled); if (pCtx->subsidiaries.num > 0) { - pInfo->tuplePos[pInfo->numSampled] = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL); + pInfo->tuplePos[pInfo->numSampled] = saveTupleData(pCtx, index, pCtx->pSrcBlock); } pInfo->numSampled++; } else { @@ -4454,7 +4467,7 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) { } if (pInfo->numSampled == 0 && pCtx->subsidiaries.num > 0 && !pInfo->nullTupleSaved) { - pInfo->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL); + pInfo->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock); pInfo->nullTupleSaved = true; } @@ -4758,7 +4771,7 @@ static void doModeAdd(SModeInfo* pInfo, int32_t rowIndex, SqlFunctionCtx* pCtx, pItem->count += 1; if (pCtx->subsidiaries.num > 0) { - pItem->tuplePos = saveTupleData(pCtx, rowIndex, pCtx->pSrcBlock, NULL); + pItem->tuplePos = saveTupleData(pCtx, rowIndex, pCtx->pSrcBlock); } taosHashPut(pInfo->pHash, data, hashKeyBytes, &pItem, sizeof(SModeItem*)); @@ -4798,7 +4811,7 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) { } if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pInfo->nullTupleSaved) { - pInfo->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL); + pInfo->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock); pInfo->nullTupleSaved = true; } @@ -5192,6 +5205,7 @@ int32_t blockDistFunction(SqlFunctionCtx* pCtx) { pDistInfo->numOfBlocks += p1.numOfBlocks; pDistInfo->numOfTables += p1.numOfTables; pDistInfo->numOfInmemRows += p1.numOfInmemRows; + pDistInfo->numOfVgroups += p1.numOfVgroups; pDistInfo->totalSize += p1.totalSize; pDistInfo->totalRows += p1.totalRows; pDistInfo->numOfFiles += p1.numOfFiles; @@ -5226,6 +5240,7 @@ int32_t tSerializeBlockDistInfo(void* buf, int32_t bufLen, const STableBlockDist if (tEncodeU16(&encoder, pInfo->numOfFiles) < 0) return -1; if (tEncodeU32(&encoder, pInfo->numOfBlocks) < 0) return -1; if (tEncodeU32(&encoder, pInfo->numOfTables) < 0) return -1; + if (tEncodeU32(&encoder, pInfo->numOfVgroups) < 0) return -1; if (tEncodeU64(&encoder, pInfo->totalSize) < 0) return -1; if (tEncodeU64(&encoder, pInfo->totalRows) < 0) return -1; @@ -5257,6 +5272,7 @@ int32_t tDeserializeBlockDistInfo(void* buf, int32_t bufLen, STableBlockDistInfo if (tDecodeU16(&decoder, &pInfo->numOfFiles) < 0) return -1; if (tDecodeU32(&decoder, &pInfo->numOfBlocks) < 0) return -1; if (tDecodeU32(&decoder, &pInfo->numOfTables) < 0) return -1; + if (tDecodeU32(&decoder, &pInfo->numOfVgroups) < 0) return -1; if (tDecodeU64(&decoder, &pInfo->totalSize) < 0) return -1; if (tDecodeU64(&decoder, &pInfo->totalRows) < 0) return -1; @@ -5299,7 +5315,7 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t len = sprintf(st + VARSTR_HEADER_SIZE, "Total_Blocks=[%d] Total_Size=[%.2f Kb] Average_size=[%.2f Kb] Compression_Ratio=[%.2f %c]", - pData->numOfBlocks, pData->totalSize / 1024.0, averageSize/1024.0, compRatio, '%'); + pData->numOfBlocks, pData->totalSize / 1024.0, averageSize / 1024.0, compRatio, '%'); varDataSetLen(st, len); colDataAppend(pColInfo, row++, st, false); @@ -5317,7 +5333,7 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { colDataAppend(pColInfo, row++, st, false); len = sprintf(st + VARSTR_HEADER_SIZE, "Total_Tables=[%d] Total_Files=[%d] Total_Vgroups=[%d]", pData->numOfTables, - pData->numOfFiles, 0); + pData->numOfFiles, pData->numOfVgroups); varDataSetLen(st, len); colDataAppend(pColInfo, row++, st, false); diff --git a/source/libs/function/src/detail/tminmax.c b/source/libs/function/src/detail/tminmax.c index cb5cea3cc851692a2a348ff2319f00d96b360119..3660ec272f31055cfca56ecbdd49b027f5de5a5b 100644 --- a/source/libs/function/src/detail/tminmax.c +++ b/source/libs/function/src/detail/tminmax.c @@ -64,7 +64,7 @@ static void calculateRounds(int32_t numOfRows, int32_t bytes, int32_t* remainder, int32_t* rounds, int32_t* width) { const int32_t bitWidth = 256; - *width = (bitWidth>>3u) / bytes; + *width = (bitWidth >> 3u) / bytes; *remainder = numOfRows % (*width); *rounds = numOfRows / (*width); } @@ -92,8 +92,7 @@ static void calculateRounds(int32_t numOfRows, int32_t bytes, int32_t* remainder (_v) = (_sec)[j]; \ } \ } - - + static int8_t i8VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFunc, bool signVal) { int8_t v = 0; const int8_t* p = pData; @@ -116,7 +115,7 @@ static int8_t i8VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFu const int8_t* q = (const int8_t*)&initVal; EXTRACT_MAX_VAL(q, p, width, remain, v) - } else { // unsigned value + } else { // unsigned value for (int32_t i = 0; i < rounds; ++i) { next = _mm256_lddqu_si256((__m256i*)p); initVal = _mm256_max_epu8(initVal, next); @@ -126,7 +125,7 @@ static int8_t i8VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFu const uint8_t* q = (const uint8_t*)&initVal; EXTRACT_MAX_VAL(q, p, width, remain, v) } - + } else { // min function if (signVal) { for (int32_t i = 0; i < rounds; ++i) { @@ -241,7 +240,7 @@ static int32_t i32VectorCmpAVX2(const int32_t* pData, int32_t numOfRows, bool is // let compare the final results const int32_t* q = (const int32_t*)&initVal; EXTRACT_MAX_VAL(q, p, width, remain, v) - } else { // unsigned value + } else { // unsigned value for (int32_t i = 0; i < rounds; ++i) { next = _mm256_lddqu_si256((__m256i*)p); initVal = _mm256_max_epi32(initVal, next); @@ -281,7 +280,7 @@ static int32_t i32VectorCmpAVX2(const int32_t* pData, int32_t numOfRows, bool is } static float floatVectorCmpAVX(const float* pData, int32_t numOfRows, bool isMinFunc) { - float v = 0; + float v = 0; const float* p = pData; int32_t width, remain, rounds; @@ -358,7 +357,7 @@ static double doubleVectorCmpAVX(const double* pData, int32_t numOfRows, bool is static int32_t findFirstValPosition(const SColumnInfoData* pCol, int32_t start, int32_t numOfRows) { int32_t i = start; - + while (i < (start + numOfRows) && (colDataIsNull_f(pCol->nullbitmap, i) == true)) { i += 1; } @@ -495,7 +494,8 @@ static void handleInt64Col(const void* data, int32_t start, int32_t numOfRows, S } } -static void handleFloatCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf, bool isMinFunc) { +static void handleFloatCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf, + bool isMinFunc) { float* pData = (float*)pCol->pData; float* val = (float*)&pBuf->v; @@ -525,7 +525,8 @@ static void handleFloatCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRo pBuf->assign = true; } -static void handleDoubleCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf, bool isMinFunc) { +static void handleDoubleCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf, + bool isMinFunc) { double* pData = (double*)pCol->pData; double* val = (double*)&pBuf->v; @@ -736,11 +737,16 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { } if (!pBuf->assign) { - pBuf->v = *(int64_t*)tval; + if (type == TSDB_DATA_TYPE_FLOAT) { + GET_FLOAT_VAL(&pBuf->v) = GET_DOUBLE_VAL(tval); + } else { + pBuf->v = GET_INT64_VAL(tval); + } + if (pCtx->subsidiaries.num > 0) { index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); if (index >= 0) { - pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL); + pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock); } } } else { @@ -750,11 +756,11 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { int64_t val = GET_INT64_VAL(tval); if ((prev < val) ^ isMinFunc) { - *(int64_t*)&pBuf->v = val; + GET_INT64_VAL(&pBuf->v) = val; if (pCtx->subsidiaries.num > 0) { index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); if (index >= 0) { - pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL); + pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock); } } } @@ -764,11 +770,11 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { uint64_t val = GET_UINT64_VAL(tval); if ((prev < val) ^ isMinFunc) { - *(uint64_t*)&pBuf->v = val; + GET_UINT64_VAL(&pBuf->v) = val; if (pCtx->subsidiaries.num > 0) { index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); if (index >= 0) { - pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL); + pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock); } } } @@ -778,11 +784,11 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { double val = GET_DOUBLE_VAL(tval); if ((prev < val) ^ isMinFunc) { - *(double*)&pBuf->v = val; + GET_DOUBLE_VAL(&pBuf->v) = val; if (pCtx->subsidiaries.num > 0) { index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); if (index >= 0) { - pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL); + pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock); } } } @@ -792,13 +798,13 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { float val = GET_DOUBLE_VAL(tval); if ((prev < val) ^ isMinFunc) { - *(float*)&pBuf->v = val; + GET_FLOAT_VAL(&pBuf->v) = val; } if (pCtx->subsidiaries.num > 0) { index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); if (index >= 0) { - pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL); + pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock); } } } @@ -819,7 +825,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { memcpy(&pBuf->v, pCol->pData + (pCol->info.bytes * i), pCol->info.bytes); if (pCtx->subsidiaries.num > 0) { - pBuf->tuplePos = saveTupleData(pCtx, i, pCtx->pSrcBlock, NULL); + pBuf->tuplePos = saveTupleData(pCtx, i, pCtx->pSrcBlock); } pBuf->assign = true; numOfElems = 1; @@ -883,9 +889,9 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { _over: if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pBuf->nullTupleSaved) { - pBuf->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, NULL); + pBuf->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock); pBuf->nullTupleSaved = true; } return numOfElems; -} \ No newline at end of file +} diff --git a/source/libs/function/src/tfunctionInt.c b/source/libs/function/src/tfunctionInt.c index 70378df0c3315c03989ae673ec50ecf1a47d8278..3afa0e5cdd402d43fa4a415468c4eda76a971e36 100644 --- a/source/libs/function/src/tfunctionInt.c +++ b/source/libs/function/src/tfunctionInt.c @@ -20,7 +20,6 @@ #include "ttypes.h" #include "function.h" -#include "tbuffer.h" #include "tcompression.h" #include "tdatablock.h" #include "tfunctionInt.h" diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index acfd5c07af0cd5c54d28ef24d586b18fbab99a20..c9fa70ff11a6909022623affd3a0ebf1850837f5 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 6c88e4d5c8615d262db99d3e0ab5e476269820a4..fe6ed7d785c7b6a6d99adbe9f930294bf8b950ef 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -400,7 +400,6 @@ void udfdProcessTeardownRequest(SUvUdfWork *uvUdf, SUdfRequest *request) { void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { SUdfdRpcSendRecvInfo *msgInfo = (SUdfdRpcSendRecvInfo *)pMsg->info.ahandle; - ASSERT(pMsg->info.ahandle != NULL); if (pEpSet) { if (!isEpsetEqual(&global.mgmtEp.epSet, pEpSet)) { @@ -461,13 +460,14 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { #else snprintf(path, sizeof(path), "%s/lib%s.so", tsTempDir, pFuncInfo->name); #endif - TdFilePtr file = - taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC | TD_FILE_AUTO_DEL); + + TdFilePtr file = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC); if (file == NULL) { fnError("udfd write udf shared library: %s failed, error: %d %s", path, errno, strerror(errno)); msgInfo->code = TSDB_CODE_FILE_CORRUPTED; goto _return; } + int64_t count = taosWriteFile(file, pFuncInfo->pCode, pFuncInfo->codeSize); if (count != pFuncInfo->codeSize) { fnError("udfd write udf shared library failed"); diff --git a/source/libs/index/inc/indexUtil.h b/source/libs/index/inc/indexUtil.h index dbaecaa9630b04b8b50f108c1a59e499f04899dc..148a521d5ac9ed12e566338da96f0755c2420eb4 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 76dc84ae42a3d38bea29b030be12a240bd3f510d..a99c87b7f9a5bef05c8e641ab4aa826e7c5e7dfc 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 e3f140047ab1fa02b328813293300096386cc4d6..c2ac7f4478a6200d9408432e591132fed87a0208 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 07696c38225796978cecb02aca2f65de5bf93558..5c14424b7ecb56a45405cd48daa018a5f8837da9 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 bbffcfa6c17aa628b0afc79ba96746d764add523..f3b7b2fbae9dc05db6645ba92b96bbaf04f212e2 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 8ce0ba1e69eb069cfe7b3c2009107d0eea5d5019..4d348e76f25eb9ec4575b536f2b5de73f1fabe6a 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 4620af8694e538a3525adaed11a1277ec14cd0a9..5a9c8dfe3d3906bd452111bf885e62b65638f6e5 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 e0abcadc78a07b0f69ef92003d4304141551865e..adafecccb13dd6928b6ef4bd2ee2df0ce8aedf2a 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 b1a919b365742791fc7daaae1f6ea47f9b012477..f1e8808cf522cd75525562971c3854de383c50f0 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 b34d05d297e26f03d5af40e8b440241cf55ed714..d921ca7103c55d51421a10818b2b23964854869c 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 fb9560341e3f9f2ff89deb9375cd2a28933a6334..12041bd2ae8557a1832c735b128fd4ca7861106f 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -409,6 +409,7 @@ static int32_t logicAggCopy(const SAggLogicNode* pSrc, SAggLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pGroupKeys); CLONE_NODE_LIST_FIELD(pAggFuncs); + COPY_SCALAR_FIELD(hasGroupKeyOptimized); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 20ba3694b63105109d16d661200d98c50ef9089b..05505a04449d67ab6e1b208503cadfeca2652f3c 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -175,6 +175,10 @@ const char* nodesNodeName(ENodeType type) { return "BalanceVgroupStmt"; case QUERY_NODE_MERGE_VGROUP_STMT: return "MergeVgroupStmt"; + case QUERY_NODE_SHOW_DB_ALIVE_STMT: + return "ShowDbAliveStmt"; + case QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT: + return "ShowClusterAliveStmt"; case QUERY_NODE_REDISTRIBUTE_VGROUP_STMT: return "RedistributeVgroupStmt"; case QUERY_NODE_SPLIT_VGROUP_STMT: @@ -1916,6 +1920,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; @@ -1933,6 +1938,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; } @@ -1953,6 +1961,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 f5e4bc1ea4ddeff6b6e408c71856435b5db9845f..a4b77fad6928cdb46c52e44266f74c1f3ec6fb46 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/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index fd8ae0ae48e458b971ea7270bfccc98b7ac172a4..15286aa42a58cd13dafe5cdb8436140f0e1389cf 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -434,6 +434,9 @@ SNode* nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SShowDnodeVariablesStmt)); case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: return makeNode(type, sizeof(SShowCreateDatabaseStmt)); + case QUERY_NODE_SHOW_DB_ALIVE_STMT: + case QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT: + return makeNode(type, sizeof(SShowAliveStmt)); case QUERY_NODE_SHOW_CREATE_TABLE_STMT: case QUERY_NODE_SHOW_CREATE_STABLE_STMT: return makeNode(type, sizeof(SShowCreateTableStmt)); @@ -960,6 +963,8 @@ void nodesDestroyNode(SNode* pNode) { case QUERY_NODE_SHOW_USERS_STMT: case QUERY_NODE_SHOW_LICENCES_STMT: case QUERY_NODE_SHOW_VGROUPS_STMT: + case QUERY_NODE_SHOW_DB_ALIVE_STMT: + case QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT: case QUERY_NODE_SHOW_TOPICS_STMT: case QUERY_NODE_SHOW_CONSUMERS_STMT: case QUERY_NODE_SHOW_CONNECTIONS_STMT: diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 3d91c20dceca60baa6baf3effcc8c0fb861bfb53..3b309db1db61b1d1e99918962fe73bd1ffa5cb09 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -177,6 +177,7 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type); SNode* createShowStmtWithCond(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbName, EOperatorType tableCondType); SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName); +SNode* createShowAliveStmt(SAstCreateContext* pCxt, SNode* pDbName, ENodeType type); SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable); SNode* createShowTableDistributedStmt(SAstCreateContext* pCxt, SNode* pRealTable); SNode* createShowDnodeVariablesStmt(SAstCreateContext* pCxt, SNode* pDnodeId, SNode* pLikePattern); @@ -188,6 +189,7 @@ SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName); SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort); SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, bool force); SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue); +SNode* createRealTableNodeForIndexName(SAstCreateContext* pCxt, SToken* pDbName, SToken* pIndexName); SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SNode* pIndexName, SNode* pRealTable, SNodeList* pCols, SNode* pOptions); SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding, @@ -195,15 +197,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); @@ -215,9 +215,9 @@ SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool const SToken* pLibPath, SDataType dataType, int32_t bufSize); SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pFuncName); SNode* createStreamOptions(SAstCreateContext* pCxt); -SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable, - SNode* pOptions, SNodeList* pTags, SNode* pSubtable, SNode* pQuery); -SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pStreamName); +SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken* pStreamName, SNode* pRealTable, + SNode* pOptions, SNodeList* pTags, SNode* pSubtable, SNode* pQuery, SNodeList* pCols); +SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, 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 26f9eb7f75c13ee4c90cf18a57734575f290167c..2b93176fae784356dde7e1cafa2c42da280dfc13 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -434,6 +434,9 @@ cmd ::= SHOW TAGS FROM table_name_cond(A) from_db_opt(B). cmd ::= SHOW TABLE TAGS tag_list_opt(C) FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowTableTagsStmt(pCxt, A, B, C); } cmd ::= SHOW VNODES NK_INTEGER(A). { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &A), NULL); } cmd ::= SHOW VNODES NK_STRING(A). { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, createValueNode(pCxt, TSDB_DATA_TYPE_VARCHAR, &A)); } +// show alive +cmd ::= SHOW db_name_cond_opt(A) ALIVE. { pCxt->pRootNode = createShowAliveStmt(pCxt, A, QUERY_NODE_SHOW_DB_ALIVE_STMT); } +cmd ::= SHOW CLUSTER ALIVE. { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); } db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createIdentifierValueNode(pCxt, &B); } @@ -460,10 +463,13 @@ tag_item(A) ::= column_name(B) AS column_alias(C). /************************************************ create index ********************************************************/ cmd ::= CREATE SMA INDEX not_exists_opt(D) - full_table_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); } + full_index_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); } cmd ::= CREATE INDEX not_exists_opt(D) - full_table_name(A) ON full_table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, D, A, B, C, NULL); } -cmd ::= DROP INDEX exists_opt(B) full_table_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, A); } + full_index_name(A) ON full_table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, D, A, B, C, NULL); } +cmd ::= DROP INDEX exists_opt(B) full_index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, A); } + +full_index_name(A) ::= index_name(B). { A = createRealTableNodeForIndexName(pCxt, NULL, &B); } +full_index_name(A) ::= db_name(B) NK_DOT index_name(C). { A = createRealTableNodeForIndexName(pCxt, &B, &C); } index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL NK_LP duration_literal(C) NK_RP sliding_opt(D) sma_stream_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D, E); } @@ -539,9 +545,15 @@ bufsize_opt(A) ::= BUFSIZE NK_INTEGER(B). /************************************************ create/drop stream **************************************************/ cmd ::= CREATE STREAM not_exists_opt(E) stream_name(A) stream_options(B) INTO - full_table_name(C) tags_def_opt(F) subtable_opt(G) AS query_or_subquery(D). { pCxt->pRootNode = createCreateStreamStmt(pCxt, E, &A, C, B, F, G, D); } + full_table_name(C) col_list_opt(H) tags_def_opt(F) subtable_opt(G) + AS query_or_subquery(D). { pCxt->pRootNode = createCreateStreamStmt(pCxt, E, &A, C, B, F, G, D, H); } cmd ::= DROP STREAM exists_opt(A) stream_name(B). { pCxt->pRootNode = createDropStreamStmt(pCxt, A, &B); } +%type col_list_opt { SNodeList* } +%destructor col_list_opt { nodesDestroyList($$); } +col_list_opt(A) ::= . { A = NULL; } +col_list_opt(A) ::= NK_LP col_name_list(B) NK_RP. { A = B; } + stream_options(A) ::= . { A = createStreamOptions(pCxt); } stream_options(A) ::= stream_options(B) TRIGGER AT_ONCE. { ((SStreamOptions*)B)->triggerType = STREAM_TRIGGER_AT_ONCE; A = B; } stream_options(A) ::= stream_options(B) TRIGGER WINDOW_CLOSE. { ((SStreamOptions*)B)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; A = B; } @@ -665,6 +677,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 9a4dfe13a71e95224117c792b8b34fb7e803a2c9..b3adcc817bf77ff6841c8e9ee82e16a1ceffbd9f 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; @@ -1381,6 +1399,38 @@ SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName) { return (SNode*)pStmt; } +SNode* createShowAliveStmt(SAstCreateContext* pCxt, SNode* pNode, ENodeType type) { + CHECK_PARSER_STATUS(pCxt); + SToken dbToken = {0}; + SToken* pDbToken = NULL; + + if (pNode) { + SValueNode* pDbName = (SValueNode*)pNode; + if (pDbName->literal) { + dbToken.z = pDbName->literal; + dbToken.n = strlen(pDbName->literal); + pDbToken = &dbToken; + } + } + + if (pDbToken && !checkDbName(pCxt, pDbToken, true)) { + nodesDestroyNode(pNode); + return NULL; + } + + SShowAliveStmt* pStmt = (SShowAliveStmt*)nodesMakeNode(type); + CHECK_OUT_OF_MEM(pStmt); + + if (pDbToken) { + COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbToken); + } + if (pNode) { + nodesDestroyNode(pNode); + } + + return (SNode*)pStmt; +} + SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable) { CHECK_PARSER_STATUS(pCxt); SShowCreateTableStmt* pStmt = (SShowCreateTableStmt*)nodesMakeNode(type); @@ -1534,6 +1584,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); @@ -1592,9 +1649,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); @@ -1603,10 +1662,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); @@ -1618,9 +1677,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); @@ -1632,8 +1694,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); @@ -1642,8 +1707,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; @@ -1748,27 +1816,32 @@ SNode* createStreamOptions(SAstCreateContext* pCxt) { return (SNode*)pOptions; } -SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable, - SNode* pOptions, SNodeList* pTags, SNode* pSubtable, SNode* pQuery) { +SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken* pStreamName, SNode* pRealTable, + SNode* pOptions, SNodeList* pTags, SNode* pSubtable, SNode* pQuery, SNodeList* pCols) { CHECK_PARSER_STATUS(pCxt); + if (!checkStreamName(pCxt, pStreamName)) { + return NULL; + } SCreateStreamStmt* pStmt = (SCreateStreamStmt*)nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT); CHECK_OUT_OF_MEM(pStmt); COPY_STRING_FORM_ID_TOKEN(pStmt->streamName, pStreamName); - if (NULL != pRealTable) { - strcpy(pStmt->targetDbName, ((SRealTableNode*)pRealTable)->table.dbName); - strcpy(pStmt->targetTabName, ((SRealTableNode*)pRealTable)->table.tableName); - nodesDestroyNode(pRealTable); - } + strcpy(pStmt->targetDbName, ((SRealTableNode*)pRealTable)->table.dbName); + strcpy(pStmt->targetTabName, ((SRealTableNode*)pRealTable)->table.tableName); + nodesDestroyNode(pRealTable); pStmt->ignoreExists = ignoreExists; pStmt->pOptions = (SStreamOptions*)pOptions; pStmt->pQuery = pQuery; pStmt->pTags = pTags; pStmt->pSubtable = pSubtable; + pStmt->pCols = pCols; 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/parAstParser.c b/source/libs/parser/src/parAstParser.c index 954e6c26fd6850ea8d870b09d09040828dd856dc..fae62626fa3666909208ce9220215baea8be3810 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -355,7 +355,12 @@ static int32_t collectMetaKeyFromDescribe(SCollectMetaKeyCxt* pCxt, SDescribeStm } static int32_t collectMetaKeyFromCreateStream(SCollectMetaKeyCxt* pCxt, SCreateStreamStmt* pStmt) { - return collectMetaKeyFromQuery(pCxt, pStmt->pQuery); + int32_t code = + reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->targetDbName, pStmt->targetTabName, pCxt->pMetaCache); + if (TSDB_CODE_SUCCESS == code) { + code = collectMetaKeyFromQuery(pCxt, pStmt->pQuery); + } + return code; } static int32_t collectMetaKeyFromShowDnodes(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { diff --git a/source/libs/parser/src/parAuthenticator.c b/source/libs/parser/src/parAuthenticator.c index d99d7d744579836def251114671c2c58b45259df..e4de60fd051d6f7f4e781160305ffb95a3ec7d3e 100644 --- a/source/libs/parser/src/parAuthenticator.c +++ b/source/libs/parser/src/parAuthenticator.c @@ -145,6 +145,8 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) { case QUERY_NODE_SHOW_CLUSTER_STMT: case QUERY_NODE_SHOW_LICENCES_STMT: case QUERY_NODE_SHOW_VGROUPS_STMT: + case QUERY_NODE_SHOW_DB_ALIVE_STMT: + case QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT: case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT: case QUERY_NODE_SHOW_VNODES_STMT: diff --git a/source/libs/parser/src/parInsertSml.c b/source/libs/parser/src/parInsertSml.c index b5baa54f77c13dd4403f9a43f86ab304b13d6813..e613739f261e0bb8599511f857eb28751508e48b 100644 --- a/source/libs/parser/src/parInsertSml.c +++ b/source/libs/parser/src/parInsertSml.c @@ -189,14 +189,23 @@ int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void* data, int32 SSchema* pColSchema = schema + index; SColVal* pVal = taosArrayGet(pTableCxt->pValues, index); SSmlKv* kv = (SSmlKv*)data; + if(kv->keyLen != strlen(pColSchema->name) || memcmp(kv->key, pColSchema->name, kv->keyLen) != 0){ + ret = TSDB_CODE_SML_INVALID_DATA; + goto end; + } if (kv->type == TSDB_DATA_TYPE_NCHAR) { int32_t len = 0; - char* pUcs4 = taosMemoryCalloc(1, pColSchema->bytes - VARSTR_HEADER_SIZE); + int64_t size = pColSchema->bytes - VARSTR_HEADER_SIZE; + if(size <= 0){ + ret = TSDB_CODE_SML_INVALID_DATA; + goto end; + } + char* pUcs4 = taosMemoryCalloc(1, size); if (NULL == pUcs4) { ret = TSDB_CODE_OUT_OF_MEMORY; goto end; } - if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)pUcs4, pColSchema->bytes - VARSTR_HEADER_SIZE, &len)) { + if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)pUcs4, size, &len)) { if (errno == E2BIG) { ret = TSDB_CODE_PAR_VALUE_TOO_LONG; goto end; diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 95922ae67bfff0141990338d1d7bb78524868fb0..48c77b5805bd2c38e3c37c694d67e91cabcdbc80 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -270,6 +270,7 @@ static SKeyword keywordTable[] = { {"_WDURATION", TK_WDURATION}, {"_WEND", TK_WEND}, {"_WSTART", TK_WSTART}, + {"ALIVE", TK_ALIVE}, }; // clang-format on diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 8187d42ac644ac567708af4e8532319b0ae51ae1..6f4d74f68b3ea9b5d5cb05f3b2b124d7fe54242f 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -352,7 +352,7 @@ static int32_t getTableMetaImpl(STranslateContext* pCxt, const SName* pName, STa code = catalogGetTableMeta(pParCxt->pCatalog, &conn, pName, pMeta); } } - if (TSDB_CODE_SUCCESS != code && TSDB_CODE_TSC_INVALID_TABLE_NAME != code) { + if (TSDB_CODE_SUCCESS != code && TSDB_CODE_PAR_TABLE_NOT_EXIST != code) { parserError("0x%" PRIx64 " catalogGetTableMeta error, code:%s, dbName:%s, tbName:%s", pCxt->pParseCxt->requestId, tstrerror(code), pName->dbname, pName->tname); } @@ -4979,10 +4979,10 @@ static int32_t buildAlterSuperTableReq(STranslateContext* pCxt, SAlterTableStmt* return TSDB_CODE_SUCCESS; } -static SSchema* getColSchema(STableMeta* pTableMeta, const char* pColName) { +static const SSchema* getColSchema(const STableMeta* pTableMeta, const char* pColName) { int32_t numOfFields = getNumOfTags(pTableMeta) + getNumOfColumns(pTableMeta); for (int32_t i = 0; i < numOfFields; ++i) { - SSchema* pSchema = pTableMeta->schema + i; + const SSchema* pSchema = pTableMeta->schema + i; if (0 == strcmp(pColName, pSchema->name)) { return pSchema; } @@ -5002,7 +5002,8 @@ static SSchema* getTagSchema(STableMeta* pTableMeta, const char* pTagName) { return NULL; } -static int32_t checkAlterSuperTableBySchema(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta) { +static int32_t checkAlterSuperTableBySchema(STranslateContext* pCxt, SAlterTableStmt* pStmt, + const STableMeta* pTableMeta) { SSchema* pTagsSchema = getTableTagSchema(pTableMeta); if (getNumOfTags(pTableMeta) == 1 && pTagsSchema->type == TSDB_DATA_TYPE_JSON && (pStmt->alterType == TSDB_ALTER_TABLE_ADD_TAG || pStmt->alterType == TSDB_ALTER_TABLE_DROP_TAG || @@ -5010,6 +5011,10 @@ static int32_t checkAlterSuperTableBySchema(STranslateContext* pCxt, SAlterTable return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_ONE_JSON_TAG); } + if (getNumOfTags(pTableMeta) == 1 && pStmt->alterType == TSDB_ALTER_TABLE_DROP_TAG) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE, "the only tag cannot be dropped"); + } + int32_t tagsLen = 0; for (int32_t i = 0; i < pTableMeta->tableInfo.numOfTags; ++i) { tagsLen += pTagsSchema[i].bytes; @@ -5021,7 +5026,7 @@ static int32_t checkAlterSuperTableBySchema(STranslateContext* pCxt, SAlterTable return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE, "Table is not super table"); } - SSchema* pSchema = getColSchema(pTableMeta, pStmt->colName); + const SSchema* pSchema = getColSchema(pTableMeta, pStmt->colName); if (NULL == pSchema) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN, pStmt->colName); } else if (!IS_VAR_DATA_TYPE(pSchema->type) || pSchema->type != pStmt->dataType.type || @@ -5729,6 +5734,139 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStm return TSDB_CODE_SUCCESS; } +static int32_t adjustDataTypeOfProjections(STranslateContext* pCxt, const STableMeta* pMeta, SNodeList* pProjections) { + if (getNumOfColumns(pMeta) != LIST_LENGTH(pProjections)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMNS_NUM, "Illegal number of columns"); + } + + SSchema* pSchemas = getTableColumnSchema(pMeta); + int32_t index = 0; + SNode* pProj = NULL; + FOREACH(pProj, pProjections) { + SSchema* pSchema = pSchemas + index; + SDataType dt = {.type = pSchema->type, .bytes = pSchema->bytes}; + if (!dataTypeEqual(&dt, &((SExprNode*)pProj)->resType)) { + SNode* pFunc = NULL; + int32_t code = createCastFunc(pCxt, pProj, dt, &pFunc); + if (TSDB_CODE_SUCCESS != code) { + return code; + } + REPLACE_NODE(pFunc); + } + } + + return TSDB_CODE_SUCCESS; +} + +typedef struct SProjColPos { + int32_t colId; + SNode* pProj; +} SProjColPos; + +static int32_t projColPosCompar(const void* l, const void* r) { + return ((SProjColPos*)l)->colId < ((SProjColPos*)r)->colId; +} + +static void projColPosDelete(void* p) { taosMemoryFree(((SProjColPos*)p)->pProj); } + +static int32_t addProjToProjColPos(STranslateContext* pCxt, const SSchema* pSchema, SNode* pProj, SArray* pProjColPos) { + SNode* pNewProj = nodesCloneNode(pProj); + if (NULL == pNewProj) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + int32_t code = TSDB_CODE_SUCCESS; + SDataType dt = {.type = pSchema->type, .bytes = pSchema->bytes}; + if (!dataTypeEqual(&dt, &((SExprNode*)pNewProj)->resType)) { + SNode* pFunc = NULL; + code = createCastFunc(pCxt, pNewProj, dt, &pFunc); + pNewProj = pFunc; + } + if (TSDB_CODE_SUCCESS == code) { + SProjColPos pos = {.colId = pSchema->colId, .pProj = pNewProj}; + code = (NULL == taosArrayPush(pProjColPos, &pos) ? TSDB_CODE_OUT_OF_MEMORY : TSDB_CODE_SUCCESS); + } + if (TSDB_CODE_SUCCESS != code) { + nodesDestroyNode(pNewProj); + } + return code; +} + +static int32_t adjustOrderOfProjection(STranslateContext* pCxt, SNodeList* pCols, const STableMeta* pMeta, + SNodeList** pProjections) { + if (LIST_LENGTH(pCols) != LIST_LENGTH(*pProjections)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMNS_NUM, "Illegal number of columns"); + } + + SArray* pProjColPos = taosArrayInit(LIST_LENGTH(pCols), sizeof(SProjColPos)); + if (NULL == pProjColPos) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + int32_t code = TSDB_CODE_SUCCESS; + SNode* pCol = NULL; + SNode* pProj = NULL; + FORBOTH(pCol, pCols, pProj, *pProjections) { + const SSchema* pSchema = getColSchema(pMeta, ((SColumnNode*)pCol)->colName); + code = addProjToProjColPos(pCxt, pSchema, pProj, pProjColPos); + if (TSDB_CODE_SUCCESS != code) { + break; + } + } + + SNodeList* pNewProjections = NULL; + if (TSDB_CODE_SUCCESS == code) { + taosArraySort(pProjColPos, projColPosCompar); + int32_t num = taosArrayGetSize(pProjColPos); + pNewProjections = nodesMakeList(); + if (NULL == pNewProjections) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + for (int32_t i = 0; TSDB_CODE_SUCCESS == code && i < num; ++i) { + SProjColPos* pPos = taosArrayGet(pProjColPos, i); + code = nodesListStrictAppend(pNewProjections, pPos->pProj); + pPos->pProj = NULL; + } + } + + if (TSDB_CODE_SUCCESS == code) { + taosArrayDestroy(pProjColPos); + nodesDestroyList(*pProjections); + *pProjections = pNewProjections; + } else { + taosArrayDestroyEx(pProjColPos, projColPosDelete); + nodesDestroyList(pNewProjections); + } + + return code; +} + +static int32_t adjustStreamQueryForExistTableImpl(STranslateContext* pCxt, SCreateStreamStmt* pStmt, + const STableMeta* pMeta) { + SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery; + if (NULL == pStmt->pCols) { + return adjustDataTypeOfProjections(pCxt, pMeta, pSelect->pProjectionList); + } + return adjustOrderOfProjection(pCxt, pStmt->pCols, pMeta, &pSelect->pProjectionList); +} + +static int32_t adjustStreamQueryForExistTable(STranslateContext* pCxt, SCreateStreamStmt* pStmt, + SCMCreateStreamReq* pReq) { + STableMeta* pMeta = NULL; + int32_t code = getTableMeta(pCxt, pStmt->targetDbName, pStmt->targetTabName, &pMeta); + if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) { + if (NULL != pStmt->pCols) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TABLE_NOT_EXIST, pStmt->targetTabName); + } + pReq->createStb = STREAM_CREATE_STABLE_TRUE; + return TSDB_CODE_SUCCESS; + } + if (TSDB_CODE_SUCCESS == code) { + code = adjustStreamQueryForExistTableImpl(pCxt, pStmt, pMeta); + } + return code; +} + static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SCMCreateStreamReq* pReq) { pCxt->createStream = true; int32_t code = addWstartTsToCreateStreamQuery(pCxt, pStmt->pQuery); @@ -5741,6 +5879,9 @@ static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt if (TSDB_CODE_SUCCESS == code) { code = checkStreamQuery(pCxt, pStmt); } + if (TSDB_CODE_SUCCESS == code) { + code = adjustStreamQueryForExistTable(pCxt, pStmt, pReq); + } if (TSDB_CODE_SUCCESS == code) { getSourceDatabase(pStmt->pQuery, pCxt->pParseCxt->acctId, pReq->sourceDB); code = nodesNodeToString(pStmt->pQuery, false, &pReq->ast, NULL); @@ -5779,8 +5920,6 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt* pReq->numOfTags = LIST_LENGTH(pStmt->pTags); } - pReq->createStb = STREAM_CREATE_STABLE_TRUE; - return code; } @@ -6240,6 +6379,20 @@ static int32_t extractShowCreateDatabaseResultSchema(int32_t* numOfCols, SSchema return TSDB_CODE_SUCCESS; } +static int32_t extractShowAliveResultSchema(int32_t* numOfCols, SSchema** pSchema) { + *numOfCols = 1; + *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); + if (NULL == (*pSchema)) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + (*pSchema)[0].type = TSDB_DATA_TYPE_INT; + (*pSchema)[0].bytes = sizeof(int32_t); + strcpy((*pSchema)[0].name, "status"); + + return TSDB_CODE_SUCCESS; +} + static int32_t extractShowCreateTableResultSchema(int32_t* numOfCols, SSchema** pSchema) { *numOfCols = 2; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); @@ -6291,6 +6444,9 @@ int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pS return extractDescribeResultSchema(numOfCols, pSchema); case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: return extractShowCreateDatabaseResultSchema(numOfCols, pSchema); + case QUERY_NODE_SHOW_DB_ALIVE_STMT: + case QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT: + return extractShowAliveResultSchema(numOfCols, pSchema); case QUERY_NODE_SHOW_CREATE_TABLE_STMT: case QUERY_NODE_SHOW_CREATE_STABLE_STMT: return extractShowCreateTableResultSchema(numOfCols, pSchema); @@ -7369,12 +7525,12 @@ static int32_t buildAddColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, S return TSDB_CODE_SUCCESS; } -static int32_t buildDropColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta, +static int32_t buildDropColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, const STableMeta* pTableMeta, SVAlterTbReq* pReq) { if (2 == getNumOfColumns(pTableMeta)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DROP_COL); } - SSchema* pSchema = getColSchema(pTableMeta, pStmt->colName); + const SSchema* pSchema = getColSchema(pTableMeta, pStmt->colName); if (NULL == pSchema) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN, pStmt->colName); } else if (PRIMARYKEY_TIMESTAMP_COL_ID == pSchema->colId) { @@ -7390,11 +7546,11 @@ static int32_t buildDropColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, return TSDB_CODE_SUCCESS; } -static int32_t buildUpdateColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta, +static int32_t buildUpdateColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, const STableMeta* pTableMeta, SVAlterTbReq* pReq) { pReq->colModBytes = calcTypeBytes(pStmt->dataType); pReq->colModType = pStmt->dataType.type; - SSchema* pSchema = getColSchema(pTableMeta, pStmt->colName); + const SSchema* pSchema = getColSchema(pTableMeta, pStmt->colName); if (NULL == pSchema) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN, pStmt->colName); } else if (!IS_VAR_DATA_TYPE(pSchema->type) || pSchema->type != pStmt->dataType.type || @@ -7558,7 +7714,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) { @@ -7810,6 +7966,8 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) { break; case QUERY_NODE_DESCRIBE_STMT: case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: + case QUERY_NODE_SHOW_DB_ALIVE_STMT: + case QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT: case QUERY_NODE_SHOW_CREATE_TABLE_STMT: case QUERY_NODE_SHOW_CREATE_STABLE_STMT: case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 67eaf5861755d16d8261475e325b7a54eb8ec769..487964df688818007b5febb9207db62cc16ebf82 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 461 +#define YYNOCODE 465 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EOrder yy32; - SToken yy77; - int32_t yy248; - int8_t yy287; - ENullOrder yy385; - EJoinType yy560; - SNode* yy600; - SNodeList* yy601; - SAlterOption yy661; - EOperatorType yy666; - int64_t yy717; - EFillMode yy798; - bool yy841; - SDataType yy888; + EJoinType yy42; + int8_t yy113; + int64_t yy159; + SToken yy179; + EOperatorType yy290; + EFillMode yy324; + SDataType yy394; + ENullOrder yy487; + SNode* yy602; + bool yy767; + int32_t yy820; + SAlterOption yy845; + SNodeList* yy874; + EOrder yy878; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -139,17 +139,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 725 -#define YYNRULE 547 -#define YYNTOKEN 325 -#define YY_MAX_SHIFT 724 -#define YY_MIN_SHIFTREDUCE 1072 -#define YY_MAX_SHIFTREDUCE 1618 -#define YY_ERROR_ACTION 1619 -#define YY_ACCEPT_ACTION 1620 -#define YY_NO_ACTION 1621 -#define YY_MIN_REDUCE 1622 -#define YY_MAX_REDUCE 2168 +#define YYNSTATE 733 +#define YYNRULE 554 +#define YYNTOKEN 326 +#define YY_MAX_SHIFT 732 +#define YY_MIN_SHIFTREDUCE 1084 +#define YY_MAX_SHIFTREDUCE 1637 +#define YY_ERROR_ACTION 1638 +#define YY_ACCEPT_ACTION 1639 +#define YY_NO_ACTION 1640 +#define YY_MIN_REDUCE 1641 +#define YY_MAX_REDUCE 2194 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -216,828 +216,779 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (3142) +#define YY_ACTTAB_COUNT (2883) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 1829, 413, 1765, 1982, 1969, 1891, 468, 356, 469, 1658, - /* 10 */ 1969, 1761, 45, 43, 1548, 1965, 1827, 1763, 1889, 601, - /* 20 */ 368, 1965, 1398, 38, 37, 527, 1105, 44, 42, 41, - /* 30 */ 40, 39, 1754, 1478, 2000, 1396, 477, 613, 469, 1658, - /* 40 */ 537, 325, 594, 1891, 1961, 1967, 350, 1951, 613, 630, - /* 50 */ 1961, 1967, 363, 359, 230, 624, 1888, 601, 1473, 27, - /* 60 */ 233, 624, 1982, 1806, 18, 1107, 2144, 1110, 1111, 530, - /* 70 */ 2139, 1404, 373, 1981, 524, 1822, 1824, 2017, 574, 229, - /* 80 */ 106, 1983, 634, 1985, 1986, 629, 2143, 624, 172, 613, - /* 90 */ 2140, 2142, 175, 2000, 2070, 486, 14, 1622, 362, 2066, - /* 100 */ 467, 631, 163, 472, 1664, 486, 1951, 1730, 630, 339, - /* 110 */ 1876, 476, 180, 48, 472, 1664, 67, 614, 721, 66, - /* 120 */ 2096, 128, 127, 126, 125, 124, 123, 122, 121, 120, - /* 130 */ 1424, 129, 1981, 1480, 1481, 1423, 2017, 360, 507, 106, - /* 140 */ 1983, 634, 1985, 1986, 629, 160, 624, 2144, 1776, 140, - /* 150 */ 1623, 146, 2041, 2070, 1778, 1423, 668, 362, 2066, 41, - /* 160 */ 40, 39, 1453, 1463, 1425, 48, 1552, 474, 1479, 1482, - /* 170 */ 1829, 119, 1423, 470, 118, 117, 116, 115, 114, 113, - /* 180 */ 112, 111, 110, 1399, 84, 1397, 1828, 1232, 656, 655, - /* 190 */ 654, 1236, 653, 1238, 1239, 652, 1241, 649, 133, 1247, - /* 200 */ 646, 1249, 1250, 643, 640, 1691, 2085, 1771, 1402, 1403, - /* 210 */ 1192, 1452, 1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, - /* 220 */ 626, 622, 1471, 1472, 1474, 1475, 1476, 1477, 2, 45, - /* 230 */ 43, 60, 2082, 324, 569, 1421, 264, 368, 1124, 1398, - /* 240 */ 1123, 1608, 443, 1275, 1276, 456, 1194, 1982, 455, 1423, - /* 250 */ 1478, 119, 1396, 216, 118, 117, 116, 115, 114, 113, - /* 260 */ 112, 111, 110, 427, 174, 457, 60, 1645, 429, 1125, - /* 270 */ 1422, 522, 521, 520, 60, 1473, 89, 1816, 2000, 134, - /* 280 */ 516, 18, 11, 1620, 515, 614, 631, 659, 1404, 514, - /* 290 */ 519, 1951, 2000, 630, 1404, 513, 49, 38, 37, 129, - /* 300 */ 573, 44, 42, 41, 40, 39, 512, 64, 263, 1426, - /* 310 */ 340, 1951, 402, 14, 1454, 181, 1776, 1981, 575, 570, - /* 320 */ 564, 2017, 417, 1829, 106, 1983, 634, 1985, 1986, 629, - /* 330 */ 361, 624, 103, 404, 400, 721, 2159, 1767, 2070, 1827, - /* 340 */ 572, 1752, 362, 2066, 35, 281, 138, 383, 1965, 680, - /* 350 */ 1480, 1481, 453, 2104, 1768, 448, 447, 446, 445, 442, - /* 360 */ 441, 440, 439, 438, 434, 433, 432, 431, 341, 424, - /* 370 */ 423, 422, 591, 419, 418, 338, 1759, 1961, 1967, 1453, - /* 380 */ 1463, 181, 272, 273, 591, 1479, 1482, 271, 624, 555, - /* 390 */ 236, 1328, 1329, 2139, 1829, 1407, 1124, 217, 1123, 60, - /* 400 */ 1399, 336, 1397, 137, 668, 13, 12, 60, 2145, 178, - /* 410 */ 1827, 1644, 167, 2140, 580, 137, 181, 1488, 503, 499, - /* 420 */ 495, 491, 214, 1423, 181, 1402, 1403, 1125, 1452, 1455, - /* 430 */ 1456, 1457, 1458, 1459, 1460, 1461, 1462, 626, 622, 1471, - /* 440 */ 1472, 1474, 1475, 1476, 1477, 2, 181, 11, 45, 43, - /* 450 */ 162, 172, 1634, 241, 139, 1951, 368, 2041, 1398, 85, - /* 460 */ 1823, 1824, 212, 177, 2078, 2079, 579, 135, 2083, 1478, - /* 470 */ 2139, 1396, 1425, 1877, 614, 261, 2078, 590, 1872, 130, - /* 480 */ 589, 660, 614, 2139, 1820, 578, 178, 1643, 611, 186, - /* 490 */ 2140, 580, 614, 406, 1473, 405, 612, 1872, 578, 178, - /* 500 */ 18, 1521, 232, 2140, 580, 1776, 54, 1404, 188, 522, - /* 510 */ 521, 520, 1982, 1776, 518, 517, 2144, 134, 516, 161, - /* 520 */ 2139, 84, 515, 1776, 301, 365, 364, 514, 519, 211, - /* 530 */ 205, 1951, 14, 513, 210, 1412, 2143, 482, 299, 70, - /* 540 */ 2140, 2141, 69, 2000, 1772, 1410, 1478, 344, 1405, 181, - /* 550 */ 614, 594, 614, 203, 721, 625, 1951, 181, 630, 2085, - /* 560 */ 199, 464, 462, 459, 183, 1454, 411, 1375, 1376, 1480, - /* 570 */ 1481, 1473, 38, 37, 1575, 1423, 44, 42, 41, 40, - /* 580 */ 39, 1776, 1981, 1776, 1404, 2081, 2017, 1426, 97, 106, - /* 590 */ 1983, 634, 1985, 1986, 629, 1872, 624, 60, 1453, 1463, - /* 600 */ 1426, 175, 190, 2070, 1479, 1482, 192, 362, 2066, 345, - /* 610 */ 1769, 343, 342, 579, 509, 2085, 263, 2139, 511, 1399, - /* 620 */ 1545, 1397, 1398, 566, 1573, 1574, 1576, 1577, 332, 2097, - /* 630 */ 658, 620, 578, 178, 586, 1396, 105, 2140, 580, 81, - /* 640 */ 510, 2080, 80, 1424, 1402, 1403, 511, 1452, 1455, 1456, - /* 650 */ 1457, 1458, 1459, 1460, 1461, 1462, 626, 622, 1471, 1472, - /* 660 */ 1474, 1475, 1476, 1477, 2, 45, 43, 1483, 510, 1507, - /* 670 */ 666, 1404, 536, 368, 449, 1398, 78, 77, 410, 664, - /* 680 */ 231, 185, 1820, 1642, 1982, 534, 1478, 532, 1396, 151, - /* 690 */ 150, 663, 662, 661, 148, 614, 1413, 1641, 1408, 323, - /* 700 */ 1509, 2143, 398, 1829, 396, 392, 388, 385, 382, 412, - /* 710 */ 372, 1473, 371, 550, 11, 2000, 9, 1454, 721, 1827, - /* 720 */ 160, 1416, 1418, 631, 1404, 1508, 1776, 1951, 1951, 1778, - /* 730 */ 630, 187, 194, 193, 622, 1471, 1472, 1474, 1475, 1476, - /* 740 */ 1477, 1951, 86, 327, 240, 614, 540, 181, 538, 46, - /* 750 */ 591, 1640, 374, 616, 1981, 2042, 1343, 1344, 2017, 421, - /* 760 */ 160, 106, 1983, 634, 1985, 1986, 629, 665, 624, 1778, - /* 770 */ 1820, 721, 32, 2159, 1639, 2070, 1776, 692, 690, 362, - /* 780 */ 2066, 137, 1514, 1399, 71, 1397, 1480, 1481, 1753, 8, - /* 790 */ 2117, 1342, 1345, 1638, 618, 1951, 2042, 34, 366, 1502, - /* 800 */ 1503, 1504, 1505, 1506, 1510, 1511, 1512, 1513, 1402, 1403, - /* 810 */ 44, 42, 41, 40, 39, 1453, 1463, 1678, 1951, 614, - /* 820 */ 295, 1479, 1482, 1806, 38, 37, 1751, 1859, 44, 42, - /* 830 */ 41, 40, 39, 282, 79, 160, 1399, 1951, 1397, 523, - /* 840 */ 593, 176, 2078, 2079, 1779, 135, 2083, 38, 37, 1938, - /* 850 */ 1776, 44, 42, 41, 40, 39, 1637, 1636, 1633, 587, - /* 860 */ 1632, 1402, 1403, 1544, 1452, 1455, 1456, 1457, 1458, 1459, - /* 870 */ 1460, 1461, 1462, 626, 622, 1471, 1472, 1474, 1475, 1476, - /* 880 */ 1477, 2, 45, 43, 681, 149, 1746, 1110, 1111, 1671, - /* 890 */ 368, 1982, 1398, 614, 614, 614, 666, 390, 2090, 1541, - /* 900 */ 1951, 1951, 1951, 1478, 1951, 1396, 1635, 435, 436, 484, - /* 910 */ 50, 525, 3, 1585, 414, 151, 150, 663, 662, 661, - /* 920 */ 148, 583, 2000, 1631, 1776, 1776, 1776, 415, 1473, 614, - /* 930 */ 631, 1731, 407, 614, 666, 1951, 1564, 630, 53, 258, - /* 940 */ 143, 1404, 131, 485, 38, 37, 1630, 1773, 44, 42, - /* 950 */ 41, 40, 39, 151, 150, 663, 662, 661, 148, 597, - /* 960 */ 1776, 1981, 567, 582, 1776, 2017, 46, 1951, 106, 1983, - /* 970 */ 634, 1985, 1986, 629, 555, 624, 215, 614, 2139, 430, - /* 980 */ 2159, 2110, 2070, 1629, 1982, 2001, 362, 2066, 721, 252, - /* 990 */ 1951, 145, 1628, 2145, 178, 1541, 1627, 562, 2140, 580, - /* 1000 */ 31, 555, 1669, 1480, 1481, 2139, 38, 37, 1776, 621, - /* 1010 */ 44, 42, 41, 40, 39, 2000, 222, 1617, 1618, 220, - /* 1020 */ 2145, 178, 379, 628, 528, 2140, 580, 1951, 1951, 614, - /* 1030 */ 630, 1626, 1453, 1463, 224, 33, 1951, 223, 1479, 1482, - /* 1040 */ 1951, 38, 37, 551, 1406, 44, 42, 41, 40, 39, - /* 1050 */ 1659, 62, 674, 1399, 1981, 1397, 226, 1625, 2017, 225, - /* 1060 */ 1776, 317, 1983, 634, 1985, 1986, 629, 627, 624, 615, - /* 1070 */ 2035, 381, 591, 228, 1173, 1951, 227, 1881, 1402, 1403, - /* 1080 */ 1817, 1452, 1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, - /* 1090 */ 626, 622, 1471, 1472, 1474, 1475, 1476, 1477, 2, 45, - /* 1100 */ 43, 1951, 239, 137, 1572, 614, 245, 368, 1982, 1398, - /* 1110 */ 1154, 1615, 614, 555, 380, 2100, 149, 2139, 52, 595, - /* 1120 */ 1478, 47, 1396, 38, 37, 554, 599, 44, 42, 41, - /* 1130 */ 40, 39, 2145, 178, 592, 614, 1776, 2140, 580, 2000, - /* 1140 */ 269, 614, 87, 1776, 584, 1473, 1155, 631, 614, 600, - /* 1150 */ 13, 12, 1951, 1499, 630, 276, 555, 68, 1404, 247, - /* 1160 */ 2139, 102, 609, 179, 2078, 2079, 1776, 135, 2083, 598, - /* 1170 */ 1972, 99, 1776, 147, 1340, 2145, 178, 257, 1981, 1776, - /* 1180 */ 2140, 580, 2017, 14, 614, 106, 1983, 634, 1985, 1986, - /* 1190 */ 629, 543, 624, 274, 1409, 62, 675, 2159, 375, 2070, - /* 1200 */ 260, 1982, 1, 362, 2066, 721, 1614, 149, 47, 47, - /* 1210 */ 606, 638, 147, 149, 2133, 1776, 4, 337, 1171, 1974, - /* 1220 */ 1480, 1481, 384, 38, 37, 1665, 278, 44, 42, 41, - /* 1230 */ 40, 39, 2000, 555, 132, 147, 389, 2139, 1362, 191, - /* 1240 */ 631, 289, 416, 1426, 1882, 1951, 420, 630, 1515, 1453, - /* 1250 */ 1463, 1688, 2145, 178, 451, 1479, 1482, 2140, 580, 425, - /* 1260 */ 1225, 1464, 294, 1421, 1253, 1257, 1264, 437, 1874, 444, - /* 1270 */ 1399, 1981, 1397, 450, 716, 2017, 452, 458, 107, 1983, - /* 1280 */ 634, 1985, 1986, 629, 461, 624, 460, 1262, 152, 196, - /* 1290 */ 1427, 463, 2070, 465, 466, 1402, 1403, 2067, 1452, 1455, - /* 1300 */ 1456, 1457, 1458, 1459, 1460, 1461, 1462, 626, 622, 1471, - /* 1310 */ 1472, 1474, 1475, 1476, 1477, 2, 1982, 698, 697, 696, - /* 1320 */ 695, 378, 475, 694, 693, 141, 688, 687, 686, 685, - /* 1330 */ 684, 683, 682, 153, 678, 677, 676, 377, 376, 673, - /* 1340 */ 672, 671, 670, 669, 1429, 478, 202, 2000, 1970, 1424, - /* 1350 */ 479, 1428, 204, 480, 1430, 631, 481, 207, 483, 1965, - /* 1360 */ 1951, 209, 630, 487, 82, 83, 213, 1127, 504, 505, - /* 1370 */ 506, 508, 1766, 219, 109, 326, 1762, 221, 1928, 159, - /* 1380 */ 1927, 542, 1982, 544, 154, 155, 1981, 1764, 1961, 1967, - /* 1390 */ 2017, 1760, 290, 106, 1983, 634, 1985, 1986, 629, 624, - /* 1400 */ 624, 156, 157, 234, 545, 2159, 237, 2070, 549, 552, - /* 1410 */ 568, 362, 2066, 2000, 546, 2116, 604, 2101, 2111, 559, - /* 1420 */ 565, 631, 2089, 2115, 351, 571, 1951, 2092, 630, 577, - /* 1430 */ 168, 243, 7, 251, 246, 560, 1982, 558, 557, 253, - /* 1440 */ 254, 255, 585, 352, 2162, 588, 1541, 2138, 259, 136, - /* 1450 */ 256, 1425, 1981, 596, 265, 2086, 2017, 355, 92, 106, - /* 1460 */ 1983, 634, 1985, 1986, 629, 291, 624, 2000, 292, 602, - /* 1470 */ 603, 2045, 1899, 2070, 1898, 631, 1897, 362, 2066, 358, - /* 1480 */ 1951, 94, 630, 607, 608, 293, 96, 59, 1777, 2051, - /* 1490 */ 98, 636, 1747, 296, 1821, 285, 717, 718, 51, 320, - /* 1500 */ 305, 319, 328, 720, 1945, 329, 1981, 1982, 300, 309, - /* 1510 */ 2017, 1944, 75, 106, 1983, 634, 1985, 1986, 629, 298, - /* 1520 */ 624, 1943, 1942, 76, 1939, 2043, 386, 2070, 387, 1390, - /* 1530 */ 1391, 362, 2066, 184, 1982, 391, 1937, 393, 2000, 395, - /* 1540 */ 394, 1936, 397, 1935, 399, 1934, 631, 401, 1933, 403, - /* 1550 */ 1365, 1951, 1364, 630, 1910, 1909, 408, 409, 1908, 1907, - /* 1560 */ 1319, 1867, 1866, 1864, 1863, 2000, 1862, 1865, 1861, 142, - /* 1570 */ 1860, 1858, 1857, 631, 1856, 189, 1855, 1981, 1951, 426, - /* 1580 */ 630, 2017, 428, 1854, 106, 1983, 634, 1985, 1986, 629, - /* 1590 */ 1853, 624, 1852, 1851, 1850, 1849, 617, 1321, 2070, 1848, - /* 1600 */ 1847, 1982, 362, 2066, 1981, 1846, 1845, 1844, 2017, 1843, - /* 1610 */ 1842, 107, 1983, 634, 1985, 1986, 629, 1841, 624, 1840, - /* 1620 */ 1839, 144, 1838, 1837, 1982, 2070, 1836, 1835, 1834, 2069, - /* 1630 */ 2066, 1833, 2000, 1832, 1831, 454, 1830, 1694, 195, 1200, - /* 1640 */ 631, 1693, 197, 1692, 198, 1951, 1690, 630, 1654, 1971, - /* 1650 */ 200, 73, 1113, 1112, 1653, 2000, 201, 173, 471, 1923, - /* 1660 */ 74, 473, 1917, 631, 1906, 1905, 208, 1885, 1951, 206, - /* 1670 */ 630, 1981, 218, 489, 490, 2017, 1755, 1689, 107, 1983, - /* 1680 */ 634, 1985, 1986, 629, 1687, 624, 488, 1685, 492, 1147, - /* 1690 */ 493, 1982, 2070, 1683, 632, 494, 619, 2066, 2017, 498, - /* 1700 */ 497, 107, 1983, 634, 1985, 1986, 629, 1681, 624, 496, - /* 1710 */ 500, 1982, 1668, 1667, 501, 2070, 1650, 502, 1757, 331, - /* 1720 */ 2066, 1269, 2000, 61, 1268, 1756, 1191, 689, 1183, 1190, - /* 1730 */ 631, 1189, 1188, 691, 1185, 1951, 1184, 630, 1182, 1679, - /* 1740 */ 1672, 346, 2000, 347, 1670, 526, 348, 1649, 1648, 529, - /* 1750 */ 631, 1647, 531, 535, 108, 1951, 1922, 630, 533, 26, - /* 1760 */ 539, 1981, 1380, 1379, 1371, 2017, 1382, 55, 164, 1983, - /* 1770 */ 634, 1985, 1986, 629, 1916, 624, 547, 158, 1904, 548, - /* 1780 */ 1902, 1981, 2144, 16, 28, 2017, 19, 1587, 165, 1983, - /* 1790 */ 634, 1985, 1986, 629, 242, 624, 563, 244, 238, 58, - /* 1800 */ 1982, 553, 561, 249, 349, 1571, 166, 248, 250, 556, - /* 1810 */ 2107, 29, 1972, 30, 21, 5, 6, 1563, 88, 63, - /* 1820 */ 1602, 1601, 353, 1607, 1606, 1605, 354, 20, 262, 1608, - /* 1830 */ 1538, 2000, 17, 1537, 1903, 169, 57, 1901, 1900, 631, - /* 1840 */ 581, 2160, 56, 1884, 1951, 90, 630, 91, 22, 605, - /* 1850 */ 268, 1883, 93, 270, 1982, 1569, 275, 280, 65, 95, - /* 1860 */ 12, 23, 170, 1414, 2020, 1500, 182, 1445, 1468, 277, - /* 1870 */ 1981, 623, 99, 1466, 2017, 657, 1490, 164, 1983, 634, - /* 1880 */ 1985, 1986, 629, 633, 624, 2000, 10, 1489, 637, 36, - /* 1890 */ 635, 1465, 15, 631, 24, 370, 1437, 25, 1951, 1254, - /* 1900 */ 630, 639, 641, 1251, 1248, 642, 1982, 644, 645, 647, - /* 1910 */ 650, 1242, 1231, 283, 648, 1246, 1263, 1240, 651, 2108, - /* 1920 */ 1245, 100, 101, 1244, 1981, 1982, 72, 1259, 2017, 1145, - /* 1930 */ 667, 311, 1983, 634, 1985, 1986, 629, 2000, 624, 1179, - /* 1940 */ 679, 1243, 1198, 1178, 1177, 631, 1176, 1175, 1174, 1172, - /* 1950 */ 1951, 1170, 630, 1169, 1168, 1166, 2000, 1165, 1164, 284, - /* 1960 */ 1163, 357, 1162, 1161, 631, 1160, 1195, 1193, 1157, 1951, - /* 1970 */ 1156, 630, 1153, 1151, 1152, 576, 1981, 1150, 1686, 699, - /* 1980 */ 2017, 1684, 700, 165, 1983, 634, 1985, 1986, 629, 701, - /* 1990 */ 624, 703, 705, 704, 1682, 1981, 707, 708, 709, 2017, - /* 2000 */ 1982, 711, 318, 1983, 634, 1985, 1986, 629, 1680, 624, - /* 2010 */ 712, 713, 1666, 1646, 715, 1102, 723, 287, 719, 722, - /* 2020 */ 1982, 1400, 297, 1621, 1621, 1621, 1621, 1621, 1621, 1621, - /* 2030 */ 1621, 2000, 1621, 1621, 1621, 1621, 2161, 1621, 1621, 628, - /* 2040 */ 1621, 1621, 1621, 1621, 1951, 1621, 630, 1621, 1621, 1621, - /* 2050 */ 1621, 2000, 1621, 1621, 1621, 1621, 367, 1621, 1621, 631, - /* 2060 */ 1621, 1621, 1621, 1621, 1951, 1621, 630, 1621, 1621, 1621, - /* 2070 */ 1981, 1621, 1621, 1621, 2017, 1621, 1621, 317, 1983, 634, - /* 2080 */ 1985, 1986, 629, 1621, 624, 1621, 2036, 1621, 1621, 1621, - /* 2090 */ 1981, 1621, 1621, 1621, 2017, 1621, 1621, 318, 1983, 634, - /* 2100 */ 1985, 1986, 629, 1621, 624, 1621, 1621, 1621, 1621, 1621, - /* 2110 */ 1982, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, - /* 2120 */ 1621, 1621, 724, 1621, 1621, 1621, 1621, 1621, 1621, 1621, - /* 2130 */ 1621, 1621, 1621, 1621, 1621, 1621, 288, 1621, 1621, 1982, - /* 2140 */ 1621, 2000, 1621, 1621, 1621, 1621, 369, 1621, 1621, 631, - /* 2150 */ 1621, 171, 1621, 1621, 1951, 1621, 630, 714, 710, 706, - /* 2160 */ 702, 286, 1621, 1621, 1621, 1621, 1621, 1621, 1982, 1621, - /* 2170 */ 2000, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 631, 1621, - /* 2180 */ 1981, 1621, 1621, 1951, 2017, 630, 1621, 318, 1983, 634, - /* 2190 */ 1985, 1986, 629, 1621, 624, 1621, 1621, 1621, 104, 2000, - /* 2200 */ 1621, 279, 1621, 1621, 1621, 1621, 1621, 631, 1621, 541, - /* 2210 */ 1621, 1621, 1951, 2017, 630, 1621, 313, 1983, 634, 1985, - /* 2220 */ 1986, 629, 1621, 624, 1621, 1621, 1621, 1621, 1621, 1621, - /* 2230 */ 1621, 1621, 1621, 1621, 610, 1982, 1621, 1621, 1981, 1621, - /* 2240 */ 1621, 1621, 2017, 1621, 1621, 302, 1983, 634, 1985, 1986, - /* 2250 */ 629, 1621, 624, 1621, 1982, 1621, 1621, 1621, 1621, 1621, - /* 2260 */ 1621, 1621, 1621, 1621, 1621, 1621, 2000, 1621, 267, 1621, - /* 2270 */ 1621, 1621, 1621, 266, 631, 1621, 1621, 1621, 1621, 1951, - /* 2280 */ 1621, 630, 1621, 1621, 1621, 2000, 1621, 1621, 1621, 1621, - /* 2290 */ 1369, 1621, 235, 631, 1621, 1621, 1621, 1621, 1951, 1621, - /* 2300 */ 630, 1621, 1621, 1621, 1621, 1981, 1621, 1621, 1621, 2017, - /* 2310 */ 1621, 1621, 303, 1983, 634, 1985, 1986, 629, 1621, 624, - /* 2320 */ 1621, 1621, 1621, 1621, 1981, 1621, 1621, 1621, 2017, 1982, - /* 2330 */ 1621, 304, 1983, 634, 1985, 1986, 629, 1621, 624, 1621, - /* 2340 */ 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1982, - /* 2350 */ 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, - /* 2360 */ 2000, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 631, 1621, - /* 2370 */ 1621, 1621, 1621, 1951, 1621, 630, 1621, 1621, 1621, 1621, - /* 2380 */ 2000, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 631, 1621, - /* 2390 */ 1621, 1621, 1621, 1951, 1621, 630, 1621, 1621, 1621, 1981, - /* 2400 */ 1621, 1621, 1621, 2017, 1621, 1621, 310, 1983, 634, 1985, - /* 2410 */ 1986, 629, 1621, 624, 1621, 1982, 1621, 1621, 1621, 1981, - /* 2420 */ 1621, 1621, 1621, 2017, 1621, 1621, 314, 1983, 634, 1985, - /* 2430 */ 1986, 629, 1621, 624, 1621, 1621, 1621, 1621, 1621, 1621, - /* 2440 */ 1621, 1621, 1621, 1621, 1621, 1621, 2000, 1621, 1621, 1621, - /* 2450 */ 1621, 1621, 1621, 1621, 631, 1621, 1621, 1621, 1621, 1951, - /* 2460 */ 1621, 630, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, - /* 2470 */ 1982, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, - /* 2480 */ 1621, 1621, 1621, 1621, 1621, 1981, 1982, 1621, 1621, 2017, - /* 2490 */ 1621, 1621, 306, 1983, 634, 1985, 1986, 629, 1621, 624, - /* 2500 */ 1621, 2000, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 631, - /* 2510 */ 1621, 1621, 1621, 1621, 1951, 1621, 630, 2000, 1621, 1621, - /* 2520 */ 1621, 1621, 1621, 1621, 1621, 631, 1621, 1621, 1621, 1621, - /* 2530 */ 1951, 1621, 630, 1621, 1621, 1621, 1621, 1621, 1982, 1621, - /* 2540 */ 1981, 1621, 1621, 1621, 2017, 1621, 1621, 315, 1983, 634, - /* 2550 */ 1985, 1986, 629, 1621, 624, 1621, 1981, 1621, 1621, 1621, - /* 2560 */ 2017, 1621, 1621, 307, 1983, 634, 1985, 1986, 629, 2000, - /* 2570 */ 624, 1621, 1621, 1621, 1621, 1621, 1621, 631, 1621, 1621, - /* 2580 */ 1621, 1621, 1951, 1621, 630, 1621, 1621, 1621, 1621, 1621, - /* 2590 */ 1621, 1621, 1621, 1621, 1621, 1982, 1621, 1621, 1621, 1621, - /* 2600 */ 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1981, 1621, - /* 2610 */ 1621, 1621, 2017, 1621, 1982, 316, 1983, 634, 1985, 1986, - /* 2620 */ 629, 1621, 624, 1621, 1621, 1621, 2000, 1621, 1621, 1621, - /* 2630 */ 1621, 1621, 1621, 1621, 631, 1621, 1621, 1621, 1621, 1951, - /* 2640 */ 1621, 630, 1621, 1621, 1621, 2000, 1621, 1621, 1621, 1621, - /* 2650 */ 1621, 1621, 1621, 631, 1621, 1621, 1621, 1621, 1951, 1621, - /* 2660 */ 630, 1621, 1621, 1621, 1621, 1981, 1621, 1621, 1621, 2017, - /* 2670 */ 1621, 1621, 308, 1983, 634, 1985, 1986, 629, 1982, 624, - /* 2680 */ 1621, 1621, 1621, 1621, 1981, 1621, 1621, 1621, 2017, 1621, - /* 2690 */ 1621, 321, 1983, 634, 1985, 1986, 629, 1982, 624, 1621, - /* 2700 */ 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 2000, - /* 2710 */ 1621, 1621, 1621, 1621, 1621, 1621, 1621, 631, 1621, 1621, - /* 2720 */ 1621, 1621, 1951, 1621, 630, 1621, 1621, 1621, 2000, 1621, - /* 2730 */ 1621, 1621, 1621, 1621, 1621, 1621, 631, 1621, 1621, 1621, - /* 2740 */ 1621, 1951, 1621, 630, 1621, 1621, 1621, 1621, 1981, 1621, - /* 2750 */ 1621, 1621, 2017, 1621, 1621, 322, 1983, 634, 1985, 1986, - /* 2760 */ 629, 1621, 624, 1621, 1621, 1621, 1621, 1981, 1621, 1621, - /* 2770 */ 1621, 2017, 1621, 1621, 1994, 1983, 634, 1985, 1986, 629, - /* 2780 */ 1621, 624, 1621, 1982, 1621, 1621, 1621, 1621, 1621, 1621, - /* 2790 */ 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1982, - /* 2800 */ 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, - /* 2810 */ 1621, 1621, 1621, 1621, 2000, 1621, 1621, 1621, 1621, 1621, - /* 2820 */ 1621, 1621, 631, 1621, 1621, 1621, 1621, 1951, 1621, 630, - /* 2830 */ 2000, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 631, 1621, - /* 2840 */ 1621, 1621, 1621, 1951, 1621, 630, 1621, 1621, 1621, 1621, - /* 2850 */ 1621, 1621, 1621, 1981, 1982, 1621, 1621, 2017, 1621, 1621, - /* 2860 */ 1993, 1983, 634, 1985, 1986, 629, 1621, 624, 1621, 1981, - /* 2870 */ 1621, 1621, 1621, 2017, 1621, 1621, 1992, 1983, 634, 1985, - /* 2880 */ 1986, 629, 1621, 624, 1621, 2000, 1621, 1621, 1621, 1621, - /* 2890 */ 1621, 1621, 1621, 631, 1621, 1621, 1621, 1621, 1951, 1621, - /* 2900 */ 630, 1621, 1621, 1621, 1621, 1621, 1982, 1621, 1621, 1621, - /* 2910 */ 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, 1621, - /* 2920 */ 1621, 1621, 1621, 1621, 1981, 1621, 1621, 1621, 2017, 1621, - /* 2930 */ 1621, 333, 1983, 634, 1985, 1986, 629, 2000, 624, 1621, - /* 2940 */ 1621, 1621, 1621, 1621, 1621, 631, 1621, 1621, 1621, 1621, - /* 2950 */ 1951, 1621, 630, 1621, 1621, 1621, 1621, 1621, 1621, 1621, - /* 2960 */ 1621, 1621, 1621, 1982, 1621, 1621, 1621, 1621, 1621, 1621, - /* 2970 */ 1621, 1621, 1621, 1621, 1621, 1621, 1981, 1621, 1621, 1621, - /* 2980 */ 2017, 1621, 1982, 334, 1983, 634, 1985, 1986, 629, 1621, - /* 2990 */ 624, 1621, 1621, 1621, 2000, 1621, 1621, 1621, 1621, 1621, - /* 3000 */ 1621, 1621, 631, 1621, 1621, 1621, 1621, 1951, 1621, 630, - /* 3010 */ 1621, 1621, 1621, 2000, 1621, 1621, 1621, 1621, 1621, 1621, - /* 3020 */ 1621, 631, 1621, 1621, 1621, 1621, 1951, 1621, 630, 1621, - /* 3030 */ 1621, 1621, 1621, 1981, 1621, 1621, 1621, 2017, 1982, 1621, - /* 3040 */ 330, 1983, 634, 1985, 1986, 629, 1621, 624, 1621, 1621, - /* 3050 */ 1621, 1621, 1981, 1621, 1621, 1621, 2017, 1982, 1621, 335, - /* 3060 */ 1983, 634, 1985, 1986, 629, 1621, 624, 1621, 1621, 2000, - /* 3070 */ 1621, 1621, 1621, 1621, 1621, 1621, 1621, 631, 1621, 1621, - /* 3080 */ 1621, 1621, 1951, 1621, 630, 1621, 1621, 1621, 2000, 1621, - /* 3090 */ 1621, 1621, 1621, 1621, 1621, 1621, 631, 1621, 1621, 1621, - /* 3100 */ 1621, 1951, 1621, 630, 1621, 1621, 1621, 1621, 632, 1621, - /* 3110 */ 1621, 1621, 2017, 1621, 1621, 313, 1983, 634, 1985, 1986, - /* 3120 */ 629, 1621, 624, 1621, 1621, 1621, 1621, 1981, 1621, 1621, - /* 3130 */ 1621, 2017, 1621, 1621, 312, 1983, 634, 1985, 1986, 629, - /* 3140 */ 1621, 624, + /* 0 */ 1914, 1784, 474, 2170, 475, 1677, 377, 2165, 1994, 1841, + /* 10 */ 1843, 1780, 45, 43, 1567, 1912, 609, 35, 284, 1990, + /* 20 */ 372, 621, 1416, 2169, 1914, 1848, 1786, 2166, 2168, 2008, + /* 30 */ 1842, 1843, 340, 1497, 1994, 1414, 363, 1990, 480, 1911, + /* 40 */ 609, 1846, 38, 37, 476, 1990, 44, 42, 41, 40, + /* 50 */ 39, 1986, 1992, 354, 164, 417, 597, 1441, 1492, 1749, + /* 60 */ 2026, 173, 632, 483, 18, 475, 1677, 84, 600, 1986, + /* 70 */ 1992, 1422, 622, 1976, 1639, 638, 621, 1986, 1992, 367, + /* 80 */ 632, 134, 343, 1897, 45, 43, 130, 138, 632, 621, + /* 90 */ 1790, 266, 372, 513, 1416, 326, 14, 48, 336, 411, + /* 100 */ 585, 622, 2007, 1795, 2165, 1497, 2043, 1414, 1773, 107, + /* 110 */ 2009, 642, 2011, 2012, 637, 130, 632, 607, 729, 584, + /* 120 */ 179, 176, 518, 2096, 2166, 586, 1442, 366, 2092, 60, + /* 130 */ 1492, 90, 1795, 1499, 1500, 1441, 18, 524, 523, 1526, + /* 140 */ 387, 181, 561, 1422, 1963, 1136, 2165, 1135, 608, 2122, + /* 150 */ 263, 2104, 596, 473, 131, 595, 478, 1683, 2165, 175, + /* 160 */ 217, 2171, 179, 1472, 1482, 48, 2166, 586, 14, 1498, + /* 170 */ 1501, 492, 1835, 584, 179, 1441, 1137, 364, 2166, 586, + /* 180 */ 528, 527, 526, 561, 1417, 161, 1415, 2165, 135, 522, + /* 190 */ 729, 1117, 394, 521, 1797, 490, 1527, 1907, 520, 525, + /* 200 */ 1342, 1343, 2171, 179, 519, 1499, 1500, 2166, 586, 1420, + /* 210 */ 1421, 60, 1471, 1474, 1475, 1476, 1477, 1478, 1479, 1480, + /* 220 */ 1481, 634, 630, 1490, 1491, 1493, 1494, 1495, 1496, 2, + /* 230 */ 1119, 2111, 1122, 1123, 482, 1472, 1482, 478, 1683, 1287, + /* 240 */ 1288, 1498, 1501, 120, 8, 2170, 119, 118, 117, 116, + /* 250 */ 115, 114, 113, 112, 111, 347, 1417, 2108, 1415, 38, + /* 260 */ 37, 173, 1443, 44, 42, 41, 40, 39, 34, 370, + /* 270 */ 1521, 1522, 1523, 1524, 1525, 1529, 1530, 1531, 1532, 492, + /* 280 */ 182, 1420, 1421, 1898, 1471, 1474, 1475, 1476, 1477, 1478, + /* 290 */ 1479, 1480, 1481, 634, 630, 1490, 1491, 1493, 1494, 1495, + /* 300 */ 1496, 2, 60, 11, 45, 43, 603, 44, 42, 41, + /* 310 */ 40, 39, 372, 1441, 1416, 2026, 182, 348, 1473, 346, + /* 320 */ 345, 2008, 515, 579, 84, 1497, 517, 1414, 1244, 664, + /* 330 */ 663, 662, 1248, 661, 1250, 1251, 660, 1253, 657, 1627, + /* 340 */ 1259, 654, 1261, 1262, 651, 648, 1771, 1791, 516, 561, + /* 350 */ 1492, 597, 2026, 2165, 1848, 2170, 18, 233, 418, 2165, + /* 360 */ 639, 352, 182, 1422, 580, 1976, 578, 638, 2171, 179, + /* 370 */ 1846, 419, 542, 2166, 586, 2169, 45, 43, 1502, 2166, + /* 380 */ 2167, 622, 138, 608, 372, 540, 1416, 538, 14, 410, + /* 390 */ 2008, 409, 1204, 64, 2007, 54, 676, 1497, 2043, 1414, + /* 400 */ 455, 107, 2009, 642, 2011, 2012, 637, 265, 632, 676, + /* 410 */ 729, 141, 1795, 147, 2067, 2096, 1443, 622, 218, 366, + /* 420 */ 2092, 2026, 1492, 1393, 1394, 1499, 1500, 1634, 1206, 639, + /* 430 */ 606, 184, 1907, 168, 1976, 1422, 638, 1440, 622, 509, + /* 440 */ 505, 501, 497, 215, 599, 177, 2104, 2105, 1795, 136, + /* 450 */ 2109, 1560, 415, 182, 575, 1472, 1482, 1710, 195, 194, + /* 460 */ 46, 1498, 1501, 2007, 1136, 622, 1135, 2043, 597, 1795, + /* 470 */ 108, 2009, 642, 2011, 2012, 637, 1417, 632, 1415, 416, + /* 480 */ 85, 454, 729, 213, 2096, 60, 38, 37, 2095, 2092, + /* 490 */ 44, 42, 41, 40, 39, 1137, 1795, 1499, 1500, 138, + /* 500 */ 667, 1420, 1421, 60, 1471, 1474, 1475, 1476, 1477, 1478, + /* 510 */ 1479, 1480, 1481, 634, 630, 1490, 1491, 1493, 1494, 1495, + /* 520 */ 1496, 2, 1633, 528, 527, 526, 2008, 1472, 1482, 622, + /* 530 */ 1848, 135, 522, 1498, 1501, 1422, 521, 360, 581, 576, + /* 540 */ 570, 520, 525, 425, 49, 161, 1846, 519, 1417, 608, + /* 550 */ 1415, 212, 206, 1772, 1798, 1442, 211, 2026, 11, 488, + /* 560 */ 1795, 265, 178, 2104, 2105, 600, 136, 2109, 1664, 163, + /* 570 */ 1976, 1653, 638, 1420, 1421, 204, 1471, 1474, 1475, 1476, + /* 580 */ 1477, 1478, 1479, 1480, 1481, 634, 630, 1490, 1491, 1493, + /* 590 */ 1494, 1495, 1496, 2, 45, 43, 617, 688, 1907, 2007, + /* 600 */ 275, 276, 372, 2043, 1416, 274, 107, 2009, 642, 2011, + /* 610 */ 2012, 637, 1976, 632, 1654, 1497, 533, 1414, 176, 104, + /* 620 */ 2096, 1893, 38, 37, 366, 2092, 44, 42, 41, 40, + /* 630 */ 39, 543, 187, 139, 1444, 1425, 182, 1528, 585, 556, + /* 640 */ 1492, 1787, 2165, 38, 37, 231, 2123, 44, 42, 41, + /* 650 */ 40, 39, 1782, 1422, 182, 2008, 375, 584, 179, 385, + /* 660 */ 536, 674, 2166, 586, 161, 530, 45, 43, 1359, 1360, + /* 670 */ 230, 13, 12, 1797, 372, 406, 1416, 622, 46, 27, + /* 680 */ 152, 151, 671, 670, 669, 149, 2026, 1497, 624, 1414, + /* 690 */ 2068, 440, 1571, 71, 639, 182, 408, 404, 1441, 1976, + /* 700 */ 729, 638, 561, 622, 1358, 1361, 2165, 67, 1795, 32, + /* 710 */ 66, 98, 1492, 1848, 1848, 1499, 1500, 441, 2111, 1533, + /* 720 */ 365, 2171, 179, 1636, 1637, 1422, 2166, 586, 2007, 1846, + /* 730 */ 1847, 1594, 2043, 1788, 1795, 107, 2009, 642, 2011, 2012, + /* 740 */ 637, 1848, 632, 79, 2107, 1472, 1482, 2185, 376, 2096, + /* 750 */ 14, 1498, 1501, 366, 2092, 38, 37, 1846, 1778, 44, + /* 760 */ 42, 41, 40, 39, 2130, 1444, 1417, 1540, 1415, 384, + /* 770 */ 38, 37, 729, 238, 44, 42, 41, 40, 39, 243, + /* 780 */ 572, 1592, 1593, 1595, 1596, 1663, 1428, 1499, 1500, 1662, + /* 790 */ 191, 1420, 1421, 150, 1471, 1474, 1475, 1476, 1477, 1478, + /* 800 */ 1479, 1480, 1481, 634, 630, 1490, 1491, 1493, 1494, 1495, + /* 810 */ 1496, 2, 561, 329, 633, 1439, 2165, 1472, 1482, 41, + /* 820 */ 40, 39, 448, 1498, 1501, 462, 1642, 81, 461, 1976, + /* 830 */ 80, 2171, 179, 1976, 1564, 2111, 2166, 586, 1417, 1707, + /* 840 */ 1415, 1473, 666, 431, 1604, 463, 53, 120, 433, 1661, + /* 850 */ 119, 118, 117, 116, 115, 114, 113, 112, 111, 1583, + /* 860 */ 1660, 2106, 234, 1420, 1421, 1825, 1471, 1474, 1475, 1476, + /* 870 */ 1477, 1478, 1479, 1480, 1481, 634, 630, 1490, 1491, 1493, + /* 880 */ 1494, 1495, 1496, 2, 2169, 31, 378, 700, 698, 1659, + /* 890 */ 344, 38, 37, 1976, 161, 44, 42, 41, 40, 39, + /* 900 */ 1122, 1123, 421, 1797, 1976, 706, 705, 704, 703, 382, + /* 910 */ 188, 702, 701, 142, 696, 695, 694, 693, 692, 691, + /* 920 */ 690, 154, 686, 685, 684, 381, 380, 681, 680, 679, + /* 930 */ 678, 677, 459, 1976, 2008, 453, 452, 451, 450, 447, + /* 940 */ 446, 445, 444, 443, 439, 438, 437, 436, 328, 428, + /* 950 */ 427, 426, 1878, 423, 422, 342, 162, 1641, 1658, 1657, + /* 960 */ 232, 304, 1750, 38, 37, 2026, 1995, 44, 42, 41, + /* 970 */ 40, 39, 674, 639, 2136, 302, 70, 1990, 1976, 69, + /* 980 */ 638, 129, 128, 127, 126, 125, 124, 123, 122, 121, + /* 990 */ 1893, 152, 151, 671, 670, 669, 149, 200, 470, 468, + /* 1000 */ 465, 189, 1976, 1976, 11, 1656, 9, 2007, 2008, 1986, + /* 1010 */ 1992, 2043, 2116, 1560, 107, 2009, 642, 2011, 2012, 637, + /* 1020 */ 632, 632, 622, 87, 331, 1655, 2185, 546, 2096, 544, + /* 1030 */ 1652, 260, 366, 2092, 60, 1893, 491, 597, 626, 2026, + /* 1040 */ 2068, 622, 1507, 2143, 622, 622, 193, 639, 1441, 1976, + /* 1050 */ 33, 622, 1976, 1795, 638, 1792, 38, 37, 235, 557, + /* 1060 */ 44, 42, 41, 40, 39, 285, 622, 1651, 138, 1976, + /* 1070 */ 622, 1444, 1795, 106, 1976, 1795, 1795, 1650, 1563, 2008, + /* 1080 */ 601, 2007, 1795, 1649, 605, 2043, 1648, 592, 107, 2009, + /* 1090 */ 642, 2011, 2012, 637, 241, 632, 140, 1795, 589, 2067, + /* 1100 */ 2185, 1795, 2096, 689, 435, 1765, 366, 2092, 622, 668, + /* 1110 */ 2026, 1976, 1839, 434, 78, 77, 414, 568, 639, 186, + /* 1120 */ 160, 1976, 279, 1976, 1770, 638, 2008, 1976, 369, 368, + /* 1130 */ 1976, 180, 2104, 2105, 88, 136, 2109, 327, 1430, 1795, + /* 1140 */ 402, 1424, 400, 396, 392, 389, 386, 588, 1647, 1497, + /* 1150 */ 1646, 1423, 2007, 622, 1645, 622, 2043, 2026, 1644, 107, + /* 1160 */ 2009, 642, 2011, 2012, 637, 639, 632, 619, 52, 620, + /* 1170 */ 1976, 2185, 638, 2096, 1492, 560, 672, 366, 2092, 1839, + /* 1180 */ 673, 13, 12, 1839, 1795, 182, 1795, 1422, 2159, 629, + /* 1190 */ 622, 1473, 1976, 298, 1976, 549, 1825, 2008, 1976, 2007, + /* 1200 */ 517, 1416, 1976, 2043, 379, 573, 107, 2009, 642, 2011, + /* 1210 */ 2012, 637, 150, 632, 1414, 50, 242, 3, 2185, 216, + /* 1220 */ 2096, 1795, 516, 223, 366, 2092, 221, 144, 2026, 132, + /* 1230 */ 225, 254, 674, 224, 628, 2115, 639, 227, 561, 1697, + /* 1240 */ 226, 1976, 2165, 638, 229, 1690, 1688, 228, 62, 2027, + /* 1250 */ 1422, 152, 151, 671, 670, 669, 149, 2171, 179, 247, + /* 1260 */ 1997, 529, 2166, 586, 682, 1391, 150, 531, 534, 383, + /* 1270 */ 2007, 47, 2008, 103, 2043, 272, 1902, 107, 2009, 642, + /* 1280 */ 2011, 2012, 637, 100, 632, 683, 1185, 1166, 1836, 2071, + /* 1290 */ 1678, 2096, 1427, 68, 2126, 366, 2092, 729, 148, 1684, + /* 1300 */ 1431, 1591, 1426, 2026, 598, 47, 262, 1183, 150, 1999, + /* 1310 */ 1, 639, 249, 593, 259, 4, 1976, 388, 638, 604, + /* 1320 */ 341, 1378, 590, 1167, 1356, 1434, 1436, 62, 277, 2008, + /* 1330 */ 393, 292, 1444, 192, 1518, 1439, 420, 47, 630, 1490, + /* 1340 */ 1491, 1493, 1494, 1495, 1496, 2007, 614, 1903, 724, 2043, + /* 1350 */ 424, 281, 107, 2009, 642, 2011, 2012, 637, 297, 632, + /* 1360 */ 2026, 1237, 732, 1417, 2069, 1415, 2096, 646, 639, 148, + /* 1370 */ 366, 2092, 150, 1976, 457, 638, 291, 429, 442, 133, + /* 1380 */ 1534, 1895, 148, 456, 449, 458, 464, 467, 1420, 1421, + /* 1390 */ 1483, 172, 466, 197, 469, 471, 1445, 722, 718, 714, + /* 1400 */ 710, 289, 2007, 2008, 472, 1447, 2043, 481, 484, 107, + /* 1410 */ 2009, 642, 2011, 2012, 637, 203, 632, 1442, 205, 1446, + /* 1420 */ 1265, 625, 1269, 2096, 486, 1276, 1448, 366, 2092, 489, + /* 1430 */ 485, 487, 1274, 208, 2026, 153, 210, 82, 105, 83, + /* 1440 */ 493, 282, 639, 214, 1139, 510, 512, 1976, 511, 638, + /* 1450 */ 110, 330, 1953, 1952, 548, 514, 86, 1785, 220, 1781, + /* 1460 */ 550, 222, 155, 146, 156, 293, 551, 2008, 236, 1783, + /* 1470 */ 1779, 157, 158, 239, 618, 552, 2007, 558, 574, 2142, + /* 1480 */ 2043, 612, 555, 108, 2009, 642, 2011, 2012, 637, 583, + /* 1490 */ 632, 2008, 565, 7, 2118, 2141, 255, 2096, 2026, 571, + /* 1500 */ 2127, 627, 2092, 566, 2137, 169, 639, 355, 577, 269, + /* 1510 */ 245, 1976, 253, 638, 268, 563, 248, 564, 258, 356, + /* 1520 */ 256, 261, 2026, 257, 594, 2188, 2164, 591, 137, 1443, + /* 1530 */ 636, 1385, 1560, 237, 602, 1976, 359, 638, 1449, 2112, + /* 1540 */ 640, 267, 93, 1908, 2043, 610, 294, 108, 2009, 642, + /* 1550 */ 2011, 2012, 637, 295, 632, 2008, 611, 1922, 615, 1921, + /* 1560 */ 1920, 2096, 362, 616, 2007, 335, 2092, 296, 2043, 95, + /* 1570 */ 97, 320, 2009, 642, 2011, 2012, 637, 635, 632, 623, + /* 1580 */ 2061, 59, 1796, 99, 644, 2077, 2026, 1766, 725, 1840, + /* 1590 */ 728, 288, 323, 1970, 639, 299, 332, 51, 726, 1976, + /* 1600 */ 1969, 638, 2008, 303, 75, 1968, 333, 1967, 76, 301, + /* 1610 */ 1964, 308, 390, 391, 1408, 1409, 322, 312, 185, 2008, + /* 1620 */ 395, 1962, 397, 398, 399, 1961, 401, 1960, 2007, 403, + /* 1630 */ 1959, 405, 2043, 2026, 1958, 165, 2009, 642, 2011, 2012, + /* 1640 */ 637, 639, 632, 407, 1381, 1380, 1976, 1933, 638, 1932, + /* 1650 */ 2026, 412, 413, 1931, 1930, 1886, 1885, 1883, 639, 1333, + /* 1660 */ 143, 1882, 1881, 1976, 1884, 638, 1880, 1879, 1877, 1876, + /* 1670 */ 1875, 190, 430, 1874, 432, 2007, 562, 2133, 1888, 2043, + /* 1680 */ 145, 1858, 166, 2009, 642, 2011, 2012, 637, 1873, 632, + /* 1690 */ 1872, 1871, 2007, 1870, 2008, 1869, 2043, 1335, 1853, 108, + /* 1700 */ 2009, 642, 2011, 2012, 637, 1868, 632, 1867, 1866, 1865, + /* 1710 */ 1864, 1863, 1862, 2096, 1861, 1860, 1859, 1857, 2093, 1856, + /* 1720 */ 1887, 1855, 1854, 1852, 1851, 2026, 460, 1850, 1849, 1713, + /* 1730 */ 196, 1212, 1712, 639, 587, 2186, 1711, 198, 1976, 1709, + /* 1740 */ 638, 2008, 199, 1673, 201, 73, 1996, 174, 1125, 1124, + /* 1750 */ 1672, 477, 1946, 1940, 1929, 1928, 209, 2008, 202, 1906, + /* 1760 */ 479, 1774, 1708, 1706, 74, 207, 1159, 2007, 494, 496, + /* 1770 */ 1704, 2043, 2026, 1702, 165, 2009, 642, 2011, 2012, 637, + /* 1780 */ 639, 632, 498, 500, 502, 1976, 495, 638, 2026, 499, + /* 1790 */ 503, 1700, 506, 507, 1687, 504, 639, 1686, 1669, 508, + /* 1800 */ 1776, 1976, 1281, 638, 1280, 61, 1775, 1203, 697, 1202, + /* 1810 */ 699, 1201, 1200, 1197, 2007, 2008, 2134, 1195, 2043, 1196, + /* 1820 */ 1194, 314, 2009, 642, 2011, 2012, 637, 1698, 632, 349, + /* 1830 */ 2007, 2008, 1691, 350, 2043, 1689, 532, 166, 2009, 642, + /* 1840 */ 2011, 2012, 637, 219, 632, 351, 2026, 535, 1668, 537, + /* 1850 */ 1667, 361, 539, 1666, 639, 541, 109, 1945, 1939, 1976, + /* 1860 */ 1398, 638, 2026, 1397, 26, 582, 1400, 545, 553, 1387, + /* 1870 */ 636, 1927, 159, 1925, 19, 1976, 567, 638, 1606, 2170, + /* 1880 */ 16, 569, 58, 28, 244, 251, 246, 1590, 2007, 167, + /* 1890 */ 2187, 2008, 2043, 1582, 20, 321, 2009, 642, 2011, 2012, + /* 1900 */ 637, 250, 632, 5, 2007, 29, 252, 2008, 2043, 1997, + /* 1910 */ 559, 320, 2009, 642, 2011, 2012, 637, 89, 632, 30, + /* 1920 */ 2062, 1626, 2026, 6, 63, 21, 1627, 371, 17, 1621, + /* 1930 */ 639, 1620, 240, 357, 1625, 1976, 55, 638, 2026, 1624, + /* 1940 */ 358, 1557, 1556, 373, 554, 353, 639, 264, 170, 1926, + /* 1950 */ 57, 1976, 1924, 638, 1923, 1905, 91, 92, 270, 22, + /* 1960 */ 613, 271, 2008, 1588, 2007, 273, 278, 1904, 2043, 94, + /* 1970 */ 65, 321, 2009, 642, 2011, 2012, 637, 23, 632, 280, + /* 1980 */ 2007, 96, 283, 100, 2043, 12, 1432, 321, 2009, 642, + /* 1990 */ 2011, 2012, 637, 2026, 632, 171, 1464, 183, 2046, 643, + /* 2000 */ 1487, 639, 1258, 631, 645, 36, 1976, 1485, 638, 2008, + /* 2010 */ 1484, 15, 1519, 24, 374, 641, 1456, 1266, 25, 647, + /* 2020 */ 649, 1263, 650, 652, 1260, 653, 2008, 655, 56, 1509, + /* 2030 */ 658, 1254, 1508, 10, 656, 547, 1252, 659, 1243, 2043, + /* 2040 */ 2026, 101, 316, 2009, 642, 2011, 2012, 637, 639, 632, + /* 2050 */ 665, 1257, 1256, 1976, 102, 638, 286, 2026, 1275, 72, + /* 2060 */ 1255, 1271, 1157, 675, 1191, 639, 1190, 1189, 1188, 1187, + /* 2070 */ 1976, 1186, 638, 1184, 1210, 1182, 1181, 1180, 1178, 687, + /* 2080 */ 1177, 287, 2007, 1176, 1175, 1174, 2043, 2008, 1173, 305, + /* 2090 */ 2009, 642, 2011, 2012, 637, 1172, 632, 1207, 1205, 2007, + /* 2100 */ 1169, 1168, 1165, 2043, 2008, 1164, 306, 2009, 642, 2011, + /* 2110 */ 2012, 637, 1163, 632, 1162, 1705, 707, 708, 2026, 709, + /* 2120 */ 1703, 711, 712, 713, 1701, 716, 639, 715, 717, 1699, + /* 2130 */ 719, 1976, 721, 638, 1685, 2026, 720, 723, 1114, 1665, + /* 2140 */ 290, 1418, 727, 639, 300, 1640, 730, 731, 1976, 1640, + /* 2150 */ 638, 2008, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, + /* 2160 */ 2007, 1640, 1640, 1640, 2043, 1640, 1640, 307, 2009, 642, + /* 2170 */ 2011, 2012, 637, 1640, 632, 1640, 2008, 2007, 1640, 1640, + /* 2180 */ 1640, 2043, 2026, 1640, 313, 2009, 642, 2011, 2012, 637, + /* 2190 */ 639, 632, 1640, 1640, 1640, 1976, 1640, 638, 1640, 1640, + /* 2200 */ 1640, 1640, 1640, 1640, 1640, 1640, 1640, 2026, 1640, 1640, + /* 2210 */ 1640, 1640, 1640, 1640, 1640, 639, 1640, 1640, 1640, 1640, + /* 2220 */ 1976, 1640, 638, 1640, 2007, 1640, 1640, 1640, 2043, 1640, + /* 2230 */ 1640, 317, 2009, 642, 2011, 2012, 637, 2008, 632, 1640, + /* 2240 */ 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 2007, + /* 2250 */ 1640, 1640, 1640, 2043, 1640, 1640, 309, 2009, 642, 2011, + /* 2260 */ 2012, 637, 1640, 632, 1640, 2008, 1640, 1640, 2026, 1640, + /* 2270 */ 1640, 1640, 1640, 1640, 1640, 1640, 639, 1640, 1640, 1640, + /* 2280 */ 1640, 1976, 1640, 638, 1640, 1640, 1640, 1640, 1640, 1640, + /* 2290 */ 1640, 1640, 1640, 1640, 1640, 1640, 2026, 1640, 1640, 1640, + /* 2300 */ 1640, 1640, 1640, 1640, 639, 1640, 1640, 1640, 1640, 1976, + /* 2310 */ 2007, 638, 1640, 1640, 2043, 1640, 1640, 318, 2009, 642, + /* 2320 */ 2011, 2012, 637, 2008, 632, 1640, 1640, 1640, 1640, 1640, + /* 2330 */ 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 2007, 2008, + /* 2340 */ 1640, 1640, 2043, 1640, 1640, 310, 2009, 642, 2011, 2012, + /* 2350 */ 637, 1640, 632, 1640, 2026, 1640, 1640, 1640, 1640, 1640, + /* 2360 */ 1640, 1640, 639, 1640, 1640, 1640, 1640, 1976, 1640, 638, + /* 2370 */ 2026, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 639, 1640, + /* 2380 */ 1640, 1640, 1640, 1976, 1640, 638, 1640, 1640, 1640, 1640, + /* 2390 */ 1640, 1640, 1640, 1640, 1640, 1640, 2007, 1640, 1640, 1640, + /* 2400 */ 2043, 1640, 2008, 319, 2009, 642, 2011, 2012, 637, 1640, + /* 2410 */ 632, 1640, 2007, 1640, 1640, 1640, 2043, 1640, 1640, 311, + /* 2420 */ 2009, 642, 2011, 2012, 637, 1640, 632, 1640, 1640, 1640, + /* 2430 */ 1640, 1640, 1640, 2026, 2008, 1640, 1640, 1640, 1640, 1640, + /* 2440 */ 1640, 639, 1640, 1640, 1640, 1640, 1976, 1640, 638, 1640, + /* 2450 */ 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, + /* 2460 */ 1640, 1640, 1640, 1640, 1640, 2026, 1640, 1640, 1640, 1640, + /* 2470 */ 1640, 1640, 1640, 639, 1640, 2007, 1640, 1640, 1976, 2043, + /* 2480 */ 638, 2008, 324, 2009, 642, 2011, 2012, 637, 1640, 632, + /* 2490 */ 1640, 1640, 1640, 1640, 1640, 1640, 1640, 2008, 1640, 1640, + /* 2500 */ 1640, 1640, 1640, 1640, 1640, 1640, 1640, 2007, 1640, 1640, + /* 2510 */ 1640, 2043, 2026, 1640, 325, 2009, 642, 2011, 2012, 637, + /* 2520 */ 639, 632, 1640, 1640, 1640, 1976, 1640, 638, 2026, 1640, + /* 2530 */ 1640, 1640, 1640, 1640, 1640, 1640, 639, 1640, 1640, 1640, + /* 2540 */ 1640, 1976, 1640, 638, 1640, 1640, 1640, 1640, 1640, 1640, + /* 2550 */ 1640, 1640, 2008, 1640, 2007, 1640, 1640, 1640, 2043, 1640, + /* 2560 */ 1640, 2020, 2009, 642, 2011, 2012, 637, 1640, 632, 1640, + /* 2570 */ 2007, 1640, 1640, 1640, 2043, 1640, 1640, 2019, 2009, 642, + /* 2580 */ 2011, 2012, 637, 2026, 632, 1640, 1640, 1640, 1640, 1640, + /* 2590 */ 1640, 639, 1640, 1640, 1640, 1640, 1976, 1640, 638, 1640, + /* 2600 */ 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, + /* 2610 */ 1640, 2008, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, + /* 2620 */ 1640, 1640, 1640, 1640, 1640, 2007, 1640, 1640, 1640, 2043, + /* 2630 */ 1640, 1640, 2018, 2009, 642, 2011, 2012, 637, 1640, 632, + /* 2640 */ 1640, 2008, 2026, 1640, 1640, 1640, 1640, 1640, 1640, 1640, + /* 2650 */ 639, 1640, 1640, 1640, 1640, 1976, 1640, 638, 1640, 1640, + /* 2660 */ 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 2008, + /* 2670 */ 1640, 1640, 2026, 1640, 1640, 1640, 1640, 1640, 1640, 1640, + /* 2680 */ 639, 1640, 1640, 1640, 2007, 1976, 1640, 638, 2043, 1640, + /* 2690 */ 1640, 337, 2009, 642, 2011, 2012, 637, 1640, 632, 2008, + /* 2700 */ 2026, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 639, 1640, + /* 2710 */ 1640, 1640, 1640, 1976, 2007, 638, 1640, 1640, 2043, 1640, + /* 2720 */ 1640, 338, 2009, 642, 2011, 2012, 637, 1640, 632, 1640, + /* 2730 */ 2026, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 639, 1640, + /* 2740 */ 1640, 1640, 2007, 1976, 1640, 638, 2043, 1640, 1640, 334, + /* 2750 */ 2009, 642, 2011, 2012, 637, 1640, 632, 1640, 1640, 1640, + /* 2760 */ 1640, 1640, 1640, 2008, 1640, 1640, 1640, 1640, 1640, 1640, + /* 2770 */ 1640, 1640, 2007, 1640, 1640, 1640, 2043, 1640, 1640, 339, + /* 2780 */ 2009, 642, 2011, 2012, 637, 1640, 632, 1640, 1640, 1640, + /* 2790 */ 1640, 1640, 1640, 1640, 2026, 2008, 1640, 1640, 1640, 1640, + /* 2800 */ 1640, 1640, 639, 1640, 1640, 1640, 1640, 1976, 1640, 638, + /* 2810 */ 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, + /* 2820 */ 1640, 1640, 1640, 1640, 1640, 1640, 2026, 1640, 1640, 1640, + /* 2830 */ 1640, 1640, 1640, 1640, 639, 1640, 640, 1640, 1640, 1976, + /* 2840 */ 2043, 638, 1640, 316, 2009, 642, 2011, 2012, 637, 1640, + /* 2850 */ 632, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, + /* 2860 */ 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 2007, 1640, + /* 2870 */ 1640, 1640, 2043, 1640, 1640, 315, 2009, 642, 2011, 2012, + /* 2880 */ 637, 1640, 632, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 359, 336, 360, 328, 361, 374, 332, 366, 334, 335, - /* 10 */ 361, 360, 12, 13, 14, 372, 375, 360, 387, 388, - /* 20 */ 20, 372, 22, 8, 9, 4, 4, 12, 13, 14, - /* 30 */ 15, 16, 0, 33, 359, 35, 332, 20, 334, 335, - /* 40 */ 19, 376, 367, 374, 401, 402, 403, 372, 20, 374, - /* 50 */ 401, 402, 403, 384, 33, 412, 387, 388, 58, 44, - /* 60 */ 352, 412, 328, 355, 64, 43, 431, 45, 46, 48, - /* 70 */ 435, 71, 370, 398, 53, 373, 374, 402, 20, 58, - /* 80 */ 405, 406, 407, 408, 409, 410, 451, 412, 359, 20, - /* 90 */ 455, 456, 417, 359, 419, 63, 96, 0, 423, 424, - /* 100 */ 333, 367, 343, 336, 337, 63, 372, 348, 374, 380, - /* 110 */ 381, 333, 437, 96, 336, 337, 95, 336, 118, 98, - /* 120 */ 445, 24, 25, 26, 27, 28, 29, 30, 31, 32, - /* 130 */ 20, 350, 398, 133, 134, 20, 402, 351, 357, 405, - /* 140 */ 406, 407, 408, 409, 410, 359, 412, 3, 367, 415, - /* 150 */ 0, 417, 418, 419, 368, 20, 63, 423, 424, 14, - /* 160 */ 15, 16, 162, 163, 20, 96, 14, 14, 168, 169, - /* 170 */ 359, 21, 20, 20, 24, 25, 26, 27, 28, 29, - /* 180 */ 30, 31, 32, 183, 342, 185, 375, 109, 110, 111, - /* 190 */ 112, 113, 114, 115, 116, 117, 118, 119, 356, 121, - /* 200 */ 122, 123, 124, 125, 126, 0, 404, 365, 208, 209, - /* 210 */ 35, 211, 212, 213, 214, 215, 216, 217, 218, 219, - /* 220 */ 220, 221, 222, 223, 224, 225, 226, 227, 228, 12, - /* 230 */ 13, 96, 430, 18, 167, 20, 58, 20, 20, 22, - /* 240 */ 22, 97, 27, 133, 134, 30, 71, 328, 33, 20, - /* 250 */ 33, 21, 35, 35, 24, 25, 26, 27, 28, 29, - /* 260 */ 30, 31, 32, 48, 358, 50, 96, 328, 53, 51, - /* 270 */ 20, 66, 67, 68, 96, 58, 98, 371, 359, 74, - /* 280 */ 75, 64, 230, 325, 79, 336, 367, 107, 71, 84, - /* 290 */ 85, 372, 359, 374, 71, 90, 96, 8, 9, 350, - /* 300 */ 367, 12, 13, 14, 15, 16, 357, 4, 164, 20, - /* 310 */ 95, 372, 178, 96, 162, 246, 367, 398, 251, 252, - /* 320 */ 253, 402, 107, 359, 405, 406, 407, 408, 409, 410, - /* 330 */ 366, 412, 340, 199, 200, 118, 417, 361, 419, 375, - /* 340 */ 407, 0, 423, 424, 420, 421, 354, 389, 372, 71, - /* 350 */ 133, 134, 137, 434, 362, 140, 141, 142, 143, 144, - /* 360 */ 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, - /* 370 */ 155, 156, 336, 158, 159, 160, 360, 401, 402, 162, - /* 380 */ 163, 246, 127, 128, 336, 168, 169, 132, 412, 431, - /* 390 */ 360, 162, 163, 435, 359, 35, 20, 33, 22, 96, - /* 400 */ 183, 366, 185, 367, 63, 1, 2, 96, 450, 451, - /* 410 */ 375, 328, 48, 455, 456, 367, 246, 14, 54, 55, - /* 420 */ 56, 57, 58, 20, 246, 208, 209, 51, 211, 212, - /* 430 */ 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, - /* 440 */ 223, 224, 225, 226, 227, 228, 246, 230, 12, 13, - /* 450 */ 327, 359, 329, 164, 415, 372, 20, 418, 22, 95, - /* 460 */ 373, 374, 98, 427, 428, 429, 431, 431, 432, 33, - /* 470 */ 435, 35, 20, 381, 336, 427, 428, 429, 367, 431, - /* 480 */ 432, 369, 336, 435, 372, 450, 451, 328, 350, 378, - /* 490 */ 455, 456, 336, 182, 58, 184, 350, 367, 450, 451, - /* 500 */ 64, 97, 127, 455, 456, 367, 350, 71, 378, 66, - /* 510 */ 67, 68, 328, 367, 345, 346, 431, 74, 75, 18, - /* 520 */ 435, 342, 79, 367, 23, 12, 13, 84, 85, 165, - /* 530 */ 166, 372, 96, 90, 170, 22, 451, 173, 37, 38, - /* 540 */ 455, 456, 41, 359, 365, 185, 33, 37, 35, 246, - /* 550 */ 336, 367, 336, 189, 118, 360, 372, 246, 374, 404, - /* 560 */ 59, 60, 61, 62, 350, 162, 350, 192, 193, 133, - /* 570 */ 134, 58, 8, 9, 208, 20, 12, 13, 14, 15, - /* 580 */ 16, 367, 398, 367, 71, 430, 402, 20, 340, 405, - /* 590 */ 406, 407, 408, 409, 410, 367, 412, 96, 162, 163, - /* 600 */ 20, 417, 58, 419, 168, 169, 378, 423, 424, 99, - /* 610 */ 362, 101, 102, 431, 104, 404, 164, 435, 108, 183, - /* 620 */ 4, 185, 22, 257, 258, 259, 260, 261, 64, 445, - /* 630 */ 360, 118, 450, 451, 44, 35, 135, 455, 456, 95, - /* 640 */ 130, 430, 98, 20, 208, 209, 108, 211, 212, 213, - /* 650 */ 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, - /* 660 */ 224, 225, 226, 227, 228, 12, 13, 14, 130, 105, - /* 670 */ 108, 71, 21, 20, 80, 22, 175, 176, 177, 369, - /* 680 */ 128, 180, 372, 328, 328, 34, 33, 36, 35, 127, - /* 690 */ 128, 129, 130, 131, 132, 336, 183, 328, 185, 198, - /* 700 */ 161, 3, 201, 359, 203, 204, 205, 206, 207, 350, - /* 710 */ 366, 58, 351, 393, 230, 359, 232, 162, 118, 375, - /* 720 */ 359, 208, 209, 367, 71, 161, 367, 372, 372, 368, - /* 730 */ 374, 164, 138, 139, 221, 222, 223, 224, 225, 226, - /* 740 */ 227, 372, 190, 191, 164, 336, 194, 246, 196, 96, - /* 750 */ 336, 328, 351, 416, 398, 418, 133, 134, 402, 350, - /* 760 */ 359, 405, 406, 407, 408, 409, 410, 369, 412, 368, - /* 770 */ 372, 118, 233, 417, 328, 419, 367, 345, 346, 423, - /* 780 */ 424, 367, 243, 183, 107, 185, 133, 134, 0, 39, - /* 790 */ 434, 168, 169, 328, 416, 372, 418, 233, 234, 235, - /* 800 */ 236, 237, 238, 239, 240, 241, 242, 243, 208, 209, - /* 810 */ 12, 13, 14, 15, 16, 162, 163, 0, 372, 336, - /* 820 */ 352, 168, 169, 355, 8, 9, 0, 0, 12, 13, - /* 830 */ 14, 15, 16, 350, 157, 359, 183, 372, 185, 22, - /* 840 */ 426, 427, 428, 429, 368, 431, 432, 8, 9, 0, - /* 850 */ 367, 12, 13, 14, 15, 16, 328, 328, 328, 269, - /* 860 */ 328, 208, 209, 247, 211, 212, 213, 214, 215, 216, - /* 870 */ 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, - /* 880 */ 227, 228, 12, 13, 347, 44, 349, 45, 46, 0, - /* 890 */ 20, 328, 22, 336, 336, 336, 108, 48, 244, 245, - /* 900 */ 372, 372, 372, 33, 372, 35, 329, 350, 350, 350, - /* 910 */ 42, 22, 44, 97, 22, 127, 128, 129, 130, 131, - /* 920 */ 132, 44, 359, 328, 367, 367, 367, 35, 58, 336, - /* 930 */ 367, 348, 389, 336, 108, 372, 97, 374, 97, 459, - /* 940 */ 42, 71, 44, 350, 8, 9, 328, 350, 12, 13, - /* 950 */ 14, 15, 16, 127, 128, 129, 130, 131, 132, 389, - /* 960 */ 367, 398, 448, 265, 367, 402, 96, 372, 405, 406, - /* 970 */ 407, 408, 409, 410, 431, 412, 338, 336, 435, 152, - /* 980 */ 417, 382, 419, 328, 328, 359, 423, 424, 118, 442, - /* 990 */ 372, 350, 328, 450, 451, 245, 328, 434, 455, 456, - /* 1000 */ 2, 431, 0, 133, 134, 435, 8, 9, 367, 64, - /* 1010 */ 12, 13, 14, 15, 16, 359, 100, 133, 134, 103, - /* 1020 */ 450, 451, 338, 367, 22, 455, 456, 372, 372, 336, - /* 1030 */ 374, 328, 162, 163, 100, 2, 372, 103, 168, 169, - /* 1040 */ 372, 8, 9, 350, 35, 12, 13, 14, 15, 16, - /* 1050 */ 335, 44, 13, 183, 398, 185, 100, 328, 402, 103, - /* 1060 */ 367, 405, 406, 407, 408, 409, 410, 411, 412, 413, - /* 1070 */ 414, 389, 336, 100, 35, 372, 103, 382, 208, 209, - /* 1080 */ 371, 211, 212, 213, 214, 215, 216, 217, 218, 219, - /* 1090 */ 220, 221, 222, 223, 224, 225, 226, 227, 228, 12, - /* 1100 */ 13, 372, 58, 367, 97, 336, 44, 20, 328, 22, - /* 1110 */ 35, 175, 336, 431, 389, 382, 44, 435, 164, 350, - /* 1120 */ 33, 44, 35, 8, 9, 171, 350, 12, 13, 14, - /* 1130 */ 15, 16, 450, 451, 433, 336, 367, 455, 456, 359, - /* 1140 */ 44, 336, 98, 367, 267, 58, 71, 367, 336, 350, - /* 1150 */ 1, 2, 372, 208, 374, 350, 431, 44, 71, 97, - /* 1160 */ 435, 96, 350, 427, 428, 429, 367, 431, 432, 97, - /* 1170 */ 47, 106, 367, 44, 97, 450, 451, 425, 398, 367, - /* 1180 */ 455, 456, 402, 96, 336, 405, 406, 407, 408, 409, - /* 1190 */ 410, 389, 412, 97, 185, 44, 13, 417, 350, 419, - /* 1200 */ 452, 328, 436, 423, 424, 118, 270, 44, 44, 44, - /* 1210 */ 97, 44, 44, 44, 434, 367, 248, 399, 35, 96, - /* 1220 */ 133, 134, 400, 8, 9, 0, 97, 12, 13, 14, - /* 1230 */ 15, 16, 359, 431, 44, 44, 48, 435, 181, 42, - /* 1240 */ 367, 391, 379, 20, 382, 372, 379, 374, 97, 162, - /* 1250 */ 163, 0, 450, 451, 161, 168, 169, 455, 456, 377, - /* 1260 */ 97, 97, 97, 20, 97, 97, 97, 336, 336, 379, - /* 1270 */ 183, 398, 185, 377, 49, 402, 377, 336, 405, 406, - /* 1280 */ 407, 408, 409, 410, 344, 412, 94, 97, 97, 336, - /* 1290 */ 20, 336, 419, 336, 330, 208, 209, 424, 211, 212, - /* 1300 */ 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, - /* 1310 */ 223, 224, 225, 226, 227, 228, 328, 66, 67, 68, - /* 1320 */ 69, 70, 330, 72, 73, 74, 75, 76, 77, 78, - /* 1330 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, - /* 1340 */ 89, 90, 91, 92, 20, 395, 342, 359, 361, 20, - /* 1350 */ 374, 20, 342, 337, 20, 367, 390, 342, 337, 372, - /* 1360 */ 372, 342, 374, 336, 342, 342, 342, 52, 339, 339, - /* 1370 */ 330, 359, 359, 359, 336, 330, 359, 359, 372, 164, - /* 1380 */ 372, 197, 328, 397, 359, 359, 398, 359, 401, 402, - /* 1390 */ 402, 359, 395, 405, 406, 407, 408, 409, 410, 412, - /* 1400 */ 412, 359, 359, 340, 188, 417, 340, 419, 374, 336, - /* 1410 */ 256, 423, 424, 359, 394, 441, 255, 382, 382, 372, - /* 1420 */ 372, 367, 434, 441, 372, 372, 372, 444, 374, 174, - /* 1430 */ 441, 385, 262, 443, 385, 264, 328, 263, 249, 440, - /* 1440 */ 439, 438, 266, 271, 460, 268, 245, 454, 453, 367, - /* 1450 */ 400, 20, 398, 336, 340, 404, 402, 337, 340, 405, - /* 1460 */ 406, 407, 408, 409, 410, 385, 412, 359, 385, 372, - /* 1470 */ 372, 417, 372, 419, 372, 367, 372, 423, 424, 372, - /* 1480 */ 372, 340, 374, 166, 383, 355, 340, 96, 367, 422, - /* 1490 */ 96, 363, 349, 336, 372, 340, 36, 331, 392, 396, - /* 1500 */ 353, 353, 386, 330, 0, 386, 398, 328, 326, 353, - /* 1510 */ 402, 0, 190, 405, 406, 407, 408, 409, 410, 341, - /* 1520 */ 412, 0, 0, 42, 0, 417, 35, 419, 202, 35, - /* 1530 */ 35, 423, 424, 35, 328, 202, 0, 35, 359, 202, - /* 1540 */ 35, 0, 202, 0, 35, 0, 367, 22, 0, 35, - /* 1550 */ 185, 372, 183, 374, 0, 0, 179, 178, 0, 0, - /* 1560 */ 47, 0, 0, 0, 0, 359, 0, 0, 0, 42, - /* 1570 */ 0, 0, 0, 367, 0, 152, 0, 398, 372, 35, - /* 1580 */ 374, 402, 152, 0, 405, 406, 407, 408, 409, 410, - /* 1590 */ 0, 412, 0, 0, 0, 0, 417, 22, 419, 0, - /* 1600 */ 0, 328, 423, 424, 398, 0, 0, 0, 402, 0, - /* 1610 */ 0, 405, 406, 407, 408, 409, 410, 0, 412, 0, - /* 1620 */ 0, 42, 0, 0, 328, 419, 0, 0, 0, 423, - /* 1630 */ 424, 0, 359, 0, 0, 136, 0, 0, 58, 35, - /* 1640 */ 367, 0, 58, 0, 58, 372, 0, 374, 0, 47, - /* 1650 */ 42, 39, 14, 14, 0, 359, 40, 44, 47, 0, - /* 1660 */ 39, 47, 0, 367, 0, 0, 174, 0, 372, 39, - /* 1670 */ 374, 398, 103, 48, 39, 402, 0, 0, 405, 406, - /* 1680 */ 407, 408, 409, 410, 0, 412, 35, 0, 35, 65, - /* 1690 */ 48, 328, 419, 0, 398, 39, 423, 424, 402, 39, - /* 1700 */ 48, 405, 406, 407, 408, 409, 410, 0, 412, 35, - /* 1710 */ 35, 328, 0, 0, 48, 419, 0, 39, 0, 423, - /* 1720 */ 424, 35, 359, 105, 22, 0, 35, 44, 22, 35, - /* 1730 */ 367, 35, 35, 44, 35, 372, 35, 374, 35, 0, - /* 1740 */ 0, 22, 359, 22, 0, 50, 22, 0, 0, 35, - /* 1750 */ 367, 0, 35, 22, 20, 372, 0, 374, 35, 96, - /* 1760 */ 195, 398, 35, 35, 35, 402, 97, 164, 405, 406, - /* 1770 */ 407, 408, 409, 410, 0, 412, 22, 186, 0, 164, - /* 1780 */ 0, 398, 3, 250, 96, 402, 44, 97, 405, 406, - /* 1790 */ 407, 408, 409, 410, 96, 412, 254, 97, 166, 44, - /* 1800 */ 328, 172, 229, 44, 164, 97, 96, 96, 47, 446, - /* 1810 */ 447, 96, 47, 44, 44, 171, 171, 97, 96, 3, - /* 1820 */ 35, 35, 35, 97, 35, 35, 35, 250, 47, 97, - /* 1830 */ 97, 359, 250, 97, 0, 47, 44, 0, 0, 367, - /* 1840 */ 457, 458, 244, 0, 372, 96, 374, 39, 96, 167, - /* 1850 */ 97, 0, 39, 96, 328, 97, 96, 47, 96, 96, - /* 1860 */ 2, 44, 47, 22, 96, 208, 47, 22, 97, 165, - /* 1870 */ 398, 96, 106, 97, 402, 108, 229, 405, 406, 407, - /* 1880 */ 408, 409, 410, 210, 412, 359, 231, 229, 35, 96, - /* 1890 */ 107, 97, 96, 367, 96, 35, 97, 96, 372, 97, - /* 1900 */ 374, 96, 35, 97, 97, 96, 328, 35, 96, 35, - /* 1910 */ 35, 97, 22, 44, 96, 120, 35, 97, 96, 447, - /* 1920 */ 120, 96, 96, 120, 398, 328, 96, 22, 402, 65, - /* 1930 */ 64, 405, 406, 407, 408, 409, 410, 359, 412, 35, - /* 1940 */ 93, 120, 71, 35, 35, 367, 35, 35, 35, 35, - /* 1950 */ 372, 35, 374, 35, 35, 35, 359, 35, 35, 44, - /* 1960 */ 22, 364, 35, 35, 367, 35, 71, 35, 35, 372, - /* 1970 */ 35, 374, 35, 22, 35, 449, 398, 35, 0, 35, - /* 1980 */ 402, 0, 48, 405, 406, 407, 408, 409, 410, 39, - /* 1990 */ 412, 35, 39, 48, 0, 398, 35, 48, 39, 402, - /* 2000 */ 328, 35, 405, 406, 407, 408, 409, 410, 0, 412, - /* 2010 */ 48, 39, 0, 0, 35, 35, 20, 22, 21, 21, - /* 2020 */ 328, 22, 22, 461, 461, 461, 461, 461, 461, 461, - /* 2030 */ 461, 359, 461, 461, 461, 461, 458, 461, 461, 367, - /* 2040 */ 461, 461, 461, 461, 372, 461, 374, 461, 461, 461, - /* 2050 */ 461, 359, 461, 461, 461, 461, 364, 461, 461, 367, - /* 2060 */ 461, 461, 461, 461, 372, 461, 374, 461, 461, 461, - /* 2070 */ 398, 461, 461, 461, 402, 461, 461, 405, 406, 407, - /* 2080 */ 408, 409, 410, 461, 412, 461, 414, 461, 461, 461, - /* 2090 */ 398, 461, 461, 461, 402, 461, 461, 405, 406, 407, - /* 2100 */ 408, 409, 410, 461, 412, 461, 461, 461, 461, 461, - /* 2110 */ 328, 461, 461, 461, 461, 461, 461, 461, 461, 461, - /* 2120 */ 461, 461, 19, 461, 461, 461, 461, 461, 461, 461, - /* 2130 */ 461, 461, 461, 461, 461, 461, 33, 461, 461, 328, - /* 2140 */ 461, 359, 461, 461, 461, 461, 364, 461, 461, 367, - /* 2150 */ 461, 48, 461, 461, 372, 461, 374, 54, 55, 56, - /* 2160 */ 57, 58, 461, 461, 461, 461, 461, 461, 328, 461, - /* 2170 */ 359, 461, 461, 461, 461, 461, 461, 461, 367, 461, - /* 2180 */ 398, 461, 461, 372, 402, 374, 461, 405, 406, 407, - /* 2190 */ 408, 409, 410, 461, 412, 461, 461, 461, 95, 359, - /* 2200 */ 461, 98, 461, 461, 461, 461, 461, 367, 461, 398, - /* 2210 */ 461, 461, 372, 402, 374, 461, 405, 406, 407, 408, - /* 2220 */ 409, 410, 461, 412, 461, 461, 461, 461, 461, 461, - /* 2230 */ 461, 461, 461, 461, 131, 328, 461, 461, 398, 461, - /* 2240 */ 461, 461, 402, 461, 461, 405, 406, 407, 408, 409, - /* 2250 */ 410, 461, 412, 461, 328, 461, 461, 461, 461, 461, - /* 2260 */ 461, 461, 461, 461, 461, 461, 359, 461, 165, 461, - /* 2270 */ 461, 461, 461, 170, 367, 461, 461, 461, 461, 372, - /* 2280 */ 461, 374, 461, 461, 461, 359, 461, 461, 461, 461, - /* 2290 */ 187, 461, 189, 367, 461, 461, 461, 461, 372, 461, - /* 2300 */ 374, 461, 461, 461, 461, 398, 461, 461, 461, 402, - /* 2310 */ 461, 461, 405, 406, 407, 408, 409, 410, 461, 412, - /* 2320 */ 461, 461, 461, 461, 398, 461, 461, 461, 402, 328, - /* 2330 */ 461, 405, 406, 407, 408, 409, 410, 461, 412, 461, - /* 2340 */ 461, 461, 461, 461, 461, 461, 461, 461, 461, 328, - /* 2350 */ 461, 461, 461, 461, 461, 461, 461, 461, 461, 461, - /* 2360 */ 359, 461, 461, 461, 461, 461, 461, 461, 367, 461, - /* 2370 */ 461, 461, 461, 372, 461, 374, 461, 461, 461, 461, - /* 2380 */ 359, 461, 461, 461, 461, 461, 461, 461, 367, 461, - /* 2390 */ 461, 461, 461, 372, 461, 374, 461, 461, 461, 398, - /* 2400 */ 461, 461, 461, 402, 461, 461, 405, 406, 407, 408, - /* 2410 */ 409, 410, 461, 412, 461, 328, 461, 461, 461, 398, - /* 2420 */ 461, 461, 461, 402, 461, 461, 405, 406, 407, 408, - /* 2430 */ 409, 410, 461, 412, 461, 461, 461, 461, 461, 461, - /* 2440 */ 461, 461, 461, 461, 461, 461, 359, 461, 461, 461, - /* 2450 */ 461, 461, 461, 461, 367, 461, 461, 461, 461, 372, - /* 2460 */ 461, 374, 461, 461, 461, 461, 461, 461, 461, 461, - /* 2470 */ 328, 461, 461, 461, 461, 461, 461, 461, 461, 461, - /* 2480 */ 461, 461, 461, 461, 461, 398, 328, 461, 461, 402, - /* 2490 */ 461, 461, 405, 406, 407, 408, 409, 410, 461, 412, - /* 2500 */ 461, 359, 461, 461, 461, 461, 461, 461, 461, 367, - /* 2510 */ 461, 461, 461, 461, 372, 461, 374, 359, 461, 461, - /* 2520 */ 461, 461, 461, 461, 461, 367, 461, 461, 461, 461, - /* 2530 */ 372, 461, 374, 461, 461, 461, 461, 461, 328, 461, - /* 2540 */ 398, 461, 461, 461, 402, 461, 461, 405, 406, 407, - /* 2550 */ 408, 409, 410, 461, 412, 461, 398, 461, 461, 461, - /* 2560 */ 402, 461, 461, 405, 406, 407, 408, 409, 410, 359, - /* 2570 */ 412, 461, 461, 461, 461, 461, 461, 367, 461, 461, - /* 2580 */ 461, 461, 372, 461, 374, 461, 461, 461, 461, 461, - /* 2590 */ 461, 461, 461, 461, 461, 328, 461, 461, 461, 461, - /* 2600 */ 461, 461, 461, 461, 461, 461, 461, 461, 398, 461, - /* 2610 */ 461, 461, 402, 461, 328, 405, 406, 407, 408, 409, - /* 2620 */ 410, 461, 412, 461, 461, 461, 359, 461, 461, 461, - /* 2630 */ 461, 461, 461, 461, 367, 461, 461, 461, 461, 372, - /* 2640 */ 461, 374, 461, 461, 461, 359, 461, 461, 461, 461, - /* 2650 */ 461, 461, 461, 367, 461, 461, 461, 461, 372, 461, - /* 2660 */ 374, 461, 461, 461, 461, 398, 461, 461, 461, 402, - /* 2670 */ 461, 461, 405, 406, 407, 408, 409, 410, 328, 412, - /* 2680 */ 461, 461, 461, 461, 398, 461, 461, 461, 402, 461, - /* 2690 */ 461, 405, 406, 407, 408, 409, 410, 328, 412, 461, - /* 2700 */ 461, 461, 461, 461, 461, 461, 461, 461, 461, 359, - /* 2710 */ 461, 461, 461, 461, 461, 461, 461, 367, 461, 461, - /* 2720 */ 461, 461, 372, 461, 374, 461, 461, 461, 359, 461, - /* 2730 */ 461, 461, 461, 461, 461, 461, 367, 461, 461, 461, - /* 2740 */ 461, 372, 461, 374, 461, 461, 461, 461, 398, 461, - /* 2750 */ 461, 461, 402, 461, 461, 405, 406, 407, 408, 409, - /* 2760 */ 410, 461, 412, 461, 461, 461, 461, 398, 461, 461, - /* 2770 */ 461, 402, 461, 461, 405, 406, 407, 408, 409, 410, - /* 2780 */ 461, 412, 461, 328, 461, 461, 461, 461, 461, 461, - /* 2790 */ 461, 461, 461, 461, 461, 461, 461, 461, 461, 328, - /* 2800 */ 461, 461, 461, 461, 461, 461, 461, 461, 461, 461, - /* 2810 */ 461, 461, 461, 461, 359, 461, 461, 461, 461, 461, - /* 2820 */ 461, 461, 367, 461, 461, 461, 461, 372, 461, 374, - /* 2830 */ 359, 461, 461, 461, 461, 461, 461, 461, 367, 461, - /* 2840 */ 461, 461, 461, 372, 461, 374, 461, 461, 461, 461, - /* 2850 */ 461, 461, 461, 398, 328, 461, 461, 402, 461, 461, - /* 2860 */ 405, 406, 407, 408, 409, 410, 461, 412, 461, 398, - /* 2870 */ 461, 461, 461, 402, 461, 461, 405, 406, 407, 408, - /* 2880 */ 409, 410, 461, 412, 461, 359, 461, 461, 461, 461, - /* 2890 */ 461, 461, 461, 367, 461, 461, 461, 461, 372, 461, - /* 2900 */ 374, 461, 461, 461, 461, 461, 328, 461, 461, 461, - /* 2910 */ 461, 461, 461, 461, 461, 461, 461, 461, 461, 461, - /* 2920 */ 461, 461, 461, 461, 398, 461, 461, 461, 402, 461, - /* 2930 */ 461, 405, 406, 407, 408, 409, 410, 359, 412, 461, - /* 2940 */ 461, 461, 461, 461, 461, 367, 461, 461, 461, 461, - /* 2950 */ 372, 461, 374, 461, 461, 461, 461, 461, 461, 461, - /* 2960 */ 461, 461, 461, 328, 461, 461, 461, 461, 461, 461, - /* 2970 */ 461, 461, 461, 461, 461, 461, 398, 461, 461, 461, - /* 2980 */ 402, 461, 328, 405, 406, 407, 408, 409, 410, 461, - /* 2990 */ 412, 461, 461, 461, 359, 461, 461, 461, 461, 461, - /* 3000 */ 461, 461, 367, 461, 461, 461, 461, 372, 461, 374, - /* 3010 */ 461, 461, 461, 359, 461, 461, 461, 461, 461, 461, - /* 3020 */ 461, 367, 461, 461, 461, 461, 372, 461, 374, 461, - /* 3030 */ 461, 461, 461, 398, 461, 461, 461, 402, 328, 461, - /* 3040 */ 405, 406, 407, 408, 409, 410, 461, 412, 461, 461, - /* 3050 */ 461, 461, 398, 461, 461, 461, 402, 328, 461, 405, - /* 3060 */ 406, 407, 408, 409, 410, 461, 412, 461, 461, 359, - /* 3070 */ 461, 461, 461, 461, 461, 461, 461, 367, 461, 461, - /* 3080 */ 461, 461, 372, 461, 374, 461, 461, 461, 359, 461, - /* 3090 */ 461, 461, 461, 461, 461, 461, 367, 461, 461, 461, - /* 3100 */ 461, 372, 461, 374, 461, 461, 461, 461, 398, 461, - /* 3110 */ 461, 461, 402, 461, 461, 405, 406, 407, 408, 409, - /* 3120 */ 410, 461, 412, 461, 461, 461, 461, 398, 461, 461, - /* 3130 */ 461, 402, 461, 461, 405, 406, 407, 408, 409, 410, - /* 3140 */ 461, 412, + /* 0 */ 375, 361, 333, 435, 335, 336, 371, 439, 362, 374, + /* 10 */ 375, 361, 12, 13, 14, 390, 391, 424, 425, 373, + /* 20 */ 20, 20, 22, 455, 375, 360, 362, 459, 460, 329, + /* 30 */ 374, 375, 367, 33, 362, 35, 387, 373, 14, 390, + /* 40 */ 391, 376, 8, 9, 20, 373, 12, 13, 14, 15, + /* 50 */ 16, 405, 406, 407, 344, 337, 337, 20, 58, 349, + /* 60 */ 360, 360, 416, 333, 64, 335, 336, 343, 368, 405, + /* 70 */ 406, 71, 337, 373, 326, 375, 20, 405, 406, 407, + /* 80 */ 416, 357, 381, 382, 12, 13, 351, 368, 416, 20, + /* 90 */ 366, 58, 20, 358, 22, 377, 96, 96, 64, 392, + /* 100 */ 435, 337, 402, 368, 439, 33, 406, 35, 0, 409, + /* 110 */ 410, 411, 412, 413, 414, 351, 416, 20, 118, 454, + /* 120 */ 455, 421, 358, 423, 459, 460, 20, 427, 428, 96, + /* 130 */ 58, 98, 368, 133, 134, 20, 64, 346, 347, 105, + /* 140 */ 392, 441, 435, 71, 0, 20, 439, 22, 337, 449, + /* 150 */ 431, 432, 433, 334, 435, 436, 337, 338, 439, 359, + /* 160 */ 35, 454, 455, 163, 164, 96, 459, 460, 96, 169, + /* 170 */ 170, 63, 372, 454, 455, 20, 51, 352, 459, 460, + /* 180 */ 66, 67, 68, 435, 184, 360, 186, 439, 74, 75, + /* 190 */ 118, 4, 48, 79, 369, 384, 162, 386, 84, 85, + /* 200 */ 163, 164, 454, 455, 90, 133, 134, 459, 460, 209, + /* 210 */ 210, 96, 212, 213, 214, 215, 216, 217, 218, 219, + /* 220 */ 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, + /* 230 */ 43, 408, 45, 46, 334, 163, 164, 337, 338, 133, + /* 240 */ 134, 169, 170, 21, 39, 3, 24, 25, 26, 27, + /* 250 */ 28, 29, 30, 31, 32, 37, 184, 434, 186, 8, + /* 260 */ 9, 360, 20, 12, 13, 14, 15, 16, 234, 235, + /* 270 */ 236, 237, 238, 239, 240, 241, 242, 243, 244, 63, + /* 280 */ 247, 209, 210, 382, 212, 213, 214, 215, 216, 217, + /* 290 */ 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, + /* 300 */ 228, 229, 96, 231, 12, 13, 392, 12, 13, 14, + /* 310 */ 15, 16, 20, 20, 22, 360, 247, 99, 163, 101, + /* 320 */ 102, 329, 104, 368, 343, 33, 108, 35, 109, 110, + /* 330 */ 111, 112, 113, 114, 115, 116, 117, 118, 119, 97, + /* 340 */ 121, 122, 123, 124, 125, 126, 0, 366, 130, 435, + /* 350 */ 58, 337, 360, 439, 360, 435, 64, 127, 22, 439, + /* 360 */ 368, 367, 247, 71, 20, 373, 411, 375, 454, 455, + /* 370 */ 376, 35, 21, 459, 460, 455, 12, 13, 14, 459, + /* 380 */ 460, 337, 368, 337, 20, 34, 22, 36, 96, 183, + /* 390 */ 329, 185, 35, 4, 402, 351, 63, 33, 406, 35, + /* 400 */ 80, 409, 410, 411, 412, 413, 414, 165, 416, 63, + /* 410 */ 118, 419, 368, 421, 422, 423, 20, 337, 33, 427, + /* 420 */ 428, 360, 58, 193, 194, 133, 134, 176, 71, 368, + /* 430 */ 384, 351, 386, 48, 373, 71, 375, 20, 337, 54, + /* 440 */ 55, 56, 57, 58, 430, 431, 432, 433, 368, 435, + /* 450 */ 436, 246, 351, 247, 168, 163, 164, 0, 138, 139, + /* 460 */ 96, 169, 170, 402, 20, 337, 22, 406, 337, 368, + /* 470 */ 409, 410, 411, 412, 413, 414, 184, 416, 186, 351, + /* 480 */ 95, 161, 118, 98, 423, 96, 8, 9, 427, 428, + /* 490 */ 12, 13, 14, 15, 16, 51, 368, 133, 134, 368, + /* 500 */ 107, 209, 210, 96, 212, 213, 214, 215, 216, 217, + /* 510 */ 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, + /* 520 */ 228, 229, 271, 66, 67, 68, 329, 163, 164, 337, + /* 530 */ 360, 74, 75, 169, 170, 71, 79, 367, 252, 253, + /* 540 */ 254, 84, 85, 351, 96, 360, 376, 90, 184, 337, + /* 550 */ 186, 166, 167, 0, 369, 20, 171, 360, 231, 174, + /* 560 */ 368, 165, 431, 432, 433, 368, 435, 436, 329, 328, + /* 570 */ 373, 330, 375, 209, 210, 190, 212, 213, 214, 215, + /* 580 */ 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, + /* 590 */ 226, 227, 228, 229, 12, 13, 384, 71, 386, 402, + /* 600 */ 127, 128, 20, 406, 22, 132, 409, 410, 411, 412, + /* 610 */ 413, 414, 373, 416, 330, 33, 4, 35, 421, 341, + /* 620 */ 423, 368, 8, 9, 427, 428, 12, 13, 14, 15, + /* 630 */ 16, 19, 379, 355, 20, 35, 247, 162, 435, 396, + /* 640 */ 58, 363, 439, 8, 9, 33, 449, 12, 13, 14, + /* 650 */ 15, 16, 361, 71, 247, 329, 352, 454, 455, 392, + /* 660 */ 48, 108, 459, 460, 360, 53, 12, 13, 133, 134, + /* 670 */ 58, 1, 2, 369, 20, 179, 22, 337, 96, 44, + /* 680 */ 127, 128, 129, 130, 131, 132, 360, 33, 420, 35, + /* 690 */ 422, 351, 14, 107, 368, 247, 200, 201, 20, 373, + /* 700 */ 118, 375, 435, 337, 169, 170, 439, 95, 368, 234, + /* 710 */ 98, 341, 58, 360, 360, 133, 134, 351, 408, 244, + /* 720 */ 367, 454, 455, 133, 134, 71, 459, 460, 402, 376, + /* 730 */ 376, 209, 406, 363, 368, 409, 410, 411, 412, 413, + /* 740 */ 414, 360, 416, 157, 434, 163, 164, 421, 367, 423, + /* 750 */ 96, 169, 170, 427, 428, 8, 9, 376, 361, 12, + /* 760 */ 13, 14, 15, 16, 438, 20, 184, 97, 186, 392, + /* 770 */ 8, 9, 118, 361, 12, 13, 14, 15, 16, 165, + /* 780 */ 258, 259, 260, 261, 262, 329, 186, 133, 134, 329, + /* 790 */ 58, 209, 210, 44, 212, 213, 214, 215, 216, 217, + /* 800 */ 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, + /* 810 */ 228, 229, 435, 18, 361, 20, 439, 163, 164, 14, + /* 820 */ 15, 16, 27, 169, 170, 30, 0, 95, 33, 373, + /* 830 */ 98, 454, 455, 373, 4, 408, 459, 460, 184, 0, + /* 840 */ 186, 163, 361, 48, 97, 50, 97, 21, 53, 329, + /* 850 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 97, + /* 860 */ 329, 434, 353, 209, 210, 356, 212, 213, 214, 215, + /* 870 */ 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, + /* 880 */ 226, 227, 228, 229, 3, 2, 352, 346, 347, 329, + /* 890 */ 95, 8, 9, 373, 360, 12, 13, 14, 15, 16, + /* 900 */ 45, 46, 107, 369, 373, 66, 67, 68, 69, 70, + /* 910 */ 165, 72, 73, 74, 75, 76, 77, 78, 79, 80, + /* 920 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, + /* 930 */ 91, 92, 137, 373, 329, 140, 141, 142, 143, 144, + /* 940 */ 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, + /* 950 */ 155, 156, 0, 158, 159, 160, 18, 0, 329, 329, + /* 960 */ 128, 23, 349, 8, 9, 360, 362, 12, 13, 14, + /* 970 */ 15, 16, 108, 368, 383, 37, 38, 373, 373, 41, + /* 980 */ 375, 24, 25, 26, 27, 28, 29, 30, 31, 32, + /* 990 */ 368, 127, 128, 129, 130, 131, 132, 59, 60, 61, + /* 1000 */ 62, 379, 373, 373, 231, 329, 233, 402, 329, 405, + /* 1010 */ 406, 406, 245, 246, 409, 410, 411, 412, 413, 414, + /* 1020 */ 416, 416, 337, 191, 192, 329, 421, 195, 423, 197, + /* 1030 */ 329, 463, 427, 428, 96, 368, 351, 337, 420, 360, + /* 1040 */ 422, 337, 14, 438, 337, 337, 379, 368, 20, 373, + /* 1050 */ 2, 337, 373, 368, 375, 351, 8, 9, 351, 351, + /* 1060 */ 12, 13, 14, 15, 16, 351, 337, 329, 368, 373, + /* 1070 */ 337, 20, 368, 135, 373, 368, 368, 329, 248, 329, + /* 1080 */ 351, 402, 368, 329, 351, 406, 329, 44, 409, 410, + /* 1090 */ 411, 412, 413, 414, 58, 416, 419, 368, 44, 422, + /* 1100 */ 421, 368, 423, 348, 152, 350, 427, 428, 337, 370, + /* 1110 */ 360, 373, 373, 161, 176, 177, 178, 438, 368, 181, + /* 1120 */ 165, 373, 351, 373, 0, 375, 329, 373, 12, 13, + /* 1130 */ 373, 431, 432, 433, 98, 435, 436, 199, 22, 368, + /* 1140 */ 202, 35, 204, 205, 206, 207, 208, 266, 329, 33, + /* 1150 */ 329, 35, 402, 337, 329, 337, 406, 360, 329, 409, + /* 1160 */ 410, 411, 412, 413, 414, 368, 416, 351, 165, 351, + /* 1170 */ 373, 421, 375, 423, 58, 172, 370, 427, 428, 373, + /* 1180 */ 370, 1, 2, 373, 368, 247, 368, 71, 438, 64, + /* 1190 */ 337, 163, 373, 353, 373, 392, 356, 329, 373, 402, + /* 1200 */ 108, 22, 373, 406, 351, 452, 409, 410, 411, 412, + /* 1210 */ 413, 414, 44, 416, 35, 42, 165, 44, 421, 339, + /* 1220 */ 423, 368, 130, 100, 427, 428, 103, 42, 360, 44, + /* 1230 */ 100, 446, 108, 103, 118, 438, 368, 100, 435, 0, + /* 1240 */ 103, 373, 439, 375, 100, 0, 0, 103, 44, 360, + /* 1250 */ 71, 127, 128, 129, 130, 131, 132, 454, 455, 44, + /* 1260 */ 47, 22, 459, 460, 13, 97, 44, 22, 22, 339, + /* 1270 */ 402, 44, 329, 96, 406, 44, 383, 409, 410, 411, + /* 1280 */ 412, 413, 414, 106, 416, 13, 35, 35, 372, 421, + /* 1290 */ 336, 423, 186, 44, 383, 427, 428, 118, 44, 0, + /* 1300 */ 184, 97, 186, 360, 437, 44, 456, 35, 44, 96, + /* 1310 */ 440, 368, 97, 270, 429, 249, 373, 404, 375, 97, + /* 1320 */ 403, 182, 268, 71, 97, 209, 210, 44, 97, 329, + /* 1330 */ 48, 394, 20, 42, 209, 20, 380, 44, 222, 223, + /* 1340 */ 224, 225, 226, 227, 228, 402, 97, 383, 49, 406, + /* 1350 */ 380, 97, 409, 410, 411, 412, 413, 414, 97, 416, + /* 1360 */ 360, 97, 19, 184, 421, 186, 423, 44, 368, 44, + /* 1370 */ 427, 428, 44, 373, 162, 375, 33, 378, 337, 44, + /* 1380 */ 97, 337, 44, 378, 380, 378, 337, 345, 209, 210, + /* 1390 */ 97, 48, 94, 337, 337, 337, 20, 54, 55, 56, + /* 1400 */ 57, 58, 402, 329, 331, 20, 406, 331, 398, 409, + /* 1410 */ 410, 411, 412, 413, 414, 343, 416, 20, 343, 20, + /* 1420 */ 97, 421, 97, 423, 338, 97, 20, 427, 428, 338, + /* 1430 */ 375, 393, 97, 343, 360, 97, 343, 343, 95, 343, + /* 1440 */ 337, 98, 368, 343, 52, 340, 331, 373, 340, 375, + /* 1450 */ 337, 331, 373, 373, 198, 360, 96, 360, 360, 360, + /* 1460 */ 401, 360, 360, 400, 360, 398, 189, 329, 341, 360, + /* 1470 */ 360, 360, 360, 341, 131, 397, 402, 337, 257, 445, + /* 1480 */ 406, 256, 375, 409, 410, 411, 412, 413, 414, 175, + /* 1490 */ 416, 329, 373, 263, 448, 445, 444, 423, 360, 373, + /* 1500 */ 383, 427, 428, 265, 383, 445, 368, 373, 373, 166, + /* 1510 */ 388, 373, 447, 375, 171, 250, 388, 264, 404, 272, + /* 1520 */ 443, 457, 360, 442, 269, 464, 458, 267, 368, 20, + /* 1530 */ 368, 188, 246, 190, 337, 373, 338, 375, 20, 408, + /* 1540 */ 402, 341, 341, 386, 406, 373, 388, 409, 410, 411, + /* 1550 */ 412, 413, 414, 388, 416, 329, 373, 373, 167, 373, + /* 1560 */ 373, 423, 373, 385, 402, 427, 428, 356, 406, 341, + /* 1570 */ 341, 409, 410, 411, 412, 413, 414, 415, 416, 417, + /* 1580 */ 418, 96, 368, 96, 364, 426, 360, 350, 36, 373, + /* 1590 */ 331, 341, 399, 0, 368, 337, 389, 395, 332, 373, + /* 1600 */ 0, 375, 329, 327, 191, 0, 389, 0, 42, 342, + /* 1610 */ 0, 354, 35, 203, 35, 35, 354, 354, 35, 329, + /* 1620 */ 203, 0, 35, 35, 203, 0, 203, 0, 402, 35, + /* 1630 */ 0, 22, 406, 360, 0, 409, 410, 411, 412, 413, + /* 1640 */ 414, 368, 416, 35, 186, 184, 373, 0, 375, 0, + /* 1650 */ 360, 180, 179, 0, 0, 0, 0, 0, 368, 47, + /* 1660 */ 42, 0, 0, 373, 0, 375, 0, 0, 0, 0, + /* 1670 */ 0, 152, 35, 0, 152, 402, 450, 451, 0, 406, + /* 1680 */ 42, 0, 409, 410, 411, 412, 413, 414, 0, 416, + /* 1690 */ 0, 0, 402, 0, 329, 0, 406, 22, 0, 409, + /* 1700 */ 410, 411, 412, 413, 414, 0, 416, 0, 0, 0, + /* 1710 */ 0, 0, 0, 423, 0, 0, 0, 0, 428, 0, + /* 1720 */ 0, 0, 0, 0, 0, 360, 136, 0, 0, 0, + /* 1730 */ 58, 35, 0, 368, 461, 462, 0, 58, 373, 0, + /* 1740 */ 375, 329, 58, 0, 42, 39, 47, 44, 14, 14, + /* 1750 */ 0, 47, 0, 0, 0, 0, 175, 329, 40, 0, + /* 1760 */ 47, 0, 0, 0, 39, 39, 65, 402, 35, 39, + /* 1770 */ 0, 406, 360, 0, 409, 410, 411, 412, 413, 414, + /* 1780 */ 368, 416, 35, 39, 35, 373, 48, 375, 360, 48, + /* 1790 */ 48, 0, 35, 48, 0, 39, 368, 0, 0, 39, + /* 1800 */ 0, 373, 35, 375, 22, 105, 0, 35, 44, 35, + /* 1810 */ 44, 35, 35, 35, 402, 329, 451, 22, 406, 35, + /* 1820 */ 35, 409, 410, 411, 412, 413, 414, 0, 416, 22, + /* 1830 */ 402, 329, 0, 22, 406, 0, 50, 409, 410, 411, + /* 1840 */ 412, 413, 414, 103, 416, 22, 360, 35, 0, 35, + /* 1850 */ 0, 365, 35, 0, 368, 22, 20, 0, 0, 373, + /* 1860 */ 35, 375, 360, 35, 96, 453, 97, 196, 22, 35, + /* 1870 */ 368, 0, 187, 0, 44, 373, 230, 375, 97, 3, + /* 1880 */ 251, 255, 44, 96, 96, 44, 97, 97, 402, 96, + /* 1890 */ 462, 329, 406, 97, 251, 409, 410, 411, 412, 413, + /* 1900 */ 414, 96, 416, 172, 402, 96, 47, 329, 406, 47, + /* 1910 */ 173, 409, 410, 411, 412, 413, 414, 96, 416, 44, + /* 1920 */ 418, 97, 360, 172, 3, 44, 97, 365, 251, 35, + /* 1930 */ 368, 35, 167, 35, 35, 373, 165, 375, 360, 35, + /* 1940 */ 35, 97, 97, 365, 165, 165, 368, 47, 47, 0, + /* 1950 */ 44, 373, 0, 375, 0, 0, 96, 39, 47, 96, + /* 1960 */ 168, 97, 329, 97, 402, 96, 96, 0, 406, 39, + /* 1970 */ 96, 409, 410, 411, 412, 413, 414, 44, 416, 166, + /* 1980 */ 402, 96, 47, 106, 406, 2, 22, 409, 410, 411, + /* 1990 */ 412, 413, 414, 360, 416, 47, 22, 47, 96, 107, + /* 2000 */ 97, 368, 120, 96, 35, 96, 373, 97, 375, 329, + /* 2010 */ 97, 96, 209, 96, 35, 211, 97, 97, 96, 96, + /* 2020 */ 35, 97, 96, 35, 97, 96, 329, 35, 245, 230, + /* 2030 */ 35, 97, 230, 232, 96, 402, 97, 96, 22, 406, + /* 2040 */ 360, 96, 409, 410, 411, 412, 413, 414, 368, 416, + /* 2050 */ 108, 120, 120, 373, 96, 375, 44, 360, 35, 96, + /* 2060 */ 120, 22, 65, 64, 35, 368, 35, 35, 35, 35, + /* 2070 */ 373, 35, 375, 35, 71, 35, 35, 35, 35, 93, + /* 2080 */ 35, 44, 402, 35, 22, 35, 406, 329, 35, 409, + /* 2090 */ 410, 411, 412, 413, 414, 35, 416, 71, 35, 402, + /* 2100 */ 35, 35, 35, 406, 329, 35, 409, 410, 411, 412, + /* 2110 */ 413, 414, 22, 416, 35, 0, 35, 48, 360, 39, + /* 2120 */ 0, 35, 48, 39, 0, 48, 368, 35, 39, 0, + /* 2130 */ 35, 373, 39, 375, 0, 360, 48, 35, 35, 0, + /* 2140 */ 22, 22, 21, 368, 22, 465, 21, 20, 373, 465, + /* 2150 */ 375, 329, 465, 465, 465, 465, 465, 465, 465, 465, + /* 2160 */ 402, 465, 465, 465, 406, 465, 465, 409, 410, 411, + /* 2170 */ 412, 413, 414, 465, 416, 465, 329, 402, 465, 465, + /* 2180 */ 465, 406, 360, 465, 409, 410, 411, 412, 413, 414, + /* 2190 */ 368, 416, 465, 465, 465, 373, 465, 375, 465, 465, + /* 2200 */ 465, 465, 465, 465, 465, 465, 465, 360, 465, 465, + /* 2210 */ 465, 465, 465, 465, 465, 368, 465, 465, 465, 465, + /* 2220 */ 373, 465, 375, 465, 402, 465, 465, 465, 406, 465, + /* 2230 */ 465, 409, 410, 411, 412, 413, 414, 329, 416, 465, + /* 2240 */ 465, 465, 465, 465, 465, 465, 465, 465, 465, 402, + /* 2250 */ 465, 465, 465, 406, 465, 465, 409, 410, 411, 412, + /* 2260 */ 413, 414, 465, 416, 465, 329, 465, 465, 360, 465, + /* 2270 */ 465, 465, 465, 465, 465, 465, 368, 465, 465, 465, + /* 2280 */ 465, 373, 465, 375, 465, 465, 465, 465, 465, 465, + /* 2290 */ 465, 465, 465, 465, 465, 465, 360, 465, 465, 465, + /* 2300 */ 465, 465, 465, 465, 368, 465, 465, 465, 465, 373, + /* 2310 */ 402, 375, 465, 465, 406, 465, 465, 409, 410, 411, + /* 2320 */ 412, 413, 414, 329, 416, 465, 465, 465, 465, 465, + /* 2330 */ 465, 465, 465, 465, 465, 465, 465, 465, 402, 329, + /* 2340 */ 465, 465, 406, 465, 465, 409, 410, 411, 412, 413, + /* 2350 */ 414, 465, 416, 465, 360, 465, 465, 465, 465, 465, + /* 2360 */ 465, 465, 368, 465, 465, 465, 465, 373, 465, 375, + /* 2370 */ 360, 465, 465, 465, 465, 465, 465, 465, 368, 465, + /* 2380 */ 465, 465, 465, 373, 465, 375, 465, 465, 465, 465, + /* 2390 */ 465, 465, 465, 465, 465, 465, 402, 465, 465, 465, + /* 2400 */ 406, 465, 329, 409, 410, 411, 412, 413, 414, 465, + /* 2410 */ 416, 465, 402, 465, 465, 465, 406, 465, 465, 409, + /* 2420 */ 410, 411, 412, 413, 414, 465, 416, 465, 465, 465, + /* 2430 */ 465, 465, 465, 360, 329, 465, 465, 465, 465, 465, + /* 2440 */ 465, 368, 465, 465, 465, 465, 373, 465, 375, 465, + /* 2450 */ 465, 465, 465, 465, 465, 465, 465, 465, 465, 465, + /* 2460 */ 465, 465, 465, 465, 465, 360, 465, 465, 465, 465, + /* 2470 */ 465, 465, 465, 368, 465, 402, 465, 465, 373, 406, + /* 2480 */ 375, 329, 409, 410, 411, 412, 413, 414, 465, 416, + /* 2490 */ 465, 465, 465, 465, 465, 465, 465, 329, 465, 465, + /* 2500 */ 465, 465, 465, 465, 465, 465, 465, 402, 465, 465, + /* 2510 */ 465, 406, 360, 465, 409, 410, 411, 412, 413, 414, + /* 2520 */ 368, 416, 465, 465, 465, 373, 465, 375, 360, 465, + /* 2530 */ 465, 465, 465, 465, 465, 465, 368, 465, 465, 465, + /* 2540 */ 465, 373, 465, 375, 465, 465, 465, 465, 465, 465, + /* 2550 */ 465, 465, 329, 465, 402, 465, 465, 465, 406, 465, + /* 2560 */ 465, 409, 410, 411, 412, 413, 414, 465, 416, 465, + /* 2570 */ 402, 465, 465, 465, 406, 465, 465, 409, 410, 411, + /* 2580 */ 412, 413, 414, 360, 416, 465, 465, 465, 465, 465, + /* 2590 */ 465, 368, 465, 465, 465, 465, 373, 465, 375, 465, + /* 2600 */ 465, 465, 465, 465, 465, 465, 465, 465, 465, 465, + /* 2610 */ 465, 329, 465, 465, 465, 465, 465, 465, 465, 465, + /* 2620 */ 465, 465, 465, 465, 465, 402, 465, 465, 465, 406, + /* 2630 */ 465, 465, 409, 410, 411, 412, 413, 414, 465, 416, + /* 2640 */ 465, 329, 360, 465, 465, 465, 465, 465, 465, 465, + /* 2650 */ 368, 465, 465, 465, 465, 373, 465, 375, 465, 465, + /* 2660 */ 465, 465, 465, 465, 465, 465, 465, 465, 465, 329, + /* 2670 */ 465, 465, 360, 465, 465, 465, 465, 465, 465, 465, + /* 2680 */ 368, 465, 465, 465, 402, 373, 465, 375, 406, 465, + /* 2690 */ 465, 409, 410, 411, 412, 413, 414, 465, 416, 329, + /* 2700 */ 360, 465, 465, 465, 465, 465, 465, 465, 368, 465, + /* 2710 */ 465, 465, 465, 373, 402, 375, 465, 465, 406, 465, + /* 2720 */ 465, 409, 410, 411, 412, 413, 414, 465, 416, 465, + /* 2730 */ 360, 465, 465, 465, 465, 465, 465, 465, 368, 465, + /* 2740 */ 465, 465, 402, 373, 465, 375, 406, 465, 465, 409, + /* 2750 */ 410, 411, 412, 413, 414, 465, 416, 465, 465, 465, + /* 2760 */ 465, 465, 465, 329, 465, 465, 465, 465, 465, 465, + /* 2770 */ 465, 465, 402, 465, 465, 465, 406, 465, 465, 409, + /* 2780 */ 410, 411, 412, 413, 414, 465, 416, 465, 465, 465, + /* 2790 */ 465, 465, 465, 465, 360, 329, 465, 465, 465, 465, + /* 2800 */ 465, 465, 368, 465, 465, 465, 465, 373, 465, 375, + /* 2810 */ 465, 465, 465, 465, 465, 465, 465, 465, 465, 465, + /* 2820 */ 465, 465, 465, 465, 465, 465, 360, 465, 465, 465, + /* 2830 */ 465, 465, 465, 465, 368, 465, 402, 465, 465, 373, + /* 2840 */ 406, 375, 465, 409, 410, 411, 412, 413, 414, 465, + /* 2850 */ 416, 465, 465, 465, 465, 465, 465, 465, 465, 465, + /* 2860 */ 465, 465, 465, 465, 465, 465, 465, 465, 402, 465, + /* 2870 */ 465, 465, 406, 465, 465, 409, 410, 411, 412, 413, + /* 2880 */ 414, 465, 416, }; -#define YY_SHIFT_COUNT (724) +#define YY_SHIFT_COUNT (732) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2103) +#define YY_SHIFT_MAX (2139) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 501, 0, 217, 0, 436, 436, 436, 436, 436, 436, - /* 10 */ 436, 436, 436, 436, 436, 653, 870, 870, 1087, 870, - /* 20 */ 870, 870, 870, 870, 870, 870, 870, 870, 870, 870, - /* 30 */ 870, 870, 870, 870, 870, 870, 870, 870, 870, 870, - /* 40 */ 870, 870, 870, 870, 870, 870, 870, 870, 69, 135, - /* 50 */ 17, 311, 178, 170, 200, 170, 17, 17, 513, 513, - /* 60 */ 170, 513, 513, 303, 170, 623, 28, 28, 623, 22, - /* 70 */ 22, 229, 110, 153, 153, 28, 28, 28, 28, 28, - /* 80 */ 28, 28, 28, 28, 28, 42, 28, 28, 58, 28, - /* 90 */ 115, 28, 28, 28, 28, 115, 28, 28, 115, 28, - /* 100 */ 115, 115, 115, 28, 93, 215, 564, 564, 230, 443, - /* 110 */ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, - /* 120 */ 600, 600, 600, 600, 600, 600, 600, 600, 600, 510, - /* 130 */ 144, 229, 110, 32, 175, 452, 452, 452, 341, 484, - /* 140 */ 484, 175, 250, 250, 250, 180, 52, 115, 223, 115, - /* 150 */ 223, 223, 180, 278, 78, 78, 78, 78, 78, 78, - /* 160 */ 78, 2103, 150, 205, 289, 936, 366, 218, 67, 152, - /* 170 */ 403, 376, 567, 842, 538, 580, 654, 750, 698, 654, - /* 180 */ 868, 616, 555, 968, 1188, 1057, 1197, 1223, 1197, 1093, - /* 190 */ 1243, 1243, 1197, 1093, 1093, 1243, 1192, 1243, 1243, 1243, - /* 200 */ 1270, 1270, 1324, 42, 1329, 42, 1331, 1334, 42, 1331, - /* 210 */ 42, 42, 42, 1243, 42, 1315, 1315, 1270, 115, 115, - /* 220 */ 115, 115, 115, 115, 115, 115, 115, 115, 115, 1243, - /* 230 */ 1270, 223, 223, 1184, 1324, 93, 1216, 1329, 93, 1243, - /* 240 */ 1223, 1223, 223, 1154, 1161, 223, 1154, 1161, 223, 223, - /* 250 */ 115, 1170, 1255, 1154, 1171, 1174, 1189, 968, 1172, 1177, - /* 260 */ 1176, 1201, 250, 1431, 1243, 1331, 93, 93, 1161, 223, - /* 270 */ 223, 223, 223, 223, 1161, 223, 1317, 93, 180, 93, - /* 280 */ 250, 1391, 1394, 223, 278, 1243, 93, 1460, 1270, 3142, - /* 290 */ 3142, 3142, 3142, 3142, 3142, 3142, 3142, 3142, 1251, 364, - /* 300 */ 97, 21, 816, 15, 839, 788, 998, 1033, 1215, 826, - /* 310 */ 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 562, - /* 320 */ 552, 798, 798, 134, 544, 594, 651, 375, 255, 255, - /* 330 */ 145, 404, 539, 145, 145, 145, 841, 849, 892, 898, - /* 340 */ 677, 827, 916, 934, 956, 973, 817, 889, 1002, 1044, - /* 350 */ 1007, 1062, 884, 877, 590, 954, 1072, 1077, 1096, 1113, - /* 360 */ 1129, 1163, 1149, 1151, 360, 1009, 945, 1164, 1123, 1165, - /* 370 */ 1167, 1168, 1169, 1190, 1191, 1065, 1039, 1183, 1075, 1225, - /* 380 */ 1504, 1511, 1322, 1521, 1522, 1481, 1524, 1491, 1326, 1494, - /* 390 */ 1495, 1498, 1333, 1536, 1502, 1505, 1337, 1541, 1340, 1543, - /* 400 */ 1509, 1545, 1525, 1548, 1514, 1365, 1369, 1554, 1555, 1377, - /* 410 */ 1379, 1558, 1559, 1513, 1561, 1562, 1563, 1527, 1564, 1566, - /* 420 */ 1567, 1568, 1570, 1571, 1572, 1574, 1423, 1544, 1576, 1430, - /* 430 */ 1583, 1590, 1592, 1593, 1594, 1595, 1599, 1600, 1605, 1606, - /* 440 */ 1607, 1609, 1610, 1617, 1619, 1579, 1620, 1622, 1623, 1626, - /* 450 */ 1627, 1575, 1628, 1631, 1633, 1499, 1634, 1636, 1637, 1580, - /* 460 */ 1604, 1641, 1584, 1643, 1586, 1646, 1648, 1608, 1612, 1613, - /* 470 */ 1602, 1638, 1611, 1639, 1614, 1654, 1616, 1621, 1659, 1662, - /* 480 */ 1664, 1630, 1492, 1665, 1667, 1676, 1624, 1677, 1684, 1651, - /* 490 */ 1625, 1635, 1687, 1653, 1642, 1656, 1693, 1674, 1652, 1660, - /* 500 */ 1707, 1675, 1666, 1678, 1712, 1713, 1716, 1718, 1618, 1569, - /* 510 */ 1686, 1702, 1725, 1691, 1694, 1696, 1697, 1683, 1689, 1699, - /* 520 */ 1701, 1706, 1703, 1739, 1719, 1740, 1721, 1695, 1744, 1724, - /* 530 */ 1714, 1747, 1717, 1748, 1723, 1751, 1731, 1734, 1727, 1728, - /* 540 */ 1565, 1669, 1663, 1756, 1603, 1729, 1774, 1591, 1754, 1615, - /* 550 */ 1632, 1778, 1780, 1640, 1629, 1779, 1742, 1533, 1688, 1690, - /* 560 */ 1698, 1644, 1573, 1645, 1542, 1700, 1755, 1708, 1710, 1711, - /* 570 */ 1715, 1720, 1759, 1761, 1765, 1722, 1769, 1577, 1726, 1732, - /* 580 */ 1816, 1770, 1582, 1785, 1786, 1787, 1789, 1790, 1791, 1733, - /* 590 */ 1736, 1781, 1598, 1792, 1788, 1834, 1837, 1838, 1843, 1749, - /* 600 */ 1808, 1752, 1753, 1758, 1757, 1760, 1682, 1762, 1851, 1813, - /* 610 */ 1704, 1763, 1766, 1602, 1810, 1817, 1647, 1655, 1658, 1858, - /* 620 */ 1841, 1657, 1768, 1771, 1775, 1776, 1793, 1794, 1815, 1796, - /* 630 */ 1798, 1819, 1799, 1845, 1673, 1801, 1783, 1802, 1853, 1860, - /* 640 */ 1805, 1806, 1867, 1809, 1807, 1872, 1812, 1814, 1874, 1818, - /* 650 */ 1820, 1875, 1822, 1795, 1800, 1803, 1821, 1890, 1767, 1825, - /* 660 */ 1869, 1826, 1881, 1830, 1869, 1869, 1905, 1864, 1866, 1904, - /* 670 */ 1908, 1909, 1911, 1912, 1913, 1914, 1916, 1918, 1919, 1871, - /* 680 */ 1847, 1915, 1920, 1922, 1923, 1938, 1927, 1928, 1930, 1895, - /* 690 */ 1683, 1932, 1689, 1933, 1935, 1937, 1939, 1951, 1942, 1978, - /* 700 */ 1944, 1934, 1950, 1981, 1956, 1945, 1953, 1994, 1961, 1949, - /* 710 */ 1959, 2008, 1966, 1962, 1972, 2012, 1979, 1980, 2013, 1995, - /* 720 */ 1997, 1999, 2000, 1998, 1996, + /* 0 */ 938, 0, 72, 0, 292, 292, 292, 292, 292, 292, + /* 10 */ 292, 292, 292, 292, 292, 364, 582, 582, 654, 582, + /* 20 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 582, + /* 30 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 582, + /* 40 */ 582, 582, 582, 582, 582, 582, 582, 582, 69, 115, + /* 50 */ 1, 206, 33, 407, 448, 407, 1, 1, 1116, 1116, + /* 60 */ 407, 1116, 1116, 389, 407, 535, 56, 56, 535, 187, + /* 70 */ 187, 37, 106, 24, 24, 56, 56, 56, 56, 56, + /* 80 */ 56, 56, 97, 56, 56, 216, 293, 56, 56, 344, + /* 90 */ 56, 293, 56, 97, 56, 97, 293, 56, 56, 293, + /* 100 */ 56, 293, 293, 293, 56, 333, 795, 34, 34, 222, + /* 110 */ 114, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, + /* 120 */ 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, + /* 130 */ 218, 242, 37, 106, 108, 357, 396, 396, 396, 346, + /* 140 */ 773, 773, 357, 417, 417, 417, 393, 327, 293, 464, + /* 150 */ 293, 464, 464, 393, 526, 219, 219, 219, 219, 219, + /* 160 */ 219, 219, 1343, 826, 457, 614, 251, 522, 125, 286, + /* 170 */ 678, 1028, 444, 745, 855, 1092, 1051, 767, 205, 881, + /* 180 */ 767, 1173, 830, 155, 1066, 1282, 1139, 1291, 1312, 1291, + /* 190 */ 1212, 1315, 1315, 1291, 1212, 1212, 1315, 1298, 1315, 1315, + /* 200 */ 1315, 1376, 1376, 1385, 216, 1397, 216, 1399, 1406, 216, + /* 210 */ 1399, 216, 216, 216, 1315, 216, 1392, 1392, 1376, 293, + /* 220 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, + /* 230 */ 1315, 1376, 464, 464, 1256, 1360, 1385, 333, 1277, 1397, + /* 240 */ 333, 1315, 1312, 1312, 464, 1221, 1225, 464, 1221, 1225, + /* 250 */ 464, 464, 293, 1230, 1314, 1221, 1238, 1253, 1265, 1066, + /* 260 */ 1247, 1255, 1260, 1286, 417, 1509, 1315, 1399, 333, 333, + /* 270 */ 1518, 1225, 464, 464, 464, 464, 464, 1225, 464, 1391, + /* 280 */ 333, 393, 333, 417, 1485, 1487, 464, 526, 1315, 333, + /* 290 */ 1552, 1376, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, + /* 300 */ 2883, 839, 385, 957, 612, 747, 635, 762, 553, 883, + /* 310 */ 1048, 955, 1124, 478, 478, 478, 478, 478, 478, 478, + /* 320 */ 478, 478, 864, 832, 295, 295, 320, 496, 952, 732, + /* 330 */ 351, 230, 473, 473, 805, 670, 475, 805, 805, 805, + /* 340 */ 749, 144, 336, 1185, 586, 1123, 1130, 1137, 1144, 1239, + /* 350 */ 1245, 1246, 1168, 1036, 1204, 1215, 590, 1054, 1043, 1003, + /* 360 */ 1222, 1227, 1231, 1249, 1254, 1264, 1180, 1283, 600, 1106, + /* 370 */ 1125, 1293, 1213, 1261, 1323, 1325, 1328, 1335, 1338, 1177, + /* 380 */ 1251, 1272, 1252, 1299, 1593, 1600, 1413, 1605, 1607, 1566, + /* 390 */ 1610, 1577, 1410, 1579, 1580, 1583, 1417, 1621, 1587, 1588, + /* 400 */ 1421, 1625, 1423, 1627, 1594, 1630, 1609, 1634, 1608, 1458, + /* 410 */ 1461, 1647, 1649, 1471, 1473, 1653, 1654, 1612, 1655, 1656, + /* 420 */ 1657, 1618, 1661, 1662, 1664, 1666, 1667, 1668, 1669, 1670, + /* 430 */ 1519, 1637, 1673, 1522, 1678, 1688, 1690, 1691, 1693, 1695, + /* 440 */ 1705, 1707, 1708, 1709, 1710, 1711, 1712, 1714, 1715, 1716, + /* 450 */ 1638, 1681, 1717, 1719, 1720, 1721, 1722, 1675, 1698, 1723, + /* 460 */ 1724, 1590, 1727, 1728, 1729, 1672, 1696, 1732, 1679, 1736, + /* 470 */ 1684, 1739, 1743, 1702, 1706, 1703, 1699, 1734, 1704, 1735, + /* 480 */ 1713, 1750, 1718, 1725, 1752, 1753, 1754, 1726, 1581, 1755, + /* 490 */ 1759, 1761, 1701, 1762, 1763, 1733, 1738, 1730, 1770, 1747, + /* 500 */ 1741, 1744, 1773, 1749, 1742, 1756, 1791, 1757, 1745, 1760, + /* 510 */ 1794, 1797, 1798, 1800, 1700, 1740, 1767, 1782, 1806, 1772, + /* 520 */ 1774, 1776, 1777, 1764, 1766, 1778, 1784, 1795, 1785, 1827, + /* 530 */ 1807, 1832, 1811, 1786, 1835, 1823, 1812, 1848, 1814, 1850, + /* 540 */ 1817, 1853, 1833, 1836, 1825, 1828, 1671, 1769, 1768, 1857, + /* 550 */ 1771, 1834, 1858, 1685, 1846, 1779, 1765, 1871, 1873, 1780, + /* 560 */ 1737, 1876, 1830, 1629, 1787, 1781, 1788, 1731, 1646, 1751, + /* 570 */ 1626, 1789, 1838, 1790, 1793, 1805, 1809, 1796, 1841, 1859, + /* 580 */ 1862, 1821, 1875, 1643, 1824, 1829, 1921, 1881, 1677, 1894, + /* 590 */ 1896, 1898, 1899, 1904, 1905, 1844, 1845, 1900, 1783, 1906, + /* 600 */ 1901, 1949, 1952, 1954, 1955, 1860, 1918, 1699, 1911, 1863, + /* 610 */ 1864, 1866, 1869, 1870, 1792, 1874, 1967, 1930, 1813, 1885, + /* 620 */ 1877, 1699, 1935, 1933, 1799, 1801, 1802, 1983, 1964, 1803, + /* 630 */ 1902, 1903, 1907, 1910, 1909, 1913, 1948, 1915, 1917, 1950, + /* 640 */ 1919, 1974, 1804, 1922, 1892, 1920, 1969, 1979, 1923, 1924, + /* 650 */ 1985, 1926, 1927, 1988, 1929, 1934, 1992, 1938, 1939, 1995, + /* 660 */ 1941, 1882, 1931, 1932, 1940, 2016, 1942, 1945, 2012, 1958, + /* 670 */ 2023, 1963, 2012, 2012, 2039, 1997, 1999, 2029, 2031, 2032, + /* 680 */ 2033, 2034, 2036, 2038, 2040, 2041, 2042, 2003, 1986, 2037, + /* 690 */ 2043, 2045, 2048, 2062, 2050, 2053, 2060, 2026, 1764, 2063, + /* 700 */ 1766, 2065, 2066, 2067, 2070, 2090, 2079, 2115, 2081, 2069, + /* 710 */ 2080, 2120, 2086, 2074, 2084, 2124, 2092, 2077, 2089, 2129, + /* 720 */ 2095, 2088, 2093, 2134, 2102, 2103, 2139, 2118, 2121, 2119, + /* 730 */ 2122, 2125, 2127, }; -#define YY_REDUCE_COUNT (297) -#define YY_REDUCE_MIN (-369) -#define YY_REDUCE_MAX (2729) +#define YY_REDUCE_COUNT (300) +#define YY_REDUCE_MIN (-432) +#define YY_REDUCE_MAX (2466) static const short yy_reduce_ofst[] = { - /* 0 */ -42, -325, -266, 184, -81, 356, 563, 780, 988, 1054, - /* 10 */ 1108, 1179, 1206, 1273, 1296, 656, 1363, 1383, 873, 1472, - /* 20 */ 1526, 1578, 1597, 1672, 1692, 1782, 1811, 1840, 1907, 1926, - /* 30 */ 2001, 2021, 2087, 2142, 2158, 2210, 2267, 2286, 2350, 2369, - /* 40 */ 2455, 2471, 2526, 2578, 2635, 2654, 2710, 2729, 48, 35, - /* 50 */ 414, 543, 570, 682, 725, 802, 36, 736, -357, -351, - /* 60 */ 182, -24, 987, -365, 85, -331, -219, -51, -369, -326, - /* 70 */ -296, -271, -298, -233, -222, 156, 214, 216, 359, 409, - /* 80 */ 557, 558, 559, 593, 597, -158, 641, 693, -67, 769, - /* 90 */ -359, 776, 799, 805, 812, -214, 138, 146, -36, 483, - /* 100 */ 361, 344, 401, 848, -8, -335, -76, -76, 123, -241, - /* 110 */ -61, 83, 159, 355, 369, 423, 446, 465, 528, 529, - /* 120 */ 530, 532, 595, 618, 655, 664, 668, 703, 729, -94, - /* 130 */ -198, 92, 87, 179, 169, -198, 155, 211, 248, 337, - /* 140 */ 378, 432, 111, 130, 228, -292, 39, 476, 112, -189, - /* 150 */ 310, 398, 468, 537, -358, -349, -343, 16, 30, 195, - /* 160 */ 270, 320, 577, 583, 599, 480, 514, 638, 547, 626, - /* 170 */ 626, 684, 695, 715, 709, 733, 701, 701, 748, 701, - /* 180 */ 752, 766, 626, 822, 818, 850, 863, 862, 867, 882, - /* 190 */ 931, 932, 890, 896, 899, 941, 940, 953, 955, 957, - /* 200 */ 964, 992, 950, 1004, 976, 1010, 1016, 966, 1015, 1021, - /* 210 */ 1019, 1022, 1023, 1027, 1024, 1029, 1030, 1040, 1012, 1013, - /* 220 */ 1014, 1017, 1018, 1025, 1026, 1028, 1032, 1042, 1043, 1038, - /* 230 */ 1045, 1006, 1008, 986, 997, 1063, 1020, 1034, 1066, 1073, - /* 240 */ 1035, 1036, 1047, 974, 1046, 1048, 982, 1049, 1052, 1053, - /* 250 */ 626, 983, 990, 989, 999, 1001, 1003, 1050, 984, 993, - /* 260 */ 995, 701, 1082, 1051, 1117, 1120, 1114, 1118, 1080, 1097, - /* 270 */ 1098, 1100, 1102, 1104, 1083, 1107, 1101, 1141, 1130, 1146, - /* 280 */ 1121, 1067, 1128, 1122, 1143, 1157, 1155, 1166, 1173, 1106, - /* 290 */ 1103, 1116, 1119, 1147, 1148, 1156, 1178, 1182, + /* 0 */ -252, -300, -8, 197, 326, 605, 679, 750, 797, 868, + /* 10 */ 943, 1000, 61, 1074, 1138, 1162, 1226, 1273, 1290, 1365, + /* 20 */ 1412, 1428, 1486, 1502, 1562, 1578, 1633, 1680, 1697, 1758, + /* 30 */ 1775, 1822, 1847, 1908, 1936, 1994, 2010, 2073, 2105, 2152, + /* 40 */ 2168, 2223, 2282, 2312, 2340, 2370, 2434, 2466, -281, -335, + /* 50 */ 14, -293, -86, 267, 377, 803, 131, 700, -354, -328, + /* 60 */ 203, -336, 604, -432, -80, -351, -265, -236, -375, -331, + /* 70 */ -270, -299, -365, -181, -100, 44, 80, 101, 128, 192, + /* 80 */ 340, 366, -189, 685, 704, -276, -6, 707, 708, -45, + /* 90 */ 729, 170, 733, 46, 771, 212, -175, 816, 818, 353, + /* 100 */ 714, 304, 381, 534, 853, 278, -282, -407, -407, 241, + /* 110 */ -290, 239, 456, 460, 520, 531, 560, 629, 630, 676, + /* 120 */ 696, 701, 738, 748, 754, 757, 819, 821, 825, 829, + /* 130 */ -200, -177, -99, -344, -19, -209, -177, 310, 427, 370, + /* 140 */ 268, 618, 541, 253, 622, 667, 509, 677, 185, 739, + /* 150 */ 354, 806, 810, 840, 755, -360, -350, 291, 397, 412, + /* 160 */ 453, 481, 243, 284, 613, 591, 568, 753, 880, 785, + /* 170 */ 889, 889, 930, 893, 954, 916, 911, 867, 867, 850, + /* 180 */ 867, 885, 870, 889, 913, 917, 937, 956, 964, 970, + /* 190 */ 999, 1041, 1044, 1004, 1005, 1007, 1049, 1042, 1056, 1057, + /* 200 */ 1058, 1073, 1076, 1010, 1072, 1055, 1075, 1086, 1038, 1090, + /* 210 */ 1091, 1093, 1094, 1096, 1103, 1100, 1105, 1108, 1115, 1095, + /* 220 */ 1097, 1098, 1099, 1101, 1102, 1104, 1109, 1110, 1111, 1112, + /* 230 */ 1113, 1120, 1079, 1080, 1059, 1063, 1067, 1127, 1078, 1107, + /* 240 */ 1132, 1140, 1117, 1121, 1119, 1034, 1122, 1126, 1050, 1128, + /* 250 */ 1134, 1135, 889, 1046, 1065, 1060, 1052, 1077, 1081, 1114, + /* 260 */ 1061, 1068, 1064, 867, 1160, 1131, 1197, 1198, 1200, 1201, + /* 270 */ 1157, 1158, 1172, 1183, 1184, 1186, 1187, 1165, 1189, 1178, + /* 280 */ 1228, 1211, 1229, 1214, 1159, 1220, 1216, 1237, 1258, 1250, + /* 290 */ 1266, 1259, 1202, 1193, 1207, 1217, 1257, 1262, 1263, 1267, + /* 300 */ 1276, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 10 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 20 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 30 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 40 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 50 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 60 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 70 */ 1619, 1875, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 80 */ 1619, 1619, 1619, 1619, 1619, 1698, 1619, 1619, 1619, 1619, - /* 90 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 100 */ 1619, 1619, 1619, 1619, 1696, 1868, 2072, 1619, 1619, 1619, - /* 110 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 120 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 130 */ 2084, 1619, 1619, 1698, 1619, 2084, 2084, 2084, 1696, 2044, - /* 140 */ 2044, 1619, 1619, 1619, 1619, 1805, 1619, 1619, 1619, 1619, - /* 150 */ 1619, 1619, 1805, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 160 */ 1619, 1918, 1619, 1619, 2109, 2163, 1619, 1619, 2112, 1619, - /* 170 */ 1619, 1619, 1880, 1619, 1758, 2099, 2076, 2090, 2147, 2077, - /* 180 */ 2074, 2093, 1619, 2103, 1619, 1911, 1873, 1619, 1873, 1870, - /* 190 */ 1619, 1619, 1873, 1870, 1870, 1619, 1749, 1619, 1619, 1619, - /* 200 */ 1619, 1619, 1619, 1698, 1619, 1698, 1619, 1619, 1698, 1619, - /* 210 */ 1698, 1698, 1698, 1619, 1698, 1676, 1676, 1619, 1619, 1619, - /* 220 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 230 */ 1619, 1619, 1619, 1931, 1619, 1696, 1920, 1619, 1696, 1619, - /* 240 */ 1619, 1619, 1619, 2120, 2118, 1619, 2120, 2118, 1619, 1619, - /* 250 */ 1619, 2132, 2128, 2120, 2136, 2134, 2105, 2103, 2166, 2153, - /* 260 */ 2149, 2090, 1619, 1619, 1619, 1619, 1696, 1696, 2118, 1619, - /* 270 */ 1619, 1619, 1619, 1619, 2118, 1619, 1619, 1696, 1619, 1696, - /* 280 */ 1619, 1619, 1774, 1619, 1619, 1619, 1696, 1651, 1619, 1913, - /* 290 */ 1924, 1896, 1896, 1808, 1808, 1808, 1699, 1624, 1619, 1619, - /* 300 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 310 */ 2131, 2130, 1999, 1619, 2048, 2047, 2046, 2037, 1998, 1770, - /* 320 */ 1619, 1997, 1996, 1619, 1619, 1619, 1619, 1619, 1887, 1886, - /* 330 */ 1990, 1619, 1619, 1991, 1989, 1988, 1619, 1619, 1619, 1619, - /* 340 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 350 */ 1619, 1619, 1619, 2150, 2154, 1619, 1619, 1619, 1619, 1619, - /* 360 */ 1619, 1619, 2073, 1619, 1619, 1619, 1619, 1619, 1973, 1619, - /* 370 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 380 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 390 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 400 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 410 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 420 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 430 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 440 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 450 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 460 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1656, - /* 470 */ 1978, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 480 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 490 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 500 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 510 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1737, 1736, 1619, - /* 520 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 530 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 540 */ 1619, 1981, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 550 */ 1619, 1619, 1619, 1619, 1619, 2146, 2106, 1619, 1619, 1619, - /* 560 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 570 */ 1619, 1619, 1619, 1619, 1973, 1619, 2129, 1619, 1619, 2144, - /* 580 */ 1619, 2148, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 2083, - /* 590 */ 2079, 1619, 1619, 2075, 1619, 1619, 1619, 1619, 1619, 1619, - /* 600 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 610 */ 1619, 1619, 1619, 1972, 1619, 2034, 1619, 1619, 1619, 2068, - /* 620 */ 1619, 1619, 2019, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 630 */ 1619, 1619, 1981, 1619, 1984, 1619, 1619, 1619, 1619, 1619, - /* 640 */ 1802, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 650 */ 1619, 1619, 1619, 1787, 1785, 1784, 1783, 1619, 1780, 1619, - /* 660 */ 1815, 1619, 1619, 1619, 1811, 1810, 1619, 1619, 1619, 1619, - /* 670 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 680 */ 1619, 1717, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 690 */ 1709, 1619, 1708, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 700 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 710 */ 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, 1619, - /* 720 */ 1619, 1619, 1619, 1619, 1619, + /* 0 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 10 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 20 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 30 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 40 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 50 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 60 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 70 */ 1638, 1896, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 80 */ 1638, 1638, 1638, 1638, 1638, 1717, 1638, 1638, 1638, 1638, + /* 90 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 100 */ 1638, 1638, 1638, 1638, 1638, 1715, 1889, 2098, 1638, 1638, + /* 110 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 120 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 130 */ 1638, 2110, 1638, 1638, 1717, 1638, 2110, 2110, 2110, 1715, + /* 140 */ 2070, 2070, 1638, 1638, 1638, 1638, 1824, 1638, 1638, 1638, + /* 150 */ 1638, 1638, 1638, 1824, 1638, 1638, 1638, 1638, 1638, 1638, + /* 160 */ 1638, 1638, 1941, 1638, 1638, 2135, 2189, 1638, 1638, 2138, + /* 170 */ 1638, 1638, 1638, 1901, 1638, 1777, 2125, 2102, 2116, 2173, + /* 180 */ 2103, 2100, 2119, 1638, 2129, 1638, 1934, 1894, 1638, 1894, + /* 190 */ 1891, 1638, 1638, 1894, 1891, 1891, 1638, 1768, 1638, 1638, + /* 200 */ 1638, 1638, 1638, 1638, 1717, 1638, 1717, 1638, 1638, 1717, + /* 210 */ 1638, 1717, 1717, 1717, 1638, 1717, 1695, 1695, 1638, 1638, + /* 220 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 230 */ 1638, 1638, 1638, 1638, 1956, 1947, 1638, 1715, 1943, 1638, + /* 240 */ 1715, 1638, 1638, 1638, 1638, 2146, 2144, 1638, 2146, 2144, + /* 250 */ 1638, 1638, 1638, 2158, 2154, 2146, 2162, 2160, 2131, 2129, + /* 260 */ 2192, 2179, 2175, 2116, 1638, 1638, 1638, 1638, 1715, 1715, + /* 270 */ 1638, 2144, 1638, 1638, 1638, 1638, 1638, 2144, 1638, 1638, + /* 280 */ 1715, 1638, 1715, 1638, 1638, 1793, 1638, 1638, 1638, 1715, + /* 290 */ 1670, 1638, 1936, 1949, 1919, 1919, 1827, 1827, 1827, 1718, + /* 300 */ 1643, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 310 */ 1638, 1638, 1638, 2157, 2156, 2025, 1638, 2074, 2073, 2072, + /* 320 */ 2063, 2024, 1789, 1638, 2023, 2022, 1638, 1638, 1638, 1638, + /* 330 */ 1638, 1638, 1910, 1909, 2016, 1638, 1638, 2017, 2015, 2014, + /* 340 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 350 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 2176, 2180, 1638, + /* 360 */ 1638, 1638, 1638, 1638, 1638, 1638, 2099, 1638, 1638, 1638, + /* 370 */ 1638, 1638, 1998, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 380 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 390 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 400 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 410 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 420 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 430 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 440 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 450 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 460 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 470 */ 1638, 1638, 1638, 1638, 1638, 1675, 2003, 1638, 1638, 1638, + /* 480 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 490 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 500 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 510 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 520 */ 1638, 1638, 1638, 1756, 1755, 1638, 1638, 1638, 1638, 1638, + /* 530 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 540 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 2007, 1638, 1638, + /* 550 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 560 */ 1638, 2172, 2132, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 570 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 580 */ 1998, 1638, 2155, 1638, 1638, 2170, 1638, 2174, 1638, 1638, + /* 590 */ 1638, 1638, 1638, 1638, 1638, 2109, 2105, 1638, 1638, 2101, + /* 600 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 2006, 1638, 1638, + /* 610 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 620 */ 1638, 1997, 1638, 2060, 1638, 1638, 1638, 2094, 1638, 1638, + /* 630 */ 2045, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 640 */ 2007, 1638, 2010, 1638, 1638, 1638, 1638, 1638, 1821, 1638, + /* 650 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 660 */ 1638, 1806, 1804, 1803, 1802, 1638, 1799, 1638, 1834, 1638, + /* 670 */ 1638, 1638, 1830, 1829, 1638, 1638, 1638, 1638, 1638, 1638, + /* 680 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1736, + /* 690 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1728, 1638, + /* 700 */ 1727, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 710 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 720 */ 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, + /* 730 */ 1638, 1638, 1638, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1218,6 +1169,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* CONSUMERS => nothing */ 0, /* SUBSCRIPTIONS => nothing */ 0, /* VNODES => nothing */ + 0, /* ALIVE => nothing */ 0, /* LIKE => nothing */ 0, /* TBNAME => nothing */ 0, /* QTAGS => nothing */ @@ -1286,7 +1238,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* SERVER_STATUS => nothing */ 0, /* CURRENT_USER => nothing */ 0, /* CASE => nothing */ - 272, /* END => ABORT */ + 273, /* END => ABORT */ 0, /* WHEN => nothing */ 0, /* THEN => nothing */ 0, /* ELSE => nothing */ @@ -1330,58 +1282,58 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ABORT => nothing */ - 272, /* AFTER => ABORT */ - 272, /* ATTACH => ABORT */ - 272, /* BEFORE => ABORT */ - 272, /* BEGIN => ABORT */ - 272, /* BITAND => ABORT */ - 272, /* BITNOT => ABORT */ - 272, /* BITOR => ABORT */ - 272, /* BLOCKS => ABORT */ - 272, /* CHANGE => ABORT */ - 272, /* COMMA => ABORT */ - 272, /* CONCAT => ABORT */ - 272, /* CONFLICT => ABORT */ - 272, /* COPY => ABORT */ - 272, /* DEFERRED => ABORT */ - 272, /* DELIMITERS => ABORT */ - 272, /* DETACH => ABORT */ - 272, /* DIVIDE => ABORT */ - 272, /* DOT => ABORT */ - 272, /* EACH => ABORT */ - 272, /* FAIL => ABORT */ - 272, /* FILE => ABORT */ - 272, /* FOR => ABORT */ - 272, /* GLOB => ABORT */ - 272, /* ID => ABORT */ - 272, /* IMMEDIATE => ABORT */ - 272, /* IMPORT => ABORT */ - 272, /* INITIALLY => ABORT */ - 272, /* INSTEAD => ABORT */ - 272, /* ISNULL => ABORT */ - 272, /* KEY => ABORT */ - 272, /* MODULES => ABORT */ - 272, /* NK_BITNOT => ABORT */ - 272, /* NK_SEMI => ABORT */ - 272, /* NOTNULL => ABORT */ - 272, /* OF => ABORT */ - 272, /* PLUS => ABORT */ - 272, /* PRIVILEGE => ABORT */ - 272, /* RAISE => ABORT */ - 272, /* REPLACE => ABORT */ - 272, /* RESTRICT => ABORT */ - 272, /* ROW => ABORT */ - 272, /* SEMI => ABORT */ - 272, /* STAR => ABORT */ - 272, /* STATEMENT => ABORT */ - 272, /* STRICT => ABORT */ - 272, /* STRING => ABORT */ - 272, /* TIMES => ABORT */ - 272, /* UPDATE => ABORT */ - 272, /* VALUES => ABORT */ - 272, /* VARIABLE => ABORT */ - 272, /* VIEW => ABORT */ - 272, /* WAL => ABORT */ + 273, /* AFTER => ABORT */ + 273, /* ATTACH => ABORT */ + 273, /* BEFORE => ABORT */ + 273, /* BEGIN => ABORT */ + 273, /* BITAND => ABORT */ + 273, /* BITNOT => ABORT */ + 273, /* BITOR => ABORT */ + 273, /* BLOCKS => ABORT */ + 273, /* CHANGE => ABORT */ + 273, /* COMMA => ABORT */ + 273, /* CONCAT => ABORT */ + 273, /* CONFLICT => ABORT */ + 273, /* COPY => ABORT */ + 273, /* DEFERRED => ABORT */ + 273, /* DELIMITERS => ABORT */ + 273, /* DETACH => ABORT */ + 273, /* DIVIDE => ABORT */ + 273, /* DOT => ABORT */ + 273, /* EACH => ABORT */ + 273, /* FAIL => ABORT */ + 273, /* FILE => ABORT */ + 273, /* FOR => ABORT */ + 273, /* GLOB => ABORT */ + 273, /* ID => ABORT */ + 273, /* IMMEDIATE => ABORT */ + 273, /* IMPORT => ABORT */ + 273, /* INITIALLY => ABORT */ + 273, /* INSTEAD => ABORT */ + 273, /* ISNULL => ABORT */ + 273, /* KEY => ABORT */ + 273, /* MODULES => ABORT */ + 273, /* NK_BITNOT => ABORT */ + 273, /* NK_SEMI => ABORT */ + 273, /* NOTNULL => ABORT */ + 273, /* OF => ABORT */ + 273, /* PLUS => ABORT */ + 273, /* PRIVILEGE => ABORT */ + 273, /* RAISE => ABORT */ + 273, /* REPLACE => ABORT */ + 273, /* RESTRICT => ABORT */ + 273, /* ROW => ABORT */ + 273, /* SEMI => ABORT */ + 273, /* STAR => ABORT */ + 273, /* STATEMENT => ABORT */ + 273, /* STRICT => ABORT */ + 273, /* STRING => ABORT */ + 273, /* TIMES => ABORT */ + 273, /* UPDATE => ABORT */ + 273, /* VALUES => ABORT */ + 273, /* VARIABLE => ABORT */ + 273, /* VIEW => ABORT */ + 273, /* WAL => ABORT */ }; #endif /* YYFALLBACK */ @@ -1630,306 +1582,310 @@ static const char *const yyTokenName[] = { /* 158 */ "CONSUMERS", /* 159 */ "SUBSCRIPTIONS", /* 160 */ "VNODES", - /* 161 */ "LIKE", - /* 162 */ "TBNAME", - /* 163 */ "QTAGS", - /* 164 */ "AS", - /* 165 */ "INDEX", - /* 166 */ "FUNCTION", - /* 167 */ "INTERVAL", - /* 168 */ "COUNT", - /* 169 */ "LAST_ROW", - /* 170 */ "TOPIC", - /* 171 */ "WITH", - /* 172 */ "META", - /* 173 */ "CONSUMER", - /* 174 */ "GROUP", - /* 175 */ "DESC", - /* 176 */ "DESCRIBE", - /* 177 */ "RESET", - /* 178 */ "QUERY", - /* 179 */ "CACHE", - /* 180 */ "EXPLAIN", - /* 181 */ "ANALYZE", - /* 182 */ "VERBOSE", - /* 183 */ "NK_BOOL", - /* 184 */ "RATIO", - /* 185 */ "NK_FLOAT", - /* 186 */ "OUTPUTTYPE", - /* 187 */ "AGGREGATE", - /* 188 */ "BUFSIZE", - /* 189 */ "STREAM", - /* 190 */ "INTO", - /* 191 */ "TRIGGER", - /* 192 */ "AT_ONCE", - /* 193 */ "WINDOW_CLOSE", - /* 194 */ "IGNORE", - /* 195 */ "EXPIRED", - /* 196 */ "FILL_HISTORY", - /* 197 */ "SUBTABLE", - /* 198 */ "KILL", - /* 199 */ "CONNECTION", - /* 200 */ "TRANSACTION", - /* 201 */ "BALANCE", - /* 202 */ "VGROUP", - /* 203 */ "MERGE", - /* 204 */ "REDISTRIBUTE", - /* 205 */ "SPLIT", - /* 206 */ "DELETE", - /* 207 */ "INSERT", - /* 208 */ "NULL", - /* 209 */ "NK_QUESTION", - /* 210 */ "NK_ARROW", - /* 211 */ "ROWTS", - /* 212 */ "QSTART", - /* 213 */ "QEND", - /* 214 */ "QDURATION", - /* 215 */ "WSTART", - /* 216 */ "WEND", - /* 217 */ "WDURATION", - /* 218 */ "IROWTS", - /* 219 */ "ISFILLED", - /* 220 */ "CAST", - /* 221 */ "NOW", - /* 222 */ "TODAY", - /* 223 */ "TIMEZONE", - /* 224 */ "CLIENT_VERSION", - /* 225 */ "SERVER_VERSION", - /* 226 */ "SERVER_STATUS", - /* 227 */ "CURRENT_USER", - /* 228 */ "CASE", - /* 229 */ "END", - /* 230 */ "WHEN", - /* 231 */ "THEN", - /* 232 */ "ELSE", - /* 233 */ "BETWEEN", - /* 234 */ "IS", - /* 235 */ "NK_LT", - /* 236 */ "NK_GT", - /* 237 */ "NK_LE", - /* 238 */ "NK_GE", - /* 239 */ "NK_NE", - /* 240 */ "MATCH", - /* 241 */ "NMATCH", - /* 242 */ "CONTAINS", - /* 243 */ "IN", - /* 244 */ "JOIN", - /* 245 */ "INNER", - /* 246 */ "SELECT", - /* 247 */ "DISTINCT", - /* 248 */ "WHERE", - /* 249 */ "PARTITION", - /* 250 */ "BY", - /* 251 */ "SESSION", - /* 252 */ "STATE_WINDOW", - /* 253 */ "EVENT_WINDOW", - /* 254 */ "START", - /* 255 */ "SLIDING", - /* 256 */ "FILL", - /* 257 */ "VALUE", - /* 258 */ "NONE", - /* 259 */ "PREV", - /* 260 */ "LINEAR", - /* 261 */ "NEXT", - /* 262 */ "HAVING", - /* 263 */ "RANGE", - /* 264 */ "EVERY", - /* 265 */ "ORDER", - /* 266 */ "SLIMIT", - /* 267 */ "SOFFSET", - /* 268 */ "LIMIT", - /* 269 */ "OFFSET", - /* 270 */ "ASC", - /* 271 */ "NULLS", - /* 272 */ "ABORT", - /* 273 */ "AFTER", - /* 274 */ "ATTACH", - /* 275 */ "BEFORE", - /* 276 */ "BEGIN", - /* 277 */ "BITAND", - /* 278 */ "BITNOT", - /* 279 */ "BITOR", - /* 280 */ "BLOCKS", - /* 281 */ "CHANGE", - /* 282 */ "COMMA", - /* 283 */ "CONCAT", - /* 284 */ "CONFLICT", - /* 285 */ "COPY", - /* 286 */ "DEFERRED", - /* 287 */ "DELIMITERS", - /* 288 */ "DETACH", - /* 289 */ "DIVIDE", - /* 290 */ "DOT", - /* 291 */ "EACH", - /* 292 */ "FAIL", - /* 293 */ "FILE", - /* 294 */ "FOR", - /* 295 */ "GLOB", - /* 296 */ "ID", - /* 297 */ "IMMEDIATE", - /* 298 */ "IMPORT", - /* 299 */ "INITIALLY", - /* 300 */ "INSTEAD", - /* 301 */ "ISNULL", - /* 302 */ "KEY", - /* 303 */ "MODULES", - /* 304 */ "NK_BITNOT", - /* 305 */ "NK_SEMI", - /* 306 */ "NOTNULL", - /* 307 */ "OF", - /* 308 */ "PLUS", - /* 309 */ "PRIVILEGE", - /* 310 */ "RAISE", - /* 311 */ "REPLACE", - /* 312 */ "RESTRICT", - /* 313 */ "ROW", - /* 314 */ "SEMI", - /* 315 */ "STAR", - /* 316 */ "STATEMENT", - /* 317 */ "STRICT", - /* 318 */ "STRING", - /* 319 */ "TIMES", - /* 320 */ "UPDATE", - /* 321 */ "VALUES", - /* 322 */ "VARIABLE", - /* 323 */ "VIEW", - /* 324 */ "WAL", - /* 325 */ "cmd", - /* 326 */ "account_options", - /* 327 */ "alter_account_options", - /* 328 */ "literal", - /* 329 */ "alter_account_option", - /* 330 */ "user_name", - /* 331 */ "sysinfo_opt", - /* 332 */ "privileges", - /* 333 */ "priv_level", - /* 334 */ "priv_type_list", - /* 335 */ "priv_type", - /* 336 */ "db_name", - /* 337 */ "topic_name", - /* 338 */ "dnode_endpoint", - /* 339 */ "force_opt", - /* 340 */ "not_exists_opt", - /* 341 */ "db_options", - /* 342 */ "exists_opt", - /* 343 */ "alter_db_options", - /* 344 */ "speed_opt", - /* 345 */ "integer_list", - /* 346 */ "variable_list", - /* 347 */ "retention_list", - /* 348 */ "alter_db_option", - /* 349 */ "retention", - /* 350 */ "full_table_name", - /* 351 */ "column_def_list", - /* 352 */ "tags_def_opt", - /* 353 */ "table_options", - /* 354 */ "multi_create_clause", - /* 355 */ "tags_def", - /* 356 */ "multi_drop_clause", - /* 357 */ "alter_table_clause", - /* 358 */ "alter_table_options", - /* 359 */ "column_name", - /* 360 */ "type_name", - /* 361 */ "signed_literal", - /* 362 */ "create_subtable_clause", - /* 363 */ "specific_cols_opt", - /* 364 */ "expression_list", - /* 365 */ "drop_table_clause", - /* 366 */ "col_name_list", - /* 367 */ "table_name", - /* 368 */ "column_def", - /* 369 */ "duration_list", - /* 370 */ "rollup_func_list", - /* 371 */ "alter_table_option", - /* 372 */ "duration_literal", - /* 373 */ "rollup_func_name", - /* 374 */ "function_name", - /* 375 */ "col_name", - /* 376 */ "db_name_cond_opt", - /* 377 */ "like_pattern_opt", - /* 378 */ "table_name_cond", - /* 379 */ "from_db_opt", - /* 380 */ "tag_list_opt", - /* 381 */ "tag_item", - /* 382 */ "column_alias", - /* 383 */ "index_options", - /* 384 */ "func_list", - /* 385 */ "sliding_opt", - /* 386 */ "sma_stream_opt", - /* 387 */ "func", - /* 388 */ "sma_func_name", - /* 389 */ "query_or_subquery", - /* 390 */ "cgroup_name", - /* 391 */ "analyze_opt", - /* 392 */ "explain_options", - /* 393 */ "agg_func_opt", - /* 394 */ "bufsize_opt", - /* 395 */ "stream_name", - /* 396 */ "stream_options", - /* 397 */ "subtable_opt", - /* 398 */ "expression", - /* 399 */ "dnode_list", - /* 400 */ "where_clause_opt", - /* 401 */ "signed", - /* 402 */ "literal_func", - /* 403 */ "literal_list", - /* 404 */ "table_alias", - /* 405 */ "expr_or_subquery", - /* 406 */ "pseudo_column", - /* 407 */ "column_reference", - /* 408 */ "function_expression", - /* 409 */ "case_when_expression", - /* 410 */ "star_func", - /* 411 */ "star_func_para_list", - /* 412 */ "noarg_func", - /* 413 */ "other_para_list", - /* 414 */ "star_func_para", - /* 415 */ "when_then_list", - /* 416 */ "case_when_else_opt", - /* 417 */ "common_expression", - /* 418 */ "when_then_expr", - /* 419 */ "predicate", - /* 420 */ "compare_op", - /* 421 */ "in_op", - /* 422 */ "in_predicate_value", - /* 423 */ "boolean_value_expression", - /* 424 */ "boolean_primary", - /* 425 */ "from_clause_opt", - /* 426 */ "table_reference_list", - /* 427 */ "table_reference", - /* 428 */ "table_primary", - /* 429 */ "joined_table", - /* 430 */ "alias_opt", - /* 431 */ "subquery", - /* 432 */ "parenthesized_joined_table", - /* 433 */ "join_type", - /* 434 */ "search_condition", - /* 435 */ "query_specification", - /* 436 */ "set_quantifier_opt", - /* 437 */ "select_list", - /* 438 */ "partition_by_clause_opt", - /* 439 */ "range_opt", - /* 440 */ "every_opt", - /* 441 */ "fill_opt", - /* 442 */ "twindow_clause_opt", - /* 443 */ "group_by_clause_opt", - /* 444 */ "having_clause_opt", - /* 445 */ "select_item", - /* 446 */ "partition_list", - /* 447 */ "partition_item", - /* 448 */ "fill_mode", - /* 449 */ "group_by_list", - /* 450 */ "query_expression", - /* 451 */ "query_simple", - /* 452 */ "order_by_clause_opt", - /* 453 */ "slimit_clause_opt", - /* 454 */ "limit_clause_opt", - /* 455 */ "union_query_expression", - /* 456 */ "query_simple_or_subquery", - /* 457 */ "sort_specification_list", - /* 458 */ "sort_specification", - /* 459 */ "ordering_specification_opt", - /* 460 */ "null_ordering_opt", + /* 161 */ "ALIVE", + /* 162 */ "LIKE", + /* 163 */ "TBNAME", + /* 164 */ "QTAGS", + /* 165 */ "AS", + /* 166 */ "INDEX", + /* 167 */ "FUNCTION", + /* 168 */ "INTERVAL", + /* 169 */ "COUNT", + /* 170 */ "LAST_ROW", + /* 171 */ "TOPIC", + /* 172 */ "WITH", + /* 173 */ "META", + /* 174 */ "CONSUMER", + /* 175 */ "GROUP", + /* 176 */ "DESC", + /* 177 */ "DESCRIBE", + /* 178 */ "RESET", + /* 179 */ "QUERY", + /* 180 */ "CACHE", + /* 181 */ "EXPLAIN", + /* 182 */ "ANALYZE", + /* 183 */ "VERBOSE", + /* 184 */ "NK_BOOL", + /* 185 */ "RATIO", + /* 186 */ "NK_FLOAT", + /* 187 */ "OUTPUTTYPE", + /* 188 */ "AGGREGATE", + /* 189 */ "BUFSIZE", + /* 190 */ "STREAM", + /* 191 */ "INTO", + /* 192 */ "TRIGGER", + /* 193 */ "AT_ONCE", + /* 194 */ "WINDOW_CLOSE", + /* 195 */ "IGNORE", + /* 196 */ "EXPIRED", + /* 197 */ "FILL_HISTORY", + /* 198 */ "SUBTABLE", + /* 199 */ "KILL", + /* 200 */ "CONNECTION", + /* 201 */ "TRANSACTION", + /* 202 */ "BALANCE", + /* 203 */ "VGROUP", + /* 204 */ "MERGE", + /* 205 */ "REDISTRIBUTE", + /* 206 */ "SPLIT", + /* 207 */ "DELETE", + /* 208 */ "INSERT", + /* 209 */ "NULL", + /* 210 */ "NK_QUESTION", + /* 211 */ "NK_ARROW", + /* 212 */ "ROWTS", + /* 213 */ "QSTART", + /* 214 */ "QEND", + /* 215 */ "QDURATION", + /* 216 */ "WSTART", + /* 217 */ "WEND", + /* 218 */ "WDURATION", + /* 219 */ "IROWTS", + /* 220 */ "ISFILLED", + /* 221 */ "CAST", + /* 222 */ "NOW", + /* 223 */ "TODAY", + /* 224 */ "TIMEZONE", + /* 225 */ "CLIENT_VERSION", + /* 226 */ "SERVER_VERSION", + /* 227 */ "SERVER_STATUS", + /* 228 */ "CURRENT_USER", + /* 229 */ "CASE", + /* 230 */ "END", + /* 231 */ "WHEN", + /* 232 */ "THEN", + /* 233 */ "ELSE", + /* 234 */ "BETWEEN", + /* 235 */ "IS", + /* 236 */ "NK_LT", + /* 237 */ "NK_GT", + /* 238 */ "NK_LE", + /* 239 */ "NK_GE", + /* 240 */ "NK_NE", + /* 241 */ "MATCH", + /* 242 */ "NMATCH", + /* 243 */ "CONTAINS", + /* 244 */ "IN", + /* 245 */ "JOIN", + /* 246 */ "INNER", + /* 247 */ "SELECT", + /* 248 */ "DISTINCT", + /* 249 */ "WHERE", + /* 250 */ "PARTITION", + /* 251 */ "BY", + /* 252 */ "SESSION", + /* 253 */ "STATE_WINDOW", + /* 254 */ "EVENT_WINDOW", + /* 255 */ "START", + /* 256 */ "SLIDING", + /* 257 */ "FILL", + /* 258 */ "VALUE", + /* 259 */ "NONE", + /* 260 */ "PREV", + /* 261 */ "LINEAR", + /* 262 */ "NEXT", + /* 263 */ "HAVING", + /* 264 */ "RANGE", + /* 265 */ "EVERY", + /* 266 */ "ORDER", + /* 267 */ "SLIMIT", + /* 268 */ "SOFFSET", + /* 269 */ "LIMIT", + /* 270 */ "OFFSET", + /* 271 */ "ASC", + /* 272 */ "NULLS", + /* 273 */ "ABORT", + /* 274 */ "AFTER", + /* 275 */ "ATTACH", + /* 276 */ "BEFORE", + /* 277 */ "BEGIN", + /* 278 */ "BITAND", + /* 279 */ "BITNOT", + /* 280 */ "BITOR", + /* 281 */ "BLOCKS", + /* 282 */ "CHANGE", + /* 283 */ "COMMA", + /* 284 */ "CONCAT", + /* 285 */ "CONFLICT", + /* 286 */ "COPY", + /* 287 */ "DEFERRED", + /* 288 */ "DELIMITERS", + /* 289 */ "DETACH", + /* 290 */ "DIVIDE", + /* 291 */ "DOT", + /* 292 */ "EACH", + /* 293 */ "FAIL", + /* 294 */ "FILE", + /* 295 */ "FOR", + /* 296 */ "GLOB", + /* 297 */ "ID", + /* 298 */ "IMMEDIATE", + /* 299 */ "IMPORT", + /* 300 */ "INITIALLY", + /* 301 */ "INSTEAD", + /* 302 */ "ISNULL", + /* 303 */ "KEY", + /* 304 */ "MODULES", + /* 305 */ "NK_BITNOT", + /* 306 */ "NK_SEMI", + /* 307 */ "NOTNULL", + /* 308 */ "OF", + /* 309 */ "PLUS", + /* 310 */ "PRIVILEGE", + /* 311 */ "RAISE", + /* 312 */ "REPLACE", + /* 313 */ "RESTRICT", + /* 314 */ "ROW", + /* 315 */ "SEMI", + /* 316 */ "STAR", + /* 317 */ "STATEMENT", + /* 318 */ "STRICT", + /* 319 */ "STRING", + /* 320 */ "TIMES", + /* 321 */ "UPDATE", + /* 322 */ "VALUES", + /* 323 */ "VARIABLE", + /* 324 */ "VIEW", + /* 325 */ "WAL", + /* 326 */ "cmd", + /* 327 */ "account_options", + /* 328 */ "alter_account_options", + /* 329 */ "literal", + /* 330 */ "alter_account_option", + /* 331 */ "user_name", + /* 332 */ "sysinfo_opt", + /* 333 */ "privileges", + /* 334 */ "priv_level", + /* 335 */ "priv_type_list", + /* 336 */ "priv_type", + /* 337 */ "db_name", + /* 338 */ "topic_name", + /* 339 */ "dnode_endpoint", + /* 340 */ "force_opt", + /* 341 */ "not_exists_opt", + /* 342 */ "db_options", + /* 343 */ "exists_opt", + /* 344 */ "alter_db_options", + /* 345 */ "speed_opt", + /* 346 */ "integer_list", + /* 347 */ "variable_list", + /* 348 */ "retention_list", + /* 349 */ "alter_db_option", + /* 350 */ "retention", + /* 351 */ "full_table_name", + /* 352 */ "column_def_list", + /* 353 */ "tags_def_opt", + /* 354 */ "table_options", + /* 355 */ "multi_create_clause", + /* 356 */ "tags_def", + /* 357 */ "multi_drop_clause", + /* 358 */ "alter_table_clause", + /* 359 */ "alter_table_options", + /* 360 */ "column_name", + /* 361 */ "type_name", + /* 362 */ "signed_literal", + /* 363 */ "create_subtable_clause", + /* 364 */ "specific_cols_opt", + /* 365 */ "expression_list", + /* 366 */ "drop_table_clause", + /* 367 */ "col_name_list", + /* 368 */ "table_name", + /* 369 */ "column_def", + /* 370 */ "duration_list", + /* 371 */ "rollup_func_list", + /* 372 */ "alter_table_option", + /* 373 */ "duration_literal", + /* 374 */ "rollup_func_name", + /* 375 */ "function_name", + /* 376 */ "col_name", + /* 377 */ "db_name_cond_opt", + /* 378 */ "like_pattern_opt", + /* 379 */ "table_name_cond", + /* 380 */ "from_db_opt", + /* 381 */ "tag_list_opt", + /* 382 */ "tag_item", + /* 383 */ "column_alias", + /* 384 */ "full_index_name", + /* 385 */ "index_options", + /* 386 */ "index_name", + /* 387 */ "func_list", + /* 388 */ "sliding_opt", + /* 389 */ "sma_stream_opt", + /* 390 */ "func", + /* 391 */ "sma_func_name", + /* 392 */ "query_or_subquery", + /* 393 */ "cgroup_name", + /* 394 */ "analyze_opt", + /* 395 */ "explain_options", + /* 396 */ "agg_func_opt", + /* 397 */ "bufsize_opt", + /* 398 */ "stream_name", + /* 399 */ "stream_options", + /* 400 */ "col_list_opt", + /* 401 */ "subtable_opt", + /* 402 */ "expression", + /* 403 */ "dnode_list", + /* 404 */ "where_clause_opt", + /* 405 */ "signed", + /* 406 */ "literal_func", + /* 407 */ "literal_list", + /* 408 */ "table_alias", + /* 409 */ "expr_or_subquery", + /* 410 */ "pseudo_column", + /* 411 */ "column_reference", + /* 412 */ "function_expression", + /* 413 */ "case_when_expression", + /* 414 */ "star_func", + /* 415 */ "star_func_para_list", + /* 416 */ "noarg_func", + /* 417 */ "other_para_list", + /* 418 */ "star_func_para", + /* 419 */ "when_then_list", + /* 420 */ "case_when_else_opt", + /* 421 */ "common_expression", + /* 422 */ "when_then_expr", + /* 423 */ "predicate", + /* 424 */ "compare_op", + /* 425 */ "in_op", + /* 426 */ "in_predicate_value", + /* 427 */ "boolean_value_expression", + /* 428 */ "boolean_primary", + /* 429 */ "from_clause_opt", + /* 430 */ "table_reference_list", + /* 431 */ "table_reference", + /* 432 */ "table_primary", + /* 433 */ "joined_table", + /* 434 */ "alias_opt", + /* 435 */ "subquery", + /* 436 */ "parenthesized_joined_table", + /* 437 */ "join_type", + /* 438 */ "search_condition", + /* 439 */ "query_specification", + /* 440 */ "set_quantifier_opt", + /* 441 */ "select_list", + /* 442 */ "partition_by_clause_opt", + /* 443 */ "range_opt", + /* 444 */ "every_opt", + /* 445 */ "fill_opt", + /* 446 */ "twindow_clause_opt", + /* 447 */ "group_by_clause_opt", + /* 448 */ "having_clause_opt", + /* 449 */ "select_item", + /* 450 */ "partition_list", + /* 451 */ "partition_item", + /* 452 */ "fill_mode", + /* 453 */ "group_by_list", + /* 454 */ "query_expression", + /* 455 */ "query_simple", + /* 456 */ "order_by_clause_opt", + /* 457 */ "slimit_clause_opt", + /* 458 */ "limit_clause_opt", + /* 459 */ "union_query_expression", + /* 460 */ "query_simple_or_subquery", + /* 461 */ "sort_specification_list", + /* 462 */ "sort_specification", + /* 463 */ "ordering_specification_opt", + /* 464 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -2183,307 +2139,314 @@ static const char *const yyRuleName[] = { /* 243 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", /* 244 */ "cmd ::= SHOW VNODES NK_INTEGER", /* 245 */ "cmd ::= SHOW VNODES NK_STRING", - /* 246 */ "db_name_cond_opt ::=", - /* 247 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 248 */ "like_pattern_opt ::=", - /* 249 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 250 */ "table_name_cond ::= table_name", - /* 251 */ "from_db_opt ::=", - /* 252 */ "from_db_opt ::= FROM db_name", - /* 253 */ "tag_list_opt ::=", - /* 254 */ "tag_list_opt ::= tag_item", - /* 255 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", - /* 256 */ "tag_item ::= TBNAME", - /* 257 */ "tag_item ::= QTAGS", - /* 258 */ "tag_item ::= column_name", - /* 259 */ "tag_item ::= column_name column_alias", - /* 260 */ "tag_item ::= column_name AS column_alias", - /* 261 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options", - /* 262 */ "cmd ::= CREATE INDEX not_exists_opt full_table_name ON full_table_name NK_LP col_name_list NK_RP", - /* 263 */ "cmd ::= DROP INDEX exists_opt full_table_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 ::= sma_func_name NK_LP expression_list NK_RP", - /* 269 */ "sma_func_name ::= function_name", - /* 270 */ "sma_func_name ::= COUNT", - /* 271 */ "sma_func_name ::= FIRST", - /* 272 */ "sma_func_name ::= LAST", - /* 273 */ "sma_func_name ::= LAST_ROW", - /* 274 */ "sma_stream_opt ::=", - /* 275 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", - /* 276 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", - /* 277 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", - /* 278 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", - /* 279 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", - /* 280 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", - /* 281 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", - /* 282 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", - /* 283 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 284 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 285 */ "cmd ::= DESC full_table_name", - /* 286 */ "cmd ::= DESCRIBE full_table_name", - /* 287 */ "cmd ::= RESET QUERY CACHE", - /* 288 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", - /* 289 */ "analyze_opt ::=", - /* 290 */ "analyze_opt ::= ANALYZE", - /* 291 */ "explain_options ::=", - /* 292 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 293 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 294 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", - /* 295 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 296 */ "agg_func_opt ::=", - /* 297 */ "agg_func_opt ::= AGGREGATE", - /* 298 */ "bufsize_opt ::=", - /* 299 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 300 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery", - /* 301 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 302 */ "stream_options ::=", - /* 303 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 304 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 305 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 306 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 307 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 308 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", - /* 309 */ "subtable_opt ::=", - /* 310 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 311 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 312 */ "cmd ::= KILL QUERY NK_STRING", - /* 313 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 314 */ "cmd ::= BALANCE VGROUP", - /* 315 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 316 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 317 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 318 */ "dnode_list ::= DNODE NK_INTEGER", - /* 319 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 320 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 321 */ "cmd ::= query_or_subquery", - /* 322 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 323 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", - /* 324 */ "literal ::= NK_INTEGER", - /* 325 */ "literal ::= NK_FLOAT", - /* 326 */ "literal ::= NK_STRING", - /* 327 */ "literal ::= NK_BOOL", - /* 328 */ "literal ::= TIMESTAMP NK_STRING", - /* 329 */ "literal ::= duration_literal", - /* 330 */ "literal ::= NULL", - /* 331 */ "literal ::= NK_QUESTION", - /* 332 */ "duration_literal ::= NK_VARIABLE", - /* 333 */ "signed ::= NK_INTEGER", - /* 334 */ "signed ::= NK_PLUS NK_INTEGER", - /* 335 */ "signed ::= NK_MINUS NK_INTEGER", - /* 336 */ "signed ::= NK_FLOAT", - /* 337 */ "signed ::= NK_PLUS NK_FLOAT", - /* 338 */ "signed ::= NK_MINUS NK_FLOAT", - /* 339 */ "signed_literal ::= signed", - /* 340 */ "signed_literal ::= NK_STRING", - /* 341 */ "signed_literal ::= NK_BOOL", - /* 342 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 343 */ "signed_literal ::= duration_literal", - /* 344 */ "signed_literal ::= NULL", - /* 345 */ "signed_literal ::= literal_func", - /* 346 */ "signed_literal ::= NK_QUESTION", - /* 347 */ "literal_list ::= signed_literal", - /* 348 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 349 */ "db_name ::= NK_ID", - /* 350 */ "table_name ::= NK_ID", - /* 351 */ "column_name ::= NK_ID", - /* 352 */ "function_name ::= NK_ID", - /* 353 */ "table_alias ::= NK_ID", - /* 354 */ "column_alias ::= NK_ID", - /* 355 */ "user_name ::= NK_ID", - /* 356 */ "topic_name ::= NK_ID", - /* 357 */ "stream_name ::= NK_ID", - /* 358 */ "cgroup_name ::= NK_ID", - /* 359 */ "expr_or_subquery ::= expression", - /* 360 */ "expression ::= literal", - /* 361 */ "expression ::= pseudo_column", - /* 362 */ "expression ::= column_reference", - /* 363 */ "expression ::= function_expression", - /* 364 */ "expression ::= case_when_expression", - /* 365 */ "expression ::= NK_LP expression NK_RP", - /* 366 */ "expression ::= NK_PLUS expr_or_subquery", - /* 367 */ "expression ::= NK_MINUS expr_or_subquery", - /* 368 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 369 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 370 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 371 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 372 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 373 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 374 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 375 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 376 */ "expression_list ::= expr_or_subquery", - /* 377 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 378 */ "column_reference ::= column_name", - /* 379 */ "column_reference ::= table_name NK_DOT column_name", - /* 380 */ "pseudo_column ::= ROWTS", - /* 381 */ "pseudo_column ::= TBNAME", - /* 382 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 383 */ "pseudo_column ::= QSTART", - /* 384 */ "pseudo_column ::= QEND", - /* 385 */ "pseudo_column ::= QDURATION", - /* 386 */ "pseudo_column ::= WSTART", - /* 387 */ "pseudo_column ::= WEND", - /* 388 */ "pseudo_column ::= WDURATION", - /* 389 */ "pseudo_column ::= IROWTS", - /* 390 */ "pseudo_column ::= ISFILLED", - /* 391 */ "pseudo_column ::= QTAGS", - /* 392 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 393 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 394 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 395 */ "function_expression ::= literal_func", - /* 396 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 397 */ "literal_func ::= NOW", - /* 398 */ "noarg_func ::= NOW", - /* 399 */ "noarg_func ::= TODAY", - /* 400 */ "noarg_func ::= TIMEZONE", - /* 401 */ "noarg_func ::= DATABASE", - /* 402 */ "noarg_func ::= CLIENT_VERSION", - /* 403 */ "noarg_func ::= SERVER_VERSION", - /* 404 */ "noarg_func ::= SERVER_STATUS", - /* 405 */ "noarg_func ::= CURRENT_USER", - /* 406 */ "noarg_func ::= USER", - /* 407 */ "star_func ::= COUNT", - /* 408 */ "star_func ::= FIRST", - /* 409 */ "star_func ::= LAST", - /* 410 */ "star_func ::= LAST_ROW", - /* 411 */ "star_func_para_list ::= NK_STAR", - /* 412 */ "star_func_para_list ::= other_para_list", - /* 413 */ "other_para_list ::= star_func_para", - /* 414 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 415 */ "star_func_para ::= expr_or_subquery", - /* 416 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 417 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 418 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 419 */ "when_then_list ::= when_then_expr", - /* 420 */ "when_then_list ::= when_then_list when_then_expr", - /* 421 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 422 */ "case_when_else_opt ::=", - /* 423 */ "case_when_else_opt ::= ELSE common_expression", - /* 424 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 425 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 426 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 427 */ "predicate ::= expr_or_subquery IS NULL", - /* 428 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 429 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 430 */ "compare_op ::= NK_LT", - /* 431 */ "compare_op ::= NK_GT", - /* 432 */ "compare_op ::= NK_LE", - /* 433 */ "compare_op ::= NK_GE", - /* 434 */ "compare_op ::= NK_NE", - /* 435 */ "compare_op ::= NK_EQ", - /* 436 */ "compare_op ::= LIKE", - /* 437 */ "compare_op ::= NOT LIKE", - /* 438 */ "compare_op ::= MATCH", - /* 439 */ "compare_op ::= NMATCH", - /* 440 */ "compare_op ::= CONTAINS", - /* 441 */ "in_op ::= IN", - /* 442 */ "in_op ::= NOT IN", - /* 443 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 444 */ "boolean_value_expression ::= boolean_primary", - /* 445 */ "boolean_value_expression ::= NOT boolean_primary", - /* 446 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 447 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 448 */ "boolean_primary ::= predicate", - /* 449 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 450 */ "common_expression ::= expr_or_subquery", - /* 451 */ "common_expression ::= boolean_value_expression", - /* 452 */ "from_clause_opt ::=", - /* 453 */ "from_clause_opt ::= FROM table_reference_list", - /* 454 */ "table_reference_list ::= table_reference", - /* 455 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 456 */ "table_reference ::= table_primary", - /* 457 */ "table_reference ::= joined_table", - /* 458 */ "table_primary ::= table_name alias_opt", - /* 459 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 460 */ "table_primary ::= subquery alias_opt", - /* 461 */ "table_primary ::= parenthesized_joined_table", - /* 462 */ "alias_opt ::=", - /* 463 */ "alias_opt ::= table_alias", - /* 464 */ "alias_opt ::= AS table_alias", - /* 465 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 466 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 467 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 468 */ "join_type ::=", - /* 469 */ "join_type ::= INNER", - /* 470 */ "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", - /* 471 */ "set_quantifier_opt ::=", - /* 472 */ "set_quantifier_opt ::= DISTINCT", - /* 473 */ "set_quantifier_opt ::= ALL", - /* 474 */ "select_list ::= select_item", - /* 475 */ "select_list ::= select_list NK_COMMA select_item", - /* 476 */ "select_item ::= NK_STAR", - /* 477 */ "select_item ::= common_expression", - /* 478 */ "select_item ::= common_expression column_alias", - /* 479 */ "select_item ::= common_expression AS column_alias", - /* 480 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 481 */ "where_clause_opt ::=", - /* 482 */ "where_clause_opt ::= WHERE search_condition", - /* 483 */ "partition_by_clause_opt ::=", - /* 484 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 485 */ "partition_list ::= partition_item", - /* 486 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 487 */ "partition_item ::= expr_or_subquery", - /* 488 */ "partition_item ::= expr_or_subquery column_alias", - /* 489 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 490 */ "twindow_clause_opt ::=", - /* 491 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 492 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 493 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 494 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 495 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", - /* 496 */ "sliding_opt ::=", - /* 497 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 498 */ "fill_opt ::=", - /* 499 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 500 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 501 */ "fill_mode ::= NONE", - /* 502 */ "fill_mode ::= PREV", - /* 503 */ "fill_mode ::= NULL", - /* 504 */ "fill_mode ::= LINEAR", - /* 505 */ "fill_mode ::= NEXT", - /* 506 */ "group_by_clause_opt ::=", - /* 507 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 508 */ "group_by_list ::= expr_or_subquery", - /* 509 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 510 */ "having_clause_opt ::=", - /* 511 */ "having_clause_opt ::= HAVING search_condition", - /* 512 */ "range_opt ::=", - /* 513 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 514 */ "every_opt ::=", - /* 515 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 516 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 517 */ "query_simple ::= query_specification", - /* 518 */ "query_simple ::= union_query_expression", - /* 519 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 520 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 521 */ "query_simple_or_subquery ::= query_simple", - /* 522 */ "query_simple_or_subquery ::= subquery", - /* 523 */ "query_or_subquery ::= query_expression", - /* 524 */ "query_or_subquery ::= subquery", - /* 525 */ "order_by_clause_opt ::=", - /* 526 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 527 */ "slimit_clause_opt ::=", - /* 528 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 529 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 530 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 531 */ "limit_clause_opt ::=", - /* 532 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 533 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 534 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 535 */ "subquery ::= NK_LP query_expression NK_RP", - /* 536 */ "subquery ::= NK_LP subquery NK_RP", - /* 537 */ "search_condition ::= common_expression", - /* 538 */ "sort_specification_list ::= sort_specification", - /* 539 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 540 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 541 */ "ordering_specification_opt ::=", - /* 542 */ "ordering_specification_opt ::= ASC", - /* 543 */ "ordering_specification_opt ::= DESC", - /* 544 */ "null_ordering_opt ::=", - /* 545 */ "null_ordering_opt ::= NULLS FIRST", - /* 546 */ "null_ordering_opt ::= NULLS LAST", + /* 246 */ "cmd ::= SHOW db_name_cond_opt ALIVE", + /* 247 */ "cmd ::= SHOW CLUSTER ALIVE", + /* 248 */ "db_name_cond_opt ::=", + /* 249 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 250 */ "like_pattern_opt ::=", + /* 251 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 252 */ "table_name_cond ::= table_name", + /* 253 */ "from_db_opt ::=", + /* 254 */ "from_db_opt ::= FROM db_name", + /* 255 */ "tag_list_opt ::=", + /* 256 */ "tag_list_opt ::= tag_item", + /* 257 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", + /* 258 */ "tag_item ::= TBNAME", + /* 259 */ "tag_item ::= QTAGS", + /* 260 */ "tag_item ::= column_name", + /* 261 */ "tag_item ::= column_name column_alias", + /* 262 */ "tag_item ::= column_name AS column_alias", + /* 263 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options", + /* 264 */ "cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP", + /* 265 */ "cmd ::= DROP INDEX exists_opt full_index_name", + /* 266 */ "full_index_name ::= index_name", + /* 267 */ "full_index_name ::= db_name NK_DOT index_name", + /* 268 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 269 */ "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", + /* 270 */ "func_list ::= func", + /* 271 */ "func_list ::= func_list NK_COMMA func", + /* 272 */ "func ::= sma_func_name NK_LP expression_list NK_RP", + /* 273 */ "sma_func_name ::= function_name", + /* 274 */ "sma_func_name ::= COUNT", + /* 275 */ "sma_func_name ::= FIRST", + /* 276 */ "sma_func_name ::= LAST", + /* 277 */ "sma_func_name ::= LAST_ROW", + /* 278 */ "sma_stream_opt ::=", + /* 279 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", + /* 280 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", + /* 281 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", + /* 282 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", + /* 283 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", + /* 284 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", + /* 285 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", + /* 286 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", + /* 287 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 288 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 289 */ "cmd ::= DESC full_table_name", + /* 290 */ "cmd ::= DESCRIBE full_table_name", + /* 291 */ "cmd ::= RESET QUERY CACHE", + /* 292 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", + /* 293 */ "analyze_opt ::=", + /* 294 */ "analyze_opt ::= ANALYZE", + /* 295 */ "explain_options ::=", + /* 296 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 297 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 298 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 299 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 300 */ "agg_func_opt ::=", + /* 301 */ "agg_func_opt ::= AGGREGATE", + /* 302 */ "bufsize_opt ::=", + /* 303 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 304 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tags_def_opt subtable_opt AS query_or_subquery", + /* 305 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 306 */ "col_list_opt ::=", + /* 307 */ "col_list_opt ::= NK_LP col_name_list NK_RP", + /* 308 */ "stream_options ::=", + /* 309 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 310 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 311 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 312 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 313 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", + /* 314 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", + /* 315 */ "subtable_opt ::=", + /* 316 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 317 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 318 */ "cmd ::= KILL QUERY NK_STRING", + /* 319 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 320 */ "cmd ::= BALANCE VGROUP", + /* 321 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 322 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 323 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 324 */ "dnode_list ::= DNODE NK_INTEGER", + /* 325 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 326 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 327 */ "cmd ::= query_or_subquery", + /* 328 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 329 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", + /* 330 */ "literal ::= NK_INTEGER", + /* 331 */ "literal ::= NK_FLOAT", + /* 332 */ "literal ::= NK_STRING", + /* 333 */ "literal ::= NK_BOOL", + /* 334 */ "literal ::= TIMESTAMP NK_STRING", + /* 335 */ "literal ::= duration_literal", + /* 336 */ "literal ::= NULL", + /* 337 */ "literal ::= NK_QUESTION", + /* 338 */ "duration_literal ::= NK_VARIABLE", + /* 339 */ "signed ::= NK_INTEGER", + /* 340 */ "signed ::= NK_PLUS NK_INTEGER", + /* 341 */ "signed ::= NK_MINUS NK_INTEGER", + /* 342 */ "signed ::= NK_FLOAT", + /* 343 */ "signed ::= NK_PLUS NK_FLOAT", + /* 344 */ "signed ::= NK_MINUS NK_FLOAT", + /* 345 */ "signed_literal ::= signed", + /* 346 */ "signed_literal ::= NK_STRING", + /* 347 */ "signed_literal ::= NK_BOOL", + /* 348 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 349 */ "signed_literal ::= duration_literal", + /* 350 */ "signed_literal ::= NULL", + /* 351 */ "signed_literal ::= literal_func", + /* 352 */ "signed_literal ::= NK_QUESTION", + /* 353 */ "literal_list ::= signed_literal", + /* 354 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 355 */ "db_name ::= NK_ID", + /* 356 */ "table_name ::= NK_ID", + /* 357 */ "column_name ::= NK_ID", + /* 358 */ "function_name ::= NK_ID", + /* 359 */ "table_alias ::= NK_ID", + /* 360 */ "column_alias ::= NK_ID", + /* 361 */ "user_name ::= NK_ID", + /* 362 */ "topic_name ::= NK_ID", + /* 363 */ "stream_name ::= NK_ID", + /* 364 */ "cgroup_name ::= NK_ID", + /* 365 */ "index_name ::= NK_ID", + /* 366 */ "expr_or_subquery ::= expression", + /* 367 */ "expression ::= literal", + /* 368 */ "expression ::= pseudo_column", + /* 369 */ "expression ::= column_reference", + /* 370 */ "expression ::= function_expression", + /* 371 */ "expression ::= case_when_expression", + /* 372 */ "expression ::= NK_LP expression NK_RP", + /* 373 */ "expression ::= NK_PLUS expr_or_subquery", + /* 374 */ "expression ::= NK_MINUS expr_or_subquery", + /* 375 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 376 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 377 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 378 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 379 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 380 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 381 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 382 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 383 */ "expression_list ::= expr_or_subquery", + /* 384 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 385 */ "column_reference ::= column_name", + /* 386 */ "column_reference ::= table_name NK_DOT column_name", + /* 387 */ "pseudo_column ::= ROWTS", + /* 388 */ "pseudo_column ::= TBNAME", + /* 389 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 390 */ "pseudo_column ::= QSTART", + /* 391 */ "pseudo_column ::= QEND", + /* 392 */ "pseudo_column ::= QDURATION", + /* 393 */ "pseudo_column ::= WSTART", + /* 394 */ "pseudo_column ::= WEND", + /* 395 */ "pseudo_column ::= WDURATION", + /* 396 */ "pseudo_column ::= IROWTS", + /* 397 */ "pseudo_column ::= ISFILLED", + /* 398 */ "pseudo_column ::= QTAGS", + /* 399 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 400 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 401 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 402 */ "function_expression ::= literal_func", + /* 403 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 404 */ "literal_func ::= NOW", + /* 405 */ "noarg_func ::= NOW", + /* 406 */ "noarg_func ::= TODAY", + /* 407 */ "noarg_func ::= TIMEZONE", + /* 408 */ "noarg_func ::= DATABASE", + /* 409 */ "noarg_func ::= CLIENT_VERSION", + /* 410 */ "noarg_func ::= SERVER_VERSION", + /* 411 */ "noarg_func ::= SERVER_STATUS", + /* 412 */ "noarg_func ::= CURRENT_USER", + /* 413 */ "noarg_func ::= USER", + /* 414 */ "star_func ::= COUNT", + /* 415 */ "star_func ::= FIRST", + /* 416 */ "star_func ::= LAST", + /* 417 */ "star_func ::= LAST_ROW", + /* 418 */ "star_func_para_list ::= NK_STAR", + /* 419 */ "star_func_para_list ::= other_para_list", + /* 420 */ "other_para_list ::= star_func_para", + /* 421 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 422 */ "star_func_para ::= expr_or_subquery", + /* 423 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 424 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 425 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 426 */ "when_then_list ::= when_then_expr", + /* 427 */ "when_then_list ::= when_then_list when_then_expr", + /* 428 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 429 */ "case_when_else_opt ::=", + /* 430 */ "case_when_else_opt ::= ELSE common_expression", + /* 431 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 432 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 433 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 434 */ "predicate ::= expr_or_subquery IS NULL", + /* 435 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 436 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 437 */ "compare_op ::= NK_LT", + /* 438 */ "compare_op ::= NK_GT", + /* 439 */ "compare_op ::= NK_LE", + /* 440 */ "compare_op ::= NK_GE", + /* 441 */ "compare_op ::= NK_NE", + /* 442 */ "compare_op ::= NK_EQ", + /* 443 */ "compare_op ::= LIKE", + /* 444 */ "compare_op ::= NOT LIKE", + /* 445 */ "compare_op ::= MATCH", + /* 446 */ "compare_op ::= NMATCH", + /* 447 */ "compare_op ::= CONTAINS", + /* 448 */ "in_op ::= IN", + /* 449 */ "in_op ::= NOT IN", + /* 450 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 451 */ "boolean_value_expression ::= boolean_primary", + /* 452 */ "boolean_value_expression ::= NOT boolean_primary", + /* 453 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 454 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 455 */ "boolean_primary ::= predicate", + /* 456 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 457 */ "common_expression ::= expr_or_subquery", + /* 458 */ "common_expression ::= boolean_value_expression", + /* 459 */ "from_clause_opt ::=", + /* 460 */ "from_clause_opt ::= FROM table_reference_list", + /* 461 */ "table_reference_list ::= table_reference", + /* 462 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 463 */ "table_reference ::= table_primary", + /* 464 */ "table_reference ::= joined_table", + /* 465 */ "table_primary ::= table_name alias_opt", + /* 466 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 467 */ "table_primary ::= subquery alias_opt", + /* 468 */ "table_primary ::= parenthesized_joined_table", + /* 469 */ "alias_opt ::=", + /* 470 */ "alias_opt ::= table_alias", + /* 471 */ "alias_opt ::= AS table_alias", + /* 472 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 473 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 474 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 475 */ "join_type ::=", + /* 476 */ "join_type ::= INNER", + /* 477 */ "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", + /* 478 */ "set_quantifier_opt ::=", + /* 479 */ "set_quantifier_opt ::= DISTINCT", + /* 480 */ "set_quantifier_opt ::= ALL", + /* 481 */ "select_list ::= select_item", + /* 482 */ "select_list ::= select_list NK_COMMA select_item", + /* 483 */ "select_item ::= NK_STAR", + /* 484 */ "select_item ::= common_expression", + /* 485 */ "select_item ::= common_expression column_alias", + /* 486 */ "select_item ::= common_expression AS column_alias", + /* 487 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 488 */ "where_clause_opt ::=", + /* 489 */ "where_clause_opt ::= WHERE search_condition", + /* 490 */ "partition_by_clause_opt ::=", + /* 491 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 492 */ "partition_list ::= partition_item", + /* 493 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 494 */ "partition_item ::= expr_or_subquery", + /* 495 */ "partition_item ::= expr_or_subquery column_alias", + /* 496 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 497 */ "twindow_clause_opt ::=", + /* 498 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 499 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 500 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 501 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 502 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", + /* 503 */ "sliding_opt ::=", + /* 504 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 505 */ "fill_opt ::=", + /* 506 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 507 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 508 */ "fill_mode ::= NONE", + /* 509 */ "fill_mode ::= PREV", + /* 510 */ "fill_mode ::= NULL", + /* 511 */ "fill_mode ::= LINEAR", + /* 512 */ "fill_mode ::= NEXT", + /* 513 */ "group_by_clause_opt ::=", + /* 514 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 515 */ "group_by_list ::= expr_or_subquery", + /* 516 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 517 */ "having_clause_opt ::=", + /* 518 */ "having_clause_opt ::= HAVING search_condition", + /* 519 */ "range_opt ::=", + /* 520 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 521 */ "every_opt ::=", + /* 522 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 523 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 524 */ "query_simple ::= query_specification", + /* 525 */ "query_simple ::= union_query_expression", + /* 526 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 527 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 528 */ "query_simple_or_subquery ::= query_simple", + /* 529 */ "query_simple_or_subquery ::= subquery", + /* 530 */ "query_or_subquery ::= query_expression", + /* 531 */ "query_or_subquery ::= subquery", + /* 532 */ "order_by_clause_opt ::=", + /* 533 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 534 */ "slimit_clause_opt ::=", + /* 535 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 536 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 537 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 538 */ "limit_clause_opt ::=", + /* 539 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 540 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 541 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 542 */ "subquery ::= NK_LP query_expression NK_RP", + /* 543 */ "subquery ::= NK_LP subquery NK_RP", + /* 544 */ "search_condition ::= common_expression", + /* 545 */ "sort_specification_list ::= sort_specification", + /* 546 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 547 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 548 */ "ordering_specification_opt ::=", + /* 549 */ "ordering_specification_opt ::= ASC", + /* 550 */ "ordering_specification_opt ::= DESC", + /* 551 */ "null_ordering_opt ::=", + /* 552 */ "null_ordering_opt ::= NULLS FIRST", + /* 553 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2610,194 +2573,197 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 325: /* cmd */ - case 328: /* literal */ - case 341: /* db_options */ - case 343: /* alter_db_options */ - case 349: /* retention */ - case 350: /* full_table_name */ - case 353: /* table_options */ - case 357: /* alter_table_clause */ - case 358: /* alter_table_options */ - case 361: /* signed_literal */ - case 362: /* create_subtable_clause */ - case 365: /* drop_table_clause */ - case 368: /* column_def */ - case 372: /* duration_literal */ - case 373: /* rollup_func_name */ - case 375: /* col_name */ - case 376: /* db_name_cond_opt */ - case 377: /* like_pattern_opt */ - case 378: /* table_name_cond */ - case 379: /* from_db_opt */ - case 381: /* tag_item */ - case 383: /* index_options */ - case 385: /* sliding_opt */ - case 386: /* sma_stream_opt */ - case 387: /* func */ - case 389: /* query_or_subquery */ - case 392: /* explain_options */ - case 396: /* stream_options */ - case 397: /* subtable_opt */ - case 398: /* expression */ - case 400: /* where_clause_opt */ - case 401: /* signed */ - case 402: /* literal_func */ - case 405: /* expr_or_subquery */ - case 406: /* pseudo_column */ - case 407: /* column_reference */ - case 408: /* function_expression */ - case 409: /* case_when_expression */ - case 414: /* star_func_para */ - case 416: /* case_when_else_opt */ - case 417: /* common_expression */ - case 418: /* when_then_expr */ - case 419: /* predicate */ - case 422: /* in_predicate_value */ - case 423: /* boolean_value_expression */ - case 424: /* boolean_primary */ - case 425: /* from_clause_opt */ - case 426: /* table_reference_list */ - case 427: /* table_reference */ - case 428: /* table_primary */ - case 429: /* joined_table */ - case 431: /* subquery */ - case 432: /* parenthesized_joined_table */ - case 434: /* search_condition */ - case 435: /* query_specification */ - case 439: /* range_opt */ - case 440: /* every_opt */ - case 441: /* fill_opt */ - case 442: /* twindow_clause_opt */ - case 444: /* having_clause_opt */ - case 445: /* select_item */ - case 447: /* partition_item */ - case 450: /* query_expression */ - case 451: /* query_simple */ - case 453: /* slimit_clause_opt */ - case 454: /* limit_clause_opt */ - case 455: /* union_query_expression */ - case 456: /* query_simple_or_subquery */ - case 458: /* sort_specification */ + case 326: /* cmd */ + case 329: /* literal */ + case 342: /* db_options */ + case 344: /* alter_db_options */ + case 350: /* retention */ + case 351: /* full_table_name */ + case 354: /* table_options */ + case 358: /* alter_table_clause */ + case 359: /* alter_table_options */ + case 362: /* signed_literal */ + case 363: /* create_subtable_clause */ + case 366: /* drop_table_clause */ + case 369: /* column_def */ + case 373: /* duration_literal */ + case 374: /* rollup_func_name */ + case 376: /* col_name */ + case 377: /* db_name_cond_opt */ + case 378: /* like_pattern_opt */ + case 379: /* table_name_cond */ + case 380: /* from_db_opt */ + case 382: /* tag_item */ + case 384: /* full_index_name */ + case 385: /* index_options */ + case 388: /* sliding_opt */ + case 389: /* sma_stream_opt */ + case 390: /* func */ + case 392: /* query_or_subquery */ + case 395: /* explain_options */ + case 399: /* stream_options */ + case 401: /* subtable_opt */ + case 402: /* expression */ + case 404: /* where_clause_opt */ + case 405: /* signed */ + case 406: /* literal_func */ + case 409: /* expr_or_subquery */ + case 410: /* pseudo_column */ + case 411: /* column_reference */ + case 412: /* function_expression */ + case 413: /* case_when_expression */ + case 418: /* star_func_para */ + case 420: /* case_when_else_opt */ + case 421: /* common_expression */ + case 422: /* when_then_expr */ + case 423: /* predicate */ + case 426: /* in_predicate_value */ + case 427: /* boolean_value_expression */ + case 428: /* boolean_primary */ + case 429: /* from_clause_opt */ + case 430: /* table_reference_list */ + case 431: /* table_reference */ + case 432: /* table_primary */ + case 433: /* joined_table */ + case 435: /* subquery */ + case 436: /* parenthesized_joined_table */ + case 438: /* search_condition */ + case 439: /* query_specification */ + case 443: /* range_opt */ + case 444: /* every_opt */ + case 445: /* fill_opt */ + case 446: /* twindow_clause_opt */ + case 448: /* having_clause_opt */ + case 449: /* select_item */ + case 451: /* partition_item */ + case 454: /* query_expression */ + case 455: /* query_simple */ + case 457: /* slimit_clause_opt */ + case 458: /* limit_clause_opt */ + case 459: /* union_query_expression */ + case 460: /* query_simple_or_subquery */ + case 462: /* sort_specification */ { - nodesDestroyNode((yypminor->yy600)); + nodesDestroyNode((yypminor->yy602)); } break; - case 326: /* account_options */ - case 327: /* alter_account_options */ - case 329: /* alter_account_option */ - case 344: /* speed_opt */ - case 394: /* bufsize_opt */ + case 327: /* account_options */ + case 328: /* alter_account_options */ + case 330: /* alter_account_option */ + case 345: /* speed_opt */ + case 397: /* bufsize_opt */ { } break; - case 330: /* user_name */ - case 333: /* priv_level */ - case 336: /* db_name */ - case 337: /* topic_name */ - case 338: /* dnode_endpoint */ - case 359: /* column_name */ - case 367: /* table_name */ - case 374: /* function_name */ - case 382: /* column_alias */ - case 388: /* sma_func_name */ - case 390: /* cgroup_name */ - case 395: /* stream_name */ - case 404: /* table_alias */ - case 410: /* star_func */ - case 412: /* noarg_func */ - case 430: /* alias_opt */ + case 331: /* user_name */ + case 334: /* priv_level */ + case 337: /* db_name */ + case 338: /* topic_name */ + case 339: /* dnode_endpoint */ + case 360: /* column_name */ + case 368: /* table_name */ + case 375: /* function_name */ + case 383: /* column_alias */ + case 386: /* index_name */ + case 391: /* sma_func_name */ + case 393: /* cgroup_name */ + case 398: /* stream_name */ + case 408: /* table_alias */ + case 414: /* star_func */ + case 416: /* noarg_func */ + case 434: /* alias_opt */ { } break; - case 331: /* sysinfo_opt */ + case 332: /* sysinfo_opt */ { } break; - case 332: /* privileges */ - case 334: /* priv_type_list */ - case 335: /* priv_type */ + case 333: /* privileges */ + case 335: /* priv_type_list */ + case 336: /* priv_type */ { } break; - case 339: /* force_opt */ - case 340: /* not_exists_opt */ - case 342: /* exists_opt */ - case 391: /* analyze_opt */ - case 393: /* agg_func_opt */ - case 436: /* set_quantifier_opt */ + case 340: /* force_opt */ + case 341: /* not_exists_opt */ + case 343: /* exists_opt */ + case 394: /* analyze_opt */ + case 396: /* agg_func_opt */ + case 440: /* set_quantifier_opt */ { } break; - case 345: /* integer_list */ - case 346: /* variable_list */ - case 347: /* retention_list */ - case 351: /* column_def_list */ - case 352: /* tags_def_opt */ - case 354: /* multi_create_clause */ - case 355: /* tags_def */ - case 356: /* multi_drop_clause */ - case 363: /* specific_cols_opt */ - case 364: /* expression_list */ - case 366: /* col_name_list */ - case 369: /* duration_list */ - case 370: /* rollup_func_list */ - case 380: /* tag_list_opt */ - case 384: /* func_list */ - case 399: /* dnode_list */ - case 403: /* literal_list */ - case 411: /* star_func_para_list */ - case 413: /* other_para_list */ - case 415: /* when_then_list */ - case 437: /* select_list */ - case 438: /* partition_by_clause_opt */ - case 443: /* group_by_clause_opt */ - case 446: /* partition_list */ - case 449: /* group_by_list */ - case 452: /* order_by_clause_opt */ - case 457: /* sort_specification_list */ + case 346: /* integer_list */ + case 347: /* variable_list */ + case 348: /* retention_list */ + case 352: /* column_def_list */ + case 353: /* tags_def_opt */ + case 355: /* multi_create_clause */ + case 356: /* tags_def */ + case 357: /* multi_drop_clause */ + case 364: /* specific_cols_opt */ + case 365: /* expression_list */ + case 367: /* col_name_list */ + case 370: /* duration_list */ + case 371: /* rollup_func_list */ + case 381: /* tag_list_opt */ + case 387: /* func_list */ + case 400: /* col_list_opt */ + case 403: /* dnode_list */ + case 407: /* literal_list */ + case 415: /* star_func_para_list */ + case 417: /* other_para_list */ + case 419: /* when_then_list */ + case 441: /* select_list */ + case 442: /* partition_by_clause_opt */ + case 447: /* group_by_clause_opt */ + case 450: /* partition_list */ + case 453: /* group_by_list */ + case 456: /* order_by_clause_opt */ + case 461: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy601)); + nodesDestroyList((yypminor->yy874)); } break; - case 348: /* alter_db_option */ - case 371: /* alter_table_option */ + case 349: /* alter_db_option */ + case 372: /* alter_table_option */ { } break; - case 360: /* type_name */ + case 361: /* type_name */ { } break; - case 420: /* compare_op */ - case 421: /* in_op */ + case 424: /* compare_op */ + case 425: /* in_op */ { } break; - case 433: /* join_type */ + case 437: /* join_type */ { } break; - case 448: /* fill_mode */ + case 452: /* fill_mode */ { } break; - case 459: /* ordering_specification_opt */ + case 463: /* ordering_specification_opt */ { } break; - case 460: /* null_ordering_opt */ + case 464: /* null_ordering_opt */ { } @@ -3096,553 +3062,560 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { - { 325, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 325, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 326, 0 }, /* (2) account_options ::= */ - { 326, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 326, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 326, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 326, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 326, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 326, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 326, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 326, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 326, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 327, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 327, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 329, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 329, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 329, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 329, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 329, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 329, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 329, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 329, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 329, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 329, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 325, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ - { 325, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 325, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - { 325, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - { 325, -3 }, /* (28) cmd ::= DROP USER user_name */ - { 331, 0 }, /* (29) sysinfo_opt ::= */ - { 331, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ - { 325, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 325, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 332, -1 }, /* (33) privileges ::= ALL */ - { 332, -1 }, /* (34) privileges ::= priv_type_list */ - { 332, -1 }, /* (35) privileges ::= SUBSCRIBE */ - { 334, -1 }, /* (36) priv_type_list ::= priv_type */ - { 334, -3 }, /* (37) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 335, -1 }, /* (38) priv_type ::= READ */ - { 335, -1 }, /* (39) priv_type ::= WRITE */ - { 333, -3 }, /* (40) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 333, -3 }, /* (41) priv_level ::= db_name NK_DOT NK_STAR */ - { 333, -1 }, /* (42) priv_level ::= topic_name */ - { 325, -3 }, /* (43) cmd ::= CREATE DNODE dnode_endpoint */ - { 325, -5 }, /* (44) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - { 325, -4 }, /* (45) cmd ::= DROP DNODE NK_INTEGER force_opt */ - { 325, -4 }, /* (46) cmd ::= DROP DNODE dnode_endpoint force_opt */ - { 325, -4 }, /* (47) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 325, -5 }, /* (48) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 325, -4 }, /* (49) cmd ::= ALTER ALL DNODES NK_STRING */ - { 325, -5 }, /* (50) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 338, -1 }, /* (51) dnode_endpoint ::= NK_STRING */ - { 338, -1 }, /* (52) dnode_endpoint ::= NK_ID */ - { 338, -1 }, /* (53) dnode_endpoint ::= NK_IPTOKEN */ - { 339, 0 }, /* (54) force_opt ::= */ - { 339, -1 }, /* (55) force_opt ::= FORCE */ - { 325, -3 }, /* (56) cmd ::= ALTER LOCAL NK_STRING */ - { 325, -4 }, /* (57) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 325, -5 }, /* (58) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 325, -5 }, /* (59) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 325, -5 }, /* (60) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 325, -5 }, /* (61) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 325, -5 }, /* (62) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 325, -5 }, /* (63) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 325, -5 }, /* (64) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 325, -5 }, /* (65) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 325, -5 }, /* (66) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 325, -4 }, /* (67) cmd ::= DROP DATABASE exists_opt db_name */ - { 325, -2 }, /* (68) cmd ::= USE db_name */ - { 325, -4 }, /* (69) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 325, -3 }, /* (70) cmd ::= FLUSH DATABASE db_name */ - { 325, -4 }, /* (71) cmd ::= TRIM DATABASE db_name speed_opt */ - { 325, -3 }, /* (72) cmd ::= COMPACT DATABASE db_name */ - { 340, -3 }, /* (73) not_exists_opt ::= IF NOT EXISTS */ - { 340, 0 }, /* (74) not_exists_opt ::= */ - { 342, -2 }, /* (75) exists_opt ::= IF EXISTS */ - { 342, 0 }, /* (76) exists_opt ::= */ - { 341, 0 }, /* (77) db_options ::= */ - { 341, -3 }, /* (78) db_options ::= db_options BUFFER NK_INTEGER */ - { 341, -3 }, /* (79) db_options ::= db_options CACHEMODEL NK_STRING */ - { 341, -3 }, /* (80) db_options ::= db_options CACHESIZE NK_INTEGER */ - { 341, -3 }, /* (81) db_options ::= db_options COMP NK_INTEGER */ - { 341, -3 }, /* (82) db_options ::= db_options DURATION NK_INTEGER */ - { 341, -3 }, /* (83) db_options ::= db_options DURATION NK_VARIABLE */ - { 341, -3 }, /* (84) db_options ::= db_options MAXROWS NK_INTEGER */ - { 341, -3 }, /* (85) db_options ::= db_options MINROWS NK_INTEGER */ - { 341, -3 }, /* (86) db_options ::= db_options KEEP integer_list */ - { 341, -3 }, /* (87) db_options ::= db_options KEEP variable_list */ - { 341, -3 }, /* (88) db_options ::= db_options PAGES NK_INTEGER */ - { 341, -3 }, /* (89) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 341, -3 }, /* (90) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ - { 341, -3 }, /* (91) db_options ::= db_options PRECISION NK_STRING */ - { 341, -3 }, /* (92) db_options ::= db_options REPLICA NK_INTEGER */ - { 341, -3 }, /* (93) db_options ::= db_options VGROUPS NK_INTEGER */ - { 341, -3 }, /* (94) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 341, -3 }, /* (95) db_options ::= db_options RETENTIONS retention_list */ - { 341, -3 }, /* (96) db_options ::= db_options SCHEMALESS NK_INTEGER */ - { 341, -3 }, /* (97) db_options ::= db_options WAL_LEVEL NK_INTEGER */ - { 341, -3 }, /* (98) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ - { 341, -3 }, /* (99) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ - { 341, -4 }, /* (100) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - { 341, -3 }, /* (101) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ - { 341, -4 }, /* (102) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - { 341, -3 }, /* (103) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ - { 341, -3 }, /* (104) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ - { 341, -3 }, /* (105) db_options ::= db_options STT_TRIGGER NK_INTEGER */ - { 341, -3 }, /* (106) db_options ::= db_options TABLE_PREFIX NK_INTEGER */ - { 341, -3 }, /* (107) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ - { 343, -1 }, /* (108) alter_db_options ::= alter_db_option */ - { 343, -2 }, /* (109) alter_db_options ::= alter_db_options alter_db_option */ - { 348, -2 }, /* (110) alter_db_option ::= BUFFER NK_INTEGER */ - { 348, -2 }, /* (111) alter_db_option ::= CACHEMODEL NK_STRING */ - { 348, -2 }, /* (112) alter_db_option ::= CACHESIZE NK_INTEGER */ - { 348, -2 }, /* (113) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ - { 348, -2 }, /* (114) alter_db_option ::= KEEP integer_list */ - { 348, -2 }, /* (115) alter_db_option ::= KEEP variable_list */ - { 348, -2 }, /* (116) alter_db_option ::= PAGES NK_INTEGER */ - { 348, -2 }, /* (117) alter_db_option ::= REPLICA NK_INTEGER */ - { 348, -2 }, /* (118) alter_db_option ::= WAL_LEVEL NK_INTEGER */ - { 348, -2 }, /* (119) alter_db_option ::= STT_TRIGGER NK_INTEGER */ - { 345, -1 }, /* (120) integer_list ::= NK_INTEGER */ - { 345, -3 }, /* (121) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 346, -1 }, /* (122) variable_list ::= NK_VARIABLE */ - { 346, -3 }, /* (123) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 347, -1 }, /* (124) retention_list ::= retention */ - { 347, -3 }, /* (125) retention_list ::= retention_list NK_COMMA retention */ - { 349, -3 }, /* (126) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 344, 0 }, /* (127) speed_opt ::= */ - { 344, -2 }, /* (128) speed_opt ::= MAX_SPEED NK_INTEGER */ - { 325, -9 }, /* (129) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 325, -3 }, /* (130) cmd ::= CREATE TABLE multi_create_clause */ - { 325, -9 }, /* (131) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 325, -3 }, /* (132) cmd ::= DROP TABLE multi_drop_clause */ - { 325, -4 }, /* (133) cmd ::= DROP STABLE exists_opt full_table_name */ - { 325, -3 }, /* (134) cmd ::= ALTER TABLE alter_table_clause */ - { 325, -3 }, /* (135) cmd ::= ALTER STABLE alter_table_clause */ - { 357, -2 }, /* (136) alter_table_clause ::= full_table_name alter_table_options */ - { 357, -5 }, /* (137) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 357, -4 }, /* (138) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 357, -5 }, /* (139) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 357, -5 }, /* (140) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 357, -5 }, /* (141) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 357, -4 }, /* (142) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 357, -5 }, /* (143) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 357, -5 }, /* (144) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 357, -6 }, /* (145) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 354, -1 }, /* (146) multi_create_clause ::= create_subtable_clause */ - { 354, -2 }, /* (147) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 362, -10 }, /* (148) 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 */ - { 356, -1 }, /* (149) multi_drop_clause ::= drop_table_clause */ - { 356, -2 }, /* (150) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 365, -2 }, /* (151) drop_table_clause ::= exists_opt full_table_name */ - { 363, 0 }, /* (152) specific_cols_opt ::= */ - { 363, -3 }, /* (153) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - { 350, -1 }, /* (154) full_table_name ::= table_name */ - { 350, -3 }, /* (155) full_table_name ::= db_name NK_DOT table_name */ - { 351, -1 }, /* (156) column_def_list ::= column_def */ - { 351, -3 }, /* (157) column_def_list ::= column_def_list NK_COMMA column_def */ - { 368, -2 }, /* (158) column_def ::= column_name type_name */ - { 368, -4 }, /* (159) column_def ::= column_name type_name COMMENT NK_STRING */ - { 360, -1 }, /* (160) type_name ::= BOOL */ - { 360, -1 }, /* (161) type_name ::= TINYINT */ - { 360, -1 }, /* (162) type_name ::= SMALLINT */ - { 360, -1 }, /* (163) type_name ::= INT */ - { 360, -1 }, /* (164) type_name ::= INTEGER */ - { 360, -1 }, /* (165) type_name ::= BIGINT */ - { 360, -1 }, /* (166) type_name ::= FLOAT */ - { 360, -1 }, /* (167) type_name ::= DOUBLE */ - { 360, -4 }, /* (168) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 360, -1 }, /* (169) type_name ::= TIMESTAMP */ - { 360, -4 }, /* (170) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 360, -2 }, /* (171) type_name ::= TINYINT UNSIGNED */ - { 360, -2 }, /* (172) type_name ::= SMALLINT UNSIGNED */ - { 360, -2 }, /* (173) type_name ::= INT UNSIGNED */ - { 360, -2 }, /* (174) type_name ::= BIGINT UNSIGNED */ - { 360, -1 }, /* (175) type_name ::= JSON */ - { 360, -4 }, /* (176) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 360, -1 }, /* (177) type_name ::= MEDIUMBLOB */ - { 360, -1 }, /* (178) type_name ::= BLOB */ - { 360, -4 }, /* (179) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 360, -1 }, /* (180) type_name ::= DECIMAL */ - { 360, -4 }, /* (181) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 360, -6 }, /* (182) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 352, 0 }, /* (183) tags_def_opt ::= */ - { 352, -1 }, /* (184) tags_def_opt ::= tags_def */ - { 355, -4 }, /* (185) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 353, 0 }, /* (186) table_options ::= */ - { 353, -3 }, /* (187) table_options ::= table_options COMMENT NK_STRING */ - { 353, -3 }, /* (188) table_options ::= table_options MAX_DELAY duration_list */ - { 353, -3 }, /* (189) table_options ::= table_options WATERMARK duration_list */ - { 353, -5 }, /* (190) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - { 353, -3 }, /* (191) table_options ::= table_options TTL NK_INTEGER */ - { 353, -5 }, /* (192) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 353, -3 }, /* (193) table_options ::= table_options DELETE_MARK duration_list */ - { 358, -1 }, /* (194) alter_table_options ::= alter_table_option */ - { 358, -2 }, /* (195) alter_table_options ::= alter_table_options alter_table_option */ - { 371, -2 }, /* (196) alter_table_option ::= COMMENT NK_STRING */ - { 371, -2 }, /* (197) alter_table_option ::= TTL NK_INTEGER */ - { 369, -1 }, /* (198) duration_list ::= duration_literal */ - { 369, -3 }, /* (199) duration_list ::= duration_list NK_COMMA duration_literal */ - { 370, -1 }, /* (200) rollup_func_list ::= rollup_func_name */ - { 370, -3 }, /* (201) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - { 373, -1 }, /* (202) rollup_func_name ::= function_name */ - { 373, -1 }, /* (203) rollup_func_name ::= FIRST */ - { 373, -1 }, /* (204) rollup_func_name ::= LAST */ - { 366, -1 }, /* (205) col_name_list ::= col_name */ - { 366, -3 }, /* (206) col_name_list ::= col_name_list NK_COMMA col_name */ - { 375, -1 }, /* (207) col_name ::= column_name */ - { 325, -2 }, /* (208) cmd ::= SHOW DNODES */ - { 325, -2 }, /* (209) cmd ::= SHOW USERS */ - { 325, -3 }, /* (210) cmd ::= SHOW USER PRIVILEGES */ - { 325, -2 }, /* (211) cmd ::= SHOW DATABASES */ - { 325, -4 }, /* (212) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 325, -4 }, /* (213) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 325, -3 }, /* (214) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 325, -2 }, /* (215) cmd ::= SHOW MNODES */ - { 325, -2 }, /* (216) cmd ::= SHOW QNODES */ - { 325, -2 }, /* (217) cmd ::= SHOW FUNCTIONS */ - { 325, -5 }, /* (218) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 325, -2 }, /* (219) cmd ::= SHOW STREAMS */ - { 325, -2 }, /* (220) cmd ::= SHOW ACCOUNTS */ - { 325, -2 }, /* (221) cmd ::= SHOW APPS */ - { 325, -2 }, /* (222) cmd ::= SHOW CONNECTIONS */ - { 325, -2 }, /* (223) cmd ::= SHOW LICENCES */ - { 325, -2 }, /* (224) cmd ::= SHOW GRANTS */ - { 325, -4 }, /* (225) cmd ::= SHOW CREATE DATABASE db_name */ - { 325, -4 }, /* (226) cmd ::= SHOW CREATE TABLE full_table_name */ - { 325, -4 }, /* (227) cmd ::= SHOW CREATE STABLE full_table_name */ - { 325, -2 }, /* (228) cmd ::= SHOW QUERIES */ - { 325, -2 }, /* (229) cmd ::= SHOW SCORES */ - { 325, -2 }, /* (230) cmd ::= SHOW TOPICS */ - { 325, -2 }, /* (231) cmd ::= SHOW VARIABLES */ - { 325, -3 }, /* (232) cmd ::= SHOW CLUSTER VARIABLES */ - { 325, -3 }, /* (233) cmd ::= SHOW LOCAL VARIABLES */ - { 325, -5 }, /* (234) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ - { 325, -2 }, /* (235) cmd ::= SHOW BNODES */ - { 325, -2 }, /* (236) cmd ::= SHOW SNODES */ - { 325, -2 }, /* (237) cmd ::= SHOW CLUSTER */ - { 325, -2 }, /* (238) cmd ::= SHOW TRANSACTIONS */ - { 325, -4 }, /* (239) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - { 325, -2 }, /* (240) cmd ::= SHOW CONSUMERS */ - { 325, -2 }, /* (241) cmd ::= SHOW SUBSCRIPTIONS */ - { 325, -5 }, /* (242) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - { 325, -7 }, /* (243) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ - { 325, -3 }, /* (244) cmd ::= SHOW VNODES NK_INTEGER */ - { 325, -3 }, /* (245) cmd ::= SHOW VNODES NK_STRING */ - { 376, 0 }, /* (246) db_name_cond_opt ::= */ - { 376, -2 }, /* (247) db_name_cond_opt ::= db_name NK_DOT */ - { 377, 0 }, /* (248) like_pattern_opt ::= */ - { 377, -2 }, /* (249) like_pattern_opt ::= LIKE NK_STRING */ - { 378, -1 }, /* (250) table_name_cond ::= table_name */ - { 379, 0 }, /* (251) from_db_opt ::= */ - { 379, -2 }, /* (252) from_db_opt ::= FROM db_name */ - { 380, 0 }, /* (253) tag_list_opt ::= */ - { 380, -1 }, /* (254) tag_list_opt ::= tag_item */ - { 380, -3 }, /* (255) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ - { 381, -1 }, /* (256) tag_item ::= TBNAME */ - { 381, -1 }, /* (257) tag_item ::= QTAGS */ - { 381, -1 }, /* (258) tag_item ::= column_name */ - { 381, -2 }, /* (259) tag_item ::= column_name column_alias */ - { 381, -3 }, /* (260) tag_item ::= column_name AS column_alias */ - { 325, -8 }, /* (261) cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ - { 325, -9 }, /* (262) cmd ::= CREATE INDEX not_exists_opt full_table_name ON full_table_name NK_LP col_name_list NK_RP */ - { 325, -4 }, /* (263) cmd ::= DROP INDEX exists_opt full_table_name */ - { 383, -10 }, /* (264) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - { 383, -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 */ - { 384, -1 }, /* (266) func_list ::= func */ - { 384, -3 }, /* (267) func_list ::= func_list NK_COMMA func */ - { 387, -4 }, /* (268) func ::= sma_func_name NK_LP expression_list NK_RP */ - { 388, -1 }, /* (269) sma_func_name ::= function_name */ - { 388, -1 }, /* (270) sma_func_name ::= COUNT */ - { 388, -1 }, /* (271) sma_func_name ::= FIRST */ - { 388, -1 }, /* (272) sma_func_name ::= LAST */ - { 388, -1 }, /* (273) sma_func_name ::= LAST_ROW */ - { 386, 0 }, /* (274) sma_stream_opt ::= */ - { 386, -3 }, /* (275) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - { 386, -3 }, /* (276) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - { 386, -3 }, /* (277) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - { 325, -6 }, /* (278) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - { 325, -7 }, /* (279) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 325, -9 }, /* (280) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ - { 325, -7 }, /* (281) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 325, -9 }, /* (282) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ - { 325, -4 }, /* (283) cmd ::= DROP TOPIC exists_opt topic_name */ - { 325, -7 }, /* (284) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 325, -2 }, /* (285) cmd ::= DESC full_table_name */ - { 325, -2 }, /* (286) cmd ::= DESCRIBE full_table_name */ - { 325, -3 }, /* (287) cmd ::= RESET QUERY CACHE */ - { 325, -4 }, /* (288) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - { 391, 0 }, /* (289) analyze_opt ::= */ - { 391, -1 }, /* (290) analyze_opt ::= ANALYZE */ - { 392, 0 }, /* (291) explain_options ::= */ - { 392, -3 }, /* (292) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 392, -3 }, /* (293) explain_options ::= explain_options RATIO NK_FLOAT */ - { 325, -10 }, /* (294) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 325, -4 }, /* (295) cmd ::= DROP FUNCTION exists_opt function_name */ - { 393, 0 }, /* (296) agg_func_opt ::= */ - { 393, -1 }, /* (297) agg_func_opt ::= AGGREGATE */ - { 394, 0 }, /* (298) bufsize_opt ::= */ - { 394, -2 }, /* (299) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 325, -11 }, /* (300) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery */ - { 325, -4 }, /* (301) cmd ::= DROP STREAM exists_opt stream_name */ - { 396, 0 }, /* (302) stream_options ::= */ - { 396, -3 }, /* (303) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 396, -3 }, /* (304) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 396, -4 }, /* (305) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 396, -3 }, /* (306) stream_options ::= stream_options WATERMARK duration_literal */ - { 396, -4 }, /* (307) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - { 396, -3 }, /* (308) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - { 397, 0 }, /* (309) subtable_opt ::= */ - { 397, -4 }, /* (310) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - { 325, -3 }, /* (311) cmd ::= KILL CONNECTION NK_INTEGER */ - { 325, -3 }, /* (312) cmd ::= KILL QUERY NK_STRING */ - { 325, -3 }, /* (313) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 325, -2 }, /* (314) cmd ::= BALANCE VGROUP */ - { 325, -4 }, /* (315) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 325, -4 }, /* (316) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 325, -3 }, /* (317) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 399, -2 }, /* (318) dnode_list ::= DNODE NK_INTEGER */ - { 399, -3 }, /* (319) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 325, -4 }, /* (320) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 325, -1 }, /* (321) cmd ::= query_or_subquery */ - { 325, -7 }, /* (322) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - { 325, -4 }, /* (323) cmd ::= INSERT INTO full_table_name query_or_subquery */ - { 328, -1 }, /* (324) literal ::= NK_INTEGER */ - { 328, -1 }, /* (325) literal ::= NK_FLOAT */ - { 328, -1 }, /* (326) literal ::= NK_STRING */ - { 328, -1 }, /* (327) literal ::= NK_BOOL */ - { 328, -2 }, /* (328) literal ::= TIMESTAMP NK_STRING */ - { 328, -1 }, /* (329) literal ::= duration_literal */ - { 328, -1 }, /* (330) literal ::= NULL */ - { 328, -1 }, /* (331) literal ::= NK_QUESTION */ - { 372, -1 }, /* (332) duration_literal ::= NK_VARIABLE */ - { 401, -1 }, /* (333) signed ::= NK_INTEGER */ - { 401, -2 }, /* (334) signed ::= NK_PLUS NK_INTEGER */ - { 401, -2 }, /* (335) signed ::= NK_MINUS NK_INTEGER */ - { 401, -1 }, /* (336) signed ::= NK_FLOAT */ - { 401, -2 }, /* (337) signed ::= NK_PLUS NK_FLOAT */ - { 401, -2 }, /* (338) signed ::= NK_MINUS NK_FLOAT */ - { 361, -1 }, /* (339) signed_literal ::= signed */ - { 361, -1 }, /* (340) signed_literal ::= NK_STRING */ - { 361, -1 }, /* (341) signed_literal ::= NK_BOOL */ - { 361, -2 }, /* (342) signed_literal ::= TIMESTAMP NK_STRING */ - { 361, -1 }, /* (343) signed_literal ::= duration_literal */ - { 361, -1 }, /* (344) signed_literal ::= NULL */ - { 361, -1 }, /* (345) signed_literal ::= literal_func */ - { 361, -1 }, /* (346) signed_literal ::= NK_QUESTION */ - { 403, -1 }, /* (347) literal_list ::= signed_literal */ - { 403, -3 }, /* (348) literal_list ::= literal_list NK_COMMA signed_literal */ - { 336, -1 }, /* (349) db_name ::= NK_ID */ - { 367, -1 }, /* (350) table_name ::= NK_ID */ - { 359, -1 }, /* (351) column_name ::= NK_ID */ - { 374, -1 }, /* (352) function_name ::= NK_ID */ - { 404, -1 }, /* (353) table_alias ::= NK_ID */ - { 382, -1 }, /* (354) column_alias ::= NK_ID */ - { 330, -1 }, /* (355) user_name ::= NK_ID */ - { 337, -1 }, /* (356) topic_name ::= NK_ID */ - { 395, -1 }, /* (357) stream_name ::= NK_ID */ - { 390, -1 }, /* (358) cgroup_name ::= NK_ID */ - { 405, -1 }, /* (359) expr_or_subquery ::= expression */ - { 398, -1 }, /* (360) expression ::= literal */ - { 398, -1 }, /* (361) expression ::= pseudo_column */ - { 398, -1 }, /* (362) expression ::= column_reference */ - { 398, -1 }, /* (363) expression ::= function_expression */ - { 398, -1 }, /* (364) expression ::= case_when_expression */ - { 398, -3 }, /* (365) expression ::= NK_LP expression NK_RP */ - { 398, -2 }, /* (366) expression ::= NK_PLUS expr_or_subquery */ - { 398, -2 }, /* (367) expression ::= NK_MINUS expr_or_subquery */ - { 398, -3 }, /* (368) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - { 398, -3 }, /* (369) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - { 398, -3 }, /* (370) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - { 398, -3 }, /* (371) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - { 398, -3 }, /* (372) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - { 398, -3 }, /* (373) expression ::= column_reference NK_ARROW NK_STRING */ - { 398, -3 }, /* (374) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - { 398, -3 }, /* (375) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - { 364, -1 }, /* (376) expression_list ::= expr_or_subquery */ - { 364, -3 }, /* (377) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - { 407, -1 }, /* (378) column_reference ::= column_name */ - { 407, -3 }, /* (379) column_reference ::= table_name NK_DOT column_name */ - { 406, -1 }, /* (380) pseudo_column ::= ROWTS */ - { 406, -1 }, /* (381) pseudo_column ::= TBNAME */ - { 406, -3 }, /* (382) pseudo_column ::= table_name NK_DOT TBNAME */ - { 406, -1 }, /* (383) pseudo_column ::= QSTART */ - { 406, -1 }, /* (384) pseudo_column ::= QEND */ - { 406, -1 }, /* (385) pseudo_column ::= QDURATION */ - { 406, -1 }, /* (386) pseudo_column ::= WSTART */ - { 406, -1 }, /* (387) pseudo_column ::= WEND */ - { 406, -1 }, /* (388) pseudo_column ::= WDURATION */ - { 406, -1 }, /* (389) pseudo_column ::= IROWTS */ - { 406, -1 }, /* (390) pseudo_column ::= ISFILLED */ - { 406, -1 }, /* (391) pseudo_column ::= QTAGS */ - { 408, -4 }, /* (392) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 408, -4 }, /* (393) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 408, -6 }, /* (394) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - { 408, -1 }, /* (395) function_expression ::= literal_func */ - { 402, -3 }, /* (396) literal_func ::= noarg_func NK_LP NK_RP */ - { 402, -1 }, /* (397) literal_func ::= NOW */ - { 412, -1 }, /* (398) noarg_func ::= NOW */ - { 412, -1 }, /* (399) noarg_func ::= TODAY */ - { 412, -1 }, /* (400) noarg_func ::= TIMEZONE */ - { 412, -1 }, /* (401) noarg_func ::= DATABASE */ - { 412, -1 }, /* (402) noarg_func ::= CLIENT_VERSION */ - { 412, -1 }, /* (403) noarg_func ::= SERVER_VERSION */ - { 412, -1 }, /* (404) noarg_func ::= SERVER_STATUS */ - { 412, -1 }, /* (405) noarg_func ::= CURRENT_USER */ - { 412, -1 }, /* (406) noarg_func ::= USER */ - { 410, -1 }, /* (407) star_func ::= COUNT */ - { 410, -1 }, /* (408) star_func ::= FIRST */ - { 410, -1 }, /* (409) star_func ::= LAST */ - { 410, -1 }, /* (410) star_func ::= LAST_ROW */ - { 411, -1 }, /* (411) star_func_para_list ::= NK_STAR */ - { 411, -1 }, /* (412) star_func_para_list ::= other_para_list */ - { 413, -1 }, /* (413) other_para_list ::= star_func_para */ - { 413, -3 }, /* (414) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 414, -1 }, /* (415) star_func_para ::= expr_or_subquery */ - { 414, -3 }, /* (416) star_func_para ::= table_name NK_DOT NK_STAR */ - { 409, -4 }, /* (417) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - { 409, -5 }, /* (418) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - { 415, -1 }, /* (419) when_then_list ::= when_then_expr */ - { 415, -2 }, /* (420) when_then_list ::= when_then_list when_then_expr */ - { 418, -4 }, /* (421) when_then_expr ::= WHEN common_expression THEN common_expression */ - { 416, 0 }, /* (422) case_when_else_opt ::= */ - { 416, -2 }, /* (423) case_when_else_opt ::= ELSE common_expression */ - { 419, -3 }, /* (424) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - { 419, -5 }, /* (425) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - { 419, -6 }, /* (426) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - { 419, -3 }, /* (427) predicate ::= expr_or_subquery IS NULL */ - { 419, -4 }, /* (428) predicate ::= expr_or_subquery IS NOT NULL */ - { 419, -3 }, /* (429) predicate ::= expr_or_subquery in_op in_predicate_value */ - { 420, -1 }, /* (430) compare_op ::= NK_LT */ - { 420, -1 }, /* (431) compare_op ::= NK_GT */ - { 420, -1 }, /* (432) compare_op ::= NK_LE */ - { 420, -1 }, /* (433) compare_op ::= NK_GE */ - { 420, -1 }, /* (434) compare_op ::= NK_NE */ - { 420, -1 }, /* (435) compare_op ::= NK_EQ */ - { 420, -1 }, /* (436) compare_op ::= LIKE */ - { 420, -2 }, /* (437) compare_op ::= NOT LIKE */ - { 420, -1 }, /* (438) compare_op ::= MATCH */ - { 420, -1 }, /* (439) compare_op ::= NMATCH */ - { 420, -1 }, /* (440) compare_op ::= CONTAINS */ - { 421, -1 }, /* (441) in_op ::= IN */ - { 421, -2 }, /* (442) in_op ::= NOT IN */ - { 422, -3 }, /* (443) in_predicate_value ::= NK_LP literal_list NK_RP */ - { 423, -1 }, /* (444) boolean_value_expression ::= boolean_primary */ - { 423, -2 }, /* (445) boolean_value_expression ::= NOT boolean_primary */ - { 423, -3 }, /* (446) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 423, -3 }, /* (447) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 424, -1 }, /* (448) boolean_primary ::= predicate */ - { 424, -3 }, /* (449) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 417, -1 }, /* (450) common_expression ::= expr_or_subquery */ - { 417, -1 }, /* (451) common_expression ::= boolean_value_expression */ - { 425, 0 }, /* (452) from_clause_opt ::= */ - { 425, -2 }, /* (453) from_clause_opt ::= FROM table_reference_list */ - { 426, -1 }, /* (454) table_reference_list ::= table_reference */ - { 426, -3 }, /* (455) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 427, -1 }, /* (456) table_reference ::= table_primary */ - { 427, -1 }, /* (457) table_reference ::= joined_table */ - { 428, -2 }, /* (458) table_primary ::= table_name alias_opt */ - { 428, -4 }, /* (459) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 428, -2 }, /* (460) table_primary ::= subquery alias_opt */ - { 428, -1 }, /* (461) table_primary ::= parenthesized_joined_table */ - { 430, 0 }, /* (462) alias_opt ::= */ - { 430, -1 }, /* (463) alias_opt ::= table_alias */ - { 430, -2 }, /* (464) alias_opt ::= AS table_alias */ - { 432, -3 }, /* (465) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 432, -3 }, /* (466) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 429, -6 }, /* (467) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 433, 0 }, /* (468) join_type ::= */ - { 433, -1 }, /* (469) join_type ::= INNER */ - { 435, -12 }, /* (470) 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 */ - { 436, 0 }, /* (471) set_quantifier_opt ::= */ - { 436, -1 }, /* (472) set_quantifier_opt ::= DISTINCT */ - { 436, -1 }, /* (473) set_quantifier_opt ::= ALL */ - { 437, -1 }, /* (474) select_list ::= select_item */ - { 437, -3 }, /* (475) select_list ::= select_list NK_COMMA select_item */ - { 445, -1 }, /* (476) select_item ::= NK_STAR */ - { 445, -1 }, /* (477) select_item ::= common_expression */ - { 445, -2 }, /* (478) select_item ::= common_expression column_alias */ - { 445, -3 }, /* (479) select_item ::= common_expression AS column_alias */ - { 445, -3 }, /* (480) select_item ::= table_name NK_DOT NK_STAR */ - { 400, 0 }, /* (481) where_clause_opt ::= */ - { 400, -2 }, /* (482) where_clause_opt ::= WHERE search_condition */ - { 438, 0 }, /* (483) partition_by_clause_opt ::= */ - { 438, -3 }, /* (484) partition_by_clause_opt ::= PARTITION BY partition_list */ - { 446, -1 }, /* (485) partition_list ::= partition_item */ - { 446, -3 }, /* (486) partition_list ::= partition_list NK_COMMA partition_item */ - { 447, -1 }, /* (487) partition_item ::= expr_or_subquery */ - { 447, -2 }, /* (488) partition_item ::= expr_or_subquery column_alias */ - { 447, -3 }, /* (489) partition_item ::= expr_or_subquery AS column_alias */ - { 442, 0 }, /* (490) twindow_clause_opt ::= */ - { 442, -6 }, /* (491) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 442, -4 }, /* (492) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - { 442, -6 }, /* (493) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 442, -8 }, /* (494) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 442, -7 }, /* (495) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ - { 385, 0 }, /* (496) sliding_opt ::= */ - { 385, -4 }, /* (497) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 441, 0 }, /* (498) fill_opt ::= */ - { 441, -4 }, /* (499) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 441, -6 }, /* (500) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 448, -1 }, /* (501) fill_mode ::= NONE */ - { 448, -1 }, /* (502) fill_mode ::= PREV */ - { 448, -1 }, /* (503) fill_mode ::= NULL */ - { 448, -1 }, /* (504) fill_mode ::= LINEAR */ - { 448, -1 }, /* (505) fill_mode ::= NEXT */ - { 443, 0 }, /* (506) group_by_clause_opt ::= */ - { 443, -3 }, /* (507) group_by_clause_opt ::= GROUP BY group_by_list */ - { 449, -1 }, /* (508) group_by_list ::= expr_or_subquery */ - { 449, -3 }, /* (509) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - { 444, 0 }, /* (510) having_clause_opt ::= */ - { 444, -2 }, /* (511) having_clause_opt ::= HAVING search_condition */ - { 439, 0 }, /* (512) range_opt ::= */ - { 439, -6 }, /* (513) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - { 440, 0 }, /* (514) every_opt ::= */ - { 440, -4 }, /* (515) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 450, -4 }, /* (516) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 451, -1 }, /* (517) query_simple ::= query_specification */ - { 451, -1 }, /* (518) query_simple ::= union_query_expression */ - { 455, -4 }, /* (519) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - { 455, -3 }, /* (520) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - { 456, -1 }, /* (521) query_simple_or_subquery ::= query_simple */ - { 456, -1 }, /* (522) query_simple_or_subquery ::= subquery */ - { 389, -1 }, /* (523) query_or_subquery ::= query_expression */ - { 389, -1 }, /* (524) query_or_subquery ::= subquery */ - { 452, 0 }, /* (525) order_by_clause_opt ::= */ - { 452, -3 }, /* (526) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 453, 0 }, /* (527) slimit_clause_opt ::= */ - { 453, -2 }, /* (528) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 453, -4 }, /* (529) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 453, -4 }, /* (530) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 454, 0 }, /* (531) limit_clause_opt ::= */ - { 454, -2 }, /* (532) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 454, -4 }, /* (533) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 454, -4 }, /* (534) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 431, -3 }, /* (535) subquery ::= NK_LP query_expression NK_RP */ - { 431, -3 }, /* (536) subquery ::= NK_LP subquery NK_RP */ - { 434, -1 }, /* (537) search_condition ::= common_expression */ - { 457, -1 }, /* (538) sort_specification_list ::= sort_specification */ - { 457, -3 }, /* (539) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 458, -3 }, /* (540) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - { 459, 0 }, /* (541) ordering_specification_opt ::= */ - { 459, -1 }, /* (542) ordering_specification_opt ::= ASC */ - { 459, -1 }, /* (543) ordering_specification_opt ::= DESC */ - { 460, 0 }, /* (544) null_ordering_opt ::= */ - { 460, -2 }, /* (545) null_ordering_opt ::= NULLS FIRST */ - { 460, -2 }, /* (546) null_ordering_opt ::= NULLS LAST */ + { 326, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 326, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 327, 0 }, /* (2) account_options ::= */ + { 327, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 327, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 327, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 327, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 327, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 327, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 327, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 327, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 327, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 328, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 328, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 330, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 330, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 330, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 330, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 330, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 330, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 330, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 330, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 330, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 330, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 326, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ + { 326, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 326, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + { 326, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + { 326, -3 }, /* (28) cmd ::= DROP USER user_name */ + { 332, 0 }, /* (29) sysinfo_opt ::= */ + { 332, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ + { 326, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 326, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 333, -1 }, /* (33) privileges ::= ALL */ + { 333, -1 }, /* (34) privileges ::= priv_type_list */ + { 333, -1 }, /* (35) privileges ::= SUBSCRIBE */ + { 335, -1 }, /* (36) priv_type_list ::= priv_type */ + { 335, -3 }, /* (37) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 336, -1 }, /* (38) priv_type ::= READ */ + { 336, -1 }, /* (39) priv_type ::= WRITE */ + { 334, -3 }, /* (40) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 334, -3 }, /* (41) priv_level ::= db_name NK_DOT NK_STAR */ + { 334, -1 }, /* (42) priv_level ::= topic_name */ + { 326, -3 }, /* (43) cmd ::= CREATE DNODE dnode_endpoint */ + { 326, -5 }, /* (44) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + { 326, -4 }, /* (45) cmd ::= DROP DNODE NK_INTEGER force_opt */ + { 326, -4 }, /* (46) cmd ::= DROP DNODE dnode_endpoint force_opt */ + { 326, -4 }, /* (47) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 326, -5 }, /* (48) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 326, -4 }, /* (49) cmd ::= ALTER ALL DNODES NK_STRING */ + { 326, -5 }, /* (50) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 339, -1 }, /* (51) dnode_endpoint ::= NK_STRING */ + { 339, -1 }, /* (52) dnode_endpoint ::= NK_ID */ + { 339, -1 }, /* (53) dnode_endpoint ::= NK_IPTOKEN */ + { 340, 0 }, /* (54) force_opt ::= */ + { 340, -1 }, /* (55) force_opt ::= FORCE */ + { 326, -3 }, /* (56) cmd ::= ALTER LOCAL NK_STRING */ + { 326, -4 }, /* (57) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 326, -5 }, /* (58) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 326, -5 }, /* (59) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 326, -5 }, /* (60) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 326, -5 }, /* (61) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 326, -5 }, /* (62) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 326, -5 }, /* (63) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 326, -5 }, /* (64) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 326, -5 }, /* (65) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 326, -5 }, /* (66) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 326, -4 }, /* (67) cmd ::= DROP DATABASE exists_opt db_name */ + { 326, -2 }, /* (68) cmd ::= USE db_name */ + { 326, -4 }, /* (69) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 326, -3 }, /* (70) cmd ::= FLUSH DATABASE db_name */ + { 326, -4 }, /* (71) cmd ::= TRIM DATABASE db_name speed_opt */ + { 326, -3 }, /* (72) cmd ::= COMPACT DATABASE db_name */ + { 341, -3 }, /* (73) not_exists_opt ::= IF NOT EXISTS */ + { 341, 0 }, /* (74) not_exists_opt ::= */ + { 343, -2 }, /* (75) exists_opt ::= IF EXISTS */ + { 343, 0 }, /* (76) exists_opt ::= */ + { 342, 0 }, /* (77) db_options ::= */ + { 342, -3 }, /* (78) db_options ::= db_options BUFFER NK_INTEGER */ + { 342, -3 }, /* (79) db_options ::= db_options CACHEMODEL NK_STRING */ + { 342, -3 }, /* (80) db_options ::= db_options CACHESIZE NK_INTEGER */ + { 342, -3 }, /* (81) db_options ::= db_options COMP NK_INTEGER */ + { 342, -3 }, /* (82) db_options ::= db_options DURATION NK_INTEGER */ + { 342, -3 }, /* (83) db_options ::= db_options DURATION NK_VARIABLE */ + { 342, -3 }, /* (84) db_options ::= db_options MAXROWS NK_INTEGER */ + { 342, -3 }, /* (85) db_options ::= db_options MINROWS NK_INTEGER */ + { 342, -3 }, /* (86) db_options ::= db_options KEEP integer_list */ + { 342, -3 }, /* (87) db_options ::= db_options KEEP variable_list */ + { 342, -3 }, /* (88) db_options ::= db_options PAGES NK_INTEGER */ + { 342, -3 }, /* (89) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 342, -3 }, /* (90) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ + { 342, -3 }, /* (91) db_options ::= db_options PRECISION NK_STRING */ + { 342, -3 }, /* (92) db_options ::= db_options REPLICA NK_INTEGER */ + { 342, -3 }, /* (93) db_options ::= db_options VGROUPS NK_INTEGER */ + { 342, -3 }, /* (94) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 342, -3 }, /* (95) db_options ::= db_options RETENTIONS retention_list */ + { 342, -3 }, /* (96) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 342, -3 }, /* (97) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + { 342, -3 }, /* (98) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + { 342, -3 }, /* (99) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + { 342, -4 }, /* (100) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + { 342, -3 }, /* (101) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + { 342, -4 }, /* (102) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + { 342, -3 }, /* (103) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + { 342, -3 }, /* (104) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + { 342, -3 }, /* (105) db_options ::= db_options STT_TRIGGER NK_INTEGER */ + { 342, -3 }, /* (106) db_options ::= db_options TABLE_PREFIX NK_INTEGER */ + { 342, -3 }, /* (107) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ + { 344, -1 }, /* (108) alter_db_options ::= alter_db_option */ + { 344, -2 }, /* (109) alter_db_options ::= alter_db_options alter_db_option */ + { 349, -2 }, /* (110) alter_db_option ::= BUFFER NK_INTEGER */ + { 349, -2 }, /* (111) alter_db_option ::= CACHEMODEL NK_STRING */ + { 349, -2 }, /* (112) alter_db_option ::= CACHESIZE NK_INTEGER */ + { 349, -2 }, /* (113) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + { 349, -2 }, /* (114) alter_db_option ::= KEEP integer_list */ + { 349, -2 }, /* (115) alter_db_option ::= KEEP variable_list */ + { 349, -2 }, /* (116) alter_db_option ::= PAGES NK_INTEGER */ + { 349, -2 }, /* (117) alter_db_option ::= REPLICA NK_INTEGER */ + { 349, -2 }, /* (118) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + { 349, -2 }, /* (119) alter_db_option ::= STT_TRIGGER NK_INTEGER */ + { 346, -1 }, /* (120) integer_list ::= NK_INTEGER */ + { 346, -3 }, /* (121) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 347, -1 }, /* (122) variable_list ::= NK_VARIABLE */ + { 347, -3 }, /* (123) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 348, -1 }, /* (124) retention_list ::= retention */ + { 348, -3 }, /* (125) retention_list ::= retention_list NK_COMMA retention */ + { 350, -3 }, /* (126) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 345, 0 }, /* (127) speed_opt ::= */ + { 345, -2 }, /* (128) speed_opt ::= MAX_SPEED NK_INTEGER */ + { 326, -9 }, /* (129) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 326, -3 }, /* (130) cmd ::= CREATE TABLE multi_create_clause */ + { 326, -9 }, /* (131) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 326, -3 }, /* (132) cmd ::= DROP TABLE multi_drop_clause */ + { 326, -4 }, /* (133) cmd ::= DROP STABLE exists_opt full_table_name */ + { 326, -3 }, /* (134) cmd ::= ALTER TABLE alter_table_clause */ + { 326, -3 }, /* (135) cmd ::= ALTER STABLE alter_table_clause */ + { 358, -2 }, /* (136) alter_table_clause ::= full_table_name alter_table_options */ + { 358, -5 }, /* (137) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 358, -4 }, /* (138) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 358, -5 }, /* (139) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 358, -5 }, /* (140) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 358, -5 }, /* (141) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 358, -4 }, /* (142) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 358, -5 }, /* (143) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 358, -5 }, /* (144) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 358, -6 }, /* (145) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 355, -1 }, /* (146) multi_create_clause ::= create_subtable_clause */ + { 355, -2 }, /* (147) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 363, -10 }, /* (148) 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 */ + { 357, -1 }, /* (149) multi_drop_clause ::= drop_table_clause */ + { 357, -2 }, /* (150) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 366, -2 }, /* (151) drop_table_clause ::= exists_opt full_table_name */ + { 364, 0 }, /* (152) specific_cols_opt ::= */ + { 364, -3 }, /* (153) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + { 351, -1 }, /* (154) full_table_name ::= table_name */ + { 351, -3 }, /* (155) full_table_name ::= db_name NK_DOT table_name */ + { 352, -1 }, /* (156) column_def_list ::= column_def */ + { 352, -3 }, /* (157) column_def_list ::= column_def_list NK_COMMA column_def */ + { 369, -2 }, /* (158) column_def ::= column_name type_name */ + { 369, -4 }, /* (159) column_def ::= column_name type_name COMMENT NK_STRING */ + { 361, -1 }, /* (160) type_name ::= BOOL */ + { 361, -1 }, /* (161) type_name ::= TINYINT */ + { 361, -1 }, /* (162) type_name ::= SMALLINT */ + { 361, -1 }, /* (163) type_name ::= INT */ + { 361, -1 }, /* (164) type_name ::= INTEGER */ + { 361, -1 }, /* (165) type_name ::= BIGINT */ + { 361, -1 }, /* (166) type_name ::= FLOAT */ + { 361, -1 }, /* (167) type_name ::= DOUBLE */ + { 361, -4 }, /* (168) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 361, -1 }, /* (169) type_name ::= TIMESTAMP */ + { 361, -4 }, /* (170) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 361, -2 }, /* (171) type_name ::= TINYINT UNSIGNED */ + { 361, -2 }, /* (172) type_name ::= SMALLINT UNSIGNED */ + { 361, -2 }, /* (173) type_name ::= INT UNSIGNED */ + { 361, -2 }, /* (174) type_name ::= BIGINT UNSIGNED */ + { 361, -1 }, /* (175) type_name ::= JSON */ + { 361, -4 }, /* (176) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 361, -1 }, /* (177) type_name ::= MEDIUMBLOB */ + { 361, -1 }, /* (178) type_name ::= BLOB */ + { 361, -4 }, /* (179) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 361, -1 }, /* (180) type_name ::= DECIMAL */ + { 361, -4 }, /* (181) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 361, -6 }, /* (182) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 353, 0 }, /* (183) tags_def_opt ::= */ + { 353, -1 }, /* (184) tags_def_opt ::= tags_def */ + { 356, -4 }, /* (185) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 354, 0 }, /* (186) table_options ::= */ + { 354, -3 }, /* (187) table_options ::= table_options COMMENT NK_STRING */ + { 354, -3 }, /* (188) table_options ::= table_options MAX_DELAY duration_list */ + { 354, -3 }, /* (189) table_options ::= table_options WATERMARK duration_list */ + { 354, -5 }, /* (190) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + { 354, -3 }, /* (191) table_options ::= table_options TTL NK_INTEGER */ + { 354, -5 }, /* (192) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 354, -3 }, /* (193) table_options ::= table_options DELETE_MARK duration_list */ + { 359, -1 }, /* (194) alter_table_options ::= alter_table_option */ + { 359, -2 }, /* (195) alter_table_options ::= alter_table_options alter_table_option */ + { 372, -2 }, /* (196) alter_table_option ::= COMMENT NK_STRING */ + { 372, -2 }, /* (197) alter_table_option ::= TTL NK_INTEGER */ + { 370, -1 }, /* (198) duration_list ::= duration_literal */ + { 370, -3 }, /* (199) duration_list ::= duration_list NK_COMMA duration_literal */ + { 371, -1 }, /* (200) rollup_func_list ::= rollup_func_name */ + { 371, -3 }, /* (201) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + { 374, -1 }, /* (202) rollup_func_name ::= function_name */ + { 374, -1 }, /* (203) rollup_func_name ::= FIRST */ + { 374, -1 }, /* (204) rollup_func_name ::= LAST */ + { 367, -1 }, /* (205) col_name_list ::= col_name */ + { 367, -3 }, /* (206) col_name_list ::= col_name_list NK_COMMA col_name */ + { 376, -1 }, /* (207) col_name ::= column_name */ + { 326, -2 }, /* (208) cmd ::= SHOW DNODES */ + { 326, -2 }, /* (209) cmd ::= SHOW USERS */ + { 326, -3 }, /* (210) cmd ::= SHOW USER PRIVILEGES */ + { 326, -2 }, /* (211) cmd ::= SHOW DATABASES */ + { 326, -4 }, /* (212) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 326, -4 }, /* (213) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 326, -3 }, /* (214) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 326, -2 }, /* (215) cmd ::= SHOW MNODES */ + { 326, -2 }, /* (216) cmd ::= SHOW QNODES */ + { 326, -2 }, /* (217) cmd ::= SHOW FUNCTIONS */ + { 326, -5 }, /* (218) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 326, -2 }, /* (219) cmd ::= SHOW STREAMS */ + { 326, -2 }, /* (220) cmd ::= SHOW ACCOUNTS */ + { 326, -2 }, /* (221) cmd ::= SHOW APPS */ + { 326, -2 }, /* (222) cmd ::= SHOW CONNECTIONS */ + { 326, -2 }, /* (223) cmd ::= SHOW LICENCES */ + { 326, -2 }, /* (224) cmd ::= SHOW GRANTS */ + { 326, -4 }, /* (225) cmd ::= SHOW CREATE DATABASE db_name */ + { 326, -4 }, /* (226) cmd ::= SHOW CREATE TABLE full_table_name */ + { 326, -4 }, /* (227) cmd ::= SHOW CREATE STABLE full_table_name */ + { 326, -2 }, /* (228) cmd ::= SHOW QUERIES */ + { 326, -2 }, /* (229) cmd ::= SHOW SCORES */ + { 326, -2 }, /* (230) cmd ::= SHOW TOPICS */ + { 326, -2 }, /* (231) cmd ::= SHOW VARIABLES */ + { 326, -3 }, /* (232) cmd ::= SHOW CLUSTER VARIABLES */ + { 326, -3 }, /* (233) cmd ::= SHOW LOCAL VARIABLES */ + { 326, -5 }, /* (234) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ + { 326, -2 }, /* (235) cmd ::= SHOW BNODES */ + { 326, -2 }, /* (236) cmd ::= SHOW SNODES */ + { 326, -2 }, /* (237) cmd ::= SHOW CLUSTER */ + { 326, -2 }, /* (238) cmd ::= SHOW TRANSACTIONS */ + { 326, -4 }, /* (239) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 326, -2 }, /* (240) cmd ::= SHOW CONSUMERS */ + { 326, -2 }, /* (241) cmd ::= SHOW SUBSCRIPTIONS */ + { 326, -5 }, /* (242) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + { 326, -7 }, /* (243) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ + { 326, -3 }, /* (244) cmd ::= SHOW VNODES NK_INTEGER */ + { 326, -3 }, /* (245) cmd ::= SHOW VNODES NK_STRING */ + { 326, -3 }, /* (246) cmd ::= SHOW db_name_cond_opt ALIVE */ + { 326, -3 }, /* (247) cmd ::= SHOW CLUSTER ALIVE */ + { 377, 0 }, /* (248) db_name_cond_opt ::= */ + { 377, -2 }, /* (249) db_name_cond_opt ::= db_name NK_DOT */ + { 378, 0 }, /* (250) like_pattern_opt ::= */ + { 378, -2 }, /* (251) like_pattern_opt ::= LIKE NK_STRING */ + { 379, -1 }, /* (252) table_name_cond ::= table_name */ + { 380, 0 }, /* (253) from_db_opt ::= */ + { 380, -2 }, /* (254) from_db_opt ::= FROM db_name */ + { 381, 0 }, /* (255) tag_list_opt ::= */ + { 381, -1 }, /* (256) tag_list_opt ::= tag_item */ + { 381, -3 }, /* (257) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ + { 382, -1 }, /* (258) tag_item ::= TBNAME */ + { 382, -1 }, /* (259) tag_item ::= QTAGS */ + { 382, -1 }, /* (260) tag_item ::= column_name */ + { 382, -2 }, /* (261) tag_item ::= column_name column_alias */ + { 382, -3 }, /* (262) tag_item ::= column_name AS column_alias */ + { 326, -8 }, /* (263) cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */ + { 326, -9 }, /* (264) cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP */ + { 326, -4 }, /* (265) cmd ::= DROP INDEX exists_opt full_index_name */ + { 384, -1 }, /* (266) full_index_name ::= index_name */ + { 384, -3 }, /* (267) full_index_name ::= db_name NK_DOT index_name */ + { 385, -10 }, /* (268) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + { 385, -12 }, /* (269) 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 */ + { 387, -1 }, /* (270) func_list ::= func */ + { 387, -3 }, /* (271) func_list ::= func_list NK_COMMA func */ + { 390, -4 }, /* (272) func ::= sma_func_name NK_LP expression_list NK_RP */ + { 391, -1 }, /* (273) sma_func_name ::= function_name */ + { 391, -1 }, /* (274) sma_func_name ::= COUNT */ + { 391, -1 }, /* (275) sma_func_name ::= FIRST */ + { 391, -1 }, /* (276) sma_func_name ::= LAST */ + { 391, -1 }, /* (277) sma_func_name ::= LAST_ROW */ + { 389, 0 }, /* (278) sma_stream_opt ::= */ + { 389, -3 }, /* (279) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + { 389, -3 }, /* (280) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + { 389, -3 }, /* (281) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + { 326, -6 }, /* (282) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + { 326, -7 }, /* (283) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 326, -9 }, /* (284) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 326, -7 }, /* (285) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 326, -9 }, /* (286) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 326, -4 }, /* (287) cmd ::= DROP TOPIC exists_opt topic_name */ + { 326, -7 }, /* (288) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 326, -2 }, /* (289) cmd ::= DESC full_table_name */ + { 326, -2 }, /* (290) cmd ::= DESCRIBE full_table_name */ + { 326, -3 }, /* (291) cmd ::= RESET QUERY CACHE */ + { 326, -4 }, /* (292) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + { 394, 0 }, /* (293) analyze_opt ::= */ + { 394, -1 }, /* (294) analyze_opt ::= ANALYZE */ + { 395, 0 }, /* (295) explain_options ::= */ + { 395, -3 }, /* (296) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 395, -3 }, /* (297) explain_options ::= explain_options RATIO NK_FLOAT */ + { 326, -10 }, /* (298) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 326, -4 }, /* (299) cmd ::= DROP FUNCTION exists_opt function_name */ + { 396, 0 }, /* (300) agg_func_opt ::= */ + { 396, -1 }, /* (301) agg_func_opt ::= AGGREGATE */ + { 397, 0 }, /* (302) bufsize_opt ::= */ + { 397, -2 }, /* (303) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 326, -12 }, /* (304) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tags_def_opt subtable_opt AS query_or_subquery */ + { 326, -4 }, /* (305) cmd ::= DROP STREAM exists_opt stream_name */ + { 400, 0 }, /* (306) col_list_opt ::= */ + { 400, -3 }, /* (307) col_list_opt ::= NK_LP col_name_list NK_RP */ + { 399, 0 }, /* (308) stream_options ::= */ + { 399, -3 }, /* (309) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 399, -3 }, /* (310) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 399, -4 }, /* (311) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 399, -3 }, /* (312) stream_options ::= stream_options WATERMARK duration_literal */ + { 399, -4 }, /* (313) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + { 399, -3 }, /* (314) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + { 401, 0 }, /* (315) subtable_opt ::= */ + { 401, -4 }, /* (316) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + { 326, -3 }, /* (317) cmd ::= KILL CONNECTION NK_INTEGER */ + { 326, -3 }, /* (318) cmd ::= KILL QUERY NK_STRING */ + { 326, -3 }, /* (319) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 326, -2 }, /* (320) cmd ::= BALANCE VGROUP */ + { 326, -4 }, /* (321) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 326, -4 }, /* (322) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 326, -3 }, /* (323) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 403, -2 }, /* (324) dnode_list ::= DNODE NK_INTEGER */ + { 403, -3 }, /* (325) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 326, -4 }, /* (326) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 326, -1 }, /* (327) cmd ::= query_or_subquery */ + { 326, -7 }, /* (328) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + { 326, -4 }, /* (329) cmd ::= INSERT INTO full_table_name query_or_subquery */ + { 329, -1 }, /* (330) literal ::= NK_INTEGER */ + { 329, -1 }, /* (331) literal ::= NK_FLOAT */ + { 329, -1 }, /* (332) literal ::= NK_STRING */ + { 329, -1 }, /* (333) literal ::= NK_BOOL */ + { 329, -2 }, /* (334) literal ::= TIMESTAMP NK_STRING */ + { 329, -1 }, /* (335) literal ::= duration_literal */ + { 329, -1 }, /* (336) literal ::= NULL */ + { 329, -1 }, /* (337) literal ::= NK_QUESTION */ + { 373, -1 }, /* (338) duration_literal ::= NK_VARIABLE */ + { 405, -1 }, /* (339) signed ::= NK_INTEGER */ + { 405, -2 }, /* (340) signed ::= NK_PLUS NK_INTEGER */ + { 405, -2 }, /* (341) signed ::= NK_MINUS NK_INTEGER */ + { 405, -1 }, /* (342) signed ::= NK_FLOAT */ + { 405, -2 }, /* (343) signed ::= NK_PLUS NK_FLOAT */ + { 405, -2 }, /* (344) signed ::= NK_MINUS NK_FLOAT */ + { 362, -1 }, /* (345) signed_literal ::= signed */ + { 362, -1 }, /* (346) signed_literal ::= NK_STRING */ + { 362, -1 }, /* (347) signed_literal ::= NK_BOOL */ + { 362, -2 }, /* (348) signed_literal ::= TIMESTAMP NK_STRING */ + { 362, -1 }, /* (349) signed_literal ::= duration_literal */ + { 362, -1 }, /* (350) signed_literal ::= NULL */ + { 362, -1 }, /* (351) signed_literal ::= literal_func */ + { 362, -1 }, /* (352) signed_literal ::= NK_QUESTION */ + { 407, -1 }, /* (353) literal_list ::= signed_literal */ + { 407, -3 }, /* (354) literal_list ::= literal_list NK_COMMA signed_literal */ + { 337, -1 }, /* (355) db_name ::= NK_ID */ + { 368, -1 }, /* (356) table_name ::= NK_ID */ + { 360, -1 }, /* (357) column_name ::= NK_ID */ + { 375, -1 }, /* (358) function_name ::= NK_ID */ + { 408, -1 }, /* (359) table_alias ::= NK_ID */ + { 383, -1 }, /* (360) column_alias ::= NK_ID */ + { 331, -1 }, /* (361) user_name ::= NK_ID */ + { 338, -1 }, /* (362) topic_name ::= NK_ID */ + { 398, -1 }, /* (363) stream_name ::= NK_ID */ + { 393, -1 }, /* (364) cgroup_name ::= NK_ID */ + { 386, -1 }, /* (365) index_name ::= NK_ID */ + { 409, -1 }, /* (366) expr_or_subquery ::= expression */ + { 402, -1 }, /* (367) expression ::= literal */ + { 402, -1 }, /* (368) expression ::= pseudo_column */ + { 402, -1 }, /* (369) expression ::= column_reference */ + { 402, -1 }, /* (370) expression ::= function_expression */ + { 402, -1 }, /* (371) expression ::= case_when_expression */ + { 402, -3 }, /* (372) expression ::= NK_LP expression NK_RP */ + { 402, -2 }, /* (373) expression ::= NK_PLUS expr_or_subquery */ + { 402, -2 }, /* (374) expression ::= NK_MINUS expr_or_subquery */ + { 402, -3 }, /* (375) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + { 402, -3 }, /* (376) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + { 402, -3 }, /* (377) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + { 402, -3 }, /* (378) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + { 402, -3 }, /* (379) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + { 402, -3 }, /* (380) expression ::= column_reference NK_ARROW NK_STRING */ + { 402, -3 }, /* (381) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + { 402, -3 }, /* (382) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + { 365, -1 }, /* (383) expression_list ::= expr_or_subquery */ + { 365, -3 }, /* (384) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + { 411, -1 }, /* (385) column_reference ::= column_name */ + { 411, -3 }, /* (386) column_reference ::= table_name NK_DOT column_name */ + { 410, -1 }, /* (387) pseudo_column ::= ROWTS */ + { 410, -1 }, /* (388) pseudo_column ::= TBNAME */ + { 410, -3 }, /* (389) pseudo_column ::= table_name NK_DOT TBNAME */ + { 410, -1 }, /* (390) pseudo_column ::= QSTART */ + { 410, -1 }, /* (391) pseudo_column ::= QEND */ + { 410, -1 }, /* (392) pseudo_column ::= QDURATION */ + { 410, -1 }, /* (393) pseudo_column ::= WSTART */ + { 410, -1 }, /* (394) pseudo_column ::= WEND */ + { 410, -1 }, /* (395) pseudo_column ::= WDURATION */ + { 410, -1 }, /* (396) pseudo_column ::= IROWTS */ + { 410, -1 }, /* (397) pseudo_column ::= ISFILLED */ + { 410, -1 }, /* (398) pseudo_column ::= QTAGS */ + { 412, -4 }, /* (399) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 412, -4 }, /* (400) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 412, -6 }, /* (401) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + { 412, -1 }, /* (402) function_expression ::= literal_func */ + { 406, -3 }, /* (403) literal_func ::= noarg_func NK_LP NK_RP */ + { 406, -1 }, /* (404) literal_func ::= NOW */ + { 416, -1 }, /* (405) noarg_func ::= NOW */ + { 416, -1 }, /* (406) noarg_func ::= TODAY */ + { 416, -1 }, /* (407) noarg_func ::= TIMEZONE */ + { 416, -1 }, /* (408) noarg_func ::= DATABASE */ + { 416, -1 }, /* (409) noarg_func ::= CLIENT_VERSION */ + { 416, -1 }, /* (410) noarg_func ::= SERVER_VERSION */ + { 416, -1 }, /* (411) noarg_func ::= SERVER_STATUS */ + { 416, -1 }, /* (412) noarg_func ::= CURRENT_USER */ + { 416, -1 }, /* (413) noarg_func ::= USER */ + { 414, -1 }, /* (414) star_func ::= COUNT */ + { 414, -1 }, /* (415) star_func ::= FIRST */ + { 414, -1 }, /* (416) star_func ::= LAST */ + { 414, -1 }, /* (417) star_func ::= LAST_ROW */ + { 415, -1 }, /* (418) star_func_para_list ::= NK_STAR */ + { 415, -1 }, /* (419) star_func_para_list ::= other_para_list */ + { 417, -1 }, /* (420) other_para_list ::= star_func_para */ + { 417, -3 }, /* (421) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 418, -1 }, /* (422) star_func_para ::= expr_or_subquery */ + { 418, -3 }, /* (423) star_func_para ::= table_name NK_DOT NK_STAR */ + { 413, -4 }, /* (424) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + { 413, -5 }, /* (425) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + { 419, -1 }, /* (426) when_then_list ::= when_then_expr */ + { 419, -2 }, /* (427) when_then_list ::= when_then_list when_then_expr */ + { 422, -4 }, /* (428) when_then_expr ::= WHEN common_expression THEN common_expression */ + { 420, 0 }, /* (429) case_when_else_opt ::= */ + { 420, -2 }, /* (430) case_when_else_opt ::= ELSE common_expression */ + { 423, -3 }, /* (431) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + { 423, -5 }, /* (432) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + { 423, -6 }, /* (433) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + { 423, -3 }, /* (434) predicate ::= expr_or_subquery IS NULL */ + { 423, -4 }, /* (435) predicate ::= expr_or_subquery IS NOT NULL */ + { 423, -3 }, /* (436) predicate ::= expr_or_subquery in_op in_predicate_value */ + { 424, -1 }, /* (437) compare_op ::= NK_LT */ + { 424, -1 }, /* (438) compare_op ::= NK_GT */ + { 424, -1 }, /* (439) compare_op ::= NK_LE */ + { 424, -1 }, /* (440) compare_op ::= NK_GE */ + { 424, -1 }, /* (441) compare_op ::= NK_NE */ + { 424, -1 }, /* (442) compare_op ::= NK_EQ */ + { 424, -1 }, /* (443) compare_op ::= LIKE */ + { 424, -2 }, /* (444) compare_op ::= NOT LIKE */ + { 424, -1 }, /* (445) compare_op ::= MATCH */ + { 424, -1 }, /* (446) compare_op ::= NMATCH */ + { 424, -1 }, /* (447) compare_op ::= CONTAINS */ + { 425, -1 }, /* (448) in_op ::= IN */ + { 425, -2 }, /* (449) in_op ::= NOT IN */ + { 426, -3 }, /* (450) in_predicate_value ::= NK_LP literal_list NK_RP */ + { 427, -1 }, /* (451) boolean_value_expression ::= boolean_primary */ + { 427, -2 }, /* (452) boolean_value_expression ::= NOT boolean_primary */ + { 427, -3 }, /* (453) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 427, -3 }, /* (454) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 428, -1 }, /* (455) boolean_primary ::= predicate */ + { 428, -3 }, /* (456) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 421, -1 }, /* (457) common_expression ::= expr_or_subquery */ + { 421, -1 }, /* (458) common_expression ::= boolean_value_expression */ + { 429, 0 }, /* (459) from_clause_opt ::= */ + { 429, -2 }, /* (460) from_clause_opt ::= FROM table_reference_list */ + { 430, -1 }, /* (461) table_reference_list ::= table_reference */ + { 430, -3 }, /* (462) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 431, -1 }, /* (463) table_reference ::= table_primary */ + { 431, -1 }, /* (464) table_reference ::= joined_table */ + { 432, -2 }, /* (465) table_primary ::= table_name alias_opt */ + { 432, -4 }, /* (466) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 432, -2 }, /* (467) table_primary ::= subquery alias_opt */ + { 432, -1 }, /* (468) table_primary ::= parenthesized_joined_table */ + { 434, 0 }, /* (469) alias_opt ::= */ + { 434, -1 }, /* (470) alias_opt ::= table_alias */ + { 434, -2 }, /* (471) alias_opt ::= AS table_alias */ + { 436, -3 }, /* (472) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 436, -3 }, /* (473) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 433, -6 }, /* (474) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 437, 0 }, /* (475) join_type ::= */ + { 437, -1 }, /* (476) join_type ::= INNER */ + { 439, -12 }, /* (477) 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 */ + { 440, 0 }, /* (478) set_quantifier_opt ::= */ + { 440, -1 }, /* (479) set_quantifier_opt ::= DISTINCT */ + { 440, -1 }, /* (480) set_quantifier_opt ::= ALL */ + { 441, -1 }, /* (481) select_list ::= select_item */ + { 441, -3 }, /* (482) select_list ::= select_list NK_COMMA select_item */ + { 449, -1 }, /* (483) select_item ::= NK_STAR */ + { 449, -1 }, /* (484) select_item ::= common_expression */ + { 449, -2 }, /* (485) select_item ::= common_expression column_alias */ + { 449, -3 }, /* (486) select_item ::= common_expression AS column_alias */ + { 449, -3 }, /* (487) select_item ::= table_name NK_DOT NK_STAR */ + { 404, 0 }, /* (488) where_clause_opt ::= */ + { 404, -2 }, /* (489) where_clause_opt ::= WHERE search_condition */ + { 442, 0 }, /* (490) partition_by_clause_opt ::= */ + { 442, -3 }, /* (491) partition_by_clause_opt ::= PARTITION BY partition_list */ + { 450, -1 }, /* (492) partition_list ::= partition_item */ + { 450, -3 }, /* (493) partition_list ::= partition_list NK_COMMA partition_item */ + { 451, -1 }, /* (494) partition_item ::= expr_or_subquery */ + { 451, -2 }, /* (495) partition_item ::= expr_or_subquery column_alias */ + { 451, -3 }, /* (496) partition_item ::= expr_or_subquery AS column_alias */ + { 446, 0 }, /* (497) twindow_clause_opt ::= */ + { 446, -6 }, /* (498) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 446, -4 }, /* (499) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + { 446, -6 }, /* (500) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 446, -8 }, /* (501) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 446, -7 }, /* (502) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ + { 388, 0 }, /* (503) sliding_opt ::= */ + { 388, -4 }, /* (504) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 445, 0 }, /* (505) fill_opt ::= */ + { 445, -4 }, /* (506) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 445, -6 }, /* (507) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 452, -1 }, /* (508) fill_mode ::= NONE */ + { 452, -1 }, /* (509) fill_mode ::= PREV */ + { 452, -1 }, /* (510) fill_mode ::= NULL */ + { 452, -1 }, /* (511) fill_mode ::= LINEAR */ + { 452, -1 }, /* (512) fill_mode ::= NEXT */ + { 447, 0 }, /* (513) group_by_clause_opt ::= */ + { 447, -3 }, /* (514) group_by_clause_opt ::= GROUP BY group_by_list */ + { 453, -1 }, /* (515) group_by_list ::= expr_or_subquery */ + { 453, -3 }, /* (516) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + { 448, 0 }, /* (517) having_clause_opt ::= */ + { 448, -2 }, /* (518) having_clause_opt ::= HAVING search_condition */ + { 443, 0 }, /* (519) range_opt ::= */ + { 443, -6 }, /* (520) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + { 444, 0 }, /* (521) every_opt ::= */ + { 444, -4 }, /* (522) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 454, -4 }, /* (523) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 455, -1 }, /* (524) query_simple ::= query_specification */ + { 455, -1 }, /* (525) query_simple ::= union_query_expression */ + { 459, -4 }, /* (526) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + { 459, -3 }, /* (527) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + { 460, -1 }, /* (528) query_simple_or_subquery ::= query_simple */ + { 460, -1 }, /* (529) query_simple_or_subquery ::= subquery */ + { 392, -1 }, /* (530) query_or_subquery ::= query_expression */ + { 392, -1 }, /* (531) query_or_subquery ::= subquery */ + { 456, 0 }, /* (532) order_by_clause_opt ::= */ + { 456, -3 }, /* (533) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 457, 0 }, /* (534) slimit_clause_opt ::= */ + { 457, -2 }, /* (535) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 457, -4 }, /* (536) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 457, -4 }, /* (537) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 458, 0 }, /* (538) limit_clause_opt ::= */ + { 458, -2 }, /* (539) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 458, -4 }, /* (540) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 458, -4 }, /* (541) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 435, -3 }, /* (542) subquery ::= NK_LP query_expression NK_RP */ + { 435, -3 }, /* (543) subquery ::= NK_LP subquery NK_RP */ + { 438, -1 }, /* (544) search_condition ::= common_expression */ + { 461, -1 }, /* (545) sort_specification_list ::= sort_specification */ + { 461, -3 }, /* (546) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 462, -3 }, /* (547) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + { 463, 0 }, /* (548) ordering_specification_opt ::= */ + { 463, -1 }, /* (549) ordering_specification_opt ::= ASC */ + { 463, -1 }, /* (550) ordering_specification_opt ::= DESC */ + { 464, 0 }, /* (551) null_ordering_opt ::= */ + { 464, -2 }, /* (552) null_ordering_opt ::= NULLS FIRST */ + { 464, -2 }, /* (553) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3731,11 +3704,11 @@ static YYACTIONTYPE yy_reduce( YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,326,&yymsp[0].minor); + yy_destructor(yypParser,327,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,327,&yymsp[0].minor); + yy_destructor(yypParser,328,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3749,20 +3722,20 @@ static YYACTIONTYPE yy_reduce( case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9); case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); -{ yy_destructor(yypParser,326,&yymsp[-2].minor); +{ yy_destructor(yypParser,327,&yymsp[-2].minor); { } - yy_destructor(yypParser,328,&yymsp[0].minor); + yy_destructor(yypParser,329,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,329,&yymsp[0].minor); +{ yy_destructor(yypParser,330,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,327,&yymsp[-1].minor); +{ yy_destructor(yypParser,328,&yymsp[-1].minor); { } - yy_destructor(yypParser,329,&yymsp[0].minor); + yy_destructor(yypParser,330,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3776,81 +3749,81 @@ static YYACTIONTYPE yy_reduce( case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); { } - yy_destructor(yypParser,328,&yymsp[0].minor); + yy_destructor(yypParser,329,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy77, &yymsp[-1].minor.yy0, yymsp[0].minor.yy287); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy179, &yymsp[-1].minor.yy0, yymsp[0].minor.yy113); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy77, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy179, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy77, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy179, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy77, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy179, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 28: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy77); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy179); } break; case 29: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy287 = 1; } +{ yymsp[1].minor.yy113 = 1; } break; case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy287 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy113 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } break; case 31: /* cmd ::= GRANT privileges ON priv_level TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy717, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy77); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy159, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy179); } break; case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy717, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy77); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy159, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy179); } break; case 33: /* privileges ::= ALL */ -{ yymsp[0].minor.yy717 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy159 = PRIVILEGE_TYPE_ALL; } break; case 34: /* privileges ::= priv_type_list */ case 36: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==36); -{ yylhsminor.yy717 = yymsp[0].minor.yy717; } - yymsp[0].minor.yy717 = yylhsminor.yy717; +{ yylhsminor.yy159 = yymsp[0].minor.yy159; } + yymsp[0].minor.yy159 = yylhsminor.yy159; break; case 35: /* privileges ::= SUBSCRIBE */ -{ yymsp[0].minor.yy717 = PRIVILEGE_TYPE_SUBSCRIBE; } +{ yymsp[0].minor.yy159 = PRIVILEGE_TYPE_SUBSCRIBE; } break; case 37: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy717 = yymsp[-2].minor.yy717 | yymsp[0].minor.yy717; } - yymsp[-2].minor.yy717 = yylhsminor.yy717; +{ yylhsminor.yy159 = yymsp[-2].minor.yy159 | yymsp[0].minor.yy159; } + yymsp[-2].minor.yy159 = yylhsminor.yy159; break; case 38: /* priv_type ::= READ */ -{ yymsp[0].minor.yy717 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy159 = PRIVILEGE_TYPE_READ; } break; case 39: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy717 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy159 = PRIVILEGE_TYPE_WRITE; } break; case 40: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy77 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy77 = yylhsminor.yy77; +{ yylhsminor.yy179 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy179 = yylhsminor.yy179; break; case 41: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy77 = yymsp[-2].minor.yy77; } - yymsp[-2].minor.yy77 = yylhsminor.yy77; +{ yylhsminor.yy179 = yymsp[-2].minor.yy179; } + yymsp[-2].minor.yy179 = yylhsminor.yy179; break; case 42: /* priv_level ::= topic_name */ - case 269: /* sma_func_name ::= function_name */ yytestcase(yyruleno==269); - case 463: /* alias_opt ::= table_alias */ yytestcase(yyruleno==463); -{ yylhsminor.yy77 = yymsp[0].minor.yy77; } - yymsp[0].minor.yy77 = yylhsminor.yy77; + case 273: /* sma_func_name ::= function_name */ yytestcase(yyruleno==273); + case 470: /* alias_opt ::= table_alias */ yytestcase(yyruleno==470); +{ yylhsminor.yy179 = yymsp[0].minor.yy179; } + yymsp[0].minor.yy179 = yylhsminor.yy179; break; case 43: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy77, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy179, NULL); } break; case 44: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy0); } break; case 45: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy841); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy767); } break; case 46: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy77, yymsp[0].minor.yy841); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy179, yymsp[0].minor.yy767); } break; case 47: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3867,49 +3840,50 @@ static YYACTIONTYPE yy_reduce( case 51: /* dnode_endpoint ::= NK_STRING */ case 52: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==52); case 53: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==53); - case 270: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==270); - case 271: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==271); - case 272: /* sma_func_name ::= LAST */ yytestcase(yyruleno==272); - case 273: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==273); - case 349: /* db_name ::= NK_ID */ yytestcase(yyruleno==349); - case 350: /* table_name ::= NK_ID */ yytestcase(yyruleno==350); - case 351: /* column_name ::= NK_ID */ yytestcase(yyruleno==351); - case 352: /* function_name ::= NK_ID */ yytestcase(yyruleno==352); - case 353: /* table_alias ::= NK_ID */ yytestcase(yyruleno==353); - case 354: /* column_alias ::= NK_ID */ yytestcase(yyruleno==354); - case 355: /* user_name ::= NK_ID */ yytestcase(yyruleno==355); - case 356: /* topic_name ::= NK_ID */ yytestcase(yyruleno==356); - case 357: /* stream_name ::= NK_ID */ yytestcase(yyruleno==357); - case 358: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==358); - case 398: /* noarg_func ::= NOW */ yytestcase(yyruleno==398); - case 399: /* noarg_func ::= TODAY */ yytestcase(yyruleno==399); - case 400: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==400); - case 401: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==401); - case 402: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==402); - case 403: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==403); - case 404: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==404); - case 405: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==405); - case 406: /* noarg_func ::= USER */ yytestcase(yyruleno==406); - case 407: /* star_func ::= COUNT */ yytestcase(yyruleno==407); - case 408: /* star_func ::= FIRST */ yytestcase(yyruleno==408); - case 409: /* star_func ::= LAST */ yytestcase(yyruleno==409); - case 410: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==410); -{ yylhsminor.yy77 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy77 = yylhsminor.yy77; + case 274: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==274); + case 275: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==275); + case 276: /* sma_func_name ::= LAST */ yytestcase(yyruleno==276); + case 277: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==277); + case 355: /* db_name ::= NK_ID */ yytestcase(yyruleno==355); + case 356: /* table_name ::= NK_ID */ yytestcase(yyruleno==356); + case 357: /* column_name ::= NK_ID */ yytestcase(yyruleno==357); + case 358: /* function_name ::= NK_ID */ yytestcase(yyruleno==358); + case 359: /* table_alias ::= NK_ID */ yytestcase(yyruleno==359); + case 360: /* column_alias ::= NK_ID */ yytestcase(yyruleno==360); + case 361: /* user_name ::= NK_ID */ yytestcase(yyruleno==361); + case 362: /* topic_name ::= NK_ID */ yytestcase(yyruleno==362); + case 363: /* stream_name ::= NK_ID */ yytestcase(yyruleno==363); + case 364: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==364); + case 365: /* index_name ::= NK_ID */ yytestcase(yyruleno==365); + case 405: /* noarg_func ::= NOW */ yytestcase(yyruleno==405); + case 406: /* noarg_func ::= TODAY */ yytestcase(yyruleno==406); + case 407: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==407); + case 408: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==408); + case 409: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==409); + case 410: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==410); + case 411: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==411); + case 412: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==412); + case 413: /* noarg_func ::= USER */ yytestcase(yyruleno==413); + case 414: /* star_func ::= COUNT */ yytestcase(yyruleno==414); + case 415: /* star_func ::= FIRST */ yytestcase(yyruleno==415); + case 416: /* star_func ::= LAST */ yytestcase(yyruleno==416); + case 417: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==417); +{ yylhsminor.yy179 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy179 = yylhsminor.yy179; break; case 54: /* force_opt ::= */ case 74: /* not_exists_opt ::= */ yytestcase(yyruleno==74); case 76: /* exists_opt ::= */ yytestcase(yyruleno==76); - case 289: /* analyze_opt ::= */ yytestcase(yyruleno==289); - case 296: /* agg_func_opt ::= */ yytestcase(yyruleno==296); - case 471: /* set_quantifier_opt ::= */ yytestcase(yyruleno==471); -{ yymsp[1].minor.yy841 = false; } + case 293: /* analyze_opt ::= */ yytestcase(yyruleno==293); + case 300: /* agg_func_opt ::= */ yytestcase(yyruleno==300); + case 478: /* set_quantifier_opt ::= */ yytestcase(yyruleno==478); +{ yymsp[1].minor.yy767 = false; } break; case 55: /* force_opt ::= FORCE */ - case 290: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==290); - case 297: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==297); - case 472: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==472); -{ yymsp[0].minor.yy841 = true; } + case 294: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==294); + case 301: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==301); + case 479: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==479); +{ yymsp[0].minor.yy767 = true; } break; case 56: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3942,209 +3916,209 @@ 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.yy841, &yymsp[-1].minor.yy77, yymsp[0].minor.yy600); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy767, &yymsp[-1].minor.yy179, yymsp[0].minor.yy602); } break; case 67: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy841, &yymsp[0].minor.yy77); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy767, &yymsp[0].minor.yy179); } break; case 68: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy77); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy179); } break; case 69: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy77, yymsp[0].minor.yy600); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy179, yymsp[0].minor.yy602); } break; case 70: /* cmd ::= FLUSH DATABASE db_name */ -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy77); } +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy179); } break; case 71: /* cmd ::= TRIM DATABASE db_name speed_opt */ -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy77, yymsp[0].minor.yy248); } +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy179, yymsp[0].minor.yy820); } break; case 72: /* cmd ::= COMPACT DATABASE db_name */ -{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[0].minor.yy77); } +{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[0].minor.yy179); } break; case 73: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy841 = true; } +{ yymsp[-2].minor.yy767 = true; } break; case 75: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy841 = true; } +{ yymsp[-1].minor.yy767 = true; } break; case 77: /* db_options ::= */ -{ yymsp[1].minor.yy600 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy602 = createDefaultDatabaseOptions(pCxt); } break; case 78: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 79: /* db_options ::= db_options CACHEMODEL NK_STRING */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 80: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 81: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 82: /* db_options ::= db_options DURATION NK_INTEGER */ case 83: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==83); -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 84: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 85: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 86: /* db_options ::= db_options KEEP integer_list */ case 87: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==87); -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_KEEP, yymsp[0].minor.yy601); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_KEEP, yymsp[0].minor.yy874); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 88: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 89: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 90: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 91: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 92: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 93: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 94: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 95: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_RETENTIONS, yymsp[0].minor.yy601); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_RETENTIONS, yymsp[0].minor.yy874); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 96: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 97: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 98: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 99: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 100: /* 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.yy600 = setDatabaseOption(pCxt, yymsp[-3].minor.yy600, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-3].minor.yy602, DB_OPTION_WAL_RETENTION_PERIOD, &t); } - yymsp[-3].minor.yy600 = yylhsminor.yy600; + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; case 101: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 102: /* 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.yy600 = setDatabaseOption(pCxt, yymsp[-3].minor.yy600, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-3].minor.yy602, DB_OPTION_WAL_RETENTION_SIZE, &t); } - yymsp[-3].minor.yy600 = yylhsminor.yy600; + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; case 103: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 104: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 105: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 106: /* db_options ::= db_options TABLE_PREFIX NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 107: /* db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ -{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setDatabaseOption(pCxt, yymsp[-2].minor.yy602, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 108: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy600 = createAlterDatabaseOptions(pCxt); yylhsminor.yy600 = setAlterDatabaseOption(pCxt, yylhsminor.yy600, &yymsp[0].minor.yy661); } - yymsp[0].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createAlterDatabaseOptions(pCxt); yylhsminor.yy602 = setAlterDatabaseOption(pCxt, yylhsminor.yy602, &yymsp[0].minor.yy845); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; case 109: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy600 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy600, &yymsp[0].minor.yy661); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy602, &yymsp[0].minor.yy845); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; case 110: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy661.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 111: /* alter_db_option ::= CACHEMODEL NK_STRING */ -{ yymsp[-1].minor.yy661.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 112: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -{ yymsp[-1].minor.yy661.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 113: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy661.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 114: /* alter_db_option ::= KEEP integer_list */ case 115: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==115); -{ yymsp[-1].minor.yy661.type = DB_OPTION_KEEP; yymsp[-1].minor.yy661.pList = yymsp[0].minor.yy601; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_KEEP; yymsp[-1].minor.yy845.pList = yymsp[0].minor.yy874; } break; case 116: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy661.type = DB_OPTION_PAGES; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_PAGES; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 117: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy661.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 118: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -{ yymsp[-1].minor.yy661.type = DB_OPTION_WAL; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_WAL; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 119: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ -{ yymsp[-1].minor.yy661.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 120: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy601 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy601 = yylhsminor.yy601; +{ yylhsminor.yy874 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy874 = yylhsminor.yy874; break; case 121: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 319: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==319); -{ yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy601 = yylhsminor.yy601; + case 325: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==325); +{ 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 122: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy601 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy601 = yylhsminor.yy601; +{ yylhsminor.yy874 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy874 = yylhsminor.yy874; break; case 123: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy601 = yylhsminor.yy601; +{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-2].minor.yy874, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy874 = yylhsminor.yy874; break; case 124: /* retention_list ::= retention */ case 146: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==146); @@ -4152,288 +4126,290 @@ static YYACTIONTYPE yy_reduce( case 156: /* column_def_list ::= column_def */ yytestcase(yyruleno==156); case 200: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==200); case 205: /* col_name_list ::= col_name */ yytestcase(yyruleno==205); - case 254: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==254); - case 266: /* func_list ::= func */ yytestcase(yyruleno==266); - case 347: /* literal_list ::= signed_literal */ yytestcase(yyruleno==347); - case 413: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==413); - case 419: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==419); - case 474: /* select_list ::= select_item */ yytestcase(yyruleno==474); - case 485: /* partition_list ::= partition_item */ yytestcase(yyruleno==485); - case 538: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==538); -{ yylhsminor.yy601 = createNodeList(pCxt, yymsp[0].minor.yy600); } - yymsp[0].minor.yy601 = yylhsminor.yy601; + case 256: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==256); + case 270: /* func_list ::= func */ yytestcase(yyruleno==270); + case 353: /* literal_list ::= signed_literal */ yytestcase(yyruleno==353); + case 420: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==420); + case 426: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==426); + case 481: /* select_list ::= select_item */ yytestcase(yyruleno==481); + case 492: /* partition_list ::= partition_item */ yytestcase(yyruleno==492); + case 545: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==545); +{ yylhsminor.yy874 = createNodeList(pCxt, yymsp[0].minor.yy602); } + yymsp[0].minor.yy874 = yylhsminor.yy874; break; case 125: /* retention_list ::= retention_list NK_COMMA retention */ case 157: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==157); case 201: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==201); case 206: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==206); - case 255: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==255); - case 267: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==267); - case 348: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==348); - case 414: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==414); - case 475: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==475); - case 486: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==486); - case 539: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==539); -{ yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, yymsp[0].minor.yy600); } - yymsp[-2].minor.yy601 = yylhsminor.yy601; + case 257: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==257); + case 271: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==271); + case 354: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==354); + case 421: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==421); + case 482: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==482); + case 493: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==493); + case 546: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==546); +{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-2].minor.yy874, yymsp[0].minor.yy602); } + yymsp[-2].minor.yy874 = yylhsminor.yy874; break; case 126: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy600 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 127: /* speed_opt ::= */ - case 298: /* bufsize_opt ::= */ yytestcase(yyruleno==298); -{ yymsp[1].minor.yy248 = 0; } + case 302: /* bufsize_opt ::= */ yytestcase(yyruleno==302); +{ yymsp[1].minor.yy820 = 0; } break; case 128: /* speed_opt ::= MAX_SPEED NK_INTEGER */ - case 299: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==299); -{ yymsp[-1].minor.yy248 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + case 303: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==303); +{ yymsp[-1].minor.yy820 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; case 129: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 131: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==131); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy841, yymsp[-5].minor.yy600, yymsp[-3].minor.yy601, yymsp[-1].minor.yy601, yymsp[0].minor.yy600); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy767, yymsp[-5].minor.yy602, yymsp[-3].minor.yy874, yymsp[-1].minor.yy874, yymsp[0].minor.yy602); } break; case 130: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy601); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy874); } break; case 132: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy601); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy874); } break; case 133: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy841, yymsp[0].minor.yy600); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy767, yymsp[0].minor.yy602); } break; case 134: /* cmd ::= ALTER TABLE alter_table_clause */ - case 321: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==321); -{ pCxt->pRootNode = yymsp[0].minor.yy600; } + case 327: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==327); +{ pCxt->pRootNode = yymsp[0].minor.yy602; } break; case 135: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy600); } +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy602); } break; case 136: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy600 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy602, yymsp[0].minor.yy602); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; case 137: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy600 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy600, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy77, yymsp[0].minor.yy888); } - yymsp[-4].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy602, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy179, yymsp[0].minor.yy394); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; case 138: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy600 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy600, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy77); } - yymsp[-3].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy602, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy179); } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; case 139: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy600 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy600, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy77, yymsp[0].minor.yy888); } - yymsp[-4].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy602, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy179, yymsp[0].minor.yy394); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; case 140: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy600 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy600, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy77, &yymsp[0].minor.yy77); } - yymsp[-4].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy602, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy179, &yymsp[0].minor.yy179); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; case 141: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy600 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy600, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy77, yymsp[0].minor.yy888); } - yymsp[-4].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy602, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy179, yymsp[0].minor.yy394); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; case 142: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy600 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy600, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy77); } - yymsp[-3].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy602, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy179); } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; case 143: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy600 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy600, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy77, yymsp[0].minor.yy888); } - yymsp[-4].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy602, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy179, yymsp[0].minor.yy394); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; case 144: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy600 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy600, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy77, &yymsp[0].minor.yy77); } - yymsp[-4].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy602, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy179, &yymsp[0].minor.yy179); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; case 145: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy600 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy600, &yymsp[-2].minor.yy77, yymsp[0].minor.yy600); } - yymsp[-5].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy602, &yymsp[-2].minor.yy179, yymsp[0].minor.yy602); } + yymsp[-5].minor.yy602 = yylhsminor.yy602; break; case 147: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 150: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==150); - case 420: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==420); -{ yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-1].minor.yy601, yymsp[0].minor.yy600); } - yymsp[-1].minor.yy601 = yylhsminor.yy601; + case 427: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==427); +{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-1].minor.yy874, yymsp[0].minor.yy602); } + yymsp[-1].minor.yy874 = yylhsminor.yy874; break; case 148: /* 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.yy600 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy841, yymsp[-8].minor.yy600, yymsp[-6].minor.yy600, yymsp[-5].minor.yy601, yymsp[-2].minor.yy601, yymsp[0].minor.yy600); } - yymsp[-9].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy767, yymsp[-8].minor.yy602, yymsp[-6].minor.yy602, yymsp[-5].minor.yy874, yymsp[-2].minor.yy874, yymsp[0].minor.yy602); } + yymsp[-9].minor.yy602 = yylhsminor.yy602; break; case 151: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy600 = createDropTableClause(pCxt, yymsp[-1].minor.yy841, yymsp[0].minor.yy600); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createDropTableClause(pCxt, yymsp[-1].minor.yy767, yymsp[0].minor.yy602); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; case 152: /* specific_cols_opt ::= */ case 183: /* tags_def_opt ::= */ yytestcase(yyruleno==183); - case 253: /* tag_list_opt ::= */ yytestcase(yyruleno==253); - case 483: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==483); - case 506: /* group_by_clause_opt ::= */ yytestcase(yyruleno==506); - case 525: /* order_by_clause_opt ::= */ yytestcase(yyruleno==525); -{ yymsp[1].minor.yy601 = NULL; } + case 255: /* tag_list_opt ::= */ yytestcase(yyruleno==255); + case 306: /* col_list_opt ::= */ yytestcase(yyruleno==306); + case 490: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==490); + case 513: /* group_by_clause_opt ::= */ yytestcase(yyruleno==513); + case 532: /* order_by_clause_opt ::= */ yytestcase(yyruleno==532); +{ yymsp[1].minor.yy874 = NULL; } break; case 153: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy601 = yymsp[-1].minor.yy601; } + case 307: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==307); +{ yymsp[-2].minor.yy874 = yymsp[-1].minor.yy874; } break; case 154: /* full_table_name ::= table_name */ -{ yylhsminor.yy600 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy77, NULL); } - yymsp[0].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy179, NULL); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; case 155: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy600 = createRealTableNode(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy77, NULL); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createRealTableNode(pCxt, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy179, NULL); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 158: /* column_def ::= column_name type_name */ -{ yylhsminor.yy600 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy77, yymsp[0].minor.yy888, NULL); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy179, yymsp[0].minor.yy394, NULL); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; case 159: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy600 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy77, yymsp[-2].minor.yy888, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy179, yymsp[-2].minor.yy394, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; case 160: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 161: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 162: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 163: /* type_name ::= INT */ case 164: /* type_name ::= INTEGER */ yytestcase(yyruleno==164); -{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_INT); } break; case 165: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 166: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 167: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 168: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy888 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy394 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 169: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 170: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy888 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy394 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 171: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy888 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy394 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 172: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy888 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy394 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 173: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy888 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy394 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 174: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy888 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy394 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 175: /* type_name ::= JSON */ -{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 176: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy888 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy394 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 177: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 178: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 179: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy888 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy394 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 180: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy394 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 181: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy888 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy394 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 182: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy888 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy394 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 184: /* tags_def_opt ::= tags_def */ - case 412: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==412); -{ yylhsminor.yy601 = yymsp[0].minor.yy601; } - yymsp[0].minor.yy601 = yylhsminor.yy601; + case 419: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==419); +{ yylhsminor.yy874 = yymsp[0].minor.yy874; } + yymsp[0].minor.yy874 = yylhsminor.yy874; break; case 185: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy601 = yymsp[-1].minor.yy601; } +{ yymsp[-3].minor.yy874 = yymsp[-1].minor.yy874; } break; case 186: /* table_options ::= */ -{ yymsp[1].minor.yy600 = createDefaultTableOptions(pCxt); } +{ yymsp[1].minor.yy602 = createDefaultTableOptions(pCxt); } break; case 187: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy600 = setTableOption(pCxt, yymsp[-2].minor.yy600, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setTableOption(pCxt, yymsp[-2].minor.yy602, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 188: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy600 = setTableOption(pCxt, yymsp[-2].minor.yy600, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy601); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setTableOption(pCxt, yymsp[-2].minor.yy602, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy874); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 189: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy600 = setTableOption(pCxt, yymsp[-2].minor.yy600, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy601); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setTableOption(pCxt, yymsp[-2].minor.yy602, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy874); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 190: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy600 = setTableOption(pCxt, yymsp[-4].minor.yy600, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy601); } - yymsp[-4].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setTableOption(pCxt, yymsp[-4].minor.yy602, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy874); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; case 191: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy600 = setTableOption(pCxt, yymsp[-2].minor.yy600, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setTableOption(pCxt, yymsp[-2].minor.yy602, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 192: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy600 = setTableOption(pCxt, yymsp[-4].minor.yy600, TABLE_OPTION_SMA, yymsp[-1].minor.yy601); } - yymsp[-4].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setTableOption(pCxt, yymsp[-4].minor.yy602, TABLE_OPTION_SMA, yymsp[-1].minor.yy874); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; case 193: /* table_options ::= table_options DELETE_MARK duration_list */ -{ yylhsminor.yy600 = setTableOption(pCxt, yymsp[-2].minor.yy600, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy601); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setTableOption(pCxt, yymsp[-2].minor.yy602, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy874); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; case 194: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy600 = createAlterTableOptions(pCxt); yylhsminor.yy600 = setTableOption(pCxt, yylhsminor.yy600, yymsp[0].minor.yy661.type, &yymsp[0].minor.yy661.val); } - yymsp[0].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createAlterTableOptions(pCxt); yylhsminor.yy602 = setTableOption(pCxt, yylhsminor.yy602, yymsp[0].minor.yy845.type, &yymsp[0].minor.yy845.val); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; case 195: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy600 = setTableOption(pCxt, yymsp[-1].minor.yy600, yymsp[0].minor.yy661.type, &yymsp[0].minor.yy661.val); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = setTableOption(pCxt, yymsp[-1].minor.yy602, yymsp[0].minor.yy845.type, &yymsp[0].minor.yy845.val); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; case 196: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy661.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 197: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy661.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 198: /* duration_list ::= duration_literal */ - case 376: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==376); -{ yylhsminor.yy601 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy600)); } - yymsp[0].minor.yy601 = yylhsminor.yy601; + case 383: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==383); +{ yylhsminor.yy874 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy602)); } + yymsp[0].minor.yy874 = yylhsminor.yy874; break; case 199: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 377: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==377); -{ yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, releaseRawExprNode(pCxt, yymsp[0].minor.yy600)); } - yymsp[-2].minor.yy601 = yylhsminor.yy601; + case 384: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==384); +{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-2].minor.yy874, releaseRawExprNode(pCxt, yymsp[0].minor.yy602)); } + yymsp[-2].minor.yy874 = yylhsminor.yy874; break; case 202: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy600 = createFunctionNode(pCxt, &yymsp[0].minor.yy77, NULL); } - yymsp[0].minor.yy600 = yylhsminor.yy600; +{ yylhsminor.yy602 = createFunctionNode(pCxt, &yymsp[0].minor.yy179, NULL); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; case 203: /* rollup_func_name ::= FIRST */ case 204: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==204); - case 257: /* tag_item ::= QTAGS */ yytestcase(yyruleno==257); -{ yylhsminor.yy600 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy600 = yylhsminor.yy600; + case 259: /* tag_item ::= QTAGS */ yytestcase(yyruleno==259); +{ yylhsminor.yy602 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; case 207: /* col_name ::= column_name */ - case 258: /* tag_item ::= column_name */ yytestcase(yyruleno==258); -{ yylhsminor.yy600 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy77); } - yymsp[0].minor.yy600 = yylhsminor.yy600; + case 260: /* tag_item ::= column_name */ yytestcase(yyruleno==260); +{ yylhsminor.yy602 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy179); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; case 208: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } @@ -4448,13 +4424,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } break; case 212: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy600, yymsp[0].minor.yy600, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy602, yymsp[0].minor.yy602, OP_TYPE_LIKE); } break; case 213: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy600, yymsp[0].minor.yy600, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy602, yymsp[0].minor.yy602, OP_TYPE_LIKE); } break; case 214: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy600, NULL, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy602, NULL, OP_TYPE_LIKE); } break; case 215: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } @@ -4466,7 +4442,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; case 218: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy600, yymsp[-1].minor.yy600, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy602, yymsp[-1].minor.yy602, OP_TYPE_EQUAL); } break; case 219: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } @@ -4485,13 +4461,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } break; case 225: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy77); } +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy179); } break; case 226: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy600); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy602); } break; case 227: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy600); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy602); } break; case 228: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } @@ -4510,7 +4486,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } break; case 234: /* 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.yy600); } +{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy602); } break; case 235: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } @@ -4525,7 +4501,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; case 239: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy600); } +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy602); } break; case 240: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } @@ -4534,10 +4510,10 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; case 242: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy600, yymsp[-1].minor.yy600, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy602, yymsp[-1].minor.yy602, OP_TYPE_EQUAL); } break; case 243: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy600, yymsp[0].minor.yy600, yymsp[-3].minor.yy601); } +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy602, yymsp[0].minor.yy602, yymsp[-3].minor.yy874); } break; case 244: /* cmd ::= SHOW VNODES NK_INTEGER */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } @@ -4545,742 +4521,756 @@ static YYACTIONTYPE yy_reduce( case 245: /* cmd ::= SHOW VNODES NK_STRING */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, createValueNode(pCxt, TSDB_DATA_TYPE_VARCHAR, &yymsp[0].minor.yy0)); } break; - case 246: /* db_name_cond_opt ::= */ - case 251: /* from_db_opt ::= */ yytestcase(yyruleno==251); -{ yymsp[1].minor.yy600 = createDefaultDatabaseCondValue(pCxt); } + case 246: /* cmd ::= SHOW db_name_cond_opt ALIVE */ +{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy602, QUERY_NODE_SHOW_DB_ALIVE_STMT); } + break; + case 247: /* cmd ::= SHOW CLUSTER ALIVE */ +{ pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } + break; + case 248: /* db_name_cond_opt ::= */ + case 253: /* from_db_opt ::= */ yytestcase(yyruleno==253); +{ yymsp[1].minor.yy602 = createDefaultDatabaseCondValue(pCxt); } + break; + case 249: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy602 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy179); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; + break; + case 250: /* like_pattern_opt ::= */ + case 315: /* subtable_opt ::= */ yytestcase(yyruleno==315); + case 429: /* case_when_else_opt ::= */ yytestcase(yyruleno==429); + case 459: /* from_clause_opt ::= */ yytestcase(yyruleno==459); + case 488: /* where_clause_opt ::= */ yytestcase(yyruleno==488); + case 497: /* twindow_clause_opt ::= */ yytestcase(yyruleno==497); + case 503: /* sliding_opt ::= */ yytestcase(yyruleno==503); + case 505: /* fill_opt ::= */ yytestcase(yyruleno==505); + case 517: /* having_clause_opt ::= */ yytestcase(yyruleno==517); + case 519: /* range_opt ::= */ yytestcase(yyruleno==519); + case 521: /* every_opt ::= */ yytestcase(yyruleno==521); + case 534: /* slimit_clause_opt ::= */ yytestcase(yyruleno==534); + case 538: /* limit_clause_opt ::= */ yytestcase(yyruleno==538); +{ yymsp[1].minor.yy602 = NULL; } break; - case 247: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy600 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy77); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; + case 251: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 248: /* like_pattern_opt ::= */ - case 309: /* subtable_opt ::= */ yytestcase(yyruleno==309); - case 422: /* case_when_else_opt ::= */ yytestcase(yyruleno==422); - case 452: /* from_clause_opt ::= */ yytestcase(yyruleno==452); - case 481: /* where_clause_opt ::= */ yytestcase(yyruleno==481); - case 490: /* twindow_clause_opt ::= */ yytestcase(yyruleno==490); - case 496: /* sliding_opt ::= */ yytestcase(yyruleno==496); - case 498: /* fill_opt ::= */ yytestcase(yyruleno==498); - case 510: /* having_clause_opt ::= */ yytestcase(yyruleno==510); - case 512: /* range_opt ::= */ yytestcase(yyruleno==512); - case 514: /* every_opt ::= */ yytestcase(yyruleno==514); - case 527: /* slimit_clause_opt ::= */ yytestcase(yyruleno==527); - case 531: /* limit_clause_opt ::= */ yytestcase(yyruleno==531); -{ yymsp[1].minor.yy600 = NULL; } + case 252: /* table_name_cond ::= table_name */ +{ yylhsminor.yy602 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy179); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 249: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 254: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy602 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy179); } break; - case 250: /* table_name_cond ::= table_name */ -{ yylhsminor.yy600 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy77); } - yymsp[0].minor.yy600 = yylhsminor.yy600; + case 258: /* tag_item ::= TBNAME */ +{ yylhsminor.yy602 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 252: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy600 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy77); } + case 261: /* tag_item ::= column_name column_alias */ +{ yylhsminor.yy602 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy179), &yymsp[0].minor.yy179); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 256: /* tag_item ::= TBNAME */ -{ yylhsminor.yy600 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } - yymsp[0].minor.yy600 = yylhsminor.yy600; + case 262: /* tag_item ::= column_name AS column_alias */ +{ yylhsminor.yy602 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy179), &yymsp[0].minor.yy179); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 259: /* tag_item ::= column_name column_alias */ -{ yylhsminor.yy600 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy77), &yymsp[0].minor.yy77); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; + case 263: /* cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy767, yymsp[-3].minor.yy602, yymsp[-1].minor.yy602, NULL, yymsp[0].minor.yy602); } break; - case 260: /* tag_item ::= column_name AS column_alias */ -{ yylhsminor.yy600 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy77), &yymsp[0].minor.yy77); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 264: /* cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy767, yymsp[-5].minor.yy602, yymsp[-3].minor.yy602, yymsp[-1].minor.yy874, NULL); } break; - case 261: /* 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.yy841, yymsp[-3].minor.yy600, yymsp[-1].minor.yy600, NULL, yymsp[0].minor.yy600); } + case 265: /* cmd ::= DROP INDEX exists_opt full_index_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy767, yymsp[0].minor.yy602); } break; - case 262: /* cmd ::= CREATE INDEX not_exists_opt full_table_name ON full_table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy841, yymsp[-5].minor.yy600, yymsp[-3].minor.yy600, yymsp[-1].minor.yy601, NULL); } + case 266: /* full_index_name ::= index_name */ +{ yylhsminor.yy602 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy179); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 263: /* cmd ::= DROP INDEX exists_opt full_table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy841, yymsp[0].minor.yy600); } + case 267: /* full_index_name ::= db_name NK_DOT index_name */ +{ yylhsminor.yy602 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy179); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 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.yy600 = createIndexOption(pCxt, yymsp[-7].minor.yy601, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), NULL, yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } + case 268: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-9].minor.yy602 = createIndexOption(pCxt, yymsp[-7].minor.yy874, releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), NULL, yymsp[-1].minor.yy602, yymsp[0].minor.yy602); } break; - case 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.yy600 = createIndexOption(pCxt, yymsp[-9].minor.yy601, releaseRawExprNode(pCxt, yymsp[-5].minor.yy600), releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } + case 269: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-11].minor.yy602 = createIndexOption(pCxt, yymsp[-9].minor.yy874, releaseRawExprNode(pCxt, yymsp[-5].minor.yy602), releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), yymsp[-1].minor.yy602, yymsp[0].minor.yy602); } break; - case 268: /* func ::= sma_func_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy600 = createFunctionNode(pCxt, &yymsp[-3].minor.yy77, yymsp[-1].minor.yy601); } - yymsp[-3].minor.yy600 = yylhsminor.yy600; + case 272: /* func ::= sma_func_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy602 = createFunctionNode(pCxt, &yymsp[-3].minor.yy179, yymsp[-1].minor.yy874); } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; - case 274: /* sma_stream_opt ::= */ - case 302: /* stream_options ::= */ yytestcase(yyruleno==302); -{ yymsp[1].minor.yy600 = createStreamOptions(pCxt); } + case 278: /* sma_stream_opt ::= */ + case 308: /* stream_options ::= */ yytestcase(yyruleno==308); +{ yymsp[1].minor.yy602 = createStreamOptions(pCxt); } break; - case 275: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - case 306: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==306); -{ ((SStreamOptions*)yymsp[-2].minor.yy600)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy600); yylhsminor.yy600 = yymsp[-2].minor.yy600; } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 279: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + case 312: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==312); +{ ((SStreamOptions*)yymsp[-2].minor.yy602)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy602); yylhsminor.yy602 = yymsp[-2].minor.yy602; } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 276: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy600)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy600); yylhsminor.yy600 = yymsp[-2].minor.yy600; } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 280: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy602)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy602); yylhsminor.yy602 = yymsp[-2].minor.yy602; } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 277: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy600)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy600); yylhsminor.yy600 = yymsp[-2].minor.yy600; } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 281: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy602)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy602); yylhsminor.yy602 = yymsp[-2].minor.yy602; } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 278: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy841, &yymsp[-2].minor.yy77, yymsp[0].minor.yy600); } + case 282: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy767, &yymsp[-2].minor.yy179, yymsp[0].minor.yy602); } break; - case 279: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy841, &yymsp[-3].minor.yy77, &yymsp[0].minor.yy77, false); } + case 283: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy767, &yymsp[-3].minor.yy179, &yymsp[0].minor.yy179, false); } break; - case 280: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy841, &yymsp[-5].minor.yy77, &yymsp[0].minor.yy77, true); } + case 284: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy767, &yymsp[-5].minor.yy179, &yymsp[0].minor.yy179, true); } break; - case 281: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy841, &yymsp[-3].minor.yy77, yymsp[0].minor.yy600, false); } + case 285: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy767, &yymsp[-3].minor.yy179, yymsp[0].minor.yy602, false); } break; - case 282: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy841, &yymsp[-5].minor.yy77, yymsp[0].minor.yy600, true); } + case 286: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy767, &yymsp[-5].minor.yy179, yymsp[0].minor.yy602, true); } break; - case 283: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy841, &yymsp[0].minor.yy77); } + case 287: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy767, &yymsp[0].minor.yy179); } break; - case 284: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy841, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy77); } + case 288: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy767, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy179); } break; - case 285: /* cmd ::= DESC full_table_name */ - case 286: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==286); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy600); } + case 289: /* cmd ::= DESC full_table_name */ + case 290: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==290); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy602); } break; - case 287: /* cmd ::= RESET QUERY CACHE */ + case 291: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 288: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy841, yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } + case 292: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy767, yymsp[-1].minor.yy602, yymsp[0].minor.yy602); } break; - case 291: /* explain_options ::= */ -{ yymsp[1].minor.yy600 = createDefaultExplainOptions(pCxt); } + case 295: /* explain_options ::= */ +{ yymsp[1].minor.yy602 = createDefaultExplainOptions(pCxt); } break; - case 292: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy600 = setExplainVerbose(pCxt, yymsp[-2].minor.yy600, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 296: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy602 = setExplainVerbose(pCxt, yymsp[-2].minor.yy602, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 293: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy600 = setExplainRatio(pCxt, yymsp[-2].minor.yy600, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 297: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy602 = setExplainRatio(pCxt, yymsp[-2].minor.yy602, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 294: /* 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.yy841, yymsp[-8].minor.yy841, &yymsp[-5].minor.yy77, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy888, yymsp[0].minor.yy248); } + case 298: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy767, yymsp[-8].minor.yy767, &yymsp[-5].minor.yy179, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy820); } break; - case 295: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy841, &yymsp[0].minor.yy77); } + case 299: /* cmd ::= DROP FUNCTION exists_opt function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy767, &yymsp[0].minor.yy179); } break; - case 300: /* 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.yy841, &yymsp[-7].minor.yy77, yymsp[-4].minor.yy600, yymsp[-6].minor.yy600, yymsp[-3].minor.yy601, yymsp[-2].minor.yy600, yymsp[0].minor.yy600); } + case 304: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tags_def_opt subtable_opt AS query_or_subquery */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy767, &yymsp[-8].minor.yy179, yymsp[-5].minor.yy602, yymsp[-7].minor.yy602, yymsp[-3].minor.yy874, yymsp[-2].minor.yy602, yymsp[0].minor.yy602, yymsp[-4].minor.yy874); } break; - case 301: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy841, &yymsp[0].minor.yy77); } + case 305: /* cmd ::= DROP STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy767, &yymsp[0].minor.yy179); } break; - case 303: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy600)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy600 = yymsp[-2].minor.yy600; } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 309: /* stream_options ::= stream_options TRIGGER AT_ONCE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy602)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy602 = yymsp[-2].minor.yy602; } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 304: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy600)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy600 = yymsp[-2].minor.yy600; } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 310: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy602)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy602 = yymsp[-2].minor.yy602; } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 305: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-3].minor.yy600)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy600)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy600); yylhsminor.yy600 = yymsp[-3].minor.yy600; } - yymsp[-3].minor.yy600 = yylhsminor.yy600; + case 311: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-3].minor.yy602)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy602)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy602); yylhsminor.yy602 = yymsp[-3].minor.yy602; } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; - case 307: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -{ ((SStreamOptions*)yymsp[-3].minor.yy600)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy600 = yymsp[-3].minor.yy600; } - yymsp[-3].minor.yy600 = yylhsminor.yy600; + case 313: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ +{ ((SStreamOptions*)yymsp[-3].minor.yy602)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy602 = yymsp[-3].minor.yy602; } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; - case 308: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ -{ ((SStreamOptions*)yymsp[-2].minor.yy600)->fillHistory = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy600 = yymsp[-2].minor.yy600; } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 314: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ +{ ((SStreamOptions*)yymsp[-2].minor.yy602)->fillHistory = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy602 = yymsp[-2].minor.yy602; } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 310: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 497: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==497); - case 515: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==515); -{ yymsp[-3].minor.yy600 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy600); } + case 316: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 504: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==504); + case 522: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==522); +{ yymsp[-3].minor.yy602 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy602); } break; - case 311: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 317: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 312: /* cmd ::= KILL QUERY NK_STRING */ + case 318: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 313: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 319: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 314: /* cmd ::= BALANCE VGROUP */ + case 320: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 315: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 321: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 316: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy601); } + case 322: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy874); } break; - case 317: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 323: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 318: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy601 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - break; - case 320: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } - break; - case 322: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy600, yymsp[-2].minor.yy601, yymsp[0].minor.yy600); } - break; - case 323: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy600, NULL, yymsp[0].minor.yy600); } - break; - case 324: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 325: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 326: /* literal ::= NK_STRING */ -{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 327: /* literal ::= NK_BOOL */ -{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 328: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; - break; - case 329: /* literal ::= duration_literal */ - case 339: /* signed_literal ::= signed */ yytestcase(yyruleno==339); - case 359: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==359); - case 360: /* expression ::= literal */ yytestcase(yyruleno==360); - case 361: /* expression ::= pseudo_column */ yytestcase(yyruleno==361); - case 362: /* expression ::= column_reference */ yytestcase(yyruleno==362); - case 363: /* expression ::= function_expression */ yytestcase(yyruleno==363); - case 364: /* expression ::= case_when_expression */ yytestcase(yyruleno==364); - case 395: /* function_expression ::= literal_func */ yytestcase(yyruleno==395); - case 444: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==444); - case 448: /* boolean_primary ::= predicate */ yytestcase(yyruleno==448); - case 450: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==450); - case 451: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==451); - case 454: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==454); - case 456: /* table_reference ::= table_primary */ yytestcase(yyruleno==456); - case 457: /* table_reference ::= joined_table */ yytestcase(yyruleno==457); - case 461: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==461); - case 517: /* query_simple ::= query_specification */ yytestcase(yyruleno==517); - case 518: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==518); - case 521: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==521); - case 523: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==523); -{ yylhsminor.yy600 = yymsp[0].minor.yy600; } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 330: /* literal ::= NULL */ -{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 331: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 332: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 333: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 334: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - break; - case 335: /* signed ::= NK_MINUS NK_INTEGER */ + case 324: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy874 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + break; + case 326: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy602, yymsp[0].minor.yy602); } + break; + case 328: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy602, yymsp[-2].minor.yy874, yymsp[0].minor.yy602); } + break; + case 329: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy602, NULL, yymsp[0].minor.yy602); } + break; + case 330: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; + break; + case 331: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; + break; + case 332: /* literal ::= NK_STRING */ +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; + break; + case 333: /* literal ::= NK_BOOL */ +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; + break; + case 334: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; + break; + case 335: /* literal ::= duration_literal */ + case 345: /* signed_literal ::= signed */ yytestcase(yyruleno==345); + case 366: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==366); + case 367: /* expression ::= literal */ yytestcase(yyruleno==367); + case 368: /* expression ::= pseudo_column */ yytestcase(yyruleno==368); + case 369: /* expression ::= column_reference */ yytestcase(yyruleno==369); + case 370: /* expression ::= function_expression */ yytestcase(yyruleno==370); + case 371: /* expression ::= case_when_expression */ yytestcase(yyruleno==371); + case 402: /* function_expression ::= literal_func */ yytestcase(yyruleno==402); + case 451: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==451); + case 455: /* boolean_primary ::= predicate */ yytestcase(yyruleno==455); + case 457: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==457); + case 458: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==458); + case 461: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==461); + case 463: /* table_reference ::= table_primary */ yytestcase(yyruleno==463); + case 464: /* table_reference ::= joined_table */ yytestcase(yyruleno==464); + case 468: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==468); + case 524: /* query_simple ::= query_specification */ yytestcase(yyruleno==524); + case 525: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==525); + case 528: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==528); + case 530: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==530); +{ yylhsminor.yy602 = yymsp[0].minor.yy602; } + yymsp[0].minor.yy602 = yylhsminor.yy602; + break; + case 336: /* literal ::= NULL */ +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; + break; + case 337: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; + break; + case 338: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; + break; + case 339: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy602 = yylhsminor.yy602; + break; + case 340: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + break; + case 341: /* 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.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 336: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy600 = yylhsminor.yy600; + case 342: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 337: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 343: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 338: /* signed ::= NK_MINUS NK_FLOAT */ + case 344: /* 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.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; - break; - case 340: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 341: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 342: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } - break; - case 343: /* signed_literal ::= duration_literal */ - case 345: /* signed_literal ::= literal_func */ yytestcase(yyruleno==345); - case 415: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==415); - case 477: /* select_item ::= common_expression */ yytestcase(yyruleno==477); - case 487: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==487); - case 522: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==522); - case 524: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==524); - case 537: /* search_condition ::= common_expression */ yytestcase(yyruleno==537); -{ yylhsminor.yy600 = releaseRawExprNode(pCxt, yymsp[0].minor.yy600); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 344: /* signed_literal ::= NULL */ -{ yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 346: /* signed_literal ::= NK_QUESTION */ -{ yylhsminor.yy600 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 365: /* expression ::= NK_LP expression NK_RP */ - case 449: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==449); - case 536: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==536); -{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy600)); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; - break; - case 366: /* expression ::= NK_PLUS expr_or_subquery */ + yymsp[-1].minor.yy602 = yylhsminor.yy602; + break; + case 346: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy602 = yylhsminor.yy602; + break; + case 347: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy602 = yylhsminor.yy602; + break; + case 348: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + break; + case 349: /* signed_literal ::= duration_literal */ + case 351: /* signed_literal ::= literal_func */ yytestcase(yyruleno==351); + case 422: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==422); + case 484: /* select_item ::= common_expression */ yytestcase(yyruleno==484); + case 494: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==494); + case 529: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==529); + case 531: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==531); + case 544: /* search_condition ::= common_expression */ yytestcase(yyruleno==544); +{ yylhsminor.yy602 = releaseRawExprNode(pCxt, yymsp[0].minor.yy602); } + yymsp[0].minor.yy602 = yylhsminor.yy602; + break; + case 350: /* signed_literal ::= NULL */ +{ yylhsminor.yy602 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy602 = yylhsminor.yy602; + break; + case 352: /* signed_literal ::= NK_QUESTION */ +{ yylhsminor.yy602 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy602 = yylhsminor.yy602; + break; + case 372: /* expression ::= NK_LP expression NK_RP */ + case 456: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==456); + case 543: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==543); +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy602)); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; + break; + case 373: /* expression ::= NK_PLUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy600)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy602)); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 367: /* expression ::= NK_MINUS expr_or_subquery */ + case 374: /* expression ::= NK_MINUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy600), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy602), NULL)); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 368: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + case 375: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 369: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + case 376: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 370: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + case 377: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 371: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + case 378: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 372: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ + case 379: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 373: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 380: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 374: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + case 381: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 375: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + case 382: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; - break; - case 378: /* column_reference ::= column_name */ -{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy77, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy77)); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 379: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy77, createColumnNode(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy77)); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; - break; - case 380: /* pseudo_column ::= ROWTS */ - case 381: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==381); - case 383: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==383); - case 384: /* pseudo_column ::= QEND */ yytestcase(yyruleno==384); - case 385: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==385); - case 386: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==386); - case 387: /* pseudo_column ::= WEND */ yytestcase(yyruleno==387); - case 388: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==388); - case 389: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==389); - case 390: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==390); - case 391: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==391); - case 397: /* literal_func ::= NOW */ yytestcase(yyruleno==397); -{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 382: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy77)))); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; - break; - case 392: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 393: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==393); -{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy77, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy77, yymsp[-1].minor.yy601)); } - yymsp[-3].minor.yy600 = yylhsminor.yy600; - break; - case 394: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ -{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), yymsp[-1].minor.yy888)); } - yymsp[-5].minor.yy600 = yylhsminor.yy600; - break; - case 396: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy77, NULL)); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; - break; - case 411: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy601 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy601 = yylhsminor.yy601; - break; - case 416: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 480: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==480); -{ yylhsminor.yy600 = createColumnNode(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; - break; - case 417: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy601, yymsp[-1].minor.yy600)); } - yymsp[-3].minor.yy600 = yylhsminor.yy600; - break; - case 418: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), yymsp[-2].minor.yy601, yymsp[-1].minor.yy600)); } - yymsp[-4].minor.yy600 = yylhsminor.yy600; - break; - case 421: /* when_then_expr ::= WHEN common_expression THEN common_expression */ -{ yymsp[-3].minor.yy600 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600)); } - break; - case 423: /* case_when_else_opt ::= ELSE common_expression */ -{ yymsp[-1].minor.yy600 = releaseRawExprNode(pCxt, yymsp[0].minor.yy600); } - break; - case 424: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 429: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==429); + yymsp[-2].minor.yy602 = yylhsminor.yy602; + break; + case 385: /* column_reference ::= column_name */ +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy179, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy179)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; + break; + case 386: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy179, createColumnNode(pCxt, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy179)); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; + break; + case 387: /* pseudo_column ::= ROWTS */ + case 388: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==388); + case 390: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==390); + case 391: /* pseudo_column ::= QEND */ yytestcase(yyruleno==391); + case 392: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==392); + case 393: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==393); + case 394: /* pseudo_column ::= WEND */ yytestcase(yyruleno==394); + case 395: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==395); + case 396: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==396); + case 397: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==397); + case 398: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==398); + case 404: /* literal_func ::= NOW */ yytestcase(yyruleno==404); +{ yylhsminor.yy602 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy602 = yylhsminor.yy602; + break; + case 389: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy179)))); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; + break; + case 399: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 400: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==400); +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy179, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy179, yymsp[-1].minor.yy874)); } + yymsp[-3].minor.yy602 = yylhsminor.yy602; + break; + case 401: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), yymsp[-1].minor.yy394)); } + yymsp[-5].minor.yy602 = yylhsminor.yy602; + break; + case 403: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy179, NULL)); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; + break; + case 418: /* 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 423: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 487: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==487); +{ yylhsminor.yy602 = createColumnNode(pCxt, &yymsp[-2].minor.yy179, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; + break; + case 424: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy874, yymsp[-1].minor.yy602)); } + yymsp[-3].minor.yy602 = yylhsminor.yy602; + break; + case 425: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), yymsp[-2].minor.yy874, yymsp[-1].minor.yy602)); } + yymsp[-4].minor.yy602 = yylhsminor.yy602; + break; + case 428: /* when_then_expr ::= WHEN common_expression THEN common_expression */ +{ yymsp[-3].minor.yy602 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602)); } + break; + case 430: /* case_when_else_opt ::= ELSE common_expression */ +{ yymsp[-1].minor.yy602 = releaseRawExprNode(pCxt, yymsp[0].minor.yy602); } + break; + case 431: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 436: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==436); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy666, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy290, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 425: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + case 432: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy600); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy600), releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy602), releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-4].minor.yy600 = yylhsminor.yy600; + yymsp[-4].minor.yy602 = yylhsminor.yy602; break; - case 426: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + case 433: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy600); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy600), releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy602), releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-5].minor.yy600 = yylhsminor.yy600; + yymsp[-5].minor.yy602 = yylhsminor.yy602; break; - case 427: /* predicate ::= expr_or_subquery IS NULL */ + case 434: /* predicate ::= expr_or_subquery IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), NULL)); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 428: /* predicate ::= expr_or_subquery IS NOT NULL */ + case 435: /* predicate ::= expr_or_subquery IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), NULL)); } - yymsp[-3].minor.yy600 = yylhsminor.yy600; + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; - case 430: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy666 = OP_TYPE_LOWER_THAN; } + case 437: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy290 = OP_TYPE_LOWER_THAN; } break; - case 431: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy666 = OP_TYPE_GREATER_THAN; } + case 438: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy290 = OP_TYPE_GREATER_THAN; } break; - case 432: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy666 = OP_TYPE_LOWER_EQUAL; } + case 439: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy290 = OP_TYPE_LOWER_EQUAL; } break; - case 433: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy666 = OP_TYPE_GREATER_EQUAL; } + case 440: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy290 = OP_TYPE_GREATER_EQUAL; } break; - case 434: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy666 = OP_TYPE_NOT_EQUAL; } + case 441: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy290 = OP_TYPE_NOT_EQUAL; } break; - case 435: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy666 = OP_TYPE_EQUAL; } + case 442: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy290 = OP_TYPE_EQUAL; } break; - case 436: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy666 = OP_TYPE_LIKE; } + case 443: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy290 = OP_TYPE_LIKE; } break; - case 437: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy666 = OP_TYPE_NOT_LIKE; } + case 444: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy290 = OP_TYPE_NOT_LIKE; } break; - case 438: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy666 = OP_TYPE_MATCH; } + case 445: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy290 = OP_TYPE_MATCH; } break; - case 439: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy666 = OP_TYPE_NMATCH; } + case 446: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy290 = OP_TYPE_NMATCH; } break; - case 440: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy666 = OP_TYPE_JSON_CONTAINS; } + case 447: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy290 = OP_TYPE_JSON_CONTAINS; } break; - case 441: /* in_op ::= IN */ -{ yymsp[0].minor.yy666 = OP_TYPE_IN; } + case 448: /* in_op ::= IN */ +{ yymsp[0].minor.yy290 = OP_TYPE_IN; } break; - case 442: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy666 = OP_TYPE_NOT_IN; } + case 449: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy290 = OP_TYPE_NOT_IN; } break; - case 443: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy601)); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 450: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy874)); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 445: /* boolean_value_expression ::= NOT boolean_primary */ + case 452: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy600), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy602), NULL)); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 446: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 453: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 447: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 454: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); - yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy602); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy602); + yylhsminor.yy602 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 453: /* from_clause_opt ::= FROM table_reference_list */ - case 482: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==482); - case 511: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==511); -{ yymsp[-1].minor.yy600 = yymsp[0].minor.yy600; } + case 460: /* from_clause_opt ::= FROM table_reference_list */ + case 489: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==489); + case 518: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==518); +{ yymsp[-1].minor.yy602 = yymsp[0].minor.yy602; } break; - case 455: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy600 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy600, yymsp[0].minor.yy600, NULL); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 462: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy602 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy602, yymsp[0].minor.yy602, NULL); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 458: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy600 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy77, &yymsp[0].minor.yy77); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; + case 465: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy602 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy179, &yymsp[0].minor.yy179); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 459: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy600 = createRealTableNode(pCxt, &yymsp[-3].minor.yy77, &yymsp[-1].minor.yy77, &yymsp[0].minor.yy77); } - yymsp[-3].minor.yy600 = yylhsminor.yy600; + case 466: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy602 = createRealTableNode(pCxt, &yymsp[-3].minor.yy179, &yymsp[-1].minor.yy179, &yymsp[0].minor.yy179); } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; - case 460: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy600 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy600), &yymsp[0].minor.yy77); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; + case 467: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy602 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy602), &yymsp[0].minor.yy179); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 462: /* alias_opt ::= */ -{ yymsp[1].minor.yy77 = nil_token; } + case 469: /* alias_opt ::= */ +{ yymsp[1].minor.yy179 = nil_token; } break; - case 464: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy77 = yymsp[0].minor.yy77; } + case 471: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy179 = yymsp[0].minor.yy179; } break; - case 465: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 466: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==466); -{ yymsp[-2].minor.yy600 = yymsp[-1].minor.yy600; } + case 472: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 473: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==473); +{ yymsp[-2].minor.yy602 = yymsp[-1].minor.yy602; } break; - case 467: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy600 = createJoinTableNode(pCxt, yymsp[-4].minor.yy560, yymsp[-5].minor.yy600, yymsp[-2].minor.yy600, yymsp[0].minor.yy600); } - yymsp[-5].minor.yy600 = yylhsminor.yy600; + case 474: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy602 = createJoinTableNode(pCxt, yymsp[-4].minor.yy42, yymsp[-5].minor.yy602, yymsp[-2].minor.yy602, yymsp[0].minor.yy602); } + yymsp[-5].minor.yy602 = yylhsminor.yy602; break; - case 468: /* join_type ::= */ -{ yymsp[1].minor.yy560 = JOIN_TYPE_INNER; } + case 475: /* join_type ::= */ +{ yymsp[1].minor.yy42 = JOIN_TYPE_INNER; } break; - case 469: /* join_type ::= INNER */ -{ yymsp[0].minor.yy560 = JOIN_TYPE_INNER; } + case 476: /* join_type ::= INNER */ +{ yymsp[0].minor.yy42 = JOIN_TYPE_INNER; } break; - case 470: /* 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 477: /* 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.yy600 = createSelectStmt(pCxt, yymsp[-10].minor.yy841, yymsp[-9].minor.yy601, yymsp[-8].minor.yy600); - yymsp[-11].minor.yy600 = addWhereClause(pCxt, yymsp[-11].minor.yy600, yymsp[-7].minor.yy600); - yymsp[-11].minor.yy600 = addPartitionByClause(pCxt, yymsp[-11].minor.yy600, yymsp[-6].minor.yy601); - yymsp[-11].minor.yy600 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy600, yymsp[-2].minor.yy600); - yymsp[-11].minor.yy600 = addGroupByClause(pCxt, yymsp[-11].minor.yy600, yymsp[-1].minor.yy601); - yymsp[-11].minor.yy600 = addHavingClause(pCxt, yymsp[-11].minor.yy600, yymsp[0].minor.yy600); - yymsp[-11].minor.yy600 = addRangeClause(pCxt, yymsp[-11].minor.yy600, yymsp[-5].minor.yy600); - yymsp[-11].minor.yy600 = addEveryClause(pCxt, yymsp[-11].minor.yy600, yymsp[-4].minor.yy600); - yymsp[-11].minor.yy600 = addFillClause(pCxt, yymsp[-11].minor.yy600, yymsp[-3].minor.yy600); + yymsp[-11].minor.yy602 = createSelectStmt(pCxt, yymsp[-10].minor.yy767, yymsp[-9].minor.yy874, yymsp[-8].minor.yy602); + yymsp[-11].minor.yy602 = addWhereClause(pCxt, yymsp[-11].minor.yy602, yymsp[-7].minor.yy602); + yymsp[-11].minor.yy602 = addPartitionByClause(pCxt, yymsp[-11].minor.yy602, yymsp[-6].minor.yy874); + yymsp[-11].minor.yy602 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy602, yymsp[-2].minor.yy602); + yymsp[-11].minor.yy602 = addGroupByClause(pCxt, yymsp[-11].minor.yy602, yymsp[-1].minor.yy874); + yymsp[-11].minor.yy602 = addHavingClause(pCxt, yymsp[-11].minor.yy602, yymsp[0].minor.yy602); + yymsp[-11].minor.yy602 = addRangeClause(pCxt, yymsp[-11].minor.yy602, yymsp[-5].minor.yy602); + yymsp[-11].minor.yy602 = addEveryClause(pCxt, yymsp[-11].minor.yy602, yymsp[-4].minor.yy602); + yymsp[-11].minor.yy602 = addFillClause(pCxt, yymsp[-11].minor.yy602, yymsp[-3].minor.yy602); } break; - case 473: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy841 = false; } + case 480: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy767 = false; } break; - case 476: /* select_item ::= NK_STAR */ -{ yylhsminor.yy600 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy600 = yylhsminor.yy600; + case 483: /* select_item ::= NK_STAR */ +{ yylhsminor.yy602 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy602 = yylhsminor.yy602; break; - case 478: /* select_item ::= common_expression column_alias */ - case 488: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==488); -{ yylhsminor.yy600 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy600), &yymsp[0].minor.yy77); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; + case 485: /* select_item ::= common_expression column_alias */ + case 495: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==495); +{ yylhsminor.yy602 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy602), &yymsp[0].minor.yy179); } + yymsp[-1].minor.yy602 = yylhsminor.yy602; break; - case 479: /* select_item ::= common_expression AS column_alias */ - case 489: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==489); -{ yylhsminor.yy600 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), &yymsp[0].minor.yy77); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 486: /* select_item ::= common_expression AS column_alias */ + case 496: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==496); +{ yylhsminor.yy602 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), &yymsp[0].minor.yy179); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 484: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 507: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==507); - case 526: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==526); -{ yymsp[-2].minor.yy601 = yymsp[0].minor.yy601; } + case 491: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 514: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==514); + case 533: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==533); +{ yymsp[-2].minor.yy874 = yymsp[0].minor.yy874; } break; - case 491: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy600 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), releaseRawExprNode(pCxt, yymsp[-1].minor.yy600)); } + case 498: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy602 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), releaseRawExprNode(pCxt, yymsp[-1].minor.yy602)); } break; - case 492: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy600 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy600)); } + case 499: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ +{ yymsp[-3].minor.yy602 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy602)); } break; - case 493: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy600 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), NULL, yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } + case 500: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy602 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), NULL, yymsp[-1].minor.yy602, yymsp[0].minor.yy602); } break; - case 494: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy600 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy600), releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } + case 501: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy602 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy602), releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), yymsp[-1].minor.yy602, yymsp[0].minor.yy602); } break; - case 495: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ -{ yymsp[-6].minor.yy600 = createEventWindowNode(pCxt, yymsp[-3].minor.yy600, yymsp[0].minor.yy600); } + case 502: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ +{ yymsp[-6].minor.yy602 = createEventWindowNode(pCxt, yymsp[-3].minor.yy602, yymsp[0].minor.yy602); } break; - case 499: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy600 = createFillNode(pCxt, yymsp[-1].minor.yy798, NULL); } + case 506: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy602 = createFillNode(pCxt, yymsp[-1].minor.yy324, NULL); } break; - case 500: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy600 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy601)); } + case 507: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy602 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy874)); } break; - case 501: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy798 = FILL_MODE_NONE; } + case 508: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy324 = FILL_MODE_NONE; } break; - case 502: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy798 = FILL_MODE_PREV; } + case 509: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy324 = FILL_MODE_PREV; } break; - case 503: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy798 = FILL_MODE_NULL; } + case 510: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy324 = FILL_MODE_NULL; } break; - case 504: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy798 = FILL_MODE_LINEAR; } + case 511: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy324 = FILL_MODE_LINEAR; } break; - case 505: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy798 = FILL_MODE_NEXT; } + case 512: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy324 = FILL_MODE_NEXT; } break; - case 508: /* group_by_list ::= expr_or_subquery */ -{ yylhsminor.yy601 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } - yymsp[0].minor.yy601 = yylhsminor.yy601; + case 515: /* group_by_list ::= expr_or_subquery */ +{ yylhsminor.yy874 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } + yymsp[0].minor.yy874 = yylhsminor.yy874; break; - case 509: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -{ yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } - yymsp[-2].minor.yy601 = yylhsminor.yy601; + case 516: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ +{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-2].minor.yy874, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy602))); } + yymsp[-2].minor.yy874 = yylhsminor.yy874; break; - case 513: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -{ yymsp[-5].minor.yy600 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), releaseRawExprNode(pCxt, yymsp[-1].minor.yy600)); } + case 520: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +{ yymsp[-5].minor.yy602 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy602), releaseRawExprNode(pCxt, yymsp[-1].minor.yy602)); } break; - case 516: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 523: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy600 = addOrderByClause(pCxt, yymsp[-3].minor.yy600, yymsp[-2].minor.yy601); - yylhsminor.yy600 = addSlimitClause(pCxt, yylhsminor.yy600, yymsp[-1].minor.yy600); - yylhsminor.yy600 = addLimitClause(pCxt, yylhsminor.yy600, yymsp[0].minor.yy600); + yylhsminor.yy602 = addOrderByClause(pCxt, yymsp[-3].minor.yy602, yymsp[-2].minor.yy874); + yylhsminor.yy602 = addSlimitClause(pCxt, yylhsminor.yy602, yymsp[-1].minor.yy602); + yylhsminor.yy602 = addLimitClause(pCxt, yylhsminor.yy602, yymsp[0].minor.yy602); } - yymsp[-3].minor.yy600 = yylhsminor.yy600; + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; - case 519: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -{ yylhsminor.yy600 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy600, yymsp[0].minor.yy600); } - yymsp[-3].minor.yy600 = yylhsminor.yy600; + case 526: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +{ yylhsminor.yy602 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy602, yymsp[0].minor.yy602); } + yymsp[-3].minor.yy602 = yylhsminor.yy602; break; - case 520: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -{ yylhsminor.yy600 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy600, yymsp[0].minor.yy600); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 527: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +{ yylhsminor.yy602 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy602, yymsp[0].minor.yy602); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 528: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 532: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==532); -{ yymsp[-1].minor.yy600 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 535: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 539: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==539); +{ yymsp[-1].minor.yy602 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 529: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 533: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==533); -{ yymsp[-3].minor.yy600 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 536: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 540: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==540); +{ yymsp[-3].minor.yy602 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 530: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 534: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==534); -{ yymsp[-3].minor.yy600 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 537: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 541: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==541); +{ yymsp[-3].minor.yy602 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 535: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy600); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 542: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy602 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy602); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 540: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy600 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), yymsp[-1].minor.yy32, yymsp[0].minor.yy385); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 547: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy602 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy602), yymsp[-1].minor.yy878, yymsp[0].minor.yy487); } + yymsp[-2].minor.yy602 = yylhsminor.yy602; break; - case 541: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy32 = ORDER_ASC; } + case 548: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy878 = ORDER_ASC; } break; - case 542: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy32 = ORDER_ASC; } + case 549: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy878 = ORDER_ASC; } break; - case 543: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy32 = ORDER_DESC; } + case 550: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy878 = ORDER_DESC; } break; - case 544: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy385 = NULL_ORDER_DEFAULT; } + case 551: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy487 = NULL_ORDER_DEFAULT; } break; - case 545: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy385 = NULL_ORDER_FIRST; } + case 552: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy487 = NULL_ORDER_FIRST; } break; - case 546: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy385 = NULL_ORDER_LAST; } + case 553: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy487 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp index 9cc55a7cd55a0060635e9a9044ac076ce5a77119..ac801149f58f2aa838fae9748e92483e09e36f33 100644 --- a/source/libs/parser/test/mockCatalogService.cpp +++ b/source/libs/parser/test/mockCatalogService.cpp @@ -427,7 +427,7 @@ class MockCatalogServiceImpl { int32_t copyTableSchemaMeta(const string& db, const string& tbname, std::unique_ptr* dst) const { STableMeta* src = getTableSchemaMeta(db, tbname); if (nullptr == src) { - return TSDB_CODE_TSC_INVALID_TABLE_NAME; + return TSDB_CODE_PAR_TABLE_NOT_EXIST; } int32_t len = sizeof(STableMeta) + sizeof(SSchema) * (src->tableInfo.numOfTags + src->tableInfo.numOfColumns); dst->reset((STableMeta*)taosMemoryCalloc(1, len)); diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp index 710b04106f053be88db1c98bedd54ebce324f02d..1656940a943d7f62da684216ff66988e45677b67 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -775,14 +775,23 @@ TEST_F(ParserInitialCTest, createStream) { }; auto setCreateStreamReq = [&](const char* pStream, const char* pSrcDb, const char* pSql, const char* pDstStb, - int8_t igExists = 0, int8_t triggerType = STREAM_TRIGGER_AT_ONCE, int64_t maxDelay = 0, - int64_t watermark = 0, int8_t igExpired = STREAM_DEFAULT_IGNORE_EXPIRED, - int8_t fillHistory = STREAM_DEFAULT_FILL_HISTORY) { + int8_t createStb = STREAM_CREATE_STABLE_TRUE, int8_t igExists = 0) { snprintf(expect.name, sizeof(expect.name), "0.%s", pStream); snprintf(expect.sourceDB, sizeof(expect.sourceDB), "0.%s", pSrcDb); snprintf(expect.targetStbFullName, sizeof(expect.targetStbFullName), "0.test.%s", pDstStb); expect.igExists = igExists; expect.sql = strdup(pSql); + expect.createStb = createStb; + expect.triggerType = STREAM_TRIGGER_AT_ONCE; + expect.maxDelay = 0; + expect.watermark = 0; + expect.fillHistory = STREAM_DEFAULT_FILL_HISTORY; + expect.igExpired = STREAM_DEFAULT_IGNORE_EXPIRED; + }; + + auto setStreamOptions = [&](int8_t triggerType = STREAM_TRIGGER_AT_ONCE, int64_t maxDelay = 0, int64_t watermark = 0, + int8_t igExpired = STREAM_DEFAULT_IGNORE_EXPIRED, + int8_t fillHistory = STREAM_DEFAULT_FILL_HISTORY) { expect.triggerType = triggerType; expect.maxDelay = maxDelay; expect.watermark = watermark; @@ -833,19 +842,22 @@ TEST_F(ParserInitialCTest, createStream) { ASSERT_EQ(pField->flags, pExpectField->flags); } } + ASSERT_EQ(req.checkpointFreq, expect.checkpointFreq); + ASSERT_EQ(req.createStb, expect.createStb); tFreeSCMCreateStreamReq(&req); }); - setCreateStreamReq("s1", "test", "create stream s1 into st1 as select count(*) from t1 interval(10s)", "st1"); - run("CREATE STREAM s1 INTO st1 AS SELECT COUNT(*) FROM t1 INTERVAL(10S)"); + setCreateStreamReq("s1", "test", "create stream s1 into st3 as select count(*) from t1 interval(10s)", "st3"); + run("CREATE STREAM s1 INTO st3 AS SELECT COUNT(*) FROM t1 INTERVAL(10S)"); clearCreateStreamReq(); setCreateStreamReq( "s1", "test", - "create stream if not exists s1 trigger max_delay 20s watermark 10s ignore expired 0 fill_history 1 into st1 " + "create stream if not exists s1 trigger max_delay 20s watermark 10s ignore expired 0 fill_history 1 into st3 " "as select count(*) from t1 interval(10s)", - "st1", 1, STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_SECOND, 0, 1); - run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s IGNORE EXPIRED 0 FILL_HISTORY 1 INTO st1 AS " + "st3", 1, 1); + setStreamOptions(STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_SECOND, 0, 1); + run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s IGNORE EXPIRED 0 FILL_HISTORY 1 INTO st3 AS " "SELECT COUNT(*) " "FROM t1 INTERVAL(10S)"); clearCreateStreamReq(); @@ -859,6 +871,11 @@ TEST_F(ParserInitialCTest, createStream) { run("CREATE STREAM s1 INTO st3 TAGS(tname VARCHAR(10), id INT) SUBTABLE(CONCAT('new-', tname)) " "AS SELECT _WSTART wstart, COUNT(*) cnt FROM st1 PARTITION BY TBNAME tname, tag1 id INTERVAL(10S)"); clearCreateStreamReq(); + + setCreateStreamReq("s1", "test", "create stream s1 into st1 as select max(c1), c2 from t1 interval(10s)", "st1", + STREAM_CREATE_STABLE_FALSE); + run("CREATE STREAM s1 INTO st1 AS SELECT MAX(c1), c2 FROM t1 INTERVAL(10S)"); + clearCreateStreamReq(); } TEST_F(ParserInitialCTest, createStreamSemanticCheck) { diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 4e1e98c9c026b116e9cf67d5324b53a003a65192..559182bf7be2faaf4caa39eaa84ac1f5b045d522 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 83341d200af10a8df800b16c08818ccd2be681bf..120a8537417562a4002268ba4f897a3811b0eaa4 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1538,6 +1538,11 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub code = adjustLogicNodeDataRequirement((SLogicNode*)pScan, pNode->resultDataOrder); } if (TSDB_CODE_SUCCESS == code) { + if (QUERY_NODE_LOGIC_PLAN_AGG == pNode->pParent->type) { + SAggLogicNode* pParent = (SAggLogicNode*)(pNode->pParent); + pParent->hasGroupKeyOptimized = true; + } + NODES_CLEAR_LIST(pNode->pChildren); nodesDestroyNode((SNode*)pNode); } @@ -1563,6 +1568,8 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub break; } } + pAgg->hasGroupKeyOptimized = true; + NODES_DESTORY_LIST(pAgg->pGroupKeys); if (TSDB_CODE_SUCCESS == code && start >= 0) { code = partTagsRewriteGroupTagsToFuncs(pScan->pGroupTags, start, pAgg); @@ -1571,6 +1578,7 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub if (TSDB_CODE_SUCCESS == code) { code = partTagsOptRebuildTbanme(pScan->pGroupTags); } + pCxt->optimized = true; return code; } @@ -2374,6 +2382,9 @@ static bool tagScanOptShouldBeOptimized(SLogicNode* pNode) { if (pScan->hasNormalCols) { return false; } + if (pScan->tableType == TSDB_SYSTEM_TABLE) { + return false; + } if (NULL == pNode->pParent || QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode->pParent) || 1 != LIST_LENGTH(pNode->pParent->pChildren)) { return false; diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 78ae3c1c3b9bbf68066e53f32385f4c726a2d94d..7d6238193d7e6411cffd9bd8b092afa01e651b7a 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 f6b1babf9501e12122bdcf97e8260251c348a617..6208fc172aa4fd9a55b259f794e0d9e266bfabea 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/planner/test/planOtherTest.cpp b/source/libs/planner/test/planOtherTest.cpp index 4741d241b5ac8b5541b6f92d08dbe1dd26151099..3a12d62340f1744db5d351d7494e2e181b512d76 100644 --- a/source/libs/planner/test/planOtherTest.cpp +++ b/source/libs/planner/test/planOtherTest.cpp @@ -30,7 +30,7 @@ TEST_F(PlanOtherTest, createTopic) { TEST_F(PlanOtherTest, createStream) { useDb("root", "test"); - run("create stream if not exists s1 trigger window_close watermark 10s into st1 as select count(*) from t1 " + run("create stream if not exists s1 trigger window_close watermark 10s into st3 as select count(*) from t1 " "interval(10s)"); run("CREATE STREAM s1 INTO st3 TAGS(tname VARCHAR(10), id INT) SUBTABLE(CONCAT('new-', tname)) " @@ -43,9 +43,9 @@ TEST_F(PlanOtherTest, createStream) { TEST_F(PlanOtherTest, createStreamUseSTable) { useDb("root", "test"); - run("CREATE STREAM IF NOT EXISTS s1 into st1 as SELECT COUNT(*) FROM st1 INTERVAL(10s)"); + run("CREATE STREAM IF NOT EXISTS s1 into st3 as SELECT COUNT(*) FROM st1 INTERVAL(10s)"); - run("CREATE STREAM IF NOT EXISTS s1 into st1 as SELECT COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)"); + run("CREATE STREAM IF NOT EXISTS s1 into st3 as SELECT COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)"); } TEST_F(PlanOtherTest, createSmaIndex) { diff --git a/source/libs/qcom/src/queryUtil.c b/source/libs/qcom/src/queryUtil.c index 040ccc1694308d952ec43f57390562ab43e9b50b..d8cd5f4e751ede58190a4458eb0e348e63210b00 100644 --- a/source/libs/qcom/src/queryUtil.c +++ b/source/libs/qcom/src/queryUtil.c @@ -116,8 +116,6 @@ int32_t cleanupTaskQueue() { } static void execHelper(struct SSchedMsg* pSchedMsg) { - assert(pSchedMsg != NULL && pSchedMsg->ahandle != NULL); - __async_exec_fn_t execFn = (__async_exec_fn_t)pSchedMsg->ahandle; int32_t code = execFn(pSchedMsg->thandle); if (code != 0 && pSchedMsg->msg != NULL) { @@ -126,8 +124,6 @@ static void execHelper(struct SSchedMsg* pSchedMsg) { } int32_t taosAsyncExec(__async_exec_fn_t execFn, void* execParam, int32_t* code) { - assert(execFn != NULL); - SSchedMsg schedMsg = {0}; schedMsg.fp = execHelper; schedMsg.ahandle = execFn; @@ -138,7 +134,10 @@ int32_t taosAsyncExec(__async_exec_fn_t execFn, void* execParam, int32_t* code) } void destroySendMsgInfo(SMsgSendInfo* pMsgBody) { - assert(pMsgBody != NULL); + if (NULL == pMsgBody) { + return; + } + taosMemoryFreeClear(pMsgBody->target.dbFName); taosMemoryFreeClear(pMsgBody->msgInfo.pData); if (pMsgBody->paramFreeFp) { @@ -394,7 +393,7 @@ char* parseTagDatatoJson(void* p) { } else if (pTagVal->nData == 0) { value = cJSON_CreateString(""); } else { - ASSERT(0); + goto end; } cJSON_AddItemToObject(json, tagJsonKey, value); @@ -413,7 +412,7 @@ char* parseTagDatatoJson(void* p) { } cJSON_AddItemToObject(json, tagJsonKey, value); } else { - ASSERT(0); + goto end; } } string = cJSON_PrintUnformatted(json); diff --git a/source/libs/qworker/inc/qwInt.h b/source/libs/qworker/inc/qwInt.h index eb6091d60583ecbd07fbb202870d97dce4577d91..66b8e48eb1a41d5669e008d3296359f208e0a19f 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 { \ @@ -316,34 +325,34 @@ typedef struct SQWorkerMgmt { #define QW_LOCK(type, _lock) \ do { \ if (QW_READ == (type)) { \ - assert(atomic_load_32((_lock)) >= 0); \ + ASSERTS(atomic_load_32((_lock)) >= 0, "invalid lock value before read lock"); \ QW_LOCK_DEBUG("QW RLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ taosRLockLatch(_lock); \ QW_LOCK_DEBUG("QW RLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) > 0); \ + ASSERTS(atomic_load_32((_lock)) > 0, "invalid lock value after read lock"); \ } else { \ - assert(atomic_load_32((_lock)) >= 0); \ + ASSERTS(atomic_load_32((_lock)) >= 0, "invalid lock value before write lock"); \ QW_LOCK_DEBUG("QW WLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ taosWLockLatch(_lock); \ QW_LOCK_DEBUG("QW WLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \ + ASSERTS(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY, "invalid lock value after write lock"); \ } \ } while (0) #define QW_UNLOCK(type, _lock) \ do { \ if (QW_READ == (type)) { \ - assert(atomic_load_32((_lock)) > 0); \ + ASSERTS(atomic_load_32((_lock)) > 0, "invalid lock value before read unlock"); \ QW_LOCK_DEBUG("QW RULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ taosRUnLockLatch(_lock); \ QW_LOCK_DEBUG("QW RULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) >= 0); \ + ASSERTS(atomic_load_32((_lock)) >= 0, "invalid lock value after read unlock"); \ } else { \ - assert(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \ + ASSERTS(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY, "invalid lock value before write unlock"); \ QW_LOCK_DEBUG("QW WULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ taosWUnLockLatch(_lock); \ QW_LOCK_DEBUG("QW WULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) >= 0); \ + ASSERTS(atomic_load_32((_lock)) >= 0, "invalid lock value after write unlock"); \ } \ } while (0) diff --git a/source/libs/qworker/src/qwDbg.c b/source/libs/qworker/src/qwDbg.c index db6e5b19fb51cda2a5bce77ed169b9ff2e69b05b..7a755cd36f46f87674096bae5b970a137c4e4655 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 81f73b1226227d79a1c11cbaa1d162bd462c6bf1..952b87f9d734ed3bdaf2c1d2ea675b575ece3de1 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -147,7 +147,6 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryStop) { size_t numOfResBlock = taosArrayGetSize(pResList); for (int32_t j = 0; j < numOfResBlock; ++j) { SSDataBlock *pRes = taosArrayGetP(pResList, j); - ASSERT(pRes->info.rows > 0); SInputData inputData = {.pData = pRes}; code = dsPutDataBlock(sinkHandle, &inputData, &qcontinue); @@ -508,14 +507,6 @@ int32_t qwHandlePostPhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inp } if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) { - if (QW_PHASE_POST_FETCH == phase) { - QW_TASK_WLOG("drop received at wrong phase %s", qwPhaseStr(phase)); - QW_ERR_JRET(TSDB_CODE_APP_ERROR); - } - - // qwBuildAndSendDropRsp(&ctx->ctrlConnInfo, code); - // QW_TASK_DLOG("drop rsp send, handle:%p, code:%x - %s", ctx->ctrlConnInfo.handle, code, tstrerror(code)); - QW_ERR_JRET(qwDropTask(QW_FPARAMS())); QW_ERR_JRET(ctx->rspCode); } @@ -580,6 +571,7 @@ int32_t qwPreprocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) { QW_ERR_JRET(qwAcquireTaskCtx(QW_FPARAMS(), &ctx)); ctx->ctrlConnInfo = qwMsg->connInfo; + ctx->sId = sId; ctx->phase = -1; QW_ERR_JRET(qwAddTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_INIT)); @@ -670,7 +662,7 @@ _return: qwMsg->connInfo = ctx->dataConnInfo; QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_FETCH); - qwBuildAndSendFetchRsp(ctx->fetchType, &qwMsg->connInfo, rsp, dataLen, code); + qwBuildAndSendFetchRsp(ctx->msgType + 1, &qwMsg->connInfo, rsp, dataLen, code); rsp = NULL; QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code, tstrerror(code), @@ -688,6 +680,7 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) { void *rsp = NULL; int32_t dataLen = 0; bool queryStop = false; + bool qComplete = false; do { ctx = NULL; @@ -712,17 +705,18 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) { } if (rsp) { - bool qComplete = (DS_BUF_EMPTY == sOutput.bufStatus && sOutput.queryEnd); + qComplete = (DS_BUF_EMPTY == sOutput.bufStatus && sOutput.queryEnd); qwBuildFetchRsp(rsp, &sOutput, dataLen, qComplete); if (qComplete) { atomic_store_8((int8_t *)&ctx->queryEnd, true); + atomic_store_8((int8_t *)&ctx->queryContinue, 0); } qwMsg->connInfo = ctx->dataConnInfo; QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_FETCH); - qwBuildAndSendFetchRsp(ctx->fetchType, &qwMsg->connInfo, rsp, dataLen, code); + qwBuildAndSendFetchRsp(ctx->msgType + 1, &qwMsg->connInfo, rsp, dataLen, code); rsp = NULL; QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code, @@ -744,14 +738,13 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) { rsp = NULL; qwMsg->connInfo = ctx->dataConnInfo; - qwBuildAndSendFetchRsp(ctx->fetchType, &qwMsg->connInfo, NULL, 0, code); + qwBuildAndSendFetchRsp(ctx->msgType + 1, &qwMsg->connInfo, NULL, 0, code); QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code, tstrerror(code), 0); } QW_LOCK(QW_WRITE, &ctx->lock); - if ((queryStop && (0 == atomic_load_8((int8_t *)&ctx->queryContinue))) || code || - 0 == atomic_load_8((int8_t *)&ctx->queryContinue)) { + if (qComplete || (queryStop && (0 == atomic_load_8((int8_t *)&ctx->queryContinue))) || code) { // Note: query is not running anymore QW_SET_PHASE(ctx, 0); QW_UNLOCK(QW_WRITE, &ctx->lock); @@ -1178,8 +1171,9 @@ void qWorkerStopAllTasks(void *qWorkerMgmt) { QW_DLOG("start to stop all tasks, taskNum:%d", taosHashGetSize(mgmt->ctxHash)); - uint64_t qId, tId; + uint64_t qId, tId, sId; int32_t eId; + int64_t rId = 0; void *pIter = taosHashIterate(mgmt->ctxHash, NULL); while (pIter) { SQWTaskCtx *ctx = (SQWTaskCtx *)pIter; @@ -1188,6 +1182,8 @@ void qWorkerStopAllTasks(void *qWorkerMgmt) { QW_LOCK(QW_WRITE, &ctx->lock); + sId = ctx->sId; + QW_TASK_DLOG_E("start to force stop task"); if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP) || QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) { @@ -1200,9 +1196,11 @@ void qWorkerStopAllTasks(void *qWorkerMgmt) { if (QW_QUERY_RUNNING(ctx)) { qwKillTaskHandle(ctx, TSDB_CODE_VND_STOPPED); - } else if (!QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) { + } else if (QW_FETCH_RUNNING(ctx)) { QW_UPDATE_RSP_CODE(ctx, TSDB_CODE_VND_STOPPED); - QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_DROP); + QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_DROP); + } else { + qwDropTask(QW_FPARAMS()); } QW_UNLOCK(QW_WRITE, &ctx->lock); diff --git a/source/libs/scalar/inc/sclInt.h b/source/libs/scalar/inc/sclInt.h index 0b85675c83dbde077ae54aaf737121336afd2dd1..8278da0ed0f4b7b02ab7e95558bad7f0d9d21fa8 100644 --- a/source/libs/scalar/inc/sclInt.h +++ b/source/libs/scalar/inc/sclInt.h @@ -53,9 +53,6 @@ typedef struct SScalarCtx { #define SCL_IS_COMPARISON_OPERATOR(_opType) ((_opType) >= OP_TYPE_GREATER_THAN && (_opType) < OP_TYPE_IS_NOT_UNKNOWN) #define SCL_DOWNGRADE_DATETYPE(_type) \ ((_type) == TSDB_DATA_TYPE_BIGINT || TSDB_DATA_TYPE_DOUBLE == (_type) || (_type) == TSDB_DATA_TYPE_UBIGINT) -#define SCL_NO_NEED_CONVERT_COMPARISION(_ltype, _rtype, _optr) \ - (IS_NUMERIC_TYPE(_ltype) && IS_NUMERIC_TYPE(_rtype) && \ - ((_optr) >= OP_TYPE_GREATER_THAN && (_optr) <= OP_TYPE_NOT_EQUAL)) #define sclFatal(...) qFatal(__VA_ARGS__) #define sclError(...) qError(__VA_ARGS__) diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 3795f5ecb9ff60b19f7d589873536a5ade302767..d0c27560cae9496cf05de9cfb7868da7e35f8ed6 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -130,9 +130,9 @@ __compar_fn_t gDataCompare[] = {compareInt32Val, compareFloatVal, compareDoubleVal, compareLenPrefixedStr, - compareStrPatternMatch, + comparestrPatternMatch, compareChkInString, - compareWStrPatternMatch, + comparewcsPatternMatch, compareLenPrefixedWStr, compareUint8Val, compareUint16Val, @@ -142,15 +142,17 @@ __compar_fn_t gDataCompare[] = {compareInt32Val, setChkInBytes2, setChkInBytes4, setChkInBytes8, - compareStrRegexCompMatch, - compareStrRegexCompNMatch, + comparestrRegexMatch, + comparestrRegexNMatch, setChkNotInBytes1, setChkNotInBytes2, setChkNotInBytes4, setChkNotInBytes8, compareChkNotInString, - compareStrPatternNotMatch, - compareWStrPatternNotMatch}; + comparestrPatternNMatch, + comparewcsPatternNMatch, + comparewcsRegexMatch, + comparewcsRegexNMatch,}; __compar_fn_t gInt8SignCompare[] = {compareInt8Val, compareInt8Int16, compareInt8Int32, compareInt8Int64, compareInt8Float, compareInt8Double}; @@ -295,9 +297,9 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { case TSDB_DATA_TYPE_NCHAR: { if (optr == OP_TYPE_MATCH) { - comparFn = 19; + comparFn = 28; } else if (optr == OP_TYPE_NMATCH) { - comparFn = 20; + comparFn = 29; } else if (optr == OP_TYPE_LIKE) { comparFn = 9; } else if (optr == OP_TYPE_NOT_LIKE) { @@ -336,7 +338,7 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { __compar_fn_t filterGetCompFunc(int32_t type, int32_t optr) { return gDataCompare[filterGetCompFuncIdx(type, optr)]; } __compar_fn_t filterGetCompFuncEx(int32_t lType, int32_t rType, int32_t optr) { - if (TSDB_DATA_TYPE_NULL == rType) { + if (TSDB_DATA_TYPE_NULL == rType || TSDB_DATA_TYPE_JSON == rType) { return NULL; } @@ -4085,7 +4087,7 @@ bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, SC SArray *pList = taosArrayInit(1, POINTER_BYTES); taosArrayPush(pList, &pSrc); - int32_t code = scalarCalculate(info->sclCtx.node, pList, &output); + code = scalarCalculate(info->sclCtx.node, pList, &output); taosArrayDestroy(pList); FLT_ERR_RET(code); diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index a1995bdf500bedaa906c488fa5769146b41a8741..8f2fe87a53a68a6267a8085a60cfb99303bcd059 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -37,6 +37,11 @@ #define IS_HELPER_NULL(col, i) colDataIsNull_s(col, i) || IS_JSON_NULL(col->info.type, colDataGetVarData(col, i)) +bool noConvertBeforeCompare(int32_t leftType, int32_t rightType, int32_t optr) { + return IS_NUMERIC_TYPE(leftType) && IS_NUMERIC_TYPE(rightType) && + (optr >= OP_TYPE_GREATER_THAN && optr <= OP_TYPE_NOT_EQUAL); +} + void convertNumberToNumber(const void *inData, void *outData, int8_t inType, int8_t outType) { switch (outType) { case TSDB_DATA_TYPE_BOOL: { @@ -338,6 +343,7 @@ static FORCE_INLINE void varToBool(char *buf, SScalarParam *pOut, int32_t rowInd colDataAppendInt8(pOut->columnData, rowIndex, (int8_t *)&v); } +// todo remove this malloc static FORCE_INLINE void varToNchar(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) { int32_t len = 0; int32_t inputLen = varDataLen(buf); @@ -399,6 +405,8 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) { } pCtx->pOut->numOfRows = pCtx->pIn->numOfRows; + char* tmp = NULL; + for (int32_t i = pCtx->startIndex; i <= pCtx->endIndex; ++i) { if (IS_HELPER_NULL(pCtx->pIn->columnData, i)) { colDataAppendNULL(pCtx->pOut->columnData, i); @@ -421,12 +429,16 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) { continue; } } + int32_t bufSize = pCtx->pIn->columnData->info.bytes; - char *tmp = taosMemoryMalloc(varDataTLen(data)); - if (!tmp) { - sclError("out of memory in vectorConvertFromVarData"); - return TSDB_CODE_OUT_OF_MEMORY; + if (tmp == NULL) { + tmp = taosMemoryMalloc(bufSize); + if (tmp == NULL) { + sclError("out of memory in vectorConvertFromVarData"); + return TSDB_CODE_OUT_OF_MEMORY; + } } + if (vton) { memcpy(tmp, data, varDataTLen(data)); } else { @@ -434,6 +446,7 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) { memcpy(tmp, varDataVal(data), varDataLen(data)); tmp[varDataLen(data)] = 0; } else if (TSDB_DATA_TYPE_NCHAR == convertType) { + // we need to convert it to native char string, and then perform the string to numeric data ASSERT(varDataLen(data) <= bufSize); int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(data), varDataLen(data), tmp); @@ -448,9 +461,11 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) { } (*func)(tmp, pCtx->pOut, i, overflow); - taosMemoryFreeClear(tmp); } + if (tmp != NULL) { + taosMemoryFreeClear(tmp); + } return TSDB_CODE_SUCCESS; } @@ -901,9 +916,11 @@ int32_t vectorGetConvertType(int32_t type1, int32_t type2) { int32_t vectorConvertSingleCol(SScalarParam *input, SScalarParam *output, int32_t type, int32_t startIndex, int32_t numOfRows) { - SDataType t = {.type = type, .bytes = tDataTypes[type].bytes}; output->numOfRows = input->numOfRows; + SDataType t = {.type = type}; + t.bytes = IS_VAR_DATA_TYPE(t.type)? input->columnData->info.bytes:tDataTypes[type].bytes; + int32_t code = sclCreateColumnInfoData(&t, input->numOfRows, output); if (code != TSDB_CODE_SUCCESS) { return TSDB_CODE_OUT_OF_MEMORY; @@ -925,25 +942,43 @@ int32_t vectorConvertCols(SScalarParam *pLeft, SScalarParam *pRight, SScalarPara return TSDB_CODE_SUCCESS; } + int8_t type = 0; + int32_t code = 0; + SScalarParam *param1 = NULL, *paramOut1 = NULL; SScalarParam *param2 = NULL, *paramOut2 = NULL; - int32_t code = 0; - if (leftType < rightType) { + // always convert least data + if (IS_VAR_DATA_TYPE(leftType) && IS_VAR_DATA_TYPE(rightType) && (pLeft->numOfRows != pRight->numOfRows) && + leftType != TSDB_DATA_TYPE_JSON && rightType != TSDB_DATA_TYPE_JSON) { param1 = pLeft; param2 = pRight; paramOut1 = pLeftOut; paramOut2 = pRightOut; + + if (pLeft->numOfRows > pRight->numOfRows) { + type = leftType; + } else { + type = rightType; + } } else { - param1 = pRight; - param2 = pLeft; - paramOut1 = pRightOut; - paramOut2 = pLeftOut; - } + // we only define half value in the convert-matrix, so make sure param1 always less equal than param2 + if (leftType < rightType) { + param1 = pLeft; + param2 = pRight; + paramOut1 = pLeftOut; + paramOut2 = pRightOut; + } else { + param1 = pRight; + param2 = pLeft; + paramOut1 = pRightOut; + paramOut2 = pLeftOut; + } - int8_t type = vectorGetConvertType(GET_PARAM_TYPE(param1), GET_PARAM_TYPE(param2)); - if (0 == type) { - return TSDB_CODE_SUCCESS; + type = vectorGetConvertType(GET_PARAM_TYPE(param1), GET_PARAM_TYPE(param2)); + if (0 == type) { + return TSDB_CODE_SUCCESS; + } } if (type != GET_PARAM_TYPE(param1)) { @@ -1683,23 +1718,13 @@ void vectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam * SScalarParam *param1 = NULL; SScalarParam *param2 = NULL; - if (SCL_NO_NEED_CONVERT_COMPARISION(GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), optr)) { + if (noConvertBeforeCompare(GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), optr)) { param1 = pLeft; param2 = pRight; } else { vectorConvertCols(pLeft, pRight, &pLeftOut, &pRightOut, startIndex, numOfRows); - - if (pLeftOut.columnData != NULL) { - param1 = &pLeftOut; - } else { - param1 = pLeft; - } - - if (pRightOut.columnData != NULL) { - param2 = &pRightOut; - } else { - param2 = pRight; - } + param1 = (pLeftOut.columnData != NULL) ? &pLeftOut : pLeft; + param2 = (pRightOut.columnData != NULL) ? &pRightOut : pRight; } doVectorCompare(param1, param2, pOut, startIndex, numOfRows, _ord, optr); diff --git a/source/libs/scalar/test/scalar/scalarTests.cpp b/source/libs/scalar/test/scalar/scalarTests.cpp index f5a40c9a87f25c6c9e3e5d39ab3db5ff55d8a959..97002ed9bfaa5e1edca3654a910237422ffdcb9a 100644 --- a/source/libs/scalar/test/scalar/scalarTests.cpp +++ b/source/libs/scalar/test/scalar/scalarTests.cpp @@ -344,7 +344,7 @@ TEST(constantTest, int_or_binary) { ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); SValueNode *v = (SValueNode *)res; ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BIGINT); - ASSERT_EQ(v->datum.b, scltLeftV | scltRightV); + ASSERT_EQ(v->datum.i, scltLeftV | scltRightV); nodesDestroyNode(res); } @@ -1101,7 +1101,8 @@ void makeCalculate(void *json, void *key, int32_t rightType, void *rightData, do opType == OP_TYPE_LIKE || opType == OP_TYPE_NOT_LIKE || opType == OP_TYPE_MATCH || opType == OP_TYPE_NMATCH) { printf("op:%s,3result:%d,except:%f\n", operatorTypeStr(opType), *((bool *)colDataGetData(column, 0)), exceptValue); - ASSERT_EQ(*((bool *)colDataGetData(column, 0)), exceptValue); + assert(*(bool *)colDataGetData(column, 0) == exceptValue); +// ASSERT_EQ((int) *((bool *)colDataGetData(column, 0)), (int)exceptValue); } taosArrayDestroyEx(blockList, scltFreeDataBlock); @@ -1426,7 +1427,7 @@ TEST(columnTest, json_column_logic_op) { printf("--------------------json string-- 6.6hello {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); key = "k9"; - bool eRes8[len + len1] = {false, false, false, false, false, false, false, true, true, false, true, false, true}; + bool eRes8[len + len1] = {false, false, false, false, false, false, false, true, true, false, true, true, true}; for (int i = 0; i < len; i++) { makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes8[i], op[i], false); } @@ -1437,6 +1438,9 @@ TEST(columnTest, json_column_logic_op) { for (int i = len; i < len + len1; i++) { void *rightData = prepareNchar(inputNchar[i - len]); + if (i == 11) { + printf("abc\n"); + } makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes8[i], op[i], false); taosMemoryFree(rightData); } diff --git a/source/libs/scheduler/inc/schInt.h b/source/libs/scheduler/inc/schInt.h index e8216fcd7c7d6f50981218ae8c27531390903382..2a5eeecd36f03f26519768c822343b8cd7323b22 100644 --- a/source/libs/scheduler/inc/schInt.h +++ b/source/libs/scheduler/inc/schInt.h @@ -478,34 +478,34 @@ extern SSchedulerMgmt schMgmt; #define SCH_LOCK(type, _lock) \ do { \ if (SCH_READ == (type)) { \ - assert(atomic_load_32(_lock) >= 0); \ + ASSERTS(atomic_load_32(_lock) >= 0, "invalid lock value before read lock"); \ SCH_LOCK_DEBUG("SCH RLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ taosRLockLatch(_lock); \ SCH_LOCK_DEBUG("SCH RLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32(_lock) > 0); \ + ASSERTS(atomic_load_32(_lock) > 0, "invalid lock value after read lock"); \ } else { \ - assert(atomic_load_32(_lock) >= 0); \ + ASSERTS(atomic_load_32(_lock) >= 0, "invalid lock value before write lock"); \ SCH_LOCK_DEBUG("SCH WLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ taosWLockLatch(_lock); \ SCH_LOCK_DEBUG("SCH WLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32(_lock) == TD_RWLATCH_WRITE_FLAG_COPY); \ + ASSERTS(atomic_load_32(_lock) == TD_RWLATCH_WRITE_FLAG_COPY, "invalid lock value after write lock"); \ } \ } while (0) #define SCH_UNLOCK(type, _lock) \ do { \ if (SCH_READ == (type)) { \ - assert(atomic_load_32((_lock)) > 0); \ + ASSERTS(atomic_load_32((_lock)) > 0, "invalid lock value before read unlock"); \ SCH_LOCK_DEBUG("SCH RULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ taosRUnLockLatch(_lock); \ SCH_LOCK_DEBUG("SCH RULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) >= 0); \ + ASSERTS(atomic_load_32((_lock)) >= 0, "invalid lock value after read unlock"); \ } else { \ - assert(atomic_load_32((_lock)) & TD_RWLATCH_WRITE_FLAG_COPY); \ + ASSERTS(atomic_load_32((_lock)) & TD_RWLATCH_WRITE_FLAG_COPY, "invalid lock value before write unlock"); \ SCH_LOCK_DEBUG("SCH WULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ taosWUnLockLatch(_lock); \ SCH_LOCK_DEBUG("SCH WULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) >= 0); \ + ASSERTS(atomic_load_32((_lock)) >= 0, "invalid lock value after write unlock"); \ } \ } while (0) diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index 62ba74bd23b0a3b7817376e13629b13953c6226a..8f63cbbd99dcc6f75dcdc4554ba3d7bf959f481c 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -111,10 +111,14 @@ int32_t streamScanExec(SStreamTask* pTask, int32_t batchSz) { int32_t batchCnt = 0; while (1) { + if (atomic_load_8(&pTask->taskStatus) == TASK_STATUS__DROPPING) { + return 0; + } + SSDataBlock* output = NULL; uint64_t ts = 0; if (qExecTask(exec, &output, &ts) < 0) { - ASSERT(0); + return -1; } if (output == NULL) { if (qStreamRecoverScanFinished(exec)) { diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index afad78c5e57724809500905e35be136c9354885f..2b22a4ed2937b52c591f41661952cd01a667ae79 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 52777fd83401454483955eababaffe3123243383..061b211ddfa7045e0121b01d28dc77a581a401d2 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 79b4fa0fbf06be6d1c16e783ebc59638fff1a5b5..4e6ab284f8cf9b10a06f5880abd8f14e7c13de81 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); - -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); +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 *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 b5227152dfe0012bb34446a8d486f46af0400c55..3bf4a8d1cda5e55a76a5286c0c9837ff2e3823fd 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -53,6 +53,18 @@ typedef struct SyncPreSnapshot SyncPreSnapshot; typedef struct SSyncLogBuffer SSyncLogBuffer; typedef struct SSyncLogReplMgr SSyncLogReplMgr; +#define MAX_CONFIG_INDEX_COUNT 256 + +typedef struct SRaftCfg { + SSyncCfg cfg; + int32_t batchSize; + int8_t isStandBy; + int8_t snapshotStrategy; + SyncIndex lastConfigIndex; + int32_t configIndexCount; + SyncIndex configIndexArr[MAX_CONFIG_INDEX_COUNT]; +} SRaftCfg; + typedef struct SRaftId { SyncNodeId addr; SyncGroupId vgId; @@ -93,7 +105,7 @@ typedef struct SPeerState { typedef struct SSyncNode { // init by SSyncInfo SyncGroupId vgId; - SRaftCfg* pRaftCfg; + SRaftCfg raftCfg; char path[TSDB_FILENAME_LEN]; char raftStorePath[TSDB_FILENAME_LEN * 2]; char configPath[TSDB_FILENAME_LEN * 2]; @@ -112,6 +124,7 @@ typedef struct SSyncNode { int32_t peersNum; SNodeInfo peersNodeInfo[TSDB_MAX_REPLICA]; + SEpSet peersEpset[TSDB_MAX_REPLICA]; SRaftId peersId[TSDB_MAX_REPLICA]; int32_t replicaNum; @@ -245,7 +258,6 @@ int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode); // utils -------------- int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pSyncNode, SRpcMsg* pMsg); -int32_t syncNodeSendMsgByInfo(const SNodeInfo* nodeInfo, SSyncNode* pSyncNode, SRpcMsg* pMsg); SyncIndex syncMinMatchIndex(SSyncNode* pSyncNode); int32_t syncCacheEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry, LRUHandle** h); bool syncNodeHeartbeatReplyTimeout(SSyncNode* pSyncNode); diff --git a/source/libs/sync/inc/syncRaftCfg.h b/source/libs/sync/inc/syncRaftCfg.h index 823983e732c88baaf8ef17ad398902ccf71346d8..4f03a60fbca27487511c0989d50d7d3518873feb 100644 --- a/source/libs/sync/inc/syncRaftCfg.h +++ b/source/libs/sync/inc/syncRaftCfg.h @@ -22,64 +22,9 @@ extern "C" { #include "syncInt.h" -#define CONFIG_FILE_LEN 2048 -#define MAX_CONFIG_INDEX_COUNT 256 - -typedef struct SRaftCfgIndex { - TdFilePtr pFile; - char path[TSDB_FILENAME_LEN * 2]; - - SyncIndex configIndexArr[MAX_CONFIG_INDEX_COUNT]; - int32_t configIndexCount; -} SRaftCfgIndex; - -SRaftCfgIndex *raftCfgIndexOpen(const char *path); -int32_t raftCfgIndexClose(SRaftCfgIndex *pRaftCfgIndex); -int32_t raftCfgIndexPersist(SRaftCfgIndex *pRaftCfgIndex); -int32_t raftCfgIndexAddConfigIndex(SRaftCfgIndex *pRaftCfgIndex, SyncIndex configIndex); - -cJSON *raftCfgIndex2Json(SRaftCfgIndex *pRaftCfgIndex); -char *raftCfgIndex2Str(SRaftCfgIndex *pRaftCfgIndex); -int32_t raftCfgIndexFromJson(const cJSON *pRoot, SRaftCfgIndex *pRaftCfgIndex); -int32_t raftCfgIndexFromStr(const char *s, SRaftCfgIndex *pRaftCfgIndex); -int32_t raftCfgIndexCreateFile(const char *path); - -typedef struct SRaftCfg { - SSyncCfg cfg; - TdFilePtr pFile; - char path[TSDB_FILENAME_LEN * 2]; - int8_t isStandBy; - int32_t batchSize; - int8_t snapshotStrategy; - SyncIndex lastConfigIndex; - - SyncIndex configIndexArr[MAX_CONFIG_INDEX_COUNT]; - int32_t configIndexCount; - -} SRaftCfg; - -SRaftCfg *raftCfgOpen(const char *path); -int32_t raftCfgClose(SRaftCfg *pRaftCfg); -int32_t raftCfgPersist(SRaftCfg *pRaftCfg); -int32_t raftCfgAddConfigIndex(SRaftCfg *pRaftCfg, SyncIndex configIndex); - -void syncCfg2SimpleStr(const SSyncCfg *pCfg, char *str, int32_t bufLen); -cJSON *syncCfg2Json(SSyncCfg *pSyncCfg); -int32_t syncCfgFromJson(const cJSON *pRoot, SSyncCfg *pSyncCfg); - -cJSON *raftCfg2Json(SRaftCfg *pRaftCfg); -char *raftCfg2Str(SRaftCfg *pRaftCfg); -int32_t raftCfgFromJson(const cJSON *pRoot, SRaftCfg *pRaftCfg); -int32_t raftCfgFromStr(const char *s, SRaftCfg *pRaftCfg); - -typedef struct SRaftCfgMeta { - int8_t isStandBy; - int32_t batchSize; - int8_t snapshotStrategy; - SyncIndex lastConfigIndex; -} SRaftCfgMeta; - -int32_t raftCfgCreateFile(SSyncCfg *pCfg, SRaftCfgMeta meta, const char *path); +int32_t syncWriteCfgFile(SSyncNode *pNode); +int32_t syncReadCfgFile(SSyncNode *pNode); +int32_t syncAddCfgIndex(SSyncNode *pNode, SyncIndex cfgIndex); #ifdef __cplusplus } diff --git a/source/libs/sync/inc/syncUtil.h b/source/libs/sync/inc/syncUtil.h index 7d08585656584efacc08c7faf89b3cb1f8610473..39c679a2ad4677cea4db8432b7603b951b2e21c7 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 066a4dd76faafaaf822cd7f770f50acaef1d0637..6e63a2b3963d944497a92655bed92b8800d3ec27 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 8d548114fbb851e24035edd5acb11fe371390dcf..bcc95c5f103ec7bf0daef7664c80726338dfce83 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 28ae8711a8cd728a3850f016d32151e72332927f..0d6d0f93f102800b1e9d13e0aa65061983db7332 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 7933258e53f477795726d0ee5dcc286a35ccaa43..7ecb9d77825b496ea290d4bbca6f3c873edc716a 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 1a481a7e1452b852c44d655a33c3fdb06b79fc1a..bf220178a422970c69fd3998f8dd735ebccfdb17 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -306,15 +306,10 @@ int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex) { for (int32_t i = 0; i < pSyncNode->peersNum; ++i) { int64_t matchIndex = syncIndexMgrGetIndex(pSyncNode->pMatchIndex, &(pSyncNode->peersId[i])); if (lastApplyIndex > matchIndex) { - do { - char host[64]; - uint16_t port; - syncUtilU642Addr(pSyncNode->peersId[i].addr, host, sizeof(host), &port); - sNTrace(pSyncNode, - "new-snapshot-index:%" PRId64 " is greater than match-index:%" PRId64 - " of %s:%d, do not delete wal", - lastApplyIndex, matchIndex, host, port); - } while (0); + sNTrace(pSyncNode, + "new-snapshot-index:%" PRId64 " is greater than match-index:%" PRId64 + " of dnode:%d, do not delete wal", + lastApplyIndex, matchIndex, DID(&pSyncNode->peersId[i])); syncNodeRelease(pSyncNode); return 0; @@ -556,7 +551,7 @@ int32_t syncNodeLeaderTransferTo(SSyncNode* pSyncNode, SNodeInfo newLeader) { (void)syncBuildLeaderTransfer(&rpcMsg, pSyncNode->vgId); SyncLeaderTransfer* pMsg = rpcMsg.pCont; - pMsg->newLeaderId.addr = syncUtilAddr2U64(newLeader.nodeFqdn, newLeader.nodePort); + pMsg->newLeaderId.addr = SYNC_ADDR(&newLeader); pMsg->newLeaderId.vgId = pSyncNode->vgId; pMsg->newNodeInfo = newLeader; @@ -622,9 +617,9 @@ int32_t syncGetSnapshotMeta(int64_t rid, struct SSnapshotMeta* sMeta) { return -1; } ASSERT(rid == pSyncNode->rid); - sMeta->lastConfigIndex = pSyncNode->pRaftCfg->lastConfigIndex; + sMeta->lastConfigIndex = pSyncNode->raftCfg.lastConfigIndex; - sTrace("vgId:%d, get snapshot meta, lastConfigIndex:%" PRId64, pSyncNode->vgId, pSyncNode->pRaftCfg->lastConfigIndex); + sTrace("vgId:%d, get snapshot meta, lastConfigIndex:%" PRId64, pSyncNode->vgId, pSyncNode->raftCfg.lastConfigIndex); syncNodeRelease(pSyncNode); return 0; @@ -637,13 +632,13 @@ int32_t syncGetSnapshotMetaByIndex(int64_t rid, SyncIndex snapshotIndex, struct } ASSERT(rid == pSyncNode->rid); - ASSERT(pSyncNode->pRaftCfg->configIndexCount >= 1); - SyncIndex lastIndex = (pSyncNode->pRaftCfg->configIndexArr)[0]; + ASSERT(pSyncNode->raftCfg.configIndexCount >= 1); + SyncIndex lastIndex = (pSyncNode->raftCfg.configIndexArr)[0]; - for (int32_t i = 0; i < pSyncNode->pRaftCfg->configIndexCount; ++i) { - if ((pSyncNode->pRaftCfg->configIndexArr)[i] > lastIndex && - (pSyncNode->pRaftCfg->configIndexArr)[i] <= snapshotIndex) { - lastIndex = (pSyncNode->pRaftCfg->configIndexArr)[i]; + for (int32_t i = 0; i < pSyncNode->raftCfg.configIndexCount; ++i) { + if ((pSyncNode->raftCfg.configIndexArr)[i] > lastIndex && + (pSyncNode->raftCfg.configIndexArr)[i] <= snapshotIndex) { + lastIndex = (pSyncNode->raftCfg.configIndexArr)[i]; } } sMeta->lastConfigIndex = lastIndex; @@ -656,13 +651,13 @@ int32_t syncGetSnapshotMetaByIndex(int64_t rid, SyncIndex snapshotIndex, struct #endif SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode* pSyncNode, SyncIndex snapshotLastApplyIndex) { - ASSERT(pSyncNode->pRaftCfg->configIndexCount >= 1); - SyncIndex lastIndex = (pSyncNode->pRaftCfg->configIndexArr)[0]; + ASSERT(pSyncNode->raftCfg.configIndexCount >= 1); + SyncIndex lastIndex = (pSyncNode->raftCfg.configIndexArr)[0]; - for (int32_t i = 0; i < pSyncNode->pRaftCfg->configIndexCount; ++i) { - if ((pSyncNode->pRaftCfg->configIndexArr)[i] > lastIndex && - (pSyncNode->pRaftCfg->configIndexArr)[i] <= snapshotLastApplyIndex) { - lastIndex = (pSyncNode->pRaftCfg->configIndexArr)[i]; + for (int32_t i = 0; i < pSyncNode->raftCfg.configIndexCount; ++i) { + if ((pSyncNode->raftCfg.configIndexArr)[i] > lastIndex && + (pSyncNode->raftCfg.configIndexArr)[i] <= snapshotLastApplyIndex) { + lastIndex = (pSyncNode->raftCfg.configIndexArr)[i]; } } sTrace("vgId:%d, sync get last config index, index:%" PRId64 " lcindex:%" PRId64, pSyncNode->vgId, @@ -677,15 +672,15 @@ void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet) { SSyncNode* pSyncNode = syncNodeAcquire(rid); if (pSyncNode == NULL) return; - for (int32_t i = 0; i < pSyncNode->pRaftCfg->cfg.replicaNum; ++i) { + for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.replicaNum; ++i) { SEp* pEp = &pEpSet->eps[i]; - tstrncpy(pEp->fqdn, pSyncNode->pRaftCfg->cfg.nodeInfo[i].nodeFqdn, TSDB_FQDN_LEN); - pEp->port = (pSyncNode->pRaftCfg->cfg.nodeInfo)[i].nodePort; + tstrncpy(pEp->fqdn, pSyncNode->raftCfg.cfg.nodeInfo[i].nodeFqdn, TSDB_FQDN_LEN); + pEp->port = (pSyncNode->raftCfg.cfg.nodeInfo)[i].nodePort; pEpSet->numOfEps++; sDebug("vgId:%d, sync get retry epset, index:%d %s:%d", pSyncNode->vgId, i, pEp->fqdn, pEp->port); } if (pEpSet->numOfEps > 0) { - pEpSet->inUse = (pSyncNode->pRaftCfg->cfg.myIndex + 1) % pEpSet->numOfEps; + pEpSet->inUse = (pSyncNode->raftCfg.cfg.myIndex + 1) % pEpSet->numOfEps; } sInfo("vgId:%d, sync get retry epset numOfEps:%d inUse:%d", pSyncNode->vgId, pEpSet->numOfEps, pEpSet->inUse); @@ -849,60 +844,57 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { } } + 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 - 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); + 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; } - 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); + if (syncReadCfgFile(pSyncNode) != 0) { + sError("vgId:%d, failed to read sync cfg file", pSyncNode->vgId); goto _error; } - if (pSyncInfo->syncCfg.replicaNum > 0 && syncIsConfigChanged(&pSyncNode->pRaftCfg->cfg, &pSyncInfo->syncCfg)) { + 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->pRaftCfg->cfg = pSyncInfo->syncCfg; - if (raftCfgPersist(pSyncNode->pRaftCfg) != 0) { - sError("vgId:%d, failed to persist raft cfg file at %s", pSyncNode->vgId, pSyncNode->configPath); + 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 raft cfg file", pSyncNode->vgId); - pSyncInfo->syncCfg = pSyncNode->pRaftCfg->cfg; + sInfo("vgId:%d, use sync config from sync cfg file", pSyncNode->vgId); + pSyncInfo->syncCfg = pSyncNode->raftCfg.cfg; } - - raftCfgClose(pSyncNode->pRaftCfg); - pSyncNode->pRaftCfg = NULL; } // init by SSyncInfo pSyncNode->vgId = pSyncInfo->vgId; - SSyncCfg* pCfg = &pSyncInfo->syncCfg; + 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]; - sInfo("vgId:%d, index:%d ep:%s:%u", pSyncNode->vgId, i, pNode->nodeFqdn, pNode->nodePort); + (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); } - 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); - pSyncNode->pWal = pSyncInfo->pWal; pSyncNode->msgcb = pSyncInfo->msgcb; pSyncNode->syncSendMSg = pSyncInfo->syncSendMSg; @@ -916,26 +908,20 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { goto _error; } - // init raft config - pSyncNode->pRaftCfg = raftCfgOpen(pSyncNode->configPath); - if (pSyncNode->pRaftCfg == NULL) { - sError("vgId:%d, failed to open raft cfg file at %s", pSyncNode->vgId, pSyncNode->configPath); - goto _error; - } - // init internal - pSyncNode->myNodeInfo = pSyncNode->pRaftCfg->cfg.nodeInfo[pSyncNode->pRaftCfg->cfg.myIndex]; + pSyncNode->myNodeInfo = pSyncNode->raftCfg.cfg.nodeInfo[pSyncNode->raftCfg.cfg.myIndex]; if (!syncUtilNodeInfo2RaftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId)) { sError("vgId:%d, failed to determine my raft member id", pSyncNode->vgId); goto _error; } // init peersNum, peers, peersId - pSyncNode->peersNum = pSyncNode->pRaftCfg->cfg.replicaNum - 1; + pSyncNode->peersNum = pSyncNode->raftCfg.cfg.replicaNum - 1; int32_t j = 0; - for (int32_t i = 0; i < pSyncNode->pRaftCfg->cfg.replicaNum; ++i) { - if (i != pSyncNode->pRaftCfg->cfg.myIndex) { - pSyncNode->peersNodeInfo[j] = pSyncNode->pRaftCfg->cfg.nodeInfo[i]; + for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.replicaNum; ++i) { + if (i != pSyncNode->raftCfg.cfg.myIndex) { + pSyncNode->peersNodeInfo[j] = pSyncNode->raftCfg.cfg.nodeInfo[i]; + syncUtilNodeInfo2EpSet(&pSyncNode->peersNodeInfo[j], &pSyncNode->peersEpset[j]); j++; } } @@ -947,9 +933,9 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { } // init replicaNum, replicasId - pSyncNode->replicaNum = pSyncNode->pRaftCfg->cfg.replicaNum; - for (int32_t i = 0; i < pSyncNode->pRaftCfg->cfg.replicaNum; ++i) { - if (!syncUtilNodeInfo2RaftId(&pSyncNode->pRaftCfg->cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i])) { + pSyncNode->replicaNum = pSyncNode->raftCfg.cfg.replicaNum; + for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.replicaNum; ++i) { + if (!syncUtilNodeInfo2RaftId(&pSyncNode->raftCfg.cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i])) { sError("vgId:%d, failed to determine raft member id, replica:%d", pSyncNode->vgId, i); goto _error; } @@ -958,7 +944,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { // init raft algorithm pSyncNode->pFsm = pSyncInfo->pFsm; pSyncInfo->pFsm = NULL; - pSyncNode->quorum = syncUtilQuorum(pSyncNode->pRaftCfg->cfg.replicaNum); + pSyncNode->quorum = syncUtilQuorum(pSyncNode->raftCfg.cfg.replicaNum); pSyncNode->leaderCache = EMPTY_RAFT_ID; // init life cycle outside @@ -1293,8 +1279,6 @@ void syncNodeClose(SSyncNode* pSyncNode) { pSyncNode->pLogStore = NULL; syncLogBufferDestroy(pSyncNode->pLogBuf); pSyncNode->pLogBuf = NULL; - raftCfgClose(pSyncNode->pRaftCfg); - pSyncNode->pRaftCfg = NULL; syncNodeStopPingTimer(pSyncNode); syncNodeStopElectTimer(pSyncNode); @@ -1330,7 +1314,7 @@ void syncNodeClose(SSyncNode* pSyncNode) { taosMemoryFree(pSyncNode); } -ESyncStrategy syncNodeStrategy(SSyncNode* pSyncNode) { return pSyncNode->pRaftCfg->snapshotStrategy; } +ESyncStrategy syncNodeStrategy(SSyncNode* pSyncNode) { return pSyncNode->raftCfg.snapshotStrategy; } // timer control -------------- int32_t syncNodeStartPingTimer(SSyncNode* pSyncNode) { @@ -1392,7 +1376,7 @@ int32_t syncNodeRestartElectTimer(SSyncNode* pSyncNode, int32_t ms) { void syncNodeResetElectTimer(SSyncNode* pSyncNode) { int32_t electMS; - if (pSyncNode->pRaftCfg->isStandBy) { + if (pSyncNode->raftCfg.isStandBy) { electMS = TIMER_MAX_MS; } else { electMS = syncUtilElectRandomMS(pSyncNode->electBaseLine, 2 * pSyncNode->electBaseLine); @@ -1461,55 +1445,46 @@ int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode) { return 0; } -int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pSyncNode, SRpcMsg* pMsg) { - SEpSet epSet; - syncUtilRaftId2EpSet(destRaftId, &epSet); +int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pNode, SRpcMsg* pMsg) { + SEpSet* epSet = NULL; + for (int32_t i = 0; i < pNode->peersNum; ++i) { + if (destRaftId->addr == pNode->peersId[i].addr) { + epSet = &pNode->peersEpset[i]; + break; + } + } - if (pSyncNode->syncSendMSg != NULL) { + if (pNode->syncSendMSg != NULL && epSet != NULL) { syncUtilMsgHtoN(pMsg->pCont); pMsg->info.noResp = 1; - return pSyncNode->syncSendMSg(&epSet, pMsg); + return pNode->syncSendMSg(epSet, pMsg); } else { - sError("vgId:%d, sync send msg by id error, fp-send-msg is null", pSyncNode->vgId); + sError("vgId:%d, sync send msg by id error, fp:%p epset:%p", pNode->vgId, pNode->syncSendMSg, epSet); rpcFreeCont(pMsg->pCont); terrno = TSDB_CODE_SYN_INTERNAL_ERROR; return -1; } } -int32_t syncNodeSendMsgByInfo(const SNodeInfo* nodeInfo, SSyncNode* pSyncNode, SRpcMsg* pMsg) { - SEpSet epSet; - syncUtilNodeInfo2EpSet(nodeInfo, &epSet); - if (pSyncNode->syncSendMSg != NULL) { - // htonl - syncUtilMsgHtoN(pMsg->pCont); - - pMsg->info.noResp = 1; - pSyncNode->syncSendMSg(&epSet, pMsg); - } else { - sError("vgId:%d, sync send msg by info error, fp-send-msg is null", pSyncNode->vgId); - } - return 0; -} - -inline bool syncNodeInConfig(SSyncNode* pSyncNode, const SSyncCfg* config) { +inline bool syncNodeInConfig(SSyncNode* pNode, const SSyncCfg* pCfg) { bool b1 = false; bool b2 = false; - for (int32_t i = 0; i < config->replicaNum; ++i) { - if (strcmp((config->nodeInfo)[i].nodeFqdn, pSyncNode->myNodeInfo.nodeFqdn) == 0 && - (config->nodeInfo)[i].nodePort == pSyncNode->myNodeInfo.nodePort) { + for (int32_t i = 0; i < pCfg->replicaNum; ++i) { + if (strcmp(pCfg->nodeInfo[i].nodeFqdn, pNode->myNodeInfo.nodeFqdn) == 0 && + pCfg->nodeInfo[i].nodePort == pNode->myNodeInfo.nodePort) { b1 = true; break; } } - for (int32_t i = 0; i < config->replicaNum; ++i) { - SRaftId raftId; - raftId.addr = syncUtilAddr2U64((config->nodeInfo)[i].nodeFqdn, (config->nodeInfo)[i].nodePort); - raftId.vgId = pSyncNode->vgId; + for (int32_t i = 0; i < pCfg->replicaNum; ++i) { + SRaftId raftId = { + .addr = SYNC_ADDR(&pCfg->nodeInfo[i]), + .vgId = pNode->vgId, + }; - if (syncUtilSameId(&raftId, &(pSyncNode->myRaftId))) { + if (syncUtilSameId(&raftId, &pNode->myRaftId)) { b2 = true; break; } @@ -1533,14 +1508,14 @@ static bool syncIsConfigChanged(const SSyncCfg* pOldCfg, const SSyncCfg* pNewCfg } void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncIndex lastConfigChangeIndex) { - SSyncCfg oldConfig = pSyncNode->pRaftCfg->cfg; + SSyncCfg oldConfig = pSyncNode->raftCfg.cfg; if (!syncIsConfigChanged(&oldConfig, pNewConfig)) { sInfo("vgId:1, sync not reconfig since not changed"); return; } - pSyncNode->pRaftCfg->cfg = *pNewConfig; - pSyncNode->pRaftCfg->lastConfigIndex = lastConfigChangeIndex; + pSyncNode->raftCfg.cfg = *pNewConfig; + pSyncNode->raftCfg.lastConfigIndex = lastConfigChangeIndex; pSyncNode->configChangeNum++; @@ -1563,21 +1538,18 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde } // log begin config change - char oldCfgStr[1024] = {0}; - char newCfgStr[1024] = {0}; - syncCfg2SimpleStr(&oldConfig, oldCfgStr, sizeof(oldCfgStr)); - syncCfg2SimpleStr(pNewConfig, oldCfgStr, sizeof(oldCfgStr)); - sNInfo(pSyncNode, "begin do config change, from %s to %s", oldCfgStr, oldCfgStr); + sNInfo(pSyncNode, "begin do config change, from %d to %d", pSyncNode->vgId, oldConfig.replicaNum, + pNewConfig->replicaNum); if (IamInNew) { - pSyncNode->pRaftCfg->isStandBy = 0; // change isStandBy to normal + pSyncNode->raftCfg.isStandBy = 0; // change isStandBy to normal } if (isDrop) { - pSyncNode->pRaftCfg->isStandBy = 1; // set standby + pSyncNode->raftCfg.isStandBy = 1; // set standby } // add last config index - raftCfgAddConfigIndex(pSyncNode->pRaftCfg, lastConfigChangeIndex); + syncAddCfgIndex(pSyncNode, lastConfigChangeIndex); if (IamInNew) { //----------------------------------------- @@ -1594,15 +1566,16 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde } // init internal - pSyncNode->myNodeInfo = pSyncNode->pRaftCfg->cfg.nodeInfo[pSyncNode->pRaftCfg->cfg.myIndex]; + pSyncNode->myNodeInfo = pSyncNode->raftCfg.cfg.nodeInfo[pSyncNode->raftCfg.cfg.myIndex]; syncUtilNodeInfo2RaftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId); // init peersNum, peers, peersId - pSyncNode->peersNum = pSyncNode->pRaftCfg->cfg.replicaNum - 1; + pSyncNode->peersNum = pSyncNode->raftCfg.cfg.replicaNum - 1; int32_t j = 0; - for (int32_t i = 0; i < pSyncNode->pRaftCfg->cfg.replicaNum; ++i) { - if (i != pSyncNode->pRaftCfg->cfg.myIndex) { - pSyncNode->peersNodeInfo[j] = pSyncNode->pRaftCfg->cfg.nodeInfo[i]; + for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.replicaNum; ++i) { + if (i != pSyncNode->raftCfg.cfg.myIndex) { + pSyncNode->peersNodeInfo[j] = pSyncNode->raftCfg.cfg.nodeInfo[i]; + syncUtilNodeInfo2EpSet(&pSyncNode->peersNodeInfo[j], &pSyncNode->peersEpset[j]); j++; } } @@ -1611,13 +1584,13 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde } // init replicaNum, replicasId - pSyncNode->replicaNum = pSyncNode->pRaftCfg->cfg.replicaNum; - for (int32_t i = 0; i < pSyncNode->pRaftCfg->cfg.replicaNum; ++i) { - syncUtilNodeInfo2RaftId(&pSyncNode->pRaftCfg->cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i]); + pSyncNode->replicaNum = pSyncNode->raftCfg.cfg.replicaNum; + for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.replicaNum; ++i) { + syncUtilNodeInfo2RaftId(&pSyncNode->raftCfg.cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i]); } // update quorum first - pSyncNode->quorum = syncUtilQuorum(pSyncNode->pRaftCfg->cfg.replicaNum); + pSyncNode->quorum = syncUtilQuorum(pSyncNode->raftCfg.cfg.replicaNum); syncIndexMgrUpdate(pSyncNode->pNextIndex, pSyncNode); syncIndexMgrUpdate(pSyncNode->pMatchIndex, pSyncNode); @@ -1637,11 +1610,8 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde bool reset = false; for (int32_t j = 0; j < TSDB_MAX_REPLICA; ++j) { if (syncUtilSameId(&(pSyncNode->replicasId)[i], &oldReplicasId[j]) && oldSenders[j] != NULL) { - char host[128]; - uint16_t port; - syncUtilU642Addr((pSyncNode->replicasId)[i].addr, host, sizeof(host), &port); - sNTrace(pSyncNode, "snapshot sender reset for: %" PRId64 ", newIndex:%d, %s:%d, %p", - (pSyncNode->replicasId)[i].addr, i, host, port, oldSenders[j]); + sNTrace(pSyncNode, "snapshot sender reset for:%" PRId64 ", newIndex:%d, dnode:%d, %p", + (pSyncNode->replicasId)[i].addr, i, DID(&pSyncNode->replicasId[i]), oldSenders[j]); pSyncNode->senders[i] = oldSenders[j]; oldSenders[j] = NULL; @@ -1651,8 +1621,8 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde int32_t oldreplicaIndex = pSyncNode->senders[i]->replicaIndex; pSyncNode->senders[i]->replicaIndex = i; - sNTrace(pSyncNode, "snapshot sender udpate replicaIndex from %d to %d, %s:%d, %p, reset:%d", oldreplicaIndex, - i, host, port, pSyncNode->senders[i], reset); + sNTrace(pSyncNode, "snapshot sender udpate replicaIndex from %d to %d, dnode:%d, %p, reset:%d", + oldreplicaIndex, i, DID(&pSyncNode->replicasId[i]), pSyncNode->senders[i], reset); break; } @@ -1684,33 +1654,29 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde } // persist cfg - raftCfgPersist(pSyncNode->pRaftCfg); - - char tmpbuf[1024] = {0}; - snprintf(tmpbuf, sizeof(tmpbuf), "config change from %d to %d, index:%" PRId64 ", %s --> %s", - oldConfig.replicaNum, pNewConfig->replicaNum, lastConfigChangeIndex, oldCfgStr, newCfgStr); + syncWriteCfgFile(pSyncNode); // change isStandBy to normal (election timeout) if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { - syncNodeBecomeLeader(pSyncNode, tmpbuf); + syncNodeBecomeLeader(pSyncNode, ""); // Raft 3.6.2 Committing entries from previous terms syncNodeAppendNoop(pSyncNode); // syncMaybeAdvanceCommitIndex(pSyncNode); } else { - syncNodeBecomeFollower(pSyncNode, tmpbuf); + syncNodeBecomeFollower(pSyncNode, ""); } } else { // persist cfg - raftCfgPersist(pSyncNode->pRaftCfg); - sNInfo(pSyncNode, "do not config change from %d to %d, index:%" PRId64 ", %s --> %s", oldConfig.replicaNum, - pNewConfig->replicaNum, lastConfigChangeIndex, oldCfgStr, newCfgStr); + syncWriteCfgFile(pSyncNode); + sNInfo(pSyncNode, "do not config change from %d to %d", oldConfig.replicaNum, pNewConfig->replicaNum); } _END: // log end config change - sNInfo(pSyncNode, "end do config change, from %s to %s", oldCfgStr, newCfgStr); + sNInfo(pSyncNode, "end do config change, from %d to %d", pSyncNode->vgId, oldConfig.replicaNum, + pNewConfig->replicaNum); } // raft state change -------------- @@ -2889,9 +2855,10 @@ int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* p int32_t syncNodeUpdateNewConfigIndex(SSyncNode* ths, SSyncCfg* pNewCfg) { for (int32_t i = 0; i < pNewCfg->replicaNum; ++i) { - SRaftId raftId; - raftId.addr = syncUtilAddr2U64((pNewCfg->nodeInfo)[i].nodeFqdn, (pNewCfg->nodeInfo)[i].nodePort); - raftId.vgId = ths->vgId; + SRaftId raftId = { + .addr = SYNC_ADDR(&pNewCfg->nodeInfo[i]), + .vgId = ths->vgId, + }; if (syncUtilSameId(&(ths->myRaftId), &raftId)) { pNewCfg->myIndex = i; diff --git a/source/libs/sync/src/syncPipeline.c b/source/libs/sync/src/syncPipeline.c index ee649c268c67d6022ed75bbd81fb10a3994b9feb..410986b87a4031d19e8b4e7d96da65ceac7a4839 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 c609bfba93377e89fb8eeb41c3b098359efc93b3..86ea1f48ccf9416cfedaff87acd58a038f9fb6aa 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" - -// file must already exist! -SRaftCfgIndex *raftCfgIndexOpen(const char *path) { - SRaftCfgIndex *pRaftCfgIndex = taosMemoryMalloc(sizeof(SRaftCfg)); - snprintf(pRaftCfgIndex->path, sizeof(pRaftCfgIndex->path), "%s", path); - - 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); +#include "tjson.h" + +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; + + 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 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); +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; + + 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; } return 0; } -int32_t raftCfgIndexFromStr(const char *s, SRaftCfgIndex *pRaftCfgIndex) { - cJSON *pRoot = cJSON_Parse(s); - ASSERT(pRoot != NULL); - - int32_t ret = raftCfgIndexFromJson(pRoot, pRaftCfgIndex); - ASSERT(ret == 0); +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); - cJSON_Delete(pRoot); - return 0; -} - -int32_t raftCfgIndexCreateFile(const char *path) { - TdFilePtr pFile = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE); + 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)); - - // int64_t ret = taosWriteFile(pRaftCfg->pFile, s, strlen(s) + 1); - // ASSERT(ret == strlen(s) + 1); + code = 0; + sInfo("vgId:%d, succeed to write sync cfg file:%s, len:%d", pNode->vgId, realfile, len); - taosMemoryFree(s); - taosFsyncFile(pRaftCfg->pFile); - return 0; -} +_OVER: + if (pJson != NULL) tjsonDelete(pJson); + if (buffer != NULL) taosMemoryFree(buffer); + if (pFile != NULL) taosCloseFile(&pFile); -int32_t raftCfgAddConfigIndex(SRaftCfg *pRaftCfg, SyncIndex configIndex) { - ASSERT(pRaftCfg->configIndexCount <= MAX_CONFIG_INDEX_COUNT); - (pRaftCfg->configIndexArr)[pRaftCfg->configIndexCount] = configIndex; - ++(pRaftCfg->configIndexCount); - return 0; + if (code != 0) { + sError("vgId:%d, failed to write sync cfg file:%s since %s", pNode->vgId, realfile, terrstr()); + } + return code; } -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); - } +static int32_t syncDecodeSyncCfg(const SJson *pJson, void *pObj) { + SSyncCfg *pCfg = (SSyncCfg *)pObj; + int32_t code = 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); } - return pRoot; + return 0; } -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); +static int32_t syncDecodeRaftCfg(const SJson *pJson, void *pObj) { + SRaftCfg *pCfg = (SRaftCfg *)pObj; + int32_t code = 0; - cJSON *pNodeInfoArr = cJSON_GetObjectItem(pJson, "nodeInfo"); - int arraySize = cJSON_GetArraySize(pNodeInfoArr); - ASSERT(arraySize == pSyncCfg->replicaNum); + if (tjsonToObject(pJson, "SSyncCfg", syncDecodeSyncCfg, (void *)&pCfg->cfg) < 0) return -1; - for (int i = 0; i < arraySize; ++i) { - cJSON *pNodeInfo = cJSON_GetArrayItem(pNodeInfoArr, i); - ASSERT(pNodeInfo != NULL); + 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); - cJSON *pNodePort = cJSON_GetObjectItem(pNodeInfo, "nodePort"); - ASSERT(cJSON_IsNumber(pNodePort)); - ((pSyncCfg->nodeInfo)[i]).nodePort = cJSON_GetNumberValue(pNodePort); + SJson *configIndexArr = tjsonGetObjectItem(pJson, "configIndexArr"); + if (configIndexArr == NULL) return -1; - cJSON *pNodeFqdn = cJSON_GetObjectItem(pNodeInfo, "nodeFqdn"); - ASSERT(cJSON_IsString(pNodeFqdn)); - snprintf(((pSyncCfg->nodeInfo)[i]).nodeFqdn, sizeof(((pSyncCfg->nodeInfo)[i]).nodeFqdn), "%s", - pNodeFqdn->valuestring); + 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; } -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); - } +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; - 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); + pFile = taosOpenFile(file, TD_FILE_READ); 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; + terrno = TAOS_SYSTEM_ERROR(errno); + sError("vgId:%d, failed to open sync cfg file:%s since %s", pNode->vgId, file, terrstr()); + goto _OVER; } - 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"); + 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; + } - cJSON *pJsonIsStandBy = cJSON_GetObjectItem(pJson, "isStandBy"); - pRaftCfg->isStandBy = cJSON_GetNumberValue(pJsonIsStandBy); + pData = taosMemoryMalloc(size + 1); + if (pData == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } - cJSON *pJsonBatchSize = cJSON_GetObjectItem(pJson, "batchSize"); - pRaftCfg->batchSize = cJSON_GetNumberValue(pJsonBatchSize); + 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; + } - cJSON *pJsonSnapshotStrategy = cJSON_GetObjectItem(pJson, "snapshotStrategy"); - pRaftCfg->snapshotStrategy = cJSON_GetNumberValue(pJsonSnapshotStrategy); + pData[size] = '\0'; - cJSON *pJsonLastConfigIndex = cJSON_GetObjectItem(pJson, "lastConfigIndex"); - pRaftCfg->lastConfigIndex = atoll(cJSON_GetStringValue(pJsonLastConfigIndex)); + pJson = tjsonParse(pData); + if (pJson == NULL) { + terrno = TSDB_CODE_INVALID_JSON_FORMAT; + goto _OVER; + } - cJSON *pJsonConfigIndexCount = cJSON_GetObjectItem(pJson, "configIndexCount"); - pRaftCfg->configIndexCount = cJSON_GetNumberValue(pJsonConfigIndexCount); + if (tjsonToObject(pJson, "RaftCfg", syncDecodeRaftCfg, (void *)pCfg) < 0) { + terrno = TSDB_CODE_INVALID_JSON_FORMAT; + goto _OVER; + } - cJSON *pIndexArr = cJSON_GetObjectItem(pJson, "configIndexArr"); - int arraySize = cJSON_GetArraySize(pIndexArr); - ASSERT(arraySize == pRaftCfg->configIndexCount); + code = 0; + sInfo("vgId:%d, succceed to read sync cfg file %s", pNode->vgId, file); - memset(pRaftCfg->configIndexArr, 0, sizeof(pRaftCfg->configIndexArr)); - for (int i = 0; i < arraySize; ++i) { - cJSON *pIndexObj = cJSON_GetArrayItem(pIndexArr, i); - ASSERT(pIndexObj != NULL); +_OVER: + if (pData != NULL) taosMemoryFree(pData); + if (pJson != NULL) cJSON_Delete(pJson); + if (pFile != NULL) taosCloseFile(&pFile); - cJSON *pIndex = cJSON_GetObjectItem(pIndexObj, "index"); - ASSERT(cJSON_IsString(pIndex)); - (pRaftCfg->configIndexArr)[i] = atoll(pIndex->valuestring); + if (code != 0) { + sError("vgId:%d, failed to read sync cfg file:%s since %s", pNode->vgId, file, terrstr()); } - - 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); - - int32_t ret = raftCfgFromJson(pRoot, pRaftCfg); - ASSERT(ret == 0); +int32_t syncAddCfgIndex(SSyncNode *pNode, SyncIndex cfgIndex) { + SRaftCfg *pCfg = &pNode->raftCfg; + if (pCfg->configIndexCount <= MAX_CONFIG_INDEX_COUNT) { + return -1; + } - cJSON_Delete(pRoot); + 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 e328ed3d31ab3f51297c93bdea781417e9e33999..b19cda2a446fcb6147eec2cd13400fc22526f049 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 0f56921ec77570e85c081837e596071aeecbe483..e3058768f8b1579b1d7b1074603ce2ade08a5b89 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 503c56b1e7d00639680e57d44f7d1d31be34a089..b55aae4c768415d5bcf810fed9bfbc1e78ac0b1b 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 f2da2fb2ce527761c8f562dbf7b7611b428f6c3d..b68b735f4688dc7ecf99fdfdfcbcd1beeb9ce7f4 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -406,7 +406,7 @@ void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *p } // just set start = false -// FpSnapshotStopWrite should not be called, assert writer == NULL +// FpSnapshotStopWrite should not be called void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { sRInfo(pReceiver, "snapshot receiver stop, not apply, writer:%p", pReceiver->pWriter); diff --git a/source/libs/sync/src/syncTimeout.c b/source/libs/sync/src/syncTimeout.c index 16e593d0e49695f3ec7ac02d47388106bcb9d281..859183db9529ace6bf914fafbc381ca388880dea 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 49a24bebde3774640c2636e7964a2c18e3a1266f..0ec24d5326c83fdf70111cc6ab16ee7a49533cdf 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 8a0a35ce336bfa9d1ed1d01fb96b79a98da24edb..6bd9625276c898184341cec291abed6c304700fb 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 e6d3f23b58e471609b6127c497a34176731fb182..54000654431b01ecebe453269d47c07c3d4fb570 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 c841a68fde081a0c5fc666dc33752dd62c2e321d..8e63b4ca09d00484e33e8af9123aded673ffa51c 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 ae4cc6ed6f7839eced1f829822b22d4b03f62208..fc52e83aa7c22f383e13bfbd3395d5fe3cb0b73e 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 cb4bed1e671e40ec58e028a4a614e6c5db955dc5..4e0b53467102507c74abde4d05ca3361767c41e1 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 4b305f823ff3a1002c4e8c29ed0c3afe02c371a7..2e0078558662f5a8aaee5af792f2c28a0cbec5b2 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 1d3198c51d285f7a3de97e1c59b0676e1b15142c..c951eef7616c0afbe20cab19047113fbe342e3ac 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 6b461da0e562ed1c153003f1cd7d098699d88737..f1db2f0204faedcac7ad5599a9c376142a2dc2c5 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 3b6007df6bd346986a7e6a7b46ddb0300761d2fc..ae83bf9ead0d6436bcb6375bd5ab4724799e1efa 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 50ecc5d47804d54a4fa00aab34ec169706fcc1a5..bafa22ea640a508ffc7b3b8f51596fca9a7e3b22 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 b12f4e76a58fad992cb5b3ea545966e43469ea00..6802148578d159ff546276faf2be9f1171465aeb 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 f1c26a97aa443f9fa27580b4b2138192ecc09401..f3ea5e07fd1e649084e15fe53d03d6606f987f16 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 4e25d72b2ba587dae1192fa686e1d2a628f74142..734bac5c872c457f1bf57bcf32d002220f4194d1 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -1788,6 +1788,10 @@ int tdbBtreeNext(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen) { } memcpy(pVal, cd.pVal, cd.vLen); + if (TDB_CELLDECODER_FREE_VAL(&cd)) { + tdbTrace("tdb/btree-next decoder: %p pVal free: %p", &cd, cd.pVal); + tdbFree(cd.pVal); + } } else { pVal = NULL; } diff --git a/source/libs/tfs/src/tfs.c b/source/libs/tfs/src/tfs.c index 943611ee27c6f1d6bfa51dfff211bf723764f88f..9a71fc7f30ffebb5cf864d30faea3b8690438112 100644 --- a/source/libs/tfs/src/tfs.c +++ b/source/libs/tfs/src/tfs.c @@ -284,7 +284,9 @@ int32_t tfsMkdir(STfs *pTfs, const char *rname) { } int32_t tfsRmdir(STfs *pTfs, const char *rname) { - ASSERT(rname[0] != 0); + if (rname[0] == 0) { + return 0; + } char aname[TMPNAME_LEN] = "\0"; diff --git a/source/libs/transport/src/tmsgcb.c b/source/libs/transport/src/tmsgcb.c index 95bc532994d7581eb538e9ec22d3d93395f16424..4131619ed9b89f8c4aa7cc74c2608327f6353a0c 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 55c3c61b05ebb0728858b8151f5fc33425fc7a65..47b1ac5ca7c8a46d435ea7c412b2c7adf25d5081 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 1dc79e0cfb9d606ba0e7739e8cb6f047449365db..2632d290e956c536bdcfb3ac70d20aa3607e7382 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 09f9a78ab88ecce3b95441d9bb0727be6c18e2fd..1161ed7c00408a9559146ba532c74055813f5c5d 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 73848773137133551e90ca57e9d59a8ba1cbc0fa..fa8929f7d954fd42a04f3b8bade2cb084d79c981 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 0d85a8bec4133a95459994a0cb310a0836e6f8fd..3aac5e97751295be13956283c2e8dae46f4c453e 100644 --- a/source/os/CMakeLists.txt +++ b/source/os/CMakeLists.txt @@ -41,7 +41,7 @@ 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) @@ -59,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 d8cccc83ed7ce0942576873859b27b33cc4621ec..3f527e913025af968753a47a77e713ac165874fc 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -39,14 +39,6 @@ #define _SEND_FILE_STEP_ 1000 #endif -#if defined(WINDOWS) -typedef int32_t FileFd; -typedef int32_t SocketFd; -#else -typedef int32_t FileFd; -typedef int32_t SocketFd; -#endif - typedef int32_t FileFd; typedef struct TdFile { @@ -54,19 +46,10 @@ typedef struct TdFile { int refId; FileFd fd; FILE *fp; -} * TdFilePtr, TdFile; +} TdFile; #define FILE_WITH_LOCK 1 -typedef struct AutoDelFile *AutoDelFilePtr; -typedef struct AutoDelFile { - char *name; - AutoDelFilePtr lastAutoDelFilePtr; -} AutoDelFile; -static TdThreadMutex autoDelFileLock; -static AutoDelFilePtr nowAutoDelFilePtr = NULL; -static TdThreadOnce autoDelFileInit = PTHREAD_ONCE_INIT; - void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath) { #ifdef WINDOWS const char *tdengineTmpFileNamePrefix = "tdengine-"; @@ -268,34 +251,6 @@ int32_t taosDevInoFile(TdFilePtr pFile, int64_t *stDev, int64_t *stIno) { return 0; } -void autoDelFileList() { - taosThreadMutexLock(&autoDelFileLock); - while (nowAutoDelFilePtr != NULL) { - taosRemoveFile(nowAutoDelFilePtr->name); - AutoDelFilePtr tmp = nowAutoDelFilePtr->lastAutoDelFilePtr; - taosMemoryFree(nowAutoDelFilePtr->name); - taosMemoryFree(nowAutoDelFilePtr); - nowAutoDelFilePtr = tmp; - } - taosThreadMutexUnlock(&autoDelFileLock); - taosThreadMutexDestroy(&autoDelFileLock); -} - -void autoDelFileListInit() { - taosThreadMutexInit(&autoDelFileLock, NULL); - atexit(autoDelFileList); -} - -void autoDelFileListAdd(const char *path) { - taosThreadOnce(&autoDelFileInit, autoDelFileListInit); - taosThreadMutexLock(&autoDelFileLock); - AutoDelFilePtr tmp = taosMemoryMalloc(sizeof(AutoDelFile)); - tmp->lastAutoDelFilePtr = nowAutoDelFilePtr; - tmp->name = taosMemoryStrDup(path); - nowAutoDelFilePtr = tmp; - taosThreadMutexUnlock(&autoDelFileLock); -} - TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) { int fd = -1; FILE *fp = NULL; @@ -313,7 +268,6 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) { assert(!(tdFileOptions & TD_FILE_EXCL)); fp = fopen(path, mode); if (fp == NULL) { - // terrno = TAOS_SYSTEM_ERROR(errno); return NULL; } } else { @@ -331,32 +285,44 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) { access |= (tdFileOptions & TD_FILE_TEXT) ? O_TEXT : 0; access |= (tdFileOptions & TD_FILE_EXCL) ? O_EXCL : 0; #ifdef WINDOWS - fd = _open(path, access, _S_IREAD | _S_IWRITE); + int32_t pmode = _S_IREAD | _S_IWRITE; + if (tdFileOptions & TD_FILE_AUTO_DEL) { + pmode |= _O_TEMPORARY; + } + fd = _open(path, access, pmode); #else fd = open(path, access, S_IRWXU | S_IRWXG | S_IRWXO); #endif if (fd == -1) { - // terrno = TAOS_SYSTEM_ERROR(errno); return NULL; } } TdFilePtr pFile = (TdFilePtr)taosMemoryMalloc(sizeof(TdFile)); if (pFile == NULL) { - // terrno = TSDB_CODE_OUT_OF_MEMORY; if (fd >= 0) close(fd); if (fp != NULL) fclose(fp); return NULL; } + #if FILE_WITH_LOCK taosThreadRwlockInit(&(pFile->rwlock), NULL); #endif pFile->fd = fd; pFile->fp = fp; pFile->refId = 0; + if (tdFileOptions & TD_FILE_AUTO_DEL) { - autoDelFileListAdd(path); +#ifdef WINDOWS + // do nothing, since the property of pmode is set with _O_TEMPORARY; the OS will recycle + // the file handle, as well as the space on disk. +#else + // Remove it instantly, so when the program exits normally/abnormally, the file + // will be automatically remove by OS. + unlink(path); +#endif } + return pFile; } @@ -560,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. @@ -570,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/test/CMakeLists.txt b/source/os/test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..21fb2ee630d2d0058ca48f94a1f39c10ce7abe40 --- /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 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f831f457f9e7215d6d80eed3e33cf2ebc9346f00 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 057d3a620c714b22e0dea9643f672782c93424ed..d9319485b7c3bbed717c054f6d63f91ca2220063 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 d2fac72c77dc55a1c9e7c087d1af8f78dc466409..0000000000000000000000000000000000000000 --- 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 3edd067ce2aafa35e96cf632badf04f822ce2454..ed254b651f421885ca159b3da2a373034e4d4d1a 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -21,6 +21,7 @@ #include "tdef.h" #include "thash.h" #include "tlog.h" +#include "tutil.h" #include "types.h" int32_t setChkInBytes1(const void *pLeft, const void *pRight) { @@ -243,7 +244,7 @@ int32_t compareJsonVal(const void *pLeft, const void *pRight) { } else if (leftType == TSDB_DATA_TYPE_NULL) { return 0; } else { - assert(0); + ASSERTS(0, "data type unexpected"); return 0; } } @@ -997,6 +998,7 @@ int32_t compareUint64Uint32(const void *pLeft, const void *pRight) { } int32_t compareJsonValDesc(const void *pLeft, const void *pRight) { return compareJsonVal(pRight, pLeft); } + /* * Compare two strings * TSDB_MATCH: Match @@ -1007,59 +1009,63 @@ int32_t compareJsonValDesc(const void *pLeft, const void *pRight) { return compa * '_': Matches one character * */ -int32_t patternMatch(const char *patterStr, const char *str, size_t size, const SPatternCompareInfo *pInfo) { +int32_t patternMatch(const char *pattern, size_t psize, const char *str, size_t ssize, + const SPatternCompareInfo *pInfo) { char c, c1; int32_t i = 0; int32_t j = 0; - int32_t o = 0; - int32_t m = 0; + int32_t nMatchChar = 0; - while ((c = patterStr[i++]) != 0) { + while ((i < psize) && ((c = pattern[i++]) != 0)) { if (c == pInfo->matchAll) { /* Match "*" */ - while ((c = patterStr[i++]) == pInfo->matchAll || c == pInfo->matchOne) { + while ((i < psize) && ((c = pattern[i++]) == pInfo->matchAll || c == pInfo->matchOne)) { if (c == pInfo->matchOne) { - if (j > size || str[j++] == 0) { - // empty string, return not match + if (j >= ssize || str[j++] == 0) { // empty string, return not match return TSDB_PATTERN_NOWILDCARDMATCH; } else { - ++o; + ++nMatchChar; } } } - if (c == 0) { + if (i >= psize && (c == pInfo->umatchOne || c == pInfo->umatchAll)) { return TSDB_PATTERN_MATCH; /* "*" at the end of the pattern matches */ } - char next[3] = {toupper(c), tolower(c), 0}; - m = o; + char rejectList[2] = {toupper(c), tolower(c)}; + + str += nMatchChar; + int32_t remain = ssize - nMatchChar; while (1) { - size_t n = strcspn(str + m, next); - str += m + n; + size_t n = tstrncspn(str, remain, rejectList, 2); + + str += n; + remain -= n; - if (str[0] == 0 || (n >= size)) { + if ((remain <= 0) || str[0] == 0) { break; } - int32_t ret = patternMatch(&patterStr[i], ++str, size - n - 1, pInfo); + int32_t ret = patternMatch(&pattern[i], psize - i, ++str, --remain, pInfo); if (ret != TSDB_PATTERN_NOMATCH) { return ret; } - m = 0; } + return TSDB_PATTERN_NOWILDCARDMATCH; } - c1 = str[j++]; - ++o; + if (j < ssize) { + c1 = str[j++]; + ++nMatchChar; - if (j <= size) { - if (c == '\\' && patterStr[i] == '_' && c1 == '_') { + if (c == '\\' && pattern[i] == '_' && c1 == '_') { i++; continue; } + if (c == c1 || tolower(c) == tolower(c1) || (c == pInfo->matchOne && c1 != 0)) { continue; } @@ -1068,39 +1074,49 @@ int32_t patternMatch(const char *patterStr, const char *str, size_t size, const return TSDB_PATTERN_NOMATCH; } - return (str[j] == 0 || j >= size) ? TSDB_PATTERN_MATCH : TSDB_PATTERN_NOMATCH; + return (j >= ssize || str[j] == 0) ? TSDB_PATTERN_MATCH : TSDB_PATTERN_NOMATCH; } -int32_t WCSPatternMatch(const TdUcs4 *patterStr, const TdUcs4 *str, size_t size, const SPatternCompareInfo *pInfo) { +int32_t wcsPatternMatch(const TdUcs4 *pattern, size_t psize, const TdUcs4 *str, size_t ssize, + const SPatternCompareInfo *pInfo) { TdUcs4 c, c1; - TdUcs4 matchOne = L'_'; // "_" - TdUcs4 matchAll = L'%'; // "%" int32_t i = 0; int32_t j = 0; + int32_t nMatchChar = 0; - while ((c = patterStr[i++]) != 0) { - if (c == matchAll) { /* Match "%" */ + while ((i < psize) && ((c = pattern[i++]) != 0)) { + if (c == pInfo->umatchAll) { /* Match "%" */ - while ((c = patterStr[i++]) == matchAll || c == matchOne) { - if (c == matchOne && (j >= size || str[j++] == 0)) { - return TSDB_PATTERN_NOWILDCARDMATCH; + while ((i < psize) && ((c = pattern[i++]) == pInfo->umatchAll || c == pInfo->umatchOne)) { + if (c == pInfo->umatchOne) { + if (j >= ssize || str[j++] == 0) { + return TSDB_PATTERN_NOWILDCARDMATCH; + } else { + ++nMatchChar; + } } } - if (c == 0) { + + if (i >= psize && (c == pInfo->umatchOne || c == pInfo->umatchAll)) { return TSDB_PATTERN_MATCH; } - TdUcs4 accept[3] = {towupper(c), towlower(c), 0}; + TdUcs4 rejectList[2] = {towupper(c), towlower(c)}; + + str += nMatchChar; + int32_t remain = ssize - nMatchChar; while (1) { - size_t n = wcscspn(str, accept); + size_t n = twcsncspn(str, remain, rejectList, 2); str += n; - if (str[0] == 0 || (n >= size)) { + remain -= n; + + if ((remain <= 0) || str[0] == 0) { break; } - int32_t ret = WCSPatternMatch(&patterStr[i], ++str, size - n - 1, pInfo); + int32_t ret = wcsPatternMatch(&pattern[i], psize - i, ++str, --remain, pInfo); if (ret != TSDB_PATTERN_NOMATCH) { return ret; } @@ -1109,10 +1125,16 @@ int32_t WCSPatternMatch(const TdUcs4 *patterStr, const TdUcs4 *str, size_t size, return TSDB_PATTERN_NOWILDCARDMATCH; } - c1 = str[j++]; + if (j < ssize) { + c1 = str[j++]; + nMatchChar++; + + if (c == L'\\' && pattern[i] == L'_' && c1 == L'_') { + i++; + continue; + } - if (j <= size) { - if (c == c1 || towlower(c) == towlower(c1) || (c == matchOne && c1 != 0)) { + if (c == c1 || towlower(c) == towlower(c1) || (c == pInfo->umatchOne && c1 != 0)) { continue; } } @@ -1120,16 +1142,39 @@ int32_t WCSPatternMatch(const TdUcs4 *patterStr, const TdUcs4 *str, size_t size, return TSDB_PATTERN_NOMATCH; } - return (j >= size || str[j] == 0) ? TSDB_PATTERN_MATCH : TSDB_PATTERN_NOMATCH; + return (j >= ssize || str[j] == 0) ? TSDB_PATTERN_MATCH : TSDB_PATTERN_NOMATCH; +} + +int32_t comparestrRegexNMatch(const void *pLeft, const void *pRight) { + return comparestrRegexMatch(pLeft, pRight) ? 0 : 1; } -int32_t compareStrRegexCompMatch(const void *pLeft, const void *pRight) { return compareStrRegexComp(pLeft, pRight); } +static int32_t doExecRegexMatch(const char *pString, const char *pPattern) { + int32_t ret = 0; + regex_t regex; + char msgbuf[256] = {0}; + + int32_t cflags = REG_EXTENDED; + if ((ret = regcomp(®ex, pPattern, cflags)) != 0) { + regerror(ret, ®ex, msgbuf, tListLen(msgbuf)); -int32_t compareStrRegexCompNMatch(const void *pLeft, const void *pRight) { - return compareStrRegexComp(pLeft, pRight) ? 0 : 1; + uError("Failed to compile regex pattern %s. reason %s", pPattern, msgbuf); + regfree(®ex); + return 1; + } + + regmatch_t pmatch[1]; + ret = regexec(®ex, pString, 1, pmatch, 0); + if (ret != 0 && ret != REG_NOMATCH) { + regerror(ret, ®ex, msgbuf, sizeof(msgbuf)); + uDebug("Failed to match %s with pattern %s, reason %s", pString, pPattern, msgbuf) + } + + regfree(®ex); + return (ret == 0) ? 0 : 1; } -int32_t compareStrRegexComp(const void *pLeft, const void *pRight) { +int32_t comparestrRegexMatch(const void *pLeft, const void *pRight) { size_t sz = varDataLen(pRight); char *pattern = taosMemoryMalloc(sz + 1); memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); @@ -1140,30 +1185,49 @@ int32_t compareStrRegexComp(const void *pLeft, const void *pRight) { memcpy(str, varDataVal(pLeft), sz); str[sz] = 0; - int32_t errCode = 0; - regex_t regex; - char msgbuf[256] = {0}; + int32_t ret = doExecRegexMatch(str, pattern); - int32_t cflags = REG_EXTENDED; - if ((errCode = regcomp(®ex, pattern, cflags)) != 0) { - regerror(errCode, ®ex, msgbuf, sizeof(msgbuf)); - uError("Failed to compile regex pattern %s. reason %s", pattern, msgbuf); - regfree(®ex); - taosMemoryFree(str); + taosMemoryFree(str); + taosMemoryFree(pattern); + + return (ret == 0) ? 0 : 1; + ; +} + +int32_t comparewcsRegexMatch(const void *pString, const void *pPattern) { + size_t len = varDataLen(pPattern); + char *pattern = taosMemoryMalloc(len + 1); + + int convertLen = taosUcs4ToMbs((TdUcs4 *)varDataVal(pPattern), len, pattern); + if (convertLen < 0) { taosMemoryFree(pattern); - return 1; + return TSDB_CODE_APP_ERROR; } - errCode = regexec(®ex, str, 0, NULL, 0); - if (errCode != 0 && errCode != REG_NOMATCH) { - regerror(errCode, ®ex, msgbuf, sizeof(msgbuf)); - uDebug("Failed to match %s with pattern %s, reason %s", str, pattern, msgbuf) + pattern[convertLen] = 0; + + len = varDataLen(pString); + char *str = taosMemoryMalloc(len + 1); + convertLen = taosUcs4ToMbs((TdUcs4 *)varDataVal(pString), len, str); + if (convertLen < 0) { + taosMemoryFree(str); + taosMemoryFree(pattern); + + return TSDB_CODE_APP_ERROR; } - int32_t result = (errCode == 0) ? 0 : 1; - regfree(®ex); + + str[convertLen] = 0; + + int32_t ret = doExecRegexMatch(str, pattern); + taosMemoryFree(str); taosMemoryFree(pattern); - return result; + + return (ret == 0) ? 0 : 1; +} + +int32_t comparewcsRegexNMatch(const void *pLeft, const void *pRight) { + return comparewcsRegexMatch(pLeft, pRight) ? 0 : 1; } int32_t taosArrayCompareString(const void *a, const void *b) { @@ -1173,46 +1237,35 @@ int32_t taosArrayCompareString(const void *a, const void *b) { return compareLenPrefixedStr(x, y); } -int32_t compareStrPatternMatch(const void *pLeft, const void *pRight) { - SPatternCompareInfo pInfo = {'%', '_'}; - - assert(varDataLen(pRight) <= TSDB_MAX_FIELD_LEN); - char *pattern = taosMemoryCalloc(varDataLen(pRight) + 1, sizeof(char)); - memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); +int32_t comparestrPatternMatch(const void *pLeft, const void *pRight) { + SPatternCompareInfo pInfo = PATTERN_COMPARE_INFO_INITIALIZER; + ASSERT(varDataLen(pRight) <= TSDB_MAX_FIELD_LEN); + size_t pLen = varDataLen(pRight); size_t sz = varDataLen(pLeft); - char *buf = taosMemoryMalloc(sz + 1); - memcpy(buf, varDataVal(pLeft), sz); - buf[sz] = 0; - int32_t ret = patternMatch(pattern, buf, sz, &pInfo); - taosMemoryFree(buf); - taosMemoryFree(pattern); + int32_t ret = patternMatch(varDataVal(pRight), pLen, varDataVal(pLeft), sz, &pInfo); return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; } -int32_t compareStrPatternNotMatch(const void *pLeft, const void *pRight) { - return compareStrPatternMatch(pLeft, pRight) ? 0 : 1; +int32_t comparestrPatternNMatch(const void *pLeft, const void *pRight) { + return comparestrPatternMatch(pLeft, pRight) ? 0 : 1; } -int32_t compareWStrPatternMatch(const void *pLeft, const void *pRight) { - SPatternCompareInfo pInfo = {'%', '_'}; +int32_t comparewcsPatternMatch(const void *pLeft, const void *pRight) { + SPatternCompareInfo pInfo = PATTERN_COMPARE_INFO_INITIALIZER; - assert(varDataLen(pRight) <= TSDB_MAX_FIELD_LEN * TSDB_NCHAR_SIZE); - - char *pattern = taosMemoryCalloc(varDataLen(pRight) + TSDB_NCHAR_SIZE, 1); - memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); - - int32_t ret = - WCSPatternMatch((TdUcs4 *)pattern, (TdUcs4 *)varDataVal(pLeft), varDataLen(pLeft) / TSDB_NCHAR_SIZE, &pInfo); - taosMemoryFree(pattern); + size_t psize = varDataLen(pRight); + int32_t ret = wcsPatternMatch((TdUcs4 *)varDataVal(pRight), psize / TSDB_NCHAR_SIZE, (TdUcs4 *)varDataVal(pLeft), + varDataLen(pLeft) / TSDB_NCHAR_SIZE, &pInfo); return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; } -int32_t compareWStrPatternNotMatch(const void *pLeft, const void *pRight) { - return compareWStrPatternMatch(pLeft, pRight) ? 0 : 1; +int32_t comparewcsPatternNMatch(const void *pLeft, const void *pRight) { + return comparewcsPatternMatch(pLeft, pRight) ? 0 : 1; } + __compar_fn_t getComparFunc(int32_t type, int32_t optr) { __compar_fn_t comparFn = NULL; @@ -1235,7 +1288,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { case TSDB_DATA_TYPE_TIMESTAMP: return setChkInBytes8; default: - assert(0); + ASSERTS(0, "data type unexpected"); } } @@ -1258,7 +1311,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { case TSDB_DATA_TYPE_TIMESTAMP: return setChkNotInBytes8; default: - assert(0); + ASSERTS(0, "data type unexpected"); } } @@ -1285,13 +1338,13 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { break; case TSDB_DATA_TYPE_BINARY: { if (optr == OP_TYPE_MATCH) { - comparFn = compareStrRegexCompMatch; + comparFn = comparestrRegexMatch; } else if (optr == OP_TYPE_NMATCH) { - comparFn = compareStrRegexCompNMatch; + comparFn = comparestrRegexNMatch; } else if (optr == OP_TYPE_LIKE) { /* wildcard query using like operator */ - comparFn = compareStrPatternMatch; + comparFn = comparestrPatternMatch; } else if (optr == OP_TYPE_NOT_LIKE) { /* wildcard query using like operator */ - comparFn = compareStrPatternNotMatch; + comparFn = comparestrPatternNMatch; } else if (optr == OP_TYPE_IN) { comparFn = compareChkInString; } else if (optr == OP_TYPE_NOT_IN) { @@ -1305,13 +1358,13 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { case TSDB_DATA_TYPE_NCHAR: { if (optr == OP_TYPE_MATCH) { - comparFn = compareStrRegexCompMatch; + comparFn = comparewcsRegexMatch; } else if (optr == OP_TYPE_NMATCH) { - comparFn = compareStrRegexCompNMatch; + comparFn = comparewcsRegexNMatch; } else if (optr == OP_TYPE_LIKE) { - comparFn = compareWStrPatternMatch; + comparFn = comparewcsPatternMatch; } else if (optr == OP_TYPE_NOT_LIKE) { - comparFn = compareWStrPatternNotMatch; + comparFn = comparewcsPatternNMatch; } else if (optr == OP_TYPE_IN) { comparFn = compareChkInString; } else if (optr == OP_TYPE_NOT_IN) { diff --git a/source/util/src/tcompression.c b/source/util/src/tcompression.c index 18305e594b7942019c955523109941b05779618c..64d550e874f8a7f22b54a3f5ac27e59c317f8025 100644 --- a/source/util/src/tcompression.c +++ b/source/util/src/tcompression.c @@ -273,42 +273,90 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha char bit = bit_per_integer[(int32_t)selector]; // bit = 3 int32_t elems = selector_to_elems[(int32_t)selector]; - for (int32_t i = 0; i < elems; i++) { - uint64_t zigzag_value; + // Optimize the performance, by remove the constantly switch operation. + int32_t v = 0; + uint64_t zigzag_value; + + switch (type) { + case TSDB_DATA_TYPE_BIGINT: { + for (int32_t i = 0; i < elems; i++) { + if (selector == 0 || selector == 1) { + zigzag_value = 0; + } else { + zigzag_value = ((w >> (4 + v)) & INT64MASK(bit)); + } - if (selector == 0 || selector == 1) { - zigzag_value = 0; - } else { - zigzag_value = ((w >> (4 + bit * i)) & INT64MASK(bit)); - } - int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); - int64_t curr_value = diff + prev_value; - prev_value = curr_value; + int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); + int64_t curr_value = diff + prev_value; + prev_value = curr_value; - switch (type) { - case TSDB_DATA_TYPE_BIGINT: *((int64_t *)output + _pos) = (int64_t)curr_value; _pos++; - break; - case TSDB_DATA_TYPE_INT: + + v += bit; + if ((++count) == nelements) break; + } + } break; + case TSDB_DATA_TYPE_INT: { + for (int32_t i = 0; i < elems; i++) { + if (selector == 0 || selector == 1) { + zigzag_value = 0; + } else { + zigzag_value = ((w >> (4 + v)) & INT64MASK(bit)); + } + + int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); + int64_t curr_value = diff + prev_value; + prev_value = curr_value; + *((int32_t *)output + _pos) = (int32_t)curr_value; _pos++; - break; - case TSDB_DATA_TYPE_SMALLINT: + + v += bit; + if ((++count) == nelements) break; + } + } break; + case TSDB_DATA_TYPE_SMALLINT: { + for (int32_t i = 0; i < elems; i++) { + if (selector == 0 || selector == 1) { + zigzag_value = 0; + } else { + zigzag_value = ((w >> (4 + v)) & INT64MASK(bit)); + } + + int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); + int64_t curr_value = diff + prev_value; + prev_value = curr_value; + *((int16_t *)output + _pos) = (int16_t)curr_value; _pos++; - break; - case TSDB_DATA_TYPE_TINYINT: + + v += bit; + if ((++count) == nelements) break; + } + } break; + + case TSDB_DATA_TYPE_TINYINT: { + for (int32_t i = 0; i < elems; i++) { + if (selector == 0 || selector == 1) { + zigzag_value = 0; + } else { + zigzag_value = ((w >> (4 + v)) & INT64MASK(bit)); + } + + int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); + int64_t curr_value = diff + prev_value; + prev_value = curr_value; + *((int8_t *)output + _pos) = (int8_t)curr_value; _pos++; - break; - default: - perror("Wrong integer types.\n"); - return -1; - } - count++; - if (count == nelements) break; + + v += bit; + if ((++count) == nelements) break; + } + } break; } + ip += LONG_BYTES; } @@ -470,7 +518,7 @@ int32_t tsDecompressStringImp(const char *const input, int32_t compressedSize, c // TODO: Take care here, we assumes little endian encoding. int32_t tsCompressTimestampImp(const char *const input, const int32_t nelements, char *const output) { int32_t _pos = 1; - assert(nelements >= 0); + ASSERTS(nelements >= 0, "nelements is negative"); if (nelements == 0) return 0; @@ -565,7 +613,7 @@ _exit_over: } int32_t tsDecompressTimestampImp(const char *const input, const int32_t nelements, char *const output) { - assert(nelements >= 0); + ASSERTS(nelements >= 0, "nelements is negative"); if (nelements == 0) return 0; if (input[0] == 0) { @@ -629,7 +677,7 @@ int32_t tsDecompressTimestampImp(const char *const input, const int32_t nelement } } else { - assert(0); + ASSERT(0); return -1; } } @@ -758,7 +806,7 @@ int32_t tsDecompressDoubleImp(const char *const input, const int32_t nelements, uint64_t prev_value = 0; for (int32_t i = 0; i < nelements; i++) { - if (i % 2 == 0) { + if ((i & 0x01) == 0) { flags = input[ipos++]; } @@ -2146,7 +2194,7 @@ int32_t tsCompressTimestamp(void *pIn, int32_t nIn, int32_t nEle, void *pOut, in int32_t len = tsCompressTimestampImp(pIn, nEle, pBuf); return tsCompressStringImp(pBuf, len, pOut, nOut); } else { - assert(0); + ASSERTS(0, "compress algo not one or two stage"); return -1; } } @@ -2159,7 +2207,7 @@ int32_t tsDecompressTimestamp(void *pIn, int32_t nIn, int32_t nEle, void *pOut, if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; return tsDecompressTimestampImp(pBuf, nEle, pOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2180,7 +2228,7 @@ int32_t tsCompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_ int32_t len = tsCompressFloatImp(pIn, nEle, pBuf); return tsCompressStringImp(pBuf, len, pOut, nOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } #ifdef TD_TSZ @@ -2203,7 +2251,7 @@ int32_t tsDecompressFloat(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int3 if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; return tsDecompressFloatImp(pBuf, nEle, pOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } #ifdef TD_TSZ @@ -2227,7 +2275,7 @@ int32_t tsCompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32 int32_t len = tsCompressDoubleImp(pIn, nEle, pBuf); return tsCompressStringImp(pBuf, len, pOut, nOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } #ifdef TD_TSZ @@ -2250,7 +2298,7 @@ int32_t tsDecompressDouble(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; return tsDecompressDoubleImp(pBuf, nEle, pOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } #ifdef TD_TSZ @@ -2281,7 +2329,7 @@ int32_t tsCompressBool(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t } return tsCompressStringImp(pBuf, len, pOut, nOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2294,7 +2342,7 @@ int32_t tsDecompressBool(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32 if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; return tsDecompressBoolImp(pBuf, nEle, pOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2308,7 +2356,7 @@ int32_t tsCompressTinyint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int3 int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_TINYINT); return tsCompressStringImp(pBuf, len, pOut, nOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2321,7 +2369,7 @@ int32_t tsDecompressTinyint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, in if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_TINYINT); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2335,7 +2383,7 @@ int32_t tsCompressSmallint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_SMALLINT); return tsCompressStringImp(pBuf, len, pOut, nOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2348,7 +2396,7 @@ int32_t tsDecompressSmallint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, i if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_SMALLINT); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2362,7 +2410,7 @@ int32_t tsCompressInt(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_INT); return tsCompressStringImp(pBuf, len, pOut, nOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2375,7 +2423,7 @@ int32_t tsDecompressInt(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_ if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_INT); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2389,7 +2437,7 @@ int32_t tsCompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32 int32_t len = tsCompressINTImp(pIn, nEle, pBuf, TSDB_DATA_TYPE_BIGINT); return tsCompressStringImp(pBuf, len, pOut, nOut); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } @@ -2402,7 +2450,7 @@ int32_t tsDecompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int if (tsDecompressStringImp(pIn, nIn, pBuf, nBuf) < 0) return -1; return tsDecompressINTImp(pBuf, nEle, pOut, TSDB_DATA_TYPE_BIGINT); } else { - assert(0); + ASSERTS(0, "compress algo invalid"); return -1; } } diff --git a/source/util/src/tdigest.c b/source/util/src/tdigest.c index 337ee803ffbf4fa3a715251daa1c8b850b06e17d..b46a50b2dc03bcf1242eded9028424327121b612 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 7bf63abc5febd6b7c99e0ba9b5061748aa58ae8f..08ab43494df2934a22a775c1fadbf85934d5e898 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -277,8 +277,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_SUBSCRIBE_NOT_EXIST, "Subcribe not exist") TAOS_DEFINE_ERROR(TSDB_CODE_MND_OFFSET_NOT_EXIST, "Offset not exist") TAOS_DEFINE_ERROR(TSDB_CODE_MND_CONSUMER_NOT_READY, "Consumer not ready") TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOPIC_SUBSCRIBED, "Topic subscribed cannot be dropped") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOPIC_MUST_BE_DELETED, "Topic must be dropped first") TAOS_DEFINE_ERROR(TSDB_CODE_MND_CGROUP_USED, "Consumer group being used by some consumer") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOPIC_MUST_BE_DELETED, "Topic must be dropped first") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SUB_OPTION, "Invalid subscribe option") TAOS_DEFINE_ERROR(TSDB_CODE_MND_IN_REBALANCE, "Topic being rebalanced") // mnode-stream diff --git a/source/util/src/texception.c b/source/util/src/texception.c index 33befb694a0a0a71c01042d9c9b5b19f7da12912..4723e349903505923de5790cdbca223a0d5073b5 100644 --- a/source/util/src/texception.c +++ b/source/util/src/texception.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "texception.h" +#include "tlog.h" static threadlocal SExceptionNode* expList; @@ -71,7 +72,7 @@ static wrapper wrappers[] = { }; void cleanupPush_void_ptr_ptr(bool failOnly, void* func, void* arg1, void* arg2) { - assert(expList->numCleanupAction < expList->maxCleanupAction); + ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction"); SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++; ca->wrapper = 0; @@ -82,7 +83,7 @@ void cleanupPush_void_ptr_ptr(bool failOnly, void* func, void* arg1, void* arg2) } void cleanupPush_void_ptr_bool(bool failOnly, void* func, void* arg1, bool arg2) { - assert(expList->numCleanupAction < expList->maxCleanupAction); + ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction"); SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++; ca->wrapper = 1; @@ -93,7 +94,7 @@ void cleanupPush_void_ptr_bool(bool failOnly, void* func, void* arg1, bool arg2) } void cleanupPush_void_ptr(bool failOnly, void* func, void* arg) { - assert(expList->numCleanupAction < expList->maxCleanupAction); + ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction"); SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++; ca->wrapper = 2; @@ -103,7 +104,7 @@ void cleanupPush_void_ptr(bool failOnly, void* func, void* arg) { } void cleanupPush_int_int(bool failOnly, void* func, int32_t arg) { - assert(expList->numCleanupAction < expList->maxCleanupAction); + ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction"); SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++; ca->wrapper = 3; @@ -113,7 +114,7 @@ void cleanupPush_int_int(bool failOnly, void* func, int32_t arg) { } void cleanupPush_void(bool failOnly, void* func) { - assert(expList->numCleanupAction < expList->maxCleanupAction); + ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction"); SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++; ca->wrapper = 4; @@ -122,7 +123,7 @@ void cleanupPush_void(bool failOnly, void* func) { } void cleanupPush_int_ptr(bool failOnly, void* func, void* arg) { - assert(expList->numCleanupAction < expList->maxCleanupAction); + ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction"); SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++; ca->wrapper = 5; diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index f6f814d82b8f1de69e28790bb6407c629446590e..53d0cad5eabbbcf5f6c6b38833ebf1c9fd172cce 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -790,7 +790,7 @@ cmp_end: return ret; } -bool taosAssert(bool condition, const char *file, int32_t line, const char *format, ...) { +bool taosAssertDebug(bool condition, const char *file, int32_t line, const char *format, ...) { if (condition) return false; const char *flags = "UTL FATAL "; @@ -822,4 +822,24 @@ bool taosAssert(bool condition, const char *file, int32_t line, const char *form } return true; -} \ No newline at end of file +} + +#ifdef NDEBUG +bool taosAssertRelease(bool condition) { + if (condition) return false; + + const char *flags = "UTL FATAL "; + ELogLevel level = DEBUG_FATAL; + int32_t dflag = 255; // tsLogEmbedded ? 255 : uDebugFlag + + taosPrintLog(flags, level, dflag, "tAssert called in release mode, exit:%d", tsAssert); + taosPrintTrace(flags, level, dflag); + + if (tsAssert) { + taosMsleep(300); + abort(); + } + + return true; +} +#endif \ No newline at end of file diff --git a/source/util/src/tlosertree.c b/source/util/src/tlosertree.c index aeb9ce310b3a8802120fa58e52a3fc88a57b7eec..bf99212b78d4e75d3cbe3eb9823881168e03c129 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 ced5b4f25e3f86e2a360cf60d964b7566b8b94a3..87b44b2d1337ab157e4499f5165abf0868069bc5 100644 --- a/source/util/src/tpagedbuf.c +++ b/source/util/src/tpagedbuf.c @@ -125,20 +125,20 @@ static FORCE_INLINE size_t getAllocPageSize(int32_t pageSize) { return pageSize * @return */ static char* doFlushPageToDisk(SDiskbasedBuf* pBuf, SPageInfo* pg) { - assert(!pg->used && pg->pData != NULL); + ASSERT(!pg->used && pg->pData != NULL); int32_t size = pBuf->pageSize; char* t = NULL; if (pg->offset == -1 || pg->dirty) { void* payload = GET_DATA_PAYLOAD(pg); t = doCompressData(payload, pBuf->pageSize, &size, pBuf); - assert(size >= 0); + ASSERTS(size >= 0, "size is negative"); } // this page is flushed to disk for the first time if (pg->dirty) { if (pg->offset == -1) { - assert(pg->dirty == true); + ASSERTS(pg->dirty == true, "pg->dirty is false"); pg->offset = allocatePositionInFile(pBuf, size); pBuf->nextPos += size; @@ -210,7 +210,7 @@ static char* doFlushPageToDisk(SDiskbasedBuf* pBuf, SPageInfo* pg) { static char* flushPageToDisk(SDiskbasedBuf* pBuf, SPageInfo* pg) { int32_t ret = TSDB_CODE_SUCCESS; - assert(((int64_t)pBuf->numOfPages * pBuf->pageSize) == pBuf->totalBufSize && pBuf->numOfPages >= pBuf->inMemPages); + ASSERT(((int64_t)pBuf->numOfPages * pBuf->pageSize) == pBuf->totalBufSize && pBuf->numOfPages >= pBuf->inMemPages); if (pBuf->pFile == NULL) { if ((ret = createDiskFile(pBuf)) != TSDB_CODE_SUCCESS) { @@ -272,7 +272,7 @@ static SListNode* getEldestUnrefedPage(SDiskbasedBuf* pBuf) { SListNode* pn = NULL; while ((pn = tdListNext(&iter)) != NULL) { SPageInfo* pageInfo = *(SPageInfo**)pn->data; - assert(pageInfo->pageId >= 0 && pageInfo->pn == pn); + ASSERT(pageInfo->pageId >= 0 && pageInfo->pn == pn); if (!pageInfo->used) { // printf("%d is chosen\n", pageInfo->pageId); @@ -303,7 +303,7 @@ static char* evacOneDataPage(SDiskbasedBuf* pBuf) { tdListPopNode(pBuf->lruList, pn); SPageInfo* d = *(SPageInfo**)pn->data; - assert(d->pn == pn); + ASSERTS(d->pn == pn, "d->pn not equal pn"); d->pn = NULL; taosMemoryFreeClear(pn); @@ -353,7 +353,7 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMem pPBuf->freePgList = tdListNew(POINTER_BYTES); // at least more than 2 pages must be in memory - assert(inMemBufSize >= pagesize * 2); + ASSERT(inMemBufSize >= pagesize * 2); pPBuf->lruList = tdListNew(POINTER_BYTES); @@ -402,7 +402,7 @@ void* getNewBufPage(SDiskbasedBuf* pBuf, int32_t* pageId) { } // add to LRU list - assert(listNEles(pBuf->lruList) < pBuf->inMemPages && pBuf->inMemPages > 0); + ASSERT(listNEles(pBuf->lruList) < pBuf->inMemPages && pBuf->inMemPages > 0); lruListPushFront(pBuf->lruList, pi); // allocate buf @@ -421,11 +421,11 @@ void* getNewBufPage(SDiskbasedBuf* pBuf, int32_t* pageId) { } void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) { - assert(pBuf != NULL && id >= 0); + ASSERT(pBuf != NULL && id >= 0); pBuf->statis.getPages += 1; SPageInfo** pi = taosHashGet(pBuf->all, &id, sizeof(int32_t)); - assert(pi != NULL && *pi != NULL); + ASSERT(pi != NULL && *pi != NULL); if ((*pi)->pData != NULL) { // it is in memory // no need to update the LRU list if only one page exists @@ -435,7 +435,7 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) { } SPageInfo** pInfo = (SPageInfo**)((*pi)->pn->data); - assert(*pInfo == *pi); + ASSERT(*pInfo == *pi); lruListMoveToFront(pBuf->lruList, (*pi)); (*pi)->used = true; @@ -444,7 +444,7 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) { #endif return (void*)(GET_DATA_PAYLOAD(*pi)); } else { // not in memory - assert((*pi)->pData == NULL && (*pi)->pn == NULL && + ASSERT((*pi)->pData == NULL && (*pi)->pn == NULL && (((*pi)->length >= 0 && (*pi)->offset >= 0) || ((*pi)->length == -1 && (*pi)->offset == -1))); char* availablePage = NULL; @@ -482,7 +482,9 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) { } void releaseBufPage(SDiskbasedBuf* pBuf, void* page) { - assert(pBuf != NULL && page != NULL); + if (ASSERTS(pBuf != NULL && page != NULL, "pBuf or page is NULL")) { + return; + } SPageInfo* ppi = getPageInfoFromPayload(page); releaseBufPageInfo(pBuf, ppi); } @@ -491,8 +493,10 @@ void releaseBufPageInfo(SDiskbasedBuf* pBuf, SPageInfo* pi) { #ifdef BUF_PAGE_DEBUG uDebug("page_releaseBufPageInfo pageId:%d, used:%d, offset:%" PRId64, pi->pageId, pi->used, pi->offset); #endif - // assert(pi->pData != NULL && pi->used == true); - assert(pi->pData != NULL); + if (ASSERTS(pi->pData != NULL, "pi->pData is NULL")) { + return; + } + pi->used = false; pBuf->statis.releasePages += 1; } diff --git a/source/util/src/trbtree.c b/source/util/src/trbtree.c index c6aea874704a9508c7a75568fc976226a07402e1..ffae5441aa088f2cc71710b301d5243cb3975235 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 75a16b0ad706668edc1ad2567aa9393a06fc685d..e70e12b37b4366d60bbb87c3eee33fc08bcced73 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 51d0a59d001b12cd64775cf43b20f83ee0f1a638..7e99d6a35cf2eafeb8205e768152b5fb0deb0bd7 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 addb9f55ba9760f8f5d6f915836ca22260f67333..e94f94a00dcdd3b625b9bf705bf19a5febae43a9 100644 --- a/source/util/src/tutil.c +++ b/source/util/src/tutil.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "tutil.h" +#include "tlog.h" void *tmemmem(const char *haystack, int32_t hlen, const char *needle, int32_t nlen) { const char *limit; @@ -117,7 +118,7 @@ char **strsplit(char *z, const char *delim, int32_t *num) { if ((*num) >= size) { size = (size << 1); split = taosMemoryRealloc(split, POINTER_BYTES * size); - assert(NULL != split); + ASSERTS(NULL != split, "realloc memory failed. size=%d", POINTER_BYTES * size); } } @@ -144,11 +145,23 @@ char *strnchr(const char *haystack, char needle, int32_t len, bool skipquote) { return NULL; } +TdUcs4* wcsnchr(const TdUcs4* haystack, TdUcs4 needle, size_t len) { + for(int32_t i = 0; i < len; ++i) { + if (haystack[i] == needle) { + return (TdUcs4*) &haystack[i]; + } + } + + return NULL; +} + char *strtolower(char *dst, const char *src) { int32_t esc = 0; char quote = 0, *p = dst, c; - assert(dst != NULL); + if (ASSERTS(dst != NULL, "dst is NULL")) { + return NULL; + } for (c = *src++; c; c = *src++) { if (esc) { @@ -175,7 +188,10 @@ char *strntolower(char *dst, const char *src, int32_t n) { int32_t esc = 0; char quote = 0, *p = dst, c; - assert(dst != NULL); + if (ASSERTS(dst != NULL, "dst is NULL")) { + return NULL; + } + if (n == 0) { *p = 0; return dst; @@ -204,7 +220,10 @@ char *strntolower(char *dst, const char *src, int32_t n) { char *strntolower_s(char *dst, const char *src, int32_t n) { char *p = dst, c; - assert(dst != NULL); + if (ASSERTS(dst != NULL, "dst is NULL")) { + return NULL; + } + if (n == 0) { return NULL; } @@ -376,3 +395,73 @@ void taosIp2String(uint32_t ip, char *str) { void taosIpPort2String(uint32_t ip, uint16_t port, char *str) { sprintf(str, "%u.%u.%u.%u:%u", ip & 0xFF, (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, (uint8_t)(ip >> 24), port); } + +size_t tstrncspn(const char *str, size_t size, const char *reject, size_t rsize) { + if (rsize == 0 || rsize == 1) { + char* p = strnchr(str, reject[0], size, false); + return (p == NULL)? size:(p-str); + } + + /* Use multiple small memsets to enable inlining on most targets. */ + unsigned char table[256]; + unsigned char *p = memset(table, 0, 64); + memset(p + 64, 0, 64); + memset(p + 128, 0, 64); + memset(p + 192, 0, 64); + + unsigned char *s = (unsigned char *)reject; + int32_t index = 0; + do { + p[s[index++]] = 1; + } while (index < rsize); + + s = (unsigned char*) str; + int32_t times = size >> 2; + if (times == 0) { + for(int32_t i = 0; i < size; ++i) { + if (p[s[i]]) { + return i; + } + } + + return size; + } + + index = 0; + uint32_t c0, c1, c2, c3; + for(int32_t i = 0; i < times; ++i, index += 4) { + int32_t j = index; + c0 = p[s[j]]; + c1 = p[s[j + 1]]; + c2 = p[s[j + 2]]; + c3 = p[s[j + 3]]; + + if ((c0 | c1 | c2 | c3) != 0) { + size_t count = ((i + 1) >> 2); + return (c0 | c1) != 0 ? count - c0 + 1 : count - c2 + 3; + } + } + + int32_t offset = times * 4; + for(int32_t i = offset; i < size; ++i) { + if (p[s[i]]) { + return i; + } + } + + return size; +} + +size_t twcsncspn(const TdUcs4 *wcs, size_t size, const TdUcs4 *reject, size_t rsize) { + if (rsize == 0 || rsize == 1) { + TdUcs4* p = wcsnchr(wcs, reject[0], size); + return (p == NULL)? size:(p-wcs); + } + + size_t index = 0; + while ((index < size) && (wcsnchr(reject, wcs[index], rsize) == NULL)) { + ++index; + } + + return index; +} diff --git a/source/util/test/utilTests.cpp b/source/util/test/utilTests.cpp index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c56ef348cc3754499a15a84fad3cd93603901077 100644 --- a/source/util/test/utilTests.cpp +++ b/source/util/test/utilTests.cpp @@ -0,0 +1,297 @@ +#include +#include +#include +#include + +#include "tarray.h" +#include "tcompare.h" + +namespace { +} // namespace + +TEST(utilTest, wchar_pattern_match_test) { + const TdWchar* pattern = L"%1"; + + int32_t ret = 0; + SPatternCompareInfo pInfo = PATTERN_COMPARE_INFO_INITIALIZER; + + const TdWchar* str0 = L"14"; + ret = wcsPatternMatch(reinterpret_cast(pattern), 2, reinterpret_cast(str0), wcslen(str0), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const TdWchar* str1 = L"11"; + ret = wcsPatternMatch(reinterpret_cast(pattern), 2, reinterpret_cast(str1), wcslen(str1), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* str2 = L"41"; + ret = wcsPatternMatch(reinterpret_cast(pattern), 2, reinterpret_cast(str2), wcslen(str2), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern3 = L"%_"; + const TdWchar* str3 = L"88"; + ret = wcsPatternMatch(reinterpret_cast(pattern3), 2, reinterpret_cast(str3), wcslen(str3), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern4 = L"%___"; + const TdWchar* str4 = L"88"; + ret = wcsPatternMatch(reinterpret_cast(pattern4), 4, reinterpret_cast(str4), wcslen(str4), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const TdWchar* pattern5 = L"%___"; + const TdWchar* str5 = L"883391"; + ret = wcsPatternMatch(reinterpret_cast(pattern5), 4, reinterpret_cast(str5), wcslen(str5), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern6 = L"%___66"; + const TdWchar* str6 = L"88339166"; + ret = wcsPatternMatch(reinterpret_cast(pattern6), 6, reinterpret_cast(str6), wcslen(str6), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern7 = L"%____66"; + const TdWchar* str7 = L"66166"; + ret = wcsPatternMatch(reinterpret_cast(pattern7), 7, reinterpret_cast(str7), wcslen(str7), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const TdWchar* pattern8 = L"6%____66"; + const TdWchar* str8 = L"666166"; + ret = wcsPatternMatch(reinterpret_cast(pattern8), 8, reinterpret_cast(str8), wcslen(str8), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const TdWchar* pattern9 = L"6\\__6"; + const TdWchar* str9 = L"6_66"; + ret = wcsPatternMatch(reinterpret_cast(pattern9), 6, reinterpret_cast(str9), wcslen(str9), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern10 = L"%"; + const TdWchar* str10 = L""; + ret = wcsPatternMatch(reinterpret_cast(pattern10), 1, reinterpret_cast(str10), 0, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern11 = L"china%"; + const TdWchar* str11 = L"CHI "; + ret = wcsPatternMatch(reinterpret_cast(pattern11), 6, reinterpret_cast(str11), 3, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOMATCH); + + const TdWchar* pattern12 = L"abc%"; + const TdWchar* str12 = L""; + ret = wcsPatternMatch(reinterpret_cast(pattern12), 4, reinterpret_cast(str12), 0, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOMATCH); +} + +TEST(utilTest, wchar_pattern_match_no_terminated) { + const TdWchar* pattern = L"%1 "; + + int32_t ret = 0; + SPatternCompareInfo pInfo = PATTERN_COMPARE_INFO_INITIALIZER; + + const TdWchar* str0 = L"14 "; + ret = wcsPatternMatch(reinterpret_cast(pattern), 2, reinterpret_cast(str0), 2, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const TdWchar* str1 = L"11 "; + ret = wcsPatternMatch(reinterpret_cast(pattern), 2, reinterpret_cast(str1), 2, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* str2 = L"41 "; + ret = wcsPatternMatch(reinterpret_cast(pattern), 2, reinterpret_cast(str2), 2, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern3 = L"%_ "; + const TdWchar* str3 = L"88 "; + ret = wcsPatternMatch(reinterpret_cast(pattern3), 2, reinterpret_cast(str3), 2, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern4 = L"%___ "; + const TdWchar* str4 = L"88 "; + ret = wcsPatternMatch(reinterpret_cast(pattern4), 4, reinterpret_cast(str4), 2, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const TdWchar* pattern5 = L"%___ "; + const TdWchar* str5 = L"883391 "; + ret = wcsPatternMatch(reinterpret_cast(pattern5), 4, reinterpret_cast(str5), 6, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern6 = L"%___66 "; + const TdWchar* str6 = L"88339166 "; + ret = wcsPatternMatch(reinterpret_cast(pattern6), 6, reinterpret_cast(str6), 8, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern7 = L"%____66 "; + const TdWchar* str7 = L"66166 "; + ret = wcsPatternMatch(reinterpret_cast(pattern7), 7, reinterpret_cast(str7), 5, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const TdWchar* pattern8 = L"6%____66 "; + const TdWchar* str8 = L"666166 "; + ret = wcsPatternMatch(reinterpret_cast(pattern8), 8, reinterpret_cast(str8), 6, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const TdWchar* pattern9 = L"6\\_6 "; + const TdWchar* str9 = L"6_6 "; + ret = wcsPatternMatch(reinterpret_cast(pattern9), 4, reinterpret_cast(str9), 3, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const TdWchar* pattern10 = L"% "; + const TdWchar* str10 = L"6_6 "; + ret = wcsPatternMatch(reinterpret_cast(pattern10), 1, reinterpret_cast(str10), 3, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); +} + +TEST(utilTest, char_pattern_match_test) { + const char* pattern = "%1"; + + int32_t ret = 0; + SPatternCompareInfo pInfo = PATTERN_COMPARE_INFO_INITIALIZER; + + const char* str0 = "14"; + ret = patternMatch(pattern, 2, str0, strlen(str0), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const char* str1 = "11"; + ret = patternMatch(pattern, 2, str1, strlen(str1), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* str2 = "41"; + ret = patternMatch(pattern, 2, str2, strlen(str2), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern3 = "%_"; + const char* str3 = "88"; + ret = patternMatch(pattern3, 2, str3, strlen(str3), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern4 = "%___"; + const char* str4 = "88"; + ret = patternMatch(pattern4, 4, str4, strlen(str4), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const char* pattern5 = "%___"; + const char* str5 = "883391"; + ret = patternMatch(pattern5, 4, str5, strlen(str5), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern6 = "%___66"; + const char* str6 = "88339166"; + ret = patternMatch(pattern6, 6, str6, strlen(str6), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern7 = "%____66"; + const char* str7 = "66166"; + ret = patternMatch(pattern7, 7, str7, strlen(str7), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const char* pattern8 = "6%____66"; + const char* str8 = "666166"; + ret = patternMatch(pattern8, 8, str8, strlen(str8), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const char* pattern9 = "6\\_6"; + const char* str9 = "6_6"; + ret = patternMatch(pattern9, 5, str9, strlen(str9), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern10 = "%"; + const char* str10 = " "; + ret = patternMatch(pattern10, 1, str10, 0, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern11 = "china%"; + const char* str11 = "abc "; + ret = patternMatch(pattern11, 6, str11, 3, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOMATCH); + + const char* pattern12 = "abc%"; + const char* str12 = NULL; + ret = patternMatch(pattern12, 4, str12, 0, &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOMATCH); +} + +TEST(utilTest, char_pattern_match_no_terminated) { + const char* pattern = "%1 "; + + int32_t ret = 0; + SPatternCompareInfo pInfo = PATTERN_COMPARE_INFO_INITIALIZER; + + const char* str0 = "14"; + ret = patternMatch(pattern, 2, str0, strlen(str0), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const char* str1 = "11"; + ret = patternMatch(pattern, 2, str1, strlen(str1), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* str2 = "41"; + ret = patternMatch(pattern, 2, str2, strlen(str2), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern3 = "%_ "; + const char* str3 = "88"; + ret = patternMatch(pattern3, 2, str3, strlen(str3), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern4 = "%___ "; + const char* str4 = "88"; + ret = patternMatch(pattern4, 4, str4, strlen(str4), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const char* pattern5 = "%___ "; + const char* str5 = "883391"; + ret = patternMatch(pattern5, 4, str5, strlen(str5), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern6 = "%___66 "; + const char* str6 = "88339166"; + ret = patternMatch(pattern6, 6, str6, strlen(str6), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern7 = "%____66 "; + const char* str7 = "66166"; + ret = patternMatch(pattern7, 7, str7, strlen(str7), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const char* pattern8 = "6%____66 "; + const char* str8 = "666166"; + ret = patternMatch(pattern8, 8, str8, strlen(str8), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_NOWILDCARDMATCH); + + const char* pattern9 = "6\\_6 "; + const char* str9 = "6_6"; + ret = patternMatch(pattern9, 4, str9, strlen(str9), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); + + const char* pattern10 = "% "; + const char* str10 = "6_6"; + ret = patternMatch(pattern10, 1, str10, strlen(str10), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); +} + +TEST(utilTest, tstrncspn) { + const char* p1 = "abc"; + const char* reject = "d"; + size_t v = tstrncspn(p1, strlen(p1), reject, 1); + ASSERT_EQ(v, 3); + + const char* reject1 = "a"; + v = tstrncspn(p1, strlen(p1), reject1, 1); + ASSERT_EQ(v, 0); + + const char* reject2 = "de"; + v = tstrncspn(p1, strlen(p1), reject2, 2); + ASSERT_EQ(v, 3); + + const char* p2 = "abcdefghijklmn"; + v = tstrncspn(p2, strlen(p2), reject2, 2); + ASSERT_EQ(v, 3); + + const char* reject3 = "12345n"; + v = tstrncspn(p2, strlen(p2), reject3, 6); + ASSERT_EQ(v, 13); + + const char* reject4 = ""; + v = tstrncspn(p2, strlen(p2), reject4, 0); + ASSERT_EQ(v, 14); + + const char* reject5 = "911"; + v = tstrncspn(p2, strlen(p2), reject5, 0); + ASSERT_EQ(v, 14); +} \ No newline at end of file diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index ac207003b5d95a4811b2d2f26fb2db1926eaec85..d55e4f919b9542cd0d5c32e22fd6410349e21840 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 @@ -423,8 +425,8 @@ ,,n,system-test,python3 ./test.py -f 0-others/compatibility.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_database.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/influxdb_line_taosc_insert.py -,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_telnet_line_taosc_insert.py -,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_json_taosc_insert.py +,,n,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_telnet_line_taosc_insert.py +,,n,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_json_taosc_insert.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/test_stmt_muti_insert_query.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/test_stmt_set_tbname_tag.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_stable.py @@ -616,6 +618,8 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/varchar.py -R ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/case_when.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/case_when.py -R +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/blockSMA.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/blockSMA.py -R ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/update_data.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/tb_100w_data_order.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/delete_stable.py @@ -702,8 +706,8 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsumerGroup.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqShow.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqAlterSchema.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb.py -N 3 -n 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1.py -N 3 -n 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb-1ctb.py @@ -718,11 +722,11 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDnodeRestart.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDnodeRestart1.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdate-1ctb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdateWithConsume.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdateWithConsume.py -N 3 -n 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdate-multiCtb-snapshot0.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdate-multiCtb-snapshot1.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDelete-1ctb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDelete-multiCtb.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDelete-multiCtb.py -N 3 -n 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropStb.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropStbCtb.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropNtb-snapshot0.py @@ -736,6 +740,7 @@ #,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_taosx.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/stbTagFilter-multiCtb.py ,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-19201.py +,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqSubscribeStb-r3.py -N 5 ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 6 -M 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 6 -M 3 -n 3 @@ -834,6 +839,8 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tsbsQuery.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/sml.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/case_when.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/blockSMA.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/between.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/distinct.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/varchar.py -Q 3 @@ -929,6 +936,8 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/sml.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/interp.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/case_when.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/blockSMA.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/between.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/distinct.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/varchar.py -Q 4 @@ -1034,10 +1043,12 @@ ,,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 -#,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/auto_create_table_json.py +,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/auto_create_table_json.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/custom_col_tag.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/default_json.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/demo.py @@ -1046,7 +1057,7 @@ ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/json_tag.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/query_json.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/sample_csv_json.py -#,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/sml_json_alltypes.py +,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/sml_json_alltypes.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestQueryWithJson.py -R ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/telnet_tcp.py -R diff --git a/tests/pytest/auto_crash_gen.py b/tests/pytest/auto_crash_gen.py index 9c134e6d64a343dfa3a20afdf3ceec3d6e8d6855..56629ede131606a917582a885ecaa137938adce1 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 ce87fec684bdfaa4941a9ffcc01e984143aab559..22fc5a480f2facfe6eff0e00460292bdd5aa1996 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 f4afa80afe999a30d46619b7bba6905a43e820c4..547de9af479c51bac9f608eb01bc6e6b95b6fe48 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/pytest/util/sql.py b/tests/pytest/util/sql.py index 9cfd1d368edfa319aa4e80b307cbcc09020245ff..bdf3f20e1546e029dfbf7b41b280e857fb732020 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -261,6 +261,70 @@ class TDSql: tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") + # return true or false replace exit, no print out + def checkRowColNoExit(self, row, col): + caller = inspect.getframeinfo(inspect.stack()[2][0]) + if row < 0: + args = (caller.filename, caller.lineno, self.sql, row) + return False + if col < 0: + args = (caller.filename, caller.lineno, self.sql, row) + return False + if row > self.queryRows: + args = (caller.filename, caller.lineno, self.sql, row, self.queryRows) + return False + if col > self.queryCols: + args = (caller.filename, caller.lineno, self.sql, col, self.queryCols) + return False + + return True + + + # return true or false replace exit, no print out + def checkDataNoExit(self, row, col, data): + if self.checkRowColNoExit(row, col) == False: + return False + if self.queryResult[row][col] != data: + if self.cursor.istype(col, "TIMESTAMP"): + # suppose user want to check nanosecond timestamp if a longer data passed + if (len(data) >= 28): + if pd.to_datetime(self.queryResult[row][col]) == pd.to_datetime(data): + return True + else: + if self.queryResult[row][col] == _parse_datetime(data): + return True + return False + + if str(self.queryResult[row][col]) == str(data): + return True + elif isinstance(data, float): + if abs(data) >= 1 and abs((self.queryResult[row][col] - data) / data) <= 0.000001: + return True + elif abs(data) < 1 and abs(self.queryResult[row][col] - data) <= 0.000001: + return True + else: + return False + else: + return False + + return True + + + # loop execute sql then sleep(waitTime) , if checkData ok break loop + def checkDataLoop(self, row, col, data, sql, loopCount, waitTime): + # loop check util checkData return true + for i in range(loopCount): + self.query(sql) + if self.checkDataNoExit(row, col, data) : + self.checkData(row, col, data) + return + time.sleep(waitTime) + + # last check + self.query(sql) + self.checkData(row, col, data) + + def getData(self, row, col): self.checkRowCol(row, col) return self.queryResult[row][col] diff --git a/tests/script/tmp/data.sim b/tests/script/tmp/data.sim index e3bfe23c3d0d41f78e87ba0d9c78871d9a70d6ea..e2ddd60c8c0efbb8b24bf236beac518b763ab080 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 e3374ee277ae982d2df476b981ca7fc58f76199d..333964b1d66f72ec663fc0f807b4e84bb2ea7a69 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 0000000000000000000000000000000000000000..045e908a578af1a1a1248574a4dd70c2af5cf8b2 --- /dev/null +++ b/tests/script/tsim/query/sys_tbname.sim @@ -0,0 +1,89 @@ + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database sys_tbname; +sql use sys_tbname; +sql create stable st(ts timestamp, f int) tags(t int); +sql create table ct1 using st tags(1); +sql create table ct2 using st tags(2); + +sql create table t (ts timestamp, f int); +sql insert into t values(now, 1)(now+1s, 2); + + +sql create table t2 (ts timestamp, f1 int, f2 int); +sql insert into t2 values(now, 0, 0)(now+1s, 1, 1); + +sql select tbname from information_schema.ins_databases; +print $rows $data00 +if $rows != 3 then + return -1 +endi +if $data00 != @ins_databases@ then + return -1 +endi +sql select distinct tbname from information_schema.ins_databases; +print $rows $data00 +if $rows != 1 then + return -1 +endi +if $data00 != @ins_databases@ then + return -1 +endi + +sql select tbname from information_schema.ins_stables; +print $rows $data00 +if $rows != 1 then + return -1 +endi +if $data00 != @ins_stables@ then + return -1 +endi +sql select distinct tbname from information_schema.ins_stables; +print $rows $data00 +if $rows != 1 then + return -1 +endi +if $data00 != @ins_stables@ then + return -1 +endi + +sql select tbname from information_schema.ins_tables; +print $rows $data00 +if $rows != 32 then + return -1 +endi +if $data00 != @ins_tables@ then + return -1 +endi + +sql select distinct tbname from information_schema.ins_tables; +print $rows $data00 +if $rows != 1 then + return -1 +endi +if $data00 != @ins_tables@ then + return -1 +endi + +sql select tbname from information_schema.ins_tags; +print $rows $data00 +if $rows != 2 then + return -1 +endi +if $data00 != @ins_tags@ then + return -1 +endi +sql select distinct tbname from information_schema.ins_tags; +print $rows $data00 +if $rows != 1 then + return -1 +endi +if $data00 != @ins_tags@ then + return -1 +endi + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/system-test/0-others/backquote_check.py b/tests/system-test/0-others/backquote_check.py new file mode 100644 index 0000000000000000000000000000000000000000..33577232538074953457830934fa853ba81aec6a --- /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/1-insert/opentsdb_json_taosc_insert.py b/tests/system-test/1-insert/opentsdb_json_taosc_insert.py index 93f3c7410df5bfc0ffef836d8353249f8de0c965..5e493eab0af2bd0cf5ebe463cbde889fa957041b 100644 --- a/tests/system-test/1-insert/opentsdb_json_taosc_insert.py +++ b/tests/system-test/1-insert/opentsdb_json_taosc_insert.py @@ -1432,9 +1432,9 @@ class TDTestCase: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) query_sql = 'select * from `rFa$sta`' query_res = tdSql.query(query_sql, True) - tdSql.checkEqual(query_res, [(datetime.datetime(2021, 7, 11, 20, 33, 54), True, 'rFas$ta_1', 'ncharTagValue', 2147483647, 9223372036854775807, 22.123456789, 'binaryTagValue', 32767, 11.12345027923584, False, 127)]) + tdSql.checkEqual(query_res, [(datetime.datetime(2021, 7, 11, 20, 33, 54), True, False, 127, 32767, 2147483647, 9223372036854775807, 11.12345027923584, 22.123456789, 'binaryTagValue', 'ncharTagValue', 'rFas$ta_1')]) col_tag_res = tdSql.getColNameList(query_sql) - tdSql.checkEqual(col_tag_res, ['_ts', '_value', 'id', 't!@#$%^&*()_+[];:<>?,9', 't$3', 't%4', 't&6', 't*7', 't@2', 't^5', 'Tt!0', 'tT@1']) + tdSql.checkEqual(col_tag_res, ['_ts', '_value', 'Tt!0', 'tT@1', 't@2', 't$3', 't%4', 't^5', 't&6', 't*7', 't!@#$%^&*()_+[];:<>?,9', 'id']) tdSql.execute('drop table `rFa$sta`') def pointTransCheckCase(self, value_type="obj"): @@ -1719,7 +1719,6 @@ class TDTestCase: print(err.errno) def runAll(self): - """ for value_type in ["obj", "default"]: self.initCheckCase(value_type) self.symbolsCheckCase(value_type) @@ -1772,7 +1771,7 @@ class TDTestCase: # self.sStbStbDdataDtsMtInsertMultiThreadCheckCase() # self.sStbDtbDdataDtsMtInsertMultiThreadCheckCase() # self.lengthIcreaseCrashCheckCase() - """ + def run(self): print("running {}".format(__file__)) self.createDb() diff --git a/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py b/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py index a17a2d9514a50a06f594fca2990048b1876ef441..351cf49e3a217a44e93bbaf9c8c69ce2fa76c190 100644 --- a/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py +++ b/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py @@ -243,7 +243,7 @@ class TDTestCase: if t_add_tag is not None: sql_seq = f'{stb_name} {ts} {value} t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8} t9={t8}' if id_change_tag is not None: - sql_seq = f'{stb_name} {ts} {value} t0={t0} {id}={tb_name} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8}' + sql_seq = f'{stb_name} {ts} {value} {id}={tb_name} t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8}' if id_double_tag is not None: sql_seq = f'{stb_name} {ts} {value} {id}=\"{tb_name}_1\" t0={t0} t1={t1} {id}=\"{tb_name}_2\" t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8}' if t_add_tag is not None: @@ -1126,9 +1126,9 @@ class TDTestCase: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) query_sql = 'select * from `rFa$sta`' query_res = tdSql.query(query_sql, True) - tdSql.checkEqual(query_res, [(datetime.datetime(2021, 7, 11, 20, 33, 54), 9.223372036854776e+18, '2147483647i32', 'L"ncharTagValue"', '32767i16', '9223372036854775807i64', '22.123456789f64', '"ddzhiksj"', '11.12345f32', 'true', '127Ii8')]) + tdSql.checkEqual(query_res, [(datetime.datetime(2021, 7, 11, 20, 33, 54), 9.223372036854776e+18, 'true', '127Ii8', '32767i16', '2147483647i32', '9223372036854775807i64', '11.12345f32', '22.123456789f64', '"ddzhiksj"', 'L"ncharTagValue"')]) col_tag_res = tdSql.getColNameList(query_sql) - tdSql.checkEqual(col_tag_res, ['_ts', '_value', '"t$3"', 't!@#$%^&*()_+[];:<>?,9', 't#2', 't%4', 't&6', 't*7', 't^5', 'Tt!0', 'tT@1']) + tdSql.checkEqual(col_tag_res, ['_ts', '_value', 'Tt!0', 'tT@1', 't#2', '"t$3"', 't%4', 't^5', 't&6', 't*7', 't!@#$%^&*()_+[];:<>?,9']) tdSql.execute('drop table `rFa$sta`') def tcpKeywordsCheckCase(self, protocol="telnet-tcp"): @@ -1207,7 +1207,6 @@ class TDTestCase: tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') tdCom.cleanTb(dbname="test") input_sql = self.genSqlList()[0] - print(input_sql) self.multiThreadRun(self.genMultiThreadSeq(input_sql)) tdSql.query(f"show tables;") tdSql.checkRows(5) @@ -1416,8 +1415,8 @@ class TDTestCase: self.symbolsCheckCase() self.tsCheckCase() self.openTstbTelnetTsCheckCase() - #self.idSeqCheckCase() - #self.idLetterCheckCase() + # self.idSeqCheckCase() + self.idLetterCheckCase() self.noIdCheckCase() self.maxColTagCheckCase() self.stbTbNameCheckCase() @@ -1450,7 +1449,7 @@ class TDTestCase: self.spellCheckCase() self.pointTransCheckCase() self.defaultTypeCheckCase() - #self.tbnameTagsColsNameCheckCase() + self.tbnameTagsColsNameCheckCase() # # # MultiThreads # self.stbInsertMultiThreadCheckCase() # self.sStbStbDdataInsertMultiThreadCheckCase() diff --git a/tests/system-test/2-query/blockSMA.py b/tests/system-test/2-query/blockSMA.py new file mode 100644 index 0000000000000000000000000000000000000000..85c0189e277eee3cf20a05edc447a6803f3c2202 --- /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/sml.py b/tests/system-test/2-query/sml.py index 8ad1982b55506621606a92840e5496f29094da75..d5439d05de2ed6471e2dae8627574296340b7f94 100644 --- a/tests/system-test/2-query/sml.py +++ b/tests/system-test/2-query/sml.py @@ -71,23 +71,26 @@ class TDTestCase: tdSql.checkData(0, 2, "web01") tdSql.query(f"select distinct tbname from {dbname}.`sys.cpu.nice`") - tdSql.checkRows(2) + tdSql.checkRows(3) tdSql.query(f"select * from {dbname}.`sys.cpu.nice` order by _ts") - tdSql.checkRows(2) - tdSql.checkData(0, 1, 9.000000000) - tdSql.checkData(0, 2, "web02") + tdSql.checkRows(4) + tdSql.checkData(0, 1, 13.000000000) + tdSql.checkData(0, 2, "web01") tdSql.checkData(0, 3, None) tdSql.checkData(0, 4, "lga") - tdSql.checkData(1, 1, 18.000000000) - tdSql.checkData(1, 2, "web01") - tdSql.checkData(1, 3, "t1") + tdSql.checkData(1, 1, 9.000000000) + tdSql.checkData(1, 2, "web02") + tdSql.checkData(3, 3, "t1") tdSql.checkData(0, 4, "lga") tdSql.query(f"select * from {dbname}.macylr") tdSql.checkRows(2) + tdSql.query(f"select * from {dbname}.qelhxo") + tdSql.checkRows(5) + tdSql.query(f"desc {dbname}.macylr") tdSql.checkRows(25) return diff --git a/tests/system-test/6-cluster/5dnode1mnode.py b/tests/system-test/6-cluster/5dnode1mnode.py index d0157ec7c772182a2e24064dfec3cc29ed2a7ed6..ce87bced1b75d1994024586cf5084c5194befc22 100644 --- a/tests/system-test/6-cluster/5dnode1mnode.py +++ b/tests/system-test/6-cluster/5dnode1mnode.py @@ -137,11 +137,34 @@ class TDTestCase: config_dir = dnode.cfgDir return taos.connect(host=host, port=int(port), config=config_dir) + def check_alive(self): + # check cluster alive + tdLog.printNoPrefix("======== test cluster alive: ") + tdSql.checkDataLoop(0, 0, 1, "show cluster alive;", 20, 0.5) + + tdSql.query("show db.alive;") + tdSql.checkData(0, 0, 1) + + # stop 5 dnode + self.TDDnodes.stoptaosd(5) + tdSql.checkDataLoop(0, 0, 2, "show cluster alive;", 20, 0.5) + + tdSql.query("show db.alive;") + tdSql.checkData(0, 0, 2) + + # stop 2 dnode + self.TDDnodes.stoptaosd(2) + tdSql.checkDataLoop(0, 0, 0, "show cluster alive;", 20, 0.5) + + tdSql.query("show db.alive;") + tdSql.checkData(0, 0, 0) + def run(self): # print(self.master_dnode.cfgDict) self.five_dnode_one_mnode() - + # check cluster and db alive + self.check_alive() def stop(self): tdSql.close() diff --git a/tests/system-test/7-tmq/subscribeDb1.py b/tests/system-test/7-tmq/subscribeDb1.py index ea78c90abddebac86391af732750d8f670b80492..c5ae44214a0cea58f2c4f3cfee03dd0c3e5918a2 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 9bfc01529fda135789e55cbe0d01b39e2a6c2639..87832ac0ef2169ad2895928ceb20121ae17ecba9 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 975f89cbd7977df5640d2000a885eaf975a401e6..9bb8c4cc0d953d4c03fa772427523b477896a90d 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 c0c459d315efa541115cf666b85203f69794b306..b910caf420de5efd6fef315e220920599f946435 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 3b72b4aea5d1df34e0230a98953d671536442cab..e59e3d6ecda6e13127eba3f087029ad281cc55b3 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 49a475ff16db96534c13107e94f5d42c8f10454c..4f595788daee975f26cd2e30c1a0fe973e35aa68 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 0000000000000000000000000000000000000000..5b852c77662c7e944762336827476e7fac75ea19 --- /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/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index b391d59725938295fcffba13dfac81821a40a0cb..45ff694e722112c54e4803b19d6816c7c1348af1 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -138,6 +138,7 @@ SWords shellCommands[] = { {"show create table \\G;", 0, 0, NULL}, {"show connections;", 0, 0, NULL}, {"show cluster;", 0, 0, NULL}, + {"show cluster alive;", 0, 0, NULL}, {"show databases;", 0, 0, NULL}, {"show dnodes;", 0, 0, NULL}, {"show dnode variables;", 0, 0, NULL}, @@ -425,6 +426,7 @@ void showHelp() { show create table ;\n\ show connections;\n\ show cluster;\n\ + show cluster alive;\n\ show databases;\n\ show dnodes;\n\ show dnode variables;\n\ diff --git a/utils/test/c/sml_test.c b/utils/test/c/sml_test.c index 49885c0aea8098b9ea8160b0cd89c93d1f5b20aa..30d0ab27d86b6fe902c0fbb40051768203b3da98 100644 --- a/utils/test/c/sml_test.c +++ b/utils/test/c/sml_test.c @@ -78,21 +78,23 @@ int smlProcess_telnet_Test() { pRes = taos_query(taos, "use sml_db"); taos_free_result(pRes); - char *sql[4] = {0}; - sql[0] = taosMemoryCalloc(1, 128); - sql[1] = taosMemoryCalloc(1, 128); - sql[2] = taosMemoryCalloc(1, 128); - sql[3] = taosMemoryCalloc(1, 128); +// char *sql[4] = {0}; +// sql[0] = taosMemoryCalloc(1, 128); +// sql[1] = taosMemoryCalloc(1, 128); +// sql[2] = taosMemoryCalloc(1, 128); +// sql[3] = taosMemoryCalloc(1, 128); const char *sql1[] = {"sys.if.bytes.out 1479496100 1.3E0 host=web01 interface=eth0", "sys.if.bytes.out 1479496101 1.3E1 interface=eth0 host=web01 ", "sys.if.bytes.out 1479496102 1.3E3 network=tcp", " sys.procs.running 1479496100 42 host=web01 "}; - for(int i = 0; i < 4; i++){ - strncpy(sql[i], sql1[i], 128); - } +// for(int i = 0; i < 4; i++){ +// strncpy(sql[i], sql1[i], 128); +// } - pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_TELNET_PROTOCOL, +// pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_TELNET_PROTOCOL, +// TSDB_SML_TIMESTAMP_NANO_SECONDS); + pRes = taos_schemaless_insert(taos, (char **)sql1, sizeof(sql1) / sizeof(sql1[0]), TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); int code = taos_errno(pRes); @@ -112,13 +114,53 @@ int smlProcess_json1_Test() { taos_free_result(pRes); const char *sql[] = { - "[{\"metric\":\"sys.cpu.nice\",\"timestamp\":0,\"value\":18,\"tags\":{\"host\":\"web01\",\"id\":\"t1\",\"dc\":\"lga\"}},{\"metric\":\"sys.cpu.nice\",\"timestamp\":1662344042,\"value\":9,\"tags\":{\"host\":\"web02\",\"dc\":\"lga\"}}]" + "[{\"metric\":\"sys.cpu.nice\",\"timestamp\":0,\"value\":18,\"tags\":{\"host\":\"web01\",\"id\":\"t1\",\"dc\":\"lga\"}},{\"metric\":\"sys.cpu.nice\",\"timestamp\":1662344045,\"value\":9,\"tags\":{\"host\":\"web02\",\"dc\":\"lga\"}}]" }; - pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, + + char *sql1[1] = {0}; + for(int i = 0; i < 1; i++){ + sql1[i] = taosMemoryCalloc(1, 1024); + strncpy(sql1[i], sql[i], 1023); + } + + pRes = taos_schemaless_insert(taos, (char **)sql1, sizeof(sql1) / sizeof(sql1[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); int code = taos_errno(pRes); + if(code != 0){ + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + }else{ + printf("%s result:success\n", __FUNCTION__); + } taos_free_result(pRes); + + for(int i = 0; i < 1; i++){ + taosMemoryFree(sql1[i]); + } + + const char *sql2[] = { + "[{\"metric\":\"sys.cpu.nice\",\"timestamp\":1662344041,\"value\":13,\"tags\":{\"host\":\"web01\",\"dc\":\"lga\"}},{\"metric\":\"sys.cpu.nice\",\"timestamp\":1662344042,\"value\":9,\"tags\":{\"host\":\"web02\",\"dc\":\"lga\"}}]", + }; + + char *sql3[1] = {0}; + for(int i = 0; i < 1; i++){ + sql3[i] = taosMemoryCalloc(1, 1024); + strncpy(sql3[i], sql2[i], 1023); + } + + pRes = taos_schemaless_insert(taos, (char **)sql3, sizeof(sql3) / sizeof(sql3[0]), TSDB_SML_JSON_PROTOCOL, + TSDB_SML_TIMESTAMP_NANO_SECONDS); + code = taos_errno(pRes); + if(code != 0){ + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + }else{ + printf("%s result:success\n", __FUNCTION__); + } + taos_free_result(pRes); + + for(int i = 0; i < 1; i++){ + taosMemoryFree(sql3[i]); + } + taos_close(taos); return code; @@ -136,13 +178,26 @@ int smlProcess_json2_Test() { const char *sql[] = { "{\"metric\":\"meter_current0\",\"timestamp\":{\"value\":1662344042,\"type\":\"s\"},\"value\":{\"value\":10.3,\"type\":\"i64\"},\"tags\":{\"groupid\":{\"value\":2,\"type\":\"bigint\"},\"location\":{\"value\":\"北京\",\"type\":\"binary\"},\"id\":\"d1001\"}}" }; - pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, + char *sql1[1] = {0}; + for(int i = 0; i < 1; i++){ + sql1[i] = taosMemoryCalloc(1, 1024); + strncpy(sql1[i], sql[i], 1023); + } + + pRes = taos_schemaless_insert(taos, (char **)sql1, sizeof(sql1) / sizeof(sql1[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); int code = taos_errno(pRes); + if(code != 0){ + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + }else{ + printf("%s result:success\n", __FUNCTION__); + } taos_free_result(pRes); taos_close(taos); + for(int i = 0; i < 1; i++){ + taosMemoryFree(sql1[i]); + } return code; } @@ -156,15 +211,29 @@ int smlProcess_json3_Test() { taos_free_result(pRes); const char *sql[] = { - "[{\"metric\":\"sys.cpu.nice\",\"timestamp\":0,\"value\":\"18\",\"tags\":{\"host\":\"web01\",\"id\":\"t1\",\"dc\":\"lga\"}}]" +// "[{\"metric\":\"sys.cpu.nice3\",\"timestamp\":0,\"value\":\"18\",\"tags\":{\"host\":\"web01\",\"id\":\"t1\",\"dc\":\"lga\"}}]" + "{\"metric\": \"dcxnmr\", \"timestamp\": {\"value\": 1626006833639000000, \"type\": \"ns\"}, \"value\": {\"value\": false, \"type\": \"bool\"}, \"tags\": {\"t0\": {\"value\": false, \"type\": \"bool\"}, \"t1\": {\"value\": 127, \"type\": \"tinyint\"}, \"t2\": {\"value\": 32767, \"type\": \"smallint\"}, \"t3\": {\"value\": 2147483647, \"type\": \"int\"}, \"t4\": {\"value\": 9223372036854775807, \"type\": \"bigint\"}, \"t5\": {\"value\": 11.12345027923584, \"type\": \"float\"}, \"t6\": {\"value\": 22.123456789, \"type\": \"double\"}, \"t7\": {\"value\": \"binaryTagValue\", \"type\": \"binary\"}, \"t8\": {\"value\": \"abc{aaa\", \"type\": \"nchar\"}}}" }; - pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, + char *sql1[1] = {0}; + for(int i = 0; i < 1; i++){ + sql1[i] = taosMemoryCalloc(1, 1024); + strncpy(sql1[i], sql[i], 1023); + } + + pRes = taos_schemaless_insert(taos, (char **)sql1, sizeof(sql1) / sizeof(sql1[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); int code = taos_errno(pRes); + if(code != 0){ + printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); + }else{ + printf("%s result:success\n", __FUNCTION__); + } taos_free_result(pRes); taos_close(taos); + for(int i = 0; i < 1; i++){ + taosMemoryFree(sql1[i]); + } return code; } @@ -233,7 +302,7 @@ int sml_16384_Test() { if(code) return code; const char *sql1[] = { - "qelhxo,id=pnnqhsa,t0=t,t1=127i8 c0=f,c1=127i8,c11=L\"ncharColValue\",c10=t 1626006833639000000", + "qelhxo,id=pnnqhsa,t0=t,t1=127i8 c0=f,c1=127i8,c11=L\"ncharColValue\",c10=t 1626006833631000000", }; pRes = taos_schemaless_insert(taos, (char **)sql1, 1, TSDB_SML_LINE_PROTOCOL, 0); printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); @@ -797,7 +866,7 @@ int sml_19221_Test() { taos_free_result(pRes); const char *sql[] = { - "qelhxo,id=pnnqhsa,t0=t,t1=127i8 c11=L\"ncharColValue\",c0=t,c1=127i8 1626006833639000000\nqelhxo,id=pnnhsa,t0=t,t1=127i8 c11=L\"ncharColValue\",c0=t,c1=127i8 1626006833639000000\n#comment\nqelhxo,id=pnqhsa,t0=t,t1=127i8 c11=L\"ncharColValue\",c0=t,c1=127i8 1626006833639000000", + "qelhxo,id=pnnqhsa,t0=t,t1=127i8 c11=L\"ncharColValue\",c0=t,c1=127i8 1626006833632000000\nqelhxo,id=pnnhsa,t0=t,t1=127i8 c11=L\"ncharColValue\",c0=t,c1=127i8 1626006833633000000\n#comment\nqelhxo,id=pnqhsa,t0=t,t1=127i8 c11=L\"ncharColValue\",c0=t,c1=127i8 1626006833634000000", }; pRes = taos_query(taos, "use sml_db"); @@ -936,9 +1005,9 @@ int main(int argc, char *argv[]) { ret = smlProcess_json1_Test(); ASSERT(!ret); ret = smlProcess_json2_Test(); - ASSERT(ret); + ASSERT(!ret); ret = smlProcess_json3_Test(); - ASSERT(ret); + ASSERT(!ret); ret = sml_TD15662_Test(); ASSERT(!ret); ret = sml_TD15742_Test(); diff --git a/utils/tsim/inc/simInt.h b/utils/tsim/inc/simInt.h index f512b119b4299c9146a3a9a915a2359ca52fc4c4..8ff3f3b18344eaa3f9533d704b401c0eab757739 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 f2fefb903d926d38d16544253a1c6cae0fc1b5c9..98f9217fd6e55bff306d06aa25151ad713e743ca 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; }