diff --git a/cmake/cmake.define b/cmake/cmake.define index 53d25e1097..e875a0d306 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -3,12 +3,6 @@ cmake_minimum_required(VERSION 3.16) if (NOT DEFINED TD_GRANT) SET(TD_GRANT FALSE) endif() -if (NOT DEFINED TD_USB_DONGLE) - SET(TD_USB_DONGLE FALSE) -endif() -IF (TD_GRANT) - ADD_DEFINITIONS(-D_GRANT) -ENDIF () IF ("${BUILD_TOOLS}" STREQUAL "") IF (TD_LINUX) diff --git a/examples/lua/build.sh b/examples/lua/build.sh index 9d00c68425..1e6fef632c 100755 --- a/examples/lua/build.sh +++ b/examples/lua/build.sh @@ -4,5 +4,5 @@ if [ "$lua_header_installed" = "0" ]; then sudo apt install -y liblua5.3-dev fi -gcc -std=c99 lua_connector.c -fPIC -shared -o luaconnector.so -Wall -ltaos -I/usr/include/lua5.3 +gcc -std=c99 lua_connector.c -fPIC -shared -o luaconnector.so -Wall -ltaos -I/usr/include/lua5.3 -I../../include/client diff --git a/examples/lua/lua_connector.c b/examples/lua/lua_connector.c index 76634ed254..3c13b196b9 100644 --- a/examples/lua/lua_connector.c +++ b/examples/lua/lua_connector.c @@ -1,11 +1,11 @@ -#include -#include -#include +#include #include #include -#include #include -#include "../../../include/client/taos.h" +#include +#include +#include +#include "taos.h" struct cb_param{ lua_State* state; @@ -28,14 +28,14 @@ static int l_connect(lua_State *L){ luaL_checktype(L, 1, LUA_TTABLE); - lua_getfield(L,1,"host"); + lua_getfield(L, 1,"host"); if (lua_isstring(L,-1)){ host = lua_tostring(L, -1); // printf("host = %s\n", host); } lua_getfield(L, 1, "port"); - if (lua_isinteger(L,-1)){ + if (lua_isinteger(L, -1)){ port = lua_tointeger(L, -1); //printf("port = %d\n", port); } @@ -60,8 +60,6 @@ static int l_connect(lua_State *L){ lua_settop(L,0); - taos_init(); - lua_newtable(L); int table_index = lua_gettop(L); @@ -102,7 +100,7 @@ static int l_query(lua_State *L){ printf("failed, reason:%s\n", taos_errstr(result)); lua_pushinteger(L, -1); lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); + lua_pushstring(L, taos_errstr(result)); lua_setfield(L, table_index, "error"); return 1; @@ -113,7 +111,6 @@ static int l_query(lua_State *L){ int rows = 0; int num_fields = taos_field_count(result); const TAOS_FIELD *fields = taos_fetch_fields(result); - //char temp[256]; const int affectRows = taos_affected_rows(result); // printf(" affect rows:%d\r\n", affectRows); @@ -122,7 +119,7 @@ static int l_query(lua_State *L){ lua_pushinteger(L, affectRows); lua_setfield(L, table_index, "affected"); lua_newtable(L); - + while ((row = taos_fetch_row(result))) { //printf("row index:%d\n",rows); rows++; @@ -136,17 +133,21 @@ static int l_query(lua_State *L){ } lua_pushstring(L,fields[i].name); - + int32_t* length = taos_fetch_lengths(result); switch (fields[i].type) { + case TSDB_DATA_TYPE_UTINYINT: case TSDB_DATA_TYPE_TINYINT: lua_pushinteger(L,*((char *)row[i])); break; + case TSDB_DATA_TYPE_USMALLINT: case TSDB_DATA_TYPE_SMALLINT: lua_pushinteger(L,*((short *)row[i])); break; + case TSDB_DATA_TYPE_UINT: case TSDB_DATA_TYPE_INT: lua_pushinteger(L,*((int *)row[i])); break; + case TSDB_DATA_TYPE_UBIGINT: case TSDB_DATA_TYPE_BIGINT: lua_pushinteger(L,*((int64_t *)row[i])); break; @@ -156,9 +157,11 @@ static int l_query(lua_State *L){ case TSDB_DATA_TYPE_DOUBLE: lua_pushnumber(L,*((double *)row[i])); break; + case TSDB_DATA_TYPE_JSON: case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: - lua_pushstring(L,(char *)row[i]); + //printf("type:%d, max len:%d, current len:%d\n",fields[i].type, fields[i].bytes, length[i]); + lua_pushlstring(L,(char *)row[i], length[i]); break; case TSDB_DATA_TYPE_TIMESTAMP: lua_pushinteger(L,*((int64_t *)row[i])); @@ -166,6 +169,7 @@ static int l_query(lua_State *L){ case TSDB_DATA_TYPE_BOOL: lua_pushinteger(L,*((char *)row[i])); break; + case TSDB_DATA_TYPE_NULL: default: lua_pushnil(L); break; @@ -235,112 +239,6 @@ static int l_async_query(lua_State *L){ return 1; } -void stream_cb(void *param, TAOS_RES *result, TAOS_ROW row){ - struct cb_param* p = (struct cb_param*) param; - TAOS_FIELD *fields = taos_fetch_fields(result); - int numFields = taos_num_fields(result); - - // printf("\nnumfields:%d\n", numFields); - //printf("\n\r-----------------------------------------------------------------------------------\n"); - - lua_State *L = p->state; - lua_rawgeti(L, LUA_REGISTRYINDEX, p->callback); - - lua_newtable(L); - - for (int i = 0; i < numFields; ++i) { - if (row[i] == NULL) { - continue; - } - - lua_pushstring(L,fields[i].name); - - switch (fields[i].type) { - case TSDB_DATA_TYPE_TINYINT: - lua_pushinteger(L,*((char *)row[i])); - break; - case TSDB_DATA_TYPE_SMALLINT: - lua_pushinteger(L,*((short *)row[i])); - break; - case TSDB_DATA_TYPE_INT: - lua_pushinteger(L,*((int *)row[i])); - break; - case TSDB_DATA_TYPE_BIGINT: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_FLOAT: - lua_pushnumber(L,*((float *)row[i])); - break; - case TSDB_DATA_TYPE_DOUBLE: - lua_pushnumber(L,*((double *)row[i])); - break; - case TSDB_DATA_TYPE_BINARY: - case TSDB_DATA_TYPE_NCHAR: - lua_pushstring(L,(char *)row[i]); - break; - case TSDB_DATA_TYPE_TIMESTAMP: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_BOOL: - lua_pushinteger(L,*((char *)row[i])); - break; - default: - lua_pushnil(L); - break; - } - - lua_settable(L, -3); - } - - lua_call(L, 1, 0); - - // printf("-----------------------------------------------------------------------------------\n\r"); -} - -static int l_open_stream(lua_State *L){ - int r = luaL_ref(L, LUA_REGISTRYINDEX); - TAOS * taos = (TAOS*)lua_topointer(L,1); - const char * sqlstr = lua_tostring(L,2); - int stime = luaL_checknumber(L,3); - - lua_newtable(L); - int table_index = lua_gettop(L); - - struct cb_param *p = malloc(sizeof(struct cb_param)); - p->state = L; - p->callback=r; - // printf("r:%d, L:%d\n",r,L); - void * s = taos_open_stream(taos,sqlstr,stream_cb,stime,p,NULL); - if (s == NULL) { - printf("failed to open stream, reason:%s\n", taos_errstr(taos)); - free(p); - lua_pushnumber(L, -1); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - lua_pushlightuserdata(L,NULL); - lua_setfield(L, table_index, "stream"); - }else{ - // printf("success to open stream\n"); - lua_pushnumber(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - p->stream = s; - lua_pushlightuserdata(L,p); - lua_setfield(L, table_index, "stream");//stream has different content in lua and c. - } - - return 1; -} - -static int l_close_stream(lua_State *L){ - //TODO:get stream and free cb_param - struct cb_param *p = lua_touserdata(L,1); - taos_close_stream(p->stream); - free(p); - return 0; -} static int l_close(lua_State *L){ TAOS *taos= (TAOS*)lua_topointer(L,1); @@ -367,8 +265,6 @@ static const struct luaL_Reg lib[] = { {"query", l_query}, {"query_a",l_async_query}, {"close", l_close}, - {"open_stream", l_open_stream}, - {"close_stream", l_close_stream}, {NULL, NULL} }; diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 8686d91a10..4e89beabcb 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -70,13 +70,11 @@ typedef uint16_t tmsg_t; #define TSDB_IE_TYPE_DNODE_EXT 6 #define TSDB_IE_TYPE_DNODE_STATE 7 -typedef enum { - HEARTBEAT_TYPE_MQ = 0, - HEARTBEAT_TYPE_QUERY, - // types can be added here - // - HEARTBEAT_TYPE_MAX -} EHbType; +enum { + CONN_TYPE__QUERY = 1, + CONN_TYPE__TMQ, + CONN_TYPE__MAX +}; enum { HEARTBEAT_KEY_DBINFO = 1, @@ -346,7 +344,7 @@ int32_t tDeserializeSConnectReq(void* buf, int32_t bufLen, SConnectReq* pReq); typedef struct { int32_t acctId; int64_t clusterId; - int32_t connId; + uint32_t connId; int8_t superUser; int8_t connType; SEpSet epSet; @@ -1048,40 +1046,6 @@ typedef struct { int32_t tSerializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq); int32_t tDeserializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq); -typedef struct { - char sql[TSDB_SHOW_SQL_LEN]; - int32_t queryId; - int64_t useconds; - int64_t stime; - int64_t qId; - int64_t sqlObjId; - int32_t pid; - char fqdn[TSDB_FQDN_LEN]; - int8_t stableQuery; - int32_t numOfSub; - char subSqlInfo[TSDB_SHOW_SUBQUERY_LEN]; // include subqueries' index, Obj IDs and states(C-complete/I-imcomplete) -} SQueryDesc; - -typedef struct { - int32_t connId; - int32_t pid; - int32_t numOfQueries; - int32_t numOfStreams; - char app[TSDB_APP_NAME_LEN]; - char pData[]; -} SHeartBeatReq; - -typedef struct { - int32_t connId; - int32_t queryId; - int32_t streamId; - int32_t totalDnodes; - int32_t onlineDnodes; - int8_t killConnection; - int8_t align[3]; - SEpSet epSet; -} SHeartBeatRsp; - typedef struct { int32_t connId; int32_t queryId; @@ -1684,13 +1648,48 @@ typedef struct { } SKv; typedef struct { - int32_t connId; - int32_t hbType; + int64_t tscRid; + int8_t connType; } SClientHbKey; typedef struct { - SClientHbKey connKey; - SHashObj* info; // hash + int64_t tid; + int32_t status; +} SQuerySubDesc; + +typedef struct { + char sql[TSDB_SHOW_SQL_LEN]; + uint64_t queryId; + int64_t useconds; + int64_t stime; + int64_t reqRid; + int32_t pid; + char fqdn[TSDB_FQDN_LEN]; + int32_t subPlanNum; + SArray* subDesc; // SArray +} SQueryDesc; + +typedef struct { + uint32_t connId; + int32_t pid; + char app[TSDB_APP_NAME_LEN]; + SArray* queryDesc; // SArray +} SQueryHbReqBasic; + +typedef struct { + uint32_t connId; + uint64_t killRid; + int32_t totalDnodes; + int32_t onlineDnodes; + int8_t killConnection; + int8_t align[3]; + SEpSet epSet; +} SQueryHbRspBasic; + +typedef struct { + SClientHbKey connKey; + SQueryHbReqBasic* query; + SHashObj* info; // hash } SClientHbReq; typedef struct { @@ -1699,9 +1698,10 @@ typedef struct { } SClientHbBatchReq; typedef struct { - SClientHbKey connKey; - int32_t status; - SArray* info; // Array + SClientHbKey connKey; + int32_t status; + SQueryHbRspBasic* query; + SArray* info; // Array } SClientHbRsp; typedef struct { @@ -1721,8 +1721,23 @@ static FORCE_INLINE void tFreeReqKvHash(SHashObj* info) { } } +static FORCE_INLINE void tFreeClientHbQueryDesc(void* pDesc) { + SQueryDesc* desc = (SQueryDesc*)pDesc; + if (desc->subDesc) { + taosArrayDestroy(desc->subDesc); + desc->subDesc = NULL; + } +} + static FORCE_INLINE void tFreeClientHbReq(void* pReq) { SClientHbReq* req = (SClientHbReq*)pReq; + if (req->query) { + if (req->query->queryDesc) { + taosArrayDestroyEx(req->query->queryDesc, tFreeClientHbQueryDesc); + } + taosMemoryFreeClear(req->query); + } + if (req->info) { tFreeReqKvHash(req->info); taosHashCleanup(req->info); @@ -1751,6 +1766,7 @@ static FORCE_INLINE void tFreeClientKv(void* pKv) { static FORCE_INLINE void tFreeClientHbRsp(void* pRsp) { SClientHbRsp* rsp = (SClientHbRsp*)pRsp; + taosMemoryFreeClear(rsp->query); if (rsp->info) taosArrayDestroyEx(rsp->info, tFreeClientKv); } @@ -1779,14 +1795,14 @@ static FORCE_INLINE int32_t tDecodeSKv(SCoder* pDecoder, SKv* pKv) { } static FORCE_INLINE int32_t tEncodeSClientHbKey(SCoder* pEncoder, const SClientHbKey* pKey) { - if (tEncodeI32(pEncoder, pKey->connId) < 0) return -1; - if (tEncodeI32(pEncoder, pKey->hbType) < 0) return -1; + if (tEncodeI64(pEncoder, pKey->tscRid) < 0) return -1; + if (tEncodeI8(pEncoder, pKey->connType) < 0) return -1; return 0; } static FORCE_INLINE int32_t tDecodeSClientHbKey(SCoder* pDecoder, SClientHbKey* pKey) { - if (tDecodeI32(pDecoder, &pKey->connId) < 0) return -1; - if (tDecodeI32(pDecoder, &pKey->hbType) < 0) return -1; + if (tDecodeI64(pDecoder, &pKey->tscRid) < 0) return -1; + if (tDecodeI8(pDecoder, &pKey->connType) < 0) return -1; return 0; } diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 3ea93cc60b..c98e5bf99d 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -171,20 +171,20 @@ #define TK_BUFSIZE 153 #define TK_STREAM 154 #define TK_INTO 155 -#define TK_KILL 156 -#define TK_CONNECTION 157 -#define TK_MERGE 158 -#define TK_VGROUP 159 -#define TK_REDISTRIBUTE 160 -#define TK_SPLIT 161 -#define TK_SYNCDB 162 -#define TK_NULL 163 -#define TK_FIRST 164 -#define TK_LAST 165 -#define TK_NOW 166 -#define TK_TODAY 167 -#define TK_TIMEZONE 168 -#define TK_CAST 169 +#define TK_TRIGGER 156 +#define TK_AT_ONCE 157 +#define TK_WINDOW_CLOSE 158 +#define TK_WATERMARK 159 +#define TK_KILL 160 +#define TK_CONNECTION 161 +#define TK_MERGE 162 +#define TK_VGROUP 163 +#define TK_REDISTRIBUTE 164 +#define TK_SPLIT 165 +#define TK_SYNCDB 166 +#define TK_NULL 167 +#define TK_NK_QUESTION 168 +#define TK_NK_ARROW 169 #define TK_ROWTS 170 #define TK_TBNAME 171 #define TK_QSTARTTS 172 @@ -192,40 +192,49 @@ #define TK_WSTARTTS 174 #define TK_WENDTS 175 #define TK_WDURATION 176 -#define TK_BETWEEN 177 -#define TK_IS 178 -#define TK_NK_LT 179 -#define TK_NK_GT 180 -#define TK_NK_LE 181 -#define TK_NK_GE 182 -#define TK_NK_NE 183 -#define TK_MATCH 184 -#define TK_NMATCH 185 -#define TK_JOIN 186 -#define TK_INNER 187 -#define TK_SELECT 188 -#define TK_DISTINCT 189 -#define TK_WHERE 190 -#define TK_PARTITION 191 -#define TK_BY 192 -#define TK_SESSION 193 -#define TK_STATE_WINDOW 194 -#define TK_SLIDING 195 -#define TK_FILL 196 -#define TK_VALUE 197 -#define TK_NONE 198 -#define TK_PREV 199 -#define TK_LINEAR 200 -#define TK_NEXT 201 -#define TK_GROUP 202 -#define TK_HAVING 203 -#define TK_ORDER 204 -#define TK_SLIMIT 205 -#define TK_SOFFSET 206 -#define TK_LIMIT 207 -#define TK_OFFSET 208 -#define TK_ASC 209 -#define TK_NULLS 210 +#define TK_CAST 177 +#define TK_NOW 178 +#define TK_TODAY 179 +#define TK_TIMEZONE 180 +#define TK_COUNT 181 +#define TK_FIRST 182 +#define TK_LAST 183 +#define TK_LAST_ROW 184 +#define TK_BETWEEN 185 +#define TK_IS 186 +#define TK_NK_LT 187 +#define TK_NK_GT 188 +#define TK_NK_LE 189 +#define TK_NK_GE 190 +#define TK_NK_NE 191 +#define TK_MATCH 192 +#define TK_NMATCH 193 +#define TK_CONTAINS 194 +#define TK_JOIN 195 +#define TK_INNER 196 +#define TK_SELECT 197 +#define TK_DISTINCT 198 +#define TK_WHERE 199 +#define TK_PARTITION 200 +#define TK_BY 201 +#define TK_SESSION 202 +#define TK_STATE_WINDOW 203 +#define TK_SLIDING 204 +#define TK_FILL 205 +#define TK_VALUE 206 +#define TK_NONE 207 +#define TK_PREV 208 +#define TK_LINEAR 209 +#define TK_NEXT 210 +#define TK_GROUP 211 +#define TK_HAVING 212 +#define TK_ORDER 213 +#define TK_SLIMIT 214 +#define TK_SOFFSET 215 +#define TK_LIMIT 216 +#define TK_OFFSET 217 +#define TK_ASC 218 +#define TK_NULLS 219 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 @@ -234,7 +243,6 @@ #define TK_NK_OCT 304 // oct number #define TK_NK_BIN 305 // bin format data 0b111 #define TK_NK_FILE 306 -#define TK_NK_QUESTION 307 // denoting the placeholder of "?",when invoking statement bind query #define TK_NK_BITNOT 501 #define TK_INSERT 502 diff --git a/include/libs/function/function.h b/include/libs/function/function.h index 9fa89f0415..1303a1fb6a 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -110,7 +110,6 @@ typedef struct SFileBlockInfo { #define FUNCTION_COV 38 typedef struct SResultRowEntryInfo { -// int8_t hasResult:6; // result generated, not NULL value bool initialized:1; // output buffer has been initialized bool complete:1; // query has completed uint8_t isNullRes:6; // the result is null @@ -119,10 +118,10 @@ typedef struct SResultRowEntryInfo { // determine the real data need to calculated the result enum { - BLK_DATA_NO_NEEDED = 0x0, - BLK_DATA_STATIS_NEEDED = 0x1, - BLK_DATA_ALL_NEEDED = 0x3, - BLK_DATA_DISCARD = 0x4, // discard current data block since it is not qualified for filter + BLK_DATA_NOT_LOAD = 0x0, + BLK_DATA_SMA_LOAD = 0x1, + BLK_DATA_DATA_LOAD = 0x3, + BLK_DATA_FILTEROUT = 0x4, // discard current data block since it is not qualified for filter }; enum { diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index a471de3147..22bbc36ee1 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -137,12 +137,13 @@ bool fmIsWindowPseudoColumnFunc(int32_t funcId); bool fmIsWindowClauseFunc(int32_t funcId); bool fmIsSpecialDataRequiredFunc(int32_t funcId); bool fmIsDynamicScanOptimizedFunc(int32_t funcId); +bool fmIsMultiResFunc(int32_t funcId); typedef enum EFuncDataRequired { - FUNC_DATA_REQUIRED_ALL_NEEDED = 1, - FUNC_DATA_REQUIRED_STATIS_NEEDED, - FUNC_DATA_REQUIRED_NO_NEEDED, - FUNC_DATA_REQUIRED_DISCARD + FUNC_DATA_REQUIRED_DATA_LOAD = 1, + FUNC_DATA_REQUIRED_STATIS_LOAD, + FUNC_DATA_REQUIRED_NOT_LOAD, + FUNC_DATA_REQUIRED_FILTEROUT, } EFuncDataRequired; EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow); diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index e1a63bd66b..6810b63f4e 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -272,6 +272,33 @@ typedef struct SKillStmt { int32_t targetId; } SKillStmt; +typedef enum EStreamTriggerType { + STREAM_TRIGGER_AT_ONCE = 1, + STREAM_TRIGGER_WINDOW_CLOSE +} EStreamTriggerType; + +typedef struct SStreamOptions { + ENodeType type; + EStreamTriggerType triggerType; + SNode* pWatermark; +} SStreamOptions; + +typedef struct SCreateStreamStmt { + ENodeType type; + char streamName[TSDB_TABLE_NAME_LEN]; + char targetDbName[TSDB_DB_NAME_LEN]; + char targetTabName[TSDB_TABLE_NAME_LEN]; + bool ignoreExists; + SStreamOptions* pOptions; + SNode* pQuery; +} SCreateStreamStmt; + +typedef struct SDropStreamStmt { + ENodeType type; + char streamName[TSDB_TABLE_NAME_LEN]; + bool ignoreNotExists; +} SDropStreamStmt; + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 02636a178e..8db93ee5f9 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -80,6 +80,7 @@ typedef enum ENodeType { QUERY_NODE_TABLE_OPTIONS, QUERY_NODE_INDEX_OPTIONS, QUERY_NODE_EXPLAIN_OPTIONS, + QUERY_NODE_STREAM_OPTIONS, // Statement nodes are used in parser and planner module. QUERY_NODE_SET_OPERATOR, @@ -151,6 +152,12 @@ typedef enum ENodeType { QUERY_NODE_SHOW_CONNECTIONS_STMT, QUERY_NODE_SHOW_QUERIES_STMT, QUERY_NODE_SHOW_VNODES_STMT, + QUERY_NODE_SHOW_APPS_STMT, + QUERY_NODE_SHOW_SCORES_STMT, + QUERY_NODE_SHOW_VARIABLE_STMT, + QUERY_NODE_SHOW_CREATE_DATABASE_STMT, + QUERY_NODE_SHOW_CREATE_TABLE_STMT, + QUERY_NODE_SHOW_CREATE_STABLE_STMT, QUERY_NODE_KILL_CONNECTION_STMT, QUERY_NODE_KILL_QUERY_STMT, diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index fef624288a..02cd073226 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -57,6 +57,7 @@ typedef struct SQuery { SNode* pRoot; int32_t numOfResCols; SSchema* pResSchema; + int8_t precision; SCmdMsgInfo* pCmdMsg; int32_t msgType; SArray* pDbList; diff --git a/include/libs/scheduler/scheduler.h b/include/libs/scheduler/scheduler.h index 5ab4ead89c..460749243c 100644 --- a/include/libs/scheduler/scheduler.h +++ b/include/libs/scheduler/scheduler.h @@ -89,6 +89,8 @@ int32_t schedulerAsyncExecJob(void *transport, SArray *pNodeList, SQueryPlan* pD */ int32_t schedulerFetchRows(int64_t job, void **data); +int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub); + /** * Cancel query job diff --git a/include/os/osMemory.h b/include/os/osMemory.h index e516000c66..4efe69e204 100644 --- a/include/os/osMemory.h +++ b/include/os/osMemory.h @@ -33,13 +33,13 @@ void *taosMemoryMalloc(int32_t size); void *taosMemoryCalloc(int32_t num, int32_t size); void *taosMemoryRealloc(void *ptr, int32_t size); void *taosMemoryStrDup(void *ptr); -void taosMemoryFree(const void *ptr); +void taosMemoryFree(void *ptr); int32_t taosMemorySize(void *ptr); #define taosMemoryFreeClear(ptr) \ do { \ if (ptr) { \ - taosMemoryFree(ptr); \ + taosMemoryFree((void*)ptr); \ (ptr) = NULL; \ } \ } while (0) diff --git a/include/util/tarray.h b/include/util/tarray.h index 521e54040d..383af8309d 100644 --- a/include/util/tarray.h +++ b/include/util/tarray.h @@ -205,6 +205,14 @@ SArray* taosArrayDup(const SArray* pSrc); */ void taosArrayClear(SArray* pArray); +/** + * clear the array (remove all element) + * @param pArray + * @param fp + */ +void taosArrayClearEx(SArray* pArray, void (*fp)(void*)); + + /** * destroy array list * @param pArray diff --git a/include/util/tdef.h b/include/util/tdef.h index 6baf784fe3..5fc30540ee 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -128,6 +128,13 @@ extern const int32_t TYPE_BYTES[15]; #define TSDB_INS_TABLE_QUERIES "queries" #define TSDB_INS_TABLE_VNODES "vnodes" +#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema" +#define TSDB_PERFS_TABLE_CONNECTIONS "connections" +#define TSDB_PERFS_TABLE_QUERIES "queries" +#define TSDB_PERFS_TABLE_TOPICS "topics" +#define TSDB_PERFS_TABLE_CONSUMERS "consumers" +#define TSDB_PERFS_TABLE_SUBSCRIBES "subscribes" + #define TSDB_INDEX_TYPE_SMA "SMA" #define TSDB_INDEX_TYPE_FULLTEXT "FULLTEXT" diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 0f12880272..772ff5e69a 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -43,13 +43,17 @@ extern "C" { } \ } while (0) +#define ERROR_MSG_BUF_DEFAULT_SIZE 512 #define HEARTBEAT_INTERVAL 1500 // ms enum { - CONN_TYPE__QUERY = 1, - CONN_TYPE__TMQ, + RES_TYPE__QUERY = 1, + RES_TYPE__TMQ, }; +#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY) +#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ) + typedef struct SAppInstInfo SAppInstInfo; typedef struct { @@ -84,8 +88,8 @@ typedef struct { TdThread thread; TdThreadMutex lock; // used when app init and cleanup SArray* appHbMgrs; // SArray one for each cluster - FHbReqHandle reqHandle[HEARTBEAT_TYPE_MAX]; - FHbRspHandle rspHandle[HEARTBEAT_TYPE_MAX]; + FHbReqHandle reqHandle[CONN_TYPE__MAX]; + FHbRspHandle rspHandle[CONN_TYPE__MAX]; } SClientHbMgr; typedef struct SQueryExecMetric { @@ -144,6 +148,7 @@ typedef struct STscObj { TdThreadMutex mutex; // used to protect the operation on db int32_t numOfReqs; // number of sqlObj bound to this connection SAppInstInfo* pAppInfo; + SHashObj* pRequests; } STscObj; typedef struct SResultColumn { @@ -172,33 +177,15 @@ typedef struct SReqResultInfo { int32_t payloadLen; } SReqResultInfo; -typedef struct SShowReqInfo { - int64_t execId; // showId/queryId - int32_t vgId; - SArray* pArray; // SArray - int32_t currentIndex; // current accessed vgroup index. -} SShowReqInfo; - typedef struct SRequestSendRecvBody { tsem_t rspSem; // not used now void* fp; - SShowReqInfo showInfo; // todo this attribute will be removed after the query framework being completed. SDataBuf requestMsg; int64_t queryJob; // query job, created according to sql query DAG. struct SQueryPlan* pDag; // the query dag, generated according to the sql statement. SReqResultInfo resInfo; } SRequestSendRecvBody; -#define ERROR_MSG_BUF_DEFAULT_SIZE 512 - -enum { - RES_TYPE__QUERY = 1, - RES_TYPE__TMQ, -}; - -#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY) -#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ) - typedef struct { int8_t resType; char* topic; @@ -212,12 +199,11 @@ typedef struct SRequestObj { uint64_t requestId; int32_t type; // request type STscObj* pTscObj; - char* pDb; + char* pDb; // current database string char* sqlstr; // sql string int32_t sqlLen; int64_t self; - char* msgBuf; - void* pInfo; // sql parse info, generated by parser module + char* msgBuf; // error msg buffer int32_t code; SArray* dbList; SArray* tableList; @@ -252,21 +238,24 @@ extern int (*handleRequestRspFp[TDMT_MAX])(void*, const SDataBuf* pMsg, int32_t int genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code); SMsgSendInfo* buildMsgInfoImpl(SRequestObj* pReqObj); -int taos_init(); +int taos_init(); void* createTscObj(const char* user, const char* auth, const char* db, SAppInstInfo* pAppInfo); void destroyTscObj(void* pObj); +STscObj *acquireTscObj(int64_t rid); +int32_t releaseTscObj(int64_t rid); uint64_t generateRequestId(); void* createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t type); void destroyRequest(SRequestObj* pRequest); +SRequestObj *acquireRequest(int64_t rid); +int32_t releaseRequest(int64_t rid); char* getDbOfConnection(STscObj* pObj); void setConnectionDB(STscObj* pTscObj, const char* db); void resetConnectDB(STscObj* pTscObj); -void taos_init_imp(void); int taos_options_imp(TSDB_OPTION option, const char* str); void* openTransporter(const char* user, const char* auth, int32_t numOfThreads); @@ -286,9 +275,8 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj* void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4); void doSetOneRowPtr(SReqResultInfo* pResultInfo); -int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows, - bool convertUcs4); void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols); +void setResPrecision(SReqResultInfo* pResInfo, int32_t precision); int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4); // --- heartbeat @@ -302,7 +290,7 @@ SAppHbMgr* appHbMgrInit(SAppInstInfo* pAppInstInfo, char* key); void appHbMgrCleanup(void); // conn level -int hbRegisterConn(SAppHbMgr* pAppHbMgr, int32_t connId, int64_t clusterId, int32_t hbType); +int hbRegisterConn(SAppHbMgr *pAppHbMgr, int64_t tscRefId, int64_t clusterId, int8_t connType); void hbDeregisterConn(SAppHbMgr* pAppHbMgr, SClientHbKey connKey); int hbAddConnInfo(SAppHbMgr* pAppHbMgr, SClientHbKey connKey, void* key, void* value, int32_t keyLen, int32_t valueLen); diff --git a/source/client/inc/clientStmt.h b/source/client/inc/clientStmt.h new file mode 100644 index 0000000000..c29361758d --- /dev/null +++ b/source/client/inc/clientStmt.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_CLIENTSTMT_H +#define TDENGINE_CLIENTSTMT_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + STMT_TYPE_INSERT = 1, + STMT_TYPE_MULTI_INSERT, + STMT_TYPE_QUERY, +} STMT_TYPE; + +typedef struct STscStmt { + STMT_TYPE type; + //int16_t last; + //STscObj* taos; + //SSqlObj* pSql; + //SMultiTbStmt mtb; + //SNormalStmt normal; + + //int numOfRows; +} STscStmt; + +#define STMT_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) +#define STMT_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) +#define STMT_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) + +TAOS_STMT *stmtInit(TAOS *taos); +int stmtClose(TAOS_STMT *stmt); +int stmtExec(TAOS_STMT *stmt); +char *stmtErrstr(TAOS_STMT *stmt); +int stmtAffectedRows(TAOS_STMT *stmt); +int stmtBind(TAOS_STMT *stmt, TAOS_BIND *bind); +int stmtPrepare(TAOS_STMT *stmt, const char *sql, unsigned long length); +int stmtSetTbNameTags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags); +int stmtIsInsert(TAOS_STMT *stmt, int *insert); +int stmtGetParamNum(TAOS_STMT *stmt, int *nums); +int stmtAddBatch(TAOS_STMT *stmt); +TAOS_RES *stmtUseResult(TAOS_STMT *stmt); +int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind); + + +#ifdef __cplusplus +} +#endif + +#endif // TDENGINE_CLIENTSTMT_H diff --git a/source/client/src/client.c b/source/client/src/client.c deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index fec6c8e5db..865c3ead27 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -27,17 +27,18 @@ #include "ttime.h" #define TSC_VAR_NOT_RELEASE 1 -#define TSC_VAR_RELEASED 0 +#define TSC_VAR_RELEASED 0 SAppInfo appInfo; -int32_t clientReqRefPool = -1; +int32_t clientReqRefPool = -1; int32_t clientConnRefPool = -1; -static TdThreadOnce tscinit = PTHREAD_ONCE_INIT; +static TdThreadOnce tscinit = PTHREAD_ONCE_INIT; volatile int32_t tscInitRes = 0; static void registerRequest(SRequestObj *pRequest) { - STscObj *pTscObj = (STscObj *)taosAcquireRef(clientConnRefPool, pRequest->pTscObj->id); + STscObj *pTscObj = acquireTscObj(pRequest->pTscObj->id); + assert(pTscObj != NULL); // connection has been released already, abort creating request. @@ -48,8 +49,8 @@ static void registerRequest(SRequestObj *pRequest) { if (pTscObj->pAppInfo) { SInstanceSummary *pSummary = &pTscObj->pAppInfo->summary; - int32_t total = atomic_add_fetch_64(&pSummary->totalRequests, 1); - int32_t currentInst = atomic_add_fetch_64(&pSummary->currentRequests, 1); + int32_t total = atomic_add_fetch_64((int64_t*)&pSummary->totalRequests, 1); + int32_t currentInst = atomic_add_fetch_64((int64_t*)&pSummary->currentRequests, 1); tscDebug("0x%" PRIx64 " new Request from connObj:0x%" PRIx64 ", current:%d, app current:%d, total:%d, reqId:0x%" PRIx64, pRequest->self, pRequest->pTscObj->id, num, currentInst, total, pRequest->requestId); @@ -62,14 +63,14 @@ static void deregisterRequest(SRequestObj *pRequest) { STscObj * pTscObj = pRequest->pTscObj; SInstanceSummary *pActivity = &pTscObj->pAppInfo->summary; - int32_t currentInst = atomic_sub_fetch_64(&pActivity->currentRequests, 1); + int32_t currentInst = atomic_sub_fetch_64((int64_t*)&pActivity->currentRequests, 1); int32_t num = atomic_sub_fetch_32(&pTscObj->numOfReqs, 1); int64_t duration = taosGetTimestampUs() - pRequest->metric.start; tscDebug("0x%" PRIx64 " free Request from connObj: 0x%" PRIx64 ", reqId:0x%" PRIx64 " elapsed:%" PRIu64 " ms, current:%d, app current:%d", pRequest->self, pTscObj->id, pRequest->requestId, duration/1000, num, currentInst); - taosReleaseRef(clientConnRefPool, pTscObj->id); + releaseTscObj(pTscObj->id); } // todo close the transporter properly @@ -107,12 +108,24 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) { return pDnodeConn; } +void closeAllRequests(SHashObj *pRequests) { + void *pIter = taosHashIterate(pRequests, NULL); + while (pIter != NULL) { + int64_t *rid = pIter; + + releaseRequest(*rid); + + pIter = taosHashIterate(pRequests, pIter); + } +} + void destroyTscObj(void *pObj) { STscObj *pTscObj = pObj; - SClientHbKey connKey = {.connId = pTscObj->connId, .hbType = pTscObj->connType}; + SClientHbKey connKey = {.tscRid = pTscObj->id, .connType = pTscObj->connType}; hbDeregisterConn(pTscObj->pAppInfo->pAppHbMgr, connKey); atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1); + closeAllRequests(pTscObj->pRequests); tscDebug("connObj 0x%" PRIx64 " destroyed, totalConn:%" PRId64, pTscObj->id, pTscObj->pAppInfo->numOfConns); taosThreadMutexDestroy(&pTscObj->mutex); taosMemoryFreeClear(pTscObj); @@ -125,6 +138,13 @@ void *createTscObj(const char *user, const char *auth, const char *db, SAppInstI return NULL; } + pObj->pRequests = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK); + if (NULL == pObj->pRequests) { + taosMemoryFree(pObj); + terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + return NULL; + } + pObj->pAppInfo = pAppInfo; tstrncpy(pObj->user, user, sizeof(pObj->user)); memcpy(pObj->pass, auth, TSDB_PASSWORD_LEN); @@ -140,6 +160,14 @@ void *createTscObj(const char *user, const char *auth, const char *db, SAppInstI return pObj; } +STscObj *acquireTscObj(int64_t rid) { + return (STscObj *)taosAcquireRef(clientConnRefPool, rid); +} + +int32_t releaseTscObj(int64_t rid) { + return taosReleaseRef(clientConnRefPool, rid); +} + void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t type) { assert(pObj != NULL); @@ -161,6 +189,7 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty tsem_init(&pRequest->body.rspSem, 0, 0); registerRequest(pRequest); + return pRequest; } @@ -186,9 +215,10 @@ static void doDestroyRequest(void *p) { assert(RID_VALID(pRequest->self)); + taosHashRemove(pRequest->pTscObj->pRequests, &pRequest->self, sizeof(pRequest->self)); + taosMemoryFreeClear(pRequest->msgBuf); taosMemoryFreeClear(pRequest->sqlstr); - taosMemoryFreeClear(pRequest->pInfo); taosMemoryFreeClear(pRequest->pDb); doFreeReqResultInfo(&pRequest->body.resInfo); @@ -198,10 +228,6 @@ static void doDestroyRequest(void *p) { schedulerFreeJob(pRequest->body.queryJob); } - if (pRequest->body.showInfo.pArray != NULL) { - taosArrayDestroy(pRequest->body.showInfo.pArray); - } - taosArrayDestroy(pRequest->tableList); taosArrayDestroy(pRequest->dbList); @@ -214,9 +240,18 @@ void destroyRequest(SRequestObj *pRequest) { return; } - taosReleaseRef(clientReqRefPool, pRequest->self); + taosRemoveRef(clientReqRefPool, pRequest->self); } +SRequestObj *acquireRequest(int64_t rid) { + return (SRequestObj *)taosAcquireRef(clientReqRefPool, rid); +} + +int32_t releaseRequest(int64_t rid) { + return taosReleaseRef(clientReqRefPool, rid); +} + + void taos_init_imp(void) { // In the APIs of other program language, taos_cleanup is not available yet. // So, to make sure taos_cleanup will be invoked to clean up the allocated resource to suppress the valgrind warning. @@ -457,11 +492,18 @@ uint64_t generateRequestId() { } } - int64_t ts = taosGetTimestampMs(); - uint64_t pid = taosGetPId(); - int32_t val = atomic_add_fetch_32(&requestSerialId, 1); + uint64_t id = 0; + + while (true) { + int64_t ts = taosGetTimestampMs(); + uint64_t pid = taosGetPId(); + int32_t val = atomic_add_fetch_32(&requestSerialId, 1); - uint64_t id = ((hashId & 0x0FFF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); + id = ((hashId & 0x0FFF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); + if (id) { + break; + } + } return id; } diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index 82788b2e11..a6678b2ec0 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -14,6 +14,7 @@ */ #include "catalog.h" +#include "scheduler.h" #include "clientInt.h" #include "clientLog.h" #include "trpc.h" @@ -109,10 +110,36 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) { SHbConnInfo *info = taosHashGet(pAppHbMgr->connInfo, &pRsp->connKey, sizeof(SClientHbKey)); if (NULL == info) { - tscWarn("fail to get connInfo, may be dropped, connId:%d, type:%d", pRsp->connKey.connId, pRsp->connKey.hbType); + tscWarn("fail to get connInfo, may be dropped, refId:%" PRIx64 ", type:%d", pRsp->connKey.tscRid, pRsp->connKey.connType); return TSDB_CODE_SUCCESS; } + if (pRsp->query) { + STscObj *pTscObj = (STscObj *)acquireTscObj(pRsp->connKey.tscRid); + if (NULL == pTscObj) { + tscDebug("tscObj rid %" PRIx64 " not exist", pRsp->connKey.tscRid); + } else { + updateEpSet_s(&pTscObj->pAppInfo->mgmtEp, &pRsp->query->epSet); + pTscObj->connId = pRsp->query->connId; + + if (pRsp->query->killRid) { + SRequestObj *pRequest = acquireRequest(pRsp->query->killRid); + if (NULL == pRequest) { + tscDebug("request 0x%" PRIx64 " not exist to kill", pRsp->query->killRid); + } else { + taos_stop_query((TAOS_RES *)pRequest); + releaseRequest(pRsp->query->killRid); + } + } + + if (pRsp->query->killConnection) { + taos_close(pTscObj); + } + + releaseTscObj(pRsp->connKey.tscRid); + } + } + int32_t kvNum = pRsp->info ? taosArrayGetSize(pRsp->info) : 0; tscDebug("hb got %d rsp kv", kvNum); @@ -197,7 +224,7 @@ static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code) for (int32_t i = 0; i < rspNum; ++i) { SClientHbRsp *rsp = taosArrayGet(pRsp.rsps, i); - code = (*clientHbMgr.rspHandle[rsp->connKey.hbType])((*pInst)->pAppHbMgr, rsp); + code = (*clientHbMgr.rspHandle[rsp->connKey.connType])((*pInst)->pAppHbMgr, rsp); if (code) { break; } @@ -208,6 +235,97 @@ static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code) return code; } +int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) { + int64_t now = taosGetTimestampUs(); + SQueryDesc desc = {0}; + int32_t code = 0; + + void *pIter = taosHashIterate(pObj->pRequests, NULL); + while (pIter != NULL) { + int64_t *rid = pIter; + SRequestObj *pRequest = acquireRequest(*rid); + if (NULL == pRequest) { + continue; + } + + tstrncpy(desc.sql, pRequest->sqlstr, sizeof(desc.sql)); + desc.stime = pRequest->metric.start; + desc.queryId = pRequest->requestId; + desc.useconds = now - pRequest->metric.start; + desc.reqRid = pRequest->self; + desc.pid = hbBasic->pid; + taosGetFqdn(desc.fqdn); + desc.subPlanNum = pRequest->body.pDag ? pRequest->body.pDag->numOfSubplans : 0; + + if (desc.subPlanNum) { + desc.subDesc = taosArrayInit(desc.subPlanNum, sizeof(SQuerySubDesc)); + if (NULL == desc.subDesc) { + releaseRequest(*rid); + return TSDB_CODE_QRY_OUT_OF_MEMORY; + } + + code = schedulerGetTasksStatus(pRequest->body.queryJob, desc.subDesc); + if (code) { + taosArrayDestroy(desc.subDesc); + desc.subDesc = NULL; + } + } + + releaseRequest(*rid); + taosArrayPush(hbBasic->queryDesc, &desc); + + pIter = taosHashIterate(pObj->pRequests, pIter); + } + + return TSDB_CODE_SUCCESS; +} + +int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) { + STscObj *pTscObj = (STscObj *)acquireTscObj(connKey->tscRid); + if (NULL == pTscObj) { + tscWarn("tscObj rid %" PRIx64 " not exist", connKey->tscRid); + return TSDB_CODE_QRY_APP_ERROR; + } + + int32_t numOfQueries = pTscObj->pRequests ? taosHashGetSize(pTscObj->pRequests) : 0; + if (numOfQueries <= 0) { + releaseTscObj(connKey->tscRid); + tscDebug("no queries on connection"); + return TSDB_CODE_QRY_APP_ERROR; + } + + SQueryHbReqBasic *hbBasic = (SQueryHbReqBasic *)taosMemoryCalloc(1, sizeof(SQueryHbReqBasic)); + if (NULL == hbBasic) { + tscError("calloc %d failed", (int32_t)sizeof(SQueryHbReqBasic)); + releaseTscObj(connKey->tscRid); + return TSDB_CODE_QRY_OUT_OF_MEMORY; + } + + hbBasic->queryDesc = taosArrayInit(numOfQueries, sizeof(SQueryDesc)); + if (NULL == hbBasic->queryDesc) { + tscWarn("taosArrayInit %d queryDesc failed", numOfQueries); + releaseTscObj(connKey->tscRid); + taosMemoryFree(hbBasic); + return TSDB_CODE_QRY_OUT_OF_MEMORY; + } + + hbBasic->connId = pTscObj->connId; + hbBasic->pid = taosGetPId(); + taosGetAppName(hbBasic->app, NULL); + + int32_t code = hbBuildQueryDesc(hbBasic, pTscObj); + if (code) { + releaseTscObj(connKey->tscRid); + taosMemoryFree(hbBasic); + return code; + } + + req->query = hbBasic; + releaseTscObj(connKey->tscRid); + + return TSDB_CODE_SUCCESS; +} + int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SClientHbReq *req) { SDbVgVersion *dbs = NULL; uint32_t dbNum = 0; @@ -286,6 +404,8 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req return code; } + hbGetQueryBasicInfo(connKey, req); + code = hbGetExpiredDBInfo(connKey, pCatalog, req); if (TSDB_CODE_SUCCESS != code) { return code; @@ -300,11 +420,11 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req } void hbMgrInitMqHbHandle() { - clientHbMgr.reqHandle[HEARTBEAT_TYPE_QUERY] = hbQueryHbReqHandle; - clientHbMgr.reqHandle[HEARTBEAT_TYPE_MQ] = hbMqHbReqHandle; + clientHbMgr.reqHandle[CONN_TYPE__QUERY] = hbQueryHbReqHandle; + clientHbMgr.reqHandle[CONN_TYPE__TMQ] = hbMqHbReqHandle; - clientHbMgr.rspHandle[HEARTBEAT_TYPE_QUERY] = hbQueryHbRspHandle; - clientHbMgr.rspHandle[HEARTBEAT_TYPE_MQ] = hbMqHbRspHandle; + clientHbMgr.rspHandle[CONN_TYPE__QUERY] = hbQueryHbRspHandle; + clientHbMgr.rspHandle[CONN_TYPE__TMQ] = hbMqHbRspHandle; } static FORCE_INLINE void hbMgrInitHandle() { @@ -317,6 +437,11 @@ void hbFreeReq(void *req) { tFreeReqKvHash(pReq->info); } +void hbClearClientHbReq(SClientHbReq *pReq) { + pReq->query = NULL; + pReq->info = NULL; +} + SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) { SClientHbBatchReq *pBatchReq = taosMemoryCalloc(1, sizeof(SClientHbBatchReq)); if (pBatchReq == NULL) { @@ -333,22 +458,23 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) { SHbConnInfo *info = taosHashGet(pAppHbMgr->connInfo, &pOneReq->connKey, sizeof(SClientHbKey)); if (info) { - code = (*clientHbMgr.reqHandle[pOneReq->connKey.hbType])(&pOneReq->connKey, info->param, pOneReq); + code = (*clientHbMgr.reqHandle[pOneReq->connKey.connType])(&pOneReq->connKey, info->param, pOneReq); if (code) { - taosHashCancelIterate(pAppHbMgr->activeInfo, pIter); - break; + pIter = taosHashIterate(pAppHbMgr->activeInfo, pIter); + continue; } } taosArrayPush(pBatchReq->reqs, pOneReq); + hbClearClientHbReq(pOneReq); pIter = taosHashIterate(pAppHbMgr->activeInfo, pIter); } - if (code) { - taosArrayDestroyEx(pBatchReq->reqs, hbFreeReq); - taosMemoryFreeClear(pBatchReq); - } +// if (code) { +// taosArrayDestroyEx(pBatchReq->reqs, hbFreeReq); +// taosMemoryFreeClear(pBatchReq); +// } return pBatchReq; } @@ -523,13 +649,13 @@ int hbMgrInit() { hbMgrInitHandle(); // init backgroud thread - hbCreateThread(); + //hbCreateThread(); return 0; } void hbMgrCleanUp() { - hbStopThread(); + //hbStopThread(); // destroy all appHbMgr int8_t old = atomic_val_compare_exchange_8(&clientHbMgr.inited, 1, 0); @@ -549,7 +675,7 @@ int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, SHbConnInfo * if (data != NULL) { return 0; } - SClientHbReq hbReq; + SClientHbReq hbReq = {0}; hbReq.connKey = connKey; hbReq.info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK); @@ -566,22 +692,22 @@ int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, SHbConnInfo * return 0; } -int hbRegisterConn(SAppHbMgr *pAppHbMgr, int32_t connId, int64_t clusterId, int32_t hbType) { +int hbRegisterConn(SAppHbMgr *pAppHbMgr, int64_t tscRefId, int64_t clusterId, int8_t connType) { SClientHbKey connKey = { - .connId = connId, - .hbType = hbType, + .tscRid = tscRefId, + .connType = connType, }; SHbConnInfo info = {0}; - switch (hbType) { - case HEARTBEAT_TYPE_QUERY: { + switch (connType) { + case CONN_TYPE__QUERY: { int64_t *pClusterId = taosMemoryMalloc(sizeof(int64_t)); *pClusterId = clusterId; info.param = pClusterId; return hbRegisterConnImpl(pAppHbMgr, connKey, &info); } - case HEARTBEAT_TYPE_MQ: { + case CONN_TYPE__TMQ: { return 0; } default: diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 96a7230ff3..74b8e711dc 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1,3 +1,17 @@ +/* + * 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 "clientInt.h" #include "clientLog.h" @@ -132,6 +146,13 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj* (*pRequest)->sqlstr[sqlLen] = 0; (*pRequest)->sqlLen = sqlLen; + if (taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self, sizeof((*pRequest)->self))) { + destroyRequest(*pRequest); + *pRequest = NULL; + tscError("put request to request hash failed"); + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + tscDebugL("0x%" PRIx64 " SQL: %s, reqId:0x%" PRIx64, (*pRequest)->self, (*pRequest)->sqlstr, (*pRequest)->requestId); return TSDB_CODE_SUCCESS; } @@ -161,6 +182,7 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery) { if (TSDB_CODE_SUCCESS == code) { if ((*pQuery)->haveResultSet) { setResSchemaInfo(&pRequest->body.resInfo, (*pQuery)->pResSchema, (*pQuery)->numOfResCols); + setResPrecision(&pRequest->body.resInfo, (*pQuery)->precision); } TSWAP(pRequest->dbList, (*pQuery)->pDbList, SArray*); @@ -215,7 +237,7 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra } void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols) { - assert(pSchema != NULL && numOfCols > 0); + ASSERT(pSchema != NULL && numOfCols > 0); pResInfo->numOfCols = numOfCols; pResInfo->fields = taosMemoryCalloc(numOfCols, sizeof(TAOS_FIELD)); @@ -239,6 +261,14 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t } } +void setResPrecision(SReqResultInfo* pResInfo, int32_t precision) { + if (precision != TSDB_TIME_PRECISION_MILLI && precision != TSDB_TIME_PRECISION_MICRO && precision != TSDB_TIME_PRECISION_NANO) { + return; + } + + pResInfo->precision = precision; +} + int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) { void* pTransporter = pRequest->pTscObj->pAppInfo->pTransporter; @@ -447,7 +477,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t taos_close(pTscObj); pTscObj = NULL; } else { - tscDebug("0x%" PRIx64 " connection is opening, connId:%d, dnodeConn:%p, reqId:0x%" PRIx64, pTscObj->id, + tscDebug("0x%" PRIx64 " connection is opening, connId:%u, dnodeConn:%p, reqId:0x%" PRIx64, pTscObj->id, pTscObj->connId, pTscObj->pAppInfo->pTransporter, pRequest->requestId); destroyRequest(pRequest); } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 42d204284e..73ac059276 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -14,7 +14,9 @@ */ #include "catalog.h" +#include "scheduler.h" #include "clientInt.h" +#include "clientStmt.h" #include "clientLog.h" #include "os.h" #include "query.h" @@ -66,6 +68,7 @@ void taos_cleanup(void) { rpcCleanup(); catalogDestroy(); + schedulerDestroy(); taosCloseLog(); tscInfo("all local resources released"); @@ -98,7 +101,7 @@ void taos_close(TAOS *taos) { STscObj *pTscObj = (STscObj *)taos; tscDebug("0x%" PRIx64 " try to close connection, numOfReq:%d", pTscObj->id, pTscObj->numOfReqs); - /*taosRemoveRef(clientConnRefPool, pTscObj->id);*/ + taosRemoveRef(clientConnRefPool, pTscObj->id); } int taos_errno(TAOS_RES *tres) { @@ -193,7 +196,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) { } } else { - // assert to avoid uninitialization error + // assert to avoid un-initialization error ASSERT(0); } return NULL; @@ -355,6 +358,7 @@ int taos_result_precision(TAOS_RES *res) { if (res == NULL) { return TSDB_TIME_PRECISION_MILLI; } + if (TD_RES_QUERY(res)) { SRequestObj *pRequest = (SRequestObj *)res; return pRequest->body.resInfo.precision; @@ -400,7 +404,7 @@ void taos_stop_query(TAOS_RES *res) { return; } - // scheduleCancelJob(pRequest->body.pQueryJob); + schedulerFreeJob(pRequest->body.queryJob); } bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col) { @@ -467,6 +471,7 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) { if (res == NULL) { return 0; } + if (TD_RES_TMQ(res)) { SReqResultInfo *pResultInfo = tmqGetNextResInfo(res); if (pResultInfo == NULL) { @@ -565,76 +570,149 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { } TAOS_STMT *taos_stmt_init(TAOS *taos) { - // TODO - return NULL; + if (taos == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return NULL; + } + + return stmtInit(taos); } int taos_stmt_close(TAOS_STMT *stmt) { - // TODO - return -1; + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtClose(stmt); } int taos_stmt_execute(TAOS_STMT *stmt) { - // TODO - return -1; + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtExec(stmt); } char *taos_stmt_errstr(TAOS_STMT *stmt) { - // TODO - return NULL; + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return NULL; + } + + return stmtErrstr(stmt); } int taos_stmt_affected_rows(TAOS_STMT *stmt) { - // TODO - return -1; + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return 0; + } + + return stmtAffectedRows(stmt); } +int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind) { + if (stmt == NULL || bind == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtBind(stmt, bind); +} + +int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) { + if (stmt == NULL || sql == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtPrepare(stmt, sql, length); +} + +int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags) { + if (stmt == NULL || name == NULL || tags == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtSetTbNameTags(stmt, name, tags); +} + +int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) { + if (stmt == NULL || name == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtSetTbNameTags(stmt, name, NULL); +} + +int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert) { + if (stmt == NULL || insert == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtIsInsert(stmt, insert); +} + +int taos_stmt_num_params(TAOS_STMT *stmt, int *nums) { + if (stmt == NULL || nums == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtGetParamNum(stmt, nums); +} + +int taos_stmt_add_batch(TAOS_STMT *stmt) { + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtAddBatch(stmt); +} + +TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt) { + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return NULL; + } + + return stmtUseResult(stmt); +} + +int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) { + if (stmt == NULL || bind == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtBindBatch(stmt, bind); +} + + TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision) { // TODO return NULL; } -int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind) { - // TODO - return -1; -} -int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) { - // TODO - return -1; -} - -int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags) { - // TODO - return -1; -} - -int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) { - // TODO - return -1; -} - -int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert) { - // TODO - return -1; -} - -int taos_stmt_num_params(TAOS_STMT *stmt, int *nums) { - // TODO - return -1; -} - -int taos_stmt_add_batch(TAOS_STMT *stmt) { - // TODO - return -1; -} - -TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt) { - // TODO - return NULL; -} - -int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) { - // TODO - return -1; -} diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 67c5679cac..74347cabf7 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -71,7 +71,7 @@ int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) { pTscObj->connType = connectRsp.connType; - hbRegisterConn(pTscObj->pAppInfo->pAppHbMgr, connectRsp.connId, connectRsp.clusterId, connectRsp.connType); + hbRegisterConn(pTscObj->pAppInfo->pAppHbMgr, pTscObj->id, connectRsp.clusterId, connectRsp.connType); // pRequest->body.resInfo.pRspMsg = pMsg->pData; tscDebug("0x%" PRIx64 " clusterId:%" PRId64 ", totalConn:%" PRId64, pRequest->requestId, connectRsp.clusterId, @@ -117,10 +117,10 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { struct SCatalog *pCatalog = NULL; if (usedbRsp.vgVersion >= 0) { - int32_t code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); - if (code != TSDB_CODE_SUCCESS) { + int32_t code1 = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); + if (code1 != TSDB_CODE_SUCCESS) { tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->pTscObj->pAppInfo->clusterId, - tstrerror(code)); + tstrerror(code1)); } else { catalogRemoveDB(pCatalog, usedbRsp.db, usedbRsp.uid); } @@ -154,10 +154,10 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { } else { struct SCatalog* pCatalog = NULL; - int32_t code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); - if (code != TSDB_CODE_SUCCESS) { + int32_t code1 = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); + if (code1 != TSDB_CODE_SUCCESS) { tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->pTscObj->pAppInfo->clusterId, - tstrerror(code)); + tstrerror(code1)); } else { catalogUpdateDBVgInfo(pCatalog, output.db, output.dbId, output.dbVgroup); } @@ -209,84 +209,9 @@ int32_t processDropDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { } void initMsgHandleFp() { -#if 0 - tscBuildMsg[TSDB_SQL_SELECT] = tscBuildQueryMsg; - tscBuildMsg[TSDB_SQL_INSERT] = tscBuildSubmitMsg; - tscBuildMsg[TSDB_SQL_FETCH] = tscBuildFetchMsg; - - tscBuildMsg[TSDB_SQL_CREATE_DB] = tscBuildCreateDbMsg; - tscBuildMsg[TSDB_SQL_CREATE_USER] = tscBuildUserMsg; - tscBuildMsg[TSDB_SQL_CREATE_FUNCTION] = tscBuildCreateFuncMsg; - - tscBuildMsg[TSDB_SQL_CREATE_ACCT] = tscBuildAcctMsg; - tscBuildMsg[TSDB_SQL_ALTER_ACCT] = tscBuildAcctMsg; - - tscBuildMsg[TSDB_SQL_CREATE_TABLE] = tscBuildCreateTableMsg; - tscBuildMsg[TSDB_SQL_DROP_USER] = tscBuildDropUserAcctMsg; - tscBuildMsg[TSDB_SQL_DROP_ACCT] = tscBuildDropUserAcctMsg; - tscBuildMsg[TSDB_SQL_DROP_DB] = tscBuildDropDbMsg; - tscBuildMsg[TSDB_SQL_DROP_FUNCTION] = tscBuildDropFuncMsg; - tscBuildMsg[TSDB_SQL_SYNC_DB_REPLICA] = tscBuildSyncDbReplicaMsg; - tscBuildMsg[TSDB_SQL_DROP_TABLE] = tscBuildDropTableMsg; - tscBuildMsg[TSDB_SQL_ALTER_USER] = tscBuildUserMsg; - tscBuildMsg[TSDB_SQL_CREATE_DNODE] = tscBuildCreateDnodeMsg; - tscBuildMsg[TSDB_SQL_DROP_DNODE] = tscBuildDropDnodeMsg; - tscBuildMsg[TSDB_SQL_CFG_DNODE] = tscBuildCfgDnodeMsg; - tscBuildMsg[TSDB_SQL_ALTER_TABLE] = tscBuildAlterTableMsg; - tscBuildMsg[TSDB_SQL_UPDATE_TAG_VAL] = tscBuildUpdateTagMsg; - tscBuildMsg[TSDB_SQL_ALTER_DB] = tscAlterDbMsg; - tscBuildMsg[TSDB_SQL_COMPACT_VNODE] = tscBuildCompactMsg; - - - tscBuildMsg[TSDB_SQL_USE_DB] = tscBuildUseDbMsg; - tscBuildMsg[TSDB_SQL_STABLEVGROUP] = tscBuildSTableVgroupMsg; - tscBuildMsg[TSDB_SQL_RETRIEVE_FUNC] = tscBuildRetrieveFuncMsg; - - tscBuildMsg[TSDB_SQL_HB] = tscBuildHeartBeatMsg; - tscBuildMsg[TSDB_SQL_SHOW] = tscBuildShowMsg; - tscBuildMsg[TSDB_SQL_RETRIEVE_MNODE] = tscBuildRetrieveFromMgmtMsg; - tscBuildMsg[TSDB_SQL_KILL_QUERY] = tscBuildKillMsg; - tscBuildMsg[TSDB_SQL_KILL_STREAM] = tscBuildKillMsg; - tscBuildMsg[TSDB_SQL_KILL_CONNECTION] = tscBuildKillMsg; - - tscProcessMsgRsp[TSDB_SQL_SELECT] = tscProcessQueryRsp; - tscProcessMsgRsp[TSDB_SQL_FETCH] = tscProcessRetrieveRspFromNode; - - tscProcessMsgRsp[TSDB_SQL_DROP_DB] = tscProcessDropDbRsp; - tscProcessMsgRsp[TSDB_SQL_DROP_TABLE] = tscProcessDropTableRsp; - - tscProcessMsgRsp[TSDB_SQL_USE_DB] = tscProcessUseDbRsp; - tscProcessMsgRsp[TSDB_SQL_META] = tscProcessTableMetaRsp; - tscProcessMsgRsp[TSDB_SQL_STABLEVGROUP] = tscProcessSTableVgroupRsp; - tscProcessMsgRsp[TSDB_SQL_MULTI_META] = tscProcessMultiTableMetaRsp; - tscProcessMsgRsp[TSDB_SQL_RETRIEVE_FUNC] = tscProcessRetrieveFuncRsp; - - tscProcessMsgRsp[TSDB_SQL_SHOW] = tscProcessShowRsp; - tscProcessMsgRsp[TSDB_SQL_RETRIEVE_MNODE] = tscProcessRetrieveRspFromNode; // rsp handled by same function. - tscProcessMsgRsp[TSDB_SQL_DESCRIBE_TABLE] = tscProcessDescribeTableRsp; - - tscProcessMsgRsp[TSDB_SQL_CURRENT_DB] = tscProcessLocalRetrieveRsp; - tscProcessMsgRsp[TSDB_SQL_CURRENT_USER] = tscProcessLocalRetrieveRsp; - tscProcessMsgRsp[TSDB_SQL_SERV_VERSION] = tscProcessLocalRetrieveRsp; - tscProcessMsgRsp[TSDB_SQL_CLI_VERSION] = tscProcessLocalRetrieveRsp; - tscProcessMsgRsp[TSDB_SQL_SERV_STATUS] = tscProcessLocalRetrieveRsp; - - tscProcessMsgRsp[TSDB_SQL_RETRIEVE_EMPTY_RESULT] = tscProcessEmptyResultRsp; - - tscProcessMsgRsp[TSDB_SQL_RETRIEVE_GLOBALMERGE] = tscProcessRetrieveGlobalMergeRsp; - - tscProcessMsgRsp[TSDB_SQL_ALTER_TABLE] = tscProcessAlterTableMsgRsp; - tscProcessMsgRsp[TSDB_SQL_ALTER_DB] = tscProcessAlterDbMsgRsp; - tscProcessMsgRsp[TSDB_SQL_COMPACT_VNODE] = tscProcessCompactRsp; - - tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_TABLE] = tscProcessShowCreateRsp; - tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_STABLE] = tscProcessShowCreateRsp; - tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_DATABASE] = tscProcessShowCreateRsp; -#endif - - handleRequestRspFp[TMSG_INDEX(TDMT_MND_CONNECT)] = processConnectRsp; - handleRequestRspFp[TMSG_INDEX(TDMT_MND_CREATE_DB)] = processCreateDbRsp; - handleRequestRspFp[TMSG_INDEX(TDMT_MND_USE_DB)] = processUseDbRsp; - handleRequestRspFp[TMSG_INDEX(TDMT_MND_CREATE_STB)] = processCreateTableRsp; - handleRequestRspFp[TMSG_INDEX(TDMT_MND_DROP_DB)] = processDropDbRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_CONNECT)] = processConnectRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_CREATE_DB)] = processCreateDbRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_USE_DB)] = processUseDbRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_CREATE_STB)] = processCreateTableRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_DROP_DB)] = processDropDbRsp; } diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c new file mode 100644 index 0000000000..8c4cff9251 --- /dev/null +++ b/source/client/src/clientStmt.c @@ -0,0 +1,99 @@ + +#include "clientInt.h" +#include "clientLog.h" +#include "clientStmt.h" +#include "tdef.h" + +TAOS_STMT *stmtInit(TAOS *taos) { + STscObj* pObj = (STscObj*)taos; + STscStmt* pStmt = NULL; + +#if 0 + pStmt = taosMemoryCalloc(1, sizeof(STscStmt)); + if (pStmt == NULL) { + terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + tscError("failed to allocate memory for statement"); + return NULL; + } + pStmt->taos = pObj; + + SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); + + if (pSql == NULL) { + free(pStmt); + terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + tscError("failed to allocate memory for statement"); + return NULL; + } + + if (TSDB_CODE_SUCCESS != tscAllocPayload(&pSql->cmd, TSDB_DEFAULT_PAYLOAD_SIZE)) { + free(pSql); + free(pStmt); + terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + tscError("failed to malloc payload buffer"); + return NULL; + } + + tsem_init(&pSql->rspSem, 0, 0); + pSql->signature = pSql; + pSql->pTscObj = pObj; + pSql->maxRetry = TSDB_MAX_REPLICA; + pStmt->pSql = pSql; + pStmt->last = STMT_INIT; + pStmt->numOfRows = 0; + registerSqlObj(pSql); +#endif + + return pStmt; +} + +int stmtClose(TAOS_STMT *stmt) { + return TSDB_CODE_SUCCESS; +} + +int stmtExec(TAOS_STMT *stmt) { + return TSDB_CODE_SUCCESS; +} + +char *stmtErrstr(TAOS_STMT *stmt) { + return NULL; +} + +int stmtAffectedRows(TAOS_STMT *stmt) { + return TSDB_CODE_SUCCESS; +} + +int stmtBind(TAOS_STMT *stmt, TAOS_BIND *bind) { + return TSDB_CODE_SUCCESS; +} + +int stmtPrepare(TAOS_STMT *stmt, const char *sql, unsigned long length) { + return TSDB_CODE_SUCCESS; +} + +int stmtSetTbNameTags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags) { + return TSDB_CODE_SUCCESS; +} + +int stmtIsInsert(TAOS_STMT *stmt, int *insert) { + return TSDB_CODE_SUCCESS; +} + +int stmtGetParamNum(TAOS_STMT *stmt, int *nums) { + return TSDB_CODE_SUCCESS; +} + +int stmtAddBatch(TAOS_STMT *stmt) { + return TSDB_CODE_SUCCESS; +} + +TAOS_RES *stmtUseResult(TAOS_STMT *stmt) { + return NULL; +} + +int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) { + return TSDB_CODE_SUCCESS; +} + + + diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 031ebdaf49..3e37c52c26 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -134,6 +134,42 @@ void *taosDecodeSEpSet(void *buf, SEpSet *pEp) { static int32_t tSerializeSClientHbReq(SCoder *pEncoder, const SClientHbReq *pReq) { if (tEncodeSClientHbKey(pEncoder, &pReq->connKey) < 0) return -1; + if (pReq->connKey.connType == CONN_TYPE__QUERY) { + int32_t queryNum = 0; + if (pReq->query) { + queryNum = 1; + if (tEncodeI32(pEncoder, queryNum) < 0) return -1; + if (tEncodeU32(pEncoder, pReq->query->connId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->query->pid) < 0) return -1; + if (tEncodeCStr(pEncoder, pReq->query->app) < 0) return -1; + + int32_t num = taosArrayGetSize(pReq->query->queryDesc); + if (tEncodeI32(pEncoder, num) < 0) return -1; + + for (int32_t i = 0; i < num; ++i) { + SQueryDesc *desc = taosArrayGet(pReq->query->queryDesc, i); + if (tEncodeCStr(pEncoder, desc->sql) < 0) return -1; + if (tEncodeU64(pEncoder, desc->queryId) < 0) return -1; + if (tEncodeI64(pEncoder, desc->useconds) < 0) return -1; + if (tEncodeI64(pEncoder, desc->stime) < 0) return -1; + if (tEncodeI64(pEncoder, desc->reqRid) < 0) return -1; + if (tEncodeI32(pEncoder, desc->pid) < 0) return -1; + if (tEncodeCStr(pEncoder, desc->fqdn) < 0) return -1; + if (tEncodeI32(pEncoder, desc->subPlanNum) < 0) return -1; + + int32_t snum = desc->subDesc ? taosArrayGetSize(desc->subDesc) : 0; + if (tEncodeI32(pEncoder, snum) < 0) return -1; + for (int32_t m = 0; m < snum; ++m) { + SQuerySubDesc *sDesc = taosArrayGet(desc->subDesc, m); + if (tEncodeI64(pEncoder, sDesc->tid) < 0) return -1; + if (tEncodeI32(pEncoder, sDesc->status) < 0) return -1; + } + } + } else { + if (tEncodeI32(pEncoder, queryNum) < 0) return -1; + } + } + int32_t kvNum = taosHashGetSize(pReq->info); if (tEncodeI32(pEncoder, kvNum) < 0) return -1; void *pIter = taosHashIterate(pReq->info, NULL); @@ -149,6 +185,53 @@ static int32_t tSerializeSClientHbReq(SCoder *pEncoder, const SClientHbReq *pReq static int32_t tDeserializeSClientHbReq(SCoder *pDecoder, SClientHbReq *pReq) { if (tDecodeSClientHbKey(pDecoder, &pReq->connKey) < 0) return -1; + if (pReq->connKey.connType == CONN_TYPE__QUERY) { + int32_t queryNum = 0; + if (tDecodeI32(pDecoder, &queryNum) < 0) return -1; + if (queryNum) { + pReq->query = taosMemoryCalloc(1, sizeof(*pReq->query)); + if (NULL == pReq->query) return -1; + if (tDecodeU32(pDecoder, &pReq->query->connId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->query->pid) < 0) return -1; + if (tDecodeCStrTo(pDecoder, pReq->query->app) < 0) return -1; + + int32_t num = 0; + if (tDecodeI32(pDecoder, &num) < 0) return -1; + if (num > 0) { + pReq->query->queryDesc = taosArrayInit(num, sizeof(SQueryDesc)); + if (NULL == pReq->query->queryDesc) return -1; + + for (int32_t i = 0; i < num; ++i) { + SQueryDesc desc = {0}; + if (tDecodeCStrTo(pDecoder, desc.sql) < 0) return -1; + if (tDecodeU64(pDecoder, &desc.queryId) < 0) return -1; + if (tDecodeI64(pDecoder, &desc.useconds) < 0) return -1; + if (tDecodeI64(pDecoder, &desc.stime) < 0) return -1; + if (tDecodeI64(pDecoder, &desc.reqRid) < 0) return -1; + if (tDecodeI32(pDecoder, &desc.pid) < 0) return -1; + if (tDecodeCStrTo(pDecoder, desc.fqdn) < 0) return -1; + if (tDecodeI32(pDecoder, &desc.subPlanNum) < 0) return -1; + + int32_t snum = 0; + if (tDecodeI32(pDecoder, &snum) < 0) return -1; + if (snum > 0) { + desc.subDesc = taosArrayInit(snum, sizeof(SQuerySubDesc)); + if (NULL == desc.subDesc) return -1; + + for (int32_t m = 0; m < snum; ++m) { + SQuerySubDesc sDesc = {0}; + if (tDecodeI64(pDecoder, &sDesc.tid) < 0) return -1; + if (tDecodeI32(pDecoder, &sDesc.status) < 0) return -1; + taosArrayPush(desc.subDesc, &sDesc); + } + } + + taosArrayPush(pReq->query->queryDesc, &desc); + } + } + } + } + int32_t kvNum = 0; if (tDecodeI32(pDecoder, &kvNum) < 0) return -1; if (pReq->info == NULL) { @@ -168,6 +251,20 @@ static int32_t tSerializeSClientHbRsp(SCoder *pEncoder, const SClientHbRsp *pRsp if (tEncodeSClientHbKey(pEncoder, &pRsp->connKey) < 0) return -1; if (tEncodeI32(pEncoder, pRsp->status) < 0) return -1; + int32_t queryNum = 0; + if (pRsp->query) { + queryNum = 1; + if (tEncodeI32(pEncoder, queryNum) < 0) return -1; + if (tEncodeU32(pEncoder, pRsp->query->connId) < 0) return -1; + if (tEncodeU64(pEncoder, pRsp->query->killRid) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->query->totalDnodes) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->query->onlineDnodes) < 0) return -1; + if (tEncodeI8(pEncoder, pRsp->query->killConnection) < 0) return -1; + if (tEncodeSEpSet(pEncoder, &pRsp->query->epSet) < 0) return -1; + } else { + if (tEncodeI32(pEncoder, queryNum) < 0) return -1; + } + int32_t kvNum = taosArrayGetSize(pRsp->info); if (tEncodeI32(pEncoder, kvNum) < 0) return -1; for (int32_t i = 0; i < kvNum; i++) { @@ -182,6 +279,19 @@ static int32_t tDeserializeSClientHbRsp(SCoder *pDecoder, SClientHbRsp *pRsp) { if (tDecodeSClientHbKey(pDecoder, &pRsp->connKey) < 0) return -1; if (tDecodeI32(pDecoder, &pRsp->status) < 0) return -1; + int32_t queryNum = 0; + if (tDecodeI32(pDecoder, &queryNum) < 0) return -1; + if (queryNum) { + pRsp->query = taosMemoryCalloc(1, sizeof(*pRsp->query)); + if (NULL == pRsp->query) return -1; + if (tDecodeU32(pDecoder, &pRsp->query->connId) < 0) return -1; + if (tDecodeU64(pDecoder, &pRsp->query->killRid) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->query->totalDnodes) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->query->onlineDnodes) < 0) return -1; + if (tDecodeI8(pDecoder, &pRsp->query->killConnection) < 0) return -1; + if (tDecodeSEpSet(pDecoder, &pRsp->query->epSet) < 0) return -1; + } + int32_t kvNum = 0; if (tDecodeI32(pDecoder, &kvNum) < 0) return -1; pRsp->info = taosArrayInit(kvNum, sizeof(SKv)); @@ -224,8 +334,9 @@ int32_t tDeserializeSClientHbBatchReq(void *buf, int32_t bufLen, SClientHbBatchR int32_t reqNum = 0; if (tDecodeI32(&decoder, &reqNum) < 0) return -1; - if (pBatchReq->reqs == NULL) { + if (reqNum > 0) { pBatchReq->reqs = taosArrayInit(reqNum, sizeof(SClientHbReq)); + if (NULL == pBatchReq->reqs) return -1; } for (int32_t i = 0; i < reqNum; i++) { SClientHbReq req = {0}; @@ -2567,7 +2678,7 @@ int32_t tSerializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) { if (tStartEncode(&encoder) < 0) return -1; if (tEncodeI32(&encoder, pRsp->acctId) < 0) return -1; if (tEncodeI64(&encoder, pRsp->clusterId) < 0) return -1; - if (tEncodeI32(&encoder, pRsp->connId) < 0) return -1; + if (tEncodeU32(&encoder, pRsp->connId) < 0) return -1; if (tEncodeI8(&encoder, pRsp->superUser) < 0) return -1; if (tEncodeI8(&encoder, pRsp->connType) < 0) return -1; if (tEncodeSEpSet(&encoder, &pRsp->epSet) < 0) return -1; @@ -2586,7 +2697,7 @@ int32_t tDeserializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) { if (tStartDecode(&decoder) < 0) return -1; if (tDecodeI32(&decoder, &pRsp->acctId) < 0) return -1; if (tDecodeI64(&decoder, &pRsp->clusterId) < 0) return -1; - if (tDecodeI32(&decoder, &pRsp->connId) < 0) return -1; + if (tDecodeU32(&decoder, &pRsp->connId) < 0) return -1; if (tDecodeI8(&decoder, &pRsp->superUser) < 0) return -1; if (tDecodeI8(&decoder, &pRsp->connType) < 0) return -1; if (tDecodeSEpSet(&decoder, &pRsp->epSet) < 0) return -1; diff --git a/source/common/src/ttypes.c b/source/common/src/ttypes.c index ef75adeb5d..cb8746c963 100644 --- a/source/common/src/ttypes.c +++ b/source/common/src/ttypes.c @@ -377,7 +377,7 @@ tDataTypeDescriptor tDataTypes[15] = { getStatics_i64}, {TSDB_DATA_TYPE_FLOAT, 5, FLOAT_BYTES, "FLOAT", 0, 0, tsCompressFloat, tsDecompressFloat, getStatics_f}, {TSDB_DATA_TYPE_DOUBLE, 6, DOUBLE_BYTES, "DOUBLE", 0, 0, tsCompressDouble, tsDecompressDouble, getStatics_d}, - {TSDB_DATA_TYPE_BINARY, 6, 0, "BINARY", 0, 0, tsCompressString, tsDecompressString, getStatics_bin}, + {TSDB_DATA_TYPE_VARCHAR, 6, 0, "VARCHAR", 0, 0, tsCompressString, tsDecompressString, getStatics_bin}, {TSDB_DATA_TYPE_TIMESTAMP, 9, LONG_BYTES, "TIMESTAMP", INT64_MIN, INT64_MAX, tsCompressTimestamp, tsDecompressTimestamp, getStatics_i64}, {TSDB_DATA_TYPE_NCHAR, 5, 8, "NCHAR", 0, 0, tsCompressString, tsDecompressString, getStatics_nchr}, @@ -402,7 +402,7 @@ char tTokenTypeSwitcher[13] = { TSDB_DATA_TYPE_DOUBLE, // TK_DOUBLE TSDB_DATA_TYPE_BINARY, // TK_STRING TSDB_DATA_TYPE_BIGINT, // TK_TIMESTAMP - TSDB_DATA_TYPE_BINARY, // TK_BINARY + TSDB_DATA_TYPE_VARCHAR, // TK_BINARY TSDB_DATA_TYPE_NCHAR, // TK_NCHAR }; diff --git a/source/dnode/mgmt/implement/CMakeLists.txt b/source/dnode/mgmt/implement/CMakeLists.txt index 26c14edc77..fbe7530395 100644 --- a/source/dnode/mgmt/implement/CMakeLists.txt +++ b/source/dnode/mgmt/implement/CMakeLists.txt @@ -6,12 +6,4 @@ target_link_libraries( target_include_directories( dnode PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" -) - -IF (TD_GRANT) - TARGET_LINK_LIBRARIES(dnode grant) -ENDIF () -IF (TD_USB_DONGLE) - TARGET_LINK_LIBRARIES(dnode usb_dongle) -else() -ENDIF () \ No newline at end of file +) \ 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 484b6646b5..925197d708 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -91,9 +91,9 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { pCfg->keep = pCreate->daysToKeep0; pCfg->streamMode = pCreate->streamMode; pCfg->isWeak = true; - pCfg->tsdbCfg.keep = pCreate->daysToKeep0; - pCfg->tsdbCfg.keep1 = pCreate->daysToKeep2; pCfg->tsdbCfg.keep2 = pCreate->daysToKeep0; + pCfg->tsdbCfg.keep0 = pCreate->daysToKeep2; + pCfg->tsdbCfg.keep1 = pCreate->daysToKeep0; pCfg->tsdbCfg.lruCacheSize = pCreate->cacheBlockSize; pCfg->tsdbCfg.retentions = pCreate->pRetensions; pCfg->metaCfg.lruSize = pCreate->cacheBlockSize; @@ -121,6 +121,8 @@ static void vmGenerateWrapperCfg(SVnodesMgmt *pMgmt, SCreateVnodeReq *pCreate, S int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { SRpcMsg *pReq = &pMsg->rpcMsg; SCreateVnodeReq createReq = {0}; + char path[TSDB_FILENAME_LEN]; + if (tDeserializeSCreateVnodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; return -1; @@ -143,6 +145,14 @@ int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { return -1; } + // create vnode + snprintf(path, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, vnodeCfg.vgId); + if (vnodeCreate(path, &vnodeCfg, pMgmt->pTfs) < 0) { + tFreeSCreateVnodeReq(&createReq); + dError("vgId:%d, failed to create vnode since %s", createReq.vgId, terrstr()); + return -1; + } + SMsgCb msgCb = pMgmt->pDnode->data.msgCb; msgCb.pWrapper = pMgmt->pWrapper; msgCb.queueFps[QUERY_QUEUE] = vmPutMsgToQueryQueue; diff --git a/source/dnode/mnode/impl/CMakeLists.txt b/source/dnode/mnode/impl/CMakeLists.txt index 8cb5e2a528..a4bd12a7f7 100644 --- a/source/dnode/mnode/impl/CMakeLists.txt +++ b/source/dnode/mnode/impl/CMakeLists.txt @@ -12,8 +12,8 @@ target_link_libraries( IF (TD_GRANT) TARGET_LINK_LIBRARIES(mnode grant) ENDIF () -IF (TD_USB_DONGLE) - TARGET_LINK_LIBRARIES(mnode usb_dongle) +IF (TD_GRANT) + ADD_DEFINITIONS(-D_GRANT) ENDIF () if(${BUILD_TEST}) diff --git a/source/dnode/mnode/impl/inc/mndDb.h b/source/dnode/mnode/impl/inc/mndDb.h index c0b25d74d1..146c6e2523 100644 --- a/source/dnode/mnode/impl/inc/mndDb.h +++ b/source/dnode/mnode/impl/inc/mndDb.h @@ -27,7 +27,7 @@ void mndCleanupDb(SMnode *pMnode); SDbObj *mndAcquireDb(SMnode *pMnode, const char *db); void mndReleaseDb(SMnode *pMnode, SDbObj *pDb); int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs, void **ppRsp, int32_t *pRspLen); -char *mnGetDbStr(char *src); +char *mndGetDbStr(char *src); int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUseDbReq *pReq); #ifdef __cplusplus diff --git a/source/dnode/mnode/impl/inc/mndInt.h b/source/dnode/mnode/impl/inc/mndInt.h index 11c1b09cc9..7b67308876 100644 --- a/source/dnode/mnode/impl/inc/mndInt.h +++ b/source/dnode/mnode/impl/inc/mndInt.h @@ -38,6 +38,10 @@ extern "C" { #define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", DEBUG_DEBUG, mDebugFlag, __VA_ARGS__); }} #define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }} +#define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE) +#define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE) +#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE) + typedef int32_t (*MndMsgFp)(SNodeMsg *pMsg); typedef int32_t (*MndInitFp)(SMnode *pMnode); typedef void (*MndCleanupFp)(SMnode *pMnode); @@ -74,7 +78,6 @@ typedef struct { } SShowMgmt; typedef struct { - int32_t connId; SCacheObj *cache; } SProfileMgmt; @@ -118,6 +121,7 @@ struct SMnode { STelemMgmt telemMgmt; SSyncMgmt syncMgmt; SHashObj *infosMeta; + SHashObj *perfsMeta; SGrantInfo grant; MndMsgFp msgFp[TDMT_MAX]; SMsgCb msgCb; diff --git a/source/dnode/mnode/impl/inc/mndPerfSchema.h b/source/dnode/mnode/impl/inc/mndPerfSchema.h new file mode 100644 index 0000000000..2c613e253c --- /dev/null +++ b/source/dnode/mnode/impl/inc/mndPerfSchema.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_MND_PERF_SCHEMA_H_ +#define _TD_MND_PERF_SCHEMA_H_ + +#include "mndInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct SPerfsTableSchema { + char *name; + int32_t type; + int32_t bytes; +} SPerfsTableSchema; + +typedef struct SPerfsTableMeta { + char *name; + const SPerfsTableSchema *schema; + int32_t colNum; +} SPerfsTableMeta; + +int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp); +int32_t mndInitPerfs(SMnode *pMnode); +void mndCleanupPerfs(SMnode *pMnode); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MND_PERF_SCHEMA_H_*/ diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 3db4e9870e..6c797b9044 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -1128,6 +1128,8 @@ static int32_t mndProcessUseDbReq(SNodeMsg *pReq) { if (taosArrayGetSize(usedbRsp.pVgroupInfos) <= 0) { terrno = TSDB_CODE_MND_DB_NOT_EXIST; + } else { + code = 0; } } else { usedbRsp.vgVersion = usedbReq.vgVersion; @@ -1340,7 +1342,7 @@ SYNC_DB_OVER: return code; } -char *mnGetDbStr(char *src) { +char *mndGetDbStr(char *src) { char *pos = strstr(src, TS_PATH_DELIMITER); if (pos != NULL) ++pos; @@ -1355,7 +1357,7 @@ static void dumpDbInfoData(SSDataBlock* pBlock, SDbObj *pDb, SShowObj *pShow, in int32_t cols = 0; char* buf = taosMemoryMalloc(pShow->bytes[cols]); - char *name = mnGetDbStr(pDb->name); + char *name = mndGetDbStr(pDb->name); if (name != NULL) { STR_WITH_MAXSIZE_TO_VARSTR(buf, name, pShow->bytes[cols]); } else { diff --git a/source/dnode/mnode/impl/src/mndInfoSchema.c b/source/dnode/mnode/impl/src/mndInfoSchema.c index c21a6e61df..f626332fc2 100644 --- a/source/dnode/mnode/impl/src/mndInfoSchema.c +++ b/source/dnode/mnode/impl/src/mndInfoSchema.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "mndInfoSchema.h" +#include "mndInt.h" #define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE) #define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE) @@ -81,7 +82,7 @@ static const SInfosTableSchema userDBSchema[] = { {.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "minrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "maxrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, - {.name = "wallevel", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, + {.name = "wal", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, {.name = "fsync", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "comp", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, {.name = "cachelast", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, @@ -94,11 +95,13 @@ static const SInfosTableSchema userDBSchema[] = { }; static const SInfosTableSchema userFuncSchema[] = { - {.name = "name", .bytes = 32, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "name", .bytes = TSDB_FUNC_NAME_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "comment", .bytes = PATH_MAX - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "aggregate", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "comment", .bytes = TSDB_TYPE_STR_MAX_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, - {.name = "ntables", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, - {.name = "precision", .bytes = 2, .type = TSDB_DATA_TYPE_VARCHAR}, - {.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "code_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "bufsize", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, }; static const SInfosTableSchema userIdxSchema[] = { diff --git a/source/dnode/mnode/impl/src/mndPerfSchema.c b/source/dnode/mnode/impl/src/mndPerfSchema.c new file mode 100644 index 0000000000..38e9e79228 --- /dev/null +++ b/source/dnode/mnode/impl/src/mndPerfSchema.c @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "mndPerfSchema.h" +#include "mndInt.h" + +//!!!! Note: only APPEND columns in below tables, NO insert !!!! +static const SPerfsTableSchema connectionsSchema[] = { + {.name = "conn_id", .bytes = 4, .type = TSDB_DATA_TYPE_UINT}, + {.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "program", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "end_point", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "login_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, +}; +static const SPerfsTableSchema queriesSchema[] = { + {.name = "query_id", .bytes = 4, .type = TSDB_DATA_TYPE_UBIGINT}, + {.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "fqdn", .bytes = TSDB_FQDN_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT}, + {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "sub_queries", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "sub_query_info", .bytes = TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, +}; + +static const SPerfsTableSchema topicSchema[] = { + {.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "row_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, +}; + +static const SPerfsTableSchema consumerSchema[] = { + {.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "status", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + // ep + // up time + // topics +}; + +static const SPerfsTableSchema subscribeSchema[] = { + {.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, +}; + +static const SPerfsTableMeta perfsMeta[] = { + {TSDB_PERFS_TABLE_CONNECTIONS, connectionsSchema, tListLen(connectionsSchema)}, + {TSDB_PERFS_TABLE_QUERIES, queriesSchema, tListLen(queriesSchema)}, + {TSDB_PERFS_TABLE_TOPICS, topicSchema, tListLen(topicSchema)}, + {TSDB_PERFS_TABLE_CONSUMERS, consumerSchema, tListLen(consumerSchema)}, + {TSDB_PERFS_TABLE_SUBSCRIBES, subscribeSchema, tListLen(subscribeSchema)}, +}; + +// connection/application/ +int32_t mndInitPerfsTableSchema(const SPerfsTableSchema *pSrc, int32_t colNum, SSchema **pDst) { + SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema)); + if (NULL == schema) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + for (int32_t i = 0; i < colNum; ++i) { + strcpy(schema[i].name, pSrc[i].name); + + schema[i].type = pSrc[i].type; + schema[i].colId = i + 1; + schema[i].bytes = pSrc[i].bytes; + } + + *pDst = schema; + return TSDB_CODE_SUCCESS; +} + +int32_t mndPerfsInitMeta(SHashObj *hash) { + STableMetaRsp meta = {0}; + + strcpy(meta.dbFName, TSDB_INFORMATION_SCHEMA_DB); + meta.tableType = TSDB_SYSTEM_TABLE; + meta.sversion = 1; + meta.tversion = 1; + + for (int32_t i = 0; i < tListLen(perfsMeta); ++i) { + strcpy(meta.tbName, perfsMeta[i].name); + meta.numOfColumns = perfsMeta[i].colNum; + + if (mndInitPerfsTableSchema(perfsMeta[i].schema, perfsMeta[i].colNum, &meta.pSchemas)) { + return -1; + } + + if (taosHashPut(hash, meta.tbName, strlen(meta.tbName), &meta, sizeof(meta))) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + } + + return TSDB_CODE_SUCCESS; +} + +int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp) { + if (NULL == pMnode->perfsMeta) { + terrno = TSDB_CODE_MND_NOT_READY; + return -1; + } + + STableMetaRsp *meta = (STableMetaRsp *)taosHashGet(pMnode->perfsMeta, tbName, strlen(tbName)); + if (NULL == meta) { + mError("invalid performance schema table name:%s", tbName); + terrno = TSDB_CODE_MND_INVALID_INFOS_TBL; + return -1; + } + + *pRsp = *meta; + + pRsp->pSchemas = taosMemoryCalloc(meta->numOfColumns, sizeof(SSchema)); + if (pRsp->pSchemas == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + pRsp->pSchemas = NULL; + return -1; + } + + memcpy(pRsp->pSchemas, meta->pSchemas, meta->numOfColumns * sizeof(SSchema)); + + return 0; +} + +int32_t mndInitPerfs(SMnode *pMnode) { + pMnode->perfsMeta = taosHashInit(20, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); + if (pMnode->perfsMeta == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + return mndPerfsInitMeta(pMnode->perfsMeta); +} + +void mndCleanupPerfs(SMnode *pMnode) { + if (NULL == pMnode->perfsMeta) { + return; + } + + void *pIter = taosHashIterate(pMnode->perfsMeta, NULL); + while (pIter) { + STableMetaRsp *meta = (STableMetaRsp *)pIter; + + taosMemoryFreeClear(meta->pSchemas); + + pIter = taosHashIterate(pMnode->perfsMeta, pIter); + } + + taosHashCleanup(pMnode->perfsMeta); + pMnode->perfsMeta = NULL; +} + diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 353a147a92..826a73afc6 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -24,7 +24,7 @@ #include "version.h" typedef struct { - int32_t id; + uint32_t id; int8_t connType; char user[TSDB_USER_LEN]; char app[TSDB_APP_NAME_LEN]; // app name that invokes taosc @@ -35,15 +35,15 @@ typedef struct { int8_t killed; int64_t loginTimeMs; int64_t lastAccessTimeMs; - int32_t queryId; + uint64_t killId; int32_t numOfQueries; - SQueryDesc *pQueries; + SArray *pQueries; //SArray } SConnObj; static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType, uint32_t ip, uint16_t port, int32_t pid, const char *app, int64_t startTime); static void mndFreeConn(SConnObj *pConn); -static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId); +static SConnObj *mndAcquireConn(SMnode *pMnode, uint32_t connId); static void mndReleaseConn(SMnode *pMnode, SConnObj *pConn); static void *mndGetNextConn(SMnode *pMnode, SCacheIter *pIter); static void mndCancelGetNextConn(SMnode *pMnode, void *pIter); @@ -91,8 +91,9 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType int32_t pid, const char *app, int64_t startTime) { SProfileMgmt *pMgmt = &pMnode->profileMgmt; - int32_t connId = atomic_add_fetch_32(&pMgmt->connId, 1); - if (connId == 0) atomic_add_fetch_32(&pMgmt->connId, 1); + char connStr[255] = {0}; + int32_t len = snprintf(connStr, sizeof(connStr), "%s%d%d%d%s", user, ip, port, pid, app); + int32_t connId = mndGenerateUid(connStr, len); if (startTime == 0) startTime = taosGetTimestampMs(); SConnObj connObj = {.id = connId, @@ -104,7 +105,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType .killed = 0, .loginTimeMs = taosGetTimestampMs(), .lastAccessTimeMs = 0, - .queryId = 0, + .killId = 0, .numOfQueries = 0, .pQueries = NULL}; @@ -119,35 +120,35 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType mError("conn:%d, failed to put into cache since %s, user:%s", connId, user, terrstr()); return NULL; } else { - mTrace("conn:%d, is created, data:%p user:%s", pConn->id, pConn, user); + mTrace("conn:%u, is created, data:%p user:%s", pConn->id, pConn, user); return pConn; } } static void mndFreeConn(SConnObj *pConn) { taosMemoryFreeClear(pConn->pQueries); - mTrace("conn:%d, is destroyed, data:%p", pConn->id, pConn); + mTrace("conn:%u, is destroyed, data:%p", pConn->id, pConn); } -static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId) { +static SConnObj *mndAcquireConn(SMnode *pMnode, uint32_t connId) { SProfileMgmt *pMgmt = &pMnode->profileMgmt; - SConnObj *pConn = taosCacheAcquireByKey(pMgmt->cache, &connId, sizeof(int32_t)); + SConnObj *pConn = taosCacheAcquireByKey(pMgmt->cache, &connId, sizeof(connId)); if (pConn == NULL) { - mDebug("conn:%d, already destroyed", connId); + mDebug("conn:%u, already destroyed", connId); return NULL; } int32_t keepTime = tsShellActivityTimer * 3; pConn->lastAccessTimeMs = keepTime * 1000 + (uint64_t)taosGetTimestampMs(); - mTrace("conn:%d, acquired from cache, data:%p", pConn->id, pConn); + mTrace("conn:%u, acquired from cache, data:%p", pConn->id, pConn); return pConn; } static void mndReleaseConn(SMnode *pMnode, SConnObj *pConn) { if (pConn == NULL) return; - mTrace("conn:%d, released from cache, data:%p", pConn->id, pConn); + mTrace("conn:%u, released from cache, data:%p", pConn->id, pConn); SProfileMgmt *pMgmt = &pMnode->profileMgmt; taosCacheRelease(pMgmt->cache, (void **)&pConn, false); @@ -212,6 +213,8 @@ static int32_t mndProcessConnectReq(SNodeMsg *pReq) { goto CONN_OVER; } + mndAcquireConn(pMnode, pConn->id); + SConnectRsp connectRsp = {0}; connectRsp.acctId = pUser->acctId; connectRsp.superUser = pUser->superUser; @@ -232,7 +235,7 @@ static int32_t mndProcessConnectReq(SNodeMsg *pReq) { pReq->rspLen = contLen; pReq->pRsp = pRsp; - mDebug("user:%s, login from %s, conn:%d, app:%s", pReq->user, ip, pConn->id, connReq.app); + mDebug("user:%s, login from %s:%d, conn:%u, app:%s", pReq->user, ip, pConn->port, pConn->id, connReq.app); code = 0; @@ -245,22 +248,13 @@ CONN_OVER: return code; } -static int32_t mndSaveQueryStreamList(SConnObj *pConn, SHeartBeatReq *pReq) { - pConn->numOfQueries = 0; - int32_t numOfQueries = htonl(pReq->numOfQueries); +static int32_t mndSaveQueryList(SConnObj *pConn, SQueryHbReqBasic *pBasic) { + taosArrayDestroyEx(pConn->pQueries, tFreeClientHbQueryDesc); - if (numOfQueries > 0) { - if (pConn->pQueries == NULL) { - pConn->pQueries = taosMemoryCalloc(sizeof(SQueryDesc), QUERY_SAVE_SIZE); - } - - pConn->numOfQueries = TMIN(QUERY_SAVE_SIZE, numOfQueries); - - int32_t saveSize = pConn->numOfQueries * sizeof(SQueryDesc); - if (saveSize > 0 && pConn->pQueries != NULL) { - memcpy(pConn->pQueries, pReq->pData, saveSize); - } - } + pConn->pQueries = pBasic->queryDesc; + pBasic->queryDesc = NULL; + + pConn->numOfQueries = pBasic->queryDesc ? taosArrayGetSize(pBasic->queryDesc) : 0; return TSDB_CODE_SUCCESS; } @@ -330,6 +324,111 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) { return NULL; } +static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHbReq *pHbReq, SClientHbBatchRsp *pBatchRsp) { + SProfileMgmt *pMgmt = &pMnode->profileMgmt; + SClientHbRsp hbRsp = {.connKey = pHbReq->connKey, .status = 0, .info = NULL, .query = NULL}; + + if (pHbReq->query) { + SQueryHbReqBasic *pBasic = pHbReq->query; + + SRpcConnInfo connInfo = {0}; + rpcGetConnInfo(pMsg->handle, &connInfo); + + SConnObj *pConn = mndAcquireConn(pMnode, pBasic->connId); + if (pConn == NULL) { + pConn = mndCreateConn(pMnode, connInfo.user, CONN_TYPE__QUERY, connInfo.clientIp, connInfo.clientPort, pBasic->pid, pBasic->app, 0); + if (pConn == NULL) { + mError("user:%s, conn:%u is freed and failed to create new since %s", connInfo.user, pBasic->connId, terrstr()); + return -1; + } else { + mDebug("user:%s, conn:%u is freed and create a new conn:%u", connInfo.user, pBasic->connId, pConn->id); + } + } else if (pConn->killed) { + mError("user:%s, conn:%u is already killed", connInfo.user, pConn->id); + mndReleaseConn(pMnode, pConn); + terrno = TSDB_CODE_MND_INVALID_CONNECTION; + return -1; + } + + SQueryHbRspBasic *rspBasic = taosMemoryCalloc(1, sizeof(SQueryHbRspBasic)); + if (rspBasic == NULL) { + mndReleaseConn(pMnode, pConn); + terrno = TSDB_CODE_OUT_OF_MEMORY; + mError("user:%s, conn:%u failed to process hb while since %s", pConn->user, pBasic->connId, terrstr()); + return -1; + } + + mndSaveQueryList(pConn, pBasic); + if (pConn->killed != 0) { + rspBasic->killConnection = 1; + } + + if (pConn->killId != 0) { + rspBasic->killRid = pConn->killId; + pConn->killId = 0; + } + + rspBasic->connId = pConn->id; + rspBasic->totalDnodes = 1; //TODO + rspBasic->onlineDnodes = 1; //TODO + mndGetMnodeEpSet(pMnode, &rspBasic->epSet); + mndReleaseConn(pMnode, pConn); + + hbRsp.query = rspBasic; + } + + int32_t kvNum = taosHashGetSize(pHbReq->info); + if (NULL == pHbReq->info || kvNum <= 0) { + taosArrayPush(pBatchRsp->rsps, &hbRsp); + return TSDB_CODE_SUCCESS; + } + + hbRsp.info = taosArrayInit(kvNum, sizeof(SKv)); + if (NULL == hbRsp.info) { + mError("taosArrayInit %d rsp kv failed", kvNum); + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + void *pIter = taosHashIterate(pHbReq->info, NULL); + while (pIter != NULL) { + SKv *kv = pIter; + + switch (kv->key) { + case HEARTBEAT_KEY_DBINFO: { + void *rspMsg = NULL; + int32_t rspLen = 0; + mndValidateDbInfo(pMnode, kv->value, kv->valueLen / sizeof(SDbVgVersion), &rspMsg, &rspLen); + if (rspMsg && rspLen > 0) { + SKv kv1 = {.key = HEARTBEAT_KEY_DBINFO, .valueLen = rspLen, .value = rspMsg}; + taosArrayPush(hbRsp.info, &kv1); + } + break; + } + case HEARTBEAT_KEY_STBINFO: { + void *rspMsg = NULL; + int32_t rspLen = 0; + mndValidateStbInfo(pMnode, kv->value, kv->valueLen / sizeof(SSTableMetaVersion), &rspMsg, &rspLen); + if (rspMsg && rspLen > 0) { + SKv kv1 = {.key = HEARTBEAT_KEY_STBINFO, .valueLen = rspLen, .value = rspMsg}; + taosArrayPush(hbRsp.info, &kv1); + } + break; + } + default: + mError("invalid kv key:%d", kv->key); + hbRsp.status = TSDB_CODE_MND_APP_ERROR; + break; + } + + pIter = taosHashIterate(pHbReq->info, pIter); + } + + taosArrayPush(pBatchRsp->rsps, &hbRsp); + + return TSDB_CODE_SUCCESS; +} + static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) { SMnode *pMnode = pReq->pNode; @@ -345,50 +444,9 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) { int32_t sz = taosArrayGetSize(batchReq.reqs); for (int i = 0; i < sz; i++) { SClientHbReq *pHbReq = taosArrayGet(batchReq.reqs, i); - if (pHbReq->connKey.hbType == HEARTBEAT_TYPE_QUERY) { - int32_t kvNum = taosHashGetSize(pHbReq->info); - if (NULL == pHbReq->info || kvNum <= 0) { - continue; - } - - SClientHbRsp hbRsp = {.connKey = pHbReq->connKey, .status = 0, .info = taosArrayInit(kvNum, sizeof(SKv))}; - - void *pIter = taosHashIterate(pHbReq->info, NULL); - while (pIter != NULL) { - SKv *kv = pIter; - - switch (kv->key) { - case HEARTBEAT_KEY_DBINFO: { - void *rspMsg = NULL; - int32_t rspLen = 0; - mndValidateDbInfo(pMnode, kv->value, kv->valueLen / sizeof(SDbVgVersion), &rspMsg, &rspLen); - if (rspMsg && rspLen > 0) { - SKv kv1 = {.key = HEARTBEAT_KEY_DBINFO, .valueLen = rspLen, .value = rspMsg}; - taosArrayPush(hbRsp.info, &kv1); - } - break; - } - case HEARTBEAT_KEY_STBINFO: { - void *rspMsg = NULL; - int32_t rspLen = 0; - mndValidateStbInfo(pMnode, kv->value, kv->valueLen / sizeof(SSTableMetaVersion), &rspMsg, &rspLen); - if (rspMsg && rspLen > 0) { - SKv kv1 = {.key = HEARTBEAT_KEY_STBINFO, .valueLen = rspLen, .value = rspMsg}; - taosArrayPush(hbRsp.info, &kv1); - } - break; - } - default: - mError("invalid kv key:%d", kv->key); - hbRsp.status = TSDB_CODE_MND_APP_ERROR; - break; - } - - pIter = taosHashIterate(pHbReq->info, pIter); - } - - taosArrayPush(batchRsp.rsps, &hbRsp); - } else if (pHbReq->connKey.hbType == HEARTBEAT_TYPE_MQ) { + if (pHbReq->connKey.connType == CONN_TYPE__QUERY) { + mndProcessQueryHeartBeat(pMnode, &pReq->rpcMsg, pHbReq, &batchRsp); + } else if (pHbReq->connKey.connType == CONN_TYPE__TMQ) { SClientHbRsp *pRsp = mndMqHbBuildRsp(pMnode, pHbReq); if (pRsp != NULL) { taosArrayPush(batchRsp.rsps, pRsp); @@ -416,73 +474,8 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) { taosArrayDestroy(batchRsp.rsps); pReq->rspLen = tlen; pReq->pRsp = buf; + return 0; - -#if 0 - SMnode *pMnode = pReq->pNode; - SProfileMgmt *pMgmt = &pMnode->profileMgmt; - - SHeartBeatReq *pHeartbeat = pReq->rpcMsg.pCont; - pHeartbeat->connId = htonl(pHeartbeat->connId); - pHeartbeat->pid = htonl(pHeartbeat->pid); - - SConnObj *pConn = mndAcquireConn(pMnode, pHeartbeat->connId); - if (pConn == NULL) { - pConn = mndCreateConn(pMnode, &info, pHeartbeat->pid, pHeartbeat->app, 0); - if (pConn == NULL) { - mError("user:%s, conn:%d is freed and failed to create new since %s", pReq->user, pHeartbeat->connId, terrstr()); - return -1; - } else { - mDebug("user:%s, conn:%d is freed and create a new conn:%d", pReq->user, pHeartbeat->connId, pConn->id); - } - } else if (pConn->killed) { - mError("user:%s, conn:%d is already killed", pReq->user, pConn->id); - terrno = TSDB_CODE_MND_INVALID_CONNECTION; - return -1; - } else { - if (pConn->ip != info.clientIp || pConn->port != info.clientPort /* || strcmp(pConn->user, info.user) != 0 */) { - char oldIpStr[40]; - char newIpStr[40]; - taosIpPort2String(pConn->ip, pConn->port, oldIpStr); - taosIpPort2String(info.clientIp, info.clientPort, newIpStr); - mError("conn:%d, incoming conn user:%s ip:%s, not match exist user:%s ip:%s", pConn->id, info.user, newIpStr, - pConn->user, oldIpStr); - - if (pMgmt->connId < pConn->id) pMgmt->connId = pConn->id + 1; - taosCacheRelease(pMgmt->cache, (void **)&pConn, false); - terrno = TSDB_CODE_MND_INVALID_CONNECTION; - return -1; - } - } - - SHeartBeatRsp *pRsp = rpcMallocCont(sizeof(SHeartBeatRsp)); - if (pRsp == NULL) { - mndReleaseConn(pMnode, pConn); - terrno = TSDB_CODE_OUT_OF_MEMORY; - mError("user:%s, conn:%d failed to process hb while since %s", pReq->user, pHeartbeat->connId, terrstr()); - return -1; - } - - mndSaveQueryStreamList(pConn, pHeartbeat); - if (pConn->killed != 0) { - pRsp->killConnection = 1; - } - - if (pConn->queryId != 0) { - pRsp->queryId = htonl(pConn->queryId); - pConn->queryId = 0; - } - - pRsp->connId = htonl(pConn->id); - pRsp->totalDnodes = htonl(1); - pRsp->onlineDnodes = htonl(1); - mndGetMnodeEpSet(pMnode, &pRsp->epSet); - mndReleaseConn(pMnode, pConn); - - pReq->contLen = sizeof(SConnectRsp); - pReq->pRsp = pRsp; - return 0; -#endif } static int32_t mndProcessKillQueryReq(SNodeMsg *pReq) { @@ -513,7 +506,7 @@ static int32_t mndProcessKillQueryReq(SNodeMsg *pReq) { return -1; } else { mInfo("connId:%d, queryId:%d is killed by user:%s", killReq.connId, killReq.queryId, pReq->user); - pConn->queryId = killReq.queryId; + pConn->killId = killReq.queryId; taosCacheRelease(pMgmt->cache, (void **)&pConn, false); return 0; } @@ -571,7 +564,7 @@ static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int cols = 0; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int32_t *)pWrite = pConn->id; + *(uint32_t *)pWrite = pConn->id; cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; @@ -613,6 +606,7 @@ static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) { SMnode *pMnode = pReq->pNode; int32_t numOfRows = 0; +#if 0 SConnObj *pConn = NULL; int32_t cols = 0; char *pWrite; @@ -709,6 +703,7 @@ static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, i } pShow->numOfRows += numOfRows; +#endif return numOfRows; } diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index 617cebf61d..1a14c94640 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -131,6 +131,13 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) { req.type = retrieveReq.type; strncpy(req.db, retrieveReq.db, tListLen(req.db)); + STableMetaRsp *pMeta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb) + 1); + if (pMeta == NULL) { + terrno = TSDB_CODE_MND_INVALID_INFOS_TBL; + mError("failed to process show-retrieve req:%p since %s", pShow, terrstr()); + return -1; + } + pShow = mndCreateShowObj(pMnode, &req); if (pShow == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -138,7 +145,7 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) { return -1; } - pShow->pMeta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb) + 1); + pShow->pMeta = pMeta; pShow->numOfColumns = pShow->pMeta->numOfColumns; int32_t offset = 0; diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 92a67fd7e9..0ce73005e8 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -18,6 +18,7 @@ #include "mndDb.h" #include "mndDnode.h" #include "mndInfoSchema.h" +#include "mndPerfSchema.h" #include "mndMnode.h" #include "mndShow.h" #include "mndTrans.h" @@ -1516,6 +1517,11 @@ static int32_t mndProcessTableMetaReq(SNodeMsg *pReq) { if (mndBuildInsTableSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) { goto RETRIEVE_META_OVER; } + } else if (0 == strcmp(infoReq.dbFName, TSDB_PERFORMANCE_SCHEMA_DB)) { + mDebug("performance_schema table:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName); + if (mndBuildPerfsTableSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) { + goto RETRIEVE_META_OVER; + } } else { mDebug("stb:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName); if (mndBuildStbSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) { diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 537ddc03c3..59fe7d16b9 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -58,7 +58,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans); static int32_t mndProcessTransReq(SNodeMsg *pReq); static int32_t mndProcessKillTransReq(SNodeMsg *pReq); -static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows); +static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextTrans(SMnode *pMnode, void *pIter); int32_t mndInitTrans(SMnode *pMnode) { @@ -73,7 +73,7 @@ int32_t mndInitTrans(SMnode *pMnode) { mndSetMsgHandle(pMnode, TDMT_MND_TRANS_TIMER, mndProcessTransReq); mndSetMsgHandle(pMnode, TDMT_MND_KILL_TRANS, mndProcessKillTransReq); -// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndRetrieveTrans); + mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndRetrieveTrans); mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndCancelGetNextTrans); return sdbSetTable(pMnode->pSdb, table); } @@ -1259,7 +1259,7 @@ void mndTransPullup(SMnode *pMnode) { sdbWriteFile(pMnode->pSdb); } -static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) { +static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { SMnode *pMnode = pReq->pNode; SSdb *pSdb = pMnode->pSdb; int32_t numOfRows = 0; @@ -1273,34 +1273,34 @@ static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, char *data, int cols = 0; - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int32_t *)pWrite = pTrans->id; - cols++; + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->id, false); - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int64_t *)pWrite = pTrans->createdTime; - cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->createdTime, false); - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - STR_TO_VARSTR(pWrite, mndTransStr(pTrans->stage)); - cols++; + char stage[TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(stage, mndTransStr(pTrans->stage), pShow->bytes[cols]); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)stage, false); - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - char *name = mnGetDbStr(pTrans->dbname); - STR_WITH_MAXSIZE_TO_VARSTR(pWrite, name, pShow->bytes[cols]); - cols++; + char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndGetDbStr(pTrans->dbname), pShow->bytes[cols]); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)dbname, false); - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - STR_TO_VARSTR(pWrite, mndTransType(pTrans->transType)); - cols++; + char transType[TSDB_TRANS_TYPE_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndTransType(pTrans->transType), pShow->bytes[cols]); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)transType, false); - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int64_t *)pWrite = pTrans->lastExecTime; - cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false); - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - STR_TO_VARSTR(pWrite, pTrans->lastError); - cols++; + char lastError[TSDB_TRANS_ERROR_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(dbname, pTrans->lastError, pShow->bytes[cols]); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)lastError, false); numOfRows++; sdbRelease(pSdb, pTrans); diff --git a/source/dnode/mnode/impl/src/mnode.c b/source/dnode/mnode/impl/src/mnode.c index f765b0ce11..3ac1c522b2 100644 --- a/source/dnode/mnode/impl/src/mnode.c +++ b/source/dnode/mnode/impl/src/mnode.c @@ -23,6 +23,7 @@ #include "mndDnode.h" #include "mndFunc.h" #include "mndInfoSchema.h" +#include "mndPerfSchema.h" #include "mndMnode.h" #include "mndOffset.h" #include "mndProfile.h" @@ -210,6 +211,7 @@ static int32_t mndInitSteps(SMnode *pMnode, bool deploy) { if (mndAllocStep(pMnode, "mnode-stb", mndInitStb, mndCleanupStb) != 0) return -1; if (mndAllocStep(pMnode, "mnode-stb", mndInitSma, mndCleanupSma) != 0) return -1; if (mndAllocStep(pMnode, "mnode-infos", mndInitInfos, mndCleanupInfos) != 0) return -1; + if (mndAllocStep(pMnode, "mnode-perfs", mndInitPerfs, mndCleanupPerfs) != 0) return -1; if (mndAllocStep(pMnode, "mnode-db", mndInitDb, mndCleanupDb) != 0) return -1; if (mndAllocStep(pMnode, "mnode-func", mndInitFunc, mndCleanupFunc) != 0) return -1; if (deploy) { diff --git a/source/dnode/mnode/impl/test/CMakeLists.txt b/source/dnode/mnode/impl/test/CMakeLists.txt index 9b669b303a..15f2aed22a 100644 --- a/source/dnode/mnode/impl/test/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/CMakeLists.txt @@ -1,17 +1,17 @@ enable_testing() -#add_subdirectory(user) add_subdirectory(acct) -#add_subdirectory(trans) -#add_subdirectory(qnode) -#add_subdirectory(snode) add_subdirectory(bnode) -#add_subdirectory(show) -#add_subdirectory(profile) -#add_subdirectory(dnode) -#add_subdirectory(mnode) -#add_subdirectory(db) -#add_subdirectory(stb) -#add_subdirectory(sma) -#add_subdirectory(func) -#add_subdirectory(topic) +add_subdirectory(db) +add_subdirectory(dnode) +add_subdirectory(func) +add_subdirectory(mnode) +add_subdirectory(profile) +add_subdirectory(qnode) +add_subdirectory(show) +add_subdirectory(sma) +add_subdirectory(snode) +add_subdirectory(stb) +add_subdirectory(topic) +add_subdirectory(trans) +add_subdirectory(user) diff --git a/source/dnode/mnode/impl/test/db/CMakeLists.txt b/source/dnode/mnode/impl/test/db/CMakeLists.txt index 1a5b4d3936..3f6a80835f 100644 --- a/source/dnode/mnode/impl/test/db/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/db/CMakeLists.txt @@ -5,7 +5,7 @@ target_link_libraries( PUBLIC sut ) -#add_test( -# NAME mnode_test_db -# COMMAND mnode_test_db -#) +add_test( + NAME dbTest + COMMAND dbTest +) diff --git a/source/dnode/mnode/impl/test/db/db.cpp b/source/dnode/mnode/impl/test/db/db.cpp index 0282663b17..adba6ca434 100644 --- a/source/dnode/mnode/impl/test/db/db.cpp +++ b/source/dnode/mnode/impl/test/db/db.cpp @@ -26,29 +26,8 @@ class MndTestDb : public ::testing::Test { Testbase MndTestDb::test; TEST_F(MndTestDb, 01_ShowDb) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - CHECK_META("show databases", 17); - CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN - 1 + VARSTR_HEADER_SIZE, "name"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "vgroups"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_INT, 4, "ntables"); - CHECK_SCHEMA(4, TSDB_DATA_TYPE_SMALLINT, 2, "replica"); - CHECK_SCHEMA(5, TSDB_DATA_TYPE_SMALLINT, 2, "quorum"); - CHECK_SCHEMA(6, TSDB_DATA_TYPE_SMALLINT, 2, "days"); - CHECK_SCHEMA(7, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "keep0,keep1,keep2"); - CHECK_SCHEMA(8, TSDB_DATA_TYPE_INT, 4, "cache"); - CHECK_SCHEMA(9, TSDB_DATA_TYPE_INT, 4, "blocks"); - CHECK_SCHEMA(10, TSDB_DATA_TYPE_INT, 4, "minrows"); - CHECK_SCHEMA(11, TSDB_DATA_TYPE_INT, 4, "maxrows"); - CHECK_SCHEMA(12, TSDB_DATA_TYPE_TINYINT, 1, "wallevel"); - CHECK_SCHEMA(13, TSDB_DATA_TYPE_INT, 4, "fsync"); - CHECK_SCHEMA(14, TSDB_DATA_TYPE_TINYINT, 1, "comp"); - CHECK_SCHEMA(15, TSDB_DATA_TYPE_TINYINT, 1, "cachelast"); - CHECK_SCHEMA(16, TSDB_DATA_TYPE_BINARY, 3 + VARSTR_HEADER_SIZE, "precision"); -// CHECK_SCHEMA(17, TSDB_DATA_TYPE_TINYINT, 1, "update"); - - test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 0); + test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", ""); + EXPECT_EQ(test.GetShowRows(), 2); } TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { @@ -58,7 +37,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { createReq.numOfVgroups = 2; createReq.cacheBlockSize = 16; createReq.totalBlocks = 10; - createReq.daysPerFile = 10; + createReq.daysPerFile = 1000; createReq.daysToKeep0 = 3650; createReq.daysToKeep1 = 3650; createReq.daysToKeep2 = 3650; @@ -66,6 +45,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { createReq.maxRows = 4096; createReq.commitTime = 3600; createReq.fsyncPeriod = 3000; + createReq.ttl = 0; createReq.walLevel = 1; createReq.precision = 0; createReq.compression = 2; @@ -74,6 +54,9 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { createReq.update = 0; createReq.cacheLastRow = 0; createReq.ignoreExist = 1; + createReq.streamMode = 0; + createReq.singleSTable = 0; + createReq.numOfRetensions = 0; int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); @@ -84,47 +67,11 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - CHECK_META("show databases", 17); + test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", ""); + EXPECT_EQ(test.GetShowRows(), 3); - test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("d1", TSDB_DB_NAME_LEN - 1); - CheckTimestamp(); - CheckInt16(2); // vgroups - CheckInt32(0); // ntables - CheckInt16(1); // replica - CheckInt16(1); // quorum - CheckInt16(10); // days - CheckBinary("3650,3650,3650", 24); // days - CheckInt32(16); // cache - CheckInt32(10); // blocks - CheckInt32(100); // minrows - CheckInt32(4096); // maxrows - CheckInt8(1); // wallevel - CheckInt32(3000); // fsync - CheckInt8(2); // comp - CheckInt8(0); // cachelast - CheckBinary("ms", 3); // precision - CheckInt8(0); // update - - test.SendShowMetaReq(TSDB_MGMT_TABLE_VGROUP, "1.d1"); - CHECK_META("show vgroups", 4); - CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "vgId"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_INT, 4, "tables"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "v1_dnode"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, 9 + VARSTR_HEADER_SIZE, "v1_status"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_VGROUP, "vgroups", "1.d1"); EXPECT_EQ(test.GetShowRows(), 2); - CheckInt32(2); - CheckInt32(3); - IgnoreInt32(); - IgnoreInt32(); - CheckInt16(1); - CheckInt16(1); - CheckBinary("master", 9); - CheckBinary("master", 9); { SAlterDbReq alterdbReq = {0}; @@ -147,55 +94,14 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("d1", TSDB_DB_NAME_LEN - 1); - CheckTimestamp(); - CheckInt16(2); // vgroups - CheckInt32(0); // tables - CheckInt16(1); // replica - CheckInt16(2); // quorum - CheckInt16(10); // days - CheckBinary("300,400,500", 24); // days - CheckInt32(16); // cache - CheckInt32(12); // blocks - CheckInt32(100); // minrows - CheckInt32(4096); // maxrows - CheckInt8(2); // wallevel - CheckInt32(4000); // fsync - CheckInt8(2); // comp - CheckInt8(1); // cachelast - CheckBinary("ms", 3); // precision - CheckInt8(0); // update + test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", ""); + EXPECT_EQ(test.GetShowRows(), 3); // restart test.Restart(); - test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - CHECK_META("show databases", 17); - - test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 1); - - CheckBinary("d1", TSDB_DB_NAME_LEN - 1); - CheckTimestamp(); - CheckInt16(2); // vgroups - CheckInt32(0); // tables - CheckInt16(1); // replica - CheckInt16(2); // quorum - CheckInt16(10); // days - CheckBinary("300,400,500", 24); // days - CheckInt32(16); // cache - CheckInt32(12); // blocks - CheckInt32(100); // minrows - CheckInt32(4096); // maxrows - CheckInt8(2); // wallevel - CheckInt32(4000); // fsync - CheckInt8(2); // comp - CheckInt8(1); // cachelast - CheckBinary("ms", 3); // precision - CheckInt8(0); // update + test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", ""); + EXPECT_EQ(test.GetShowRows(), 3); { SDropDbReq dropdbReq = {0}; @@ -214,11 +120,8 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { EXPECT_STREQ(dropdbRsp.db, "1.d1"); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - CHECK_META("show databases", 17); - - test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 0); + test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", ""); + EXPECT_EQ(test.GetShowRows(), 2); } TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) { @@ -228,7 +131,7 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) { createReq.numOfVgroups = 2; createReq.cacheBlockSize = 16; createReq.totalBlocks = 10; - createReq.daysPerFile = 10; + createReq.daysPerFile = 1000; createReq.daysToKeep0 = 3650; createReq.daysToKeep1 = 3650; createReq.daysToKeep2 = 3650; @@ -236,6 +139,7 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) { createReq.maxRows = 4096; createReq.commitTime = 3600; createReq.fsyncPeriod = 3000; + createReq.ttl = 0; createReq.walLevel = 1; createReq.precision = 0; createReq.compression = 2; @@ -244,6 +148,9 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) { createReq.update = 0; createReq.cacheLastRow = 0; createReq.ignoreExist = 1; + createReq.streamMode = 0; + createReq.singleSTable = 0; + createReq.numOfRetensions = 0; int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); @@ -254,12 +161,8 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - CHECK_META("show databases", 17); - - test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("d2", TSDB_DB_NAME_LEN - 1); + test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", ""); + EXPECT_EQ(test.GetShowRows(), 3); uint64_t d2_uid = 0; diff --git a/source/dnode/mnode/impl/test/dnode/CMakeLists.txt b/source/dnode/mnode/impl/test/dnode/CMakeLists.txt index 16e08d6c35..d064df90bc 100644 --- a/source/dnode/mnode/impl/test/dnode/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/dnode/CMakeLists.txt @@ -5,7 +5,7 @@ target_link_libraries( PUBLIC sut ) -#add_test( -# NAME mnode_test_dnode -# COMMAND mnode_test_dnode -#) +add_test( + NAME mdnodeTest + COMMAND mdnodeTest +) diff --git a/source/dnode/mnode/impl/test/dnode/mdnode.cpp b/source/dnode/mnode/impl/test/dnode/mdnode.cpp index f575556345..a4cbc201a9 100644 --- a/source/dnode/mnode/impl/test/dnode/mdnode.cpp +++ b/source/dnode/mnode/impl/test/dnode/mdnode.cpp @@ -51,27 +51,8 @@ TestServer MndTestDnode::server4; TestServer MndTestDnode::server5; TEST_F(MndTestDnode, 01_ShowDnode) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - CHECK_META("show dnodes", 7); - - CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "vnodes"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_SMALLINT, 2, "support_vnodes"); - CHECK_SCHEMA(4, TSDB_DATA_TYPE_BINARY, 10 + VARSTR_HEADER_SIZE, "status"); - CHECK_SCHEMA(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - CHECK_SCHEMA(6, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "offline_reason"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckInt16(1); - CheckBinary("localhost:9023", TSDB_EP_LEN); - CheckInt16(0); - CheckInt16(16); - CheckBinary("ready", 10); - CheckTimestamp(); - CheckBinary("", 24); } TEST_F(MndTestDnode, 02_ConfigDnode) { @@ -162,25 +143,8 @@ TEST_F(MndTestDnode, 03_Create_Dnode) { taosMsleep(1300); - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - CHECK_META("show dnodes", 7); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckInt16(1); - CheckInt16(2); - CheckBinary("localhost:9023", TSDB_EP_LEN); - CheckBinary("localhost:9024", TSDB_EP_LEN); - CheckInt16(0); - CheckInt16(0); - CheckInt16(16); - CheckInt16(16); - CheckBinary("ready", 10); - CheckBinary("ready", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("", 24); - CheckBinary("", 24); } TEST_F(MndTestDnode, 04_Drop_Dnode) { @@ -236,19 +200,9 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) { ASSERT_EQ(pRsp->code, TSDB_CODE_MND_DNODE_NOT_EXIST); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - CHECK_META("show dnodes", 7); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); - CheckInt16(1); - CheckBinary("localhost:9023", TSDB_EP_LEN); - CheckInt16(0); - CheckInt16(16); - CheckBinary("ready", 10); - CheckTimestamp(); - CheckBinary("", 24); - taosMsleep(2000); server2.Stop(); server2.DoStart(); @@ -298,40 +252,9 @@ TEST_F(MndTestDnode, 05_Create_Drop_Restart_Dnode) { } taosMsleep(1300); - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - CHECK_META("show dnodes", 7); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 4); - CheckInt16(1); - CheckInt16(3); - CheckInt16(4); - CheckInt16(5); - CheckBinary("localhost:9023", TSDB_EP_LEN); - CheckBinary("localhost:9025", TSDB_EP_LEN); - CheckBinary("localhost:9026", TSDB_EP_LEN); - CheckBinary("localhost:9027", TSDB_EP_LEN); - CheckInt16(0); - CheckInt16(0); - CheckInt16(0); - CheckInt16(0); - CheckInt16(16); - CheckInt16(16); - CheckInt16(16); - CheckInt16(16); - CheckBinary("ready", 10); - CheckBinary("ready", 10); - CheckBinary("ready", 10); - CheckBinary("ready", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("", 24); - CheckBinary("", 24); - CheckBinary("", 24); - CheckBinary("", 24); - // restart uInfo("stop all server"); test.Restart(); @@ -341,37 +264,6 @@ TEST_F(MndTestDnode, 05_Create_Drop_Restart_Dnode) { server5.Restart(); taosMsleep(1300); - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - CHECK_META("show dnodes", 7); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 4); - - CheckInt16(1); - CheckInt16(3); - CheckInt16(4); - CheckInt16(5); - CheckBinary("localhost:9023", TSDB_EP_LEN); - CheckBinary("localhost:9025", TSDB_EP_LEN); - CheckBinary("localhost:9026", TSDB_EP_LEN); - CheckBinary("localhost:9027", TSDB_EP_LEN); - CheckInt16(0); - CheckInt16(0); - CheckInt16(0); - CheckInt16(0); - CheckInt16(16); - CheckInt16(16); - CheckInt16(16); - CheckInt16(16); - CheckBinary("ready", 10); - CheckBinary("ready", 10); - CheckBinary("ready", 10); - CheckBinary("ready", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("", 24); - CheckBinary("", 24); - CheckBinary("", 24); - CheckBinary("", 24); } diff --git a/source/dnode/mnode/impl/test/func/CMakeLists.txt b/source/dnode/mnode/impl/test/func/CMakeLists.txt index 26b0a60968..ecb4f851be 100644 --- a/source/dnode/mnode/impl/test/func/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/func/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. FUNC_SRC) -add_executable(mnode_test_func ${FUNC_SRC}) +aux_source_directory(. MNODE_FUNC_TEST_SRC) +add_executable(funcTest ${MNODE_FUNC_TEST_SRC}) target_link_libraries( - mnode_test_func + funcTest PUBLIC sut ) add_test( - NAME mnode_test_func - COMMAND mnode_test_func + NAME funcTest + COMMAND funcTest ) diff --git a/source/dnode/mnode/impl/test/func/func.cpp b/source/dnode/mnode/impl/test/func/func.cpp index f34f77de0c..6b9c410738 100644 --- a/source/dnode/mnode/impl/test/func/func.cpp +++ b/source/dnode/mnode/impl/test/func/func.cpp @@ -26,18 +26,7 @@ class MndTestFunc : public ::testing::Test { Testbase MndTestFunc::test; TEST_F(MndTestFunc, 01_Show_Func) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, ""); - CHECK_META("show functions", 7); - - CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN + VARSTR_HEADER_SIZE, "name"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, PATH_MAX + VARSTR_HEADER_SIZE, "comment"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_INT, 4, "aggregate"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, TSDB_TYPE_STR_MAX_LEN + VARSTR_HEADER_SIZE, "outputtype"); - CHECK_SCHEMA(4, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - CHECK_SCHEMA(5, TSDB_DATA_TYPE_INT, 4, "code_len"); - CHECK_SCHEMA(6, TSDB_DATA_TYPE_INT, 4, "bufsize"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "user_functions", ""); EXPECT_EQ(test.GetShowRows(), 0); } @@ -194,19 +183,8 @@ TEST_F(MndTestFunc, 02_Create_Func) { } } - test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, ""); - CHECK_META("show functions", 7); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "user_functions", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckBinary("f1", TSDB_FUNC_NAME_LEN); - CheckBinaryByte('m', TSDB_FUNC_COMMENT_LEN); - CheckInt32(0); - CheckBinary("SMALLINT", TSDB_TYPE_STR_MAX_LEN); - CheckTimestamp(); - CheckInt32(TSDB_FUNC_CODE_LEN); - CheckInt32(4); } TEST_F(MndTestFunc, 03_Retrieve_Func) { @@ -331,10 +309,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, ""); - CHECK_META("show functions", 7); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "user_functions", ""); EXPECT_EQ(test.GetShowRows(), 2); } @@ -529,20 +504,12 @@ TEST_F(MndTestFunc, 04_Drop_Func) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, ""); - CHECK_META("show functions", 7); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "user_functions", ""); EXPECT_EQ(test.GetShowRows(), 1); // restart test.Restart(); - test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, ""); - CHECK_META("show functions", 7); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "user_functions", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckBinary("f2", TSDB_FUNC_NAME_LEN); } diff --git a/source/dnode/mnode/impl/test/mnode/CMakeLists.txt b/source/dnode/mnode/impl/test/mnode/CMakeLists.txt index 4d9b473291..94c25281b2 100644 --- a/source/dnode/mnode/impl/test/mnode/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/mnode/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. MTEST_SRC) -add_executable(mnode_test_mnode ${MTEST_SRC}) +aux_source_directory(. MNODE_MNODE_TEST_SRC) +add_executable(mmnodeTest ${MNODE_MNODE_TEST_SRC}) target_link_libraries( - mnode_test_mnode + mmnodeTest PUBLIC sut ) add_test( - NAME mnode_test_mnode - COMMAND mnode_test_mnode + NAME mmnodeTest + COMMAND mmnodeTest ) diff --git a/source/dnode/mnode/impl/test/mnode/mnode.cpp b/source/dnode/mnode/impl/test/mnode/mnode.cpp index dd2867f7f9..444c674667 100644 --- a/source/dnode/mnode/impl/test/mnode/mnode.cpp +++ b/source/dnode/mnode/impl/test/mnode/mnode.cpp @@ -39,23 +39,8 @@ Testbase MndTestMnode::test; TestServer MndTestMnode::server2; TEST_F(MndTestMnode, 01_ShowDnode) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_MNODE, ""); - CHECK_META("show mnodes", 5); - - CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_BINARY, 12 + VARSTR_HEADER_SIZE, "role"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - CHECK_SCHEMA(4, TSDB_DATA_TYPE_TIMESTAMP, 8, "role_time"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_MNODE, "mnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckInt16(1); - CheckBinary("localhost:9028", TSDB_EP_LEN); - CheckBinary("master", 12); - CheckTimestamp(); - IgnoreTimestamp(); } TEST_F(MndTestMnode, 02_Create_Mnode_Invalid_Id) { @@ -104,8 +89,7 @@ TEST_F(MndTestMnode, 04_Create_Mnode) { ASSERT_EQ(pRsp->code, 0); taosMsleep(1300); - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); } @@ -122,20 +106,8 @@ TEST_F(MndTestMnode, 04_Create_Mnode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_MNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_MNODE, "mnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckInt16(1); - CheckInt16(2); - CheckBinary("localhost:9028", TSDB_EP_LEN); - CheckBinary("localhost:9029", TSDB_EP_LEN); - CheckBinary("master", 12); - CheckBinary("slave", 12); - CheckTimestamp(); - CheckTimestamp(); - IgnoreTimestamp(); - IgnoreTimestamp(); } { @@ -151,15 +123,8 @@ TEST_F(MndTestMnode, 04_Create_Mnode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_MNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_MNODE, "mnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckInt16(1); - CheckBinary("localhost:9028", TSDB_EP_LEN); - CheckBinary("master", 12); - CheckTimestamp(); - IgnoreTimestamp(); } { diff --git a/source/dnode/mnode/impl/test/profile/CMakeLists.txt b/source/dnode/mnode/impl/test/profile/CMakeLists.txt index 88d7366b7d..8b811ebfed 100644 --- a/source/dnode/mnode/impl/test/profile/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/profile/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. PROFILE_SRC) -add_executable(mnode_test_profile ${PROFILE_SRC}) +aux_source_directory(. MNODE_PROFILE_TEST_SRC) +add_executable(profileTest ${MNODE_PROFILE_TEST_SRC}) target_link_libraries( - mnode_test_profile + profileTest PUBLIC sut ) add_test( - NAME mnode_test_profile - COMMAND mnode_test_profile + NAME profileTest + COMMAND profileTest ) diff --git a/source/dnode/mnode/impl/test/profile/profile.cpp b/source/dnode/mnode/impl/test/profile/profile.cpp index 14b31e5282..2c3be2135b 100644 --- a/source/dnode/mnode/impl/test/profile/profile.cpp +++ b/source/dnode/mnode/impl/test/profile/profile.cpp @@ -46,7 +46,7 @@ TEST_F(MndTestProfile, 01_ConnectMsg) { EXPECT_EQ(connectRsp.acctId, 1); EXPECT_GT(connectRsp.clusterId, 0); - EXPECT_EQ(connectRsp.connId, 1); + EXPECT_NE(connectRsp.connId, 0); EXPECT_EQ(connectRsp.superUser, 1); EXPECT_EQ(connectRsp.epSet.inUse, 0); @@ -74,32 +74,16 @@ TEST_F(MndTestProfile, 02_ConnectMsg_InvalidDB) { } TEST_F(MndTestProfile, 03_ConnectMsg_Show) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_CONNS, ""); - CHECK_META("show connections", 7); - CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "connId"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "user"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_BINARY, TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, "program"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_INT, 4, "pid"); - CHECK_SCHEMA(4, TSDB_DATA_TYPE_BINARY, TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, "ip:port"); - CHECK_SCHEMA(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "login_time"); - CHECK_SCHEMA(6, TSDB_DATA_TYPE_TIMESTAMP, 8, "last_access"); - - test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 1); - CheckInt32(1); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("mnode_test_profile", TSDB_APP_NAME_LEN); - CheckInt32(1234); - IgnoreBinary(TSDB_IPv4ADDR_LEN + 6); - CheckTimestamp(); - CheckTimestamp(); + test.SendShowReq(TSDB_MGMT_TABLE_CONNS, "connections", ""); + EXPECT_EQ(test.GetShowRows(), 0); } TEST_F(MndTestProfile, 04_HeartBeatMsg) { SClientHbBatchReq batchReq = {0}; batchReq.reqs = taosArrayInit(0, sizeof(SClientHbReq)); SClientHbReq req = {0}; - req.connKey = {.connId = 123, .hbType = HEARTBEAT_TYPE_MQ}; + req.connKey.tscRid = 123; + req.connKey.connType = CONN_TYPE__TMQ; req.info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK); SKv kv = {0}; kv.key = 123; @@ -311,24 +295,6 @@ TEST_F(MndTestProfile, 08_KillQueryMsg_InvalidConn) { } TEST_F(MndTestProfile, 09_KillQueryMsg) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_QUERIES, ""); - CHECK_META("show queries", 14); - - CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "queryId"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_INT, 4, "connId"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "user"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, "ip:port"); - CHECK_SCHEMA(4, TSDB_DATA_TYPE_BINARY, 22 + VARSTR_HEADER_SIZE, "qid"); - CHECK_SCHEMA(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "created_time"); - CHECK_SCHEMA(6, TSDB_DATA_TYPE_BIGINT, 8, "time"); - CHECK_SCHEMA(7, TSDB_DATA_TYPE_BINARY, 18 + VARSTR_HEADER_SIZE, "sql_obj_id"); - CHECK_SCHEMA(8, TSDB_DATA_TYPE_INT, 4, "pid"); - CHECK_SCHEMA(9, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "ep"); - CHECK_SCHEMA(10, TSDB_DATA_TYPE_BOOL, 1, "stable_query"); - CHECK_SCHEMA(11, TSDB_DATA_TYPE_INT, 4, "sub_queries"); - CHECK_SCHEMA(12, TSDB_DATA_TYPE_BINARY, TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE, "sub_query_info"); - CHECK_SCHEMA(13, TSDB_DATA_TYPE_BINARY, TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, "sql"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_QUERIES, "queries", ""); EXPECT_EQ(test.GetShowRows(), 0); } diff --git a/source/dnode/mnode/impl/test/qnode/CMakeLists.txt b/source/dnode/mnode/impl/test/qnode/CMakeLists.txt index 77ac39e409..8259f9f47d 100644 --- a/source/dnode/mnode/impl/test/qnode/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/qnode/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. QTEST_SRC) -add_executable(mnode_test_qnode ${QTEST_SRC}) +aux_source_directory(. MNODE_QNODE_TEST_SRC) +add_executable(mqnodeTest ${MNODE_QNODE_TEST_SRC}) target_link_libraries( - mnode_test_qnode + mqnodeTest PUBLIC sut ) add_test( - NAME mnode_test_qnode - COMMAND mnode_test_qnode + NAME mqnodeTest + COMMAND mqnodeTest ) diff --git a/source/dnode/mnode/impl/test/qnode/qnode.cpp b/source/dnode/mnode/impl/test/qnode/qnode.cpp index be214cacf2..7240e0f183 100644 --- a/source/dnode/mnode/impl/test/qnode/qnode.cpp +++ b/source/dnode/mnode/impl/test/qnode/qnode.cpp @@ -39,14 +39,7 @@ Testbase MndTestQnode::test; TestServer MndTestQnode::server2; TEST_F(MndTestQnode, 01_Show_Qnode) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); - CHECK_META("show qnodes", 3); - - CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", ""); EXPECT_EQ(test.GetShowRows(), 0); } @@ -76,14 +69,8 @@ TEST_F(MndTestQnode, 02_Create_Qnode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); - CHECK_META("show qnodes", 3); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckInt16(1); - CheckBinary("localhost:9014", TSDB_EP_LEN); - CheckTimestamp(); } { @@ -115,8 +102,7 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) { ASSERT_EQ(pRsp->code, 0); taosMsleep(1300); - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); } @@ -132,16 +118,8 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckInt16(1); - CheckInt16(2); - CheckBinary("localhost:9014", TSDB_EP_LEN); - CheckBinary("localhost:9015", TSDB_EP_LEN); - CheckTimestamp(); - CheckTimestamp(); } { @@ -156,13 +134,8 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckInt16(1); - CheckBinary("localhost:9014", TSDB_EP_LEN); - CheckTimestamp(); } { diff --git a/source/dnode/mnode/impl/test/show/CMakeLists.txt b/source/dnode/mnode/impl/test/show/CMakeLists.txt index cc0706ca50..69e93e7086 100644 --- a/source/dnode/mnode/impl/test/show/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/show/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. SHOW_SRC) -add_executable(mnode_test_show ${SHOW_SRC}) +aux_source_directory(. MNODE_SHOW_TEST_SRC) +add_executable(showTest ${MNODE_SHOW_TEST_SRC}) target_link_libraries( - mnode_test_show + showTest PUBLIC sut ) add_test( - NAME mnode_test_show - COMMAND mnode_test_show + NAME showTest + COMMAND showTest ) diff --git a/source/dnode/mnode/impl/test/show/show.cpp b/source/dnode/mnode/impl/test/show/show.cpp index a57d99a257..201a42e3ef 100644 --- a/source/dnode/mnode/impl/test/show/show.cpp +++ b/source/dnode/mnode/impl/test/show/show.cpp @@ -34,9 +34,9 @@ TEST_F(MndTestShow, 01_ShowMsg_InvalidMsgMax) { tSerializeSShowReq(pReq, contLen, &showReq); tFreeSShowReq(&showReq); - SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_SYSTABLE_RETRIEVE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_MSG_TYPE); + ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_MSG); } TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) { @@ -48,9 +48,9 @@ TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) { tSerializeSShowReq(pReq, contLen, &showReq); tFreeSShowReq(&showReq); - SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_SYSTABLE_RETRIEVE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_MSG_TYPE); + ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_MSG); } TEST_F(MndTestShow, 03_ShowMsg_Conn) { @@ -67,42 +67,11 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_CONNS, ""); - - STableMetaRsp* pMeta = test.GetShowMeta(); - EXPECT_STREQ(pMeta->tbName, "show connections"); - EXPECT_EQ(pMeta->numOfTags, 0); - EXPECT_EQ(pMeta->numOfColumns, 7); - EXPECT_EQ(pMeta->precision, 0); - EXPECT_EQ(pMeta->tableType, 0); - EXPECT_EQ(pMeta->update, 0); - EXPECT_EQ(pMeta->sversion, 0); - EXPECT_EQ(pMeta->tversion, 0); - EXPECT_EQ(pMeta->tuid, 0); - EXPECT_EQ(pMeta->suid, 0); - - test.SendShowRetrieveReq(); - - SRetrieveTableRsp* pRetrieveRsp = test.GetRetrieveRsp(); - EXPECT_EQ(pRetrieveRsp->numOfRows, 1); - EXPECT_EQ(pRetrieveRsp->useconds, 0); - EXPECT_EQ(pRetrieveRsp->completed, 1); - EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI); - EXPECT_EQ(pRetrieveRsp->compressed, 0); - EXPECT_EQ(pRetrieveRsp->compLen, 0); + test.SendShowReq(TSDB_MGMT_TABLE_CONNS, "connections", ""); + // EXPECT_EQ(test.GetShowRows(), 1); } TEST_F(MndTestShow, 04_ShowMsg_Cluster) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_CLUSTER, ""); - CHECK_META( "show cluster", 3); - CHECK_SCHEMA(0, TSDB_DATA_TYPE_BIGINT, 8, "id"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, "name"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_CLUSTER, "cluster", ""); EXPECT_EQ(test.GetShowRows(), 1); - - IgnoreInt64(); - IgnoreBinary(TSDB_CLUSTER_ID_LEN); - CheckTimestamp(); } \ No newline at end of file diff --git a/source/dnode/mnode/impl/test/sma/CMakeLists.txt b/source/dnode/mnode/impl/test/sma/CMakeLists.txt index 943695abf3..3f9ec123a8 100644 --- a/source/dnode/mnode/impl/test/sma/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/sma/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. SMA_SRC) -add_executable(mnode_test_sma ${SMA_SRC}) +aux_source_directory(. MNODE_SMA_TEST_SRC) +add_executable(smaTest ${MNODE_SMA_TEST_SRC}) target_link_libraries( - mnode_test_sma + smaTest PUBLIC sut ) add_test( - NAME mnode_test_sma - COMMAND mnode_test_sma + NAME smaTest + COMMAND smaTest ) diff --git a/source/dnode/mnode/impl/test/sma/sma.cpp b/source/dnode/mnode/impl/test/sma/sma.cpp index 4b0e33a323..4f3b0d6e37 100644 --- a/source/dnode/mnode/impl/test/sma/sma.cpp +++ b/source/dnode/mnode/impl/test/sma/sma.cpp @@ -207,7 +207,7 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) { pReq = BuildCreateStbReq(stbname, &contLen); pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables",dbname); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); } @@ -216,7 +216,7 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) { pReq = BuildCreateTSmaReq(smaname, stbname, 0, "expr", "tagsFilter", "sql", "ast", &contLen); pRsp = test.SendReq(TDMT_MND_CREATE_SMA, pReq, contLen); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname); + test.SendShowReq(TSDB_MGMT_TABLE_INDEX, dbname); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); } @@ -225,7 +225,7 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) { test.Restart(); { - test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname); + test.SendShowReq(TSDB_MGMT_TABLE_INDEX, dbname); CHECK_META("show indexes", 3); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); @@ -239,7 +239,7 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) { pReq = BuildDropTSmaReq(smaname, 0, &contLen); pRsp = test.SendReq(TDMT_MND_DROP_SMA, pReq, contLen); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname); + test.SendShowReq(TSDB_MGMT_TABLE_INDEX, dbname); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 0); } @@ -263,10 +263,8 @@ TEST_F(MndTestSma, 02_Create_Show_Meta_Drop_Restart_BSma) { pReq = BuildCreateBSmaStbReq(stbname, &contLen); pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables",dbname); EXPECT_EQ(test.GetShowRows(), 1); -// CheckBinary("bsmastb", TSDB_TABLE_NAME_LEN); } test.Restart(); @@ -281,8 +279,7 @@ TEST_F(MndTestSma, 02_Create_Show_Meta_Drop_Restart_BSma) { pReq = BuildDropStbReq(stbname, &contLen); pRsp = test.SendReq(TDMT_MND_DROP_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables",dbname); EXPECT_EQ(test.GetShowRows(), 0); } diff --git a/source/dnode/mnode/impl/test/snode/CMakeLists.txt b/source/dnode/mnode/impl/test/snode/CMakeLists.txt index 44a5f35f94..9c60da364c 100644 --- a/source/dnode/mnode/impl/test/snode/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/snode/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. STEST_SRC) -add_executable(mnode_test_snode ${STEST_SRC}) +aux_source_directory(. MNODE_SNODE_TEST_SRC) +add_executable(msnodeTest ${MNODE_SNODE_TEST_SRC}) target_link_libraries( - mnode_test_snode + msnodeTest PUBLIC sut ) add_test( - NAME mnode_test_snode - COMMAND mnode_test_snode + NAME msnodeTest + COMMAND msnodeTest ) diff --git a/source/dnode/mnode/impl/test/snode/snode.cpp b/source/dnode/mnode/impl/test/snode/snode.cpp index 7d24d89154..3742c06b0a 100644 --- a/source/dnode/mnode/impl/test/snode/snode.cpp +++ b/source/dnode/mnode/impl/test/snode/snode.cpp @@ -39,14 +39,7 @@ Testbase MndTestSnode::test; TestServer MndTestSnode::server2; TEST_F(MndTestSnode, 01_Show_Snode) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, ""); - CHECK_META("show snodes", 3); - - CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_SNODE, "snodes", ""); EXPECT_EQ(test.GetShowRows(), 0); } @@ -76,14 +69,8 @@ TEST_F(MndTestSnode, 02_Create_Snode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, ""); - CHECK_META("show snodes", 3); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_SNODE, "snodes", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckInt16(1); - CheckBinary("localhost:9016", TSDB_EP_LEN); - CheckTimestamp(); } { @@ -115,8 +102,7 @@ TEST_F(MndTestSnode, 03_Drop_Snode) { ASSERT_EQ(pRsp->code, 0); taosMsleep(1300); - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); } @@ -132,16 +118,8 @@ TEST_F(MndTestSnode, 03_Drop_Snode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_SNODE, "snodes", ""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckInt16(1); - CheckInt16(2); - CheckBinary("localhost:9016", TSDB_EP_LEN); - CheckBinary("localhost:9017", TSDB_EP_LEN); - CheckTimestamp(); - CheckTimestamp(); } { @@ -156,13 +134,8 @@ TEST_F(MndTestSnode, 03_Drop_Snode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_SNODE, "snodes", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckInt16(1); - CheckBinary("localhost:9016", TSDB_EP_LEN); - CheckTimestamp(); } { diff --git a/source/dnode/mnode/impl/test/stb/CMakeLists.txt b/source/dnode/mnode/impl/test/stb/CMakeLists.txt index 70e20d3411..d2fe387997 100644 --- a/source/dnode/mnode/impl/test/stb/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/stb/CMakeLists.txt @@ -5,7 +5,7 @@ target_link_libraries( PUBLIC sut ) -#add_test( -# NAME mnode_test_stb -# COMMAND mnode_test_stb -#) +add_test( + NAME stbTest + COMMAND stbTest +) diff --git a/source/dnode/mnode/impl/test/stb/stb.cpp b/source/dnode/mnode/impl/test/stb/stb.cpp index f45c0795cd..f8f8799c9f 100644 --- a/source/dnode/mnode/impl/test/stb/stb.cpp +++ b/source/dnode/mnode/impl/test/stb/stb.cpp @@ -43,7 +43,7 @@ void* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { createReq.numOfVgroups = 2; createReq.cacheBlockSize = 16; createReq.totalBlocks = 10; - createReq.daysPerFile = 10; + createReq.daysPerFile = 1000; createReq.daysToKeep0 = 3650; createReq.daysToKeep1 = 3650; createReq.daysToKeep2 = 3650; @@ -314,19 +314,8 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { } { - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - CHECK_META("show stables", 4); - CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, "name"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_INT, 4, "columns"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_INT, 4, "tags"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(2); - CheckInt32(3); } // ----- meta ------ @@ -407,15 +396,8 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { test.Restart(); { - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - CHECK_META("show stables", 4); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); - - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(2); - CheckInt32(3); } { @@ -432,9 +414,7 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { } { - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - CHECK_META("show stables", 4); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 0); } @@ -496,13 +476,7 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(2); - CheckInt32(4); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); } { @@ -542,13 +516,8 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(2); - CheckInt32(2); } { @@ -611,13 +580,8 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(2); - CheckInt32(3); } { @@ -668,13 +632,8 @@ TEST_F(MndTestStb, 05_Alter_Stb_AlterTagBytes) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(2); - CheckInt32(3); } { @@ -734,13 +693,8 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(3); - CheckInt32(3); } { @@ -799,13 +753,8 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(2); - CheckInt32(3); } { @@ -862,13 +811,8 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(2); - CheckInt32(3); } { diff --git a/source/dnode/mnode/impl/test/topic/CMakeLists.txt b/source/dnode/mnode/impl/test/topic/CMakeLists.txt index 63a77713d6..076228ec9d 100644 --- a/source/dnode/mnode/impl/test/topic/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/topic/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. TOPIC_SRC) -add_executable(mnode_test_topic ${TOPIC_SRC}) +aux_source_directory(. MNODE_TOPIC_TEST_SRC) +add_executable(topicTest ${MNODE_TOPIC_TEST_SRC}) target_link_libraries( - mnode_test_topic + topicTest PUBLIC sut ) add_test( - NAME mnode_test_topic - COMMAND mnode_test_topic + NAME topicTest + COMMAND topicTest ) diff --git a/source/dnode/mnode/impl/test/topic/topic.cpp b/source/dnode/mnode/impl/test/topic/topic.cpp index 2111d61e3f..ee47a3c8b4 100644 --- a/source/dnode/mnode/impl/test/topic/topic.cpp +++ b/source/dnode/mnode/impl/test/topic/topic.cpp @@ -101,7 +101,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) { ASSERT_EQ(pRsp->code, 0); } - { test.SendShowMetaReq(TSDB_MGMT_TABLE_TOPICS, ""); } + { test.SendShowReq(TSDB_MGMT_TABLE_TOPICS, ""); } { int32_t contLen = 0; @@ -128,7 +128,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) { } { - test.SendShowMetaReq(TSDB_MGMT_TABLE_TOPICS, dbname); + test.SendShowReq(TSDB_MGMT_TABLE_TOPICS, dbname); CHECK_META("show topics", 3); CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, "name"); @@ -145,7 +145,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) { // restart test.Restart(); - test.SendShowMetaReq(TSDB_MGMT_TABLE_TOPICS, dbname); + test.SendShowReq(TSDB_MGMT_TABLE_TOPICS, dbname); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); @@ -169,7 +169,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TOPIC_NOT_EXIST); - test.SendShowMetaReq(TSDB_MGMT_TABLE_TOPICS, dbname); + test.SendShowReq(TSDB_MGMT_TABLE_TOPICS, dbname); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 0); } diff --git a/source/dnode/mnode/impl/test/trans/CMakeLists.txt b/source/dnode/mnode/impl/test/trans/CMakeLists.txt index d7c9756794..fa0ef9f263 100644 --- a/source/dnode/mnode/impl/test/trans/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/trans/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. TRANS_SRC) -add_executable(mnode_test_trans ${TRANS_SRC}) +aux_source_directory(. MNODE_TRANS_TEST_SRC) +add_executable(transTest ${MNODE_TRANS_TEST_SRC}) target_link_libraries( - mnode_test_trans + transTest PUBLIC sut ) add_test( - NAME mnode_test_trans - COMMAND mnode_test_trans + NAME transTest + COMMAND transTest ) diff --git a/source/dnode/mnode/impl/test/trans/trans.cpp b/source/dnode/mnode/impl/test/trans/trans.cpp index 560b30d13c..bcf6fe8536 100644 --- a/source/dnode/mnode/impl/test/trans/trans.cpp +++ b/source/dnode/mnode/impl/test/trans/trans.cpp @@ -26,11 +26,11 @@ class MndTestTrans : public ::testing::Test { } static void KillThenRestartServer() { - char file[PATH_MAX] = "/tmp/mnode_test_trans/mnode/data/sdb.data"; + char file[PATH_MAX] = "/tmp/mnode_test_trans/mnode/data/sdb.data"; TdFilePtr pFile = taosOpenFile(file, TD_FILE_READ); - int32_t size = 3 * 1024 * 1024; - void* buffer = taosMemoryMalloc(size); - int32_t readLen = taosReadFile(pFile, buffer, size); + int32_t size = 3 * 1024 * 1024; + void* buffer = taosMemoryMalloc(size); + int32_t readLen = taosReadFile(pFile, buffer, size); if (readLen < 0 || readLen == size) { ASSERT(1); } @@ -65,18 +65,7 @@ TestServer MndTestTrans::server2; TEST_F(MndTestTrans, 00_Create_User_Crash) { { - test.SendShowMetaReq(TSDB_MGMT_TABLE_TRANS, ""); - CHECK_META("show trans", 7); - - CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "id"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_BINARY, TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE, "stage"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN - 1 + VARSTR_HEADER_SIZE, "db"); - CHECK_SCHEMA(4, TSDB_DATA_TYPE_BINARY, TSDB_TRANS_TYPE_LEN + VARSTR_HEADER_SIZE, "type"); - CHECK_SCHEMA(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "last_exec_time"); - CHECK_SCHEMA(6, TSDB_DATA_TYPE_BINARY, TSDB_TRANS_ERROR_LEN - 1 + VARSTR_HEADER_SIZE, "last_error"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_TRANS, "trans", ""); EXPECT_EQ(test.GetShowRows(), 0); } @@ -109,26 +98,13 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - CHECK_META("show users", 4); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 2); KillThenRestartServer(); - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - CHECK_META("show users", 4); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckBinary("u1", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("normal", 10); - CheckBinary("super", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); } TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) { @@ -144,9 +120,7 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); - CHECK_META("show qnodes", 3); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); } @@ -163,9 +137,7 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_QNODE_ALREADY_EXIST); - test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); - CHECK_META("show qnodes", 3); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); } } @@ -185,8 +157,7 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) { ASSERT_EQ(pRsp->code, 0); taosMsleep(1300); - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); } @@ -208,18 +179,8 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) { { // show trans - test.SendShowMetaReq(TSDB_MGMT_TABLE_TRANS, ""); - CHECK_META("show trans", 7); - test.SendShowRetrieveReq(); - + test.SendShowReq(TSDB_MGMT_TABLE_TRANS, "trans", ""); EXPECT_EQ(test.GetShowRows(), 1); - CheckInt32(4); - CheckTimestamp(); - CheckBinary("undoAction", TSDB_TRANS_STAGE_LEN); - CheckBinary("", TSDB_DB_NAME_LEN - 1); - CheckBinary("create-qnode", TSDB_TRANS_TYPE_LEN); - CheckTimestamp(); - CheckBinary("Unable to establish connection", TSDB_TRANS_ERROR_LEN - 1); } // kill trans @@ -238,8 +199,7 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) { // show trans { - test.SendShowMetaReq(TSDB_MGMT_TABLE_TRANS, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_TRANS, "trans", ""); EXPECT_EQ(test.GetShowRows(), 0); } @@ -258,11 +218,9 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) { ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_NETWORK_UNAVAIL); } - uInfo("======== kill and restart server") - KillThenRestartServer(); + uInfo("======== kill and restart server") KillThenRestartServer(); - uInfo("======== server2 start") - server2.DoStart(); + uInfo("======== server2 start") server2.DoStart(); uInfo("======== server2 started") @@ -286,14 +244,11 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) { ASSERT_NE(retry, retryMax); - test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); - CHECK_META("show qnodes", 3); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); } } - // create db // partial create stb // drop db failed diff --git a/source/dnode/mnode/impl/test/user/CMakeLists.txt b/source/dnode/mnode/impl/test/user/CMakeLists.txt index c6aeef7221..b39ea0e73f 100644 --- a/source/dnode/mnode/impl/test/user/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/user/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. USER_SRC) -add_executable(mnode_test_user ${USER_SRC}) +aux_source_directory(. MNODE_USER_TEST_SRC) +add_executable(userTest ${MNODE_USER_TEST_SRC}) target_link_libraries( - mnode_test_user + userTest PUBLIC sut ) add_test( - NAME mnode_test_user - COMMAND mnode_test_user + NAME userTest + COMMAND userTest ) diff --git a/source/dnode/mnode/impl/test/user/user.cpp b/source/dnode/mnode/impl/test/user/user.cpp index 97a144fdee..4e7f3c0213 100644 --- a/source/dnode/mnode/impl/test/user/user.cpp +++ b/source/dnode/mnode/impl/test/user/user.cpp @@ -26,21 +26,8 @@ class MndTestUser : public ::testing::Test { Testbase MndTestUser::test; TEST_F(MndTestUser, 01_Show_User) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - CHECK_META("show users", 4); - - CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "name"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, 10 + VARSTR_HEADER_SIZE, "privilege"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "account"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("super", 10); - CheckTimestamp(); - CheckBinary("root", TSDB_USER_LEN); } TEST_F(MndTestUser, 02_Create_User) { @@ -99,18 +86,8 @@ TEST_F(MndTestUser, 02_Create_User) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckBinary("u1", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("normal", 10); - CheckBinary("super", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); } { @@ -125,8 +102,7 @@ TEST_F(MndTestUser, 02_Create_User) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 1); } @@ -144,18 +120,8 @@ TEST_F(MndTestUser, 02_Create_User) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("u2", TSDB_USER_LEN); - CheckBinary("super", 10); - CheckBinary("super", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); } { @@ -170,8 +136,7 @@ TEST_F(MndTestUser, 02_Create_User) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 1); } } @@ -191,8 +156,7 @@ TEST_F(MndTestUser, 03_Alter_User) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 2); } @@ -437,8 +401,7 @@ TEST_F(MndTestUser, 03_Alter_User) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 1); } } @@ -497,10 +460,7 @@ TEST_F(MndTestUser, 05_Drop_User) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - CHECK_META("show users", 4); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 1); } @@ -533,25 +493,9 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - CHECK_META("show users", 4); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 3); - CheckBinary("u1", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("u2", TSDB_USER_LEN); - CheckBinary("normal", 10); - CheckBinary("super", 10); - CheckBinary("normal", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - { SAlterUserReq alterReq = {0}; alterReq.alterType = TSDB_ALTER_USER_PASSWD; @@ -567,25 +511,8 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - CHECK_META("show users", 4); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 3); - - CheckBinary("u1", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("u2", TSDB_USER_LEN); - CheckBinary("normal", 10); - CheckBinary("super", 10); - CheckBinary("normal", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - { SDropUserReq dropReq = {0}; strcpy(dropReq.user, "u1"); @@ -599,37 +526,13 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - CHECK_META("show users", 4); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 2); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("u2", TSDB_USER_LEN); - CheckBinary("super", 10); - CheckBinary("normal", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - // restart test.Restart(); taosMsleep(1000); - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - CHECK_META("show users", 4); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("u2", TSDB_USER_LEN); - CheckBinary("super", 10); - CheckBinary("normal", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); } diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index 3ab007e3a2..c0e458219c 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -4,13 +4,13 @@ target_sources( vnode PRIVATE # vnode + "src/vnd/vnodeOpen.c" "src/vnd/vnodeArenaMAImpl.c" "src/vnd/vnodeBufferPool.c" # "src/vnd/vnodeBufferPool2.c" "src/vnd/vnodeCfg.c" "src/vnd/vnodeCommit.c" "src/vnd/vnodeInt.c" - "src/vnd/vnodeMain.c" "src/vnd/vnodeQuery.c" "src/vnd/vnodeStateMgr.c" "src/vnd/vnodeWrite.c" diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 76fc09ca1d..303376dba4 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -42,11 +42,12 @@ typedef struct STsdbCfg STsdbCfg; // todo: remove typedef struct STqCfg STqCfg; // todo: remove typedef struct SVnodeCfg SVnodeCfg; -int vnodeInit(); +int vnodeInit(int nthreads); void vnodeCleanup(); +int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs); +void vnodeDestroy(const char *path); SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg); void vnodeClose(SVnode *pVnode); -void vnodeDestroy(const char *path); void vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs); int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); int vnodeProcessCMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); @@ -123,12 +124,12 @@ struct STsdbCfg { int8_t precision; int8_t update; int8_t compression; - int32_t daysPerFile; - int32_t minRowsPerFileBlock; - int32_t maxRowsPerFileBlock; - int32_t keep; - int32_t keep1; + int32_t days; + int32_t minRows; + int32_t maxRows; int32_t keep2; + int32_t keep0; + int32_t keep1; uint64_t lruCacheSize; SArray *retentions; }; diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index 1cdb38b650..cb40900e81 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -30,6 +30,8 @@ extern "C" { #define vTrace(...) do { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", DEBUG_TRACE, vDebugFlag, __VA_ARGS__); }} while(0) // clang-format on +// vnodeCfg ==================== + // vnodeModule ==================== int vnodeScheduleTask(int (*execute)(void*), void* arg); @@ -38,6 +40,11 @@ int vnodeQueryOpen(SVnode* pVnode); void vnodeQueryClose(SVnode* pVnode); int vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg); +// vnodeCommit ==================== +int vnodeSaveInfo(const char* dir, const SVnodeInfo* pCfg); +int vnodeCommitInfo(const char* dir, const SVnodeInfo* pInfo); +int vnodeLoadInfo(const char* dir, SVnodeInfo* pInfo); + #if 1 // SVBufPool int vnodeOpenBufPool(SVnode* pVnode); @@ -75,9 +82,9 @@ void vmaFree(SVMemAllocator* pVMA, void* ptr); bool vmaIsFull(SVMemAllocator* pVMA); // vnodeCfg.h -extern const SVnodeCfg defaultVnodeOptions; +extern const SVnodeCfg vnodeCfgDefault; -int vnodeValidateOptions(const SVnodeCfg*); +int vnodeCheckCfg(const SVnodeCfg*); void vnodeOptionsCopy(SVnodeCfg* pDest, const SVnodeCfg* pSrc); // For commit diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index f988df01cb..e95878b04e 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -27,6 +27,7 @@ #include "tdbInt.h" #include "tfs.h" #include "tglobal.h" +#include "tjson.h" #include "tlist.h" #include "tlockfree.h" #include "tlosertree.h" @@ -43,6 +44,7 @@ extern "C" { #endif +typedef struct SVnodeInfo SVnodeInfo; typedef struct SMeta SMeta; typedef struct STsdb STsdb; typedef struct STQ STQ; @@ -72,6 +74,11 @@ struct SVState { int64_t applied; }; +struct SVnodeInfo { + SVnodeCfg config; + SVState state; +}; + struct SVnode { int32_t vgId; char* path; diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index eb32663387..a1edb7cd9c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -55,7 +55,7 @@ typedef struct { #define TSDB_COMMIT_BUF(ch) TSDB_READ_BUF(&((ch)->readh)) #define TSDB_COMMIT_COMP_BUF(ch) TSDB_READ_COMP_BUF(&((ch)->readh)) #define TSDB_COMMIT_EXBUF(ch) TSDB_READ_EXBUF(&((ch)->readh)) -#define TSDB_COMMIT_DEFAULT_ROWS(ch) TSDB_DEFAULT_BLOCK_ROWS(TSDB_COMMIT_REPO(ch)->config.maxRowsPerFileBlock) +#define TSDB_COMMIT_DEFAULT_ROWS(ch) TSDB_DEFAULT_BLOCK_ROWS(TSDB_COMMIT_REPO(ch)->config.maxRows) #define TSDB_COMMIT_TXN_VERSION(ch) FS_TXN_VERSION(REPO_FS(TSDB_COMMIT_REPO(ch))) static void tsdbStartCommit(STsdb *pRepo); @@ -217,14 +217,14 @@ void tsdbGetRtnSnap(STsdb *pRepo, SRtn *pRtn) { TSKEY minKey, midKey, maxKey, now; now = taosGetTimestamp(pCfg->precision); - minKey = now - pCfg->keep * tsTickPerDay[pCfg->precision]; - midKey = now - pCfg->keep2 * tsTickPerDay[pCfg->precision]; - maxKey = now - pCfg->keep1 * tsTickPerDay[pCfg->precision]; + minKey = now - pCfg->keep2 * tsTickPerDay[pCfg->precision]; + midKey = now - pCfg->keep1 * tsTickPerDay[pCfg->precision]; + maxKey = now - pCfg->keep0 * tsTickPerDay[pCfg->precision]; pRtn->minKey = minKey; - pRtn->minFid = (int)(TSDB_KEY_FID(minKey, pCfg->daysPerFile, pCfg->precision)); - pRtn->midFid = (int)(TSDB_KEY_FID(midKey, pCfg->daysPerFile, pCfg->precision)); - pRtn->maxFid = (int)(TSDB_KEY_FID(maxKey, pCfg->daysPerFile, pCfg->precision)); + pRtn->minFid = (int)(TSDB_KEY_FID(minKey, pCfg->days, pCfg->precision)); + pRtn->midFid = (int)(TSDB_KEY_FID(midKey, pCfg->days, pCfg->precision)); + pRtn->maxFid = (int)(TSDB_KEY_FID(maxKey, pCfg->days, pCfg->precision)); tsdbDebug("vgId:%d now:%" PRId64 " minKey:%" PRId64 " minFid:%d, midFid:%d, maxFid:%d", REPO_ID(pRepo), now, minKey, pRtn->minFid, pRtn->midFid, pRtn->maxFid); } @@ -286,7 +286,7 @@ static int tsdbInitCommitH(SCommitH *pCommith, STsdb *pRepo) { return -1; } - pCommith->pDataCols = tdNewDataCols(0, pCfg->maxRowsPerFileBlock); + pCommith->pDataCols = tdNewDataCols(0, pCfg->maxRows); if (pCommith->pDataCols == NULL) { terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; tsdbDestroyCommitH(pCommith); @@ -319,7 +319,7 @@ static int tsdbNextCommitFid(SCommitH *pCommith) { if (nextKey == TSDB_DATA_TIMESTAMP_NULL) { continue; } else { - int tfid = (int)(TSDB_KEY_FID(nextKey, pCfg->daysPerFile, pCfg->precision)); + int tfid = (int)(TSDB_KEY_FID(nextKey, pCfg->days, pCfg->precision)); if (fid == TSDB_IVLD_FID || fid > tfid) { fid = tfid; } @@ -346,7 +346,7 @@ static int tsdbCommitToFile(SCommitH *pCommith, SDFileSet *pSet, int fid) { ASSERT(pSet == NULL || pSet->fid == fid); tsdbResetCommitFile(pCommith); - tsdbGetFidKeyRange(pCfg->daysPerFile, pCfg->precision, fid, &(pCommith->minKey), &(pCommith->maxKey)); + tsdbGetFidKeyRange(pCfg->days, pCfg->precision, fid, &(pCommith->minKey), &(pCommith->maxKey)); // Set and open files if (tsdbSetAndOpenCommitFile(pCommith, pSet, fid) < 0) { @@ -1210,8 +1210,8 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF int64_t offset = 0, offsetAggr = 0; int rowsToWrite = pDataCols->numOfRows; - ASSERT(rowsToWrite > 0 && rowsToWrite <= pCfg->maxRowsPerFileBlock); - ASSERT((!isLast) || rowsToWrite < pCfg->minRowsPerFileBlock); + ASSERT(rowsToWrite > 0 && rowsToWrite <= pCfg->maxRows); + ASSERT((!isLast) || rowsToWrite < pCfg->minRows); // Make buffer space if (tsdbMakeRoom(ppBuf, tsdbBlockStatisSize(pDataCols->numOfCols, SBlockVerLatest)) < 0) { @@ -1460,7 +1460,7 @@ static int tsdbCommitMemData(SCommitH *pCommith, SCommitIter *pIter, TSKEY keyLi if (pCommith->pDataCols->numOfRows <= 0) break; - if (toData || pCommith->pDataCols->numOfRows >= pCfg->minRowsPerFileBlock) { + if (toData || pCommith->pDataCols->numOfRows >= pCfg->minRows) { pDFile = TSDB_COMMIT_DATA_FILE(pCommith); isLast = false; } else { @@ -1619,7 +1619,7 @@ static int tsdbMergeBlockData(SCommitH *pCommith, SCommitIter *pIter, SDataCols if (pCommith->pDataCols->numOfRows == 0) break; if (isLastOneBlock) { - if (pCommith->pDataCols->numOfRows < pCfg->minRowsPerFileBlock) { + if (pCommith->pDataCols->numOfRows < pCfg->minRows) { pDFile = TSDB_COMMIT_LAST_FILE(pCommith); isLast = true; } else { @@ -1667,7 +1667,8 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt if (tdGetColDataOfRow(&sVal, pDataCols->cols + i, *iter, pDataCols->bitmapMode) < 0) { TASSERT(0); } - tdAppendValToDataCol(pTarget->cols + i, sVal.valType, sVal.val, pTarget->numOfRows, pTarget->maxPoints, pTarget->bitmapMode); + tdAppendValToDataCol(pTarget->cols + i, sVal.valType, sVal.val, pTarget->numOfRows, pTarget->maxPoints, + pTarget->bitmapMode); } ++pTarget->numOfRows; @@ -1774,11 +1775,11 @@ static bool tsdbCanAddSubBlock(SCommitH *pCommith, SBlock *pBlock, SMergeInfo *p ASSERT(mergeRows > 0); - if (pBlock->numOfSubBlocks < TSDB_MAX_SUBBLOCKS && pInfo->nOperations <= pCfg->maxRowsPerFileBlock) { + if (pBlock->numOfSubBlocks < TSDB_MAX_SUBBLOCKS && pInfo->nOperations <= pCfg->maxRows) { if (pBlock->last) { - if (pCommith->isLFileSame && mergeRows < pCfg->minRowsPerFileBlock) return true; + if (pCommith->isLFileSame && mergeRows < pCfg->minRows) return true; } else { - if (pCommith->isDFileSame && mergeRows <= pCfg->maxRowsPerFileBlock) return true; + if (pCommith->isDFileSame && mergeRows <= pCfg->maxRows) return true; } } diff --git a/source/dnode/vnode/src/tsdb/tsdbFS.c b/source/dnode/vnode/src/tsdb/tsdbFS.c index bd3888864d..866c02cbb3 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS.c @@ -190,8 +190,8 @@ static int tsdbAddDFileSetToStatus(SFSStatus *pStatus, const SDFileSet *pSet) { // ================== STsdbFS STsdbFS *tsdbNewFS(const STsdbCfg *pCfg) { - int keep = pCfg->keep; - int days = pCfg->daysPerFile; + int keep = pCfg->keep2; + int days = pCfg->days; int maxFSet = TSDB_MAX_FSETS(keep, days); STsdbFS *pfs; diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index 5a477e646c..5f401c9b2b 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -19,9 +19,9 @@ static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg); static int tsdbMemTableInsertTbData(STsdb *pRepo, SSubmitBlk *pBlock, int32_t *pAffectedRows); static STbData *tsdbNewTbData(tb_uid_t uid); static void tsdbFreeTbData(STbData *pTbData); -static char * tsdbGetTsTupleKey(const void *data); +static char *tsdbGetTsTupleKey(const void *data); static int tsdbTbDataComp(const void *arg1, const void *arg2); -static char * tsdbTbDataGetUid(const void *arg); +static char *tsdbTbDataGetUid(const void *arg); static int tsdbAppendTableRowToCols(STable *pTable, SDataCols *pCols, STSchema **ppSchema, STSRow *row); STsdbMemTable *tsdbNewMemTable(STsdb *pTsdb) { @@ -74,7 +74,7 @@ void tsdbFreeMemTable(STsdb *pTsdb, STsdbMemTable *pMemTable) { } int tsdbMemTableInsert(STsdb *pTsdb, STsdbMemTable *pMemTable, SSubmitReq *pMsg, SSubmitRsp *pRsp) { - SSubmitBlk * pBlock = NULL; + SSubmitBlk *pBlock = NULL; SSubmitMsgIter msgIter = {0}; int32_t affectedrows = 0, numOfRows = 0; @@ -119,12 +119,12 @@ int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey TKEY *filterKeys, int nFilterKeys, bool keepDup, SMergeInfo *pMergeInfo) { ASSERT(maxRowsToRead > 0 && nFilterKeys >= 0); if (pIter == NULL) return 0; - STSchema * pSchema = NULL; + STSchema *pSchema = NULL; TSKEY rowKey = 0; TSKEY fKey = 0; bool isRowDel = false; int filterIter = 0; - STSRow * row = NULL; + STSRow *row = NULL; SMergeInfo mInfo; if (pMergeInfo == NULL) pMergeInfo = &mInfo; @@ -259,12 +259,12 @@ static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg) { ASSERT(pMsg != NULL); // STsdbMeta * pMeta = pTsdb->tsdbMeta; SSubmitMsgIter msgIter = {0}; - SSubmitBlk * pBlock = NULL; + SSubmitBlk *pBlock = NULL; SSubmitBlkIter blkIter = {0}; - STSRow * row = NULL; + STSRow *row = NULL; TSKEY now = taosGetTimestamp(pTsdb->config.precision); - TSKEY minKey = now - tsTickPerDay[pTsdb->config.precision] * pTsdb->config.keep; - TSKEY maxKey = now + tsTickPerDay[pTsdb->config.precision] * pTsdb->config.daysPerFile; + TSKEY minKey = now - tsTickPerDay[pTsdb->config.precision] * pTsdb->config.keep2; + TSKEY maxKey = now + tsTickPerDay[pTsdb->config.precision] * pTsdb->config.days; terrno = TSDB_CODE_SUCCESS; pMsg->length = htonl(pMsg->length); @@ -332,9 +332,9 @@ static int tsdbMemTableInsertTbData(STsdb *pTsdb, SSubmitBlk *pBlock, int32_t *p // STable *pTable = NULL; SSubmitBlkIter blkIter = {0}; STsdbMemTable *pMemTable = pTsdb->mem; - void * tptr; - STbData * pTbData; - STSRow * row; + void *tptr; + STbData *pTbData; + STSRow *row; TSKEY keyMin; TSKEY keyMax; @@ -504,7 +504,7 @@ int tsdbInsertDataToMemTable(STsdbMemTable *pMemTable, SSubmitReq *pMsg) { #include "tskiplist.h" #define TSDB_DATA_SKIPLIST_LEVEL 5 -#define TSDB_MAX_INSERT_BATCH 512 +#define TSDB_MAX_INSERT_BATCH 512 typedef struct { int32_t totalLen; diff --git a/source/dnode/vnode/src/tsdb/tsdbOptions.c b/source/dnode/vnode/src/tsdb/tsdbOptions.c index 2c57a7406e..3560c9feaa 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOptions.c +++ b/source/dnode/vnode/src/tsdb/tsdbOptions.c @@ -17,12 +17,12 @@ const STsdbCfg defautlTsdbOptions = {.precision = 0, .lruCacheSize = 0, - .daysPerFile = 10, - .minRowsPerFileBlock = 100, - .maxRowsPerFileBlock = 4096, - .keep = 3650, - .keep1 = 3650, + .days = 10, + .minRows = 100, + .maxRows = 4096, .keep2 = 3650, + .keep0 = 3650, + .keep1 = 3650, .update = 0, .compression = TWO_STAGE_COMP}; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 9509dfa462..1314ef7d1e 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -314,7 +314,7 @@ static int64_t getEarliestValidTimestamp(STsdb* pTsdb) { STsdbCfg* pCfg = &pTsdb->config; int64_t now = taosGetTimestamp(pCfg->precision); - return now - (tsTickPerDay[pCfg->precision] * pCfg->keep) + 1; // needs to add one tick + return now - (tsTickPerDay[pCfg->precision] * pCfg->keep2) + 1; // needs to add one tick } static void setQueryTimewindow(STsdbReadHandle* pTsdbReadHandle, STsdbQueryCond* pCond) { @@ -404,7 +404,7 @@ static STsdbReadHandle* tsdbQueryTablesImpl(STsdb* tsdb, STsdbQueryCond* pCond, pReadHandle->defaultLoadColumn = getDefaultLoadColumns(pReadHandle, true); } - pReadHandle->pDataCols = tdNewDataCols(1000, pReadHandle->pTsdb->config.maxRowsPerFileBlock); + pReadHandle->pDataCols = tdNewDataCols(1000, pReadHandle->pTsdb->config.maxRows); if (pReadHandle->pDataCols == NULL) { tsdbError("%p failed to malloc buf for pDataCols, %s", pReadHandle, pReadHandle->idStr); terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; @@ -2199,7 +2199,7 @@ static int32_t getFirstFileDataBlock(STsdbReadHandle* pTsdbReadHandle, bool* exi break; } - tsdbGetFidKeyRange(pCfg->daysPerFile, pCfg->precision, pTsdbReadHandle->pFileGroup->fid, &win.skey, &win.ekey); + tsdbGetFidKeyRange(pCfg->days, pCfg->precision, pTsdbReadHandle->pFileGroup->fid, &win.skey, &win.ekey); // current file are not overlapped with query time window, ignore remain files if ((ASCENDING_TRAVERSE(pTsdbReadHandle->order) && win.skey > pTsdbReadHandle->window.ekey) || @@ -2295,7 +2295,7 @@ int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT* queryHandle, STableBlockDistInfo* // find the start data block in file pTsdbReadHandle->locateStart = true; STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config; - int32_t fid = getFileIdFromKey(pTsdbReadHandle->window.skey, pCfg->daysPerFile, pCfg->precision); + int32_t fid = getFileIdFromKey(pTsdbReadHandle->window.skey, pCfg->days, pCfg->precision); tsdbRLockFS(pFileHandle); tsdbFSIterInit(&pTsdbReadHandle->fileIter, pFileHandle, pTsdbReadHandle->order); @@ -2321,7 +2321,7 @@ int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT* queryHandle, STableBlockDistInfo* break; } - tsdbGetFidKeyRange(pCfg->daysPerFile, pCfg->precision, pTsdbReadHandle->pFileGroup->fid, &win.skey, &win.ekey); + tsdbGetFidKeyRange(pCfg->days, pCfg->precision, pTsdbReadHandle->pFileGroup->fid, &win.skey, &win.ekey); // current file are not overlapped with query time window, ignore remain files if ((ascTraverse && win.skey > pTsdbReadHandle->window.ekey) || @@ -2396,7 +2396,7 @@ static int32_t getDataBlocksInFiles(STsdbReadHandle* pTsdbReadHandle, bool* exis if (!pTsdbReadHandle->locateStart) { pTsdbReadHandle->locateStart = true; STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config; - int32_t fid = getFileIdFromKey(pTsdbReadHandle->window.skey, pCfg->daysPerFile, pCfg->precision); + int32_t fid = getFileIdFromKey(pTsdbReadHandle->window.skey, pCfg->days, pCfg->precision); tsdbRLockFS(pFileHandle); tsdbFSIterInit(&pTsdbReadHandle->fileIter, pFileHandle, pTsdbReadHandle->order); diff --git a/source/dnode/vnode/src/tsdb/tsdbReadImpl.c b/source/dnode/vnode/src/tsdb/tsdbReadImpl.c index e31ede09cc..187ec54949 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReadImpl.c +++ b/source/dnode/vnode/src/tsdb/tsdbReadImpl.c @@ -43,14 +43,14 @@ int tsdbInitReadH(SReadH *pReadh, STsdb *pRepo) { return -1; } - pReadh->pDCols[0] = tdNewDataCols(0, pCfg->maxRowsPerFileBlock); + pReadh->pDCols[0] = tdNewDataCols(0, pCfg->maxRows); if (pReadh->pDCols[0] == NULL) { terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; tsdbDestroyReadH(pReadh); return -1; } - pReadh->pDCols[1] = tdNewDataCols(0, pCfg->maxRowsPerFileBlock); + pReadh->pDCols[1] = tdNewDataCols(0, pCfg->maxRows); if (pReadh->pDCols[1] == NULL) { terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; tsdbDestroyReadH(pReadh); @@ -276,8 +276,8 @@ int tsdbLoadBlockData(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo) { return 0; } -int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo, const int16_t *colIds, - int numOfColsIds, bool mergeBitmap) { +int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo, const int16_t *colIds, int numOfColsIds, + bool mergeBitmap) { ASSERT(pBlock->numOfSubBlocks > 0); int8_t update = pReadh->pRepo->config.update; @@ -513,7 +513,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat tdResetDataCols(pDataCols); - if(tsdbIsSupBlock(pBlock)) { + if (tsdbIsSupBlock(pBlock)) { tdDataColsSetBitmapI(pDataCols); } @@ -606,9 +606,10 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat if (tsdbMakeRoom((void **)(&TSDB_READ_COMP_BUF(pReadh)), zsize) < 0) return -1; } - if (tsdbCheckAndDecodeColumnData(pDataCol, POINTER_SHIFT(pBlockData, tsize + toffset), tlen, pBlockCol->blen, - pBlock->algorithm, pBlock->numOfRows, tLenBitmap, pDataCols->maxPoints, - TSDB_READ_COMP_BUF(pReadh), (int)taosTSizeof(TSDB_READ_COMP_BUF(pReadh))) < 0) { + if (tsdbCheckAndDecodeColumnData(pDataCol, POINTER_SHIFT(pBlockData, tsize + toffset), tlen, + pBlockCol ? pBlockCol->blen : 0, pBlock->algorithm, pBlock->numOfRows, + tLenBitmap, pDataCols->maxPoints, TSDB_READ_COMP_BUF(pReadh), + (int)taosTSizeof(TSDB_READ_COMP_BUF(pReadh))) < 0) { tsdbError("vgId:%d file %s is broken at column %d block offset %" PRId64 " column offset %u", TSDB_READ_REPO_ID(pReadh), TSDB_FILE_FULL_NAME(pDFile), tcolId, (int64_t)pBlock->offset, toffset); return -1; @@ -710,7 +711,7 @@ static int tsdbLoadBlockDataColsImpl(SReadH *pReadh, SBlock *pBlock, SDataCols * tdResetDataCols(pDataCols); - if(tsdbIsSupBlock(pBlock)) { + if (tsdbIsSupBlock(pBlock)) { tdDataColsSetBitmapI(pDataCols); } @@ -747,6 +748,7 @@ static int tsdbLoadBlockDataColsImpl(SReadH *pReadh, SBlock *pBlock, SDataCols * if (colId == PRIMARYKEY_TIMESTAMP_COL_ID) { // load the key row blockCol.colId = colId; TD_SET_COL_ROWS_NORM(&blockCol); // default is NORM for the primary key column + blockCol.blen = 0; blockCol.len = pBlock->keyLen; blockCol.type = pDataCol->type; blockCol.offset = TSDB_KEY_COL_OFFSET; @@ -836,7 +838,7 @@ static int tsdbLoadColData(SReadH *pReadh, SDFile *pDFile, SBlock *pBlock, SBloc } if (tsdbCheckAndDecodeColumnData(pDataCol, pReadh->pBuf, pBlockCol->len, pBlockCol->blen, pBlock->algorithm, - pBlock->numOfRows, tLenBitmap, pCfg->maxRowsPerFileBlock, pReadh->pCBuf, + pBlock->numOfRows, tLenBitmap, pCfg->maxRows, pReadh->pCBuf, (int32_t)taosTSizeof(pReadh->pCBuf)) < 0) { tsdbError("vgId:%d file %s is broken at column %d offset %" PRId64, REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pDFile), pBlockCol->colId, offset); diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index 7de5a0d5a9..7abdf22073 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -106,7 +106,8 @@ struct SSmaStat { // expired window static int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t version); -static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey, int64_t version); +static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey, + int64_t version); static int32_t tsdbInitSmaStat(SSmaStat **pSmaStat); static void *tsdbFreeSmaStatItem(SSmaStatItem *pSmaStatItem); static int32_t tsdbDestroySmaState(SSmaStat *pSmaStat); @@ -197,7 +198,7 @@ static SPoolMem *openPool() { static void clearPool(SPoolMem *pPool) { if (!pPool) return; - + SPoolMem *pMem; do { @@ -544,7 +545,8 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { return TSDB_CODE_SUCCESS; }; -static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey, int64_t version) { +static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey, + int64_t version) { SSmaStatItem *pItem = taosHashGet(pItemsHash, &indexUid, sizeof(indexUid)); if (pItem == NULL) { // TODO: use TSDB_SMA_STAT_EXPIRED and update by stream computing later @@ -946,7 +948,7 @@ static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, int64_t indexUid, int32_t */ static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLevel) { STsdbCfg *pCfg = REPO_CFG(pTsdb); - int32_t daysPerFile = pCfg->daysPerFile; + int32_t daysPerFile = pCfg->days; if (storageLevel == SMA_STORAGE_LEVEL_TSDB) { int32_t days = SMA_STORAGE_TSDB_TIMES * (interval / tsTickPerDay[pCfg->precision]); diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index ef417cabc6..34b983c20c 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -15,14 +15,15 @@ #include "vnodeInt.h" -const SVnodeCfg defaultVnodeOptions = { - .wsize = 96 * 1024 * 1024, .ssize = 1 * 1024 * 1024, .lsize = 1024, .walCfg = {.level = TAOS_WAL_WRITE}}; /* TODO */ +const SVnodeCfg vnodeCfgDefault = { + .wsize = 96 * 1024 * 1024, .ssize = 1 * 1024 * 1024, .lsize = 1024, .walCfg = {.level = TAOS_WAL_WRITE}}; -int vnodeValidateOptions(const SVnodeCfg *pVnodeOptions) { +int vnodeCheckCfg(const SVnodeCfg *pCfg) { // TODO return 0; } +#if 1 //====================================================================== void vnodeOptionsCopy(SVnodeCfg *pDest, const SVnodeCfg *pSrc) { memcpy((void *)pDest, (void *)pSrc, sizeof(SVnodeCfg)); } @@ -46,3 +47,5 @@ int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName) { return TSDB_CODE_SUCCESS; } + +#endif \ No newline at end of file diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index b4c3725a5e..fa249d3ba1 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -15,11 +15,128 @@ #include "vnodeInt.h" +#define VND_INFO_FNAME "vnode.json" +#define VND_INFO_FNAME_TMP "vnode_tmp.json" + +static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData); +static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo); static int vnodeStartCommit(SVnode *pVnode); static int vnodeEndCommit(SVnode *pVnode); static int vnodeCommit(void *arg); static void vnodeWaitCommit(SVnode *pVnode); +int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) { + char fname[TSDB_FILENAME_LEN]; + TdFilePtr pFile; + char *data; + + snprintf(fname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME_TMP); + + // encode info + data = NULL; + + if (vnodeEncodeInfo(pInfo, &data) < 0) { + return -1; + } + + // save info to a vnode_tmp.json + pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); + if (pFile == NULL) { + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + + if (taosWriteFile(pFile, data, strlen(data)) < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + + if (taosFsyncFile(pFile) < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + + taosCloseFile(&pFile); + + // free info binary + taosMemoryFree(data); + + vInfo("vgId: %d vnode info is saved, fname: %s", pInfo->config.vgId, fname); + + return 0; + +_err: + taosCloseFile(&pFile); + taosMemoryFree(data); + return -1; +} + +int vnodeCommitInfo(const char *dir, const SVnodeInfo *pInfo) { + char fname[TSDB_FILENAME_LEN]; + char tfname[TSDB_FILENAME_LEN]; + + snprintf(fname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME); + snprintf(tfname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME_TMP); + + if (taosRenameFile(tfname, fname) < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + + vInfo("vgId: %d vnode info is committed", pInfo->config.vgId); + + return 0; +} + +int vnodeLoadInfo(const char *dir, SVnodeInfo *pInfo) { + char fname[TSDB_FILENAME_LEN]; + TdFilePtr pFile = NULL; + char *pData = NULL; + int64_t size; + + snprintf(fname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME); + + // read info + pFile = taosOpenFile(fname, TD_FILE_READ); + if (pFile == NULL) { + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + + if (taosFStatFile(pFile, &size, NULL) < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + + pData = taosMemoryMalloc(size); + if (pData == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + + if (taosReadFile(pFile, pData, size) < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + + taosCloseFile(&pFile); + + // decode info + if (vnodeDecodeInfo(pData, pInfo) < 0) { + taosMemoryFree(pData); + return -1; + } + + taosMemoryFree(pData); + + return 0; + +_err: + taosCloseFile(&pFile); + taosMemoryFree(pData); + return -1; +} + int vnodeAsyncCommit(SVnode *pVnode) { vnodeWaitCommit(pVnode); @@ -60,4 +177,133 @@ static int vnodeEndCommit(SVnode *pVnode) { return 0; } -static FORCE_INLINE void vnodeWaitCommit(SVnode *pVnode) { tsem_wait(&pVnode->canCommit); } \ No newline at end of file +static FORCE_INLINE void vnodeWaitCommit(SVnode *pVnode) { tsem_wait(&pVnode->canCommit); } + +static int vnodeEncodeConfig(const void *pObj, SJson *pJson) { + const SVnodeCfg *pCfg = (SVnodeCfg *)pObj; + + if (tjsonAddIntegerToObject(pJson, "vgId", pCfg->vgId) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "dbId", pCfg->dbId) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "wsize", pCfg->wsize) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "ssize", pCfg->ssize) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "lsize", pCfg->lsize) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "isHeap", pCfg->isHeapAllocator) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "ttl", pCfg->ttl) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "keep", pCfg->keep) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "streamMode", pCfg->streamMode) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "isWeak", pCfg->isWeak) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "precision", pCfg->tsdbCfg.precision) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "update", pCfg->tsdbCfg.update) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "compression", pCfg->tsdbCfg.compression) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "daysPerFile", pCfg->tsdbCfg.days) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "minRows", pCfg->tsdbCfg.minRows) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "maxRows", pCfg->tsdbCfg.maxRows) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "keep0", pCfg->tsdbCfg.keep0) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "lruCacheSize", pCfg->tsdbCfg.lruCacheSize) < 0) return -1; + + return 0; +} + +static int vnodeDecodeConfig(const SJson *pJson, void *pObj) { + SVnodeCfg *pCfg = (SVnodeCfg *)pObj; + + if (tjsonGetNumberValue(pJson, "vgId", pCfg->vgId) < 0) return -1; + if (tjsonGetNumberValue(pJson, "dbId", pCfg->dbId) < 0) return -1; + if (tjsonGetNumberValue(pJson, "wsize", pCfg->wsize) < 0) return -1; + if (tjsonGetNumberValue(pJson, "ssize", pCfg->ssize) < 0) return -1; + if (tjsonGetNumberValue(pJson, "lsize", pCfg->lsize) < 0) return -1; + if (tjsonGetNumberValue(pJson, "isHeap", pCfg->isHeapAllocator) < 0) return -1; + if (tjsonGetNumberValue(pJson, "ttl", pCfg->ttl) < 0) return -1; + if (tjsonGetNumberValue(pJson, "keep", pCfg->keep) < 0) return -1; + if (tjsonGetNumberValue(pJson, "streamMode", pCfg->streamMode) < 0) return -1; + if (tjsonGetNumberValue(pJson, "isWeak", pCfg->isWeak) < 0) return -1; + if (tjsonGetNumberValue(pJson, "precision", pCfg->tsdbCfg.precision) < 0) return -1; + if (tjsonGetNumberValue(pJson, "update", pCfg->tsdbCfg.update) < 0) return -1; + if (tjsonGetNumberValue(pJson, "compression", pCfg->tsdbCfg.compression) < 0) return -1; + if (tjsonGetNumberValue(pJson, "daysPerFile", pCfg->tsdbCfg.days) < 0) return -1; + if (tjsonGetNumberValue(pJson, "minRows", pCfg->tsdbCfg.minRows) < 0) return -1; + if (tjsonGetNumberValue(pJson, "maxRows", pCfg->tsdbCfg.maxRows) < 0) return -1; + if (tjsonGetNumberValue(pJson, "keep0", pCfg->tsdbCfg.keep0) < 0) return -1; + if (tjsonGetNumberValue(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1; + if (tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1; + if (tjsonGetNumberValue(pJson, "lruCacheSize", pCfg->tsdbCfg.lruCacheSize) < 0) return -1; + + return 0; +} + +static int vnodeEncodeState(const void *pObj, SJson *pJson) { + const SVState *pState = (SVState *)pObj; + + if (tjsonAddIntegerToObject(pJson, "commit version", pState->committed) < 0) return -1; + + return 0; +} + +static int vnodeDecodeState(const SJson *pJson, void *pObj) { + SVState *pState = (SVState *)pObj; + + if (tjsonGetNumberValue(pJson, "commit version", pState->committed) < 0) return -1; + + return 0; +} + +static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData) { + SJson *pJson; + char *pData; + + *ppData = NULL; + + pJson = tjsonCreateObject(); + if (pJson == NULL) { + return -1; + } + + if (tjsonAddObject(pJson, "config", vnodeEncodeConfig, (void *)&pInfo->config) < 0) { + goto _err; + } + + if (tjsonAddObject(pJson, "state", vnodeEncodeState, (void *)&pInfo->state) < 0) { + goto _err; + } + + pData = tjsonToString(pJson); + if (pData == NULL) { + goto _err; + } + + tjsonDelete(pJson); + + *ppData = pData; + return 0; + +_err: + tjsonDelete(pJson); + return -1; +} + +static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo) { + SJson *pJson = NULL; + + pJson = tjsonCreateObject(); + if (pJson == NULL) { + return -1; + } + + if (tjsonToObject(pJson, "config", vnodeDecodeConfig, (void *)&pInfo->config) < 0) { + goto _err; + } + + if (tjsonToObject(pJson, "state", vnodeDecodeState, (void *)&pInfo->state) < 0) { + goto _err; + } + + tjsonDelete(pJson); + + return 0; + +_err: + tjsonDelete(pJson); + return -1; +} diff --git a/source/dnode/vnode/src/vnd/vnodeMain.c b/source/dnode/vnode/src/vnd/vnodeOpen.c similarity index 80% rename from source/dnode/vnode/src/vnd/vnodeMain.c rename to source/dnode/vnode/src/vnd/vnodeOpen.c index 2fd848a39d..241c26ab1c 100644 --- a/source/dnode/vnode/src/vnd/vnodeMain.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -20,11 +20,42 @@ static void vnodeFree(SVnode *pVnode); static int vnodeOpenImpl(SVnode *pVnode); static void vnodeCloseImpl(SVnode *pVnode); +int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) { + SVnodeInfo info = {0}; + char dir[TSDB_FILENAME_LEN]; + + // TODO: check if directory exists + + // check config + if (vnodeCheckCfg(pCfg) < 0) { + vError("vgId: %d failed to create vnode since: %s", pCfg->vgId, tstrerror(terrno)); + return -1; + } + + // create vnode env + if (tfsMkdir(pTfs, path) < 0) { + vError("vgId: %d failed to create vnode since: %s", pCfg->vgId, tstrerror(terrno)); + return -1; + } + + snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path); + info.config = *pCfg; + + if (vnodeSaveInfo(dir, &info) < 0 || vnodeCommitInfo(dir, &info) < 0) { + vError("vgId: %d failed to save vnode config since %s", pCfg->vgId, tstrerror(terrno)); + return -1; + } + + vInfo("vgId: %d vnode is created", pCfg->vgId); + + return 0; +} + SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg) { SVnode *pVnode = NULL; // Set default options - SVnodeCfg cfg = defaultVnodeOptions; + SVnodeCfg cfg = vnodeCfgDefault; if (pVnodeCfg != NULL) { cfg.vgId = pVnodeCfg->vgId; cfg.msgCb = pVnodeCfg->msgCb; @@ -36,7 +67,7 @@ SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg) { } // Validate options - if (vnodeValidateOptions(&cfg) < 0) { + if (vnodeCheckCfg(&cfg) < 0) { // TODO return NULL; } diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index 09f51dc03e..8938084724 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -227,20 +227,20 @@ typedef struct SCtgAction { #define CTG_FLAG_STB 0x1 #define CTG_FLAG_NOT_STB 0x2 #define CTG_FLAG_UNKNOWN_STB 0x4 -#define CTG_FLAG_INF_DB 0x8 +#define CTG_FLAG_SYS_DB 0x8 #define CTG_FLAG_FORCE_UPDATE 0x10 #define CTG_FLAG_IS_STB(_flag) ((_flag) & CTG_FLAG_STB) #define CTG_FLAG_IS_NOT_STB(_flag) ((_flag) & CTG_FLAG_NOT_STB) #define CTG_FLAG_IS_UNKNOWN_STB(_flag) ((_flag) & CTG_FLAG_UNKNOWN_STB) -#define CTG_FLAG_IS_INF_DB(_flag) ((_flag) & CTG_FLAG_INF_DB) +#define CTG_FLAG_IS_SYS_DB(_flag) ((_flag) & CTG_FLAG_SYS_DB) #define CTG_FLAG_IS_FORCE_UPDATE(_flag) ((_flag) & CTG_FLAG_FORCE_UPDATE) -#define CTG_FLAG_SET_INF_DB(_flag) ((_flag) |= CTG_FLAG_INF_DB) +#define CTG_FLAG_SET_SYS_DB(_flag) ((_flag) |= CTG_FLAG_SYS_DB) #define CTG_FLAG_SET_STB(_flag, tbType) do { (_flag) |= ((tbType) == TSDB_SUPER_TABLE) ? CTG_FLAG_STB : ((tbType) > TSDB_SUPER_TABLE ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB); } while (0) #define CTG_FLAG_MAKE_STB(_isStb) (((_isStb) == 1) ? CTG_FLAG_STB : ((_isStb) == 0 ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB)) #define CTG_FLAG_MATCH_STB(_flag, tbType) (CTG_FLAG_IS_UNKNOWN_STB(_flag) || (CTG_FLAG_IS_STB(_flag) && (tbType) == TSDB_SUPER_TABLE) || (CTG_FLAG_IS_NOT_STB(_flag) && (tbType) != TSDB_SUPER_TABLE)) -#define CTG_IS_INF_DBNAME(_dbname) ((*(_dbname) == 'i') && (0 == strcmp(_dbname, TSDB_INFORMATION_SCHEMA_DB))) +#define CTG_IS_SYS_DBNAME(_dbname) (((*(_dbname) == 'i') && (0 == strcmp(_dbname, TSDB_INFORMATION_SCHEMA_DB))) || ((*(_dbname) == 'p') && (0 == strcmp(_dbname, TSDB_PERFORMANCE_SCHEMA_DB)))) #define CTG_META_SIZE(pMeta) (sizeof(STableMeta) + ((pMeta)->tableInfo.numOfTags + (pMeta)->tableInfo.numOfColumns) * sizeof(SSchema)) diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 2aa858fe06..21e0be40a4 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -217,7 +217,7 @@ int32_t ctgPushRmDBMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId) } char *p = strchr(dbFName, '.'); - if (p && CTG_IS_INF_DBNAME(p + 1)) { + if (p && CTG_IS_SYS_DBNAME(p + 1)) { dbFName = p + 1; } @@ -304,7 +304,7 @@ int32_t ctgPushUpdateVgMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t d } char *p = strchr(dbFName, '.'); - if (p && CTG_IS_INF_DBNAME(p + 1)) { + if (p && CTG_IS_SYS_DBNAME(p + 1)) { dbFName = p + 1; } @@ -336,7 +336,7 @@ int32_t ctgPushUpdateTblMsgInQueue(SCatalog* pCtg, STableMetaOutput *output, boo } char *p = strchr(output->dbFName, '.'); - if (p && CTG_IS_INF_DBNAME(p + 1)) { + if (p && CTG_IS_SYS_DBNAME(p + 1)) { memmove(output->dbFName, p + 1, strlen(p + 1)); } @@ -410,7 +410,7 @@ void ctgWReleaseVgInfo(SCtgDBCache *dbCache) { int32_t ctgAcquireDBCacheImpl(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache, bool acquire) { char *p = strchr(dbFName, '.'); - if (p && CTG_IS_INF_DBNAME(p + 1)) { + if (p && CTG_IS_SYS_DBNAME(p + 1)) { dbFName = p + 1; } @@ -688,7 +688,7 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable } char dbFName[TSDB_DB_FNAME_LEN] = {0}; - if (CTG_FLAG_IS_INF_DB(flag)) { + if (CTG_FLAG_IS_SYS_DB(flag)) { strcpy(dbFName, pTableName->dbname); } else { tNameGetFullDbName(pTableName, dbFName); @@ -1721,7 +1721,7 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, SVgroupInfo vgroupInfo = {0}; int32_t code = 0; - if (!CTG_FLAG_IS_INF_DB(flag)) { + if (!CTG_FLAG_IS_SYS_DB(flag)) { CTG_ERR_RET(catalogGetTableHashVgroup(pCtg, pTrans, pMgmtEps, pTableName, &vgroupInfo)); } @@ -1732,7 +1732,7 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); } - if (CTG_FLAG_IS_INF_DB(flag)) { + if (CTG_FLAG_IS_SYS_DB(flag)) { ctgDebug("will refresh tbmeta, supposed in information_schema, tbName:%s", tNameGetTableName(pTableName)); CTG_ERR_JRET(ctgGetTableMetaFromMnodeImpl(pCtg, pTrans, pMgmtEps, (char *)pTableName->dbname, (char *)pTableName->tname, output)); @@ -1820,8 +1820,8 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons uint64_t suid = 0; STableMetaOutput *output = NULL; - if (CTG_IS_INF_DBNAME(pTableName->dbname)) { - CTG_FLAG_SET_INF_DB(flag); + if (CTG_IS_SYS_DBNAME(pTableName->dbname)) { + CTG_FLAG_SET_SYS_DB(flag); } CTG_ERR_RET(ctgGetTableMetaFromCache(pCtg, pTableName, pTableMeta, &inCache, flag, &dbId)); @@ -1829,7 +1829,7 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons int32_t tbType = 0; if (inCache) { - if (CTG_FLAG_MATCH_STB(flag, (*pTableMeta)->tableType) && ((!CTG_FLAG_IS_FORCE_UPDATE(flag)) || (CTG_FLAG_IS_INF_DB(flag)))) { + if (CTG_FLAG_MATCH_STB(flag, (*pTableMeta)->tableType) && ((!CTG_FLAG_IS_FORCE_UPDATE(flag)) || (CTG_FLAG_IS_SYS_DB(flag)))) { goto _return; } @@ -1885,7 +1885,7 @@ _return: if (CTG_TABLE_NOT_EXIST(code) && inCache) { char dbFName[TSDB_DB_FNAME_LEN] = {0}; - if (CTG_FLAG_IS_INF_DB(flag)) { + if (CTG_FLAG_IS_SYS_DB(flag)) { strcpy(dbFName, pTableName->dbname); } else { tNameGetFullDbName(pTableName, dbFName); @@ -2633,7 +2633,7 @@ int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgm CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } - if (CTG_IS_INF_DBNAME(pTableName->dbname)) { + if (CTG_IS_SYS_DBNAME(pTableName->dbname)) { ctgError("no valid vgInfo for db, dbname:%s", pTableName->dbname); CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } @@ -2666,7 +2666,7 @@ _return: int32_t catalogGetTableHashVgroup(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, SVgroupInfo *pVgroup) { CTG_API_ENTER(); - if (CTG_IS_INF_DBNAME(pTableName->dbname)) { + if (CTG_IS_SYS_DBNAME(pTableName->dbname)) { ctgError("no valid vgInfo for db, dbname:%s", pTableName->dbname); CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index 8d88b94d6c..1f3c003dfb 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -42,10 +42,6 @@ #define curTimeWindowIndex(_winres) ((_winres)->curIndex) -struct SColumnFilterElem; - -typedef bool (*__filter_func_t)(struct SColumnFilterElem* pFilter, const char* val1, const char* val2, int16_t type); - typedef struct SGroupResInfo { int32_t totalGroup; int32_t currentGroup; diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index cbd2dc66f5..51dfeed7ae 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -20,9 +20,9 @@ extern "C" { #endif #include "os.h" -#include "tsort.h" #include "tcommon.h" #include "tlosertree.h" +#include "tsort.h" #include "ttszip.h" #include "tvariant.h" @@ -35,15 +35,13 @@ extern "C" { #include "tarray.h" #include "thash.h" #include "tlockfree.h" -#include "tpagedbuf.h" #include "tmsg.h" - -struct SColumnFilterElem; +#include "tpagedbuf.h" typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int32_t order); -#define IS_QUERY_KILLED(_q) ((_q)->code == TSDB_CODE_TSC_QUERY_CANCELLED) -#define Q_STATUS_EQUAL(p, s) (((p) & (s)) != 0u) +#define IS_QUERY_KILLED(_q) ((_q)->code == TSDB_CODE_TSC_QUERY_CANCELLED) +#define Q_STATUS_EQUAL(p, s) (((p) & (s)) != 0u) #define QUERY_IS_ASC_QUERY(q) (GET_FORWARD_DIRECTION_FACTOR((q)->order.order) == QUERY_ASC_FORWARD_STEP) #define GET_TABLEGROUP(q, _index) ((SArray*)taosArrayGetP((q)->tableqinfoGroupInfo.pGroupList, (_index))) @@ -67,7 +65,7 @@ enum { }; typedef struct SResultRowCell { - uint64_t groupId; + uint64_t groupId; SResultRowPosition pos; } SResultRowCell; @@ -75,19 +73,19 @@ typedef struct SResultRowCell { * If the number of generated results is greater than this value, * query query will be halt and return results to client immediate. */ -typedef struct SResultInfo { // TODO refactor - int64_t totalRows; // total generated result size in rows - int64_t totalBytes; // total results in bytes. - int32_t capacity; // capacity of current result output buffer - int32_t threshold; // result size threshold in rows. +typedef struct SResultInfo { // TODO refactor + int64_t totalRows; // total generated result size in rows + int64_t totalBytes; // total results in bytes. + int32_t capacity; // capacity of current result output buffer + int32_t threshold; // result size threshold in rows. } SResultInfo; typedef struct STableQueryInfo { - TSKEY lastKey; // last check ts - uint64_t uid; // table uid - int32_t groupIndex; // group id in table list -// SVariant tag; - SResultRowInfo resInfo; // result info + TSKEY lastKey; // last check ts + uint64_t uid; // table uid + int32_t groupIndex; // group id in table list + // SVariant tag; + SResultRowInfo resInfo; // result info } STableQueryInfo; typedef enum { @@ -155,27 +153,27 @@ typedef struct SOperatorCostInfo { // The basic query information extracted from the SQueryInfo tree to support the // execution of query in a data node. typedef struct STaskAttr { - SLimit limit; - SLimit slimit; - bool stableQuery; // super table query or not - bool topBotQuery; // TODO used bitwise flag - bool groupbyColumn; // denote if this is a groupby normal column query - bool timeWindowInterpo; // if the time window start/end required interpolation - bool tsCompQuery; // is tscomp query - bool diffQuery; // is diff query - bool pointInterpQuery; // point interpolation query - int32_t havingNum; // having expr number - int16_t numOfCols; - int16_t numOfTags; - STimeWindow window; - SInterval interval; - int16_t precision; - int16_t numOfOutput; - int16_t fillType; - int32_t resultRowSize; - int32_t tagLen; // tag value length of current query + SLimit limit; + SLimit slimit; + bool stableQuery; // super table query or not + bool topBotQuery; // TODO used bitwise flag + bool groupbyColumn; // denote if this is a groupby normal column query + bool timeWindowInterpo; // if the time window start/end required interpolation + bool tsCompQuery; // is tscomp query + bool diffQuery; // is diff query + bool pointInterpQuery; // point interpolation query + int32_t havingNum; // having expr number + int16_t numOfCols; + int16_t numOfTags; + STimeWindow window; + SInterval interval; + int16_t precision; + int16_t numOfOutput; + int16_t fillType; + int32_t resultRowSize; + int32_t tagLen; // tag value length of current query - SExprInfo *pExpr1; + SExprInfo* pExpr1; SColumnInfo* tagColList; int32_t numOfFilterCols; int64_t* fillVal; @@ -188,13 +186,15 @@ struct SOperatorInfo; struct SAggSupporter; struct SOptrBasicInfo; -typedef void (*__optr_encode_fn_t)(struct SOperatorInfo* pOperator, struct SAggSupporter *pSup, struct SOptrBasicInfo *pInfo, char **result, int32_t *length); -typedef bool (*__optr_decode_fn_t)(struct SOperatorInfo* pOperator, struct SAggSupporter *pSup, struct SOptrBasicInfo *pInfo, char *result, int32_t length); +typedef void (*__optr_encode_fn_t)(struct SOperatorInfo* pOperator, struct SAggSupporter* pSup, + struct SOptrBasicInfo* pInfo, char** result, int32_t* length); +typedef bool (*__optr_decode_fn_t)(struct SOperatorInfo* pOperator, struct SAggSupporter* pSup, + struct SOptrBasicInfo* pInfo, char* result, int32_t length); typedef int32_t (*__optr_open_fn_t)(struct SOperatorInfo* pOptr); typedef SSDataBlock* (*__optr_fn_t)(struct SOperatorInfo* pOptr, bool* newgroup); typedef void (*__optr_close_fn_t)(void* param, int32_t num); -typedef int32_t (*__optr_get_explain_fn_t)(struct SOperatorInfo* pOptr, void **pOptrExplain); +typedef int32_t (*__optr_get_explain_fn_t)(struct SOperatorInfo* pOptr, void** pOptrExplain); typedef struct STaskIdInfo { uint64_t queryId; // this is also a request id @@ -204,29 +204,28 @@ typedef struct STaskIdInfo { } STaskIdInfo; typedef struct SExecTaskInfo { - STaskIdInfo id; - uint32_t status; - STimeWindow window; - STaskCostInfo cost; - int64_t owner; // if it is in execution - int32_t code; - uint64_t totalRows; // total number of rows - STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray structure - char* sql; // query sql string - jmp_buf env; // jump to this position when error happens. - EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] + STaskIdInfo id; + uint32_t status; + STimeWindow window; + STaskCostInfo cost; + int64_t owner; // if it is in execution + int32_t code; + uint64_t totalRows; // total number of rows + STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray structure + char* sql; // query sql string + jmp_buf env; // jump to this position when error happens. + EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] struct SOperatorInfo* pRoot; } SExecTaskInfo; typedef struct STaskRuntimeEnv { + jmp_buf env; STaskAttr* pQueryAttr; uint32_t status; // query status void* qinfo; uint8_t scanFlag; // denotes reversed scan of data or not void* pTsdbReadHandle; - - int32_t prevGroupId; // previous executed group id bool enableGroupData; SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file SHashObj* pResultRowHashTable; // quick locate the window object for each result @@ -234,31 +233,28 @@ typedef struct STaskRuntimeEnv { SArray* pResultRowArrayList; // The array list that contains the Result rows char* keyBuf; // window key buffer // The window result objects pool, all the resultRow Objects are allocated and managed by this object. - char** prevRow; - SArray* prevResult; // intermediate result, SArray - STSBuf* pTsBuf; // timestamp filter list - STSCursor cur; + char** prevRow; + SArray* prevResult; // intermediate result, SArray + STSBuf* pTsBuf; // timestamp filter list + STSCursor cur; - char* tagVal; // tag value of current data block + char* tagVal; // tag value of current data block struct SScalarFunctionSupport* scalarSup; - - SSDataBlock* outputBuf; STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray structure struct SOperatorInfo* proot; - SGroupResInfo groupResInfo; - int64_t currentOffset; // dynamic offset value + SGroupResInfo groupResInfo; + int64_t currentOffset; // dynamic offset value STableQueryInfo* current; SResultInfo resultInfo; - SHashObj* pTableRetrieveTsMap; struct SUdfInfo* pUdfInfo; } STaskRuntimeEnv; enum { - OP_NOT_OPENED = 0x0, - OP_OPENED = 0x1, + OP_NOT_OPENED = 0x0, + OP_OPENED = 0x1, OP_RES_TO_RETURN = 0x5, - OP_EXEC_DONE = 0x9, + OP_EXEC_DONE = 0x9, }; typedef struct SOperatorInfo { @@ -269,7 +265,7 @@ typedef struct SOperatorInfo { char* name; // name, used to show the query execution plan void* info; // extension attribution SExprInfo* pExpr; - STaskRuntimeEnv* pRuntimeEnv; // todo remove it + STaskRuntimeEnv* pRuntimeEnv; // todo remove it SExecTaskInfo* pTaskInfo; SOperatorCostInfo cost; SResultInfo resultInfo; @@ -277,8 +273,8 @@ typedef struct SOperatorInfo { int32_t numOfDownstream; // number of downstream. The value is always ONE expect for join operator __optr_open_fn_t _openFn; // DO NOT invoke this function directly __optr_fn_t getNextFn; - __optr_fn_t getStreamResFn; // execute the aggregate in the stream model. - __optr_fn_t cleanupFn; // call this function to release the allocated resources ASAP + __optr_fn_t getStreamResFn; // execute the aggregate in the stream model. + __optr_fn_t cleanupFn; // call this function to release the allocated resources ASAP __optr_close_fn_t closeFn; __optr_encode_fn_t encodeResultRow; __optr_decode_fn_t decodeResultRow; @@ -293,33 +289,33 @@ typedef struct { typedef enum { EX_SOURCE_DATA_NOT_READY = 0x1, - EX_SOURCE_DATA_READY = 0x2, + EX_SOURCE_DATA_READY = 0x2, EX_SOURCE_DATA_EXHAUSTED = 0x3, } EX_SOURCE_STATUS; typedef struct SSourceDataInfo { - struct SExchangeInfo *pEx; + struct SExchangeInfo* pEx; int32_t index; - SRetrieveTableRsp *pRsp; + SRetrieveTableRsp* pRsp; uint64_t totalRows; int32_t code; EX_SOURCE_STATUS status; } SSourceDataInfo; typedef struct SLoadRemoteDataInfo { - uint64_t totalSize; // total load bytes from remote - uint64_t totalRows; // total number of rows - uint64_t totalElapsed; // total elapsed time + uint64_t totalSize; // total load bytes from remote + uint64_t totalRows; // total number of rows + uint64_t totalElapsed; // total elapsed time } SLoadRemoteDataInfo; typedef struct SExchangeInfo { - SArray* pSources; - SArray* pSourceDataInfo; - tsem_t ready; - void* pTransporter; - SSDataBlock* pResult; - bool seqLoadData; // sequential load data or not, false by default - int32_t current; + SArray* pSources; + SArray* pSourceDataInfo; + tsem_t ready; + void* pTransporter; + SSDataBlock* pResult; + bool seqLoadData; // sequential load data or not, false by default + int32_t current; SLoadRemoteDataInfo loadInfo; } SExchangeInfo; @@ -340,7 +336,7 @@ typedef struct STableScanInfo { int32_t current; int32_t reverseTimes; // 0 by default SNode* pFilterNode; // filter operator info - SqlFunctionCtx* pCtx; // next operator query context + SqlFunctionCtx* pCtx; // next operator query context SResultRowInfo* pResultRowInfo; int32_t* rowCellInfoOffset; SExprInfo* pExpr; @@ -349,7 +345,9 @@ typedef struct STableScanInfo { int32_t numOfOutput; int64_t elapsedTime; int32_t prevGroupId; // previous table group id + int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan + int32_t dataBlockLoadFlag; } STableScanInfo; typedef struct STagScanInfo { @@ -360,15 +358,15 @@ typedef struct STagScanInfo { } STagScanInfo; typedef struct SStreamBlockScanInfo { - SArray* pBlockLists; // multiple SSDatablock. - SSDataBlock* pRes; // result SSDataBlock - int32_t blockType; // current block type - int32_t validBlockIndex; // Is current data has returned? - SColumnInfo* pCols; // the output column info - uint64_t numOfRows; // total scanned rows - uint64_t numOfExec; // execution times - void* readerHandle; // stream block reader handle - SArray* pColMatchInfo; // + SArray* pBlockLists; // multiple SSDatablock. + SSDataBlock* pRes; // result SSDataBlock + int32_t blockType; // current block type + int32_t validBlockIndex; // Is current data has returned? + SColumnInfo* pCols; // the output column info + uint64_t numOfRows; // total scanned rows + uint64_t numOfExec; // execution times + void* readerHandle; // stream block reader handle + SArray* pColMatchInfo; // } SStreamBlockScanInfo; typedef struct SSysTableScanInfo { @@ -377,83 +375,83 @@ typedef struct SSysTableScanInfo { void* readHandle; }; - SRetrieveMetaTableRsp *pRsp; - SRetrieveTableReq req; - SEpSet epSet; - tsem_t ready; + SRetrieveMetaTableRsp* pRsp; + SRetrieveTableReq req; + SEpSet epSet; + tsem_t ready; - int32_t accountId; - bool showRewrite; - SNode *pCondition; // db_name filter condition, to discard data that are not in current database - void *pCur; // cursor for iterate the local table meta store. - SArray *scanCols; // SArray scan column id list + int32_t accountId; + bool showRewrite; + SNode* pCondition; // db_name filter condition, to discard data that are not in current database + void* pCur; // cursor for iterate the local table meta store. + SArray* scanCols; // SArray scan column id list - int32_t type; // show type, TODO remove it + int32_t type; // show type, TODO remove it SName name; - SSDataBlock *pRes; + SSDataBlock* pRes; int32_t capacity; int64_t numOfBlocks; // extract basic running information. SLoadRemoteDataInfo loadInfo; } SSysTableScanInfo; typedef struct SOptrBasicInfo { - SResultRowInfo resultRowInfo; - int32_t* rowCellInfoOffset; // offset value for each row result cell info - SqlFunctionCtx* pCtx; - SSDataBlock* pRes; - int32_t capacity; // TODO remove it + SResultRowInfo resultRowInfo; + int32_t* rowCellInfoOffset; // offset value for each row result cell info + SqlFunctionCtx* pCtx; + SSDataBlock* pRes; + int32_t capacity; // TODO remove it } SOptrBasicInfo; -//TODO move the resultrowsiz together with SOptrBasicInfo:rowCellInfoOffset +// TODO move the resultrowsiz together with SOptrBasicInfo:rowCellInfoOffset typedef struct SAggSupporter { - SHashObj* pResultRowHashTable; // quick locate the window object for each result - SHashObj* pResultRowListSet; // used to check if current ResultRowInfo has ResultRow object or not - SArray* pResultRowArrayList; // The array list that contains the Result rows - char* keyBuf; // window key buffer - SDiskbasedBuf *pResultBuf; // query result buffer based on blocked-wised disk file - int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row + SHashObj* pResultRowHashTable; // quick locate the window object for each result + SHashObj* pResultRowListSet; // used to check if current ResultRowInfo has ResultRow object or not + SArray* pResultRowArrayList; // The array list that contains the Result rows + char* keyBuf; // window key buffer + SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file + int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row } SAggSupporter; typedef struct STableIntervalOperatorInfo { - SOptrBasicInfo binfo; // basic info - SGroupResInfo groupResInfo; // multiple results build supporter - SInterval interval; // interval info - int32_t primaryTsIndex; // primary time stamp slot id from result of downstream operator. - STimeWindow win; // query time range - bool timeWindowInterpo; // interpolation needed or not - char **pRow; // previous row/tuple of already processed datablock - SAggSupporter aggSup; // aggregate supporter - STableQueryInfo *pCurrent; // current tableQueryInfo struct - int32_t order; // current SSDataBlock scan order - EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] - SArray *pUpdatedWindow; // updated time window due to the input data block from the downstream operator. - SColumnInfoData timeWindowData; // query time window info for scalar function execution. + SOptrBasicInfo binfo; // basic info + SGroupResInfo groupResInfo; // multiple results build supporter + SInterval interval; // interval info + int32_t primaryTsIndex; // primary time stamp slot id from result of downstream operator. + STimeWindow win; // query time range + bool timeWindowInterpo; // interpolation needed or not + char** pRow; // previous row/tuple of already processed datablock + SAggSupporter aggSup; // aggregate supporter + STableQueryInfo* pCurrent; // current tableQueryInfo struct + int32_t order; // current SSDataBlock scan order + EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] + SArray* pUpdatedWindow; // updated time window due to the input data block from the downstream operator. + SColumnInfoData timeWindowData; // query time window info for scalar function execution. } STableIntervalOperatorInfo; typedef struct SAggOperatorInfo { - SOptrBasicInfo binfo; - SDiskbasedBuf *pResultBuf; // query result buffer based on blocked-wised disk file - SAggSupporter aggSup; - STableQueryInfo *current; - uint32_t groupId; - SGroupResInfo groupResInfo; - STableQueryInfo *pTableQueryInfo; + SOptrBasicInfo binfo; + SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file + SAggSupporter aggSup; + STableQueryInfo* current; + uint32_t groupId; + SGroupResInfo groupResInfo; + STableQueryInfo* pTableQueryInfo; } SAggOperatorInfo; typedef struct SProjectOperatorInfo { SOptrBasicInfo binfo; SAggSupporter aggSup; - SSDataBlock *existDataBlock; - SArray *pPseudoColInfo; + SSDataBlock* existDataBlock; + SArray* pPseudoColInfo; SLimit limit; SLimit slimit; - uint64_t groupId; - int64_t curSOffset; - int64_t curGroupOutput; + uint64_t groupId; + int64_t curSOffset; + int64_t curGroupOutput; - int64_t curOffset; - int64_t curOutput; + int64_t curOffset; + int64_t curOutput; } SProjectOperatorInfo; typedef struct SFillOperatorInfo { @@ -468,89 +466,88 @@ typedef struct SFillOperatorInfo { } SFillOperatorInfo; typedef struct { - char *pData; - bool isNull; - int16_t type; - int32_t bytes; + char* pData; + bool isNull; + int16_t type; + int32_t bytes; } SGroupKeys, SStateKeys; typedef struct SGroupbyOperatorInfo { - SOptrBasicInfo binfo; - SArray* pGroupCols; - SArray* pGroupColVals; // current group column values, SArray - SNode* pCondition; - bool isInit; // denote if current val is initialized or not - char* keyBuf; // group by keys for hash - int32_t groupKeyLen; // total group by column width - SGroupResInfo groupResInfo; - SAggSupporter aggSup; - SExprInfo* pScalarExprInfo; - int32_t numOfScalarExpr;// the number of scalar expression in group operator - SqlFunctionCtx*pScalarFuncCtx; + SOptrBasicInfo binfo; + SArray* pGroupCols; + SArray* pGroupColVals; // current group column values, SArray + SNode* pCondition; + bool isInit; // denote if current val is initialized or not + char* keyBuf; // group by keys for hash + int32_t groupKeyLen; // total group by column width + SGroupResInfo groupResInfo; + SAggSupporter aggSup; + SExprInfo* pScalarExprInfo; + int32_t numOfScalarExpr; // the number of scalar expression in group operator + SqlFunctionCtx* pScalarFuncCtx; } SGroupbyOperatorInfo; typedef struct SDataGroupInfo { uint64_t groupId; int64_t numOfRows; - SArray *pPageList; + SArray* pPageList; } SDataGroupInfo; // The sort in partition may be needed later. typedef struct SPartitionOperatorInfo { - SOptrBasicInfo binfo; - SArray* pGroupCols; - SArray* pGroupColVals; // current group column values, SArray - char* keyBuf; // group by keys for hash - int32_t groupKeyLen; // total group by column width - SHashObj* pGroupSet; // quick locate the window object for each result + SOptrBasicInfo binfo; + SArray* pGroupCols; + SArray* pGroupColVals; // current group column values, SArray + char* keyBuf; // group by keys for hash + int32_t groupKeyLen; // total group by column width + SHashObj* pGroupSet; // quick locate the window object for each result - SDiskbasedBuf* pBuf; // query result buffer based on blocked-wised disk file - int32_t rowCapacity; // maximum number of rows for each buffer page - int32_t* columnOffset; // start position for each column data + SDiskbasedBuf* pBuf; // query result buffer based on blocked-wised disk file + int32_t rowCapacity; // maximum number of rows for each buffer page + int32_t* columnOffset; // start position for each column data - void* pGroupIter; // group iterator - int32_t pageIndex; // page index of current group + void* pGroupIter; // group iterator + int32_t pageIndex; // page index of current group } SPartitionOperatorInfo; typedef struct SWindowRowsSup { - STimeWindow win; - TSKEY prevTs; - int32_t startRowIndex; - int32_t numOfRows; + STimeWindow win; + TSKEY prevTs; + int32_t startRowIndex; + int32_t numOfRows; } SWindowRowsSup; typedef struct SSessionAggOperatorInfo { - SOptrBasicInfo binfo; - SAggSupporter aggSup; - SGroupResInfo groupResInfo; - SWindowRowsSup winSup; - bool reptScan; // next round scan - int64_t gap; // session window gap - SColumnInfoData timeWindowData; // query time window info for scalar function execution. + SOptrBasicInfo binfo; + SAggSupporter aggSup; + SGroupResInfo groupResInfo; + SWindowRowsSup winSup; + bool reptScan; // next round scan + int64_t gap; // session window gap + SColumnInfoData timeWindowData; // query time window info for scalar function execution. } SSessionAggOperatorInfo; typedef struct STimeSliceOperatorInfo { - SOptrBasicInfo binfo; - SInterval interval; - SGroupResInfo groupResInfo; // multiple results build supporter + SOptrBasicInfo binfo; + SInterval interval; + SGroupResInfo groupResInfo; // multiple results build supporter } STimeSliceOperatorInfo; typedef struct SStateWindowOperatorInfo { - SOptrBasicInfo binfo; - SAggSupporter aggSup; - SGroupResInfo groupResInfo; - SWindowRowsSup winSup; - int32_t colIndex; // start row index - bool hasKey; - SStateKeys stateKey; - SColumnInfoData timeWindowData; // query time window info for scalar function execution. -// bool reptScan; + SOptrBasicInfo binfo; + SAggSupporter aggSup; + SGroupResInfo groupResInfo; + SWindowRowsSup winSup; + int32_t colIndex; // start row index + bool hasKey; + SStateKeys stateKey; + SColumnInfoData timeWindowData; // query time window info for scalar function execution. + // bool reptScan; } SStateWindowOperatorInfo; typedef struct SSortedMergeOperatorInfo { + SOptrBasicInfo binfo; - bool hasVarCol; - SArray* pSortInfo; int32_t numOfSources; SSortHandle *pSortHandle; @@ -566,41 +563,68 @@ typedef struct SSortedMergeOperatorInfo { } SSortedMergeOperatorInfo; typedef struct SSortOperatorInfo { - uint32_t sortBufSize; // max buffer size for in-memory sort - SSDataBlock *pDataBlock; - SArray* pSortInfo; - SSortHandle *pSortHandle; - SArray* inputSlotMap; // for index map from table scan output - int32_t bufPageSize; - int32_t numOfRowsInRes; + uint32_t sortBufSize; // max buffer size for in-memory sort + SSDataBlock* pDataBlock; + SArray* pSortInfo; + SSortHandle* pSortHandle; + SArray* inputSlotMap; // for index map from table scan output + int32_t bufPageSize; + int32_t numOfRowsInRes; // TODO extact struct - int64_t startTs; // sort start time - uint64_t sortElapsed; // sort elapsed time, time to flush to disk not included. - uint64_t totalSize; // total load bytes from remote - uint64_t totalRows; // total number of rows - uint64_t totalElapsed; // total elapsed time + int64_t startTs; // sort start time + uint64_t sortElapsed; // sort elapsed time, time to flush to disk not included. + uint64_t totalSize; // total load bytes from remote + uint64_t totalRows; // total number of rows + uint64_t totalElapsed; // total elapsed time } SSortOperatorInfo; +typedef struct STagFilterOperatorInfo { + SOptrBasicInfo binfo; +} STagFilterOperatorInfo; + +typedef struct SJoinOperatorInfo { + SSDataBlock *pRes; + int32_t joinType; + + SSDataBlock *pLeft; + int32_t leftPos; + SColumnInfo leftCol; + + SSDataBlock *pRight; + int32_t rightPos; + SColumnInfo rightCol; + + SNode *pOnCondition; +// SJoinStatus *status; +// int32_t numOfUpstream; +// SRspResultInfo resultInfo; +} SJoinOperatorInfo; + int32_t operatorDummyOpenFn(SOperatorInfo* pOperator); -void operatorDummyCloseFn(void* param, int32_t numOfCols); +void operatorDummyCloseFn(void* param, int32_t numOfCols); int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t num); int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, int32_t numOfRows, SSDataBlock* pResultBlock, size_t keyBufSize, const char* pkey); -void toSDatablock(SSDataBlock* pBlock, int32_t rowCapacity, SGroupResInfo* pGroupResInfo, SExprInfo* pExprInfo, SDiskbasedBuf* pBuf, int32_t* rowCellOffset); -void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int32_t* rowCellInfoOffset); -void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset, int32_t forwardStep, TSKEY* tsCol, int32_t numOfTotal, int32_t numOfOutput, int32_t order); -int32_t setGroupResultOutputBuf(SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, int16_t type, int16_t bytes, int32_t groupId, SDiskbasedBuf* pBuf, SExecTaskInfo* pTaskInfo, SAggSupporter* pAggSup); -void doDestroyBasicInfo(SOptrBasicInfo* pInfo, int32_t numOfOutput); -int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, - char* pData, int32_t compLen, int32_t numOfOutput, int64_t startTs, - uint64_t* total, SArray* pColList); -void doSetOperatorCompleted(SOperatorInfo* pOperator); -void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock); +void toSDatablock(SSDataBlock* pBlock, int32_t rowCapacity, SGroupResInfo* pGroupResInfo, SExprInfo* pExprInfo, + SDiskbasedBuf* pBuf, int32_t* rowCellOffset); +void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SDiskbasedBuf* pBuf, + SResultRowInfo* pResultRowInfo, int32_t* rowCellInfoOffset); +void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset, + int32_t forwardStep, TSKEY* tsCol, int32_t numOfTotal, int32_t numOfOutput, int32_t order); +int32_t setGroupResultOutputBuf(SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, int16_t type, int16_t bytes, + int32_t groupId, SDiskbasedBuf* pBuf, SExecTaskInfo* pTaskInfo, SAggSupporter* pAggSup); +void doDestroyBasicInfo(SOptrBasicInfo* pInfo, int32_t numOfOutput); +int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, char* pData, + int32_t compLen, int32_t numOfOutput, int64_t startTs, uint64_t* total, + SArray* pColList); +void doSetOperatorCompleted(SOperatorInfo* pOperator); +void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock); SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset); SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfCols, int32_t repeatTime, + +SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfCols, int32_t dataLoadFlag, int32_t repeatTime, int32_t reverseTime, SArray* pColMatchInfo, SSDataBlock* pResBlock, SNode* pCondition, SExecTaskInfo* pTaskInfo); SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); @@ -610,23 +634,36 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* p SOperatorInfo *createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pResBlock, SArray* pSortInfo, SArray* pIndexMap, SExecTaskInfo* pTaskInfo); SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t num, SArray* pSortInfo, SArray* pGroupInfo, SExecTaskInfo* pTaskInfo); + SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataBlock* pResBlock, const SName* pName, - SNode* pCondition, SEpSet epset, SArray* colList, SExecTaskInfo* pTaskInfo, bool showRewrite, int32_t accountId); -SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlot, + SNode* pCondition, SEpSet epset, SArray* colList, + SExecTaskInfo* pTaskInfo, bool showRewrite, int32_t accountId); +SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, + SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlot, const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, int64_t gap, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SArray* pGroupColList, - SNode* pCondition, SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); +SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, + SSDataBlock* pResBlock, int64_t gap, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, + SSDataBlock* pResultBlock, SArray* pGroupColList, SNode* pCondition, + SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo, + const STableGroupInfo* pTableGroupInfo); SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock* pResBlock, SArray* pColList, SArray* pTableIdList, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock* pResBlock, SArray* pColList, + SArray* pTableIdList, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols, SInterval* pInterval, SSDataBlock* pResBlock, - int32_t fillType, char* fillVal, bool multigroupResult, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols, + SInterval* pInterval, SSDataBlock* pResBlock, int32_t fillType, char* fillVal, + bool multigroupResult, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols, + SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SArray* pGroupColList, - SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); -SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, + SSDataBlock* pResultBlock, SArray* pGroupColList, SExecTaskInfo* pTaskInfo, + const STableGroupInfo* pTableGroupInfo); +SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, + SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo); + +SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SNode* pOnCondition, SExecTaskInfo* pTaskInfo); #if 0 SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv); @@ -635,12 +672,10 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntim SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfOutput); SOperatorInfo* createTagScanOperatorInfo(SReaderHandle* pReaderHandle, SExprInfo* pExpr, int32_t numOfOutput); - -SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pdownstream, int32_t numOfDownstream, SSchema* pSchema, - int32_t numOfOutput); #endif -void projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx, int32_t numOfOutput, SArray* pPseudoList); +void projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx, + int32_t numOfOutput, SArray* pPseudoList); void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order); @@ -652,23 +687,27 @@ STableQueryInfo* createTableQueryInfo(void* buf, bool groupbyColumn, STimeWindow bool isTaskKilled(SExecTaskInfo* pTaskInfo); int32_t checkForQueryBuf(size_t numOfTables); -void setTaskKilled(SExecTaskInfo* pTaskInfo); +void setTaskKilled(SExecTaskInfo* pTaskInfo); void publishOperatorProfEvent(SOperatorInfo* operatorInfo, EQueryProfEventType eventType); void publishQueryAbortEvent(SExecTaskInfo* pTaskInfo, int32_t code); void queryCostStatis(SExecTaskInfo* pTaskInfo); -void doDestroyTask(SExecTaskInfo* pTaskInfo); +void doDestroyTask(SExecTaskInfo* pTaskInfo); int32_t getMaximumIdleDurationSec(); void doInvokeUdf(struct SUdfInfo* pUdfInfo, SqlFunctionCtx* pCtx, int32_t idx, int32_t type); void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status); -int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, EOPTR_EXEC_MODEL model); -int32_t getOperatorExplainExecInfo(SOperatorInfo *operatorInfo, SExplainExecInfo **pRes, int32_t *capacity, int32_t *resNum); +int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, + EOPTR_EXEC_MODEL model); +int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SExplainExecInfo** pRes, int32_t* capacity, + int32_t* resNum); -bool aggDecodeResultRow(SOperatorInfo* pOperator, SAggSupporter *pSup, SOptrBasicInfo *pInfo, char* result, int32_t length); -void aggEncodeResultRow(SOperatorInfo* pOperator, SAggSupporter *pSup, SOptrBasicInfo *pInfo, char **result, int32_t *length); +bool aggDecodeResultRow(SOperatorInfo* pOperator, SAggSupporter* pSup, SOptrBasicInfo* pInfo, char* result, + int32_t length); +void aggEncodeResultRow(SOperatorInfo* pOperator, SAggSupporter* pSup, SOptrBasicInfo* pInfo, char** result, + int32_t* length); #ifdef __cplusplus } diff --git a/source/libs/executor/inc/indexoperator.h b/source/libs/executor/inc/indexoperator.h new file mode 100644 index 0000000000..9e67ac7f41 --- /dev/null +++ b/source/libs/executor/inc/indexoperator.h @@ -0,0 +1,23 @@ +/* + * 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 "filter.h" +#include "tglobal.h" + +typedef enum { SFLT_NOT_INDEX, SFLT_COARSE_INDEX, SFLT_ACCURATE_INDEX } SIdxFltStatus; + +SIdxFltStatus idxGetFltStatus(SNode *pFilterNode); +// construct tag filter operator later +int32_t doFilterTag(const SNode *pFilterNode, SArray *resutl); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 14acff3204..3e2f95a27c 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -271,7 +271,7 @@ static int compareRowData(const void* a, const void* b, const void* userData) { } // setup the output buffer for each operator -SSDataBlock* createOutputBuf_rv1(SDataBlockDescNode* pNode) { +SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) { int32_t numOfCols = LIST_LENGTH(pNode->pSlots); SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); @@ -2004,7 +2004,7 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) { bool hasFirstLastFunc = false; bool hasOtherFunc = false; - if (status == BLK_DATA_ALL_NEEDED || status == BLK_DATA_DISCARD) { + if (status == BLK_DATA_DATA_LOAD || status == BLK_DATA_FILTEROUT) { return status; } @@ -2023,11 +2023,11 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) { } } - if (hasFirstLastFunc && status == BLK_DATA_NO_NEEDED) { + if (hasFirstLastFunc && status == BLK_DATA_NOT_LOAD) { if (!hasOtherFunc) { - return BLK_DATA_DISCARD; + return BLK_DATA_FILTEROUT; } else { - return BLK_DATA_ALL_NEEDED; + return BLK_DATA_DATA_LOAD; } } @@ -2360,7 +2360,7 @@ static void doSetTagValueInParam(void* pTable, int32_t tagColId, SVarian static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock) { SqlFunctionCtx* pCtx = pTableScanInfo->pCtx; - uint32_t status = BLK_DATA_NO_NEEDED; + uint32_t status = BLK_DATA_NOT_LOAD; int32_t numOfOutput = pTableScanInfo->numOfOutput; for (int32_t i = 0; i < numOfOutput; ++i) { @@ -2369,11 +2369,11 @@ static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSData // group by + first/last should not apply the first/last block filter if (functionId < 0) { - status |= BLK_DATA_ALL_NEEDED; + status |= BLK_DATA_DATA_LOAD; return status; } else { // status |= aAggs[functionId].dataReqFunc(&pTableScanInfo->pCtx[i], &pBlock->info.window, colId); - // if ((status & BLK_DATA_ALL_NEEDED) == BLK_DATA_ALL_NEEDED) { + // if ((status & BLK_DATA_DATA_LOAD) == BLK_DATA_DATA_LOAD) { // return status; // } } @@ -2384,7 +2384,7 @@ static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSData int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, uint32_t* status) { - *status = BLK_DATA_NO_NEEDED; + *status = BLK_DATA_NOT_LOAD; pBlock->pDataBlock = NULL; pBlock->pBlockAgg = NULL; @@ -2397,36 +2397,15 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc pCost->totalBlocks += 1; pCost->totalRows += pBlock->info.rows; #if 0 - if (pRuntimeEnv->pTsBuf != NULL) { - (*status) = BLK_DATA_ALL_NEEDED; - - if (pQueryAttr->stableQuery) { // todo refactor - SExprInfo* pExprInfo = &pTableScanInfo->pExpr[0]; - int16_t tagId = (int16_t)pExprInfo->base.param[0].i; - SColumnInfo* pColInfo = doGetTagColumnInfoById(pQueryAttr->tagColList, pQueryAttr->numOfTags, tagId); - - // compare tag first - SVariant t = {0}; - doSetTagValueInParam(pRuntimeEnv->current->pTable, tagId, &t, pColInfo->type, pColInfo->bytes); - setTimestampListJoinInfo(pRuntimeEnv, &t, pRuntimeEnv->current); - - STSElem elem = tsBufGetElem(pRuntimeEnv->pTsBuf); - if (!tsBufIsValidElem(&elem) || (tsBufIsValidElem(&elem) && (taosVariantCompare(&t, elem.tag) != 0))) { - (*status) = BLK_DATA_DISCARD; - return TSDB_CODE_SUCCESS; - } - } - } - // Calculate all time windows that are overlapping or contain current data block. // If current data block is contained by all possible time window, do not load current data block. if (/*pQueryAttr->pFilters || */pQueryAttr->groupbyColumn || pQueryAttr->sw.gap > 0 || (QUERY_IS_INTERVAL_QUERY(pQueryAttr) && overlapWithTimeWindow(pTaskInfo, &pBlock->info))) { - (*status) = BLK_DATA_ALL_NEEDED; + (*status) = BLK_DATA_DATA_LOAD; } // check if this data block is required to load - if ((*status) != BLK_DATA_ALL_NEEDED) { + if ((*status) != BLK_DATA_DATA_LOAD) { bool needFilter = true; // the pCtx[i] result is belonged to previous time window since the outputBuf has not been set yet, @@ -2458,18 +2437,18 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc if (needFilter) { (*status) = doFilterByBlockTimeWindow(pTableScanInfo, pBlock); } else { - (*status) = BLK_DATA_ALL_NEEDED; + (*status) = BLK_DATA_DATA_LOAD; } } SDataBlockInfo* pBlockInfo = &pBlock->info; // *status = updateBlockLoadStatus(pRuntimeEnv->pQueryAttr, *status); - if ((*status) == BLK_DATA_NO_NEEDED || (*status) == BLK_DATA_DISCARD) { + if ((*status) == BLK_DATA_NOT_LOAD || (*status) == BLK_DATA_FILTEROUT) { //qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey, // pBlockInfo->window.ekey, pBlockInfo->rows); pCost->discardBlocks += 1; - } else if ((*status) == BLK_DATA_STATIS_NEEDED) { + } else if ((*status) == BLK_DATA_SMA_LOAD) { // this function never returns error? pCost->loadBlockStatis += 1; // tsdbRetrieveDataBlockStatisInfo(pTableScanInfo->pTsdbReadHandle, &pBlock->pBlockAgg); @@ -2479,7 +2458,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc pCost->totalCheckedRows += pBlock->info.rows; } } else { - assert((*status) == BLK_DATA_ALL_NEEDED); + assert((*status) == BLK_DATA_DATA_LOAD); // load the data block statistics to perform further filter pCost->loadBlockStatis += 1; @@ -2511,7 +2490,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc pCost->discardBlocks += 1; //qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, // pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); - (*status) = BLK_DATA_DISCARD; + (*status) = BLK_DATA_FILTEROUT; return TSDB_CODE_SUCCESS; } } @@ -2523,7 +2502,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc // pCost->discardBlocks += 1; // qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey, // pBlockInfo->window.ekey, pBlockInfo->rows); -// (*status) = BLK_DATA_DISCARD; +// (*status) = BLK_DATA_FILTEROUT; // return TSDB_CODE_SUCCESS; // } @@ -6539,8 +6518,6 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator, bool* newgroup) { SOperatorInfo* createTagScanOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SExprInfo* pExpr, int32_t numOfOutput) { STagScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STagScanInfo)); - // pInfo->pRes = createOutputBuf(pExpr, numOfOutput, pResultInfo->capacity); - size_t numOfGroup = GET_NUM_OF_TABLEGROUP(pRuntimeEnv); assert(numOfGroup == 0 || numOfGroup == 1); @@ -6600,10 +6577,10 @@ bool validateExprColumnInfo(SQueriedTableInfo* pTableInfo, SExprBasicInfo* pExpr static SResSchema createResSchema(int32_t type, int32_t bytes, int32_t slotId, int32_t scale, int32_t precision, const char* name) { SResSchema s = {0}; - s.scale = scale; - s.type = type; - s.bytes = bytes; - s.slotId = slotId; + s.scale = scale; + s.type = type; + s.bytes = bytes; + s.slotId = slotId; s.precision = precision; strncpy(s.name, name, tListLen(s.name)); @@ -6679,8 +6656,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* SFunctionNode* pFuncNode = (SFunctionNode*)pTargetNode->pExpr; SDataType* pType = &pFuncNode->node.resType; - pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale, - pType->precision, pFuncNode->node.aliasName); + pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale, pType->precision, pFuncNode->node.aliasName); pExp->pExpr->_function.functionId = pFuncNode->funcId; pExp->pExpr->_function.pFunctNode = pFuncNode; @@ -6756,22 +6732,27 @@ static SArray* createIndexMap(SNodeList* pNodeList); static SArray* extractPartitionColInfo(SNodeList* pNodeList); SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle, - uint64_t queryId, uint64_t taskId, STableGroupInfo* pTableGroupInfo) { + uint64_t queryId, uint64_t taskId, STableGroupInfo* pTableGroupInfo) { if (pPhyNode->pChildren == NULL || LIST_LENGTH(pPhyNode->pChildren) == 0) { int32_t type = nodeType(pPhyNode); if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == type) { SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode; + STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode* ) pPhyNode; int32_t numOfCols = 0; - tsdbReaderT pDataReader = doCreateDataReader((STableScanPhysiNode*)pPhyNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId); - SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols); - SSDataBlock* pResBlock = createOutputBuf_rv1(pScanPhyNode->node.pOutputDataBlockDesc); + tsdbReaderT pDataReader = doCreateDataReader(pTableScanNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId); + if (pDataReader == NULL) { + return NULL; + } - return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, pScanPhyNode->count, + SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols); + SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc); + + return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, pTableScanNode->dataRequired, pScanPhyNode->count, pScanPhyNode->reverse, pColList, pResBlock, pScanPhyNode->node.pConditions, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) { SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pPhyNode; - SSDataBlock* pResBlock = createOutputBuf_rv1(pExchange->node.pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pExchange->node.pOutputDataBlockDesc); return createExchangeOperatorInfo(pExchange->pSrcEndPoints, pResBlock, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) { SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode; // simple child table. @@ -6779,7 +6760,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo int32_t code = doCreateTableGroup(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableGroupInfo, queryId, taskId); SArray* tableIdList = extractTableIdList(pTableGroupInfo); - SSDataBlock* pResBlock = createOutputBuf_rv1(pScanPhyNode->node.pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc); int32_t numOfCols = 0; SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols); @@ -6788,7 +6769,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return pOperator; } else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) { SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode; - SSDataBlock* pResBlock = createOutputBuf_rv1(pSysScanPhyNode->scan.node.pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pSysScanPhyNode->scan.node.pOutputDataBlockDesc); struct SScanPhysiNode* pScanNode = &pSysScanPhyNode->scan; SArray* colList = extractScanColumnId(pScanNode->pScanCols); @@ -6802,26 +6783,29 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo } } + int32_t num = 0; int32_t type = nodeType(pPhyNode); - size_t size = LIST_LENGTH(pPhyNode->pChildren); - ASSERT(size == 1); + size_t size = LIST_LENGTH(pPhyNode->pChildren); - SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, 0); - SOperatorInfo* op = createOperatorTree(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo); - int32_t num = 0; + SOperatorInfo** ops = taosMemoryCalloc(size, POINTER_BYTES); + for(int32_t i = 0; i < size; ++i) { + SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, i); + ops[i] = createOperatorTree(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo); + } + SOperatorInfo* pOptr = NULL; if (QUERY_NODE_PHYSICAL_PLAN_PROJECT == type) { SProjectPhysiNode* pProjPhyNode = (SProjectPhysiNode*) pPhyNode; SExprInfo* pExprInfo = createExprInfo(pProjPhyNode->pProjections, NULL, &num); - SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); SLimit limit = {.limit = pProjPhyNode->limit, .offset = pProjPhyNode->offset}; SLimit slimit = {.limit = pProjPhyNode->slimit, .offset = pProjPhyNode->soffset}; - return createProjectOperatorInfo(op, pExprInfo, num, pResBlock, &limit, &slimit, pTaskInfo); + pOptr = createProjectOperatorInfo(ops[0], pExprInfo, num, pResBlock, &limit, &slimit, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_AGG == type) { SAggPhysiNode* pAggNode = (SAggPhysiNode*)pPhyNode; SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num); - SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); SExprInfo* pScalarExprInfo = NULL; int32_t numOfScalarExpr = 0; @@ -6831,15 +6815,15 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pScalarExprInfo = createExprInfo(pAggNode->pExprs, NULL, &numOfScalarExpr); } - return createGroupOperatorInfo(op, pExprInfo, num, pResBlock, pColList, pAggNode->node.pConditions, pScalarExprInfo, numOfScalarExpr, pTaskInfo, NULL); + pOptr = createGroupOperatorInfo(ops[0], pExprInfo, num, pResBlock, pColList, pAggNode->node.pConditions, pScalarExprInfo, numOfScalarExpr, pTaskInfo, NULL); } else { - return createAggregateOperatorInfo(op, pExprInfo, num, pResBlock, pTaskInfo, pTableGroupInfo); + pOptr = createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pTaskInfo, pTableGroupInfo); } } else if (QUERY_NODE_PHYSICAL_PLAN_INTERVAL == type) { SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode; SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &num); - SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); SInterval interval = { .interval = pIntervalPhyNode->interval, @@ -6851,33 +6835,39 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo }; int32_t primaryTsSlotId = ((SColumnNode*) pIntervalPhyNode->window.pTspk)->slotId; - return createIntervalOperatorInfo(op, pExprInfo, num, pResBlock, &interval, primaryTsSlotId, pTableGroupInfo, pTaskInfo); + pOptr = createIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, primaryTsSlotId, pTableGroupInfo, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_SORT == type) { SSortPhysiNode* pSortPhyNode = (SSortPhysiNode*)pPhyNode; - SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); SArray* info = createSortInfo(pSortPhyNode->pSortKeys, pSortPhyNode->pTargets); SArray* slotMap = createIndexMap(pSortPhyNode->pTargets); - return createSortOperatorInfo(op, pResBlock, info, slotMap, pTaskInfo); + pOptr = createSortOperatorInfo(ops[0], pResBlock, info, slotMap, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW == type) { SSessionWinodwPhysiNode* pSessionNode = (SSessionWinodwPhysiNode*)pPhyNode; SExprInfo* pExprInfo = createExprInfo(pSessionNode->window.pFuncs, NULL, &num); - SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); - return createSessionAggOperatorInfo(op, pExprInfo, num, pResBlock, pSessionNode->gap, pTaskInfo); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); + pOptr = createSessionAggOperatorInfo(ops[0], pExprInfo, num, pResBlock, pSessionNode->gap, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_PARTITION == type) { SPartitionPhysiNode* pPartNode = (SPartitionPhysiNode*) pPhyNode; SArray* pColList = extractPartitionColInfo(pPartNode->pPartitionKeys); - SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); SExprInfo* pExprInfo = createExprInfo(pPartNode->pTargets, NULL, &num); - return createPartitionOperatorInfo(op, pExprInfo, num, pResBlock, pColList, pTaskInfo, NULL); - } else if (QUERY_NODE_STATE_WINDOW == type) { + pOptr = createPartitionOperatorInfo(ops[0], pExprInfo, num, pResBlock, pColList, pTaskInfo, NULL); + } else if (QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW == type) { SStateWinodwPhysiNode* pStateNode = (SStateWinodwPhysiNode*) pPhyNode; SExprInfo* pExprInfo = createExprInfo(pStateNode->window.pFuncs, NULL, &num); - SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); - return createStatewindowOperatorInfo(op, pExprInfo, num, pResBlock, pTaskInfo); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); + pOptr = createStatewindowOperatorInfo(ops[0], pExprInfo, num, pResBlock, pTaskInfo); + } else if (QUERY_NODE_PHYSICAL_PLAN_JOIN == type) { + SJoinPhysiNode* pJoinNode = (SJoinPhysiNode*) pPhyNode; + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); + + SExprInfo* pExprInfo = createExprInfo(pJoinNode->pTargets, NULL, &num); + pOptr = createJoinOperatorInfo(ops, size, pExprInfo, num, pResBlock, pJoinNode->pOnConditions, pTaskInfo); } else { ASSERT(0); } /*else if (pPhyNode->info.type == OP_MultiTableAggregate) { @@ -6890,7 +6880,9 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return createMultiTableAggOperatorInfo(op, pPhyNode->pTargets, pTaskInfo, pTableGroupInfo); } }*/ - return NULL; + + taosMemoryFree(ops); + return pOptr; } static tsdbReaderT createDataReaderImpl(STableScanPhysiNode* pTableScanNode, STableGroupInfo* pGroupInfo, @@ -7374,4 +7366,135 @@ int32_t getOperatorExplainExecInfo(SOperatorInfo *operatorInfo, SExplainExecInfo return TSDB_CODE_SUCCESS; } +static SSDataBlock* doMergeJoin(struct SOperatorInfo* pOperator, bool* newgroup) { + SJoinOperatorInfo* pJoinInfo = pOperator->info; +// SOptrBasicInfo* pInfo = &pJoinInfo->binfo; + SSDataBlock* pRes = pJoinInfo->pRes; + blockDataCleanup(pRes); + blockDataEnsureCapacity(pRes, 4096); + + int32_t nrows = 0; + + while (1) { + bool prevVal = *newgroup; + + if (pJoinInfo->pLeft == NULL || pJoinInfo->leftPos >= pJoinInfo->pLeft->info.rows) { + SOperatorInfo* ds1 = pOperator->pDownstream[0]; + publishOperatorProfEvent(ds1, QUERY_PROF_BEFORE_OPERATOR_EXEC); + pJoinInfo->pLeft = ds1->getNextFn(ds1, newgroup); + publishOperatorProfEvent(ds1, QUERY_PROF_AFTER_OPERATOR_EXEC); + + pJoinInfo->leftPos = 0; + if (pJoinInfo->pLeft == NULL) { + setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); + break; + } + } + + if (pJoinInfo->pRight == NULL || pJoinInfo->rightPos >= pJoinInfo->pRight->info.rows) { + SOperatorInfo* ds2 = pOperator->pDownstream[1]; + publishOperatorProfEvent(ds2, QUERY_PROF_BEFORE_OPERATOR_EXEC); + pJoinInfo->pRight = ds2->getNextFn(ds2, newgroup); + publishOperatorProfEvent(ds2, QUERY_PROF_AFTER_OPERATOR_EXEC); + + pJoinInfo->rightPos = 0; + if (pJoinInfo->pRight == NULL) { + setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); + break; + } + } + + SColumnInfoData* pLeftCol = taosArrayGet(pJoinInfo->pLeft->pDataBlock, pJoinInfo->leftCol.slotId); + char* pLeftVal = colDataGetData(pLeftCol, pJoinInfo->leftPos); + + SColumnInfoData* pRightCol = taosArrayGet(pJoinInfo->pRight->pDataBlock, pJoinInfo->rightCol.slotId); + char* pRightVal = colDataGetData(pRightCol, pJoinInfo->rightPos); + + // only the timestamp match support for ordinary table + ASSERT(pLeftCol->info.type == TSDB_DATA_TYPE_TIMESTAMP); + if (*(int64_t*) pLeftVal == *(int64_t*) pRightVal) { + for(int32_t i = 0; i < pOperator->numOfOutput; ++i) { + SColumnInfoData* pDst = taosArrayGet(pRes->pDataBlock, i); + + SExprInfo* pExprInfo = &pOperator->pExpr[i]; + + int32_t blockId = pExprInfo->base.pParam[0].pCol->dataBlockId; + int32_t slotId = pExprInfo->base.pParam[0].pCol->slotId; + + SColumnInfoData* pSrc = NULL; + if (pJoinInfo->pLeft->info.blockId == blockId) { + pSrc = taosArrayGet(pJoinInfo->pLeft->pDataBlock, slotId); + } else { + pSrc = taosArrayGet(pJoinInfo->pRight->pDataBlock, slotId); + } + + if (colDataIsNull_s(pSrc, pJoinInfo->leftPos)) { + colDataAppendNULL(pDst, nrows); + } else { + char* p = colDataGetData(pSrc, pJoinInfo->leftPos); + colDataAppend(pDst, nrows, p, false); + } + } + + pJoinInfo->leftPos += 1; + pJoinInfo->rightPos += 1; + + nrows += 1; + } else if (*(int64_t*) pLeftVal < *(int64_t*) pRightVal) { + pJoinInfo->leftPos += 1; + + if (pJoinInfo->leftPos >= pJoinInfo->pLeft->info.rows) { + continue; + } + } else if (*(int64_t*) pLeftVal > *(int64_t*) pRightVal) { + pJoinInfo->rightPos += 1; + if (pJoinInfo->rightPos >= pJoinInfo->pRight->info.rows) { + continue; + } + } + + // the pDataBlock are always the same one, no need to call this again + pRes->info.rows = nrows; + if (pRes->info.rows >= pOperator->resultInfo.threshold) { + break; + } + } + + return (pRes->info.rows > 0) ? pRes : NULL; +} + +SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SNode* pOnCondition, SExecTaskInfo* pTaskInfo) { + SJoinOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SJoinOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + if (pOperator == NULL || pInfo == NULL) { + goto _error; + } + + pOperator->resultInfo.capacity = 4096; + pOperator->resultInfo.threshold = 4096 * 0.75; + +// initResultRowInf +// o(&pInfo->binfo.resultRowInfo, 8); + pInfo->pRes = pResBlock; + + pOperator->name = "JoinOperator"; + pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_JOIN; + pOperator->blockingOptr = true; + pOperator->status = OP_NOT_OPENED; + pOperator->pExpr = pExprInfo; + pOperator->numOfOutput = numOfCols; + pOperator->info = pInfo; + pOperator->pTaskInfo = pTaskInfo; + pOperator->getNextFn = doMergeJoin; + pOperator->closeFn = destroyBasicOperatorInfo; + + int32_t code = appendDownstream(pOperator, pDownstream, numOfDownstream); + return pOperator; + + _error: + taosMemoryFree(pInfo); + taosMemoryFree(pOperator); + pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; + return NULL; +} \ No newline at end of file diff --git a/source/libs/executor/src/indexoperator.c b/source/libs/executor/src/indexoperator.c new file mode 100644 index 0000000000..b5b9cdb740 --- /dev/null +++ b/source/libs/executor/src/indexoperator.c @@ -0,0 +1,198 @@ +/* + * 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 "indexoperator.h" +#include "executorimpl.h" +#include "nodes.h" + +typedef struct SIFCtx { + int32_t code; + SHashObj *pRes; /* element is SScalarParam */ +} SIFCtx; + +typedef struct SIFParam { + SArray * result; + SHashObj *pFilter; +} SIFParam; +// construct tag filter operator later +static void destroyTagFilterOperatorInfo(void *param) { + STagFilterOperatorInfo *pInfo = (STagFilterOperatorInfo *)param; +} + +static void sifFreeParam(SIFParam *param) { + if (param == NULL) return; + taosArrayDestroy(param->result); +} + +int32_t sifInitOperParams(SIFParam *params, SOperatorNode *node, SIFCtx *ctx) { + int32_t code = 0; + return code; +} +static int32_t sifExecFunction(SFunctionNode *node, SIFCtx *ctx, SIFParam *output) { + qError("index-filter not support buildin function"); + return TSDB_CODE_SUCCESS; +} +static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) { + SIFParam *params = NULL; + + return TSDB_CODE_SUCCESS; +} + +static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *output) { return TSDB_CODE_SUCCESS; } + +static EDealRes sifWalkFunction(SNode *pNode, void *context) { + // impl later + SFunctionNode *node = (SFunctionNode *)pNode; + SIFParam output = {0}; + + SIFCtx *ctx = context; + ctx->code = sifExecFunction(node, ctx, &output); + if (ctx->code != TSDB_CODE_SUCCESS) { + return DEAL_RES_ERROR; + } + + if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) { + ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + return DEAL_RES_ERROR; + } + return DEAL_RES_CONTINUE; +} +static EDealRes sifWalkLogic(SNode *pNode, void *context) { + SLogicConditionNode *node = (SLogicConditionNode *)pNode; + SIFParam output = {0}; + + SIFCtx *ctx = context; + ctx->code = sifExecLogic(node, ctx, &output); + if (ctx->code) { + return DEAL_RES_ERROR; + } + + if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) { + ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + return DEAL_RES_ERROR; + } + return DEAL_RES_CONTINUE; +} +static EDealRes sifWalkOper(SNode *pNode, void *context) { + SOperatorNode *node = (SOperatorNode *)pNode; + SIFParam output = {0}; + + SIFCtx *ctx = context; + ctx->code = sifExecOper(node, ctx, &output); + if (ctx->code) { + return DEAL_RES_ERROR; + } + + if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) { + ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + return DEAL_RES_ERROR; + } + + return DEAL_RES_CONTINUE; +} + +EDealRes sifCalcWalker(SNode *node, void *context) { + if (QUERY_NODE_VALUE == nodeType(node) || QUERY_NODE_NODE_LIST == nodeType(node) || + QUERY_NODE_COLUMN == nodeType(node)) { + return DEAL_RES_CONTINUE; + } + SIFCtx *ctx = (SIFCtx *)context; + if (QUERY_NODE_FUNCTION == nodeType(node)) { + return sifWalkFunction(node, ctx); + } + if (QUERY_NODE_LOGIC_CONDITION == nodeType(node)) { + return sifWalkLogic(node, ctx); + } + if (QUERY_NODE_OPERATOR == nodeType(node)) { + return sifWalkOper(node, ctx); + } + + qError("invalid node type for index filter calculating, type:%d", nodeType(node)); + ctx->code = TSDB_CODE_QRY_INVALID_INPUT; + return DEAL_RES_ERROR; +} + +void sifFreeRes(SHashObj *res) { + void *pIter = taosHashIterate(res, NULL); + while (pIter) { + SIFParam *p = pIter; + if (p) { + sifFreeParam(p); + } + pIter = taosHashIterate(res, pIter); + } + taosHashCleanup(res); +} +static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) { + if (pNode == NULL || pDst == NULL) { + return TSDB_CODE_QRY_INVALID_INPUT; + } + int32_t code = 0; + SIFCtx ctx = {.code = 0}; + ctx.pRes = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); + if (NULL == ctx.pRes) { + qError("index-filter failed to taosHashInit"); + return TSDB_CODE_QRY_OUT_OF_MEMORY; + } + nodesWalkExprPostOrder(pNode, sifCalcWalker, &ctx); + if (ctx.code != TSDB_CODE_SUCCESS) { + return ctx.code; + } + if (pDst) { + SIFParam *res = (SIFParam *)taosHashGet(ctx.pRes, (void *)&pNode, POINTER_BYTES); + if (res == NULL) { + qError("no valid res in hash, node:(%p), type(%d)", (void *)&pNode, nodeType(pNode)); + return TSDB_CODE_QRY_APP_ERROR; + } + taosArrayAddAll(pDst->result, res->result); + + sifFreeParam(res); + taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES); + } + return TSDB_CODE_SUCCESS; +} + +int32_t doFilterTag(const SNode *pFilterNode, SArray *result) { + if (pFilterNode == NULL) { + return TSDB_CODE_SUCCESS; + } + + SFilterInfo *filter = NULL; + // todo move to the initialization function + int32_t code = filterInitFromNode((SNode *)pFilterNode, &filter, 0); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + SIFParam param = {0}; + code = sifCalculate((SNode *)pFilterNode, ¶m); + + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + taosArrayAddAll(result, param.result); + sifFreeParam(¶m); + + return code; +} + +SIdxFltStatus idxGetFltStatus(SNode *pFilterNode) { + if (pFilterNode == NULL) { + return SFLT_NOT_INDEX; + } + // impl later + return SFLT_ACCURATE_INDEX; +} diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 0286b6e6e9..3de9d9020e 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -64,16 +64,19 @@ static void setupQueryRangeForReverseScan(STableScanInfo* pTableScanInfo) { #endif } -int32_t loadDataBlock(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, uint32_t* status) { +int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, uint32_t* status) { + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + STableScanInfo* pInfo = pOperator->info; + STaskCostInfo* pCost = &pTaskInfo->cost; pCost->totalBlocks += 1; + pCost->loadBlocks += 1; + pCost->totalRows += pBlock->info.rows; - pCost->totalCheckedRows += pBlock->info.rows; - pCost->loadBlocks += 1; - *status = BLK_DATA_ALL_NEEDED; + *status = pInfo->dataBlockLoadFlag; SArray* pCols = tsdbRetrieveDataBlock(pTableScanInfo->dataReader, NULL); if (pCols == NULL) { @@ -138,15 +141,15 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) { // } // this function never returns error? - uint32_t status = BLK_DATA_ALL_NEEDED; - int32_t code = loadDataBlock(pTaskInfo, pTableScanInfo, pBlock, &status); + uint32_t status = BLK_DATA_DATA_LOAD; + int32_t code = loadDataBlock(pOperator, pTableScanInfo, pBlock, &status); // int32_t code = loadDataBlockOnDemand(pOperator->pRuntimeEnv, pTableScanInfo, pBlock, &status); if (code != TSDB_CODE_SUCCESS) { longjmp(pOperator->pTaskInfo->env, code); } // current block is ignored according to filter result by block statistics data, continue load the next block - if (status == BLK_DATA_DISCARD || pBlock->info.rows == 0) { + if (status == BLK_DATA_FILTEROUT || pBlock->info.rows == 0) { continue; } @@ -217,7 +220,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) { return p; } -SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfOutput, +SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfOutput, int32_t dataLoadFlag, int32_t repeatTime, int32_t reverseTime, SArray* pColMatchInfo, SSDataBlock* pResBlock, SNode* pCondition, SExecTaskInfo* pTaskInfo) { assert(repeatTime > 0); @@ -232,6 +235,7 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, return NULL; } + pInfo->dataBlockLoadFlag= dataLoadFlag; pInfo->pResBlock = pResBlock; pInfo->pFilterNode = pCondition; pInfo->dataReader = pTsdbReadHandle; diff --git a/source/libs/function/inc/builtins.h b/source/libs/function/inc/builtins.h index 814076fc34..fb36c9d978 100644 --- a/source/libs/function/inc/builtins.h +++ b/source/libs/function/inc/builtins.h @@ -37,6 +37,7 @@ extern "C" { #define FUNC_MGT_WINDOW_PC_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(8) #define FUNC_MGT_SPECIAL_DATA_REQUIRED FUNC_MGT_FUNC_CLASSIFICATION_MASK(9) #define FUNC_MGT_DYNAMIC_SCAN_OPTIMIZED FUNC_MGT_FUNC_CLASSIFICATION_MASK(10) +#define FUNC_MGT_MULTI_RES_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(11) #define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 120119610d..fb647f0b9e 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -209,9 +209,9 @@ static int32_t translateLastRow(SFunctionNode* pFunc, char* pErrBuf, int32_t len } static int32_t translateFirstLast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { - // first(*)/first(col_list) has been rewritten as first(col) + // first(col_list) will be rewritten as first(col) if (1 != LIST_LENGTH(pFunc->pParameterList)) { - return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + return TSDB_CODE_SUCCESS; } SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); @@ -376,6 +376,20 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le return TSDB_CODE_SUCCESS; } +static int32_t translateToJson(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + SExprNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); + if (QUERY_NODE_VALUE != nodeType(pPara) || (!IS_VAR_DATA_TYPE(pPara->resType.type))) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_JSON].bytes, .type = TSDB_DATA_TYPE_JSON}; + return TSDB_CODE_SUCCESS; +} + const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "count", @@ -481,7 +495,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "last_row", .type = FUNCTION_TYPE_LAST_ROW, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC, .translateFunc = translateLastRow, .getEnvFunc = getMinmaxFuncEnv, .initFunc = maxFunctionSetup, @@ -491,7 +505,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "first", .type = FUNCTION_TYPE_FIRST, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC, .translateFunc = translateFirstLast, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, @@ -501,7 +515,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "last", .type = FUNCTION_TYPE_LAST, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC, .translateFunc = translateFirstLast, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, @@ -887,6 +901,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .initFunc = NULL, .sprocessFunc = winDurFunction, .finalizeFunc = NULL + }, + { + .name = "to_json", + .type = FUNCTION_TYPE_TO_JSON, + .classification = FUNC_MGT_SCALAR_FUNC, + .translateFunc = translateToJson, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = NULL, + .finalizeFunc = NULL } }; diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 50c65439c0..71e8bcc842 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -58,9 +58,9 @@ void functionFinalize(SqlFunctionCtx *pCtx) { EFuncDataRequired countDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) { SNode* pParam = nodesListGetNode(pFunc->pParameterList, 0); if (QUERY_NODE_COLUMN == nodeType(pParam) && PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)pParam)->colId) { - return FUNC_DATA_REQUIRED_NO_NEEDED; + return FUNC_DATA_REQUIRED_NOT_LOAD; } - return FUNC_DATA_REQUIRED_STATIS_NEEDED; + return FUNC_DATA_REQUIRED_STATIS_LOAD; } bool getCountFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index aec75a0365..9500064949 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -78,10 +78,10 @@ int32_t fmGetFuncResultType(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) { if (pFunc->funcId < 0 || pFunc->funcId >= funcMgtBuiltinsNum) { - return FUNC_DATA_REQUIRED_ALL_NEEDED; + return FUNC_DATA_REQUIRED_DATA_LOAD; } if (NULL == funcMgtBuiltins[pFunc->funcId].dataRequiredFunc) { - return FUNC_DATA_REQUIRED_ALL_NEEDED; + return FUNC_DATA_REQUIRED_DATA_LOAD; } return funcMgtBuiltins[pFunc->funcId].dataRequiredFunc(pFunc, pTimeWindow); } @@ -138,6 +138,10 @@ bool fmIsDynamicScanOptimizedFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_DYNAMIC_SCAN_OPTIMIZED); } +bool fmIsMultiResFunc(int32_t funcId) { + return isSpecificClassifyFunc(funcId, FUNC_MGT_MULTI_RES_FUNC); +} + void fmFuncMgtDestroy() { void* m = gFunMgtService.pFuncNameHashTable; if (m != NULL && atomic_val_compare_exchange_ptr((void**)&gFunMgtService.pFuncNameHashTable, m, 0) == m) { diff --git a/source/libs/function/src/taggfunction.c b/source/libs/function/src/taggfunction.c index 60566d00d8..e001ef4071 100644 --- a/source/libs/function/src/taggfunction.c +++ b/source/libs/function/src/taggfunction.c @@ -557,14 +557,14 @@ static void count_func_merge(SqlFunctionCtx *pCtx) { */ int32_t countRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { if (colId == PRIMARYKEY_TIMESTAMP_COL_ID) { - return BLK_DATA_NO_NEEDED; + return BLK_DATA_NOT_LOAD; } else { - return BLK_DATA_STATIS_NEEDED; + return BLK_DATA_SMA_LOAD; } } int32_t noDataRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { - return BLK_DATA_NO_NEEDED; + return BLK_DATA_NOT_LOAD; } #define LIST_ADD_N_DOUBLE_FLOAT(x, ctx, p, t, numOfElem, tsdbType) \ do { \ @@ -743,76 +743,76 @@ static void sum_func_merge(SqlFunctionCtx *pCtx) { } static int32_t statisRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { - return BLK_DATA_STATIS_NEEDED; + return BLK_DATA_SMA_LOAD; } static int32_t dataBlockRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { - return BLK_DATA_ALL_NEEDED; + return BLK_DATA_DATA_LOAD; } // todo: if column in current data block are null, opt for this case static int32_t firstFuncRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { if (pCtx->order == TSDB_ORDER_DESC) { - return BLK_DATA_NO_NEEDED; + return BLK_DATA_NOT_LOAD; } // no result for first query, data block is required if (GET_RES_INFO(pCtx) == NULL || GET_RES_INFO(pCtx)->numOfRes <= 0) { - return BLK_DATA_ALL_NEEDED; + return BLK_DATA_DATA_LOAD; } else { - return BLK_DATA_NO_NEEDED; + return BLK_DATA_NOT_LOAD; } } static int32_t lastFuncRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { if (pCtx->order != pCtx->param[0].i) { - return BLK_DATA_NO_NEEDED; + return BLK_DATA_NOT_LOAD; } if (GET_RES_INFO(pCtx) == NULL || GET_RES_INFO(pCtx)->numOfRes <= 0) { - return BLK_DATA_ALL_NEEDED; + return BLK_DATA_DATA_LOAD; } else { - return BLK_DATA_NO_NEEDED; + return BLK_DATA_NOT_LOAD; } } static int32_t firstDistFuncRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { if (pCtx->order == TSDB_ORDER_DESC) { - return BLK_DATA_NO_NEEDED; + return BLK_DATA_NOT_LOAD; } // not initialized yet, it is the first block, load it. if (pCtx->pOutput == NULL) { - return BLK_DATA_ALL_NEEDED; + return BLK_DATA_DATA_LOAD; } // the pCtx should be set to current Ctx and output buffer before call this function. Otherwise, pCtx->pOutput is // the previous windowRes output buffer, not current unloaded block. In this case, the following filter is invalid SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->pOutput + pCtx->inputBytes); if (pInfo->hasResult != DATA_SET_FLAG) { - return BLK_DATA_ALL_NEEDED; + return BLK_DATA_DATA_LOAD; } else { // data in current block is not earlier than current result - return (pInfo->ts <= w->skey) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED; + return (pInfo->ts <= w->skey) ? BLK_DATA_NOT_LOAD : BLK_DATA_DATA_LOAD; } } static int32_t lastDistFuncRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { if (pCtx->order != pCtx->param[0].i) { - return BLK_DATA_NO_NEEDED; + return BLK_DATA_NOT_LOAD; } // not initialized yet, it is the first block, load it. if (pCtx->pOutput == NULL) { - return BLK_DATA_ALL_NEEDED; + return BLK_DATA_DATA_LOAD; } // the pCtx should be set to current Ctx and output buffer before call this function. Otherwise, pCtx->pOutput is // the previous windowRes output buffer, not current unloaded block. In this case, the following filter is invalid SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->pOutput + pCtx->inputBytes); if (pInfo->hasResult != DATA_SET_FLAG) { - return BLK_DATA_ALL_NEEDED; + return BLK_DATA_DATA_LOAD; } else { - return (pInfo->ts > w->ekey) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED; + return (pInfo->ts > w->ekey) ? BLK_DATA_NOT_LOAD : BLK_DATA_DATA_LOAD; } } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index e1a486d8b1..758f9d5d6f 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -84,6 +84,8 @@ SNodeptr nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SIndexOptions)); case QUERY_NODE_EXPLAIN_OPTIONS: return makeNode(type, sizeof(SExplainOptions)); + case QUERY_NODE_STREAM_OPTIONS: + return makeNode(type, sizeof(SStreamOptions)); case QUERY_NODE_SET_OPERATOR: return makeNode(type, sizeof(SSetOperator)); case QUERY_NODE_SELECT_STMT: @@ -146,6 +148,19 @@ SNodeptr nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SDescribeStmt)); case QUERY_NODE_RESET_QUERY_CACHE_STMT: return makeNode(type, sizeof(SNode)); + case QUERY_NODE_COMPACT_STMT: + case QUERY_NODE_CREATE_FUNCTION_STMT: + case QUERY_NODE_DROP_FUNCTION_STMT: + break; + case QUERY_NODE_CREATE_STREAM_STMT: + return makeNode(type, sizeof(SCreateStreamStmt)); + case QUERY_NODE_DROP_STREAM_STMT: + return makeNode(type, sizeof(SDropStreamStmt)); + case QUERY_NODE_MERGE_VGROUP_STMT: + case QUERY_NODE_REDISTRIBUTE_VGROUP_STMT: + case QUERY_NODE_SPLIT_VGROUP_STMT: + case QUERY_NODE_SYNCDB_STMT: + break; case QUERY_NODE_SHOW_DNODES_STMT: case QUERY_NODE_SHOW_MNODES_STMT: case QUERY_NODE_SHOW_MODULES_STMT: @@ -169,7 +184,16 @@ SNodeptr nodesMakeNode(ENodeType type) { case QUERY_NODE_SHOW_CONFIGS_STMT: case QUERY_NODE_SHOW_QUERIES_STMT: case QUERY_NODE_SHOW_VNODES_STMT: + case QUERY_NODE_SHOW_APPS_STMT: + case QUERY_NODE_SHOW_SCORES_STMT: + case QUERY_NODE_SHOW_VARIABLE_STMT: + case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: + case QUERY_NODE_SHOW_CREATE_TABLE_STMT: + case QUERY_NODE_SHOW_CREATE_STABLE_STMT: return makeNode(type, sizeof(SShowStmt)); + case QUERY_NODE_KILL_CONNECTION_STMT: + case QUERY_NODE_KILL_QUERY_STMT: + return makeNode(type, sizeof(SKillStmt)); case QUERY_NODE_LOGIC_PLAN_SCAN: return makeNode(type, sizeof(SScanLogicNode)); case QUERY_NODE_LOGIC_PLAN_JOIN: @@ -675,6 +699,7 @@ int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode) { if (NULL != pList->pTail) { pList->pTail->pNext = p; } + p->pPrev = pList->pTail; pList->pTail = p; ++(pList->length); return TSDB_CODE_SUCCESS; @@ -1201,7 +1226,7 @@ void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal) { case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARBINARY: - pVal->pz = pNode->datum.p; + pVal->pz = pNode->datum.p + VARSTR_HEADER_SIZE; break; case TSDB_DATA_TYPE_JSON: case TSDB_DATA_TYPE_DECIMAL: diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index b4319b4747..2c4fba5059 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -86,13 +86,14 @@ SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pC SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral); SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral); SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt); +SNode* createPlaceholderValueNode(SAstCreateContext* pCxt); SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, const SToken* pAlias); SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType type, SNode* pParam1, SNode* pParam2); SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pLeft, SNode* pRight); SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight); SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight); SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList); -SNode* createFunctionNodeNoParam(SAstCreateContext* pCxt, const SToken* pFuncName); +SNode* createFunctionNodeNoArg(SAstCreateContext* pCxt, const SToken* pFuncName); SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType dt); SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList); SNode* createNodeListNodeEx(SAstCreateContext* pCxt, SNode* p1, SNode* p2); @@ -166,8 +167,9 @@ SNode* createResetQueryCacheStmt(SAstCreateContext* pCxt); SNode* createCompactStmt(SAstCreateContext* pCxt, SNodeList* pVgroups); SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool aggFunc, const SToken* pFuncName, const SToken* pLibPath, SDataType dataType, int32_t bufSize); SNode* createDropFunctionStmt(SAstCreateContext* pCxt, const SToken* pFuncName); -SNode* createCreateStreamStmt(SAstCreateContext* pCxt, const SToken* pStreamName, const SToken* pTableName, SNode* pQuery); -SNode* createDropStreamStmt(SAstCreateContext* pCxt, const SToken* pStreamName); +SNode* createStreamOptions(SAstCreateContext* pCxt); +SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable, SNode* pOptions, SNode* pQuery); +SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pStreamName); SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId); SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, const SToken* pVgId2); SNode* createRedistributeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId, SNodeList* pDnodes); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 54453fde2e..ed9981b01e 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -293,6 +293,7 @@ tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP. table_options(A) ::= . { A = createTableOptions(pCxt); } table_options(A) ::= table_options(B) COMMENT NK_STRING(C). { ((STableOptions*)B)->pComments = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &C); A = B; } table_options(A) ::= table_options(B) KEEP integer_list(C). { ((STableOptions*)B)->pKeep = C; A = B; } +table_options(A) ::= table_options(B) KEEP variable_list(C). { ((STableOptions*)B)->pKeep = C; A = B; } table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { ((STableOptions*)B)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C); A = B; } table_options(A) ::= table_options(B) SMA NK_LP col_name_list(C) NK_RP. { ((STableOptions*)B)->pSma = C; A = B; } table_options(A) ::= table_options(B) ROLLUP NK_LP func_name_list(C) NK_RP. { ((STableOptions*)B)->pFuncs = C; A = B; } @@ -306,6 +307,7 @@ alter_table_options(A) ::= alter_table_options(B) alter_table_option(C). %destructor alter_table_option { } alter_table_option(A) ::= COMMENT NK_STRING(B). { A.type = TABLE_OPTION_COMMENT; A.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); } alter_table_option(A) ::= KEEP integer_list(B). { A.type = TABLE_OPTION_KEEP; A.pList = B; } +alter_table_option(A) ::= KEEP variable_list(B). { A.type = TABLE_OPTION_KEEP; A.pList = B; } alter_table_option(A) ::= TTL NK_INTEGER(B). { A.type = TABLE_OPTION_TTL; A.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B); } %type col_name_list { SNodeList* } @@ -424,8 +426,17 @@ bufsize_opt(A) ::= . bufsize_opt(A) ::= BUFSIZE NK_INTEGER(B). { A = strtol(B.z, NULL, 10); } /************************************************ create/drop stream **************************************************/ -cmd ::= CREATE STREAM stream_name(A) INTO table_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateStreamStmt(pCxt, &A, &B, C); } -cmd ::= DROP STREAM stream_name(A). { pCxt->pRootNode = createDropStreamStmt(pCxt, &A); } +cmd ::= CREATE STREAM not_exists_opt(E) stream_name(A) + stream_options(B) into_opt(C) AS query_expression(D). { pCxt->pRootNode = createCreateStreamStmt(pCxt, E, &A, B, C, D); } +cmd ::= DROP STREAM exists_opt(A) stream_name(B). { pCxt->pRootNode = createDropStreamStmt(pCxt, A, &B); } + +into_opt(A) ::= . { A = NULL; } +into_opt(A) ::= INTO full_table_name(B). { 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; } +stream_options(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; } /************************************************ kill connection/query ***********************************************/ cmd ::= KILL CONNECTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &A); } @@ -455,6 +466,7 @@ literal(A) ::= NK_BOOL(B). literal(A) ::= TIMESTAMP(B) NK_STRING(C). { A = createRawExprNodeExt(pCxt, &B, &C, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &C)); } literal(A) ::= duration_literal(B). { A = B; } literal(A) ::= NULL(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL)); } +literal(A) ::= NK_QUESTION(B). { A = createRawExprNode(pCxt, &B, createPlaceholderValueNode(pCxt)); } duration_literal(A) ::= NK_VARIABLE(B). { A = createRawExprNode(pCxt, &B, createDurationValueNode(pCxt, &B)); } @@ -501,11 +513,6 @@ column_name(A) ::= NK_ID(B). %type function_name { SToken } %destructor function_name { } function_name(A) ::= NK_ID(B). { A = B; } -function_name(A) ::= FIRST(B). { A = B; } -function_name(A) ::= LAST(B). { A = B; } -function_name(A) ::= NOW(B). { A = B; } -function_name(A) ::= TODAY(B). { A = B; } -function_name(A) ::= TIMEZONE(B). { A = B; } %type table_alias { SToken } %destructor table_alias { } @@ -533,13 +540,9 @@ stream_name(A) ::= NK_ID(B). /************************************************ expression **********************************************************/ expression(A) ::= literal(B). { A = B; } -//expression(A) ::= NK_QUESTION(B). { A = B; } expression(A) ::= pseudo_column(B). { A = B; } expression(A) ::= column_reference(B). { A = B; } -expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); } -expression(A) ::= function_name(B) NK_LP NK_STAR(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, createNodeList(pCxt, createColumnNode(pCxt, NULL, &C)))); } -expression(A) ::= function_name(B) NK_LP NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNodeNoParam(pCxt, &B)); } -expression(A) ::= CAST(B) NK_LP expression(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); } +expression(A) ::= function_expression(B). { A = B; } //expression(A) ::= case_expression(B). { A = B; } expression(A) ::= subquery(B). { A = B; } expression(A) ::= NK_LP(B) expression(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, releaseRawExprNode(pCxt, C)); } @@ -576,6 +579,10 @@ expression(A) ::= expression(B) NK_REM expression(C). SToken e = getTokenFromRawExprNode(pCxt, C); A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C))); } +expression(A) ::= column_reference(B) NK_ARROW NK_STRING(C). { + SToken s = getTokenFromRawExprNode(pCxt, B); + A = createRawExprNodeExt(pCxt, &s, &C, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, B), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &C))); + } %type expression_list { SNodeList* } %destructor expression_list { nodesDestroyList($$); } @@ -585,15 +592,44 @@ expression_list(A) ::= expression_list(B) NK_COMMA expression(C). column_reference(A) ::= column_name(B). { A = createRawExprNode(pCxt, &B, createColumnNode(pCxt, NULL, &B)); } column_reference(A) ::= table_name(B) NK_DOT column_name(C). { A = createRawExprNodeExt(pCxt, &B, &C, createColumnNode(pCxt, &B, &C)); } -//pseudo_column(A) ::= NOW(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } -//pseudo_column(A) ::= TODAY(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } -pseudo_column(A) ::= ROWTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } -pseudo_column(A) ::= TBNAME(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } -pseudo_column(A) ::= QSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } -pseudo_column(A) ::= QENDTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } -pseudo_column(A) ::= WSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } -pseudo_column(A) ::= WENDTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } -pseudo_column(A) ::= WDURATION(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } +pseudo_column(A) ::= ROWTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } +pseudo_column(A) ::= TBNAME(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } +pseudo_column(A) ::= QSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } +pseudo_column(A) ::= QENDTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } +pseudo_column(A) ::= WSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } +pseudo_column(A) ::= WENDTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } +pseudo_column(A) ::= WDURATION(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } + +function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); } +function_expression(A) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); } +function_expression(A) ::= CAST(B) NK_LP expression(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); } +function_expression(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNodeNoArg(pCxt, &B)); } + +%type noarg_func { SToken } +%destructor noarg_func { } +noarg_func(A) ::= NOW(B). { A = B; } +noarg_func(A) ::= TODAY(B). { A = B; } +noarg_func(A) ::= TIMEZONE(B). { A = B; } + +%type star_func { SToken } +%destructor star_func { } +star_func(A) ::= COUNT(B). { A = B; } +star_func(A) ::= FIRST(B). { A = B; } +star_func(A) ::= LAST(B). { A = B; } +star_func(A) ::= LAST_ROW(B). { A = B; } + +%type star_func_para_list { SNodeList* } +%destructor star_func_para_list { nodesDestroyList($$); } +star_func_para_list(A) ::= NK_STAR(B). { A = createNodeList(pCxt, createColumnNode(pCxt, NULL, &B)); } +star_func_para_list(A) ::= other_para_list(B). { A = B; } + +%type other_para_list { SNodeList* } +%destructor other_para_list { nodesDestroyList($$); } +other_para_list(A) ::= star_func_para(B). { A = createNodeList(pCxt, B); } +other_para_list(A) ::= other_para_list(B) NK_COMMA star_func_para(C). { A = addNodeToList(pCxt, B, C); } + +star_func_para(A) ::= expression(B). { A = releaseRawExprNode(pCxt, B); } +star_func_para(A) ::= table_name(B) NK_DOT NK_STAR(C). { A = createColumnNode(pCxt, &B, &C); } /************************************************ predicate ***********************************************************/ predicate(A) ::= expression(B) compare_op(C) expression(D). { @@ -638,6 +674,7 @@ compare_op(A) ::= LIKE. compare_op(A) ::= NOT LIKE. { A = OP_TYPE_NOT_LIKE; } compare_op(A) ::= MATCH. { A = OP_TYPE_MATCH; } compare_op(A) ::= NMATCH. { A = OP_TYPE_NMATCH; } +compare_op(A) ::= CONTAINS. { A = OP_TYPE_JSON_CONTAINS; } %type in_op { EOperatorType } %destructor in_op { } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index ecf2e717f2..324f68b1b3 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -306,6 +306,13 @@ SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt) { return (SNode*)val; } +SNode* createPlaceholderValueNode(SAstCreateContext* pCxt) { + SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); + CHECK_OUT_OF_MEM(val); + // todo + return (SNode*)val; +} + SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType type, SNode* pParam1, SNode* pParam2) { SLogicConditionNode* cond = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); CHECK_OUT_OF_MEM(cond); @@ -361,7 +368,7 @@ SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNod return (SNode*)func; } -SNode* createFunctionNodeNoParam(SAstCreateContext* pCxt, const SToken* pFuncName) { +SNode* createFunctionNodeNoArg(SAstCreateContext* pCxt, const SToken* pFuncName) { SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); CHECK_OUT_OF_MEM(func); char buf[64] = {0}; @@ -945,6 +952,18 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, S return (SNode*)pStmt; } +SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName) { + SNode* pStmt = nodesMakeNode(QUERY_NODE_SHOW_CREATE_DATABASE_STMT); + CHECK_OUT_OF_MEM(pStmt); + return pStmt; +} + +SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable) { + SNode* pStmt = nodesMakeNode(type); + CHECK_OUT_OF_MEM(pStmt); + return pStmt; +} + SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword) { char password[TSDB_USET_PASSWORD_LEN] = {0}; if (!checkUserName(pCxt, pUserName) || !checkPassword(pCxt, pPassword, password)) { @@ -1176,16 +1195,34 @@ SNode* createDropFunctionStmt(SAstCreateContext* pCxt, const SToken* pFuncName) return pStmt; } -SNode* createCreateStreamStmt(SAstCreateContext* pCxt, const SToken* pStreamName, const SToken* pTableName, SNode* pQuery) { - SNode* pStmt = nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT); - CHECK_OUT_OF_MEM(pStmt); - return pStmt; +SNode* createStreamOptions(SAstCreateContext* pCxt) { + SStreamOptions* pOptions = nodesMakeNode(QUERY_NODE_STREAM_OPTIONS); + CHECK_OUT_OF_MEM(pOptions); + pOptions->triggerType = STREAM_TRIGGER_AT_ONCE; + return (SNode*)pOptions; } -SNode* createDropStreamStmt(SAstCreateContext* pCxt, const SToken* pStreamName) { - SNode* pStmt = nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT); +SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable, SNode* pOptions, SNode* pQuery) { + SCreateStreamStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT); CHECK_OUT_OF_MEM(pStmt); - return pStmt; + strncpy(pStmt->streamName, pStreamName->z, pStreamName->n); + if (NULL != 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; + return (SNode*)pStmt; +} + +SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pStreamName) { + SDropStreamStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT); + CHECK_OUT_OF_MEM(pStmt); + strncpy(pStmt->streamName, pStreamName->z, pStreamName->n); + pStmt->ignoreNotExists = ignoreNotExists; + return (SNode*)pStmt; } SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId) { diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 9e53eee5c8..acc597d61b 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -223,11 +223,15 @@ static int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pPar return code; } -static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) { +static int32_t getTableMetaImpl(SInsertParseContext* pCxt, SToken* pTname, bool isStb) { SParseContext* pBasicCtx = pCxt->pComCxt; SName name = {0}; createSName(&name, pTname, pBasicCtx, &pCxt->msg); - CHECK_CODE(catalogGetTableMeta(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &pCxt->pTableMeta)); + if (isStb) { + CHECK_CODE(catalogGetSTableMeta(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &pCxt->pTableMeta)); + } else { + CHECK_CODE(catalogGetTableMeta(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &pCxt->pTableMeta)); + } SVgroupInfo vg; CHECK_CODE(catalogGetTableHashVgroup(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &vg)); CHECK_CODE(taosHashPut(pCxt->pVgroupsHashObj, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg))); @@ -235,6 +239,15 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) { return TSDB_CODE_SUCCESS; } +static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) { + return getTableMetaImpl(pCxt, pTname, false); +} + +static int32_t getSTableMeta(SInsertParseContext* pCxt, SToken* pTname) { + return getTableMetaImpl(pCxt, pTname, true); +} + + static int32_t findCol(SToken* pColname, int32_t start, int32_t end, SSchema* pSchema) { while (start < end) { if (strlen(pSchema[start].name) == pColname->n && strncmp(pColname->z, pSchema[start].name, pColname->n) == 0) { @@ -818,7 +831,7 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SToken* pTbnameToken) SToken sToken; // pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...) NEXT_TOKEN(pCxt->pSql, sToken); - CHECK_CODE(getTableMeta(pCxt, &sToken)); + CHECK_CODE(getSTableMeta(pCxt, &sToken)); if (TSDB_SUPER_TABLE != pCxt->pTableMeta->tableType) { return buildInvalidOperationMsg(&pCxt->msg, "create table only from super table is allowed"); } diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 48d73ffa66..2a191b7bf2 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -39,6 +39,7 @@ static SKeyword keywordTable[] = { {"APPS", TK_APPS}, {"AS", TK_AS}, {"ASC", TK_ASC}, + {"AT_ONCE", TK_AT_ONCE}, {"BETWEEN", TK_BETWEEN}, {"BINARY", TK_BINARY}, {"BIGINT", TK_BIGINT}, @@ -50,6 +51,7 @@ static SKeyword keywordTable[] = { {"BY", TK_BY}, {"CACHE", TK_CACHE}, {"CACHELAST", TK_CACHELAST}, + {"CAST", TK_CAST}, {"COLUMN", TK_COLUMN}, {"COMMENT", TK_COMMENT}, {"COMP", TK_COMP}, @@ -57,6 +59,7 @@ static SKeyword keywordTable[] = { {"CONNS", TK_CONNS}, {"CONNECTION", TK_CONNECTION}, {"CONNECTIONS", TK_CONNECTIONS}, + {"COUNT", TK_COUNT}, {"CREATE", TK_CREATE}, {"DATABASE", TK_DATABASE}, {"DATABASES", TK_DATABASES}, @@ -100,6 +103,7 @@ static SKeyword keywordTable[] = { {"KEEP", TK_KEEP}, {"KILL", TK_KILL}, {"LAST", TK_LAST}, + {"LAST_ROW", TK_LAST_ROW}, {"LICENCE", TK_LICENCE}, {"LIKE", TK_LIKE}, {"LIMIT", TK_LIMIT}, @@ -132,10 +136,8 @@ static SKeyword keywordTable[] = { {"PRECISION", TK_PRECISION}, {"PRIVILEGE", TK_PRIVILEGE}, {"PREV", TK_PREV}, - {"_QENDTS", TK_QENDTS}, {"QNODE", TK_QNODE}, {"QNODES", TK_QNODES}, - {"_QSTARTTS", TK_QSTARTTS}, {"QTIME", TK_QTIME}, {"QUERIES", TK_QUERIES}, {"QUERY", TK_QUERY}, @@ -145,7 +147,6 @@ static SKeyword keywordTable[] = { {"RESET", TK_RESET}, {"RETENTIONS", TK_RETENTIONS}, {"ROLLUP", TK_ROLLUP}, - {"_ROWTS", TK_ROWTS}, {"SCORES", TK_SCORES}, {"SELECT", TK_SELECT}, {"SESSION", TK_SESSION}, @@ -179,6 +180,7 @@ static SKeyword keywordTable[] = { {"TODAY", TK_TODAY}, {"TOPIC", TK_TOPIC}, {"TOPICS", TK_TOPICS}, + {"TRIGGER", TK_TRIGGER}, {"TSERIES", TK_TSERIES}, {"TTL", TK_TTL}, {"UNION", TK_UNION}, @@ -195,9 +197,14 @@ static SKeyword keywordTable[] = { {"VGROUPS", TK_VGROUPS}, {"VNODES", TK_VNODES}, {"WAL", TK_WAL}, + {"WATERMARK", TK_WATERMARK}, + {"WHERE", TK_WHERE}, + {"WINDOW_CLOSE", TK_WINDOW_CLOSE}, + {"_QENDTS", TK_QENDTS}, + {"_QSTARTTS", TK_QSTARTTS}, + {"_ROWTS", TK_ROWTS}, {"_WDURATION", TK_WDURATION}, {"_WENDTS", TK_WENDTS}, - {"WHERE", TK_WHERE}, {"_WSTARTTS", TK_WSTARTTS}, // {"ID", TK_ID}, // {"STRING", TK_STRING}, @@ -261,7 +268,6 @@ static SKeyword keywordTable[] = { // {"RESTRICT", TK_RESTRICT}, // {"ROW", TK_ROW}, // {"STATEMENT", TK_STATEMENT}, - // {"TRIGGER", TK_TRIGGER}, // {"VIEW", TK_VIEW}, // {"SEMI", TK_SEMI}, // {"PARTITIONS", TK_PARTITIONS}, @@ -346,6 +352,9 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) { } *tokenId = TK_NK_COMMENT; return i; + } else if (z[1] == '>') { + *tokenId = TK_NK_ARROW; + return 2; } *tokenId = TK_NK_MINUS; return 1; diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index d443125014..c2000f7af8 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -780,92 +780,165 @@ static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) { return TSDB_CODE_SUCCESS; } -static bool isFirstLastFunc(SFunctionNode* pFunc) { - return (FUNCTION_TYPE_FIRST == pFunc->funcType || FUNCTION_TYPE_LAST == pFunc->funcType); -} - -static bool isFirstLastStar(SNode* pNode) { - if (QUERY_NODE_FUNCTION != nodeType(pNode) || !isFirstLastFunc((SFunctionNode*)pNode)) { +static bool isMultiResFunc(SNode* pNode) { + if (QUERY_NODE_FUNCTION != nodeType(pNode) || !fmIsMultiResFunc(((SFunctionNode*)pNode)->funcId)) { return false; } SNodeList* pParameterList = ((SFunctionNode*)pNode)->pParameterList; - if (LIST_LENGTH(pParameterList) != 1) { - return false; + if (LIST_LENGTH(pParameterList) > 1) { + return true; } SNode* pParam = nodesListGetNode(pParameterList, 0); return (QUERY_NODE_COLUMN == nodeType(pParam) ? 0 == strcmp(((SColumnNode*)pParam)->colName, "*") : false); } -static SNode* createFirstLastFunc(SFunctionNode* pSrcFunc, SColumnNode* pCol) { +static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) { SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pFunc) { return NULL; } pFunc->pParameterList = nodesMakeList(); - if (NULL == pFunc->pParameterList || TSDB_CODE_SUCCESS != nodesListAppend(pFunc->pParameterList, pCol)) { + if (NULL == pFunc->pParameterList || TSDB_CODE_SUCCESS != nodesListStrictAppend(pFunc->pParameterList, nodesCloneNode(pExpr))) { nodesDestroyNode(pFunc); return NULL; } - pFunc->node.resType = pCol->node.resType; + pFunc->node.resType = pExpr->resType; pFunc->funcId = pSrcFunc->funcId; pFunc->funcType = pSrcFunc->funcType; strcpy(pFunc->functionName, pSrcFunc->functionName); - snprintf(pFunc->node.aliasName, sizeof(pFunc->node.aliasName), - (FUNCTION_TYPE_FIRST == pSrcFunc->funcType ? "first(%s)" : "last(%s)"), pCol->colName); + char buf[TSDB_FUNC_NAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_COL_NAME_LEN]; + int32_t len = 0; + if (QUERY_NODE_COLUMN == nodeType(pExpr)) { + SColumnNode* pCol = (SColumnNode*)pExpr; + len = snprintf(buf, sizeof(buf), "%s(%s.%s)", pSrcFunc->functionName, pCol->tableAlias, pCol->colName); + } else { + len = snprintf(buf, sizeof(buf), "%s(%s)", pSrcFunc->functionName, pExpr->aliasName); + } + strncpy(pFunc->node.aliasName, buf, TMIN(len, sizeof(pFunc->node.aliasName) - 1)); return (SNode*)pFunc; } -static int32_t createFirstLastAllCols(STranslateContext* pCxt, SFunctionNode* pSrcFunc, SNodeList** pOutput) { - SNodeList* pCols = NULL; - if (TSDB_CODE_SUCCESS != createAllColumns(pCxt, &pCols)) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - SNodeList* pFuncs = nodesMakeList(); - if (NULL == pFuncs) { - return TSDB_CODE_OUT_OF_MEMORY; - } - SNode* pCol = NULL; - FOREACH(pCol, pCols) { - if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pFuncs, createFirstLastFunc(pSrcFunc, (SColumnNode*)pCol))) { - nodesDestroyNode(pFuncs); - return TSDB_CODE_OUT_OF_MEMORY; - } - } - - *pOutput = pFuncs; - return TSDB_CODE_SUCCESS; -} - -static bool isTableStar(SNode* pNode) { - return (QUERY_NODE_COLUMN == nodeType(pNode)) && (0 == strcmp(((SColumnNode*)pNode)->colName, "*")); -} - -static int32_t createTableAllCols(STranslateContext* pCxt, SColumnNode* pCol, SNodeList** pOutput) { - *pOutput = nodesMakeList(); - if (NULL == *pOutput) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY); - } - bool foundTable = false; +static int32_t findTable(STranslateContext* pCxt, const char* pTableAlias, STableNode** pOutput) { SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel); size_t nums = taosArrayGetSize(pTables); for (size_t i = 0; i < nums; ++i) { STableNode* pTable = taosArrayGetP(pTables, i); - if (0 == strcmp(pTable->tableAlias, pCol->tableAlias)) { - int32_t code = createColumnNodeByTable(pCxt, pTable, *pOutput); - if (TSDB_CODE_SUCCESS != code) { - return code; - } - foundTable = true; + if (NULL == pTableAlias || 0 == strcmp(pTable->tableAlias, pTableAlias)) { + *pOutput = pTable; + return TSDB_CODE_SUCCESS; + } + } + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_TABLE_NOT_EXIST, pTableAlias); +} + +static int32_t createTableAllCols(STranslateContext* pCxt, SColumnNode* pCol, SNodeList** pOutput) { + STableNode* pTable = NULL; + int32_t code = findTable(pCxt, pCol->tableAlias, &pTable); + if (TSDB_CODE_SUCCESS == code && NULL == *pOutput) { + *pOutput = nodesMakeList(); + if (NULL == *pOutput) { + code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY); + } + } + if (TSDB_CODE_SUCCESS == code) { + code = createColumnNodeByTable(pCxt, pTable, *pOutput); + } + return code; +} + +static bool isStar(SNode* pNode) { + return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' == ((SColumnNode*)pNode)->tableAlias[0]) && (0 == strcmp(((SColumnNode*)pNode)->colName, "*")); +} + +static bool isTableStar(SNode* pNode) { + return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' != ((SColumnNode*)pNode)->tableAlias[0]) && (0 == strcmp(((SColumnNode*)pNode)->colName, "*")); +} + +static int32_t createMultiResFuncsParas(STranslateContext* pCxt, SNodeList* pSrcParas, SNodeList** pOutput) { + int32_t code = TSDB_CODE_SUCCESS; + + SNodeList* pExprs = NULL; + SNode* pPara = NULL; + FOREACH(pPara, pSrcParas) { + if (isStar(pPara)) { + code = createAllColumns(pCxt, &pExprs); + // The syntax definition ensures that * and other parameters do not appear at the same time + break; + } else if (isTableStar(pPara)) { + code = createTableAllCols(pCxt, (SColumnNode*)pPara, &pExprs); + } else { + code = nodesListMakeStrictAppend(&pExprs, nodesCloneNode(pPara)); + } + if (TSDB_CODE_SUCCESS != code) { break; } } - if (!foundTable) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_TABLE_NOT_EXIST, pCol->tableAlias); + + if (TSDB_CODE_SUCCESS == code) { + *pOutput = pExprs; + } else { + nodesDestroyList(pExprs); } - return TSDB_CODE_SUCCESS; + + return code; +} + +static int32_t createMultiResFuncs(SFunctionNode* pSrcFunc, SNodeList* pExprs, SNodeList** pOutput) { + SNodeList* pFuncs = nodesMakeList(); + if (NULL == pFuncs) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + int32_t code = TSDB_CODE_SUCCESS; + SNode* pExpr = NULL; + FOREACH(pExpr, pExprs) { + code = nodesListStrictAppend(pFuncs, createMultiResFunc(pSrcFunc, (SExprNode*)pExpr)); + if (TSDB_CODE_SUCCESS != code) { + break; + } + } + + if (TSDB_CODE_SUCCESS == code) { + *pOutput = pFuncs; + } else { + nodesDestroyList(pFuncs); + } + + return code; +} + +static int32_t createMultiResFuncsFromStar(STranslateContext* pCxt, SFunctionNode* pSrcFunc, SNodeList** pOutput) { + SNodeList* pExprs = NULL; + int32_t code = createMultiResFuncsParas(pCxt, pSrcFunc->pParameterList, &pExprs); + if (TSDB_CODE_SUCCESS == code) { + code = createMultiResFuncs(pSrcFunc, pExprs, pOutput); + } + + if (TSDB_CODE_SUCCESS != code) { + nodesDestroyList(pExprs); + } + + return code; +} + +static bool isCountStar(SNode* pNode) { + if (QUERY_NODE_FUNCTION != nodeType(pNode) || 1 != LIST_LENGTH(((SFunctionNode*)pNode)->pParameterList)) { + return false; + } + SNode* pPara = nodesListGetNode(((SFunctionNode*)pNode)->pParameterList, 0); + return (QUERY_NODE_COLUMN == nodeType(pPara) && 0 == strcmp(((SColumnNode*)pPara)->colName, "*")); +} + +static int32_t rewriteCountStar(STranslateContext* pCxt, SFunctionNode* pCount) { + SColumnNode* pCol = nodesListGetNode(pCount->pParameterList, 0); + STableNode* pTable = NULL; + int32_t code = findTable(pCxt, ('\0' == pCol->tableAlias[0] ? NULL : pCol->tableAlias), &pTable); + if (TSDB_CODE_SUCCESS == code && QUERY_NODE_REAL_TABLE == nodeType(pTable)) { + setColumnInfoBySchema((SRealTableNode*)pTable, ((SRealTableNode*)pTable)->pMeta->schema, false, pCol); + } + return code; } static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) { @@ -874,9 +947,9 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) { } else { SNode* pNode = NULL; WHERE_EACH(pNode, pSelect->pProjectionList) { - if (isFirstLastStar(pNode)) { + if (isMultiResFunc(pNode)) { SNodeList* pFuncs = NULL; - if (TSDB_CODE_SUCCESS != createFirstLastAllCols(pCxt, (SFunctionNode*)pNode, &pFuncs)) { + if (TSDB_CODE_SUCCESS != createMultiResFuncsFromStar(pCxt, (SFunctionNode*)pNode, &pFuncs)) { return TSDB_CODE_OUT_OF_MEMORY; } INSERT_LIST(pSelect->pProjectionList, pFuncs); @@ -890,6 +963,11 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) { INSERT_LIST(pSelect->pProjectionList, pCols); ERASE_NODE(pSelect->pProjectionList); continue; + } else if (isCountStar(pNode)) { + int32_t code = rewriteCountStar(pCxt, (SFunctionNode*)pNode); + if (TSDB_CODE_SUCCESS != code) { + return code; + } } WHERE_NEXT; } @@ -2077,6 +2155,46 @@ static int32_t translateKillQuery(STranslateContext* pCxt, SKillStmt* pStmt) { return buildCmdMsg(pCxt, TDMT_MND_KILL_QUERY, (FSerializeFunc)tSerializeSKillQueryReq, &killReq); } +static int32_t translateCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pStmt) { + SCMCreateStreamReq createReq = {0}; + + createReq.igExists = pStmt->ignoreExists; + + SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId}; + strcpy(name.dbname, pCxt->pParseCxt->db); + strcpy(name.tname, pStmt->streamName); + tNameExtractFullName(&name, createReq.name); + + if ('\0' != pStmt->targetTabName[0]) { + strcpy(name.dbname, pStmt->targetDbName); + strcpy(name.tname, pStmt->targetTabName); + tNameExtractFullName(&name, createReq.outputSTbName); + } + + int32_t code = translateQuery(pCxt, pStmt->pQuery); + if (TSDB_CODE_SUCCESS == code) { + code = nodesNodeToString(pStmt->pQuery, false, &createReq.ast, NULL); + } + + if (TSDB_CODE_SUCCESS == code) { + createReq.sql = strdup(pCxt->pParseCxt->pSql); + if (NULL == createReq.sql) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + + if (TSDB_CODE_SUCCESS == code) { + code = buildCmdMsg(pCxt, TDMT_MND_CREATE_STREAM, (FSerializeFunc)tSerializeSCMCreateStreamReq, &createReq); + } + + tFreeSCMCreateStreamReq(&createReq); + return code; +} + +static int32_t translateDropStream(STranslateContext* pCxt, SDropStreamStmt* pStmt) { + // todo + return TSDB_CODE_SUCCESS; +} static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { int32_t code = TSDB_CODE_SUCCESS; @@ -2170,6 +2288,12 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_KILL_QUERY_STMT: code = translateKillQuery(pCxt, (SKillStmt*)pNode); break; + case QUERY_NODE_CREATE_STREAM_STMT: + code = translateCreateStream(pCxt, (SCreateStreamStmt*)pNode); + break; + case QUERY_NODE_DROP_STREAM_STMT: + code = translateDropStream(pCxt, (SDropStreamStmt*)pNode); + break; default: break; } @@ -2208,6 +2332,10 @@ static int32_t extractSelectResultSchema(const SSelectStmt* pSelect, int32_t* nu return TSDB_CODE_SUCCESS; } +static int8_t extractResultTsPrecision(const SSelectStmt* pSelect) { + return pSelect->precision; +} + static int32_t extractExplainResultSchema(int32_t* numOfCols, SSchema** pSchema) { *numOfCols = 1; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); @@ -2229,19 +2357,19 @@ static int32_t extractDescribeResultSchema(int32_t* numOfCols, SSchema** pSchema (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; (*pSchema)[0].bytes = DESCRIBE_RESULT_FIELD_LEN; - strcpy((*pSchema)[0].name, "Field"); + strcpy((*pSchema)[0].name, "field"); (*pSchema)[1].type = TSDB_DATA_TYPE_BINARY; (*pSchema)[1].bytes = DESCRIBE_RESULT_TYPE_LEN; - strcpy((*pSchema)[1].name, "Type"); + strcpy((*pSchema)[1].name, "type"); (*pSchema)[2].type = TSDB_DATA_TYPE_INT; (*pSchema)[2].bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes; - strcpy((*pSchema)[2].name, "Length"); + strcpy((*pSchema)[2].name, "length"); (*pSchema)[3].type = TSDB_DATA_TYPE_BINARY; (*pSchema)[3].bytes = DESCRIBE_RESULT_NOTE_LEN; - strcpy((*pSchema)[3].name, "Note"); + strcpy((*pSchema)[3].name, "note"); return TSDB_CODE_SUCCESS; } @@ -2922,6 +3050,8 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) { if (TSDB_CODE_SUCCESS != extractResultSchema(pQuery->pRoot, &pQuery->numOfResCols, &pQuery->pResSchema)) { return TSDB_CODE_OUT_OF_MEMORY; } + + pQuery->precision = extractResultTsPrecision((SSelectStmt*) pQuery->pRoot); } if (NULL != pCxt->pDbs) { diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 96345ecb88..8c04051505 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -100,24 +100,24 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 317 +#define YYNOCODE 334 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EOperatorType yy142; - EOrder yy216; - SDataType yy274; - SNode* yy286; - EFillMode yy287; - SNodeList* yy352; - EJoinType yy448; - ENullOrder yy473; - bool yy495; - SToken yy567; - SAlterOption yy583; - int32_t yy634; + SAlterOption yy29; + EJoinType yy164; + ENullOrder yy209; + SDataType yy388; + EOperatorType yy416; + SNode* yy456; + SToken yy537; + EOrder yy626; + SNodeList* yy632; + EFillMode yy646; + bool yy649; + int32_t yy652; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -132,18 +132,18 @@ typedef union { #define ParseCTX_PARAM #define ParseCTX_FETCH #define ParseCTX_STORE -#define YYNSTATE 550 -#define YYNRULE 413 -#define YYNRULE_WITH_ACTION 413 -#define YYNTOKEN 211 -#define YY_MAX_SHIFT 549 -#define YY_MIN_SHIFTREDUCE 812 -#define YY_MAX_SHIFTREDUCE 1224 -#define YY_ERROR_ACTION 1225 -#define YY_ACCEPT_ACTION 1226 -#define YY_NO_ACTION 1227 -#define YY_MIN_REDUCE 1228 -#define YY_MAX_REDUCE 1640 +#define YYNSTATE 568 +#define YYNRULE 433 +#define YYNRULE_WITH_ACTION 433 +#define YYNTOKEN 220 +#define YY_MAX_SHIFT 567 +#define YY_MIN_SHIFTREDUCE 843 +#define YY_MAX_SHIFTREDUCE 1275 +#define YY_ERROR_ACTION 1276 +#define YY_ACCEPT_ACTION 1277 +#define YY_NO_ACTION 1278 +#define YY_MIN_REDUCE 1279 +#define YY_MAX_REDUCE 1711 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -210,489 +210,555 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (1567) +#define YY_ACTTAB_COUNT (1863) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 452, 1226, 258, 270, 452, 465, 1438, 25, 195, 118, - /* 10 */ 1439, 1240, 30, 28, 73, 21, 307, 1508, 1339, 1489, - /* 20 */ 267, 370, 1057, 23, 848, 32, 31, 29, 27, 26, - /* 30 */ 1348, 1485, 1491, 32, 31, 29, 27, 26, 1055, 275, - /* 40 */ 368, 1526, 32, 31, 29, 27, 26, 1619, 434, 464, - /* 50 */ 11, 30, 28, 1167, 283, 464, 1489, 1062, 451, 267, - /* 60 */ 132, 1057, 1476, 1476, 1617, 30, 28, 450, 1485, 1491, - /* 70 */ 1508, 464, 1572, 267, 1, 1057, 278, 1055, 70, 1509, - /* 80 */ 1510, 1515, 1558, 1429, 1431, 1619, 260, 1554, 127, 11, - /* 90 */ 1569, 1055, 1228, 1280, 1526, 1619, 1062, 546, 132, 349, - /* 100 */ 191, 434, 1617, 12, 1077, 1100, 414, 1585, 1618, 1056, - /* 110 */ 1062, 451, 1617, 1, 1496, 1476, 94, 93, 92, 91, - /* 120 */ 90, 89, 88, 87, 86, 12, 1494, 7, 1097, 138, - /* 130 */ 1489, 70, 1509, 1510, 1515, 1558, 546, 335, 1395, 260, - /* 140 */ 1554, 127, 1485, 1492, 257, 384, 1058, 378, 1056, 1393, - /* 150 */ 546, 383, 465, 1086, 98, 51, 379, 377, 50, 380, - /* 160 */ 1586, 311, 1056, 1061, 1081, 1082, 1083, 1084, 1085, 449, - /* 170 */ 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1348, 32, 31, - /* 180 */ 29, 27, 26, 142, 141, 1058, 85, 124, 133, 84, - /* 190 */ 83, 82, 81, 80, 79, 78, 77, 76, 1388, 1058, - /* 200 */ 542, 541, 1061, 1081, 1082, 1083, 1084, 1085, 449, 1112, - /* 210 */ 1113, 1114, 1115, 1116, 1117, 1118, 1061, 1081, 1082, 1083, - /* 220 */ 1084, 1085, 449, 1112, 1113, 1114, 1115, 1116, 1117, 1118, - /* 230 */ 30, 28, 32, 31, 29, 27, 26, 465, 267, 133, - /* 240 */ 1057, 1251, 1191, 165, 30, 28, 73, 373, 133, 384, - /* 250 */ 398, 378, 267, 376, 1057, 383, 1055, 306, 98, 305, - /* 260 */ 379, 377, 1348, 380, 438, 1080, 313, 1132, 11, 375, - /* 270 */ 1055, 190, 133, 1508, 1465, 1062, 418, 1189, 1190, 1192, - /* 280 */ 1193, 1619, 431, 30, 28, 1136, 1476, 389, 396, 1062, - /* 290 */ 53, 267, 1, 1057, 132, 1181, 239, 1526, 1617, 66, - /* 300 */ 133, 394, 397, 97, 447, 1221, 7, 101, 465, 1055, - /* 310 */ 290, 1343, 22, 102, 451, 546, 167, 312, 1476, 392, - /* 320 */ 1340, 119, 465, 465, 386, 1306, 435, 1056, 1062, 546, - /* 330 */ 166, 320, 321, 1348, 70, 1509, 1510, 1515, 1558, 53, - /* 340 */ 99, 1056, 260, 1554, 1631, 7, 465, 1348, 1348, 1079, - /* 350 */ 188, 1565, 430, 1592, 429, 348, 43, 1619, 421, 42, - /* 360 */ 1344, 271, 382, 381, 1058, 29, 27, 26, 546, 116, - /* 370 */ 132, 1348, 515, 513, 1617, 1220, 217, 1350, 1058, 1378, - /* 380 */ 1056, 1061, 1081, 1082, 1083, 1084, 1085, 449, 1112, 1113, - /* 390 */ 1114, 1115, 1116, 1117, 1118, 1061, 1081, 1082, 1083, 1084, - /* 400 */ 1085, 449, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1081, - /* 410 */ 1082, 1083, 1084, 1085, 1572, 426, 422, 1058, 9, 8, - /* 420 */ 133, 32, 31, 29, 27, 26, 32, 31, 29, 27, - /* 430 */ 26, 425, 1568, 1250, 1061, 1081, 1082, 1083, 1084, 1085, - /* 440 */ 449, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 30, 28, - /* 450 */ 32, 31, 29, 27, 26, 238, 267, 1077, 1057, 32, - /* 460 */ 31, 29, 27, 26, 328, 437, 1249, 340, 1326, 1572, - /* 470 */ 465, 849, 153, 848, 1055, 126, 341, 1229, 1476, 1345, - /* 480 */ 1248, 366, 1324, 362, 358, 354, 152, 1567, 242, 1526, - /* 490 */ 251, 850, 1143, 1062, 1174, 1348, 447, 242, 85, 1247, - /* 500 */ 1079, 84, 83, 82, 81, 80, 79, 78, 77, 76, - /* 510 */ 1, 1476, 54, 1100, 465, 150, 165, 349, 465, 900, - /* 520 */ 373, 1130, 1426, 462, 500, 1476, 1246, 463, 424, 140, - /* 530 */ 1130, 500, 252, 546, 250, 249, 6, 372, 902, 1348, - /* 540 */ 1245, 1078, 375, 1348, 1476, 1056, 1244, 115, 465, 339, - /* 550 */ 1243, 1242, 334, 333, 332, 331, 330, 209, 327, 326, - /* 560 */ 325, 324, 323, 319, 318, 317, 316, 315, 314, 1395, - /* 570 */ 1131, 1476, 149, 1348, 121, 272, 146, 502, 277, 1131, - /* 580 */ 1393, 1395, 1058, 1277, 491, 1476, 116, 279, 1135, 465, - /* 590 */ 1166, 1476, 1393, 144, 1350, 1476, 1476, 1135, 281, 1061, - /* 600 */ 1081, 1082, 1083, 1084, 1085, 449, 1112, 1113, 1114, 1115, - /* 610 */ 1116, 1117, 1118, 60, 1348, 24, 265, 1125, 1126, 1127, - /* 620 */ 1128, 1129, 1133, 1134, 24, 265, 1125, 1126, 1127, 1128, - /* 630 */ 1129, 1133, 1134, 1239, 1341, 522, 521, 520, 519, 282, - /* 640 */ 1087, 518, 517, 516, 103, 511, 510, 509, 508, 507, - /* 650 */ 506, 505, 504, 109, 938, 488, 487, 486, 942, 485, - /* 660 */ 944, 945, 484, 947, 481, 549, 953, 478, 955, 956, - /* 670 */ 475, 472, 117, 1508, 1337, 1238, 1237, 223, 1476, 214, - /* 680 */ 1162, 1236, 96, 158, 274, 273, 156, 280, 538, 221, - /* 690 */ 534, 530, 526, 213, 1070, 116, 298, 1526, 1395, 1235, - /* 700 */ 1508, 1234, 143, 1350, 447, 1233, 1232, 116, 1231, 1430, - /* 710 */ 1063, 300, 1577, 1162, 451, 1351, 1395, 1267, 1476, 67, - /* 720 */ 1476, 1476, 207, 435, 1526, 1508, 1476, 1394, 503, 1062, - /* 730 */ 1320, 447, 9, 8, 69, 1509, 1510, 1515, 1558, 385, - /* 740 */ 439, 451, 241, 1554, 1476, 1476, 1476, 65, 266, 1526, - /* 750 */ 1476, 1476, 461, 1476, 1619, 107, 447, 62, 176, 410, - /* 760 */ 1508, 234, 1509, 1510, 1515, 68, 451, 132, 514, 466, - /* 770 */ 1476, 1617, 301, 415, 160, 1165, 162, 159, 1333, 161, - /* 780 */ 413, 1066, 164, 172, 1526, 163, 234, 1509, 1510, 1515, - /* 790 */ 442, 447, 45, 49, 48, 310, 1188, 137, 1041, 1335, - /* 800 */ 169, 451, 304, 1508, 1262, 1476, 1260, 179, 1223, 1224, - /* 810 */ 247, 181, 296, 34, 292, 288, 134, 1137, 1071, 446, - /* 820 */ 1331, 70, 1509, 1510, 1515, 1558, 387, 1526, 390, 260, - /* 830 */ 1554, 1631, 34, 34, 447, 1074, 1095, 1024, 170, 1508, - /* 840 */ 1615, 874, 133, 198, 451, 1508, 95, 200, 1476, 105, - /* 850 */ 457, 107, 45, 206, 448, 931, 926, 1065, 1064, 406, - /* 860 */ 875, 490, 1241, 1526, 70, 1509, 1510, 1515, 1558, 1526, - /* 870 */ 447, 192, 260, 1554, 1631, 440, 447, 1307, 470, 407, - /* 880 */ 451, 1508, 959, 1576, 1476, 344, 451, 405, 105, 435, - /* 890 */ 1476, 431, 963, 106, 1508, 107, 419, 969, 185, 968, - /* 900 */ 229, 1509, 1510, 1515, 1389, 1526, 71, 1509, 1510, 1515, - /* 910 */ 1558, 367, 447, 1588, 1557, 1554, 101, 105, 1526, 432, - /* 920 */ 1619, 108, 451, 408, 1527, 447, 1476, 443, 1068, 1067, - /* 930 */ 194, 2, 1122, 132, 1077, 451, 285, 1617, 1508, 1476, - /* 940 */ 289, 900, 71, 1509, 1510, 1515, 1558, 246, 215, 99, - /* 950 */ 445, 1554, 248, 1033, 1619, 120, 1509, 1510, 1515, 129, - /* 960 */ 1565, 1566, 1526, 1570, 1508, 322, 431, 132, 1428, 447, - /* 970 */ 139, 1617, 337, 329, 336, 342, 338, 1091, 343, 451, - /* 980 */ 1090, 345, 145, 1476, 346, 1089, 347, 148, 1526, 52, - /* 990 */ 350, 101, 1088, 436, 1632, 447, 151, 371, 1508, 71, - /* 1000 */ 1509, 1510, 1515, 1558, 369, 451, 1508, 75, 1555, 1476, - /* 1010 */ 374, 1338, 256, 399, 155, 1334, 400, 157, 401, 402, - /* 1020 */ 110, 111, 1526, 1336, 99, 233, 1509, 1510, 1515, 447, - /* 1030 */ 1526, 1332, 112, 433, 128, 1565, 1566, 447, 1570, 451, - /* 1040 */ 1508, 1087, 171, 1476, 411, 1589, 113, 451, 174, 1508, - /* 1050 */ 420, 1476, 409, 412, 264, 1508, 455, 427, 1599, 120, - /* 1060 */ 1509, 1510, 1515, 1062, 1526, 177, 5, 234, 1509, 1510, - /* 1070 */ 1515, 447, 417, 1526, 180, 259, 428, 423, 416, 1526, - /* 1080 */ 447, 451, 4, 1508, 1162, 1476, 447, 100, 268, 1086, - /* 1090 */ 451, 1508, 261, 1579, 1476, 1598, 451, 35, 1633, 184, - /* 1100 */ 1476, 234, 1509, 1510, 1515, 1573, 444, 1526, 17, 125, - /* 1110 */ 226, 1509, 1510, 1515, 447, 1526, 232, 1509, 1510, 1515, - /* 1120 */ 1325, 441, 447, 186, 451, 1508, 1540, 1057, 1476, 187, - /* 1130 */ 1437, 1634, 451, 1508, 453, 454, 1476, 269, 1616, 1436, - /* 1140 */ 193, 459, 458, 1055, 235, 1509, 1510, 1515, 204, 1526, - /* 1150 */ 202, 460, 227, 1509, 1510, 1515, 447, 1526, 216, 1508, - /* 1160 */ 59, 61, 1062, 1349, 447, 1321, 451, 468, 497, 218, - /* 1170 */ 1476, 212, 545, 41, 451, 224, 220, 1470, 1476, 225, - /* 1180 */ 222, 210, 1469, 1526, 1508, 496, 236, 1509, 1510, 1515, - /* 1190 */ 447, 284, 1466, 286, 228, 1509, 1510, 1515, 287, 1051, - /* 1200 */ 451, 1052, 546, 135, 1476, 291, 1464, 498, 1526, 1508, - /* 1210 */ 293, 294, 295, 1463, 1056, 447, 297, 1462, 1508, 299, - /* 1220 */ 237, 1509, 1510, 1515, 1453, 451, 495, 494, 493, 1476, - /* 1230 */ 492, 136, 302, 1526, 303, 1036, 1035, 1447, 1446, 308, - /* 1240 */ 447, 1445, 1526, 1508, 309, 1523, 1509, 1510, 1515, 447, - /* 1250 */ 451, 1058, 1508, 1444, 1476, 1007, 1421, 1420, 1419, 451, - /* 1260 */ 1418, 1417, 1416, 1476, 1415, 1414, 1413, 1526, 1061, 1412, - /* 1270 */ 1522, 1509, 1510, 1515, 447, 1411, 1526, 1508, 1410, 244, - /* 1280 */ 1509, 1510, 1515, 447, 451, 1409, 1508, 1408, 1476, 1407, - /* 1290 */ 1406, 104, 1405, 451, 1404, 1403, 1402, 1476, 1323, 1401, - /* 1300 */ 1400, 1526, 1009, 1399, 1521, 1509, 1510, 1515, 447, 1398, - /* 1310 */ 1526, 1508, 1397, 245, 1509, 1510, 1515, 447, 451, 431, - /* 1320 */ 1396, 1279, 1476, 1461, 1455, 1443, 1434, 451, 1327, 147, - /* 1330 */ 867, 1476, 1278, 1276, 353, 1526, 1274, 1508, 243, 1509, - /* 1340 */ 1510, 1515, 447, 351, 101, 355, 352, 240, 1509, 1510, - /* 1350 */ 1515, 356, 451, 1272, 357, 359, 1476, 361, 360, 210, - /* 1360 */ 1270, 1526, 365, 496, 1259, 363, 364, 1258, 447, 1255, - /* 1370 */ 1329, 74, 230, 1509, 1510, 1515, 976, 99, 451, 514, - /* 1380 */ 974, 1328, 1476, 154, 899, 498, 898, 130, 1565, 1566, - /* 1390 */ 897, 1570, 896, 893, 892, 1268, 253, 1263, 231, 1509, - /* 1400 */ 1510, 1515, 512, 1261, 495, 494, 493, 254, 492, 255, - /* 1410 */ 388, 391, 1254, 393, 1253, 395, 72, 1460, 168, 44, - /* 1420 */ 1043, 1454, 114, 403, 1442, 1441, 1433, 173, 3, 1494, - /* 1430 */ 189, 404, 122, 55, 34, 14, 178, 175, 15, 38, - /* 1440 */ 1187, 1180, 123, 39, 10, 36, 57, 1209, 183, 182, - /* 1450 */ 19, 20, 56, 1208, 1159, 8, 262, 37, 1158, 1432, - /* 1460 */ 1213, 16, 203, 1072, 1214, 1212, 263, 1275, 33, 1123, - /* 1470 */ 456, 469, 205, 1098, 131, 1096, 13, 276, 196, 18, - /* 1480 */ 937, 197, 1185, 62, 199, 201, 473, 46, 476, 467, - /* 1490 */ 58, 965, 479, 482, 1493, 971, 881, 40, 967, 543, - /* 1500 */ 1227, 544, 524, 1273, 960, 471, 208, 957, 474, 888, - /* 1510 */ 954, 477, 865, 948, 480, 499, 887, 886, 946, 483, - /* 1520 */ 906, 885, 884, 63, 883, 882, 47, 903, 901, 952, - /* 1530 */ 64, 878, 877, 211, 489, 951, 501, 876, 525, 529, - /* 1540 */ 1271, 528, 527, 950, 873, 949, 872, 871, 870, 523, - /* 1550 */ 531, 532, 1269, 536, 535, 1257, 533, 537, 539, 540, - /* 1560 */ 970, 1256, 1252, 1059, 219, 547, 548, + /* 0 */ 1390, 1690, 1388, 1563, 268, 26, 203, 323, 482, 1277, + /* 10 */ 469, 1549, 33, 31, 1689, 1563, 1492, 77, 1688, 1302, + /* 20 */ 277, 1549, 1096, 285, 380, 1545, 1552, 1579, 34, 32, + /* 30 */ 30, 29, 28, 1399, 466, 1545, 1551, 248, 1094, 1579, + /* 40 */ 1549, 481, 53, 417, 465, 1535, 466, 441, 1535, 1301, + /* 50 */ 12, 33, 31, 1218, 1545, 1551, 465, 1102, 481, 277, + /* 60 */ 1535, 1096, 293, 1395, 1535, 445, 125, 1564, 468, 1566, + /* 70 */ 1567, 464, 104, 459, 1, 482, 359, 1094, 72, 1564, + /* 80 */ 468, 1566, 1567, 464, 321, 459, 1377, 418, 1629, 12, + /* 90 */ 482, 1232, 249, 1625, 1535, 36, 1102, 564, 62, 77, + /* 100 */ 1399, 1690, 33, 31, 1690, 123, 387, 1291, 102, 1095, + /* 110 */ 277, 1704, 1096, 1, 136, 1399, 1375, 136, 1688, 1392, + /* 120 */ 22, 1688, 443, 132, 1636, 1637, 1690, 1641, 1094, 1280, + /* 130 */ 34, 32, 30, 29, 28, 359, 564, 1331, 1448, 136, + /* 140 */ 12, 1117, 481, 1688, 267, 1579, 1097, 1102, 1095, 1446, + /* 150 */ 87, 127, 466, 86, 85, 84, 83, 82, 81, 80, + /* 160 */ 79, 78, 1440, 469, 1, 518, 280, 1100, 1101, 1491, + /* 170 */ 1145, 1146, 1147, 1148, 1149, 1150, 1151, 461, 1156, 1157, + /* 180 */ 1158, 1159, 1160, 1161, 1162, 1097, 434, 564, 431, 395, + /* 190 */ 316, 389, 315, 560, 559, 394, 36, 137, 101, 1095, + /* 200 */ 390, 388, 137, 391, 55, 266, 1100, 1101, 174, 1145, + /* 210 */ 1146, 1147, 1148, 1149, 1150, 1151, 461, 1156, 1157, 1158, + /* 220 */ 1159, 1160, 1161, 1162, 482, 482, 482, 441, 482, 931, + /* 230 */ 33, 31, 452, 322, 330, 331, 1097, 358, 277, 880, + /* 240 */ 1096, 879, 137, 34, 32, 30, 29, 28, 933, 1399, + /* 250 */ 1399, 1399, 104, 1399, 436, 432, 1094, 1100, 1101, 881, + /* 260 */ 1145, 1146, 1147, 1148, 1149, 1150, 1151, 461, 1156, 1157, + /* 270 */ 1158, 1159, 1160, 1161, 1162, 1102, 33, 31, 1163, 385, + /* 280 */ 384, 250, 345, 143, 277, 1300, 1096, 1328, 102, 521, + /* 290 */ 87, 1371, 7, 86, 85, 84, 83, 82, 81, 80, + /* 300 */ 79, 78, 1094, 133, 1636, 1637, 1132, 1641, 281, 51, + /* 310 */ 1119, 395, 50, 389, 1180, 564, 121, 394, 137, 137, + /* 320 */ 101, 1102, 390, 388, 1401, 391, 1242, 1095, 147, 146, + /* 330 */ 1535, 317, 260, 34, 32, 30, 29, 28, 7, 540, + /* 340 */ 539, 538, 537, 292, 879, 536, 535, 534, 107, 529, + /* 350 */ 528, 527, 526, 525, 524, 523, 522, 114, 100, 53, + /* 360 */ 378, 564, 383, 1181, 1097, 428, 1240, 1241, 1243, 1244, + /* 370 */ 1690, 124, 99, 1095, 261, 1357, 259, 258, 453, 382, + /* 380 */ 1394, 1186, 435, 136, 386, 1100, 1101, 1688, 1145, 1146, + /* 390 */ 1147, 1148, 1149, 1150, 1151, 461, 1156, 1157, 1158, 1159, + /* 400 */ 1160, 1161, 1162, 441, 33, 31, 393, 392, 441, 532, + /* 410 */ 1097, 1120, 277, 311, 1096, 137, 25, 275, 1175, 1176, + /* 420 */ 1177, 1178, 1179, 1183, 1184, 1185, 515, 514, 104, 456, + /* 430 */ 1094, 1100, 1101, 104, 1145, 1146, 1147, 1148, 1149, 1150, + /* 440 */ 1151, 461, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1102, + /* 450 */ 33, 31, 445, 482, 409, 287, 69, 1096, 277, 120, + /* 460 */ 1096, 1448, 1396, 121, 102, 1121, 7, 282, 905, 102, + /* 470 */ 105, 1401, 1446, 1094, 9, 8, 1094, 1391, 1399, 134, + /* 480 */ 1636, 1637, 449, 1641, 196, 1636, 440, 906, 439, 564, + /* 490 */ 1376, 1690, 1102, 1690, 1299, 1102, 34, 32, 30, 29, + /* 500 */ 28, 1095, 1318, 1118, 136, 1298, 136, 518, 1688, 1297, + /* 510 */ 1688, 1296, 1, 969, 505, 504, 503, 973, 502, 975, + /* 520 */ 976, 501, 978, 498, 396, 984, 495, 986, 987, 492, + /* 530 */ 489, 247, 564, 1117, 288, 564, 482, 508, 1097, 1535, + /* 540 */ 338, 1482, 1484, 350, 1095, 1516, 1172, 1095, 1194, 1295, + /* 550 */ 1535, 106, 351, 100, 1535, 513, 1535, 383, 1313, 1100, + /* 560 */ 1101, 1399, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 461, + /* 570 */ 1156, 1157, 1158, 1159, 1160, 1161, 1162, 516, 1479, 386, + /* 580 */ 398, 1097, 482, 198, 1097, 145, 34, 32, 30, 29, + /* 590 */ 28, 479, 225, 1448, 1535, 1429, 512, 511, 510, 289, + /* 600 */ 509, 520, 1100, 1101, 1446, 1100, 1101, 1399, 1145, 1146, + /* 610 */ 1147, 1148, 1149, 1150, 1151, 461, 1156, 1157, 1158, 1159, + /* 620 */ 1160, 1161, 1162, 1563, 250, 349, 450, 1294, 344, 343, + /* 630 */ 342, 341, 340, 1384, 337, 336, 335, 334, 333, 329, + /* 640 */ 328, 327, 326, 325, 324, 448, 482, 1579, 34, 32, + /* 650 */ 30, 29, 28, 482, 444, 480, 567, 1180, 1182, 290, + /* 660 */ 482, 1386, 217, 1293, 465, 533, 531, 121, 1535, 291, + /* 670 */ 221, 1399, 1535, 98, 1563, 1401, 1187, 1290, 1399, 556, + /* 680 */ 1289, 552, 548, 544, 220, 1399, 73, 1564, 468, 1566, + /* 690 */ 1567, 464, 1122, 459, 1648, 1213, 1629, 6, 1579, 1643, + /* 700 */ 270, 1625, 131, 1288, 1287, 444, 1181, 1448, 1535, 1286, + /* 710 */ 70, 23, 1285, 215, 199, 465, 24, 1382, 1483, 1535, + /* 720 */ 424, 1656, 1535, 1640, 1186, 1535, 34, 32, 30, 29, + /* 730 */ 28, 30, 29, 28, 1448, 1284, 1217, 73, 1564, 468, + /* 740 */ 1566, 1567, 464, 478, 459, 1447, 1643, 1629, 1535, 1535, + /* 750 */ 1225, 270, 1625, 131, 1535, 1563, 1119, 1535, 400, 25, + /* 760 */ 275, 1175, 1176, 1177, 1178, 1179, 1183, 1184, 1185, 1283, + /* 770 */ 1639, 423, 1657, 408, 180, 1272, 1524, 1311, 1643, 1579, + /* 780 */ 1535, 34, 32, 30, 29, 28, 466, 173, 1168, 1074, + /* 790 */ 403, 176, 1282, 177, 1119, 397, 465, 121, 308, 401, + /* 800 */ 1535, 172, 1638, 165, 167, 1402, 163, 166, 1082, 1083, + /* 810 */ 184, 1563, 300, 169, 1535, 460, 168, 310, 73, 1564, + /* 820 */ 468, 1566, 1567, 464, 507, 459, 171, 45, 1629, 170, + /* 830 */ 44, 416, 270, 1625, 1702, 1579, 1374, 1535, 407, 1292, + /* 840 */ 122, 1563, 466, 1663, 1132, 231, 9, 8, 1358, 112, + /* 850 */ 1213, 405, 465, 420, 1271, 447, 1535, 229, 47, 187, + /* 860 */ 1274, 1275, 1239, 189, 35, 1579, 200, 1441, 1188, 35, + /* 870 */ 148, 1563, 466, 1152, 73, 1564, 468, 1566, 1567, 464, + /* 880 */ 1556, 459, 465, 429, 1629, 1105, 1535, 410, 270, 1625, + /* 890 */ 1702, 377, 1554, 1104, 35, 1579, 193, 106, 1057, 1686, + /* 900 */ 68, 513, 466, 442, 73, 1564, 468, 1566, 1567, 464, + /* 910 */ 64, 459, 465, 206, 1629, 1659, 1535, 208, 270, 1625, + /* 920 */ 1702, 445, 1580, 516, 109, 202, 1563, 110, 474, 1647, + /* 930 */ 1216, 214, 2, 71, 238, 1564, 468, 1566, 1567, 464, + /* 940 */ 1117, 459, 512, 511, 510, 112, 509, 47, 487, 962, + /* 950 */ 1579, 957, 990, 295, 299, 255, 1108, 466, 1066, 222, + /* 960 */ 1690, 49, 48, 320, 1107, 142, 931, 465, 144, 332, + /* 970 */ 314, 1535, 257, 136, 110, 1481, 1563, 1688, 994, 111, + /* 980 */ 339, 112, 256, 1001, 306, 1000, 302, 298, 139, 74, + /* 990 */ 1564, 468, 1566, 1567, 464, 347, 459, 346, 110, 1629, + /* 1000 */ 1579, 348, 113, 1628, 1625, 1126, 353, 466, 352, 354, + /* 1010 */ 1125, 149, 152, 356, 355, 1124, 357, 465, 360, 137, + /* 1020 */ 160, 1535, 155, 130, 1563, 52, 158, 1123, 379, 376, + /* 1030 */ 381, 372, 368, 364, 159, 1563, 97, 1389, 265, 74, + /* 1040 */ 1564, 468, 1566, 1567, 464, 1102, 459, 162, 1579, 1629, + /* 1050 */ 1520, 1385, 164, 455, 1625, 463, 115, 116, 1387, 1579, + /* 1060 */ 54, 175, 1383, 157, 223, 465, 466, 117, 118, 1535, + /* 1070 */ 411, 419, 415, 412, 179, 1122, 465, 182, 421, 1670, + /* 1080 */ 1535, 422, 1660, 430, 472, 1669, 427, 245, 1564, 468, + /* 1090 */ 1566, 1567, 464, 462, 459, 457, 1601, 185, 125, 1564, + /* 1100 */ 468, 1566, 1567, 464, 188, 459, 1563, 269, 284, 283, + /* 1110 */ 5, 433, 438, 103, 426, 4, 1644, 1121, 1110, 1213, + /* 1120 */ 156, 1650, 151, 37, 153, 271, 451, 454, 16, 1490, + /* 1130 */ 1579, 1489, 195, 470, 1103, 129, 1563, 466, 471, 1610, + /* 1140 */ 194, 150, 446, 1703, 1563, 192, 475, 465, 476, 279, + /* 1150 */ 210, 1535, 477, 1102, 212, 63, 1400, 61, 224, 1687, + /* 1160 */ 1579, 201, 1372, 1705, 226, 219, 563, 466, 1579, 74, + /* 1170 */ 1564, 468, 1566, 1567, 464, 466, 459, 465, 128, 1629, + /* 1180 */ 485, 1535, 43, 232, 1626, 465, 233, 228, 230, 1535, + /* 1190 */ 1529, 1563, 425, 483, 1528, 294, 1525, 296, 297, 241, + /* 1200 */ 1564, 468, 1566, 1567, 464, 1106, 459, 246, 1564, 468, + /* 1210 */ 1566, 1567, 464, 1090, 459, 1579, 1091, 140, 1523, 303, + /* 1220 */ 301, 304, 466, 305, 1522, 307, 1521, 309, 1506, 141, + /* 1230 */ 312, 313, 465, 1069, 1068, 1500, 1535, 437, 1040, 274, + /* 1240 */ 1499, 1563, 1111, 319, 318, 1498, 1497, 1474, 1473, 1472, + /* 1250 */ 1471, 1470, 1469, 1468, 246, 1564, 468, 1566, 1567, 464, + /* 1260 */ 1467, 459, 1466, 1114, 1465, 1579, 1464, 1463, 1462, 1461, + /* 1270 */ 1460, 1459, 463, 108, 1458, 1457, 1456, 1455, 1454, 1563, + /* 1280 */ 1453, 1042, 465, 1452, 1451, 1450, 1535, 1449, 1330, 1514, + /* 1290 */ 1563, 1508, 1496, 1487, 1378, 898, 1329, 154, 1327, 361, + /* 1300 */ 363, 362, 1325, 1579, 245, 1564, 468, 1566, 1567, 464, + /* 1310 */ 466, 459, 1323, 1602, 1579, 367, 371, 365, 366, 369, + /* 1320 */ 465, 466, 370, 1321, 1535, 1310, 1309, 276, 373, 1306, + /* 1330 */ 1380, 465, 1006, 374, 530, 1535, 161, 1009, 278, 1279, + /* 1340 */ 1379, 76, 246, 1564, 468, 1566, 1567, 464, 1563, 459, + /* 1350 */ 1319, 375, 930, 246, 1564, 468, 1566, 1567, 464, 929, + /* 1360 */ 459, 1563, 928, 96, 95, 94, 93, 92, 91, 90, + /* 1370 */ 89, 88, 1579, 927, 532, 924, 923, 262, 1314, 466, + /* 1380 */ 263, 399, 1312, 264, 402, 1579, 1305, 404, 1304, 465, + /* 1390 */ 406, 75, 466, 1535, 1513, 1076, 1507, 413, 1495, 1563, + /* 1400 */ 1494, 1486, 465, 181, 3, 56, 1535, 119, 1563, 13, + /* 1410 */ 126, 234, 1564, 468, 1566, 1567, 464, 190, 459, 35, + /* 1420 */ 41, 14, 186, 1579, 240, 1564, 468, 1566, 1567, 464, + /* 1430 */ 466, 459, 1579, 46, 1238, 191, 178, 20, 414, 466, + /* 1440 */ 465, 1231, 40, 57, 1535, 21, 1563, 1210, 1554, 465, + /* 1450 */ 183, 1209, 39, 1535, 1265, 15, 197, 58, 1260, 135, + /* 1460 */ 1259, 1563, 242, 1564, 468, 1566, 1567, 464, 272, 459, + /* 1470 */ 1579, 235, 1564, 468, 1566, 1567, 464, 466, 459, 1264, + /* 1480 */ 1263, 273, 8, 1173, 17, 1579, 1155, 465, 458, 138, + /* 1490 */ 1154, 1535, 466, 27, 204, 1140, 1153, 10, 18, 19, + /* 1500 */ 38, 467, 465, 205, 1236, 1485, 1535, 11, 207, 243, + /* 1510 */ 1564, 468, 1566, 1567, 464, 211, 459, 64, 209, 473, + /* 1520 */ 59, 60, 213, 1553, 236, 1564, 468, 1566, 1567, 464, + /* 1530 */ 1563, 459, 1112, 42, 216, 484, 991, 486, 1563, 286, + /* 1540 */ 488, 490, 988, 491, 493, 985, 979, 496, 494, 497, + /* 1550 */ 499, 977, 968, 500, 1579, 983, 982, 981, 65, 980, + /* 1560 */ 1003, 466, 1579, 1002, 506, 66, 67, 999, 1563, 466, + /* 1570 */ 996, 465, 896, 517, 937, 1535, 519, 919, 218, 465, + /* 1580 */ 918, 917, 916, 1535, 915, 914, 912, 913, 932, 934, + /* 1590 */ 909, 908, 1579, 244, 1564, 468, 1566, 1567, 464, 466, + /* 1600 */ 459, 237, 1564, 468, 1566, 1567, 464, 1326, 459, 465, + /* 1610 */ 907, 904, 903, 1535, 902, 901, 1563, 541, 542, 1324, + /* 1620 */ 1322, 543, 545, 546, 547, 550, 549, 1320, 551, 553, + /* 1630 */ 554, 1575, 1564, 468, 1566, 1567, 464, 1308, 459, 555, + /* 1640 */ 1579, 557, 558, 1307, 1303, 561, 562, 466, 1098, 566, + /* 1650 */ 227, 565, 1278, 1278, 1563, 1278, 1278, 465, 1278, 1278, + /* 1660 */ 1278, 1535, 1278, 1563, 1278, 1278, 1278, 1278, 1278, 1278, + /* 1670 */ 1278, 1278, 1278, 1278, 1278, 1278, 1278, 1278, 1579, 1574, + /* 1680 */ 1564, 468, 1566, 1567, 464, 466, 459, 1579, 1278, 1278, + /* 1690 */ 1278, 1278, 1278, 1278, 466, 465, 1278, 1278, 1278, 1535, + /* 1700 */ 1278, 1563, 1278, 1278, 465, 1278, 1278, 1278, 1535, 1278, + /* 1710 */ 1278, 1278, 1278, 1278, 1278, 1278, 1563, 1573, 1564, 468, + /* 1720 */ 1566, 1567, 464, 1278, 459, 1579, 253, 1564, 468, 1566, + /* 1730 */ 1567, 464, 466, 459, 1278, 1278, 1278, 1278, 1278, 1278, + /* 1740 */ 1579, 1278, 465, 1278, 1278, 1278, 1535, 466, 1278, 1278, + /* 1750 */ 1278, 1278, 1278, 1278, 1563, 1278, 1278, 465, 1278, 1278, + /* 1760 */ 1278, 1535, 1278, 1278, 252, 1564, 468, 1566, 1567, 464, + /* 1770 */ 1278, 459, 1278, 1278, 1278, 1278, 1278, 1278, 1579, 254, + /* 1780 */ 1564, 468, 1566, 1567, 464, 466, 459, 1278, 1278, 1278, + /* 1790 */ 1278, 1278, 1563, 1278, 1278, 465, 1278, 1278, 1278, 1535, + /* 1800 */ 1278, 1278, 1278, 1278, 1278, 1278, 1278, 1278, 1278, 1278, + /* 1810 */ 1278, 1278, 1278, 1278, 1278, 1278, 1579, 251, 1564, 468, + /* 1820 */ 1566, 1567, 464, 466, 459, 1278, 1278, 1278, 1278, 1278, + /* 1830 */ 1278, 1278, 1278, 465, 1278, 1278, 1278, 1535, 1278, 1278, + /* 1840 */ 1278, 1278, 1278, 1278, 1278, 1278, 1278, 1278, 1278, 1278, + /* 1850 */ 1278, 1278, 1278, 1278, 1278, 239, 1564, 468, 1566, 1567, + /* 1860 */ 464, 1278, 459, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 255, 211, 242, 258, 255, 220, 261, 280, 281, 213, - /* 10 */ 261, 215, 12, 13, 229, 2, 264, 214, 214, 259, - /* 20 */ 20, 236, 22, 2, 22, 12, 13, 14, 15, 16, - /* 30 */ 245, 271, 272, 12, 13, 14, 15, 16, 38, 242, - /* 40 */ 38, 238, 12, 13, 14, 15, 16, 295, 245, 20, - /* 50 */ 50, 12, 13, 14, 264, 20, 259, 57, 255, 20, - /* 60 */ 308, 22, 259, 259, 312, 12, 13, 14, 271, 272, - /* 70 */ 214, 20, 273, 20, 74, 22, 247, 38, 275, 276, - /* 80 */ 277, 278, 279, 254, 255, 295, 283, 284, 285, 50, - /* 90 */ 291, 38, 0, 0, 238, 295, 57, 97, 308, 49, - /* 100 */ 297, 245, 312, 74, 20, 75, 303, 304, 308, 109, - /* 110 */ 57, 255, 312, 74, 74, 259, 24, 25, 26, 27, - /* 120 */ 28, 29, 30, 31, 32, 74, 86, 74, 75, 47, - /* 130 */ 259, 275, 276, 277, 278, 279, 97, 67, 238, 283, - /* 140 */ 284, 285, 271, 272, 244, 52, 146, 54, 109, 249, - /* 150 */ 97, 58, 220, 20, 61, 73, 63, 64, 76, 66, - /* 160 */ 304, 229, 109, 163, 164, 165, 166, 167, 168, 169, - /* 170 */ 170, 171, 172, 173, 174, 175, 176, 245, 12, 13, - /* 180 */ 14, 15, 16, 113, 114, 146, 21, 237, 188, 24, - /* 190 */ 25, 26, 27, 28, 29, 30, 31, 32, 248, 146, - /* 200 */ 217, 218, 163, 164, 165, 166, 167, 168, 169, 170, - /* 210 */ 171, 172, 173, 174, 175, 176, 163, 164, 165, 166, - /* 220 */ 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, - /* 230 */ 12, 13, 12, 13, 14, 15, 16, 220, 20, 188, - /* 240 */ 22, 214, 163, 61, 12, 13, 229, 65, 188, 52, - /* 250 */ 264, 54, 20, 236, 22, 58, 38, 145, 61, 147, - /* 260 */ 63, 64, 245, 66, 3, 20, 220, 132, 50, 87, - /* 270 */ 38, 138, 188, 214, 0, 57, 197, 198, 199, 200, - /* 280 */ 201, 295, 220, 12, 13, 150, 259, 4, 21, 57, - /* 290 */ 222, 20, 74, 22, 308, 75, 250, 238, 312, 219, - /* 300 */ 188, 34, 19, 235, 245, 139, 74, 245, 220, 38, - /* 310 */ 36, 243, 177, 233, 255, 97, 33, 229, 259, 36, - /* 320 */ 240, 223, 220, 220, 41, 227, 264, 109, 57, 97, - /* 330 */ 47, 229, 229, 245, 275, 276, 277, 278, 279, 222, - /* 340 */ 278, 109, 283, 284, 285, 74, 220, 245, 245, 20, - /* 350 */ 288, 289, 290, 294, 292, 229, 73, 295, 136, 76, - /* 360 */ 243, 230, 224, 225, 146, 14, 15, 16, 97, 238, - /* 370 */ 308, 245, 224, 225, 312, 209, 231, 246, 146, 234, - /* 380 */ 109, 163, 164, 165, 166, 167, 168, 169, 170, 171, - /* 390 */ 172, 173, 174, 175, 176, 163, 164, 165, 166, 167, - /* 400 */ 168, 169, 170, 171, 172, 173, 174, 175, 176, 164, - /* 410 */ 165, 166, 167, 168, 273, 193, 194, 146, 1, 2, - /* 420 */ 188, 12, 13, 14, 15, 16, 12, 13, 14, 15, - /* 430 */ 16, 20, 291, 214, 163, 164, 165, 166, 167, 168, - /* 440 */ 169, 170, 171, 172, 173, 174, 175, 176, 12, 13, - /* 450 */ 12, 13, 14, 15, 16, 18, 20, 20, 22, 12, - /* 460 */ 13, 14, 15, 16, 27, 204, 214, 30, 0, 273, - /* 470 */ 220, 20, 33, 22, 38, 36, 39, 0, 259, 229, - /* 480 */ 214, 42, 0, 44, 45, 46, 47, 291, 50, 238, - /* 490 */ 35, 40, 75, 57, 14, 245, 245, 50, 21, 214, - /* 500 */ 20, 24, 25, 26, 27, 28, 29, 30, 31, 32, - /* 510 */ 74, 259, 73, 75, 220, 76, 61, 49, 220, 38, - /* 520 */ 65, 83, 245, 229, 49, 259, 214, 229, 277, 252, - /* 530 */ 83, 49, 77, 97, 79, 80, 43, 82, 57, 245, - /* 540 */ 214, 20, 87, 245, 259, 109, 214, 138, 220, 112, - /* 550 */ 214, 214, 115, 116, 117, 118, 119, 229, 121, 122, - /* 560 */ 123, 124, 125, 126, 127, 128, 129, 130, 131, 238, - /* 570 */ 132, 259, 133, 245, 135, 244, 137, 57, 230, 132, - /* 580 */ 249, 238, 146, 0, 85, 259, 238, 244, 150, 220, - /* 590 */ 4, 259, 249, 154, 246, 259, 259, 150, 229, 163, - /* 600 */ 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, - /* 610 */ 174, 175, 176, 219, 245, 177, 178, 179, 180, 181, - /* 620 */ 182, 183, 184, 185, 177, 178, 179, 180, 181, 182, - /* 630 */ 183, 184, 185, 214, 240, 52, 53, 54, 55, 56, - /* 640 */ 20, 58, 59, 60, 61, 62, 63, 64, 65, 66, - /* 650 */ 67, 68, 69, 70, 88, 89, 90, 91, 92, 93, - /* 660 */ 94, 95, 96, 97, 98, 19, 100, 101, 102, 103, - /* 670 */ 104, 105, 18, 214, 239, 214, 214, 23, 259, 33, - /* 680 */ 187, 214, 36, 78, 12, 13, 81, 230, 42, 35, - /* 690 */ 44, 45, 46, 47, 22, 238, 142, 238, 238, 214, - /* 700 */ 214, 214, 48, 246, 245, 214, 214, 238, 214, 249, - /* 710 */ 38, 157, 186, 187, 255, 246, 238, 0, 259, 73, - /* 720 */ 259, 259, 76, 264, 238, 214, 259, 249, 226, 57, - /* 730 */ 228, 245, 1, 2, 275, 276, 277, 278, 279, 22, - /* 740 */ 71, 255, 283, 284, 259, 259, 259, 74, 262, 238, - /* 750 */ 259, 259, 106, 259, 295, 71, 245, 84, 138, 75, - /* 760 */ 214, 275, 276, 277, 278, 111, 255, 308, 71, 97, - /* 770 */ 259, 312, 75, 262, 78, 189, 78, 81, 239, 81, - /* 780 */ 134, 109, 78, 137, 238, 81, 275, 276, 277, 278, - /* 790 */ 71, 245, 71, 139, 140, 141, 75, 143, 152, 239, - /* 800 */ 154, 255, 148, 214, 0, 259, 0, 71, 164, 165, - /* 810 */ 156, 75, 158, 71, 160, 161, 162, 75, 146, 50, - /* 820 */ 239, 275, 276, 277, 278, 279, 22, 238, 22, 283, - /* 830 */ 284, 285, 71, 71, 245, 163, 75, 75, 239, 214, - /* 840 */ 294, 38, 188, 71, 255, 214, 71, 75, 259, 71, - /* 850 */ 75, 71, 71, 75, 239, 75, 75, 38, 38, 267, - /* 860 */ 57, 239, 215, 238, 275, 276, 277, 278, 279, 238, - /* 870 */ 245, 315, 283, 284, 285, 206, 245, 227, 71, 220, - /* 880 */ 255, 214, 75, 294, 259, 255, 255, 255, 71, 264, - /* 890 */ 259, 220, 75, 71, 214, 71, 306, 75, 300, 75, - /* 900 */ 275, 276, 277, 278, 248, 238, 275, 276, 277, 278, - /* 910 */ 279, 217, 245, 274, 283, 284, 245, 71, 238, 293, - /* 920 */ 295, 75, 255, 264, 238, 245, 259, 208, 109, 109, - /* 930 */ 309, 296, 163, 308, 20, 255, 220, 312, 214, 259, - /* 940 */ 36, 38, 275, 276, 277, 278, 279, 270, 265, 278, - /* 950 */ 283, 284, 224, 144, 295, 275, 276, 277, 278, 288, - /* 960 */ 289, 290, 238, 292, 214, 220, 220, 308, 220, 245, - /* 970 */ 120, 312, 132, 253, 251, 220, 251, 20, 269, 255, - /* 980 */ 20, 263, 222, 259, 245, 20, 256, 222, 238, 222, - /* 990 */ 220, 245, 20, 313, 314, 245, 222, 238, 214, 275, - /* 1000 */ 276, 277, 278, 279, 216, 255, 214, 220, 284, 259, - /* 1010 */ 224, 238, 216, 245, 238, 238, 269, 238, 153, 268, - /* 1020 */ 238, 238, 238, 238, 278, 275, 276, 277, 278, 245, - /* 1030 */ 238, 238, 238, 287, 288, 289, 290, 245, 292, 255, - /* 1040 */ 214, 20, 219, 259, 245, 274, 238, 255, 219, 214, - /* 1050 */ 196, 259, 263, 256, 262, 214, 195, 307, 305, 275, - /* 1060 */ 276, 277, 278, 57, 238, 260, 203, 275, 276, 277, - /* 1070 */ 278, 245, 259, 238, 260, 259, 202, 259, 191, 238, - /* 1080 */ 245, 255, 190, 214, 187, 259, 245, 245, 262, 20, - /* 1090 */ 255, 214, 210, 302, 259, 305, 255, 120, 314, 301, - /* 1100 */ 259, 275, 276, 277, 278, 273, 207, 238, 74, 299, - /* 1110 */ 275, 276, 277, 278, 245, 238, 275, 276, 277, 278, - /* 1120 */ 0, 205, 245, 298, 255, 214, 282, 22, 259, 286, - /* 1130 */ 260, 316, 255, 214, 259, 259, 259, 259, 311, 260, - /* 1140 */ 310, 257, 135, 38, 275, 276, 277, 278, 219, 238, - /* 1150 */ 245, 256, 275, 276, 277, 278, 245, 238, 234, 214, - /* 1160 */ 219, 74, 57, 245, 245, 228, 255, 241, 224, 220, - /* 1170 */ 259, 219, 216, 266, 255, 232, 221, 0, 259, 232, - /* 1180 */ 212, 61, 0, 238, 214, 65, 275, 276, 277, 278, - /* 1190 */ 245, 64, 0, 38, 275, 276, 277, 278, 159, 38, - /* 1200 */ 255, 38, 97, 38, 259, 159, 0, 87, 238, 214, - /* 1210 */ 38, 38, 159, 0, 109, 245, 38, 0, 214, 38, - /* 1220 */ 275, 276, 277, 278, 0, 255, 106, 107, 108, 259, - /* 1230 */ 110, 74, 150, 238, 149, 109, 146, 0, 0, 53, - /* 1240 */ 245, 0, 238, 214, 142, 275, 276, 277, 278, 245, - /* 1250 */ 255, 146, 214, 0, 259, 86, 0, 0, 0, 255, - /* 1260 */ 0, 0, 0, 259, 0, 0, 0, 238, 163, 0, - /* 1270 */ 275, 276, 277, 278, 245, 0, 238, 214, 0, 275, - /* 1280 */ 276, 277, 278, 245, 255, 0, 214, 0, 259, 0, - /* 1290 */ 0, 120, 0, 255, 0, 0, 0, 259, 0, 0, - /* 1300 */ 0, 238, 22, 0, 275, 276, 277, 278, 245, 0, - /* 1310 */ 238, 214, 0, 275, 276, 277, 278, 245, 255, 220, - /* 1320 */ 0, 0, 259, 0, 0, 0, 0, 255, 0, 43, - /* 1330 */ 51, 259, 0, 0, 43, 238, 0, 214, 275, 276, - /* 1340 */ 277, 278, 245, 38, 245, 38, 36, 275, 276, 277, - /* 1350 */ 278, 36, 255, 0, 43, 38, 259, 43, 36, 61, - /* 1360 */ 0, 238, 43, 65, 0, 38, 36, 0, 245, 0, - /* 1370 */ 0, 83, 275, 276, 277, 278, 38, 278, 255, 71, - /* 1380 */ 22, 0, 259, 81, 38, 87, 38, 288, 289, 290, - /* 1390 */ 38, 292, 38, 38, 38, 0, 22, 0, 275, 276, - /* 1400 */ 277, 278, 71, 0, 106, 107, 108, 22, 110, 22, - /* 1410 */ 39, 38, 0, 22, 0, 22, 20, 0, 155, 138, - /* 1420 */ 38, 0, 151, 22, 0, 0, 0, 43, 71, 86, - /* 1430 */ 86, 138, 135, 74, 71, 192, 75, 133, 192, 138, - /* 1440 */ 75, 75, 74, 71, 192, 186, 4, 38, 71, 74, - /* 1450 */ 74, 71, 74, 38, 75, 2, 38, 71, 75, 0, - /* 1460 */ 38, 71, 43, 22, 75, 38, 38, 0, 74, 163, - /* 1470 */ 136, 38, 133, 75, 86, 75, 74, 38, 86, 74, - /* 1480 */ 22, 75, 75, 84, 74, 74, 38, 74, 38, 85, - /* 1490 */ 74, 22, 38, 38, 86, 38, 22, 74, 38, 22, - /* 1500 */ 317, 21, 36, 0, 75, 74, 86, 75, 74, 38, - /* 1510 */ 75, 74, 51, 75, 74, 50, 38, 38, 75, 74, - /* 1520 */ 57, 38, 38, 74, 38, 38, 74, 57, 38, 99, - /* 1530 */ 74, 38, 38, 71, 87, 99, 72, 38, 43, 43, - /* 1540 */ 0, 36, 38, 99, 38, 99, 38, 38, 38, 38, - /* 1550 */ 38, 36, 0, 36, 38, 0, 43, 43, 38, 37, - /* 1560 */ 109, 0, 0, 22, 22, 21, 20, 317, 317, 317, - /* 1570 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1580 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1590 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1600 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1610 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1620 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1630 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1640 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1650 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1660 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1670 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1680 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1690 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1700 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1710 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1720 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1730 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1740 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1750 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1760 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 1770 */ 317, 317, 317, 317, 317, 317, 317, 317, + /* 0 */ 223, 312, 248, 223, 251, 297, 298, 229, 229, 220, + /* 10 */ 264, 268, 12, 13, 325, 223, 270, 238, 329, 223, + /* 20 */ 20, 268, 22, 251, 245, 282, 283, 247, 12, 13, + /* 30 */ 14, 15, 16, 254, 254, 282, 283, 259, 38, 247, + /* 40 */ 268, 20, 231, 229, 264, 268, 254, 229, 268, 223, + /* 50 */ 50, 12, 13, 14, 282, 283, 264, 57, 20, 20, + /* 60 */ 268, 22, 273, 252, 268, 273, 286, 287, 288, 289, + /* 70 */ 290, 291, 254, 293, 74, 229, 49, 38, 286, 287, + /* 80 */ 288, 289, 290, 291, 238, 293, 0, 273, 296, 50, + /* 90 */ 229, 75, 300, 301, 268, 74, 57, 97, 228, 238, + /* 100 */ 254, 312, 12, 13, 312, 222, 245, 224, 290, 109, + /* 110 */ 20, 331, 22, 74, 325, 254, 0, 325, 329, 249, + /* 120 */ 2, 329, 304, 305, 306, 307, 312, 309, 38, 0, + /* 130 */ 12, 13, 14, 15, 16, 49, 97, 0, 247, 325, + /* 140 */ 50, 20, 20, 329, 253, 247, 146, 57, 109, 258, + /* 150 */ 21, 246, 254, 24, 25, 26, 27, 28, 29, 30, + /* 160 */ 31, 32, 257, 264, 74, 49, 267, 167, 168, 270, + /* 170 */ 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, + /* 180 */ 180, 181, 182, 183, 184, 146, 288, 97, 136, 52, + /* 190 */ 145, 54, 147, 226, 227, 58, 74, 197, 61, 109, + /* 200 */ 63, 64, 197, 66, 155, 156, 167, 168, 159, 170, + /* 210 */ 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, + /* 220 */ 181, 182, 183, 184, 229, 229, 229, 229, 229, 38, + /* 230 */ 12, 13, 71, 238, 238, 238, 146, 238, 20, 20, + /* 240 */ 22, 22, 197, 12, 13, 14, 15, 16, 57, 254, + /* 250 */ 254, 254, 254, 254, 202, 203, 38, 167, 168, 40, + /* 260 */ 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, + /* 270 */ 180, 181, 182, 183, 184, 57, 12, 13, 14, 233, + /* 280 */ 234, 50, 67, 47, 20, 223, 22, 0, 290, 235, + /* 290 */ 21, 237, 74, 24, 25, 26, 27, 28, 29, 30, + /* 300 */ 31, 32, 38, 305, 306, 307, 75, 309, 239, 73, + /* 310 */ 20, 52, 76, 54, 83, 97, 247, 58, 197, 197, + /* 320 */ 61, 57, 63, 64, 255, 66, 167, 109, 113, 114, + /* 330 */ 268, 273, 35, 12, 13, 14, 15, 16, 74, 52, + /* 340 */ 53, 54, 55, 56, 22, 58, 59, 60, 61, 62, + /* 350 */ 63, 64, 65, 66, 67, 68, 69, 70, 61, 231, + /* 360 */ 38, 97, 65, 132, 146, 206, 207, 208, 209, 210, + /* 370 */ 312, 232, 244, 109, 77, 236, 79, 80, 217, 82, + /* 380 */ 252, 150, 20, 325, 87, 167, 168, 329, 170, 171, + /* 390 */ 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, + /* 400 */ 182, 183, 184, 229, 12, 13, 233, 234, 229, 71, + /* 410 */ 146, 20, 20, 75, 22, 197, 185, 186, 187, 188, + /* 420 */ 189, 190, 191, 192, 193, 194, 233, 234, 254, 50, + /* 430 */ 38, 167, 168, 254, 170, 171, 172, 173, 174, 175, + /* 440 */ 176, 177, 178, 179, 180, 181, 182, 183, 184, 57, + /* 450 */ 12, 13, 273, 229, 273, 239, 228, 22, 20, 138, + /* 460 */ 22, 247, 238, 247, 290, 20, 74, 253, 38, 290, + /* 470 */ 242, 255, 258, 38, 1, 2, 38, 249, 254, 305, + /* 480 */ 306, 307, 71, 309, 305, 306, 307, 57, 309, 97, + /* 490 */ 0, 312, 57, 312, 223, 57, 12, 13, 14, 15, + /* 500 */ 16, 109, 0, 20, 325, 223, 325, 49, 329, 223, + /* 510 */ 329, 223, 74, 88, 89, 90, 91, 92, 93, 94, + /* 520 */ 95, 96, 97, 98, 22, 100, 101, 102, 103, 104, + /* 530 */ 105, 18, 97, 20, 256, 97, 229, 85, 146, 268, + /* 540 */ 27, 263, 264, 30, 109, 238, 167, 109, 75, 223, + /* 550 */ 268, 61, 39, 61, 268, 65, 268, 65, 0, 167, + /* 560 */ 168, 254, 170, 171, 172, 173, 174, 175, 176, 177, + /* 570 */ 178, 179, 180, 181, 182, 183, 184, 87, 254, 87, + /* 580 */ 22, 146, 229, 138, 146, 261, 12, 13, 14, 15, + /* 590 */ 16, 238, 240, 247, 268, 243, 106, 107, 108, 253, + /* 600 */ 110, 57, 167, 168, 258, 167, 168, 254, 170, 171, + /* 610 */ 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, + /* 620 */ 182, 183, 184, 223, 50, 112, 215, 223, 115, 116, + /* 630 */ 117, 118, 119, 248, 121, 122, 123, 124, 125, 126, + /* 640 */ 127, 128, 129, 130, 131, 3, 229, 247, 12, 13, + /* 650 */ 14, 15, 16, 229, 254, 238, 19, 83, 132, 239, + /* 660 */ 229, 248, 238, 223, 264, 233, 234, 247, 268, 238, + /* 670 */ 33, 254, 268, 36, 223, 255, 150, 223, 254, 42, + /* 680 */ 223, 44, 45, 46, 47, 254, 286, 287, 288, 289, + /* 690 */ 290, 291, 20, 293, 195, 196, 296, 43, 247, 284, + /* 700 */ 300, 301, 302, 223, 223, 254, 132, 247, 268, 223, + /* 710 */ 73, 185, 223, 76, 314, 264, 2, 248, 258, 268, + /* 720 */ 320, 321, 268, 308, 150, 268, 12, 13, 14, 15, + /* 730 */ 16, 14, 15, 16, 247, 223, 4, 286, 287, 288, + /* 740 */ 289, 290, 291, 106, 293, 258, 284, 296, 268, 268, + /* 750 */ 14, 300, 301, 302, 268, 223, 20, 268, 4, 185, + /* 760 */ 186, 187, 188, 189, 190, 191, 192, 193, 194, 223, + /* 770 */ 308, 134, 321, 19, 137, 139, 0, 0, 284, 247, + /* 780 */ 268, 12, 13, 14, 15, 16, 254, 33, 14, 152, + /* 790 */ 36, 154, 223, 248, 20, 41, 264, 247, 142, 22, + /* 800 */ 268, 47, 308, 78, 78, 255, 81, 81, 157, 158, + /* 810 */ 138, 223, 36, 78, 268, 248, 81, 161, 286, 287, + /* 820 */ 288, 289, 290, 291, 248, 293, 78, 73, 296, 81, + /* 830 */ 76, 276, 300, 301, 302, 247, 0, 268, 21, 224, + /* 840 */ 18, 223, 254, 311, 75, 23, 1, 2, 236, 71, + /* 850 */ 196, 34, 264, 75, 218, 213, 268, 35, 71, 71, + /* 860 */ 182, 183, 75, 75, 71, 247, 332, 257, 75, 71, + /* 870 */ 48, 223, 254, 75, 286, 287, 288, 289, 290, 291, + /* 880 */ 74, 293, 264, 323, 296, 38, 268, 280, 300, 301, + /* 890 */ 302, 226, 86, 38, 71, 247, 317, 61, 75, 311, + /* 900 */ 74, 65, 254, 310, 286, 287, 288, 289, 290, 291, + /* 910 */ 84, 293, 264, 71, 296, 285, 268, 75, 300, 301, + /* 920 */ 302, 273, 247, 87, 71, 326, 223, 71, 75, 311, + /* 930 */ 198, 75, 313, 111, 286, 287, 288, 289, 290, 291, + /* 940 */ 20, 293, 106, 107, 108, 71, 110, 71, 71, 75, + /* 950 */ 247, 75, 75, 229, 36, 281, 109, 254, 144, 274, + /* 960 */ 312, 139, 140, 141, 109, 143, 38, 264, 120, 229, + /* 970 */ 148, 268, 233, 325, 71, 229, 223, 329, 75, 71, + /* 980 */ 262, 71, 160, 75, 162, 75, 164, 165, 166, 286, + /* 990 */ 287, 288, 289, 290, 291, 132, 293, 260, 71, 296, + /* 1000 */ 247, 260, 75, 300, 301, 20, 278, 254, 229, 264, + /* 1010 */ 20, 231, 231, 254, 272, 20, 265, 264, 229, 197, + /* 1020 */ 33, 268, 231, 36, 223, 231, 231, 20, 225, 42, + /* 1030 */ 247, 44, 45, 46, 47, 223, 229, 247, 225, 286, + /* 1040 */ 287, 288, 289, 290, 291, 57, 293, 247, 247, 296, + /* 1050 */ 268, 247, 247, 300, 301, 254, 247, 247, 247, 247, + /* 1060 */ 73, 228, 247, 76, 278, 264, 254, 247, 247, 268, + /* 1070 */ 153, 272, 264, 277, 228, 20, 264, 228, 254, 322, + /* 1080 */ 268, 265, 285, 205, 204, 322, 268, 286, 287, 288, + /* 1090 */ 289, 290, 291, 292, 293, 294, 295, 269, 286, 287, + /* 1100 */ 288, 289, 290, 291, 269, 293, 223, 268, 12, 13, + /* 1110 */ 212, 268, 211, 254, 200, 199, 284, 20, 22, 196, + /* 1120 */ 133, 319, 135, 120, 137, 219, 214, 216, 74, 269, + /* 1130 */ 247, 269, 303, 268, 38, 316, 223, 254, 268, 299, + /* 1140 */ 315, 154, 330, 331, 223, 318, 135, 264, 266, 268, + /* 1150 */ 254, 268, 265, 57, 228, 74, 254, 228, 243, 328, + /* 1160 */ 247, 327, 237, 333, 229, 228, 225, 254, 247, 286, + /* 1170 */ 287, 288, 289, 290, 291, 254, 293, 264, 279, 296, + /* 1180 */ 250, 268, 275, 241, 301, 264, 241, 230, 221, 268, + /* 1190 */ 0, 223, 271, 97, 0, 64, 0, 38, 163, 286, + /* 1200 */ 287, 288, 289, 290, 291, 109, 293, 286, 287, 288, + /* 1210 */ 289, 290, 291, 38, 293, 247, 38, 38, 0, 38, + /* 1220 */ 163, 38, 254, 163, 0, 38, 0, 38, 0, 74, + /* 1230 */ 150, 149, 264, 109, 146, 0, 268, 324, 86, 271, + /* 1240 */ 0, 223, 146, 142, 53, 0, 0, 0, 0, 0, + /* 1250 */ 0, 0, 0, 0, 286, 287, 288, 289, 290, 291, + /* 1260 */ 0, 293, 0, 167, 0, 247, 0, 0, 0, 0, + /* 1270 */ 0, 0, 254, 120, 0, 0, 0, 0, 0, 223, + /* 1280 */ 0, 22, 264, 0, 0, 0, 268, 0, 0, 0, + /* 1290 */ 223, 0, 0, 0, 0, 51, 0, 43, 0, 38, + /* 1300 */ 43, 36, 0, 247, 286, 287, 288, 289, 290, 291, + /* 1310 */ 254, 293, 0, 295, 247, 43, 43, 38, 36, 38, + /* 1320 */ 264, 254, 36, 0, 268, 0, 0, 271, 38, 0, + /* 1330 */ 0, 264, 22, 36, 71, 268, 81, 38, 271, 0, + /* 1340 */ 0, 83, 286, 287, 288, 289, 290, 291, 223, 293, + /* 1350 */ 0, 43, 38, 286, 287, 288, 289, 290, 291, 38, + /* 1360 */ 293, 223, 38, 24, 25, 26, 27, 28, 29, 30, + /* 1370 */ 31, 32, 247, 38, 71, 38, 38, 22, 0, 254, + /* 1380 */ 22, 39, 0, 22, 38, 247, 0, 22, 0, 264, + /* 1390 */ 22, 20, 254, 268, 0, 38, 0, 22, 0, 223, + /* 1400 */ 0, 0, 264, 43, 71, 74, 268, 151, 223, 201, + /* 1410 */ 74, 286, 287, 288, 289, 290, 291, 74, 293, 71, + /* 1420 */ 71, 201, 75, 247, 286, 287, 288, 289, 290, 291, + /* 1430 */ 254, 293, 247, 138, 75, 71, 135, 74, 138, 254, + /* 1440 */ 264, 75, 138, 74, 268, 71, 223, 75, 86, 264, + /* 1450 */ 133, 75, 71, 268, 75, 71, 86, 4, 38, 86, + /* 1460 */ 38, 223, 286, 287, 288, 289, 290, 291, 38, 293, + /* 1470 */ 247, 286, 287, 288, 289, 290, 291, 254, 293, 38, + /* 1480 */ 38, 38, 2, 167, 71, 247, 75, 264, 74, 86, + /* 1490 */ 75, 268, 254, 74, 86, 22, 75, 74, 74, 74, + /* 1500 */ 195, 169, 264, 75, 75, 0, 268, 201, 74, 286, + /* 1510 */ 287, 288, 289, 290, 291, 43, 293, 84, 74, 136, + /* 1520 */ 74, 74, 133, 86, 286, 287, 288, 289, 290, 291, + /* 1530 */ 223, 293, 22, 74, 86, 85, 75, 38, 223, 38, + /* 1540 */ 74, 38, 75, 74, 38, 75, 75, 38, 74, 74, + /* 1550 */ 38, 75, 22, 74, 247, 99, 99, 99, 74, 99, + /* 1560 */ 38, 254, 247, 109, 87, 74, 74, 38, 223, 254, + /* 1570 */ 22, 264, 51, 50, 57, 268, 72, 38, 71, 264, + /* 1580 */ 38, 38, 38, 268, 38, 38, 22, 38, 38, 57, + /* 1590 */ 38, 38, 247, 286, 287, 288, 289, 290, 291, 254, + /* 1600 */ 293, 286, 287, 288, 289, 290, 291, 0, 293, 264, + /* 1610 */ 38, 38, 38, 268, 38, 38, 223, 38, 36, 0, + /* 1620 */ 0, 43, 38, 36, 43, 36, 38, 0, 43, 38, + /* 1630 */ 36, 286, 287, 288, 289, 290, 291, 0, 293, 43, + /* 1640 */ 247, 38, 37, 0, 0, 22, 21, 254, 22, 20, + /* 1650 */ 22, 21, 334, 334, 223, 334, 334, 264, 334, 334, + /* 1660 */ 334, 268, 334, 223, 334, 334, 334, 334, 334, 334, + /* 1670 */ 334, 334, 334, 334, 334, 334, 334, 334, 247, 286, + /* 1680 */ 287, 288, 289, 290, 291, 254, 293, 247, 334, 334, + /* 1690 */ 334, 334, 334, 334, 254, 264, 334, 334, 334, 268, + /* 1700 */ 334, 223, 334, 334, 264, 334, 334, 334, 268, 334, + /* 1710 */ 334, 334, 334, 334, 334, 334, 223, 286, 287, 288, + /* 1720 */ 289, 290, 291, 334, 293, 247, 286, 287, 288, 289, + /* 1730 */ 290, 291, 254, 293, 334, 334, 334, 334, 334, 334, + /* 1740 */ 247, 334, 264, 334, 334, 334, 268, 254, 334, 334, + /* 1750 */ 334, 334, 334, 334, 223, 334, 334, 264, 334, 334, + /* 1760 */ 334, 268, 334, 334, 286, 287, 288, 289, 290, 291, + /* 1770 */ 334, 293, 334, 334, 334, 334, 334, 334, 247, 286, + /* 1780 */ 287, 288, 289, 290, 291, 254, 293, 334, 334, 334, + /* 1790 */ 334, 334, 223, 334, 334, 264, 334, 334, 334, 268, + /* 1800 */ 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, + /* 1810 */ 334, 334, 334, 334, 334, 334, 247, 286, 287, 288, + /* 1820 */ 289, 290, 291, 254, 293, 334, 334, 334, 334, 334, + /* 1830 */ 334, 334, 334, 264, 334, 334, 334, 268, 334, 334, + /* 1840 */ 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, + /* 1850 */ 334, 334, 334, 334, 334, 286, 287, 288, 289, 290, + /* 1860 */ 291, 334, 293, 334, 334, 334, 334, 334, 334, 334, + /* 1870 */ 334, 334, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1880 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1890 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1900 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1910 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1920 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1930 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1940 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1950 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1960 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1970 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1980 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1990 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 2000 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 2010 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 2020 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 2030 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 2040 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 2050 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 2060 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 2070 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 2080 */ 220, 220, 220, }; -#define YY_SHIFT_COUNT (549) +#define YY_SHIFT_COUNT (567) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1562) +#define YY_SHIFT_MAX (1644) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 654, 0, 39, 218, 218, 218, 218, 232, 218, 218, - /* 10 */ 271, 436, 51, 53, 271, 271, 271, 271, 271, 271, - /* 20 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - /* 30 */ 271, 271, 271, 271, 271, 29, 29, 29, 84, 672, - /* 40 */ 672, 112, 35, 35, 60, 672, 245, 245, 35, 35, - /* 50 */ 35, 35, 35, 35, 50, 329, 411, 60, 329, 35, - /* 60 */ 35, 329, 35, 329, 329, 329, 35, 475, 437, 438, - /* 70 */ 447, 447, 165, 455, 1105, 197, 1105, 1105, 1105, 1105, - /* 80 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, - /* 90 */ 1105, 1105, 1105, 1105, 1105, 245, 451, 468, 481, 133, - /* 100 */ 133, 133, 482, 481, 521, 329, 329, 329, 499, 520, - /* 110 */ 566, 566, 566, 566, 566, 566, 566, 646, 477, 93, - /* 120 */ 166, 245, 245, 79, 182, 222, 2, 620, 526, 493, - /* 130 */ 526, 480, 261, 586, 914, 904, 903, 809, 914, 914, - /* 140 */ 850, 840, 840, 914, 957, 960, 50, 521, 965, 50, - /* 150 */ 50, 914, 50, 972, 329, 329, 329, 329, 329, 329, - /* 160 */ 329, 329, 329, 329, 329, 903, 914, 972, 521, 957, - /* 170 */ 865, 960, 475, 521, 965, 475, 1021, 854, 861, 1006, - /* 180 */ 854, 861, 1006, 1006, 863, 874, 887, 892, 897, 521, - /* 190 */ 1069, 977, 882, 899, 916, 1034, 329, 861, 1006, 1006, - /* 200 */ 861, 1006, 1007, 521, 965, 475, 499, 475, 521, 1087, - /* 210 */ 903, 520, 914, 475, 972, 1567, 1567, 1567, 1567, 1567, - /* 220 */ 583, 439, 92, 283, 1120, 1298, 220, 13, 21, 30, - /* 230 */ 409, 414, 414, 414, 414, 414, 414, 414, 82, 70, - /* 240 */ 351, 417, 135, 351, 351, 351, 274, 554, 697, 605, - /* 250 */ 696, 698, 704, 717, 804, 806, 267, 684, 721, 736, - /* 260 */ 731, 644, 669, 719, 742, 769, 761, 40, 762, 772, - /* 270 */ 775, 778, 780, 819, 820, 781, 807, 817, 822, 824, - /* 280 */ 846, 673, 803, 1177, 1182, 1127, 1192, 1155, 1039, 1161, - /* 290 */ 1163, 1165, 1046, 1206, 1172, 1173, 1053, 1213, 1178, 1217, - /* 300 */ 1181, 1224, 1157, 1082, 1085, 1126, 1090, 1237, 1238, 1186, - /* 310 */ 1102, 1241, 1253, 1169, 1256, 1257, 1258, 1260, 1261, 1262, - /* 320 */ 1264, 1265, 1266, 1269, 1275, 1278, 1285, 1287, 1289, 1290, - /* 330 */ 1171, 1292, 1294, 1295, 1296, 1299, 1300, 1280, 1303, 1309, - /* 340 */ 1312, 1320, 1321, 1323, 1324, 1325, 1326, 1286, 1328, 1279, - /* 350 */ 1332, 1333, 1305, 1310, 1291, 1336, 1307, 1315, 1311, 1353, - /* 360 */ 1317, 1322, 1314, 1360, 1327, 1330, 1319, 1364, 1367, 1369, - /* 370 */ 1370, 1288, 1302, 1338, 1308, 1358, 1381, 1346, 1348, 1352, - /* 380 */ 1354, 1331, 1308, 1355, 1356, 1395, 1374, 1397, 1385, 1371, - /* 390 */ 1403, 1387, 1373, 1412, 1391, 1414, 1393, 1396, 1417, 1281, - /* 400 */ 1263, 1382, 1421, 1271, 1401, 1293, 1297, 1424, 1425, 1301, - /* 410 */ 1426, 1359, 1384, 1304, 1357, 1363, 1243, 1361, 1372, 1365, - /* 420 */ 1368, 1375, 1376, 1366, 1377, 1343, 1378, 1380, 1246, 1379, - /* 430 */ 1383, 1344, 1259, 1386, 1388, 1389, 1390, 1252, 1442, 1409, - /* 440 */ 1415, 1418, 1422, 1427, 1428, 1453, 1306, 1392, 1398, 1394, - /* 450 */ 1400, 1402, 1405, 1406, 1407, 1410, 1411, 1334, 1413, 1459, - /* 460 */ 1419, 1339, 1416, 1399, 1408, 1420, 1441, 1423, 1404, 1429, - /* 470 */ 1433, 1439, 1431, 1432, 1448, 1434, 1435, 1450, 1437, 1438, - /* 480 */ 1454, 1440, 1443, 1455, 1445, 1430, 1436, 1444, 1446, 1458, - /* 490 */ 1447, 1449, 1457, 1451, 1452, 1456, 1460, 1308, 1469, 1461, - /* 500 */ 1465, 1463, 1464, 1462, 1471, 1478, 1479, 1483, 1484, 1486, - /* 510 */ 1487, 1474, 1470, 1331, 1490, 1308, 1493, 1494, 1499, 1506, - /* 520 */ 1508, 1509, 1510, 1467, 1511, 1466, 1495, 1503, 1504, 1505, - /* 530 */ 1496, 1540, 1512, 1515, 1513, 1552, 1516, 1517, 1514, 1555, - /* 540 */ 1520, 1522, 1561, 1562, 1477, 1480, 1541, 1542, 1544, 1546, + /* 0 */ 822, 0, 39, 90, 90, 90, 90, 218, 90, 90, + /* 10 */ 264, 392, 438, 392, 392, 392, 392, 392, 392, 392, + /* 20 */ 392, 392, 392, 392, 392, 392, 392, 392, 392, 392, + /* 30 */ 392, 392, 392, 392, 392, 392, 122, 21, 21, 21, + /* 40 */ 121, 1096, 1096, 45, 38, 38, 5, 1096, 38, 38, + /* 50 */ 38, 38, 38, 38, 27, 38, 290, 362, 5, 391, + /* 60 */ 290, 38, 38, 290, 38, 290, 391, 290, 290, 38, + /* 70 */ 458, 513, 231, 574, 574, 269, 435, 297, 435, 435, + /* 80 */ 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, + /* 90 */ 435, 435, 435, 435, 435, 435, 435, 259, 219, 86, + /* 100 */ 191, 191, 445, 445, 445, 116, 191, 191, 483, 391, + /* 110 */ 290, 290, 290, 452, 544, 425, 425, 425, 425, 425, + /* 120 */ 425, 425, 637, 129, 137, 636, 159, 492, 49, 52, + /* 130 */ 322, 672, 499, 654, 499, 736, 642, 732, 774, 920, + /* 140 */ 918, 928, 814, 920, 920, 848, 863, 863, 920, 985, + /* 150 */ 27, 391, 990, 27, 483, 995, 27, 27, 920, 27, + /* 160 */ 1007, 290, 290, 290, 290, 290, 290, 290, 290, 290, + /* 170 */ 290, 290, 920, 1007, 988, 985, 458, 917, 391, 990, + /* 180 */ 458, 483, 995, 458, 1055, 878, 880, 988, 878, 880, + /* 190 */ 988, 988, 898, 901, 914, 916, 923, 483, 1097, 1003, + /* 200 */ 906, 911, 912, 1054, 290, 880, 988, 988, 880, 988, + /* 210 */ 1011, 483, 995, 458, 452, 458, 483, 1081, 544, 920, + /* 220 */ 458, 1007, 1863, 1863, 1863, 1863, 1863, 1863, 287, 987, + /* 230 */ 1339, 754, 490, 836, 16, 118, 714, 321, 769, 484, + /* 240 */ 484, 484, 484, 484, 484, 484, 484, 236, 215, 473, + /* 250 */ 526, 717, 717, 717, 717, 776, 656, 338, 725, 726, + /* 260 */ 735, 748, 502, 558, 777, 817, 651, 778, 787, 788, + /* 270 */ 845, 678, 411, 161, 793, 379, 798, 806, 823, 842, + /* 280 */ 853, 856, 874, 847, 855, 876, 877, 903, 908, 910, + /* 290 */ 927, 826, 430, 1190, 1194, 1131, 1196, 1159, 1035, 1175, + /* 300 */ 1178, 1179, 1057, 1218, 1181, 1183, 1060, 1224, 1187, 1226, + /* 310 */ 1189, 1228, 1155, 1080, 1082, 1124, 1088, 1235, 1240, 1191, + /* 320 */ 1101, 1245, 1246, 1152, 1247, 1248, 1249, 1250, 1251, 1252, + /* 330 */ 1253, 1260, 1262, 1264, 1266, 1267, 1268, 1269, 1270, 1271, + /* 340 */ 1153, 1274, 1275, 1276, 1277, 1278, 1280, 1259, 1283, 1284, + /* 350 */ 1285, 1287, 1288, 1289, 1291, 1292, 1293, 1254, 1294, 1244, + /* 360 */ 1296, 1298, 1261, 1265, 1257, 1302, 1279, 1282, 1272, 1312, + /* 370 */ 1281, 1286, 1273, 1323, 1290, 1297, 1308, 1325, 1326, 1329, + /* 380 */ 1330, 1258, 1255, 1299, 1263, 1303, 1310, 1340, 1314, 1321, + /* 390 */ 1324, 1335, 1263, 1303, 1337, 1338, 1350, 1355, 1378, 1358, + /* 400 */ 1342, 1382, 1361, 1346, 1386, 1365, 1388, 1368, 1371, 1394, + /* 410 */ 1295, 1357, 1396, 1256, 1375, 1300, 1301, 1398, 1400, 1304, + /* 420 */ 1401, 1331, 1360, 1317, 1333, 1348, 1208, 1347, 1349, 1359, + /* 430 */ 1336, 1343, 1363, 1366, 1364, 1362, 1369, 1374, 1220, 1372, + /* 440 */ 1376, 1370, 1305, 1381, 1373, 1379, 1384, 1306, 1453, 1420, + /* 450 */ 1422, 1430, 1441, 1442, 1443, 1480, 1316, 1413, 1411, 1414, + /* 460 */ 1415, 1419, 1421, 1403, 1423, 1424, 1408, 1473, 1332, 1425, + /* 470 */ 1428, 1429, 1434, 1444, 1383, 1446, 1505, 1472, 1389, 1447, + /* 480 */ 1433, 1437, 1448, 1510, 1459, 1450, 1461, 1499, 1501, 1466, + /* 490 */ 1467, 1503, 1469, 1470, 1506, 1474, 1471, 1509, 1475, 1476, + /* 500 */ 1512, 1479, 1456, 1457, 1458, 1460, 1530, 1477, 1484, 1522, + /* 510 */ 1454, 1491, 1492, 1529, 1263, 1303, 1548, 1521, 1523, 1517, + /* 520 */ 1504, 1507, 1539, 1542, 1543, 1544, 1546, 1547, 1549, 1564, + /* 530 */ 1532, 1263, 1550, 1303, 1552, 1553, 1572, 1573, 1574, 1576, + /* 540 */ 1577, 1607, 1579, 1582, 1578, 1619, 1584, 1587, 1581, 1620, + /* 550 */ 1588, 1589, 1585, 1627, 1591, 1594, 1596, 1637, 1603, 1605, + /* 560 */ 1643, 1644, 1623, 1625, 1626, 1628, 1630, 1629, }; -#define YY_REDUCE_COUNT (219) -#define YY_REDUCE_MIN (-273) -#define YY_REDUCE_MAX (1123) +#define YY_REDUCE_COUNT (227) +#define YY_REDUCE_MIN (-311) +#define YY_REDUCE_MAX (1569) static const short yy_reduce_ofst[] = { - /* 0 */ -210, 459, -197, -144, 59, 546, 589, 625, 631, 667, - /* 10 */ 680, 724, 62, 486, 511, 750, 784, 792, 826, 835, - /* 20 */ 841, 869, 877, 911, 919, 945, 970, 995, 1004, 1029, - /* 30 */ 1038, 1063, 1072, 1097, 1123, 746, 671, 1099, 659, -240, - /* 40 */ -203, -248, -215, 17, -14, -129, -255, -171, -68, 88, - /* 50 */ 102, 103, 126, 250, 68, -100, 251, -200, 131, 294, - /* 60 */ 298, 331, 328, 348, 343, 457, 369, 80, 46, -273, - /* 70 */ -273, -273, -204, -50, -196, 98, 27, 219, 252, 266, - /* 80 */ 285, 312, 326, 332, 336, 337, 419, 461, 462, 467, - /* 90 */ 485, 487, 491, 492, 494, -251, -17, 117, 138, -201, - /* 100 */ 141, 196, 394, 148, 277, 469, 460, 478, 145, 502, - /* 110 */ 435, 539, 560, 581, 599, 615, 622, 592, 647, 650, - /* 120 */ 556, 630, 632, 590, 656, 598, 694, 639, 626, 626, - /* 130 */ 626, 686, 621, 635, 716, 677, 728, 683, 745, 748, - /* 140 */ 720, 723, 725, 755, 709, 718, 760, 739, 730, 765, - /* 150 */ 767, 770, 774, 788, 759, 773, 776, 777, 779, 782, - /* 160 */ 783, 785, 793, 794, 808, 786, 787, 796, 768, 747, - /* 170 */ 751, 789, 823, 799, 797, 829, 771, 753, 805, 813, - /* 180 */ 790, 814, 816, 818, 791, 798, 810, 825, 626, 842, - /* 190 */ 832, 843, 815, 827, 830, 844, 686, 870, 875, 876, - /* 200 */ 879, 878, 884, 905, 895, 929, 924, 941, 918, 926, - /* 210 */ 944, 937, 949, 952, 956, 907, 943, 947, 955, 968, + /* 0 */ -211, -208, 400, 451, 532, 588, 618, 648, 703, 753, + /* 10 */ 801, 812, 883, 921, 913, -220, 968, 1018, 1056, 1067, + /* 20 */ 1125, 1138, 1176, 1185, 1223, 1238, 1307, 1315, 1345, 1393, + /* 30 */ 1431, 1440, 1478, 1493, 1531, 1569, 179, -182, -2, 174, + /* 40 */ -186, -247, -228, 58, -221, -139, 181, -257, -154, -5, + /* 50 */ -4, -3, -1, 224, 128, 307, -109, -102, -311, -101, + /* 60 */ 69, 353, 417, 214, 424, 216, 278, 346, 420, 431, + /* 70 */ 228, -222, -292, -292, -292, -117, -223, -95, -204, -174, + /* 80 */ 62, 271, 282, 286, 288, 326, 404, 440, 454, 457, + /* 90 */ 480, 481, 486, 489, 512, 546, 569, 139, -33, -189, + /* 100 */ 46, 173, 415, 462, 494, -130, 193, 432, 324, -254, + /* 110 */ 550, 460, 487, 352, 54, -246, 385, 413, 469, 545, + /* 120 */ 567, 576, 555, 615, 612, 534, 560, 610, 607, 579, + /* 130 */ 665, 630, 593, 593, 593, 675, 599, 619, 675, 724, + /* 140 */ 674, 739, 685, 740, 746, 718, 737, 741, 779, 728, + /* 150 */ 780, 745, 742, 781, 759, 751, 791, 794, 789, 795, + /* 160 */ 803, 783, 790, 800, 804, 805, 809, 810, 811, 815, + /* 170 */ 820, 821, 807, 813, 782, 786, 833, 796, 808, 799, + /* 180 */ 846, 824, 816, 849, 797, 757, 828, 818, 763, 835, + /* 190 */ 839, 843, 802, 827, 819, 825, 593, 859, 832, 829, + /* 200 */ 830, 831, 834, 840, 675, 860, 865, 870, 862, 881, + /* 210 */ 882, 896, 887, 926, 915, 929, 902, 930, 925, 935, + /* 220 */ 937, 941, 907, 899, 942, 945, 957, 967, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 10 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 20 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 30 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 40 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 50 */ 1225, 1225, 1225, 1225, 1284, 1225, 1225, 1225, 1225, 1225, - /* 60 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1282, 1422, 1225, - /* 70 */ 1560, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 80 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 90 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1284, 1225, 1571, - /* 100 */ 1571, 1571, 1282, 1225, 1225, 1225, 1225, 1225, 1377, 1225, - /* 110 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1456, 1225, 1225, - /* 120 */ 1635, 1225, 1225, 1225, 1330, 1595, 1225, 1587, 1563, 1577, - /* 130 */ 1564, 1225, 1620, 1580, 1225, 1225, 1225, 1448, 1225, 1225, - /* 140 */ 1427, 1424, 1424, 1225, 1225, 1225, 1284, 1225, 1225, 1284, - /* 150 */ 1284, 1225, 1284, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 160 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 170 */ 1458, 1225, 1282, 1225, 1225, 1282, 1225, 1602, 1600, 1225, - /* 180 */ 1602, 1600, 1225, 1225, 1614, 1610, 1593, 1591, 1577, 1225, - /* 190 */ 1225, 1225, 1638, 1626, 1622, 1225, 1225, 1600, 1225, 1225, - /* 200 */ 1600, 1225, 1435, 1225, 1225, 1282, 1225, 1282, 1225, 1346, - /* 210 */ 1225, 1225, 1225, 1282, 1225, 1450, 1380, 1380, 1285, 1230, - /* 220 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 230 */ 1225, 1525, 1613, 1612, 1524, 1537, 1536, 1535, 1225, 1225, - /* 240 */ 1519, 1225, 1225, 1520, 1518, 1517, 1225, 1225, 1225, 1225, - /* 250 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 260 */ 1561, 1225, 1623, 1627, 1225, 1225, 1225, 1495, 1225, 1225, - /* 270 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 280 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 290 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 300 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 310 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 320 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 330 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 340 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 350 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 360 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 370 */ 1225, 1225, 1225, 1225, 1391, 1225, 1225, 1225, 1225, 1225, - /* 380 */ 1225, 1311, 1310, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 390 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 400 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 410 */ 1225, 1225, 1225, 1225, 1584, 1594, 1225, 1225, 1225, 1225, - /* 420 */ 1225, 1225, 1225, 1225, 1225, 1495, 1225, 1611, 1225, 1570, - /* 430 */ 1566, 1225, 1225, 1562, 1225, 1225, 1621, 1225, 1225, 1225, - /* 440 */ 1225, 1225, 1225, 1225, 1225, 1556, 1225, 1225, 1225, 1225, - /* 450 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 460 */ 1225, 1225, 1225, 1225, 1494, 1225, 1225, 1225, 1225, 1225, - /* 470 */ 1225, 1225, 1374, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 480 */ 1225, 1225, 1225, 1225, 1225, 1359, 1357, 1356, 1355, 1225, - /* 490 */ 1352, 1225, 1225, 1225, 1225, 1225, 1225, 1382, 1225, 1225, - /* 500 */ 1225, 1225, 1225, 1305, 1225, 1225, 1225, 1225, 1225, 1225, - /* 510 */ 1225, 1225, 1225, 1296, 1225, 1295, 1225, 1225, 1225, 1225, - /* 520 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 530 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, - /* 540 */ 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1225, + /* 0 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 10 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 20 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 30 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 40 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 50 */ 1276, 1276, 1276, 1276, 1335, 1276, 1276, 1276, 1276, 1276, + /* 60 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 70 */ 1333, 1475, 1276, 1631, 1276, 1276, 1276, 1276, 1276, 1276, + /* 80 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 90 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1335, + /* 100 */ 1276, 1276, 1642, 1642, 1642, 1333, 1276, 1276, 1276, 1276, + /* 110 */ 1276, 1276, 1276, 1428, 1276, 1276, 1276, 1276, 1276, 1276, + /* 120 */ 1276, 1276, 1509, 1276, 1276, 1706, 1276, 1381, 1515, 1666, + /* 130 */ 1276, 1658, 1634, 1648, 1635, 1276, 1691, 1651, 1276, 1276, + /* 140 */ 1276, 1276, 1501, 1276, 1276, 1480, 1477, 1477, 1276, 1276, + /* 150 */ 1335, 1276, 1276, 1335, 1276, 1276, 1335, 1335, 1276, 1335, + /* 160 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 170 */ 1276, 1276, 1276, 1276, 1276, 1276, 1333, 1511, 1276, 1276, + /* 180 */ 1333, 1276, 1276, 1333, 1276, 1673, 1671, 1276, 1673, 1671, + /* 190 */ 1276, 1276, 1685, 1681, 1664, 1662, 1648, 1276, 1276, 1276, + /* 200 */ 1709, 1697, 1693, 1276, 1276, 1671, 1276, 1276, 1671, 1276, + /* 210 */ 1488, 1276, 1276, 1333, 1276, 1333, 1276, 1397, 1276, 1276, + /* 220 */ 1333, 1276, 1503, 1517, 1431, 1431, 1336, 1281, 1276, 1276, + /* 230 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1578, + /* 240 */ 1684, 1683, 1607, 1606, 1605, 1603, 1577, 1276, 1276, 1276, + /* 250 */ 1276, 1571, 1572, 1570, 1569, 1276, 1276, 1276, 1276, 1276, + /* 260 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 270 */ 1632, 1276, 1694, 1698, 1276, 1276, 1276, 1555, 1276, 1276, + /* 280 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 290 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 300 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 310 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 320 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 330 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 340 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 350 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 360 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 370 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 380 */ 1276, 1276, 1276, 1276, 1444, 1443, 1276, 1276, 1276, 1276, + /* 390 */ 1276, 1276, 1362, 1361, 1276, 1276, 1276, 1276, 1276, 1276, + /* 400 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 410 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 420 */ 1276, 1276, 1276, 1276, 1655, 1665, 1276, 1276, 1276, 1276, + /* 430 */ 1276, 1276, 1276, 1276, 1276, 1555, 1276, 1682, 1276, 1641, + /* 440 */ 1637, 1276, 1276, 1633, 1276, 1276, 1692, 1276, 1276, 1276, + /* 450 */ 1276, 1276, 1276, 1276, 1276, 1627, 1276, 1600, 1276, 1276, + /* 460 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1565, 1276, + /* 470 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 480 */ 1276, 1554, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1425, + /* 490 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 500 */ 1276, 1276, 1410, 1408, 1407, 1406, 1276, 1403, 1276, 1276, + /* 510 */ 1276, 1276, 1276, 1276, 1434, 1433, 1276, 1276, 1276, 1276, + /* 520 */ 1276, 1356, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 530 */ 1276, 1347, 1276, 1346, 1276, 1276, 1276, 1276, 1276, 1276, + /* 540 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 550 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, + /* 560 */ 1276, 1276, 1276, 1276, 1276, 1276, 1276, 1276, }; /********** End of lemon-generated parsing tables *****************************/ @@ -955,20 +1021,20 @@ static const char *const yyTokenName[] = { /* 153 */ "BUFSIZE", /* 154 */ "STREAM", /* 155 */ "INTO", - /* 156 */ "KILL", - /* 157 */ "CONNECTION", - /* 158 */ "MERGE", - /* 159 */ "VGROUP", - /* 160 */ "REDISTRIBUTE", - /* 161 */ "SPLIT", - /* 162 */ "SYNCDB", - /* 163 */ "NULL", - /* 164 */ "FIRST", - /* 165 */ "LAST", - /* 166 */ "NOW", - /* 167 */ "TODAY", - /* 168 */ "TIMEZONE", - /* 169 */ "CAST", + /* 156 */ "TRIGGER", + /* 157 */ "AT_ONCE", + /* 158 */ "WINDOW_CLOSE", + /* 159 */ "WATERMARK", + /* 160 */ "KILL", + /* 161 */ "CONNECTION", + /* 162 */ "MERGE", + /* 163 */ "VGROUP", + /* 164 */ "REDISTRIBUTE", + /* 165 */ "SPLIT", + /* 166 */ "SYNCDB", + /* 167 */ "NULL", + /* 168 */ "NK_QUESTION", + /* 169 */ "NK_ARROW", /* 170 */ "ROWTS", /* 171 */ "TBNAME", /* 172 */ "QSTARTTS", @@ -976,146 +1042,163 @@ static const char *const yyTokenName[] = { /* 174 */ "WSTARTTS", /* 175 */ "WENDTS", /* 176 */ "WDURATION", - /* 177 */ "BETWEEN", - /* 178 */ "IS", - /* 179 */ "NK_LT", - /* 180 */ "NK_GT", - /* 181 */ "NK_LE", - /* 182 */ "NK_GE", - /* 183 */ "NK_NE", - /* 184 */ "MATCH", - /* 185 */ "NMATCH", - /* 186 */ "JOIN", - /* 187 */ "INNER", - /* 188 */ "SELECT", - /* 189 */ "DISTINCT", - /* 190 */ "WHERE", - /* 191 */ "PARTITION", - /* 192 */ "BY", - /* 193 */ "SESSION", - /* 194 */ "STATE_WINDOW", - /* 195 */ "SLIDING", - /* 196 */ "FILL", - /* 197 */ "VALUE", - /* 198 */ "NONE", - /* 199 */ "PREV", - /* 200 */ "LINEAR", - /* 201 */ "NEXT", - /* 202 */ "GROUP", - /* 203 */ "HAVING", - /* 204 */ "ORDER", - /* 205 */ "SLIMIT", - /* 206 */ "SOFFSET", - /* 207 */ "LIMIT", - /* 208 */ "OFFSET", - /* 209 */ "ASC", - /* 210 */ "NULLS", - /* 211 */ "cmd", - /* 212 */ "account_options", - /* 213 */ "alter_account_options", - /* 214 */ "literal", - /* 215 */ "alter_account_option", - /* 216 */ "user_name", - /* 217 */ "dnode_endpoint", - /* 218 */ "dnode_host_name", - /* 219 */ "not_exists_opt", - /* 220 */ "db_name", - /* 221 */ "db_options", - /* 222 */ "exists_opt", - /* 223 */ "alter_db_options", - /* 224 */ "integer_list", - /* 225 */ "variable_list", - /* 226 */ "retention_list", - /* 227 */ "alter_db_option", - /* 228 */ "retention", - /* 229 */ "full_table_name", - /* 230 */ "column_def_list", - /* 231 */ "tags_def_opt", - /* 232 */ "table_options", - /* 233 */ "multi_create_clause", - /* 234 */ "tags_def", - /* 235 */ "multi_drop_clause", - /* 236 */ "alter_table_clause", - /* 237 */ "alter_table_options", - /* 238 */ "column_name", - /* 239 */ "type_name", - /* 240 */ "create_subtable_clause", - /* 241 */ "specific_tags_opt", - /* 242 */ "literal_list", - /* 243 */ "drop_table_clause", - /* 244 */ "col_name_list", - /* 245 */ "table_name", - /* 246 */ "column_def", - /* 247 */ "func_name_list", - /* 248 */ "alter_table_option", - /* 249 */ "col_name", - /* 250 */ "db_name_cond_opt", - /* 251 */ "like_pattern_opt", - /* 252 */ "table_name_cond", - /* 253 */ "from_db_opt", - /* 254 */ "func_name", - /* 255 */ "function_name", - /* 256 */ "index_name", - /* 257 */ "index_options", - /* 258 */ "func_list", - /* 259 */ "duration_literal", - /* 260 */ "sliding_opt", - /* 261 */ "func", - /* 262 */ "expression_list", - /* 263 */ "topic_name", - /* 264 */ "query_expression", - /* 265 */ "analyze_opt", - /* 266 */ "explain_options", - /* 267 */ "agg_func_opt", - /* 268 */ "bufsize_opt", - /* 269 */ "stream_name", - /* 270 */ "dnode_list", - /* 271 */ "signed", - /* 272 */ "signed_literal", - /* 273 */ "table_alias", - /* 274 */ "column_alias", - /* 275 */ "expression", - /* 276 */ "pseudo_column", - /* 277 */ "column_reference", - /* 278 */ "subquery", - /* 279 */ "predicate", - /* 280 */ "compare_op", - /* 281 */ "in_op", - /* 282 */ "in_predicate_value", - /* 283 */ "boolean_value_expression", - /* 284 */ "boolean_primary", - /* 285 */ "common_expression", - /* 286 */ "from_clause", - /* 287 */ "table_reference_list", - /* 288 */ "table_reference", - /* 289 */ "table_primary", - /* 290 */ "joined_table", - /* 291 */ "alias_opt", - /* 292 */ "parenthesized_joined_table", - /* 293 */ "join_type", - /* 294 */ "search_condition", - /* 295 */ "query_specification", - /* 296 */ "set_quantifier_opt", - /* 297 */ "select_list", - /* 298 */ "where_clause_opt", - /* 299 */ "partition_by_clause_opt", - /* 300 */ "twindow_clause_opt", - /* 301 */ "group_by_clause_opt", - /* 302 */ "having_clause_opt", - /* 303 */ "select_sublist", - /* 304 */ "select_item", - /* 305 */ "fill_opt", - /* 306 */ "fill_mode", - /* 307 */ "group_by_list", - /* 308 */ "query_expression_body", - /* 309 */ "order_by_clause_opt", - /* 310 */ "slimit_clause_opt", - /* 311 */ "limit_clause_opt", - /* 312 */ "query_primary", - /* 313 */ "sort_specification_list", - /* 314 */ "sort_specification", - /* 315 */ "ordering_specification_opt", - /* 316 */ "null_ordering_opt", + /* 177 */ "CAST", + /* 178 */ "NOW", + /* 179 */ "TODAY", + /* 180 */ "TIMEZONE", + /* 181 */ "COUNT", + /* 182 */ "FIRST", + /* 183 */ "LAST", + /* 184 */ "LAST_ROW", + /* 185 */ "BETWEEN", + /* 186 */ "IS", + /* 187 */ "NK_LT", + /* 188 */ "NK_GT", + /* 189 */ "NK_LE", + /* 190 */ "NK_GE", + /* 191 */ "NK_NE", + /* 192 */ "MATCH", + /* 193 */ "NMATCH", + /* 194 */ "CONTAINS", + /* 195 */ "JOIN", + /* 196 */ "INNER", + /* 197 */ "SELECT", + /* 198 */ "DISTINCT", + /* 199 */ "WHERE", + /* 200 */ "PARTITION", + /* 201 */ "BY", + /* 202 */ "SESSION", + /* 203 */ "STATE_WINDOW", + /* 204 */ "SLIDING", + /* 205 */ "FILL", + /* 206 */ "VALUE", + /* 207 */ "NONE", + /* 208 */ "PREV", + /* 209 */ "LINEAR", + /* 210 */ "NEXT", + /* 211 */ "GROUP", + /* 212 */ "HAVING", + /* 213 */ "ORDER", + /* 214 */ "SLIMIT", + /* 215 */ "SOFFSET", + /* 216 */ "LIMIT", + /* 217 */ "OFFSET", + /* 218 */ "ASC", + /* 219 */ "NULLS", + /* 220 */ "cmd", + /* 221 */ "account_options", + /* 222 */ "alter_account_options", + /* 223 */ "literal", + /* 224 */ "alter_account_option", + /* 225 */ "user_name", + /* 226 */ "dnode_endpoint", + /* 227 */ "dnode_host_name", + /* 228 */ "not_exists_opt", + /* 229 */ "db_name", + /* 230 */ "db_options", + /* 231 */ "exists_opt", + /* 232 */ "alter_db_options", + /* 233 */ "integer_list", + /* 234 */ "variable_list", + /* 235 */ "retention_list", + /* 236 */ "alter_db_option", + /* 237 */ "retention", + /* 238 */ "full_table_name", + /* 239 */ "column_def_list", + /* 240 */ "tags_def_opt", + /* 241 */ "table_options", + /* 242 */ "multi_create_clause", + /* 243 */ "tags_def", + /* 244 */ "multi_drop_clause", + /* 245 */ "alter_table_clause", + /* 246 */ "alter_table_options", + /* 247 */ "column_name", + /* 248 */ "type_name", + /* 249 */ "create_subtable_clause", + /* 250 */ "specific_tags_opt", + /* 251 */ "literal_list", + /* 252 */ "drop_table_clause", + /* 253 */ "col_name_list", + /* 254 */ "table_name", + /* 255 */ "column_def", + /* 256 */ "func_name_list", + /* 257 */ "alter_table_option", + /* 258 */ "col_name", + /* 259 */ "db_name_cond_opt", + /* 260 */ "like_pattern_opt", + /* 261 */ "table_name_cond", + /* 262 */ "from_db_opt", + /* 263 */ "func_name", + /* 264 */ "function_name", + /* 265 */ "index_name", + /* 266 */ "index_options", + /* 267 */ "func_list", + /* 268 */ "duration_literal", + /* 269 */ "sliding_opt", + /* 270 */ "func", + /* 271 */ "expression_list", + /* 272 */ "topic_name", + /* 273 */ "query_expression", + /* 274 */ "analyze_opt", + /* 275 */ "explain_options", + /* 276 */ "agg_func_opt", + /* 277 */ "bufsize_opt", + /* 278 */ "stream_name", + /* 279 */ "stream_options", + /* 280 */ "into_opt", + /* 281 */ "dnode_list", + /* 282 */ "signed", + /* 283 */ "signed_literal", + /* 284 */ "table_alias", + /* 285 */ "column_alias", + /* 286 */ "expression", + /* 287 */ "pseudo_column", + /* 288 */ "column_reference", + /* 289 */ "function_expression", + /* 290 */ "subquery", + /* 291 */ "star_func", + /* 292 */ "star_func_para_list", + /* 293 */ "noarg_func", + /* 294 */ "other_para_list", + /* 295 */ "star_func_para", + /* 296 */ "predicate", + /* 297 */ "compare_op", + /* 298 */ "in_op", + /* 299 */ "in_predicate_value", + /* 300 */ "boolean_value_expression", + /* 301 */ "boolean_primary", + /* 302 */ "common_expression", + /* 303 */ "from_clause", + /* 304 */ "table_reference_list", + /* 305 */ "table_reference", + /* 306 */ "table_primary", + /* 307 */ "joined_table", + /* 308 */ "alias_opt", + /* 309 */ "parenthesized_joined_table", + /* 310 */ "join_type", + /* 311 */ "search_condition", + /* 312 */ "query_specification", + /* 313 */ "set_quantifier_opt", + /* 314 */ "select_list", + /* 315 */ "where_clause_opt", + /* 316 */ "partition_by_clause_opt", + /* 317 */ "twindow_clause_opt", + /* 318 */ "group_by_clause_opt", + /* 319 */ "having_clause_opt", + /* 320 */ "select_sublist", + /* 321 */ "select_item", + /* 322 */ "fill_opt", + /* 323 */ "fill_mode", + /* 324 */ "group_by_list", + /* 325 */ "query_expression_body", + /* 326 */ "order_by_clause_opt", + /* 327 */ "slimit_clause_opt", + /* 328 */ "limit_clause_opt", + /* 329 */ "query_primary", + /* 330 */ "sort_specification_list", + /* 331 */ "sort_specification", + /* 332 */ "ordering_specification_opt", + /* 333 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1278,264 +1361,284 @@ static const char *const yyRuleName[] = { /* 152 */ "table_options ::=", /* 153 */ "table_options ::= table_options COMMENT NK_STRING", /* 154 */ "table_options ::= table_options KEEP integer_list", - /* 155 */ "table_options ::= table_options TTL NK_INTEGER", - /* 156 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 157 */ "table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP", - /* 158 */ "table_options ::= table_options FILE_FACTOR NK_FLOAT", - /* 159 */ "table_options ::= table_options DELAY NK_INTEGER", - /* 160 */ "alter_table_options ::= alter_table_option", - /* 161 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 162 */ "alter_table_option ::= COMMENT NK_STRING", - /* 163 */ "alter_table_option ::= KEEP integer_list", - /* 164 */ "alter_table_option ::= TTL NK_INTEGER", - /* 165 */ "col_name_list ::= col_name", - /* 166 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 167 */ "col_name ::= column_name", - /* 168 */ "cmd ::= SHOW DNODES", - /* 169 */ "cmd ::= SHOW USERS", - /* 170 */ "cmd ::= SHOW DATABASES", - /* 171 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", - /* 172 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 173 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 174 */ "cmd ::= SHOW MNODES", - /* 175 */ "cmd ::= SHOW MODULES", - /* 176 */ "cmd ::= SHOW QNODES", - /* 177 */ "cmd ::= SHOW FUNCTIONS", - /* 178 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 179 */ "cmd ::= SHOW STREAMS", - /* 180 */ "cmd ::= SHOW ACCOUNTS", - /* 181 */ "cmd ::= SHOW APPS", - /* 182 */ "cmd ::= SHOW CONNECTIONS", - /* 183 */ "cmd ::= SHOW LICENCE", - /* 184 */ "cmd ::= SHOW GRANTS", - /* 185 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 186 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 187 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 188 */ "cmd ::= SHOW QUERIES", - /* 189 */ "cmd ::= SHOW SCORES", - /* 190 */ "cmd ::= SHOW TOPICS", - /* 191 */ "cmd ::= SHOW VARIABLES", - /* 192 */ "cmd ::= SHOW BNODES", - /* 193 */ "cmd ::= SHOW SNODES", - /* 194 */ "db_name_cond_opt ::=", - /* 195 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 196 */ "like_pattern_opt ::=", - /* 197 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 198 */ "table_name_cond ::= table_name", - /* 199 */ "from_db_opt ::=", - /* 200 */ "from_db_opt ::= FROM db_name", - /* 201 */ "func_name_list ::= func_name", - /* 202 */ "func_name_list ::= func_name_list NK_COMMA col_name", - /* 203 */ "func_name ::= function_name", - /* 204 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", - /* 205 */ "cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP", - /* 206 */ "cmd ::= DROP INDEX exists_opt index_name ON table_name", - /* 207 */ "index_options ::=", - /* 208 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", - /* 209 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", - /* 210 */ "func_list ::= func", - /* 211 */ "func_list ::= func_list NK_COMMA func", - /* 212 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 213 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", - /* 214 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name", - /* 215 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 216 */ "cmd ::= DESC full_table_name", - /* 217 */ "cmd ::= DESCRIBE full_table_name", - /* 218 */ "cmd ::= RESET QUERY CACHE", - /* 219 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", - /* 220 */ "analyze_opt ::=", - /* 221 */ "analyze_opt ::= ANALYZE", - /* 222 */ "explain_options ::=", - /* 223 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 224 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 225 */ "cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP", - /* 226 */ "cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", - /* 227 */ "cmd ::= DROP FUNCTION function_name", - /* 228 */ "agg_func_opt ::=", - /* 229 */ "agg_func_opt ::= AGGREGATE", - /* 230 */ "bufsize_opt ::=", - /* 231 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 232 */ "cmd ::= CREATE STREAM stream_name INTO table_name AS query_expression", - /* 233 */ "cmd ::= DROP STREAM stream_name", - /* 234 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 235 */ "cmd ::= KILL QUERY NK_INTEGER", - /* 236 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 237 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 238 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 239 */ "dnode_list ::= DNODE NK_INTEGER", - /* 240 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 241 */ "cmd ::= SYNCDB db_name REPLICA", - /* 242 */ "cmd ::= query_expression", - /* 243 */ "literal ::= NK_INTEGER", - /* 244 */ "literal ::= NK_FLOAT", - /* 245 */ "literal ::= NK_STRING", - /* 246 */ "literal ::= NK_BOOL", - /* 247 */ "literal ::= TIMESTAMP NK_STRING", - /* 248 */ "literal ::= duration_literal", - /* 249 */ "literal ::= NULL", - /* 250 */ "duration_literal ::= NK_VARIABLE", - /* 251 */ "signed ::= NK_INTEGER", - /* 252 */ "signed ::= NK_PLUS NK_INTEGER", - /* 253 */ "signed ::= NK_MINUS NK_INTEGER", - /* 254 */ "signed ::= NK_FLOAT", - /* 255 */ "signed ::= NK_PLUS NK_FLOAT", - /* 256 */ "signed ::= NK_MINUS NK_FLOAT", - /* 257 */ "signed_literal ::= signed", - /* 258 */ "signed_literal ::= NK_STRING", - /* 259 */ "signed_literal ::= NK_BOOL", - /* 260 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 261 */ "signed_literal ::= duration_literal", - /* 262 */ "signed_literal ::= NULL", - /* 263 */ "literal_list ::= signed_literal", - /* 264 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 265 */ "db_name ::= NK_ID", - /* 266 */ "table_name ::= NK_ID", - /* 267 */ "column_name ::= NK_ID", - /* 268 */ "function_name ::= NK_ID", - /* 269 */ "function_name ::= FIRST", - /* 270 */ "function_name ::= LAST", - /* 271 */ "function_name ::= NOW", - /* 272 */ "function_name ::= TODAY", - /* 273 */ "function_name ::= TIMEZONE", - /* 274 */ "table_alias ::= NK_ID", - /* 275 */ "column_alias ::= NK_ID", - /* 276 */ "user_name ::= NK_ID", - /* 277 */ "index_name ::= NK_ID", - /* 278 */ "topic_name ::= NK_ID", - /* 279 */ "stream_name ::= NK_ID", - /* 280 */ "expression ::= literal", - /* 281 */ "expression ::= pseudo_column", - /* 282 */ "expression ::= column_reference", - /* 283 */ "expression ::= function_name NK_LP expression_list NK_RP", - /* 284 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 285 */ "expression ::= function_name NK_LP NK_RP", - /* 286 */ "expression ::= CAST NK_LP expression AS type_name NK_RP", - /* 287 */ "expression ::= subquery", - /* 288 */ "expression ::= NK_LP expression NK_RP", - /* 289 */ "expression ::= NK_PLUS expression", - /* 290 */ "expression ::= NK_MINUS expression", - /* 291 */ "expression ::= expression NK_PLUS expression", - /* 292 */ "expression ::= expression NK_MINUS expression", - /* 293 */ "expression ::= expression NK_STAR expression", - /* 294 */ "expression ::= expression NK_SLASH expression", - /* 295 */ "expression ::= expression NK_REM expression", - /* 296 */ "expression_list ::= expression", - /* 297 */ "expression_list ::= expression_list NK_COMMA expression", - /* 298 */ "column_reference ::= column_name", - /* 299 */ "column_reference ::= table_name NK_DOT column_name", - /* 300 */ "pseudo_column ::= ROWTS", - /* 301 */ "pseudo_column ::= TBNAME", - /* 302 */ "pseudo_column ::= QSTARTTS", - /* 303 */ "pseudo_column ::= QENDTS", - /* 304 */ "pseudo_column ::= WSTARTTS", - /* 305 */ "pseudo_column ::= WENDTS", - /* 306 */ "pseudo_column ::= WDURATION", - /* 307 */ "predicate ::= expression compare_op expression", - /* 308 */ "predicate ::= expression BETWEEN expression AND expression", - /* 309 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 310 */ "predicate ::= expression IS NULL", - /* 311 */ "predicate ::= expression IS NOT NULL", - /* 312 */ "predicate ::= expression in_op in_predicate_value", - /* 313 */ "compare_op ::= NK_LT", - /* 314 */ "compare_op ::= NK_GT", - /* 315 */ "compare_op ::= NK_LE", - /* 316 */ "compare_op ::= NK_GE", - /* 317 */ "compare_op ::= NK_NE", - /* 318 */ "compare_op ::= NK_EQ", - /* 319 */ "compare_op ::= LIKE", - /* 320 */ "compare_op ::= NOT LIKE", - /* 321 */ "compare_op ::= MATCH", - /* 322 */ "compare_op ::= NMATCH", - /* 323 */ "in_op ::= IN", - /* 324 */ "in_op ::= NOT IN", - /* 325 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 326 */ "boolean_value_expression ::= boolean_primary", - /* 327 */ "boolean_value_expression ::= NOT boolean_primary", - /* 328 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 329 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 330 */ "boolean_primary ::= predicate", - /* 331 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 332 */ "common_expression ::= expression", - /* 333 */ "common_expression ::= boolean_value_expression", - /* 334 */ "from_clause ::= FROM table_reference_list", - /* 335 */ "table_reference_list ::= table_reference", - /* 336 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 337 */ "table_reference ::= table_primary", - /* 338 */ "table_reference ::= joined_table", - /* 339 */ "table_primary ::= table_name alias_opt", - /* 340 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 341 */ "table_primary ::= subquery alias_opt", - /* 342 */ "table_primary ::= parenthesized_joined_table", - /* 343 */ "alias_opt ::=", - /* 344 */ "alias_opt ::= table_alias", - /* 345 */ "alias_opt ::= AS table_alias", - /* 346 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 347 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 348 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 349 */ "join_type ::=", - /* 350 */ "join_type ::= INNER", - /* 351 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 352 */ "set_quantifier_opt ::=", - /* 353 */ "set_quantifier_opt ::= DISTINCT", - /* 354 */ "set_quantifier_opt ::= ALL", - /* 355 */ "select_list ::= NK_STAR", - /* 356 */ "select_list ::= select_sublist", - /* 357 */ "select_sublist ::= select_item", - /* 358 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 359 */ "select_item ::= common_expression", - /* 360 */ "select_item ::= common_expression column_alias", - /* 361 */ "select_item ::= common_expression AS column_alias", - /* 362 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 363 */ "where_clause_opt ::=", - /* 364 */ "where_clause_opt ::= WHERE search_condition", - /* 365 */ "partition_by_clause_opt ::=", - /* 366 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 367 */ "twindow_clause_opt ::=", - /* 368 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 369 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 370 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 371 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 372 */ "sliding_opt ::=", - /* 373 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 374 */ "fill_opt ::=", - /* 375 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 376 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 377 */ "fill_mode ::= NONE", - /* 378 */ "fill_mode ::= PREV", - /* 379 */ "fill_mode ::= NULL", - /* 380 */ "fill_mode ::= LINEAR", - /* 381 */ "fill_mode ::= NEXT", - /* 382 */ "group_by_clause_opt ::=", - /* 383 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 384 */ "group_by_list ::= expression", - /* 385 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 386 */ "having_clause_opt ::=", - /* 387 */ "having_clause_opt ::= HAVING search_condition", - /* 388 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 389 */ "query_expression_body ::= query_primary", - /* 390 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 391 */ "query_primary ::= query_specification", - /* 392 */ "order_by_clause_opt ::=", - /* 393 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 394 */ "slimit_clause_opt ::=", - /* 395 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 396 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 397 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 398 */ "limit_clause_opt ::=", - /* 399 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 400 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 401 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 402 */ "subquery ::= NK_LP query_expression NK_RP", - /* 403 */ "search_condition ::= common_expression", - /* 404 */ "sort_specification_list ::= sort_specification", - /* 405 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 406 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 407 */ "ordering_specification_opt ::=", - /* 408 */ "ordering_specification_opt ::= ASC", - /* 409 */ "ordering_specification_opt ::= DESC", - /* 410 */ "null_ordering_opt ::=", - /* 411 */ "null_ordering_opt ::= NULLS FIRST", - /* 412 */ "null_ordering_opt ::= NULLS LAST", + /* 155 */ "table_options ::= table_options KEEP variable_list", + /* 156 */ "table_options ::= table_options TTL NK_INTEGER", + /* 157 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 158 */ "table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP", + /* 159 */ "table_options ::= table_options FILE_FACTOR NK_FLOAT", + /* 160 */ "table_options ::= table_options DELAY NK_INTEGER", + /* 161 */ "alter_table_options ::= alter_table_option", + /* 162 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 163 */ "alter_table_option ::= COMMENT NK_STRING", + /* 164 */ "alter_table_option ::= KEEP integer_list", + /* 165 */ "alter_table_option ::= KEEP variable_list", + /* 166 */ "alter_table_option ::= TTL NK_INTEGER", + /* 167 */ "col_name_list ::= col_name", + /* 168 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 169 */ "col_name ::= column_name", + /* 170 */ "cmd ::= SHOW DNODES", + /* 171 */ "cmd ::= SHOW USERS", + /* 172 */ "cmd ::= SHOW DATABASES", + /* 173 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", + /* 174 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", + /* 175 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", + /* 176 */ "cmd ::= SHOW MNODES", + /* 177 */ "cmd ::= SHOW MODULES", + /* 178 */ "cmd ::= SHOW QNODES", + /* 179 */ "cmd ::= SHOW FUNCTIONS", + /* 180 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 181 */ "cmd ::= SHOW STREAMS", + /* 182 */ "cmd ::= SHOW ACCOUNTS", + /* 183 */ "cmd ::= SHOW APPS", + /* 184 */ "cmd ::= SHOW CONNECTIONS", + /* 185 */ "cmd ::= SHOW LICENCE", + /* 186 */ "cmd ::= SHOW GRANTS", + /* 187 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 188 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 189 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 190 */ "cmd ::= SHOW QUERIES", + /* 191 */ "cmd ::= SHOW SCORES", + /* 192 */ "cmd ::= SHOW TOPICS", + /* 193 */ "cmd ::= SHOW VARIABLES", + /* 194 */ "cmd ::= SHOW BNODES", + /* 195 */ "cmd ::= SHOW SNODES", + /* 196 */ "db_name_cond_opt ::=", + /* 197 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 198 */ "like_pattern_opt ::=", + /* 199 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 200 */ "table_name_cond ::= table_name", + /* 201 */ "from_db_opt ::=", + /* 202 */ "from_db_opt ::= FROM db_name", + /* 203 */ "func_name_list ::= func_name", + /* 204 */ "func_name_list ::= func_name_list NK_COMMA col_name", + /* 205 */ "func_name ::= function_name", + /* 206 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", + /* 207 */ "cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP", + /* 208 */ "cmd ::= DROP INDEX exists_opt index_name ON table_name", + /* 209 */ "index_options ::=", + /* 210 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", + /* 211 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", + /* 212 */ "func_list ::= func", + /* 213 */ "func_list ::= func_list NK_COMMA func", + /* 214 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 215 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", + /* 216 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name", + /* 217 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 218 */ "cmd ::= DESC full_table_name", + /* 219 */ "cmd ::= DESCRIBE full_table_name", + /* 220 */ "cmd ::= RESET QUERY CACHE", + /* 221 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", + /* 222 */ "analyze_opt ::=", + /* 223 */ "analyze_opt ::= ANALYZE", + /* 224 */ "explain_options ::=", + /* 225 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 226 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 227 */ "cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP", + /* 228 */ "cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 229 */ "cmd ::= DROP FUNCTION function_name", + /* 230 */ "agg_func_opt ::=", + /* 231 */ "agg_func_opt ::= AGGREGATE", + /* 232 */ "bufsize_opt ::=", + /* 233 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 234 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression", + /* 235 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 236 */ "into_opt ::=", + /* 237 */ "into_opt ::= INTO full_table_name", + /* 238 */ "stream_options ::=", + /* 239 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 240 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 241 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 242 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 243 */ "cmd ::= KILL QUERY NK_INTEGER", + /* 244 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 245 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 246 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 247 */ "dnode_list ::= DNODE NK_INTEGER", + /* 248 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 249 */ "cmd ::= SYNCDB db_name REPLICA", + /* 250 */ "cmd ::= query_expression", + /* 251 */ "literal ::= NK_INTEGER", + /* 252 */ "literal ::= NK_FLOAT", + /* 253 */ "literal ::= NK_STRING", + /* 254 */ "literal ::= NK_BOOL", + /* 255 */ "literal ::= TIMESTAMP NK_STRING", + /* 256 */ "literal ::= duration_literal", + /* 257 */ "literal ::= NULL", + /* 258 */ "literal ::= NK_QUESTION", + /* 259 */ "duration_literal ::= NK_VARIABLE", + /* 260 */ "signed ::= NK_INTEGER", + /* 261 */ "signed ::= NK_PLUS NK_INTEGER", + /* 262 */ "signed ::= NK_MINUS NK_INTEGER", + /* 263 */ "signed ::= NK_FLOAT", + /* 264 */ "signed ::= NK_PLUS NK_FLOAT", + /* 265 */ "signed ::= NK_MINUS NK_FLOAT", + /* 266 */ "signed_literal ::= signed", + /* 267 */ "signed_literal ::= NK_STRING", + /* 268 */ "signed_literal ::= NK_BOOL", + /* 269 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 270 */ "signed_literal ::= duration_literal", + /* 271 */ "signed_literal ::= NULL", + /* 272 */ "literal_list ::= signed_literal", + /* 273 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 274 */ "db_name ::= NK_ID", + /* 275 */ "table_name ::= NK_ID", + /* 276 */ "column_name ::= NK_ID", + /* 277 */ "function_name ::= NK_ID", + /* 278 */ "table_alias ::= NK_ID", + /* 279 */ "column_alias ::= NK_ID", + /* 280 */ "user_name ::= NK_ID", + /* 281 */ "index_name ::= NK_ID", + /* 282 */ "topic_name ::= NK_ID", + /* 283 */ "stream_name ::= NK_ID", + /* 284 */ "expression ::= literal", + /* 285 */ "expression ::= pseudo_column", + /* 286 */ "expression ::= column_reference", + /* 287 */ "expression ::= function_expression", + /* 288 */ "expression ::= subquery", + /* 289 */ "expression ::= NK_LP expression NK_RP", + /* 290 */ "expression ::= NK_PLUS expression", + /* 291 */ "expression ::= NK_MINUS expression", + /* 292 */ "expression ::= expression NK_PLUS expression", + /* 293 */ "expression ::= expression NK_MINUS expression", + /* 294 */ "expression ::= expression NK_STAR expression", + /* 295 */ "expression ::= expression NK_SLASH expression", + /* 296 */ "expression ::= expression NK_REM expression", + /* 297 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 298 */ "expression_list ::= expression", + /* 299 */ "expression_list ::= expression_list NK_COMMA expression", + /* 300 */ "column_reference ::= column_name", + /* 301 */ "column_reference ::= table_name NK_DOT column_name", + /* 302 */ "pseudo_column ::= ROWTS", + /* 303 */ "pseudo_column ::= TBNAME", + /* 304 */ "pseudo_column ::= QSTARTTS", + /* 305 */ "pseudo_column ::= QENDTS", + /* 306 */ "pseudo_column ::= WSTARTTS", + /* 307 */ "pseudo_column ::= WENDTS", + /* 308 */ "pseudo_column ::= WDURATION", + /* 309 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 310 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 311 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", + /* 312 */ "function_expression ::= noarg_func NK_LP NK_RP", + /* 313 */ "noarg_func ::= NOW", + /* 314 */ "noarg_func ::= TODAY", + /* 315 */ "noarg_func ::= TIMEZONE", + /* 316 */ "star_func ::= COUNT", + /* 317 */ "star_func ::= FIRST", + /* 318 */ "star_func ::= LAST", + /* 319 */ "star_func ::= LAST_ROW", + /* 320 */ "star_func_para_list ::= NK_STAR", + /* 321 */ "star_func_para_list ::= other_para_list", + /* 322 */ "other_para_list ::= star_func_para", + /* 323 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 324 */ "star_func_para ::= expression", + /* 325 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 326 */ "predicate ::= expression compare_op expression", + /* 327 */ "predicate ::= expression BETWEEN expression AND expression", + /* 328 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 329 */ "predicate ::= expression IS NULL", + /* 330 */ "predicate ::= expression IS NOT NULL", + /* 331 */ "predicate ::= expression in_op in_predicate_value", + /* 332 */ "compare_op ::= NK_LT", + /* 333 */ "compare_op ::= NK_GT", + /* 334 */ "compare_op ::= NK_LE", + /* 335 */ "compare_op ::= NK_GE", + /* 336 */ "compare_op ::= NK_NE", + /* 337 */ "compare_op ::= NK_EQ", + /* 338 */ "compare_op ::= LIKE", + /* 339 */ "compare_op ::= NOT LIKE", + /* 340 */ "compare_op ::= MATCH", + /* 341 */ "compare_op ::= NMATCH", + /* 342 */ "compare_op ::= CONTAINS", + /* 343 */ "in_op ::= IN", + /* 344 */ "in_op ::= NOT IN", + /* 345 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 346 */ "boolean_value_expression ::= boolean_primary", + /* 347 */ "boolean_value_expression ::= NOT boolean_primary", + /* 348 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 349 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 350 */ "boolean_primary ::= predicate", + /* 351 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 352 */ "common_expression ::= expression", + /* 353 */ "common_expression ::= boolean_value_expression", + /* 354 */ "from_clause ::= FROM table_reference_list", + /* 355 */ "table_reference_list ::= table_reference", + /* 356 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 357 */ "table_reference ::= table_primary", + /* 358 */ "table_reference ::= joined_table", + /* 359 */ "table_primary ::= table_name alias_opt", + /* 360 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 361 */ "table_primary ::= subquery alias_opt", + /* 362 */ "table_primary ::= parenthesized_joined_table", + /* 363 */ "alias_opt ::=", + /* 364 */ "alias_opt ::= table_alias", + /* 365 */ "alias_opt ::= AS table_alias", + /* 366 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 367 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 368 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 369 */ "join_type ::=", + /* 370 */ "join_type ::= INNER", + /* 371 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 372 */ "set_quantifier_opt ::=", + /* 373 */ "set_quantifier_opt ::= DISTINCT", + /* 374 */ "set_quantifier_opt ::= ALL", + /* 375 */ "select_list ::= NK_STAR", + /* 376 */ "select_list ::= select_sublist", + /* 377 */ "select_sublist ::= select_item", + /* 378 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 379 */ "select_item ::= common_expression", + /* 380 */ "select_item ::= common_expression column_alias", + /* 381 */ "select_item ::= common_expression AS column_alias", + /* 382 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 383 */ "where_clause_opt ::=", + /* 384 */ "where_clause_opt ::= WHERE search_condition", + /* 385 */ "partition_by_clause_opt ::=", + /* 386 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 387 */ "twindow_clause_opt ::=", + /* 388 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 389 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 390 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 391 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 392 */ "sliding_opt ::=", + /* 393 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 394 */ "fill_opt ::=", + /* 395 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 396 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 397 */ "fill_mode ::= NONE", + /* 398 */ "fill_mode ::= PREV", + /* 399 */ "fill_mode ::= NULL", + /* 400 */ "fill_mode ::= LINEAR", + /* 401 */ "fill_mode ::= NEXT", + /* 402 */ "group_by_clause_opt ::=", + /* 403 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 404 */ "group_by_list ::= expression", + /* 405 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 406 */ "having_clause_opt ::=", + /* 407 */ "having_clause_opt ::= HAVING search_condition", + /* 408 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 409 */ "query_expression_body ::= query_primary", + /* 410 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 411 */ "query_primary ::= query_specification", + /* 412 */ "order_by_clause_opt ::=", + /* 413 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 414 */ "slimit_clause_opt ::=", + /* 415 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 416 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 417 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 418 */ "limit_clause_opt ::=", + /* 419 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 420 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 421 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 422 */ "subquery ::= NK_LP query_expression NK_RP", + /* 423 */ "search_condition ::= common_expression", + /* 424 */ "sort_specification_list ::= sort_specification", + /* 425 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 426 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 427 */ "ordering_specification_opt ::=", + /* 428 */ "ordering_specification_opt ::= ASC", + /* 429 */ "ordering_specification_opt ::= DESC", + /* 430 */ "null_ordering_opt ::=", + /* 431 */ "null_ordering_opt ::= NULLS FIRST", + /* 432 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1662,156 +1765,164 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 211: /* cmd */ - case 214: /* literal */ - case 221: /* db_options */ - case 223: /* alter_db_options */ - case 228: /* retention */ - case 229: /* full_table_name */ - case 232: /* table_options */ - case 236: /* alter_table_clause */ - case 237: /* alter_table_options */ - case 240: /* create_subtable_clause */ - case 243: /* drop_table_clause */ - case 246: /* column_def */ - case 249: /* col_name */ - case 250: /* db_name_cond_opt */ - case 251: /* like_pattern_opt */ - case 252: /* table_name_cond */ - case 253: /* from_db_opt */ - case 254: /* func_name */ - case 257: /* index_options */ - case 259: /* duration_literal */ - case 260: /* sliding_opt */ - case 261: /* func */ - case 264: /* query_expression */ - case 266: /* explain_options */ - case 271: /* signed */ - case 272: /* signed_literal */ - case 275: /* expression */ - case 276: /* pseudo_column */ - case 277: /* column_reference */ - case 278: /* subquery */ - case 279: /* predicate */ - case 282: /* in_predicate_value */ - case 283: /* boolean_value_expression */ - case 284: /* boolean_primary */ - case 285: /* common_expression */ - case 286: /* from_clause */ - case 287: /* table_reference_list */ - case 288: /* table_reference */ - case 289: /* table_primary */ - case 290: /* joined_table */ - case 292: /* parenthesized_joined_table */ - case 294: /* search_condition */ - case 295: /* query_specification */ - case 298: /* where_clause_opt */ - case 300: /* twindow_clause_opt */ - case 302: /* having_clause_opt */ - case 304: /* select_item */ - case 305: /* fill_opt */ - case 308: /* query_expression_body */ - case 310: /* slimit_clause_opt */ - case 311: /* limit_clause_opt */ - case 312: /* query_primary */ - case 314: /* sort_specification */ + case 220: /* cmd */ + case 223: /* literal */ + case 230: /* db_options */ + case 232: /* alter_db_options */ + case 237: /* retention */ + case 238: /* full_table_name */ + case 241: /* table_options */ + case 245: /* alter_table_clause */ + case 246: /* alter_table_options */ + case 249: /* create_subtable_clause */ + case 252: /* drop_table_clause */ + case 255: /* column_def */ + case 258: /* col_name */ + case 259: /* db_name_cond_opt */ + case 260: /* like_pattern_opt */ + case 261: /* table_name_cond */ + case 262: /* from_db_opt */ + case 263: /* func_name */ + case 266: /* index_options */ + case 268: /* duration_literal */ + case 269: /* sliding_opt */ + case 270: /* func */ + case 273: /* query_expression */ + case 275: /* explain_options */ + case 279: /* stream_options */ + case 280: /* into_opt */ + case 282: /* signed */ + case 283: /* signed_literal */ + case 286: /* expression */ + case 287: /* pseudo_column */ + case 288: /* column_reference */ + case 289: /* function_expression */ + case 290: /* subquery */ + case 295: /* star_func_para */ + case 296: /* predicate */ + case 299: /* in_predicate_value */ + case 300: /* boolean_value_expression */ + case 301: /* boolean_primary */ + case 302: /* common_expression */ + case 303: /* from_clause */ + case 304: /* table_reference_list */ + case 305: /* table_reference */ + case 306: /* table_primary */ + case 307: /* joined_table */ + case 309: /* parenthesized_joined_table */ + case 311: /* search_condition */ + case 312: /* query_specification */ + case 315: /* where_clause_opt */ + case 317: /* twindow_clause_opt */ + case 319: /* having_clause_opt */ + case 321: /* select_item */ + case 322: /* fill_opt */ + case 325: /* query_expression_body */ + case 327: /* slimit_clause_opt */ + case 328: /* limit_clause_opt */ + case 329: /* query_primary */ + case 331: /* sort_specification */ { - nodesDestroyNode((yypminor->yy286)); + nodesDestroyNode((yypminor->yy456)); } break; - case 212: /* account_options */ - case 213: /* alter_account_options */ - case 215: /* alter_account_option */ - case 268: /* bufsize_opt */ + case 221: /* account_options */ + case 222: /* alter_account_options */ + case 224: /* alter_account_option */ + case 277: /* bufsize_opt */ { } break; - case 216: /* user_name */ - case 217: /* dnode_endpoint */ - case 218: /* dnode_host_name */ - case 220: /* db_name */ - case 238: /* column_name */ - case 245: /* table_name */ - case 255: /* function_name */ - case 256: /* index_name */ - case 263: /* topic_name */ - case 269: /* stream_name */ - case 273: /* table_alias */ - case 274: /* column_alias */ - case 291: /* alias_opt */ + case 225: /* user_name */ + case 226: /* dnode_endpoint */ + case 227: /* dnode_host_name */ + case 229: /* db_name */ + case 247: /* column_name */ + case 254: /* table_name */ + case 264: /* function_name */ + case 265: /* index_name */ + case 272: /* topic_name */ + case 278: /* stream_name */ + case 284: /* table_alias */ + case 285: /* column_alias */ + case 291: /* star_func */ + case 293: /* noarg_func */ + case 308: /* alias_opt */ { } break; - case 219: /* not_exists_opt */ - case 222: /* exists_opt */ - case 265: /* analyze_opt */ - case 267: /* agg_func_opt */ - case 296: /* set_quantifier_opt */ + case 228: /* not_exists_opt */ + case 231: /* exists_opt */ + case 274: /* analyze_opt */ + case 276: /* agg_func_opt */ + case 313: /* set_quantifier_opt */ { } break; - case 224: /* integer_list */ - case 225: /* variable_list */ - case 226: /* retention_list */ - case 230: /* column_def_list */ - case 231: /* tags_def_opt */ - case 233: /* multi_create_clause */ - case 234: /* tags_def */ - case 235: /* multi_drop_clause */ - case 241: /* specific_tags_opt */ - case 242: /* literal_list */ - case 244: /* col_name_list */ - case 247: /* func_name_list */ - case 258: /* func_list */ - case 262: /* expression_list */ - case 270: /* dnode_list */ - case 297: /* select_list */ - case 299: /* partition_by_clause_opt */ - case 301: /* group_by_clause_opt */ - case 303: /* select_sublist */ - case 307: /* group_by_list */ - case 309: /* order_by_clause_opt */ - case 313: /* sort_specification_list */ + case 233: /* integer_list */ + case 234: /* variable_list */ + case 235: /* retention_list */ + case 239: /* column_def_list */ + case 240: /* tags_def_opt */ + case 242: /* multi_create_clause */ + case 243: /* tags_def */ + case 244: /* multi_drop_clause */ + case 250: /* specific_tags_opt */ + case 251: /* literal_list */ + case 253: /* col_name_list */ + case 256: /* func_name_list */ + case 267: /* func_list */ + case 271: /* expression_list */ + case 281: /* dnode_list */ + case 292: /* star_func_para_list */ + case 294: /* other_para_list */ + case 314: /* select_list */ + case 316: /* partition_by_clause_opt */ + case 318: /* group_by_clause_opt */ + case 320: /* select_sublist */ + case 324: /* group_by_list */ + case 326: /* order_by_clause_opt */ + case 330: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy352)); + nodesDestroyList((yypminor->yy632)); } break; - case 227: /* alter_db_option */ - case 248: /* alter_table_option */ + case 236: /* alter_db_option */ + case 257: /* alter_table_option */ { } break; - case 239: /* type_name */ + case 248: /* type_name */ { } break; - case 280: /* compare_op */ - case 281: /* in_op */ + case 297: /* compare_op */ + case 298: /* in_op */ { } break; - case 293: /* join_type */ + case 310: /* join_type */ { } break; - case 306: /* fill_mode */ + case 323: /* fill_mode */ { } break; - case 315: /* ordering_specification_opt */ + case 332: /* ordering_specification_opt */ { } break; - case 316: /* null_ordering_opt */ + case 333: /* null_ordering_opt */ { } @@ -2102,419 +2213,439 @@ static void yy_shift( /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side ** of that rule */ static const YYCODETYPE yyRuleInfoLhs[] = { - 211, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - 211, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - 212, /* (2) account_options ::= */ - 212, /* (3) account_options ::= account_options PPS literal */ - 212, /* (4) account_options ::= account_options TSERIES literal */ - 212, /* (5) account_options ::= account_options STORAGE literal */ - 212, /* (6) account_options ::= account_options STREAMS literal */ - 212, /* (7) account_options ::= account_options QTIME literal */ - 212, /* (8) account_options ::= account_options DBS literal */ - 212, /* (9) account_options ::= account_options USERS literal */ - 212, /* (10) account_options ::= account_options CONNS literal */ - 212, /* (11) account_options ::= account_options STATE literal */ - 213, /* (12) alter_account_options ::= alter_account_option */ - 213, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - 215, /* (14) alter_account_option ::= PASS literal */ - 215, /* (15) alter_account_option ::= PPS literal */ - 215, /* (16) alter_account_option ::= TSERIES literal */ - 215, /* (17) alter_account_option ::= STORAGE literal */ - 215, /* (18) alter_account_option ::= STREAMS literal */ - 215, /* (19) alter_account_option ::= QTIME literal */ - 215, /* (20) alter_account_option ::= DBS literal */ - 215, /* (21) alter_account_option ::= USERS literal */ - 215, /* (22) alter_account_option ::= CONNS literal */ - 215, /* (23) alter_account_option ::= STATE literal */ - 211, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ - 211, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - 211, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - 211, /* (27) cmd ::= DROP USER user_name */ - 211, /* (28) cmd ::= CREATE DNODE dnode_endpoint */ - 211, /* (29) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - 211, /* (30) cmd ::= DROP DNODE NK_INTEGER */ - 211, /* (31) cmd ::= DROP DNODE dnode_endpoint */ - 211, /* (32) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - 211, /* (33) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - 211, /* (34) cmd ::= ALTER ALL DNODES NK_STRING */ - 211, /* (35) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - 217, /* (36) dnode_endpoint ::= NK_STRING */ - 218, /* (37) dnode_host_name ::= NK_ID */ - 218, /* (38) dnode_host_name ::= NK_IPTOKEN */ - 211, /* (39) cmd ::= ALTER LOCAL NK_STRING */ - 211, /* (40) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - 211, /* (41) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - 211, /* (42) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - 211, /* (43) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - 211, /* (44) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - 211, /* (45) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - 211, /* (46) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - 211, /* (47) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - 211, /* (48) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - 211, /* (49) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - 211, /* (50) cmd ::= DROP DATABASE exists_opt db_name */ - 211, /* (51) cmd ::= USE db_name */ - 211, /* (52) cmd ::= ALTER DATABASE db_name alter_db_options */ - 219, /* (53) not_exists_opt ::= IF NOT EXISTS */ - 219, /* (54) not_exists_opt ::= */ - 222, /* (55) exists_opt ::= IF EXISTS */ - 222, /* (56) exists_opt ::= */ - 221, /* (57) db_options ::= */ - 221, /* (58) db_options ::= db_options BLOCKS NK_INTEGER */ - 221, /* (59) db_options ::= db_options CACHE NK_INTEGER */ - 221, /* (60) db_options ::= db_options CACHELAST NK_INTEGER */ - 221, /* (61) db_options ::= db_options COMP NK_INTEGER */ - 221, /* (62) db_options ::= db_options DAYS NK_INTEGER */ - 221, /* (63) db_options ::= db_options DAYS NK_VARIABLE */ - 221, /* (64) db_options ::= db_options FSYNC NK_INTEGER */ - 221, /* (65) db_options ::= db_options MAXROWS NK_INTEGER */ - 221, /* (66) db_options ::= db_options MINROWS NK_INTEGER */ - 221, /* (67) db_options ::= db_options KEEP integer_list */ - 221, /* (68) db_options ::= db_options KEEP variable_list */ - 221, /* (69) db_options ::= db_options PRECISION NK_STRING */ - 221, /* (70) db_options ::= db_options QUORUM NK_INTEGER */ - 221, /* (71) db_options ::= db_options REPLICA NK_INTEGER */ - 221, /* (72) db_options ::= db_options TTL NK_INTEGER */ - 221, /* (73) db_options ::= db_options WAL NK_INTEGER */ - 221, /* (74) db_options ::= db_options VGROUPS NK_INTEGER */ - 221, /* (75) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - 221, /* (76) db_options ::= db_options STREAM_MODE NK_INTEGER */ - 221, /* (77) db_options ::= db_options RETENTIONS retention_list */ - 223, /* (78) alter_db_options ::= alter_db_option */ - 223, /* (79) alter_db_options ::= alter_db_options alter_db_option */ - 227, /* (80) alter_db_option ::= BLOCKS NK_INTEGER */ - 227, /* (81) alter_db_option ::= FSYNC NK_INTEGER */ - 227, /* (82) alter_db_option ::= KEEP integer_list */ - 227, /* (83) alter_db_option ::= KEEP variable_list */ - 227, /* (84) alter_db_option ::= WAL NK_INTEGER */ - 227, /* (85) alter_db_option ::= QUORUM NK_INTEGER */ - 227, /* (86) alter_db_option ::= CACHELAST NK_INTEGER */ - 227, /* (87) alter_db_option ::= REPLICA NK_INTEGER */ - 224, /* (88) integer_list ::= NK_INTEGER */ - 224, /* (89) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - 225, /* (90) variable_list ::= NK_VARIABLE */ - 225, /* (91) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - 226, /* (92) retention_list ::= retention */ - 226, /* (93) retention_list ::= retention_list NK_COMMA retention */ - 228, /* (94) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - 211, /* (95) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - 211, /* (96) cmd ::= CREATE TABLE multi_create_clause */ - 211, /* (97) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - 211, /* (98) cmd ::= DROP TABLE multi_drop_clause */ - 211, /* (99) cmd ::= DROP STABLE exists_opt full_table_name */ - 211, /* (100) cmd ::= ALTER TABLE alter_table_clause */ - 211, /* (101) cmd ::= ALTER STABLE alter_table_clause */ - 236, /* (102) alter_table_clause ::= full_table_name alter_table_options */ - 236, /* (103) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - 236, /* (104) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - 236, /* (105) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - 236, /* (106) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - 236, /* (107) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - 236, /* (108) alter_table_clause ::= full_table_name DROP TAG column_name */ - 236, /* (109) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - 236, /* (110) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - 236, /* (111) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ - 233, /* (112) multi_create_clause ::= create_subtable_clause */ - 233, /* (113) multi_create_clause ::= multi_create_clause create_subtable_clause */ - 240, /* (114) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ - 235, /* (115) multi_drop_clause ::= drop_table_clause */ - 235, /* (116) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - 243, /* (117) drop_table_clause ::= exists_opt full_table_name */ - 241, /* (118) specific_tags_opt ::= */ - 241, /* (119) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - 229, /* (120) full_table_name ::= table_name */ - 229, /* (121) full_table_name ::= db_name NK_DOT table_name */ - 230, /* (122) column_def_list ::= column_def */ - 230, /* (123) column_def_list ::= column_def_list NK_COMMA column_def */ - 246, /* (124) column_def ::= column_name type_name */ - 246, /* (125) column_def ::= column_name type_name COMMENT NK_STRING */ - 239, /* (126) type_name ::= BOOL */ - 239, /* (127) type_name ::= TINYINT */ - 239, /* (128) type_name ::= SMALLINT */ - 239, /* (129) type_name ::= INT */ - 239, /* (130) type_name ::= INTEGER */ - 239, /* (131) type_name ::= BIGINT */ - 239, /* (132) type_name ::= FLOAT */ - 239, /* (133) type_name ::= DOUBLE */ - 239, /* (134) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - 239, /* (135) type_name ::= TIMESTAMP */ - 239, /* (136) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - 239, /* (137) type_name ::= TINYINT UNSIGNED */ - 239, /* (138) type_name ::= SMALLINT UNSIGNED */ - 239, /* (139) type_name ::= INT UNSIGNED */ - 239, /* (140) type_name ::= BIGINT UNSIGNED */ - 239, /* (141) type_name ::= JSON */ - 239, /* (142) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - 239, /* (143) type_name ::= MEDIUMBLOB */ - 239, /* (144) type_name ::= BLOB */ - 239, /* (145) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - 239, /* (146) type_name ::= DECIMAL */ - 239, /* (147) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - 239, /* (148) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 231, /* (149) tags_def_opt ::= */ - 231, /* (150) tags_def_opt ::= tags_def */ - 234, /* (151) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - 232, /* (152) table_options ::= */ - 232, /* (153) table_options ::= table_options COMMENT NK_STRING */ - 232, /* (154) table_options ::= table_options KEEP integer_list */ - 232, /* (155) table_options ::= table_options TTL NK_INTEGER */ - 232, /* (156) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - 232, /* (157) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ - 232, /* (158) table_options ::= table_options FILE_FACTOR NK_FLOAT */ - 232, /* (159) table_options ::= table_options DELAY NK_INTEGER */ - 237, /* (160) alter_table_options ::= alter_table_option */ - 237, /* (161) alter_table_options ::= alter_table_options alter_table_option */ - 248, /* (162) alter_table_option ::= COMMENT NK_STRING */ - 248, /* (163) alter_table_option ::= KEEP integer_list */ - 248, /* (164) alter_table_option ::= TTL NK_INTEGER */ - 244, /* (165) col_name_list ::= col_name */ - 244, /* (166) col_name_list ::= col_name_list NK_COMMA col_name */ - 249, /* (167) col_name ::= column_name */ - 211, /* (168) cmd ::= SHOW DNODES */ - 211, /* (169) cmd ::= SHOW USERS */ - 211, /* (170) cmd ::= SHOW DATABASES */ - 211, /* (171) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - 211, /* (172) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - 211, /* (173) cmd ::= SHOW db_name_cond_opt VGROUPS */ - 211, /* (174) cmd ::= SHOW MNODES */ - 211, /* (175) cmd ::= SHOW MODULES */ - 211, /* (176) cmd ::= SHOW QNODES */ - 211, /* (177) cmd ::= SHOW FUNCTIONS */ - 211, /* (178) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - 211, /* (179) cmd ::= SHOW STREAMS */ - 211, /* (180) cmd ::= SHOW ACCOUNTS */ - 211, /* (181) cmd ::= SHOW APPS */ - 211, /* (182) cmd ::= SHOW CONNECTIONS */ - 211, /* (183) cmd ::= SHOW LICENCE */ - 211, /* (184) cmd ::= SHOW GRANTS */ - 211, /* (185) cmd ::= SHOW CREATE DATABASE db_name */ - 211, /* (186) cmd ::= SHOW CREATE TABLE full_table_name */ - 211, /* (187) cmd ::= SHOW CREATE STABLE full_table_name */ - 211, /* (188) cmd ::= SHOW QUERIES */ - 211, /* (189) cmd ::= SHOW SCORES */ - 211, /* (190) cmd ::= SHOW TOPICS */ - 211, /* (191) cmd ::= SHOW VARIABLES */ - 211, /* (192) cmd ::= SHOW BNODES */ - 211, /* (193) cmd ::= SHOW SNODES */ - 250, /* (194) db_name_cond_opt ::= */ - 250, /* (195) db_name_cond_opt ::= db_name NK_DOT */ - 251, /* (196) like_pattern_opt ::= */ - 251, /* (197) like_pattern_opt ::= LIKE NK_STRING */ - 252, /* (198) table_name_cond ::= table_name */ - 253, /* (199) from_db_opt ::= */ - 253, /* (200) from_db_opt ::= FROM db_name */ - 247, /* (201) func_name_list ::= func_name */ - 247, /* (202) func_name_list ::= func_name_list NK_COMMA col_name */ - 254, /* (203) func_name ::= function_name */ - 211, /* (204) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - 211, /* (205) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ - 211, /* (206) cmd ::= DROP INDEX exists_opt index_name ON table_name */ - 257, /* (207) index_options ::= */ - 257, /* (208) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - 257, /* (209) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - 258, /* (210) func_list ::= func */ - 258, /* (211) func_list ::= func_list NK_COMMA func */ - 261, /* (212) func ::= function_name NK_LP expression_list NK_RP */ - 211, /* (213) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - 211, /* (214) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ - 211, /* (215) cmd ::= DROP TOPIC exists_opt topic_name */ - 211, /* (216) cmd ::= DESC full_table_name */ - 211, /* (217) cmd ::= DESCRIBE full_table_name */ - 211, /* (218) cmd ::= RESET QUERY CACHE */ - 211, /* (219) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - 265, /* (220) analyze_opt ::= */ - 265, /* (221) analyze_opt ::= ANALYZE */ - 266, /* (222) explain_options ::= */ - 266, /* (223) explain_options ::= explain_options VERBOSE NK_BOOL */ - 266, /* (224) explain_options ::= explain_options RATIO NK_FLOAT */ - 211, /* (225) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ - 211, /* (226) cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - 211, /* (227) cmd ::= DROP FUNCTION function_name */ - 267, /* (228) agg_func_opt ::= */ - 267, /* (229) agg_func_opt ::= AGGREGATE */ - 268, /* (230) bufsize_opt ::= */ - 268, /* (231) bufsize_opt ::= BUFSIZE NK_INTEGER */ - 211, /* (232) cmd ::= CREATE STREAM stream_name INTO table_name AS query_expression */ - 211, /* (233) cmd ::= DROP STREAM stream_name */ - 211, /* (234) cmd ::= KILL CONNECTION NK_INTEGER */ - 211, /* (235) cmd ::= KILL QUERY NK_INTEGER */ - 211, /* (236) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - 211, /* (237) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - 211, /* (238) cmd ::= SPLIT VGROUP NK_INTEGER */ - 270, /* (239) dnode_list ::= DNODE NK_INTEGER */ - 270, /* (240) dnode_list ::= dnode_list DNODE NK_INTEGER */ - 211, /* (241) cmd ::= SYNCDB db_name REPLICA */ - 211, /* (242) cmd ::= query_expression */ - 214, /* (243) literal ::= NK_INTEGER */ - 214, /* (244) literal ::= NK_FLOAT */ - 214, /* (245) literal ::= NK_STRING */ - 214, /* (246) literal ::= NK_BOOL */ - 214, /* (247) literal ::= TIMESTAMP NK_STRING */ - 214, /* (248) literal ::= duration_literal */ - 214, /* (249) literal ::= NULL */ - 259, /* (250) duration_literal ::= NK_VARIABLE */ - 271, /* (251) signed ::= NK_INTEGER */ - 271, /* (252) signed ::= NK_PLUS NK_INTEGER */ - 271, /* (253) signed ::= NK_MINUS NK_INTEGER */ - 271, /* (254) signed ::= NK_FLOAT */ - 271, /* (255) signed ::= NK_PLUS NK_FLOAT */ - 271, /* (256) signed ::= NK_MINUS NK_FLOAT */ - 272, /* (257) signed_literal ::= signed */ - 272, /* (258) signed_literal ::= NK_STRING */ - 272, /* (259) signed_literal ::= NK_BOOL */ - 272, /* (260) signed_literal ::= TIMESTAMP NK_STRING */ - 272, /* (261) signed_literal ::= duration_literal */ - 272, /* (262) signed_literal ::= NULL */ - 242, /* (263) literal_list ::= signed_literal */ - 242, /* (264) literal_list ::= literal_list NK_COMMA signed_literal */ - 220, /* (265) db_name ::= NK_ID */ - 245, /* (266) table_name ::= NK_ID */ - 238, /* (267) column_name ::= NK_ID */ - 255, /* (268) function_name ::= NK_ID */ - 255, /* (269) function_name ::= FIRST */ - 255, /* (270) function_name ::= LAST */ - 255, /* (271) function_name ::= NOW */ - 255, /* (272) function_name ::= TODAY */ - 255, /* (273) function_name ::= TIMEZONE */ - 273, /* (274) table_alias ::= NK_ID */ - 274, /* (275) column_alias ::= NK_ID */ - 216, /* (276) user_name ::= NK_ID */ - 256, /* (277) index_name ::= NK_ID */ - 263, /* (278) topic_name ::= NK_ID */ - 269, /* (279) stream_name ::= NK_ID */ - 275, /* (280) expression ::= literal */ - 275, /* (281) expression ::= pseudo_column */ - 275, /* (282) expression ::= column_reference */ - 275, /* (283) expression ::= function_name NK_LP expression_list NK_RP */ - 275, /* (284) expression ::= function_name NK_LP NK_STAR NK_RP */ - 275, /* (285) expression ::= function_name NK_LP NK_RP */ - 275, /* (286) expression ::= CAST NK_LP expression AS type_name NK_RP */ - 275, /* (287) expression ::= subquery */ - 275, /* (288) expression ::= NK_LP expression NK_RP */ - 275, /* (289) expression ::= NK_PLUS expression */ - 275, /* (290) expression ::= NK_MINUS expression */ - 275, /* (291) expression ::= expression NK_PLUS expression */ - 275, /* (292) expression ::= expression NK_MINUS expression */ - 275, /* (293) expression ::= expression NK_STAR expression */ - 275, /* (294) expression ::= expression NK_SLASH expression */ - 275, /* (295) expression ::= expression NK_REM expression */ - 262, /* (296) expression_list ::= expression */ - 262, /* (297) expression_list ::= expression_list NK_COMMA expression */ - 277, /* (298) column_reference ::= column_name */ - 277, /* (299) column_reference ::= table_name NK_DOT column_name */ - 276, /* (300) pseudo_column ::= ROWTS */ - 276, /* (301) pseudo_column ::= TBNAME */ - 276, /* (302) pseudo_column ::= QSTARTTS */ - 276, /* (303) pseudo_column ::= QENDTS */ - 276, /* (304) pseudo_column ::= WSTARTTS */ - 276, /* (305) pseudo_column ::= WENDTS */ - 276, /* (306) pseudo_column ::= WDURATION */ - 279, /* (307) predicate ::= expression compare_op expression */ - 279, /* (308) predicate ::= expression BETWEEN expression AND expression */ - 279, /* (309) predicate ::= expression NOT BETWEEN expression AND expression */ - 279, /* (310) predicate ::= expression IS NULL */ - 279, /* (311) predicate ::= expression IS NOT NULL */ - 279, /* (312) predicate ::= expression in_op in_predicate_value */ - 280, /* (313) compare_op ::= NK_LT */ - 280, /* (314) compare_op ::= NK_GT */ - 280, /* (315) compare_op ::= NK_LE */ - 280, /* (316) compare_op ::= NK_GE */ - 280, /* (317) compare_op ::= NK_NE */ - 280, /* (318) compare_op ::= NK_EQ */ - 280, /* (319) compare_op ::= LIKE */ - 280, /* (320) compare_op ::= NOT LIKE */ - 280, /* (321) compare_op ::= MATCH */ - 280, /* (322) compare_op ::= NMATCH */ - 281, /* (323) in_op ::= IN */ - 281, /* (324) in_op ::= NOT IN */ - 282, /* (325) in_predicate_value ::= NK_LP expression_list NK_RP */ - 283, /* (326) boolean_value_expression ::= boolean_primary */ - 283, /* (327) boolean_value_expression ::= NOT boolean_primary */ - 283, /* (328) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - 283, /* (329) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - 284, /* (330) boolean_primary ::= predicate */ - 284, /* (331) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - 285, /* (332) common_expression ::= expression */ - 285, /* (333) common_expression ::= boolean_value_expression */ - 286, /* (334) from_clause ::= FROM table_reference_list */ - 287, /* (335) table_reference_list ::= table_reference */ - 287, /* (336) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - 288, /* (337) table_reference ::= table_primary */ - 288, /* (338) table_reference ::= joined_table */ - 289, /* (339) table_primary ::= table_name alias_opt */ - 289, /* (340) table_primary ::= db_name NK_DOT table_name alias_opt */ - 289, /* (341) table_primary ::= subquery alias_opt */ - 289, /* (342) table_primary ::= parenthesized_joined_table */ - 291, /* (343) alias_opt ::= */ - 291, /* (344) alias_opt ::= table_alias */ - 291, /* (345) alias_opt ::= AS table_alias */ - 292, /* (346) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - 292, /* (347) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - 290, /* (348) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - 293, /* (349) join_type ::= */ - 293, /* (350) join_type ::= INNER */ - 295, /* (351) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - 296, /* (352) set_quantifier_opt ::= */ - 296, /* (353) set_quantifier_opt ::= DISTINCT */ - 296, /* (354) set_quantifier_opt ::= ALL */ - 297, /* (355) select_list ::= NK_STAR */ - 297, /* (356) select_list ::= select_sublist */ - 303, /* (357) select_sublist ::= select_item */ - 303, /* (358) select_sublist ::= select_sublist NK_COMMA select_item */ - 304, /* (359) select_item ::= common_expression */ - 304, /* (360) select_item ::= common_expression column_alias */ - 304, /* (361) select_item ::= common_expression AS column_alias */ - 304, /* (362) select_item ::= table_name NK_DOT NK_STAR */ - 298, /* (363) where_clause_opt ::= */ - 298, /* (364) where_clause_opt ::= WHERE search_condition */ - 299, /* (365) partition_by_clause_opt ::= */ - 299, /* (366) partition_by_clause_opt ::= PARTITION BY expression_list */ - 300, /* (367) twindow_clause_opt ::= */ - 300, /* (368) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - 300, /* (369) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - 300, /* (370) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - 300, /* (371) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - 260, /* (372) sliding_opt ::= */ - 260, /* (373) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - 305, /* (374) fill_opt ::= */ - 305, /* (375) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - 305, /* (376) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - 306, /* (377) fill_mode ::= NONE */ - 306, /* (378) fill_mode ::= PREV */ - 306, /* (379) fill_mode ::= NULL */ - 306, /* (380) fill_mode ::= LINEAR */ - 306, /* (381) fill_mode ::= NEXT */ - 301, /* (382) group_by_clause_opt ::= */ - 301, /* (383) group_by_clause_opt ::= GROUP BY group_by_list */ - 307, /* (384) group_by_list ::= expression */ - 307, /* (385) group_by_list ::= group_by_list NK_COMMA expression */ - 302, /* (386) having_clause_opt ::= */ - 302, /* (387) having_clause_opt ::= HAVING search_condition */ - 264, /* (388) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - 308, /* (389) query_expression_body ::= query_primary */ - 308, /* (390) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - 312, /* (391) query_primary ::= query_specification */ - 309, /* (392) order_by_clause_opt ::= */ - 309, /* (393) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 310, /* (394) slimit_clause_opt ::= */ - 310, /* (395) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - 310, /* (396) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - 310, /* (397) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 311, /* (398) limit_clause_opt ::= */ - 311, /* (399) limit_clause_opt ::= LIMIT NK_INTEGER */ - 311, /* (400) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - 311, /* (401) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 278, /* (402) subquery ::= NK_LP query_expression NK_RP */ - 294, /* (403) search_condition ::= common_expression */ - 313, /* (404) sort_specification_list ::= sort_specification */ - 313, /* (405) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - 314, /* (406) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - 315, /* (407) ordering_specification_opt ::= */ - 315, /* (408) ordering_specification_opt ::= ASC */ - 315, /* (409) ordering_specification_opt ::= DESC */ - 316, /* (410) null_ordering_opt ::= */ - 316, /* (411) null_ordering_opt ::= NULLS FIRST */ - 316, /* (412) null_ordering_opt ::= NULLS LAST */ + 220, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + 220, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + 221, /* (2) account_options ::= */ + 221, /* (3) account_options ::= account_options PPS literal */ + 221, /* (4) account_options ::= account_options TSERIES literal */ + 221, /* (5) account_options ::= account_options STORAGE literal */ + 221, /* (6) account_options ::= account_options STREAMS literal */ + 221, /* (7) account_options ::= account_options QTIME literal */ + 221, /* (8) account_options ::= account_options DBS literal */ + 221, /* (9) account_options ::= account_options USERS literal */ + 221, /* (10) account_options ::= account_options CONNS literal */ + 221, /* (11) account_options ::= account_options STATE literal */ + 222, /* (12) alter_account_options ::= alter_account_option */ + 222, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + 224, /* (14) alter_account_option ::= PASS literal */ + 224, /* (15) alter_account_option ::= PPS literal */ + 224, /* (16) alter_account_option ::= TSERIES literal */ + 224, /* (17) alter_account_option ::= STORAGE literal */ + 224, /* (18) alter_account_option ::= STREAMS literal */ + 224, /* (19) alter_account_option ::= QTIME literal */ + 224, /* (20) alter_account_option ::= DBS literal */ + 224, /* (21) alter_account_option ::= USERS literal */ + 224, /* (22) alter_account_option ::= CONNS literal */ + 224, /* (23) alter_account_option ::= STATE literal */ + 220, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ + 220, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + 220, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + 220, /* (27) cmd ::= DROP USER user_name */ + 220, /* (28) cmd ::= CREATE DNODE dnode_endpoint */ + 220, /* (29) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + 220, /* (30) cmd ::= DROP DNODE NK_INTEGER */ + 220, /* (31) cmd ::= DROP DNODE dnode_endpoint */ + 220, /* (32) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + 220, /* (33) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + 220, /* (34) cmd ::= ALTER ALL DNODES NK_STRING */ + 220, /* (35) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + 226, /* (36) dnode_endpoint ::= NK_STRING */ + 227, /* (37) dnode_host_name ::= NK_ID */ + 227, /* (38) dnode_host_name ::= NK_IPTOKEN */ + 220, /* (39) cmd ::= ALTER LOCAL NK_STRING */ + 220, /* (40) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + 220, /* (41) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + 220, /* (42) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + 220, /* (43) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + 220, /* (44) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + 220, /* (45) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + 220, /* (46) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + 220, /* (47) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + 220, /* (48) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + 220, /* (49) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + 220, /* (50) cmd ::= DROP DATABASE exists_opt db_name */ + 220, /* (51) cmd ::= USE db_name */ + 220, /* (52) cmd ::= ALTER DATABASE db_name alter_db_options */ + 228, /* (53) not_exists_opt ::= IF NOT EXISTS */ + 228, /* (54) not_exists_opt ::= */ + 231, /* (55) exists_opt ::= IF EXISTS */ + 231, /* (56) exists_opt ::= */ + 230, /* (57) db_options ::= */ + 230, /* (58) db_options ::= db_options BLOCKS NK_INTEGER */ + 230, /* (59) db_options ::= db_options CACHE NK_INTEGER */ + 230, /* (60) db_options ::= db_options CACHELAST NK_INTEGER */ + 230, /* (61) db_options ::= db_options COMP NK_INTEGER */ + 230, /* (62) db_options ::= db_options DAYS NK_INTEGER */ + 230, /* (63) db_options ::= db_options DAYS NK_VARIABLE */ + 230, /* (64) db_options ::= db_options FSYNC NK_INTEGER */ + 230, /* (65) db_options ::= db_options MAXROWS NK_INTEGER */ + 230, /* (66) db_options ::= db_options MINROWS NK_INTEGER */ + 230, /* (67) db_options ::= db_options KEEP integer_list */ + 230, /* (68) db_options ::= db_options KEEP variable_list */ + 230, /* (69) db_options ::= db_options PRECISION NK_STRING */ + 230, /* (70) db_options ::= db_options QUORUM NK_INTEGER */ + 230, /* (71) db_options ::= db_options REPLICA NK_INTEGER */ + 230, /* (72) db_options ::= db_options TTL NK_INTEGER */ + 230, /* (73) db_options ::= db_options WAL NK_INTEGER */ + 230, /* (74) db_options ::= db_options VGROUPS NK_INTEGER */ + 230, /* (75) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + 230, /* (76) db_options ::= db_options STREAM_MODE NK_INTEGER */ + 230, /* (77) db_options ::= db_options RETENTIONS retention_list */ + 232, /* (78) alter_db_options ::= alter_db_option */ + 232, /* (79) alter_db_options ::= alter_db_options alter_db_option */ + 236, /* (80) alter_db_option ::= BLOCKS NK_INTEGER */ + 236, /* (81) alter_db_option ::= FSYNC NK_INTEGER */ + 236, /* (82) alter_db_option ::= KEEP integer_list */ + 236, /* (83) alter_db_option ::= KEEP variable_list */ + 236, /* (84) alter_db_option ::= WAL NK_INTEGER */ + 236, /* (85) alter_db_option ::= QUORUM NK_INTEGER */ + 236, /* (86) alter_db_option ::= CACHELAST NK_INTEGER */ + 236, /* (87) alter_db_option ::= REPLICA NK_INTEGER */ + 233, /* (88) integer_list ::= NK_INTEGER */ + 233, /* (89) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + 234, /* (90) variable_list ::= NK_VARIABLE */ + 234, /* (91) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + 235, /* (92) retention_list ::= retention */ + 235, /* (93) retention_list ::= retention_list NK_COMMA retention */ + 237, /* (94) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + 220, /* (95) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + 220, /* (96) cmd ::= CREATE TABLE multi_create_clause */ + 220, /* (97) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + 220, /* (98) cmd ::= DROP TABLE multi_drop_clause */ + 220, /* (99) cmd ::= DROP STABLE exists_opt full_table_name */ + 220, /* (100) cmd ::= ALTER TABLE alter_table_clause */ + 220, /* (101) cmd ::= ALTER STABLE alter_table_clause */ + 245, /* (102) alter_table_clause ::= full_table_name alter_table_options */ + 245, /* (103) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + 245, /* (104) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + 245, /* (105) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + 245, /* (106) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + 245, /* (107) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + 245, /* (108) alter_table_clause ::= full_table_name DROP TAG column_name */ + 245, /* (109) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + 245, /* (110) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + 245, /* (111) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ + 242, /* (112) multi_create_clause ::= create_subtable_clause */ + 242, /* (113) multi_create_clause ::= multi_create_clause create_subtable_clause */ + 249, /* (114) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ + 244, /* (115) multi_drop_clause ::= drop_table_clause */ + 244, /* (116) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + 252, /* (117) drop_table_clause ::= exists_opt full_table_name */ + 250, /* (118) specific_tags_opt ::= */ + 250, /* (119) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + 238, /* (120) full_table_name ::= table_name */ + 238, /* (121) full_table_name ::= db_name NK_DOT table_name */ + 239, /* (122) column_def_list ::= column_def */ + 239, /* (123) column_def_list ::= column_def_list NK_COMMA column_def */ + 255, /* (124) column_def ::= column_name type_name */ + 255, /* (125) column_def ::= column_name type_name COMMENT NK_STRING */ + 248, /* (126) type_name ::= BOOL */ + 248, /* (127) type_name ::= TINYINT */ + 248, /* (128) type_name ::= SMALLINT */ + 248, /* (129) type_name ::= INT */ + 248, /* (130) type_name ::= INTEGER */ + 248, /* (131) type_name ::= BIGINT */ + 248, /* (132) type_name ::= FLOAT */ + 248, /* (133) type_name ::= DOUBLE */ + 248, /* (134) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + 248, /* (135) type_name ::= TIMESTAMP */ + 248, /* (136) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + 248, /* (137) type_name ::= TINYINT UNSIGNED */ + 248, /* (138) type_name ::= SMALLINT UNSIGNED */ + 248, /* (139) type_name ::= INT UNSIGNED */ + 248, /* (140) type_name ::= BIGINT UNSIGNED */ + 248, /* (141) type_name ::= JSON */ + 248, /* (142) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + 248, /* (143) type_name ::= MEDIUMBLOB */ + 248, /* (144) type_name ::= BLOB */ + 248, /* (145) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + 248, /* (146) type_name ::= DECIMAL */ + 248, /* (147) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + 248, /* (148) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 240, /* (149) tags_def_opt ::= */ + 240, /* (150) tags_def_opt ::= tags_def */ + 243, /* (151) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + 241, /* (152) table_options ::= */ + 241, /* (153) table_options ::= table_options COMMENT NK_STRING */ + 241, /* (154) table_options ::= table_options KEEP integer_list */ + 241, /* (155) table_options ::= table_options KEEP variable_list */ + 241, /* (156) table_options ::= table_options TTL NK_INTEGER */ + 241, /* (157) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + 241, /* (158) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ + 241, /* (159) table_options ::= table_options FILE_FACTOR NK_FLOAT */ + 241, /* (160) table_options ::= table_options DELAY NK_INTEGER */ + 246, /* (161) alter_table_options ::= alter_table_option */ + 246, /* (162) alter_table_options ::= alter_table_options alter_table_option */ + 257, /* (163) alter_table_option ::= COMMENT NK_STRING */ + 257, /* (164) alter_table_option ::= KEEP integer_list */ + 257, /* (165) alter_table_option ::= KEEP variable_list */ + 257, /* (166) alter_table_option ::= TTL NK_INTEGER */ + 253, /* (167) col_name_list ::= col_name */ + 253, /* (168) col_name_list ::= col_name_list NK_COMMA col_name */ + 258, /* (169) col_name ::= column_name */ + 220, /* (170) cmd ::= SHOW DNODES */ + 220, /* (171) cmd ::= SHOW USERS */ + 220, /* (172) cmd ::= SHOW DATABASES */ + 220, /* (173) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + 220, /* (174) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + 220, /* (175) cmd ::= SHOW db_name_cond_opt VGROUPS */ + 220, /* (176) cmd ::= SHOW MNODES */ + 220, /* (177) cmd ::= SHOW MODULES */ + 220, /* (178) cmd ::= SHOW QNODES */ + 220, /* (179) cmd ::= SHOW FUNCTIONS */ + 220, /* (180) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + 220, /* (181) cmd ::= SHOW STREAMS */ + 220, /* (182) cmd ::= SHOW ACCOUNTS */ + 220, /* (183) cmd ::= SHOW APPS */ + 220, /* (184) cmd ::= SHOW CONNECTIONS */ + 220, /* (185) cmd ::= SHOW LICENCE */ + 220, /* (186) cmd ::= SHOW GRANTS */ + 220, /* (187) cmd ::= SHOW CREATE DATABASE db_name */ + 220, /* (188) cmd ::= SHOW CREATE TABLE full_table_name */ + 220, /* (189) cmd ::= SHOW CREATE STABLE full_table_name */ + 220, /* (190) cmd ::= SHOW QUERIES */ + 220, /* (191) cmd ::= SHOW SCORES */ + 220, /* (192) cmd ::= SHOW TOPICS */ + 220, /* (193) cmd ::= SHOW VARIABLES */ + 220, /* (194) cmd ::= SHOW BNODES */ + 220, /* (195) cmd ::= SHOW SNODES */ + 259, /* (196) db_name_cond_opt ::= */ + 259, /* (197) db_name_cond_opt ::= db_name NK_DOT */ + 260, /* (198) like_pattern_opt ::= */ + 260, /* (199) like_pattern_opt ::= LIKE NK_STRING */ + 261, /* (200) table_name_cond ::= table_name */ + 262, /* (201) from_db_opt ::= */ + 262, /* (202) from_db_opt ::= FROM db_name */ + 256, /* (203) func_name_list ::= func_name */ + 256, /* (204) func_name_list ::= func_name_list NK_COMMA col_name */ + 263, /* (205) func_name ::= function_name */ + 220, /* (206) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + 220, /* (207) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ + 220, /* (208) cmd ::= DROP INDEX exists_opt index_name ON table_name */ + 266, /* (209) index_options ::= */ + 266, /* (210) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + 266, /* (211) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + 267, /* (212) func_list ::= func */ + 267, /* (213) func_list ::= func_list NK_COMMA func */ + 270, /* (214) func ::= function_name NK_LP expression_list NK_RP */ + 220, /* (215) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + 220, /* (216) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ + 220, /* (217) cmd ::= DROP TOPIC exists_opt topic_name */ + 220, /* (218) cmd ::= DESC full_table_name */ + 220, /* (219) cmd ::= DESCRIBE full_table_name */ + 220, /* (220) cmd ::= RESET QUERY CACHE */ + 220, /* (221) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + 274, /* (222) analyze_opt ::= */ + 274, /* (223) analyze_opt ::= ANALYZE */ + 275, /* (224) explain_options ::= */ + 275, /* (225) explain_options ::= explain_options VERBOSE NK_BOOL */ + 275, /* (226) explain_options ::= explain_options RATIO NK_FLOAT */ + 220, /* (227) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ + 220, /* (228) cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + 220, /* (229) cmd ::= DROP FUNCTION function_name */ + 276, /* (230) agg_func_opt ::= */ + 276, /* (231) agg_func_opt ::= AGGREGATE */ + 277, /* (232) bufsize_opt ::= */ + 277, /* (233) bufsize_opt ::= BUFSIZE NK_INTEGER */ + 220, /* (234) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ + 220, /* (235) cmd ::= DROP STREAM exists_opt stream_name */ + 280, /* (236) into_opt ::= */ + 280, /* (237) into_opt ::= INTO full_table_name */ + 279, /* (238) stream_options ::= */ + 279, /* (239) stream_options ::= stream_options TRIGGER AT_ONCE */ + 279, /* (240) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + 279, /* (241) stream_options ::= stream_options WATERMARK duration_literal */ + 220, /* (242) cmd ::= KILL CONNECTION NK_INTEGER */ + 220, /* (243) cmd ::= KILL QUERY NK_INTEGER */ + 220, /* (244) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + 220, /* (245) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + 220, /* (246) cmd ::= SPLIT VGROUP NK_INTEGER */ + 281, /* (247) dnode_list ::= DNODE NK_INTEGER */ + 281, /* (248) dnode_list ::= dnode_list DNODE NK_INTEGER */ + 220, /* (249) cmd ::= SYNCDB db_name REPLICA */ + 220, /* (250) cmd ::= query_expression */ + 223, /* (251) literal ::= NK_INTEGER */ + 223, /* (252) literal ::= NK_FLOAT */ + 223, /* (253) literal ::= NK_STRING */ + 223, /* (254) literal ::= NK_BOOL */ + 223, /* (255) literal ::= TIMESTAMP NK_STRING */ + 223, /* (256) literal ::= duration_literal */ + 223, /* (257) literal ::= NULL */ + 223, /* (258) literal ::= NK_QUESTION */ + 268, /* (259) duration_literal ::= NK_VARIABLE */ + 282, /* (260) signed ::= NK_INTEGER */ + 282, /* (261) signed ::= NK_PLUS NK_INTEGER */ + 282, /* (262) signed ::= NK_MINUS NK_INTEGER */ + 282, /* (263) signed ::= NK_FLOAT */ + 282, /* (264) signed ::= NK_PLUS NK_FLOAT */ + 282, /* (265) signed ::= NK_MINUS NK_FLOAT */ + 283, /* (266) signed_literal ::= signed */ + 283, /* (267) signed_literal ::= NK_STRING */ + 283, /* (268) signed_literal ::= NK_BOOL */ + 283, /* (269) signed_literal ::= TIMESTAMP NK_STRING */ + 283, /* (270) signed_literal ::= duration_literal */ + 283, /* (271) signed_literal ::= NULL */ + 251, /* (272) literal_list ::= signed_literal */ + 251, /* (273) literal_list ::= literal_list NK_COMMA signed_literal */ + 229, /* (274) db_name ::= NK_ID */ + 254, /* (275) table_name ::= NK_ID */ + 247, /* (276) column_name ::= NK_ID */ + 264, /* (277) function_name ::= NK_ID */ + 284, /* (278) table_alias ::= NK_ID */ + 285, /* (279) column_alias ::= NK_ID */ + 225, /* (280) user_name ::= NK_ID */ + 265, /* (281) index_name ::= NK_ID */ + 272, /* (282) topic_name ::= NK_ID */ + 278, /* (283) stream_name ::= NK_ID */ + 286, /* (284) expression ::= literal */ + 286, /* (285) expression ::= pseudo_column */ + 286, /* (286) expression ::= column_reference */ + 286, /* (287) expression ::= function_expression */ + 286, /* (288) expression ::= subquery */ + 286, /* (289) expression ::= NK_LP expression NK_RP */ + 286, /* (290) expression ::= NK_PLUS expression */ + 286, /* (291) expression ::= NK_MINUS expression */ + 286, /* (292) expression ::= expression NK_PLUS expression */ + 286, /* (293) expression ::= expression NK_MINUS expression */ + 286, /* (294) expression ::= expression NK_STAR expression */ + 286, /* (295) expression ::= expression NK_SLASH expression */ + 286, /* (296) expression ::= expression NK_REM expression */ + 286, /* (297) expression ::= column_reference NK_ARROW NK_STRING */ + 271, /* (298) expression_list ::= expression */ + 271, /* (299) expression_list ::= expression_list NK_COMMA expression */ + 288, /* (300) column_reference ::= column_name */ + 288, /* (301) column_reference ::= table_name NK_DOT column_name */ + 287, /* (302) pseudo_column ::= ROWTS */ + 287, /* (303) pseudo_column ::= TBNAME */ + 287, /* (304) pseudo_column ::= QSTARTTS */ + 287, /* (305) pseudo_column ::= QENDTS */ + 287, /* (306) pseudo_column ::= WSTARTTS */ + 287, /* (307) pseudo_column ::= WENDTS */ + 287, /* (308) pseudo_column ::= WDURATION */ + 289, /* (309) function_expression ::= function_name NK_LP expression_list NK_RP */ + 289, /* (310) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + 289, /* (311) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ + 289, /* (312) function_expression ::= noarg_func NK_LP NK_RP */ + 293, /* (313) noarg_func ::= NOW */ + 293, /* (314) noarg_func ::= TODAY */ + 293, /* (315) noarg_func ::= TIMEZONE */ + 291, /* (316) star_func ::= COUNT */ + 291, /* (317) star_func ::= FIRST */ + 291, /* (318) star_func ::= LAST */ + 291, /* (319) star_func ::= LAST_ROW */ + 292, /* (320) star_func_para_list ::= NK_STAR */ + 292, /* (321) star_func_para_list ::= other_para_list */ + 294, /* (322) other_para_list ::= star_func_para */ + 294, /* (323) other_para_list ::= other_para_list NK_COMMA star_func_para */ + 295, /* (324) star_func_para ::= expression */ + 295, /* (325) star_func_para ::= table_name NK_DOT NK_STAR */ + 296, /* (326) predicate ::= expression compare_op expression */ + 296, /* (327) predicate ::= expression BETWEEN expression AND expression */ + 296, /* (328) predicate ::= expression NOT BETWEEN expression AND expression */ + 296, /* (329) predicate ::= expression IS NULL */ + 296, /* (330) predicate ::= expression IS NOT NULL */ + 296, /* (331) predicate ::= expression in_op in_predicate_value */ + 297, /* (332) compare_op ::= NK_LT */ + 297, /* (333) compare_op ::= NK_GT */ + 297, /* (334) compare_op ::= NK_LE */ + 297, /* (335) compare_op ::= NK_GE */ + 297, /* (336) compare_op ::= NK_NE */ + 297, /* (337) compare_op ::= NK_EQ */ + 297, /* (338) compare_op ::= LIKE */ + 297, /* (339) compare_op ::= NOT LIKE */ + 297, /* (340) compare_op ::= MATCH */ + 297, /* (341) compare_op ::= NMATCH */ + 297, /* (342) compare_op ::= CONTAINS */ + 298, /* (343) in_op ::= IN */ + 298, /* (344) in_op ::= NOT IN */ + 299, /* (345) in_predicate_value ::= NK_LP expression_list NK_RP */ + 300, /* (346) boolean_value_expression ::= boolean_primary */ + 300, /* (347) boolean_value_expression ::= NOT boolean_primary */ + 300, /* (348) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + 300, /* (349) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + 301, /* (350) boolean_primary ::= predicate */ + 301, /* (351) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + 302, /* (352) common_expression ::= expression */ + 302, /* (353) common_expression ::= boolean_value_expression */ + 303, /* (354) from_clause ::= FROM table_reference_list */ + 304, /* (355) table_reference_list ::= table_reference */ + 304, /* (356) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + 305, /* (357) table_reference ::= table_primary */ + 305, /* (358) table_reference ::= joined_table */ + 306, /* (359) table_primary ::= table_name alias_opt */ + 306, /* (360) table_primary ::= db_name NK_DOT table_name alias_opt */ + 306, /* (361) table_primary ::= subquery alias_opt */ + 306, /* (362) table_primary ::= parenthesized_joined_table */ + 308, /* (363) alias_opt ::= */ + 308, /* (364) alias_opt ::= table_alias */ + 308, /* (365) alias_opt ::= AS table_alias */ + 309, /* (366) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + 309, /* (367) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + 307, /* (368) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + 310, /* (369) join_type ::= */ + 310, /* (370) join_type ::= INNER */ + 312, /* (371) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + 313, /* (372) set_quantifier_opt ::= */ + 313, /* (373) set_quantifier_opt ::= DISTINCT */ + 313, /* (374) set_quantifier_opt ::= ALL */ + 314, /* (375) select_list ::= NK_STAR */ + 314, /* (376) select_list ::= select_sublist */ + 320, /* (377) select_sublist ::= select_item */ + 320, /* (378) select_sublist ::= select_sublist NK_COMMA select_item */ + 321, /* (379) select_item ::= common_expression */ + 321, /* (380) select_item ::= common_expression column_alias */ + 321, /* (381) select_item ::= common_expression AS column_alias */ + 321, /* (382) select_item ::= table_name NK_DOT NK_STAR */ + 315, /* (383) where_clause_opt ::= */ + 315, /* (384) where_clause_opt ::= WHERE search_condition */ + 316, /* (385) partition_by_clause_opt ::= */ + 316, /* (386) partition_by_clause_opt ::= PARTITION BY expression_list */ + 317, /* (387) twindow_clause_opt ::= */ + 317, /* (388) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + 317, /* (389) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + 317, /* (390) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + 317, /* (391) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + 269, /* (392) sliding_opt ::= */ + 269, /* (393) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + 322, /* (394) fill_opt ::= */ + 322, /* (395) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + 322, /* (396) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + 323, /* (397) fill_mode ::= NONE */ + 323, /* (398) fill_mode ::= PREV */ + 323, /* (399) fill_mode ::= NULL */ + 323, /* (400) fill_mode ::= LINEAR */ + 323, /* (401) fill_mode ::= NEXT */ + 318, /* (402) group_by_clause_opt ::= */ + 318, /* (403) group_by_clause_opt ::= GROUP BY group_by_list */ + 324, /* (404) group_by_list ::= expression */ + 324, /* (405) group_by_list ::= group_by_list NK_COMMA expression */ + 319, /* (406) having_clause_opt ::= */ + 319, /* (407) having_clause_opt ::= HAVING search_condition */ + 273, /* (408) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + 325, /* (409) query_expression_body ::= query_primary */ + 325, /* (410) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + 329, /* (411) query_primary ::= query_specification */ + 326, /* (412) order_by_clause_opt ::= */ + 326, /* (413) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 327, /* (414) slimit_clause_opt ::= */ + 327, /* (415) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + 327, /* (416) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + 327, /* (417) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 328, /* (418) limit_clause_opt ::= */ + 328, /* (419) limit_clause_opt ::= LIMIT NK_INTEGER */ + 328, /* (420) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + 328, /* (421) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 290, /* (422) subquery ::= NK_LP query_expression NK_RP */ + 311, /* (423) search_condition ::= common_expression */ + 330, /* (424) sort_specification_list ::= sort_specification */ + 330, /* (425) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + 331, /* (426) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + 332, /* (427) ordering_specification_opt ::= */ + 332, /* (428) ordering_specification_opt ::= ASC */ + 332, /* (429) ordering_specification_opt ::= DESC */ + 333, /* (430) null_ordering_opt ::= */ + 333, /* (431) null_ordering_opt ::= NULLS FIRST */ + 333, /* (432) null_ordering_opt ::= NULLS LAST */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -2675,264 +2806,284 @@ static const signed char yyRuleInfoNRhs[] = { 0, /* (152) table_options ::= */ -3, /* (153) table_options ::= table_options COMMENT NK_STRING */ -3, /* (154) table_options ::= table_options KEEP integer_list */ - -3, /* (155) table_options ::= table_options TTL NK_INTEGER */ - -5, /* (156) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - -5, /* (157) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ - -3, /* (158) table_options ::= table_options FILE_FACTOR NK_FLOAT */ - -3, /* (159) table_options ::= table_options DELAY NK_INTEGER */ - -1, /* (160) alter_table_options ::= alter_table_option */ - -2, /* (161) alter_table_options ::= alter_table_options alter_table_option */ - -2, /* (162) alter_table_option ::= COMMENT NK_STRING */ - -2, /* (163) alter_table_option ::= KEEP integer_list */ - -2, /* (164) alter_table_option ::= TTL NK_INTEGER */ - -1, /* (165) col_name_list ::= col_name */ - -3, /* (166) col_name_list ::= col_name_list NK_COMMA col_name */ - -1, /* (167) col_name ::= column_name */ - -2, /* (168) cmd ::= SHOW DNODES */ - -2, /* (169) cmd ::= SHOW USERS */ - -2, /* (170) cmd ::= SHOW DATABASES */ - -4, /* (171) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - -4, /* (172) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - -3, /* (173) cmd ::= SHOW db_name_cond_opt VGROUPS */ - -2, /* (174) cmd ::= SHOW MNODES */ - -2, /* (175) cmd ::= SHOW MODULES */ - -2, /* (176) cmd ::= SHOW QNODES */ - -2, /* (177) cmd ::= SHOW FUNCTIONS */ - -5, /* (178) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - -2, /* (179) cmd ::= SHOW STREAMS */ - -2, /* (180) cmd ::= SHOW ACCOUNTS */ - -2, /* (181) cmd ::= SHOW APPS */ - -2, /* (182) cmd ::= SHOW CONNECTIONS */ - -2, /* (183) cmd ::= SHOW LICENCE */ - -2, /* (184) cmd ::= SHOW GRANTS */ - -4, /* (185) cmd ::= SHOW CREATE DATABASE db_name */ - -4, /* (186) cmd ::= SHOW CREATE TABLE full_table_name */ - -4, /* (187) cmd ::= SHOW CREATE STABLE full_table_name */ - -2, /* (188) cmd ::= SHOW QUERIES */ - -2, /* (189) cmd ::= SHOW SCORES */ - -2, /* (190) cmd ::= SHOW TOPICS */ - -2, /* (191) cmd ::= SHOW VARIABLES */ - -2, /* (192) cmd ::= SHOW BNODES */ - -2, /* (193) cmd ::= SHOW SNODES */ - 0, /* (194) db_name_cond_opt ::= */ - -2, /* (195) db_name_cond_opt ::= db_name NK_DOT */ - 0, /* (196) like_pattern_opt ::= */ - -2, /* (197) like_pattern_opt ::= LIKE NK_STRING */ - -1, /* (198) table_name_cond ::= table_name */ - 0, /* (199) from_db_opt ::= */ - -2, /* (200) from_db_opt ::= FROM db_name */ - -1, /* (201) func_name_list ::= func_name */ - -3, /* (202) func_name_list ::= func_name_list NK_COMMA col_name */ - -1, /* (203) func_name ::= function_name */ - -8, /* (204) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - -10, /* (205) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ - -6, /* (206) cmd ::= DROP INDEX exists_opt index_name ON table_name */ - 0, /* (207) index_options ::= */ - -9, /* (208) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - -11, /* (209) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - -1, /* (210) func_list ::= func */ - -3, /* (211) func_list ::= func_list NK_COMMA func */ - -4, /* (212) func ::= function_name NK_LP expression_list NK_RP */ - -6, /* (213) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - -6, /* (214) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ - -4, /* (215) cmd ::= DROP TOPIC exists_opt topic_name */ - -2, /* (216) cmd ::= DESC full_table_name */ - -2, /* (217) cmd ::= DESCRIBE full_table_name */ - -3, /* (218) cmd ::= RESET QUERY CACHE */ - -4, /* (219) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - 0, /* (220) analyze_opt ::= */ - -1, /* (221) analyze_opt ::= ANALYZE */ - 0, /* (222) explain_options ::= */ - -3, /* (223) explain_options ::= explain_options VERBOSE NK_BOOL */ - -3, /* (224) explain_options ::= explain_options RATIO NK_FLOAT */ - -6, /* (225) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ - -9, /* (226) cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - -3, /* (227) cmd ::= DROP FUNCTION function_name */ - 0, /* (228) agg_func_opt ::= */ - -1, /* (229) agg_func_opt ::= AGGREGATE */ - 0, /* (230) bufsize_opt ::= */ - -2, /* (231) bufsize_opt ::= BUFSIZE NK_INTEGER */ - -7, /* (232) cmd ::= CREATE STREAM stream_name INTO table_name AS query_expression */ - -3, /* (233) cmd ::= DROP STREAM stream_name */ - -3, /* (234) cmd ::= KILL CONNECTION NK_INTEGER */ - -3, /* (235) cmd ::= KILL QUERY NK_INTEGER */ - -4, /* (236) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - -4, /* (237) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - -3, /* (238) cmd ::= SPLIT VGROUP NK_INTEGER */ - -2, /* (239) dnode_list ::= DNODE NK_INTEGER */ - -3, /* (240) dnode_list ::= dnode_list DNODE NK_INTEGER */ - -3, /* (241) cmd ::= SYNCDB db_name REPLICA */ - -1, /* (242) cmd ::= query_expression */ - -1, /* (243) literal ::= NK_INTEGER */ - -1, /* (244) literal ::= NK_FLOAT */ - -1, /* (245) literal ::= NK_STRING */ - -1, /* (246) literal ::= NK_BOOL */ - -2, /* (247) literal ::= TIMESTAMP NK_STRING */ - -1, /* (248) literal ::= duration_literal */ - -1, /* (249) literal ::= NULL */ - -1, /* (250) duration_literal ::= NK_VARIABLE */ - -1, /* (251) signed ::= NK_INTEGER */ - -2, /* (252) signed ::= NK_PLUS NK_INTEGER */ - -2, /* (253) signed ::= NK_MINUS NK_INTEGER */ - -1, /* (254) signed ::= NK_FLOAT */ - -2, /* (255) signed ::= NK_PLUS NK_FLOAT */ - -2, /* (256) signed ::= NK_MINUS NK_FLOAT */ - -1, /* (257) signed_literal ::= signed */ - -1, /* (258) signed_literal ::= NK_STRING */ - -1, /* (259) signed_literal ::= NK_BOOL */ - -2, /* (260) signed_literal ::= TIMESTAMP NK_STRING */ - -1, /* (261) signed_literal ::= duration_literal */ - -1, /* (262) signed_literal ::= NULL */ - -1, /* (263) literal_list ::= signed_literal */ - -3, /* (264) literal_list ::= literal_list NK_COMMA signed_literal */ - -1, /* (265) db_name ::= NK_ID */ - -1, /* (266) table_name ::= NK_ID */ - -1, /* (267) column_name ::= NK_ID */ - -1, /* (268) function_name ::= NK_ID */ - -1, /* (269) function_name ::= FIRST */ - -1, /* (270) function_name ::= LAST */ - -1, /* (271) function_name ::= NOW */ - -1, /* (272) function_name ::= TODAY */ - -1, /* (273) function_name ::= TIMEZONE */ - -1, /* (274) table_alias ::= NK_ID */ - -1, /* (275) column_alias ::= NK_ID */ - -1, /* (276) user_name ::= NK_ID */ - -1, /* (277) index_name ::= NK_ID */ - -1, /* (278) topic_name ::= NK_ID */ - -1, /* (279) stream_name ::= NK_ID */ - -1, /* (280) expression ::= literal */ - -1, /* (281) expression ::= pseudo_column */ - -1, /* (282) expression ::= column_reference */ - -4, /* (283) expression ::= function_name NK_LP expression_list NK_RP */ - -4, /* (284) expression ::= function_name NK_LP NK_STAR NK_RP */ - -3, /* (285) expression ::= function_name NK_LP NK_RP */ - -6, /* (286) expression ::= CAST NK_LP expression AS type_name NK_RP */ - -1, /* (287) expression ::= subquery */ - -3, /* (288) expression ::= NK_LP expression NK_RP */ - -2, /* (289) expression ::= NK_PLUS expression */ - -2, /* (290) expression ::= NK_MINUS expression */ - -3, /* (291) expression ::= expression NK_PLUS expression */ - -3, /* (292) expression ::= expression NK_MINUS expression */ - -3, /* (293) expression ::= expression NK_STAR expression */ - -3, /* (294) expression ::= expression NK_SLASH expression */ - -3, /* (295) expression ::= expression NK_REM expression */ - -1, /* (296) expression_list ::= expression */ - -3, /* (297) expression_list ::= expression_list NK_COMMA expression */ - -1, /* (298) column_reference ::= column_name */ - -3, /* (299) column_reference ::= table_name NK_DOT column_name */ - -1, /* (300) pseudo_column ::= ROWTS */ - -1, /* (301) pseudo_column ::= TBNAME */ - -1, /* (302) pseudo_column ::= QSTARTTS */ - -1, /* (303) pseudo_column ::= QENDTS */ - -1, /* (304) pseudo_column ::= WSTARTTS */ - -1, /* (305) pseudo_column ::= WENDTS */ - -1, /* (306) pseudo_column ::= WDURATION */ - -3, /* (307) predicate ::= expression compare_op expression */ - -5, /* (308) predicate ::= expression BETWEEN expression AND expression */ - -6, /* (309) predicate ::= expression NOT BETWEEN expression AND expression */ - -3, /* (310) predicate ::= expression IS NULL */ - -4, /* (311) predicate ::= expression IS NOT NULL */ - -3, /* (312) predicate ::= expression in_op in_predicate_value */ - -1, /* (313) compare_op ::= NK_LT */ - -1, /* (314) compare_op ::= NK_GT */ - -1, /* (315) compare_op ::= NK_LE */ - -1, /* (316) compare_op ::= NK_GE */ - -1, /* (317) compare_op ::= NK_NE */ - -1, /* (318) compare_op ::= NK_EQ */ - -1, /* (319) compare_op ::= LIKE */ - -2, /* (320) compare_op ::= NOT LIKE */ - -1, /* (321) compare_op ::= MATCH */ - -1, /* (322) compare_op ::= NMATCH */ - -1, /* (323) in_op ::= IN */ - -2, /* (324) in_op ::= NOT IN */ - -3, /* (325) in_predicate_value ::= NK_LP expression_list NK_RP */ - -1, /* (326) boolean_value_expression ::= boolean_primary */ - -2, /* (327) boolean_value_expression ::= NOT boolean_primary */ - -3, /* (328) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - -3, /* (329) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - -1, /* (330) boolean_primary ::= predicate */ - -3, /* (331) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - -1, /* (332) common_expression ::= expression */ - -1, /* (333) common_expression ::= boolean_value_expression */ - -2, /* (334) from_clause ::= FROM table_reference_list */ - -1, /* (335) table_reference_list ::= table_reference */ - -3, /* (336) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - -1, /* (337) table_reference ::= table_primary */ - -1, /* (338) table_reference ::= joined_table */ - -2, /* (339) table_primary ::= table_name alias_opt */ - -4, /* (340) table_primary ::= db_name NK_DOT table_name alias_opt */ - -2, /* (341) table_primary ::= subquery alias_opt */ - -1, /* (342) table_primary ::= parenthesized_joined_table */ - 0, /* (343) alias_opt ::= */ - -1, /* (344) alias_opt ::= table_alias */ - -2, /* (345) alias_opt ::= AS table_alias */ - -3, /* (346) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - -3, /* (347) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - -6, /* (348) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - 0, /* (349) join_type ::= */ - -1, /* (350) join_type ::= INNER */ - -9, /* (351) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - 0, /* (352) set_quantifier_opt ::= */ - -1, /* (353) set_quantifier_opt ::= DISTINCT */ - -1, /* (354) set_quantifier_opt ::= ALL */ - -1, /* (355) select_list ::= NK_STAR */ - -1, /* (356) select_list ::= select_sublist */ - -1, /* (357) select_sublist ::= select_item */ - -3, /* (358) select_sublist ::= select_sublist NK_COMMA select_item */ - -1, /* (359) select_item ::= common_expression */ - -2, /* (360) select_item ::= common_expression column_alias */ - -3, /* (361) select_item ::= common_expression AS column_alias */ - -3, /* (362) select_item ::= table_name NK_DOT NK_STAR */ - 0, /* (363) where_clause_opt ::= */ - -2, /* (364) where_clause_opt ::= WHERE search_condition */ - 0, /* (365) partition_by_clause_opt ::= */ - -3, /* (366) partition_by_clause_opt ::= PARTITION BY expression_list */ - 0, /* (367) twindow_clause_opt ::= */ - -6, /* (368) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - -4, /* (369) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - -6, /* (370) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - -8, /* (371) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - 0, /* (372) sliding_opt ::= */ - -4, /* (373) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - 0, /* (374) fill_opt ::= */ - -4, /* (375) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - -6, /* (376) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - -1, /* (377) fill_mode ::= NONE */ - -1, /* (378) fill_mode ::= PREV */ - -1, /* (379) fill_mode ::= NULL */ - -1, /* (380) fill_mode ::= LINEAR */ - -1, /* (381) fill_mode ::= NEXT */ - 0, /* (382) group_by_clause_opt ::= */ - -3, /* (383) group_by_clause_opt ::= GROUP BY group_by_list */ - -1, /* (384) group_by_list ::= expression */ - -3, /* (385) group_by_list ::= group_by_list NK_COMMA expression */ - 0, /* (386) having_clause_opt ::= */ - -2, /* (387) having_clause_opt ::= HAVING search_condition */ - -4, /* (388) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - -1, /* (389) query_expression_body ::= query_primary */ - -4, /* (390) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - -1, /* (391) query_primary ::= query_specification */ - 0, /* (392) order_by_clause_opt ::= */ - -3, /* (393) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 0, /* (394) slimit_clause_opt ::= */ - -2, /* (395) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - -4, /* (396) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - -4, /* (397) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 0, /* (398) limit_clause_opt ::= */ - -2, /* (399) limit_clause_opt ::= LIMIT NK_INTEGER */ - -4, /* (400) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - -4, /* (401) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - -3, /* (402) subquery ::= NK_LP query_expression NK_RP */ - -1, /* (403) search_condition ::= common_expression */ - -1, /* (404) sort_specification_list ::= sort_specification */ - -3, /* (405) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - -3, /* (406) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - 0, /* (407) ordering_specification_opt ::= */ - -1, /* (408) ordering_specification_opt ::= ASC */ - -1, /* (409) ordering_specification_opt ::= DESC */ - 0, /* (410) null_ordering_opt ::= */ - -2, /* (411) null_ordering_opt ::= NULLS FIRST */ - -2, /* (412) null_ordering_opt ::= NULLS LAST */ + -3, /* (155) table_options ::= table_options KEEP variable_list */ + -3, /* (156) table_options ::= table_options TTL NK_INTEGER */ + -5, /* (157) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + -5, /* (158) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ + -3, /* (159) table_options ::= table_options FILE_FACTOR NK_FLOAT */ + -3, /* (160) table_options ::= table_options DELAY NK_INTEGER */ + -1, /* (161) alter_table_options ::= alter_table_option */ + -2, /* (162) alter_table_options ::= alter_table_options alter_table_option */ + -2, /* (163) alter_table_option ::= COMMENT NK_STRING */ + -2, /* (164) alter_table_option ::= KEEP integer_list */ + -2, /* (165) alter_table_option ::= KEEP variable_list */ + -2, /* (166) alter_table_option ::= TTL NK_INTEGER */ + -1, /* (167) col_name_list ::= col_name */ + -3, /* (168) col_name_list ::= col_name_list NK_COMMA col_name */ + -1, /* (169) col_name ::= column_name */ + -2, /* (170) cmd ::= SHOW DNODES */ + -2, /* (171) cmd ::= SHOW USERS */ + -2, /* (172) cmd ::= SHOW DATABASES */ + -4, /* (173) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + -4, /* (174) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + -3, /* (175) cmd ::= SHOW db_name_cond_opt VGROUPS */ + -2, /* (176) cmd ::= SHOW MNODES */ + -2, /* (177) cmd ::= SHOW MODULES */ + -2, /* (178) cmd ::= SHOW QNODES */ + -2, /* (179) cmd ::= SHOW FUNCTIONS */ + -5, /* (180) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + -2, /* (181) cmd ::= SHOW STREAMS */ + -2, /* (182) cmd ::= SHOW ACCOUNTS */ + -2, /* (183) cmd ::= SHOW APPS */ + -2, /* (184) cmd ::= SHOW CONNECTIONS */ + -2, /* (185) cmd ::= SHOW LICENCE */ + -2, /* (186) cmd ::= SHOW GRANTS */ + -4, /* (187) cmd ::= SHOW CREATE DATABASE db_name */ + -4, /* (188) cmd ::= SHOW CREATE TABLE full_table_name */ + -4, /* (189) cmd ::= SHOW CREATE STABLE full_table_name */ + -2, /* (190) cmd ::= SHOW QUERIES */ + -2, /* (191) cmd ::= SHOW SCORES */ + -2, /* (192) cmd ::= SHOW TOPICS */ + -2, /* (193) cmd ::= SHOW VARIABLES */ + -2, /* (194) cmd ::= SHOW BNODES */ + -2, /* (195) cmd ::= SHOW SNODES */ + 0, /* (196) db_name_cond_opt ::= */ + -2, /* (197) db_name_cond_opt ::= db_name NK_DOT */ + 0, /* (198) like_pattern_opt ::= */ + -2, /* (199) like_pattern_opt ::= LIKE NK_STRING */ + -1, /* (200) table_name_cond ::= table_name */ + 0, /* (201) from_db_opt ::= */ + -2, /* (202) from_db_opt ::= FROM db_name */ + -1, /* (203) func_name_list ::= func_name */ + -3, /* (204) func_name_list ::= func_name_list NK_COMMA col_name */ + -1, /* (205) func_name ::= function_name */ + -8, /* (206) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + -10, /* (207) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ + -6, /* (208) cmd ::= DROP INDEX exists_opt index_name ON table_name */ + 0, /* (209) index_options ::= */ + -9, /* (210) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + -11, /* (211) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + -1, /* (212) func_list ::= func */ + -3, /* (213) func_list ::= func_list NK_COMMA func */ + -4, /* (214) func ::= function_name NK_LP expression_list NK_RP */ + -6, /* (215) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + -6, /* (216) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ + -4, /* (217) cmd ::= DROP TOPIC exists_opt topic_name */ + -2, /* (218) cmd ::= DESC full_table_name */ + -2, /* (219) cmd ::= DESCRIBE full_table_name */ + -3, /* (220) cmd ::= RESET QUERY CACHE */ + -4, /* (221) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + 0, /* (222) analyze_opt ::= */ + -1, /* (223) analyze_opt ::= ANALYZE */ + 0, /* (224) explain_options ::= */ + -3, /* (225) explain_options ::= explain_options VERBOSE NK_BOOL */ + -3, /* (226) explain_options ::= explain_options RATIO NK_FLOAT */ + -6, /* (227) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ + -9, /* (228) cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + -3, /* (229) cmd ::= DROP FUNCTION function_name */ + 0, /* (230) agg_func_opt ::= */ + -1, /* (231) agg_func_opt ::= AGGREGATE */ + 0, /* (232) bufsize_opt ::= */ + -2, /* (233) bufsize_opt ::= BUFSIZE NK_INTEGER */ + -8, /* (234) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ + -4, /* (235) cmd ::= DROP STREAM exists_opt stream_name */ + 0, /* (236) into_opt ::= */ + -2, /* (237) into_opt ::= INTO full_table_name */ + 0, /* (238) stream_options ::= */ + -3, /* (239) stream_options ::= stream_options TRIGGER AT_ONCE */ + -3, /* (240) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + -3, /* (241) stream_options ::= stream_options WATERMARK duration_literal */ + -3, /* (242) cmd ::= KILL CONNECTION NK_INTEGER */ + -3, /* (243) cmd ::= KILL QUERY NK_INTEGER */ + -4, /* (244) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + -4, /* (245) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + -3, /* (246) cmd ::= SPLIT VGROUP NK_INTEGER */ + -2, /* (247) dnode_list ::= DNODE NK_INTEGER */ + -3, /* (248) dnode_list ::= dnode_list DNODE NK_INTEGER */ + -3, /* (249) cmd ::= SYNCDB db_name REPLICA */ + -1, /* (250) cmd ::= query_expression */ + -1, /* (251) literal ::= NK_INTEGER */ + -1, /* (252) literal ::= NK_FLOAT */ + -1, /* (253) literal ::= NK_STRING */ + -1, /* (254) literal ::= NK_BOOL */ + -2, /* (255) literal ::= TIMESTAMP NK_STRING */ + -1, /* (256) literal ::= duration_literal */ + -1, /* (257) literal ::= NULL */ + -1, /* (258) literal ::= NK_QUESTION */ + -1, /* (259) duration_literal ::= NK_VARIABLE */ + -1, /* (260) signed ::= NK_INTEGER */ + -2, /* (261) signed ::= NK_PLUS NK_INTEGER */ + -2, /* (262) signed ::= NK_MINUS NK_INTEGER */ + -1, /* (263) signed ::= NK_FLOAT */ + -2, /* (264) signed ::= NK_PLUS NK_FLOAT */ + -2, /* (265) signed ::= NK_MINUS NK_FLOAT */ + -1, /* (266) signed_literal ::= signed */ + -1, /* (267) signed_literal ::= NK_STRING */ + -1, /* (268) signed_literal ::= NK_BOOL */ + -2, /* (269) signed_literal ::= TIMESTAMP NK_STRING */ + -1, /* (270) signed_literal ::= duration_literal */ + -1, /* (271) signed_literal ::= NULL */ + -1, /* (272) literal_list ::= signed_literal */ + -3, /* (273) literal_list ::= literal_list NK_COMMA signed_literal */ + -1, /* (274) db_name ::= NK_ID */ + -1, /* (275) table_name ::= NK_ID */ + -1, /* (276) column_name ::= NK_ID */ + -1, /* (277) function_name ::= NK_ID */ + -1, /* (278) table_alias ::= NK_ID */ + -1, /* (279) column_alias ::= NK_ID */ + -1, /* (280) user_name ::= NK_ID */ + -1, /* (281) index_name ::= NK_ID */ + -1, /* (282) topic_name ::= NK_ID */ + -1, /* (283) stream_name ::= NK_ID */ + -1, /* (284) expression ::= literal */ + -1, /* (285) expression ::= pseudo_column */ + -1, /* (286) expression ::= column_reference */ + -1, /* (287) expression ::= function_expression */ + -1, /* (288) expression ::= subquery */ + -3, /* (289) expression ::= NK_LP expression NK_RP */ + -2, /* (290) expression ::= NK_PLUS expression */ + -2, /* (291) expression ::= NK_MINUS expression */ + -3, /* (292) expression ::= expression NK_PLUS expression */ + -3, /* (293) expression ::= expression NK_MINUS expression */ + -3, /* (294) expression ::= expression NK_STAR expression */ + -3, /* (295) expression ::= expression NK_SLASH expression */ + -3, /* (296) expression ::= expression NK_REM expression */ + -3, /* (297) expression ::= column_reference NK_ARROW NK_STRING */ + -1, /* (298) expression_list ::= expression */ + -3, /* (299) expression_list ::= expression_list NK_COMMA expression */ + -1, /* (300) column_reference ::= column_name */ + -3, /* (301) column_reference ::= table_name NK_DOT column_name */ + -1, /* (302) pseudo_column ::= ROWTS */ + -1, /* (303) pseudo_column ::= TBNAME */ + -1, /* (304) pseudo_column ::= QSTARTTS */ + -1, /* (305) pseudo_column ::= QENDTS */ + -1, /* (306) pseudo_column ::= WSTARTTS */ + -1, /* (307) pseudo_column ::= WENDTS */ + -1, /* (308) pseudo_column ::= WDURATION */ + -4, /* (309) function_expression ::= function_name NK_LP expression_list NK_RP */ + -4, /* (310) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + -6, /* (311) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ + -3, /* (312) function_expression ::= noarg_func NK_LP NK_RP */ + -1, /* (313) noarg_func ::= NOW */ + -1, /* (314) noarg_func ::= TODAY */ + -1, /* (315) noarg_func ::= TIMEZONE */ + -1, /* (316) star_func ::= COUNT */ + -1, /* (317) star_func ::= FIRST */ + -1, /* (318) star_func ::= LAST */ + -1, /* (319) star_func ::= LAST_ROW */ + -1, /* (320) star_func_para_list ::= NK_STAR */ + -1, /* (321) star_func_para_list ::= other_para_list */ + -1, /* (322) other_para_list ::= star_func_para */ + -3, /* (323) other_para_list ::= other_para_list NK_COMMA star_func_para */ + -1, /* (324) star_func_para ::= expression */ + -3, /* (325) star_func_para ::= table_name NK_DOT NK_STAR */ + -3, /* (326) predicate ::= expression compare_op expression */ + -5, /* (327) predicate ::= expression BETWEEN expression AND expression */ + -6, /* (328) predicate ::= expression NOT BETWEEN expression AND expression */ + -3, /* (329) predicate ::= expression IS NULL */ + -4, /* (330) predicate ::= expression IS NOT NULL */ + -3, /* (331) predicate ::= expression in_op in_predicate_value */ + -1, /* (332) compare_op ::= NK_LT */ + -1, /* (333) compare_op ::= NK_GT */ + -1, /* (334) compare_op ::= NK_LE */ + -1, /* (335) compare_op ::= NK_GE */ + -1, /* (336) compare_op ::= NK_NE */ + -1, /* (337) compare_op ::= NK_EQ */ + -1, /* (338) compare_op ::= LIKE */ + -2, /* (339) compare_op ::= NOT LIKE */ + -1, /* (340) compare_op ::= MATCH */ + -1, /* (341) compare_op ::= NMATCH */ + -1, /* (342) compare_op ::= CONTAINS */ + -1, /* (343) in_op ::= IN */ + -2, /* (344) in_op ::= NOT IN */ + -3, /* (345) in_predicate_value ::= NK_LP expression_list NK_RP */ + -1, /* (346) boolean_value_expression ::= boolean_primary */ + -2, /* (347) boolean_value_expression ::= NOT boolean_primary */ + -3, /* (348) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + -3, /* (349) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + -1, /* (350) boolean_primary ::= predicate */ + -3, /* (351) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + -1, /* (352) common_expression ::= expression */ + -1, /* (353) common_expression ::= boolean_value_expression */ + -2, /* (354) from_clause ::= FROM table_reference_list */ + -1, /* (355) table_reference_list ::= table_reference */ + -3, /* (356) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + -1, /* (357) table_reference ::= table_primary */ + -1, /* (358) table_reference ::= joined_table */ + -2, /* (359) table_primary ::= table_name alias_opt */ + -4, /* (360) table_primary ::= db_name NK_DOT table_name alias_opt */ + -2, /* (361) table_primary ::= subquery alias_opt */ + -1, /* (362) table_primary ::= parenthesized_joined_table */ + 0, /* (363) alias_opt ::= */ + -1, /* (364) alias_opt ::= table_alias */ + -2, /* (365) alias_opt ::= AS table_alias */ + -3, /* (366) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + -3, /* (367) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + -6, /* (368) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + 0, /* (369) join_type ::= */ + -1, /* (370) join_type ::= INNER */ + -9, /* (371) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + 0, /* (372) set_quantifier_opt ::= */ + -1, /* (373) set_quantifier_opt ::= DISTINCT */ + -1, /* (374) set_quantifier_opt ::= ALL */ + -1, /* (375) select_list ::= NK_STAR */ + -1, /* (376) select_list ::= select_sublist */ + -1, /* (377) select_sublist ::= select_item */ + -3, /* (378) select_sublist ::= select_sublist NK_COMMA select_item */ + -1, /* (379) select_item ::= common_expression */ + -2, /* (380) select_item ::= common_expression column_alias */ + -3, /* (381) select_item ::= common_expression AS column_alias */ + -3, /* (382) select_item ::= table_name NK_DOT NK_STAR */ + 0, /* (383) where_clause_opt ::= */ + -2, /* (384) where_clause_opt ::= WHERE search_condition */ + 0, /* (385) partition_by_clause_opt ::= */ + -3, /* (386) partition_by_clause_opt ::= PARTITION BY expression_list */ + 0, /* (387) twindow_clause_opt ::= */ + -6, /* (388) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + -4, /* (389) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + -6, /* (390) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + -8, /* (391) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + 0, /* (392) sliding_opt ::= */ + -4, /* (393) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + 0, /* (394) fill_opt ::= */ + -4, /* (395) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + -6, /* (396) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + -1, /* (397) fill_mode ::= NONE */ + -1, /* (398) fill_mode ::= PREV */ + -1, /* (399) fill_mode ::= NULL */ + -1, /* (400) fill_mode ::= LINEAR */ + -1, /* (401) fill_mode ::= NEXT */ + 0, /* (402) group_by_clause_opt ::= */ + -3, /* (403) group_by_clause_opt ::= GROUP BY group_by_list */ + -1, /* (404) group_by_list ::= expression */ + -3, /* (405) group_by_list ::= group_by_list NK_COMMA expression */ + 0, /* (406) having_clause_opt ::= */ + -2, /* (407) having_clause_opt ::= HAVING search_condition */ + -4, /* (408) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + -1, /* (409) query_expression_body ::= query_primary */ + -4, /* (410) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + -1, /* (411) query_primary ::= query_specification */ + 0, /* (412) order_by_clause_opt ::= */ + -3, /* (413) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 0, /* (414) slimit_clause_opt ::= */ + -2, /* (415) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + -4, /* (416) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + -4, /* (417) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 0, /* (418) limit_clause_opt ::= */ + -2, /* (419) limit_clause_opt ::= LIMIT NK_INTEGER */ + -4, /* (420) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + -4, /* (421) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + -3, /* (422) subquery ::= NK_LP query_expression NK_RP */ + -1, /* (423) search_condition ::= common_expression */ + -1, /* (424) sort_specification_list ::= sort_specification */ + -3, /* (425) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + -3, /* (426) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + 0, /* (427) ordering_specification_opt ::= */ + -1, /* (428) ordering_specification_opt ::= ASC */ + -1, /* (429) ordering_specification_opt ::= DESC */ + 0, /* (430) null_ordering_opt ::= */ + -2, /* (431) null_ordering_opt ::= NULLS FIRST */ + -2, /* (432) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3024,11 +3175,11 @@ static YYACTIONTYPE yy_reduce( YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,212,&yymsp[0].minor); + yy_destructor(yypParser,221,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,213,&yymsp[0].minor); + yy_destructor(yypParser,222,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3042,20 +3193,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,212,&yymsp[-2].minor); +{ yy_destructor(yypParser,221,&yymsp[-2].minor); { } - yy_destructor(yypParser,214,&yymsp[0].minor); + yy_destructor(yypParser,223,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,215,&yymsp[0].minor); +{ yy_destructor(yypParser,224,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,213,&yymsp[-1].minor); +{ yy_destructor(yypParser,222,&yymsp[-1].minor); { } - yy_destructor(yypParser,215,&yymsp[0].minor); + yy_destructor(yypParser,224,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3069,31 +3220,31 @@ 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,214,&yymsp[0].minor); + yy_destructor(yypParser,223,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy567, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy537, &yymsp[0].minor.yy0); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy567, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy537, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy567, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy537, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy567); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy537); } break; case 28: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy567, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy537, NULL); } break; case 29: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy567, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy537, &yymsp[0].minor.yy0); } break; case 30: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 31: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy567); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy537); } break; case 32: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3110,23 +3261,25 @@ static YYACTIONTYPE yy_reduce( case 36: /* dnode_endpoint ::= NK_STRING */ case 37: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==37); case 38: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==38); - case 265: /* db_name ::= NK_ID */ yytestcase(yyruleno==265); - case 266: /* table_name ::= NK_ID */ yytestcase(yyruleno==266); - case 267: /* column_name ::= NK_ID */ yytestcase(yyruleno==267); - case 268: /* function_name ::= NK_ID */ yytestcase(yyruleno==268); - case 269: /* function_name ::= FIRST */ yytestcase(yyruleno==269); - case 270: /* function_name ::= LAST */ yytestcase(yyruleno==270); - case 271: /* function_name ::= NOW */ yytestcase(yyruleno==271); - case 272: /* function_name ::= TODAY */ yytestcase(yyruleno==272); - case 273: /* function_name ::= TIMEZONE */ yytestcase(yyruleno==273); - case 274: /* table_alias ::= NK_ID */ yytestcase(yyruleno==274); - case 275: /* column_alias ::= NK_ID */ yytestcase(yyruleno==275); - case 276: /* user_name ::= NK_ID */ yytestcase(yyruleno==276); - case 277: /* index_name ::= NK_ID */ yytestcase(yyruleno==277); - case 278: /* topic_name ::= NK_ID */ yytestcase(yyruleno==278); - case 279: /* stream_name ::= NK_ID */ yytestcase(yyruleno==279); -{ yylhsminor.yy567 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy567 = yylhsminor.yy567; + case 274: /* db_name ::= NK_ID */ yytestcase(yyruleno==274); + case 275: /* table_name ::= NK_ID */ yytestcase(yyruleno==275); + case 276: /* column_name ::= NK_ID */ yytestcase(yyruleno==276); + case 277: /* function_name ::= NK_ID */ yytestcase(yyruleno==277); + case 278: /* table_alias ::= NK_ID */ yytestcase(yyruleno==278); + case 279: /* column_alias ::= NK_ID */ yytestcase(yyruleno==279); + case 280: /* user_name ::= NK_ID */ yytestcase(yyruleno==280); + case 281: /* index_name ::= NK_ID */ yytestcase(yyruleno==281); + case 282: /* topic_name ::= NK_ID */ yytestcase(yyruleno==282); + case 283: /* stream_name ::= NK_ID */ yytestcase(yyruleno==283); + case 313: /* noarg_func ::= NOW */ yytestcase(yyruleno==313); + case 314: /* noarg_func ::= TODAY */ yytestcase(yyruleno==314); + case 315: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==315); + case 316: /* star_func ::= COUNT */ yytestcase(yyruleno==316); + case 317: /* star_func ::= FIRST */ yytestcase(yyruleno==317); + case 318: /* star_func ::= LAST */ yytestcase(yyruleno==318); + case 319: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==319); +{ yylhsminor.yy537 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy537 = yylhsminor.yy537; break; case 39: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3159,1085 +3312,1125 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 49: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy495, &yymsp[-1].minor.yy567, yymsp[0].minor.yy286); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy649, &yymsp[-1].minor.yy537, yymsp[0].minor.yy456); } break; case 50: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy495, &yymsp[0].minor.yy567); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy649, &yymsp[0].minor.yy537); } break; case 51: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy567); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy537); } break; case 52: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy567, yymsp[0].minor.yy286); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy537, yymsp[0].minor.yy456); } break; case 53: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy495 = true; } +{ yymsp[-2].minor.yy649 = true; } break; case 54: /* not_exists_opt ::= */ case 56: /* exists_opt ::= */ yytestcase(yyruleno==56); - case 220: /* analyze_opt ::= */ yytestcase(yyruleno==220); - case 228: /* agg_func_opt ::= */ yytestcase(yyruleno==228); - case 352: /* set_quantifier_opt ::= */ yytestcase(yyruleno==352); -{ yymsp[1].minor.yy495 = false; } + case 222: /* analyze_opt ::= */ yytestcase(yyruleno==222); + case 230: /* agg_func_opt ::= */ yytestcase(yyruleno==230); + case 372: /* set_quantifier_opt ::= */ yytestcase(yyruleno==372); +{ yymsp[1].minor.yy649 = false; } break; case 55: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy495 = true; } +{ yymsp[-1].minor.yy649 = true; } break; case 57: /* db_options ::= */ -{ yymsp[1].minor.yy286 = createDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy456 = createDatabaseOptions(pCxt); } break; case 58: /* db_options ::= db_options BLOCKS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pNumOfBlocks = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pNumOfBlocks = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 59: /* db_options ::= db_options CACHE NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pCacheBlockSize = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pCacheBlockSize = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 60: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pCachelast = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pCachelast = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 61: /* db_options ::= db_options COMP NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pCompressionLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pCompressionLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 62: /* db_options ::= db_options DAYS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pDaysPerFile = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pDaysPerFile = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 63: /* db_options ::= db_options DAYS NK_VARIABLE */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pDaysPerFile = (SValueNode*)createDurationValueNode(pCxt, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pDaysPerFile = (SValueNode*)createDurationValueNode(pCxt, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 64: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pFsyncPeriod = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pFsyncPeriod = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 65: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pMaxRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pMaxRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 66: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pMinRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pMinRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 67: /* db_options ::= db_options KEEP integer_list */ case 68: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==68); -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pKeep = yymsp[0].minor.yy352; yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pKeep = yymsp[0].minor.yy632; yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 69: /* db_options ::= db_options PRECISION NK_STRING */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pPrecision = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pPrecision = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 70: /* db_options ::= db_options QUORUM NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pQuorum = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pQuorum = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 71: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pReplica = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pReplica = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 72: /* db_options ::= db_options TTL NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 73: /* db_options ::= db_options WAL NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pWalLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pWalLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 74: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pNumOfVgroups = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pNumOfVgroups = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 75: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pSingleStable = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pSingleStable = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 76: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pStreamMode = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pStreamMode = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 77: /* db_options ::= db_options RETENTIONS retention_list */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy286)->pRetentions = yymsp[0].minor.yy352; yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy456)->pRetentions = yymsp[0].minor.yy632; yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 78: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy286 = createDatabaseOptions(pCxt); yylhsminor.yy286 = setDatabaseAlterOption(pCxt, yylhsminor.yy286, &yymsp[0].minor.yy583); } - yymsp[0].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createDatabaseOptions(pCxt); yylhsminor.yy456 = setDatabaseAlterOption(pCxt, yylhsminor.yy456, &yymsp[0].minor.yy29); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 79: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy286 = setDatabaseAlterOption(pCxt, yymsp[-1].minor.yy286, &yymsp[0].minor.yy583); } - yymsp[-1].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = setDatabaseAlterOption(pCxt, yymsp[-1].minor.yy456, &yymsp[0].minor.yy29); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; case 80: /* alter_db_option ::= BLOCKS NK_INTEGER */ -{ yymsp[-1].minor.yy583.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy583.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy29.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy29.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 81: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy583.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy583.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy29.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy29.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 82: /* alter_db_option ::= KEEP integer_list */ case 83: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==83); -{ yymsp[-1].minor.yy583.type = DB_OPTION_KEEP; yymsp[-1].minor.yy583.pList = yymsp[0].minor.yy352; } +{ yymsp[-1].minor.yy29.type = DB_OPTION_KEEP; yymsp[-1].minor.yy29.pList = yymsp[0].minor.yy632; } break; case 84: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy583.type = DB_OPTION_WAL; yymsp[-1].minor.yy583.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy29.type = DB_OPTION_WAL; yymsp[-1].minor.yy29.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 85: /* alter_db_option ::= QUORUM NK_INTEGER */ -{ yymsp[-1].minor.yy583.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy583.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy29.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy29.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 86: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy583.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy583.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy29.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy29.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 87: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy583.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy583.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy29.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy29.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 88: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy352 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy352 = yylhsminor.yy352; +{ yylhsminor.yy632 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 89: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 240: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==240); -{ yylhsminor.yy352 = addNodeToList(pCxt, yymsp[-2].minor.yy352, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy352 = yylhsminor.yy352; + case 248: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==248); +{ yylhsminor.yy632 = addNodeToList(pCxt, yymsp[-2].minor.yy632, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 90: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy352 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy352 = yylhsminor.yy352; +{ yylhsminor.yy632 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 91: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy352 = addNodeToList(pCxt, yymsp[-2].minor.yy352, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy352 = yylhsminor.yy352; +{ yylhsminor.yy632 = addNodeToList(pCxt, yymsp[-2].minor.yy632, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 92: /* retention_list ::= retention */ case 112: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==112); case 115: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==115); case 122: /* column_def_list ::= column_def */ yytestcase(yyruleno==122); - case 165: /* col_name_list ::= col_name */ yytestcase(yyruleno==165); - case 201: /* func_name_list ::= func_name */ yytestcase(yyruleno==201); - case 210: /* func_list ::= func */ yytestcase(yyruleno==210); - case 263: /* literal_list ::= signed_literal */ yytestcase(yyruleno==263); - case 357: /* select_sublist ::= select_item */ yytestcase(yyruleno==357); - case 404: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==404); -{ yylhsminor.yy352 = createNodeList(pCxt, yymsp[0].minor.yy286); } - yymsp[0].minor.yy352 = yylhsminor.yy352; + case 167: /* col_name_list ::= col_name */ yytestcase(yyruleno==167); + case 203: /* func_name_list ::= func_name */ yytestcase(yyruleno==203); + case 212: /* func_list ::= func */ yytestcase(yyruleno==212); + case 272: /* literal_list ::= signed_literal */ yytestcase(yyruleno==272); + case 322: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==322); + case 377: /* select_sublist ::= select_item */ yytestcase(yyruleno==377); + case 424: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==424); +{ yylhsminor.yy632 = createNodeList(pCxt, yymsp[0].minor.yy456); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 93: /* retention_list ::= retention_list NK_COMMA retention */ case 123: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==123); - case 166: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==166); - case 202: /* func_name_list ::= func_name_list NK_COMMA col_name */ yytestcase(yyruleno==202); - case 211: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==211); - case 264: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==264); - case 358: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==358); - case 405: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==405); -{ yylhsminor.yy352 = addNodeToList(pCxt, yymsp[-2].minor.yy352, yymsp[0].minor.yy286); } - yymsp[-2].minor.yy352 = yylhsminor.yy352; + case 168: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==168); + case 204: /* func_name_list ::= func_name_list NK_COMMA col_name */ yytestcase(yyruleno==204); + case 213: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==213); + case 273: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==273); + case 323: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==323); + case 378: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==378); + case 425: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==425); +{ yylhsminor.yy632 = addNodeToList(pCxt, yymsp[-2].minor.yy632, yymsp[0].minor.yy456); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 94: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy286 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 95: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 97: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==97); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy495, yymsp[-5].minor.yy286, yymsp[-3].minor.yy352, yymsp[-1].minor.yy352, yymsp[0].minor.yy286); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy649, yymsp[-5].minor.yy456, yymsp[-3].minor.yy632, yymsp[-1].minor.yy632, yymsp[0].minor.yy456); } break; case 96: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy352); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy632); } break; case 98: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy352); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy632); } break; case 99: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy495, yymsp[0].minor.yy286); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy649, yymsp[0].minor.yy456); } break; case 100: /* cmd ::= ALTER TABLE alter_table_clause */ case 101: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==101); - case 242: /* cmd ::= query_expression */ yytestcase(yyruleno==242); -{ pCxt->pRootNode = yymsp[0].minor.yy286; } + case 250: /* cmd ::= query_expression */ yytestcase(yyruleno==250); +{ pCxt->pRootNode = yymsp[0].minor.yy456; } break; case 102: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy286 = createAlterTableOption(pCxt, yymsp[-1].minor.yy286, yymsp[0].minor.yy286); } - yymsp[-1].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createAlterTableOption(pCxt, yymsp[-1].minor.yy456, yymsp[0].minor.yy456); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; case 103: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy286 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy286, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy567, yymsp[0].minor.yy274); } - yymsp[-4].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy456, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy537, yymsp[0].minor.yy388); } + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; case 104: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy286 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy286, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy567); } - yymsp[-3].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy456, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy537); } + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; case 105: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy286 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy286, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy567, yymsp[0].minor.yy274); } - yymsp[-4].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy456, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy537, yymsp[0].minor.yy388); } + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; case 106: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy286 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy286, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy567, &yymsp[0].minor.yy567); } - yymsp[-4].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy456, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy537, &yymsp[0].minor.yy537); } + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; case 107: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy286 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy286, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy567, yymsp[0].minor.yy274); } - yymsp[-4].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy456, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy537, yymsp[0].minor.yy388); } + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; case 108: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy286 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy286, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy567); } - yymsp[-3].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy456, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy537); } + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; case 109: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy286 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy286, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy567, yymsp[0].minor.yy274); } - yymsp[-4].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy456, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy537, yymsp[0].minor.yy388); } + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; case 110: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy286 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy286, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy567, &yymsp[0].minor.yy567); } - yymsp[-4].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy456, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy537, &yymsp[0].minor.yy537); } + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; case 111: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ -{ yylhsminor.yy286 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy286, &yymsp[-2].minor.yy567, yymsp[0].minor.yy286); } - yymsp[-5].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy456, &yymsp[-2].minor.yy537, yymsp[0].minor.yy456); } + yymsp[-5].minor.yy456 = yylhsminor.yy456; break; case 113: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 116: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==116); -{ yylhsminor.yy352 = addNodeToList(pCxt, yymsp[-1].minor.yy352, yymsp[0].minor.yy286); } - yymsp[-1].minor.yy352 = yylhsminor.yy352; +{ yylhsminor.yy632 = addNodeToList(pCxt, yymsp[-1].minor.yy632, yymsp[0].minor.yy456); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; case 114: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ -{ yylhsminor.yy286 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy495, yymsp[-7].minor.yy286, yymsp[-5].minor.yy286, yymsp[-4].minor.yy352, yymsp[-1].minor.yy352); } - yymsp[-8].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy649, yymsp[-7].minor.yy456, yymsp[-5].minor.yy456, yymsp[-4].minor.yy632, yymsp[-1].minor.yy632); } + yymsp[-8].minor.yy456 = yylhsminor.yy456; break; case 117: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy286 = createDropTableClause(pCxt, yymsp[-1].minor.yy495, yymsp[0].minor.yy286); } - yymsp[-1].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createDropTableClause(pCxt, yymsp[-1].minor.yy649, yymsp[0].minor.yy456); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; case 118: /* specific_tags_opt ::= */ case 149: /* tags_def_opt ::= */ yytestcase(yyruleno==149); - case 365: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==365); - case 382: /* group_by_clause_opt ::= */ yytestcase(yyruleno==382); - case 392: /* order_by_clause_opt ::= */ yytestcase(yyruleno==392); -{ yymsp[1].minor.yy352 = NULL; } + case 385: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==385); + case 402: /* group_by_clause_opt ::= */ yytestcase(yyruleno==402); + case 412: /* order_by_clause_opt ::= */ yytestcase(yyruleno==412); +{ yymsp[1].minor.yy632 = NULL; } break; case 119: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy352 = yymsp[-1].minor.yy352; } +{ yymsp[-2].minor.yy632 = yymsp[-1].minor.yy632; } break; case 120: /* full_table_name ::= table_name */ -{ yylhsminor.yy286 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy567, NULL); } - yymsp[0].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy537, NULL); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; case 121: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy286 = createRealTableNode(pCxt, &yymsp[-2].minor.yy567, &yymsp[0].minor.yy567, NULL); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createRealTableNode(pCxt, &yymsp[-2].minor.yy537, &yymsp[0].minor.yy537, NULL); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 124: /* column_def ::= column_name type_name */ -{ yylhsminor.yy286 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy567, yymsp[0].minor.yy274, NULL); } - yymsp[-1].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy537, yymsp[0].minor.yy388, NULL); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; case 125: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy286 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy567, yymsp[-2].minor.yy274, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy286 = yylhsminor.yy286; +{ yylhsminor.yy456 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy537, yymsp[-2].minor.yy388, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; case 126: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy274 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 127: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy274 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 128: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy274 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 129: /* type_name ::= INT */ case 130: /* type_name ::= INTEGER */ yytestcase(yyruleno==130); -{ yymsp[0].minor.yy274 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_INT); } break; case 131: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy274 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 132: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy274 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 133: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy274 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 134: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy274 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy388 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 135: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy274 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 136: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy274 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy388 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 137: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy274 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy388 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 138: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy274 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy388 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 139: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy274 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy388 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 140: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy274 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy388 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 141: /* type_name ::= JSON */ -{ yymsp[0].minor.yy274 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 142: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy274 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy388 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 143: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy274 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 144: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy274 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 145: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy274 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy388 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 146: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy274 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy388 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 147: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy274 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy388 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 148: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy274 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy388 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 150: /* tags_def_opt ::= tags_def */ - case 356: /* select_list ::= select_sublist */ yytestcase(yyruleno==356); -{ yylhsminor.yy352 = yymsp[0].minor.yy352; } - yymsp[0].minor.yy352 = yylhsminor.yy352; + case 321: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==321); + case 376: /* select_list ::= select_sublist */ yytestcase(yyruleno==376); +{ yylhsminor.yy632 = yymsp[0].minor.yy632; } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 151: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy352 = yymsp[-1].minor.yy352; } +{ yymsp[-3].minor.yy632 = yymsp[-1].minor.yy632; } break; case 152: /* table_options ::= */ -{ yymsp[1].minor.yy286 = createTableOptions(pCxt); } +{ yymsp[1].minor.yy456 = createTableOptions(pCxt); } break; case 153: /* table_options ::= table_options COMMENT NK_STRING */ -{ ((STableOptions*)yymsp[-2].minor.yy286)->pComments = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; +{ ((STableOptions*)yymsp[-2].minor.yy456)->pComments = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; case 154: /* table_options ::= table_options KEEP integer_list */ -{ ((STableOptions*)yymsp[-2].minor.yy286)->pKeep = yymsp[0].minor.yy352; yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + case 155: /* table_options ::= table_options KEEP variable_list */ yytestcase(yyruleno==155); +{ ((STableOptions*)yymsp[-2].minor.yy456)->pKeep = yymsp[0].minor.yy632; yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 155: /* table_options ::= table_options TTL NK_INTEGER */ -{ ((STableOptions*)yymsp[-2].minor.yy286)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + case 156: /* table_options ::= table_options TTL NK_INTEGER */ +{ ((STableOptions*)yymsp[-2].minor.yy456)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 156: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ ((STableOptions*)yymsp[-4].minor.yy286)->pSma = yymsp[-1].minor.yy352; yylhsminor.yy286 = yymsp[-4].minor.yy286; } - yymsp[-4].minor.yy286 = yylhsminor.yy286; + case 157: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ ((STableOptions*)yymsp[-4].minor.yy456)->pSma = yymsp[-1].minor.yy632; yylhsminor.yy456 = yymsp[-4].minor.yy456; } + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; - case 157: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ -{ ((STableOptions*)yymsp[-4].minor.yy286)->pFuncs = yymsp[-1].minor.yy352; yylhsminor.yy286 = yymsp[-4].minor.yy286; } - yymsp[-4].minor.yy286 = yylhsminor.yy286; + case 158: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ +{ ((STableOptions*)yymsp[-4].minor.yy456)->pFuncs = yymsp[-1].minor.yy632; yylhsminor.yy456 = yymsp[-4].minor.yy456; } + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; - case 158: /* table_options ::= table_options FILE_FACTOR NK_FLOAT */ -{ ((STableOptions*)yymsp[-2].minor.yy286)->pFilesFactor = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + case 159: /* table_options ::= table_options FILE_FACTOR NK_FLOAT */ +{ ((STableOptions*)yymsp[-2].minor.yy456)->pFilesFactor = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 159: /* table_options ::= table_options DELAY NK_INTEGER */ -{ ((STableOptions*)yymsp[-2].minor.yy286)->pDelay = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy286 = yymsp[-2].minor.yy286; } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + case 160: /* table_options ::= table_options DELAY NK_INTEGER */ +{ ((STableOptions*)yymsp[-2].minor.yy456)->pDelay = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 160: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy286 = createTableOptions(pCxt); yylhsminor.yy286 = setTableAlterOption(pCxt, yylhsminor.yy286, &yymsp[0].minor.yy583); } - yymsp[0].minor.yy286 = yylhsminor.yy286; + case 161: /* alter_table_options ::= alter_table_option */ +{ yylhsminor.yy456 = createTableOptions(pCxt); yylhsminor.yy456 = setTableAlterOption(pCxt, yylhsminor.yy456, &yymsp[0].minor.yy29); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 161: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy286 = setTableAlterOption(pCxt, yymsp[-1].minor.yy286, &yymsp[0].minor.yy583); } - yymsp[-1].minor.yy286 = yylhsminor.yy286; + case 162: /* alter_table_options ::= alter_table_options alter_table_option */ +{ yylhsminor.yy456 = setTableAlterOption(pCxt, yymsp[-1].minor.yy456, &yymsp[0].minor.yy29); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; - case 162: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy583.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy583.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 163: /* alter_table_option ::= COMMENT NK_STRING */ +{ yymsp[-1].minor.yy29.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy29.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 163: /* alter_table_option ::= KEEP integer_list */ -{ yymsp[-1].minor.yy583.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy583.pList = yymsp[0].minor.yy352; } + case 164: /* alter_table_option ::= KEEP integer_list */ + case 165: /* alter_table_option ::= KEEP variable_list */ yytestcase(yyruleno==165); +{ yymsp[-1].minor.yy29.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy29.pList = yymsp[0].minor.yy632; } break; - case 164: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy583.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy583.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + case 166: /* alter_table_option ::= TTL NK_INTEGER */ +{ yymsp[-1].minor.yy29.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy29.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; - case 167: /* col_name ::= column_name */ -{ yylhsminor.yy286 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy567); } - yymsp[0].minor.yy286 = yylhsminor.yy286; + case 169: /* col_name ::= column_name */ +{ yylhsminor.yy456 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy537); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 168: /* cmd ::= SHOW DNODES */ + case 170: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL, NULL); } break; - case 169: /* cmd ::= SHOW USERS */ + case 171: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL, NULL); } break; - case 170: /* cmd ::= SHOW DATABASES */ + case 172: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL, NULL); } break; - case 171: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy286, yymsp[0].minor.yy286); } + case 173: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy456, yymsp[0].minor.yy456); } break; - case 172: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy286, yymsp[0].minor.yy286); } + case 174: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy456, yymsp[0].minor.yy456); } break; - case 173: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy286, NULL); } + case 175: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy456, NULL); } break; - case 174: /* cmd ::= SHOW MNODES */ + case 176: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL, NULL); } break; - case 175: /* cmd ::= SHOW MODULES */ + case 177: /* cmd ::= SHOW MODULES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT, NULL, NULL); } break; - case 176: /* cmd ::= SHOW QNODES */ + case 178: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL, NULL); } break; - case 177: /* cmd ::= SHOW FUNCTIONS */ + case 179: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT, NULL, NULL); } break; - case 178: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy286, yymsp[0].minor.yy286); } + case 180: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy456, yymsp[0].minor.yy456); } break; - case 179: /* cmd ::= SHOW STREAMS */ + case 181: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); } break; - case 180: /* cmd ::= SHOW ACCOUNTS */ + case 182: /* cmd ::= SHOW ACCOUNTS */ { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } break; - case 181: /* cmd ::= SHOW APPS */ -//{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT, NULL, NULL); } + case 183: /* cmd ::= SHOW APPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT, NULL, NULL); } break; - case 182: /* cmd ::= SHOW CONNECTIONS */ + case 184: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT, NULL, NULL); } break; - case 183: /* cmd ::= SHOW LICENCE */ - case 184: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==184); + case 185: /* cmd ::= SHOW LICENCE */ + case 186: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==186); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT, NULL, NULL); } break; - case 185: /* cmd ::= SHOW CREATE DATABASE db_name */ -//{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy567); } + case 187: /* cmd ::= SHOW CREATE DATABASE db_name */ +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy537); } break; - case 186: /* cmd ::= SHOW CREATE TABLE full_table_name */ -//{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy286); } + case 188: /* cmd ::= SHOW CREATE TABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy456); } break; - case 187: /* cmd ::= SHOW CREATE STABLE full_table_name */ -//{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy286); } + case 189: /* cmd ::= SHOW CREATE STABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy456); } break; - case 188: /* cmd ::= SHOW QUERIES */ + case 190: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT, NULL, NULL); } break; - case 189: /* cmd ::= SHOW SCORES */ -//{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT, NULL, NULL); } + case 191: /* cmd ::= SHOW SCORES */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT, NULL, NULL); } break; - case 190: /* cmd ::= SHOW TOPICS */ + case 192: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT, NULL, NULL); } break; - case 191: /* cmd ::= SHOW VARIABLES */ -//{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLE_STMT, NULL, NULL); } + case 193: /* cmd ::= SHOW VARIABLES */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLE_STMT, NULL, NULL); } break; - case 192: /* cmd ::= SHOW BNODES */ + case 194: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT, NULL, NULL); } break; - case 193: /* cmd ::= SHOW SNODES */ + case 195: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT, NULL, NULL); } break; - case 194: /* db_name_cond_opt ::= */ - case 199: /* from_db_opt ::= */ yytestcase(yyruleno==199); -{ yymsp[1].minor.yy286 = createDefaultDatabaseCondValue(pCxt); } + case 196: /* db_name_cond_opt ::= */ + case 201: /* from_db_opt ::= */ yytestcase(yyruleno==201); +{ yymsp[1].minor.yy456 = createDefaultDatabaseCondValue(pCxt); } break; - case 195: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy286 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy567); } - yymsp[-1].minor.yy286 = yylhsminor.yy286; + case 197: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy537); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; - case 196: /* like_pattern_opt ::= */ - case 207: /* index_options ::= */ yytestcase(yyruleno==207); - case 363: /* where_clause_opt ::= */ yytestcase(yyruleno==363); - case 367: /* twindow_clause_opt ::= */ yytestcase(yyruleno==367); - case 372: /* sliding_opt ::= */ yytestcase(yyruleno==372); - case 374: /* fill_opt ::= */ yytestcase(yyruleno==374); - case 386: /* having_clause_opt ::= */ yytestcase(yyruleno==386); - case 394: /* slimit_clause_opt ::= */ yytestcase(yyruleno==394); - case 398: /* limit_clause_opt ::= */ yytestcase(yyruleno==398); -{ yymsp[1].minor.yy286 = NULL; } + case 198: /* like_pattern_opt ::= */ + case 209: /* index_options ::= */ yytestcase(yyruleno==209); + case 236: /* into_opt ::= */ yytestcase(yyruleno==236); + case 383: /* where_clause_opt ::= */ yytestcase(yyruleno==383); + case 387: /* twindow_clause_opt ::= */ yytestcase(yyruleno==387); + case 392: /* sliding_opt ::= */ yytestcase(yyruleno==392); + case 394: /* fill_opt ::= */ yytestcase(yyruleno==394); + case 406: /* having_clause_opt ::= */ yytestcase(yyruleno==406); + case 414: /* slimit_clause_opt ::= */ yytestcase(yyruleno==414); + case 418: /* limit_clause_opt ::= */ yytestcase(yyruleno==418); +{ yymsp[1].minor.yy456 = NULL; } break; - case 197: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy286 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 199: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 198: /* table_name_cond ::= table_name */ -{ yylhsminor.yy286 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy567); } - yymsp[0].minor.yy286 = yylhsminor.yy286; + case 200: /* table_name_cond ::= table_name */ +{ yylhsminor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy537); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 200: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy286 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy567); } + case 202: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy537); } break; - case 203: /* func_name ::= function_name */ -{ yylhsminor.yy286 = createFunctionNode(pCxt, &yymsp[0].minor.yy567, NULL); } - yymsp[0].minor.yy286 = yylhsminor.yy286; + case 205: /* func_name ::= function_name */ +{ yylhsminor.yy456 = createFunctionNode(pCxt, &yymsp[0].minor.yy537, NULL); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 204: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy495, &yymsp[-3].minor.yy567, &yymsp[-1].minor.yy567, NULL, yymsp[0].minor.yy286); } + case 206: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy649, &yymsp[-3].minor.yy537, &yymsp[-1].minor.yy537, NULL, yymsp[0].minor.yy456); } break; - case 205: /* cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy495, &yymsp[-5].minor.yy567, &yymsp[-3].minor.yy567, yymsp[-1].minor.yy352, NULL); } + case 207: /* cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy649, &yymsp[-5].minor.yy537, &yymsp[-3].minor.yy537, yymsp[-1].minor.yy632, NULL); } break; - case 206: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy495, &yymsp[-2].minor.yy567, &yymsp[0].minor.yy567); } + case 208: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy649, &yymsp[-2].minor.yy537, &yymsp[0].minor.yy537); } break; - case 208: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy286 = createIndexOption(pCxt, yymsp[-6].minor.yy352, releaseRawExprNode(pCxt, yymsp[-2].minor.yy286), NULL, yymsp[0].minor.yy286); } + case 210: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ +{ yymsp[-8].minor.yy456 = createIndexOption(pCxt, yymsp[-6].minor.yy632, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), NULL, yymsp[0].minor.yy456); } break; - case 209: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ -{ yymsp[-10].minor.yy286 = createIndexOption(pCxt, yymsp[-8].minor.yy352, releaseRawExprNode(pCxt, yymsp[-4].minor.yy286), releaseRawExprNode(pCxt, yymsp[-2].minor.yy286), yymsp[0].minor.yy286); } + case 211: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ +{ yymsp[-10].minor.yy456 = createIndexOption(pCxt, yymsp[-8].minor.yy632, releaseRawExprNode(pCxt, yymsp[-4].minor.yy456), releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), yymsp[0].minor.yy456); } break; - case 212: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy286 = createFunctionNode(pCxt, &yymsp[-3].minor.yy567, yymsp[-1].minor.yy352); } - yymsp[-3].minor.yy286 = yylhsminor.yy286; + case 214: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy456 = createFunctionNode(pCxt, &yymsp[-3].minor.yy537, yymsp[-1].minor.yy632); } + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; - case 213: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy495, &yymsp[-2].minor.yy567, yymsp[0].minor.yy286, NULL); } + case 215: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy649, &yymsp[-2].minor.yy537, yymsp[0].minor.yy456, NULL); } break; - case 214: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy495, &yymsp[-2].minor.yy567, NULL, &yymsp[0].minor.yy567); } + case 216: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy649, &yymsp[-2].minor.yy537, NULL, &yymsp[0].minor.yy537); } break; - case 215: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy495, &yymsp[0].minor.yy567); } + case 217: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy649, &yymsp[0].minor.yy537); } break; - case 216: /* cmd ::= DESC full_table_name */ - case 217: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==217); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy286); } + case 218: /* cmd ::= DESC full_table_name */ + case 219: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==219); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy456); } break; - case 218: /* cmd ::= RESET QUERY CACHE */ + case 220: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 219: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy495, yymsp[-1].minor.yy286, yymsp[0].minor.yy286); } + case 221: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy649, yymsp[-1].minor.yy456, yymsp[0].minor.yy456); } break; - case 221: /* analyze_opt ::= ANALYZE */ - case 229: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==229); - case 353: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==353); -{ yymsp[0].minor.yy495 = true; } + case 223: /* analyze_opt ::= ANALYZE */ + case 231: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==231); + case 373: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==373); +{ yymsp[0].minor.yy649 = true; } break; - case 222: /* explain_options ::= */ -{ yymsp[1].minor.yy286 = createDefaultExplainOptions(pCxt); } + case 224: /* explain_options ::= */ +{ yymsp[1].minor.yy456 = createDefaultExplainOptions(pCxt); } break; - case 223: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy286 = setExplainVerbose(pCxt, yymsp[-2].minor.yy286, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + case 225: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy456 = setExplainVerbose(pCxt, yymsp[-2].minor.yy456, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 224: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy286 = setExplainRatio(pCxt, yymsp[-2].minor.yy286, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + case 226: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy456 = setExplainRatio(pCxt, yymsp[-2].minor.yy456, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 225: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ -{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy352); } + case 227: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ +{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy632); } break; - case 226: /* cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy495, &yymsp[-5].minor.yy567, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy274, yymsp[0].minor.yy634); } + case 228: /* cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy649, &yymsp[-5].minor.yy537, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy388, yymsp[0].minor.yy652); } break; - case 227: /* cmd ::= DROP FUNCTION function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, &yymsp[0].minor.yy567); } + case 229: /* cmd ::= DROP FUNCTION function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, &yymsp[0].minor.yy537); } break; - case 230: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy634 = 0; } + case 232: /* bufsize_opt ::= */ +{ yymsp[1].minor.yy652 = 0; } break; - case 231: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy634 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + case 233: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ +{ yymsp[-1].minor.yy652 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 232: /* cmd ::= CREATE STREAM stream_name INTO table_name AS query_expression */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, &yymsp[-4].minor.yy567, &yymsp[-2].minor.yy567, yymsp[0].minor.yy286); } + case 234: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy649, &yymsp[-4].minor.yy537, yymsp[-3].minor.yy456, yymsp[-2].minor.yy456, yymsp[0].minor.yy456); } break; - case 233: /* cmd ::= DROP STREAM stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, &yymsp[0].minor.yy567); } + case 235: /* cmd ::= DROP STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy649, &yymsp[0].minor.yy537); } break; - case 234: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 237: /* into_opt ::= INTO full_table_name */ + case 354: /* from_clause ::= FROM table_reference_list */ yytestcase(yyruleno==354); + case 384: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==384); + case 407: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==407); +{ yymsp[-1].minor.yy456 = yymsp[0].minor.yy456; } + break; + case 238: /* stream_options ::= */ +{ yymsp[1].minor.yy456 = createStreamOptions(pCxt); } + break; + case 239: /* stream_options ::= stream_options TRIGGER AT_ONCE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy456)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; + break; + case 240: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy456)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; + break; + case 241: /* stream_options ::= stream_options WATERMARK duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy456)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy456); yylhsminor.yy456 = yymsp[-2].minor.yy456; } + yymsp[-2].minor.yy456 = yylhsminor.yy456; + break; + case 242: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 235: /* cmd ::= KILL QUERY NK_INTEGER */ + case 243: /* cmd ::= KILL QUERY NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_QUERY_STMT, &yymsp[0].minor.yy0); } break; - case 236: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 244: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 237: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy352); } + case 245: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy632); } break; - case 238: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 246: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 239: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy352 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 247: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy632 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 241: /* cmd ::= SYNCDB db_name REPLICA */ -{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy567); } + case 249: /* cmd ::= SYNCDB db_name REPLICA */ +{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy537); } break; - case 243: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy286 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy286 = yylhsminor.yy286; + case 251: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 244: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy286 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy286 = yylhsminor.yy286; + case 252: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 245: /* literal ::= NK_STRING */ -{ yylhsminor.yy286 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy286 = yylhsminor.yy286; + case 253: /* literal ::= NK_STRING */ +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 246: /* literal ::= NK_BOOL */ -{ yylhsminor.yy286 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy286 = yylhsminor.yy286; + case 254: /* literal ::= NK_BOOL */ +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 247: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy286 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy286 = yylhsminor.yy286; + case 255: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; - case 248: /* literal ::= duration_literal */ - case 257: /* signed_literal ::= signed */ yytestcase(yyruleno==257); - case 280: /* expression ::= literal */ yytestcase(yyruleno==280); - case 281: /* expression ::= pseudo_column */ yytestcase(yyruleno==281); - case 282: /* expression ::= column_reference */ yytestcase(yyruleno==282); - case 287: /* expression ::= subquery */ yytestcase(yyruleno==287); - case 326: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==326); - case 330: /* boolean_primary ::= predicate */ yytestcase(yyruleno==330); - case 332: /* common_expression ::= expression */ yytestcase(yyruleno==332); - case 333: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==333); - case 335: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==335); - case 337: /* table_reference ::= table_primary */ yytestcase(yyruleno==337); - case 338: /* table_reference ::= joined_table */ yytestcase(yyruleno==338); - case 342: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==342); - case 389: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==389); - case 391: /* query_primary ::= query_specification */ yytestcase(yyruleno==391); -{ yylhsminor.yy286 = yymsp[0].minor.yy286; } - yymsp[0].minor.yy286 = yylhsminor.yy286; + case 256: /* literal ::= duration_literal */ + case 266: /* signed_literal ::= signed */ yytestcase(yyruleno==266); + case 284: /* expression ::= literal */ yytestcase(yyruleno==284); + case 285: /* expression ::= pseudo_column */ yytestcase(yyruleno==285); + case 286: /* expression ::= column_reference */ yytestcase(yyruleno==286); + case 287: /* expression ::= function_expression */ yytestcase(yyruleno==287); + case 288: /* expression ::= subquery */ yytestcase(yyruleno==288); + case 346: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==346); + case 350: /* boolean_primary ::= predicate */ yytestcase(yyruleno==350); + case 352: /* common_expression ::= expression */ yytestcase(yyruleno==352); + case 353: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==353); + case 355: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==355); + case 357: /* table_reference ::= table_primary */ yytestcase(yyruleno==357); + case 358: /* table_reference ::= joined_table */ yytestcase(yyruleno==358); + case 362: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==362); + case 409: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==409); + case 411: /* query_primary ::= query_specification */ yytestcase(yyruleno==411); +{ yylhsminor.yy456 = yymsp[0].minor.yy456; } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 249: /* literal ::= NULL */ -{ yylhsminor.yy286 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL)); } - yymsp[0].minor.yy286 = yylhsminor.yy286; + case 257: /* literal ::= NULL */ +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 250: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy286 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy286 = yylhsminor.yy286; + case 258: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 251: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy286 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy286 = yylhsminor.yy286; + case 259: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 252: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy286 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + case 260: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 253: /* signed ::= NK_MINUS NK_INTEGER */ + case 261: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + break; + case 262: /* 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.yy286 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy286 = yylhsminor.yy286; + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; - case 254: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy286 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy286 = yylhsminor.yy286; + case 263: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 255: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy286 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 264: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 256: /* signed ::= NK_MINUS NK_FLOAT */ + case 265: /* 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.yy286 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy286 = yylhsminor.yy286; + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; - case 258: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy286 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy286 = yylhsminor.yy286; + case 267: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 259: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy286 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy286 = yylhsminor.yy286; + case 268: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 260: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy286 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 269: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 261: /* signed_literal ::= duration_literal */ - case 359: /* select_item ::= common_expression */ yytestcase(yyruleno==359); - case 403: /* search_condition ::= common_expression */ yytestcase(yyruleno==403); -{ yylhsminor.yy286 = releaseRawExprNode(pCxt, yymsp[0].minor.yy286); } - yymsp[0].minor.yy286 = yylhsminor.yy286; + case 270: /* signed_literal ::= duration_literal */ + case 324: /* star_func_para ::= expression */ yytestcase(yyruleno==324); + case 379: /* select_item ::= common_expression */ yytestcase(yyruleno==379); + case 423: /* search_condition ::= common_expression */ yytestcase(yyruleno==423); +{ yylhsminor.yy456 = releaseRawExprNode(pCxt, yymsp[0].minor.yy456); } + yymsp[0].minor.yy456 = yylhsminor.yy456; break; - case 262: /* signed_literal ::= NULL */ -{ yymsp[0].minor.yy286 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL); } + case 271: /* signed_literal ::= NULL */ +{ yymsp[0].minor.yy456 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL); } break; - case 283: /* expression ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy286 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy567, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy567, yymsp[-1].minor.yy352)); } - yymsp[-3].minor.yy286 = yylhsminor.yy286; + case 289: /* expression ::= NK_LP expression NK_RP */ + case 351: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==351); +{ yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy456)); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 284: /* expression ::= function_name NK_LP NK_STAR NK_RP */ -{ yylhsminor.yy286 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy567, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy567, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } - yymsp[-3].minor.yy286 = yylhsminor.yy286; - break; - case 285: /* expression ::= function_name NK_LP NK_RP */ -{ yylhsminor.yy286 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy567, &yymsp[0].minor.yy0, createFunctionNodeNoParam(pCxt, &yymsp[-2].minor.yy567)); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; - break; - case 286: /* expression ::= CAST NK_LP expression AS type_name NK_RP */ -{ yylhsminor.yy286 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy286), yymsp[-1].minor.yy274)); } - yymsp[-5].minor.yy286 = yylhsminor.yy286; - break; - case 288: /* expression ::= NK_LP expression NK_RP */ - case 331: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==331); -{ yylhsminor.yy286 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy286)); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; - break; - case 289: /* expression ::= NK_PLUS expression */ + case 290: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy286); - yylhsminor.yy286 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy286)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy456)); } - yymsp[-1].minor.yy286 = yylhsminor.yy286; + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; - case 290: /* expression ::= NK_MINUS expression */ + case 291: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy286); - yylhsminor.yy286 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy286), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy456), NULL)); } - yymsp[-1].minor.yy286 = yylhsminor.yy286; + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; - case 291: /* expression ::= expression NK_PLUS expression */ + case 292: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy286); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy286); - yylhsminor.yy286 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy286), releaseRawExprNode(pCxt, yymsp[0].minor.yy286))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 292: /* expression ::= expression NK_MINUS expression */ + case 293: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy286); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy286); - yylhsminor.yy286 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy286), releaseRawExprNode(pCxt, yymsp[0].minor.yy286))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 293: /* expression ::= expression NK_STAR expression */ + case 294: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy286); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy286); - yylhsminor.yy286 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy286), releaseRawExprNode(pCxt, yymsp[0].minor.yy286))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 294: /* expression ::= expression NK_SLASH expression */ + case 295: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy286); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy286); - yylhsminor.yy286 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy286), releaseRawExprNode(pCxt, yymsp[0].minor.yy286))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 295: /* expression ::= expression NK_REM expression */ + case 296: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy286); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy286); - yylhsminor.yy286 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy286), releaseRawExprNode(pCxt, yymsp[0].minor.yy286))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 296: /* expression_list ::= expression */ -{ yylhsminor.yy352 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy286)); } - yymsp[0].minor.yy352 = yylhsminor.yy352; - break; - case 297: /* expression_list ::= expression_list NK_COMMA expression */ -{ yylhsminor.yy352 = addNodeToList(pCxt, yymsp[-2].minor.yy352, releaseRawExprNode(pCxt, yymsp[0].minor.yy286)); } - yymsp[-2].minor.yy352 = yylhsminor.yy352; - break; - case 298: /* column_reference ::= column_name */ -{ yylhsminor.yy286 = createRawExprNode(pCxt, &yymsp[0].minor.yy567, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy567)); } - yymsp[0].minor.yy286 = yylhsminor.yy286; - break; - case 299: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy286 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy567, &yymsp[0].minor.yy567, createColumnNode(pCxt, &yymsp[-2].minor.yy567, &yymsp[0].minor.yy567)); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; - break; - case 300: /* pseudo_column ::= ROWTS */ - case 301: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==301); - case 302: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==302); - case 303: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==303); - case 304: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==304); - case 305: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==305); - case 306: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==306); -{ yylhsminor.yy286 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy286 = yylhsminor.yy286; - break; - case 307: /* predicate ::= expression compare_op expression */ - case 312: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==312); + case 297: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy286); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy286); - yylhsminor.yy286 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy142, releaseRawExprNode(pCxt, yymsp[-2].minor.yy286), releaseRawExprNode(pCxt, yymsp[0].minor.yy286))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 308: /* predicate ::= expression BETWEEN expression AND expression */ + case 298: /* expression_list ::= expression */ +{ yylhsminor.yy632 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy456)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; + break; + case 299: /* expression_list ::= expression_list NK_COMMA expression */ +{ yylhsminor.yy632 = addNodeToList(pCxt, yymsp[-2].minor.yy632, releaseRawExprNode(pCxt, yymsp[0].minor.yy456)); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; + break; + case 300: /* column_reference ::= column_name */ +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy537, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy537)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; + break; + case 301: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy537, &yymsp[0].minor.yy537, createColumnNode(pCxt, &yymsp[-2].minor.yy537, &yymsp[0].minor.yy537)); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; + break; + case 302: /* pseudo_column ::= ROWTS */ + case 303: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==303); + case 304: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==304); + case 305: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==305); + case 306: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==306); + case 307: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==307); + case 308: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==308); +{ yylhsminor.yy456 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy456 = yylhsminor.yy456; + break; + case 309: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 310: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==310); +{ yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy537, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy537, yymsp[-1].minor.yy632)); } + yymsp[-3].minor.yy456 = yylhsminor.yy456; + break; + case 311: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ +{ yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy456), yymsp[-1].minor.yy388)); } + yymsp[-5].minor.yy456 = yylhsminor.yy456; + break; + case 312: /* function_expression ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy537, &yymsp[0].minor.yy0, createFunctionNodeNoArg(pCxt, &yymsp[-2].minor.yy537)); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; + break; + case 320: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy632 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; + break; + case 325: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 382: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==382); +{ yylhsminor.yy456 = createColumnNode(pCxt, &yymsp[-2].minor.yy537, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; + break; + case 326: /* predicate ::= expression compare_op expression */ + case 331: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==331); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy286); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy286); - yylhsminor.yy286 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy286), releaseRawExprNode(pCxt, yymsp[-2].minor.yy286), releaseRawExprNode(pCxt, yymsp[0].minor.yy286))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy416, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-4].minor.yy286 = yylhsminor.yy286; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 309: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 327: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy286); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy286); - yylhsminor.yy286 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy286), releaseRawExprNode(pCxt, yymsp[-5].minor.yy286), releaseRawExprNode(pCxt, yymsp[0].minor.yy286))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy456), releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-5].minor.yy286 = yylhsminor.yy286; + yymsp[-4].minor.yy456 = yylhsminor.yy456; break; - case 310: /* predicate ::= expression IS NULL */ + case 328: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy286); - yylhsminor.yy286 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy286), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[-5].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + yymsp[-5].minor.yy456 = yylhsminor.yy456; break; - case 311: /* predicate ::= expression IS NOT NULL */ + case 329: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy286); - yylhsminor.yy286 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy286), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), NULL)); } - yymsp[-3].minor.yy286 = yylhsminor.yy286; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 313: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy142 = OP_TYPE_LOWER_THAN; } - break; - case 314: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy142 = OP_TYPE_GREATER_THAN; } - break; - case 315: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy142 = OP_TYPE_LOWER_EQUAL; } - break; - case 316: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy142 = OP_TYPE_GREATER_EQUAL; } - break; - case 317: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy142 = OP_TYPE_NOT_EQUAL; } - break; - case 318: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy142 = OP_TYPE_EQUAL; } - break; - case 319: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy142 = OP_TYPE_LIKE; } - break; - case 320: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy142 = OP_TYPE_NOT_LIKE; } - break; - case 321: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy142 = OP_TYPE_MATCH; } - break; - case 322: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy142 = OP_TYPE_NMATCH; } - break; - case 323: /* in_op ::= IN */ -{ yymsp[0].minor.yy142 = OP_TYPE_IN; } - break; - case 324: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy142 = OP_TYPE_NOT_IN; } - break; - case 325: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy286 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy352)); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; - break; - case 327: /* boolean_value_expression ::= NOT boolean_primary */ + case 330: /* predicate ::= expression IS NOT NULL */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy286); - yylhsminor.yy286 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy286), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy456), NULL)); } - yymsp[-1].minor.yy286 = yylhsminor.yy286; + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; - case 328: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 332: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy416 = OP_TYPE_LOWER_THAN; } + break; + case 333: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy416 = OP_TYPE_GREATER_THAN; } + break; + case 334: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy416 = OP_TYPE_LOWER_EQUAL; } + break; + case 335: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy416 = OP_TYPE_GREATER_EQUAL; } + break; + case 336: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy416 = OP_TYPE_NOT_EQUAL; } + break; + case 337: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy416 = OP_TYPE_EQUAL; } + break; + case 338: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy416 = OP_TYPE_LIKE; } + break; + case 339: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy416 = OP_TYPE_NOT_LIKE; } + break; + case 340: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy416 = OP_TYPE_MATCH; } + break; + case 341: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy416 = OP_TYPE_NMATCH; } + break; + case 342: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy416 = OP_TYPE_JSON_CONTAINS; } + break; + case 343: /* in_op ::= IN */ +{ yymsp[0].minor.yy416 = OP_TYPE_IN; } + break; + case 344: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy416 = OP_TYPE_NOT_IN; } + break; + case 345: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy632)); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; + break; + case 347: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy286); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy286); - yylhsminor.yy286 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy286), releaseRawExprNode(pCxt, yymsp[0].minor.yy286))); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy456), NULL)); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; - case 329: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 348: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy286); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy286); - yylhsminor.yy286 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy286), releaseRawExprNode(pCxt, yymsp[0].minor.yy286))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 334: /* from_clause ::= FROM table_reference_list */ - case 364: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==364); - case 387: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==387); -{ yymsp[-1].minor.yy286 = yymsp[0].minor.yy286; } + case 349: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy456); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy456); + yylhsminor.yy456 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); + } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 336: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy286 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy286, yymsp[0].minor.yy286, NULL); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + case 356: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy456 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy456, yymsp[0].minor.yy456, NULL); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 339: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy286 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy567, &yymsp[0].minor.yy567); } - yymsp[-1].minor.yy286 = yylhsminor.yy286; + case 359: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy456 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy537, &yymsp[0].minor.yy537); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; - case 340: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy286 = createRealTableNode(pCxt, &yymsp[-3].minor.yy567, &yymsp[-1].minor.yy567, &yymsp[0].minor.yy567); } - yymsp[-3].minor.yy286 = yylhsminor.yy286; + case 360: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy456 = createRealTableNode(pCxt, &yymsp[-3].minor.yy537, &yymsp[-1].minor.yy537, &yymsp[0].minor.yy537); } + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; - case 341: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy286 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy286), &yymsp[0].minor.yy567); } - yymsp[-1].minor.yy286 = yylhsminor.yy286; + case 361: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy456 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy456), &yymsp[0].minor.yy537); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; - case 343: /* alias_opt ::= */ -{ yymsp[1].minor.yy567 = nil_token; } + case 363: /* alias_opt ::= */ +{ yymsp[1].minor.yy537 = nil_token; } break; - case 344: /* alias_opt ::= table_alias */ -{ yylhsminor.yy567 = yymsp[0].minor.yy567; } - yymsp[0].minor.yy567 = yylhsminor.yy567; + case 364: /* alias_opt ::= table_alias */ +{ yylhsminor.yy537 = yymsp[0].minor.yy537; } + yymsp[0].minor.yy537 = yylhsminor.yy537; break; - case 345: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy567 = yymsp[0].minor.yy567; } + case 365: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy537 = yymsp[0].minor.yy537; } break; - case 346: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 347: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==347); -{ yymsp[-2].minor.yy286 = yymsp[-1].minor.yy286; } + case 366: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 367: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==367); +{ yymsp[-2].minor.yy456 = yymsp[-1].minor.yy456; } break; - case 348: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy286 = createJoinTableNode(pCxt, yymsp[-4].minor.yy448, yymsp[-5].minor.yy286, yymsp[-2].minor.yy286, yymsp[0].minor.yy286); } - yymsp[-5].minor.yy286 = yylhsminor.yy286; + case 368: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy456 = createJoinTableNode(pCxt, yymsp[-4].minor.yy164, yymsp[-5].minor.yy456, yymsp[-2].minor.yy456, yymsp[0].minor.yy456); } + yymsp[-5].minor.yy456 = yylhsminor.yy456; break; - case 349: /* join_type ::= */ -{ yymsp[1].minor.yy448 = JOIN_TYPE_INNER; } + case 369: /* join_type ::= */ +{ yymsp[1].minor.yy164 = JOIN_TYPE_INNER; } break; - case 350: /* join_type ::= INNER */ -{ yymsp[0].minor.yy448 = JOIN_TYPE_INNER; } + case 370: /* join_type ::= INNER */ +{ yymsp[0].minor.yy164 = JOIN_TYPE_INNER; } break; - case 351: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 371: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-8].minor.yy286 = createSelectStmt(pCxt, yymsp[-7].minor.yy495, yymsp[-6].minor.yy352, yymsp[-5].minor.yy286); - yymsp[-8].minor.yy286 = addWhereClause(pCxt, yymsp[-8].minor.yy286, yymsp[-4].minor.yy286); - yymsp[-8].minor.yy286 = addPartitionByClause(pCxt, yymsp[-8].minor.yy286, yymsp[-3].minor.yy352); - yymsp[-8].minor.yy286 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy286, yymsp[-2].minor.yy286); - yymsp[-8].minor.yy286 = addGroupByClause(pCxt, yymsp[-8].minor.yy286, yymsp[-1].minor.yy352); - yymsp[-8].minor.yy286 = addHavingClause(pCxt, yymsp[-8].minor.yy286, yymsp[0].minor.yy286); + yymsp[-8].minor.yy456 = createSelectStmt(pCxt, yymsp[-7].minor.yy649, yymsp[-6].minor.yy632, yymsp[-5].minor.yy456); + yymsp[-8].minor.yy456 = addWhereClause(pCxt, yymsp[-8].minor.yy456, yymsp[-4].minor.yy456); + yymsp[-8].minor.yy456 = addPartitionByClause(pCxt, yymsp[-8].minor.yy456, yymsp[-3].minor.yy632); + yymsp[-8].minor.yy456 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy456, yymsp[-2].minor.yy456); + yymsp[-8].minor.yy456 = addGroupByClause(pCxt, yymsp[-8].minor.yy456, yymsp[-1].minor.yy632); + yymsp[-8].minor.yy456 = addHavingClause(pCxt, yymsp[-8].minor.yy456, yymsp[0].minor.yy456); } break; - case 354: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy495 = false; } + case 374: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy649 = false; } break; - case 355: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy352 = NULL; } + case 375: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy632 = NULL; } break; - case 360: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy286 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy286), &yymsp[0].minor.yy567); } - yymsp[-1].minor.yy286 = yylhsminor.yy286; + case 380: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy456 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy456), &yymsp[0].minor.yy537); } + yymsp[-1].minor.yy456 = yylhsminor.yy456; break; - case 361: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy286 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy286), &yymsp[0].minor.yy567); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + case 381: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy456 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), &yymsp[0].minor.yy537); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 362: /* select_item ::= table_name NK_DOT NK_STAR */ -{ yylhsminor.yy286 = createColumnNode(pCxt, &yymsp[-2].minor.yy567, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + case 386: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 403: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==403); + case 413: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==413); +{ yymsp[-2].minor.yy632 = yymsp[0].minor.yy632; } break; - case 366: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 383: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==383); - case 393: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==393); -{ yymsp[-2].minor.yy352 = yymsp[0].minor.yy352; } + case 388: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy456 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy456), releaseRawExprNode(pCxt, yymsp[-1].minor.yy456)); } break; - case 368: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy286 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy286), releaseRawExprNode(pCxt, yymsp[-1].minor.yy286)); } + case 389: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ +{ yymsp[-3].minor.yy456 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy456)); } break; - case 369: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ -{ yymsp[-3].minor.yy286 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy286)); } + case 390: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy456 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy456), NULL, yymsp[-1].minor.yy456, yymsp[0].minor.yy456); } break; - case 370: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy286 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy286), NULL, yymsp[-1].minor.yy286, yymsp[0].minor.yy286); } + case 391: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy456 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy456), releaseRawExprNode(pCxt, yymsp[-3].minor.yy456), yymsp[-1].minor.yy456, yymsp[0].minor.yy456); } break; - case 371: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy286 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy286), releaseRawExprNode(pCxt, yymsp[-3].minor.yy286), yymsp[-1].minor.yy286, yymsp[0].minor.yy286); } + case 393: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy456 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy456); } break; - case 373: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy286 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy286); } + case 395: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy456 = createFillNode(pCxt, yymsp[-1].minor.yy646, NULL); } break; - case 375: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy286 = createFillNode(pCxt, yymsp[-1].minor.yy287, NULL); } + case 396: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy456 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy632)); } break; - case 376: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy286 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy352)); } + case 397: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy646 = FILL_MODE_NONE; } break; - case 377: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy287 = FILL_MODE_NONE; } + case 398: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy646 = FILL_MODE_PREV; } break; - case 378: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy287 = FILL_MODE_PREV; } + case 399: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy646 = FILL_MODE_NULL; } break; - case 379: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy287 = FILL_MODE_NULL; } + case 400: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy646 = FILL_MODE_LINEAR; } break; - case 380: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy287 = FILL_MODE_LINEAR; } + case 401: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy646 = FILL_MODE_NEXT; } break; - case 381: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy287 = FILL_MODE_NEXT; } + case 404: /* group_by_list ::= expression */ +{ yylhsminor.yy632 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 384: /* group_by_list ::= expression */ -{ yylhsminor.yy352 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy286))); } - yymsp[0].minor.yy352 = yylhsminor.yy352; + case 405: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy632 = addNodeToList(pCxt, yymsp[-2].minor.yy632, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy456))); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 385: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy352 = addNodeToList(pCxt, yymsp[-2].minor.yy352, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy286))); } - yymsp[-2].minor.yy352 = yylhsminor.yy352; - break; - case 388: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 408: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy286 = addOrderByClause(pCxt, yymsp[-3].minor.yy286, yymsp[-2].minor.yy352); - yylhsminor.yy286 = addSlimitClause(pCxt, yylhsminor.yy286, yymsp[-1].minor.yy286); - yylhsminor.yy286 = addLimitClause(pCxt, yylhsminor.yy286, yymsp[0].minor.yy286); + yylhsminor.yy456 = addOrderByClause(pCxt, yymsp[-3].minor.yy456, yymsp[-2].minor.yy632); + yylhsminor.yy456 = addSlimitClause(pCxt, yylhsminor.yy456, yymsp[-1].minor.yy456); + yylhsminor.yy456 = addLimitClause(pCxt, yylhsminor.yy456, yymsp[0].minor.yy456); } - yymsp[-3].minor.yy286 = yylhsminor.yy286; + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; - case 390: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy286 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy286, yymsp[0].minor.yy286); } - yymsp[-3].minor.yy286 = yylhsminor.yy286; + case 410: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy456 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy456, yymsp[0].minor.yy456); } + yymsp[-3].minor.yy456 = yylhsminor.yy456; break; - case 395: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 399: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==399); -{ yymsp[-1].minor.yy286 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 415: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 419: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==419); +{ yymsp[-1].minor.yy456 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 396: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 400: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==400); -{ yymsp[-3].minor.yy286 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 416: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 420: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==420); +{ yymsp[-3].minor.yy456 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 397: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 401: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==401); -{ yymsp[-3].minor.yy286 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 417: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 421: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==421); +{ yymsp[-3].minor.yy456 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 402: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy286 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy286); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + case 422: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy456 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy456); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 406: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy286 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy286), yymsp[-1].minor.yy216, yymsp[0].minor.yy473); } - yymsp[-2].minor.yy286 = yylhsminor.yy286; + case 426: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy456 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy456), yymsp[-1].minor.yy626, yymsp[0].minor.yy209); } + yymsp[-2].minor.yy456 = yylhsminor.yy456; break; - case 407: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy216 = ORDER_ASC; } + case 427: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy626 = ORDER_ASC; } break; - case 408: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy216 = ORDER_ASC; } + case 428: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy626 = ORDER_ASC; } break; - case 409: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy216 = ORDER_DESC; } + case 429: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy626 = ORDER_DESC; } break; - case 410: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy473 = NULL_ORDER_DEFAULT; } + case 430: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy209 = NULL_ORDER_DEFAULT; } break; - case 411: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy473 = NULL_ORDER_FIRST; } + case 431: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy209 = NULL_ORDER_FIRST; } break; - case 412: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy473 = NULL_ORDER_LAST; } + case 432: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy209 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp index 3da3678563..3ef0eaed42 100644 --- a/source/libs/parser/test/mockCatalogService.cpp +++ b/source/libs/parser/test/mockCatalogService.cpp @@ -264,7 +264,7 @@ private: } std::string ftToString(int16_t colid, int16_t numOfColumns) const { - return (0 == colid ? "column" : (colid <= numOfColumns ? "tag" : "column")); + return (0 == colid ? "column" : (colid < numOfColumns ? "column" : "tag")); } STableMeta* getTableSchemaMeta(const std::string& db, const std::string& tbname) const { diff --git a/source/libs/parser/test/parserAstTest.cpp b/source/libs/parser/test/parserAstTest.cpp index 149c317bd4..5fc4e777c1 100644 --- a/source/libs/parser/test/parserAstTest.cpp +++ b/source/libs/parser/test/parserAstTest.cpp @@ -18,6 +18,7 @@ #include +#include "parserTestUtil.h" #include "parInt.h" using namespace std; @@ -44,7 +45,7 @@ protected: query_ = nullptr; bool res = runImpl(parseCode, translateCode); qDestroyQuery(query_); - if (1/*!res*/) { + if (!res || g_isDump) { dump(); } return res; @@ -57,7 +58,7 @@ private: int32_t code = parse(&cxt_, &query_); if (code != TSDB_CODE_SUCCESS) { parseErrStr_ = string("code:") + tstrerror(code) + string(", msg:") + errMagBuf_; - return (terrno == parseCode); + return (code == parseCode); } if (TSDB_CODE_SUCCESS != parseCode) { return false; @@ -66,7 +67,7 @@ private: code = translate(&cxt_, query_); if (code != TSDB_CODE_SUCCESS) { translateErrStr_ = string("code:") + tstrerror(code) + string(", msg:") + errMagBuf_; - return (terrno == translateCode); + return (code == translateCode); } translatedAstStr_ = toString(query_->pRoot); code = calculateConstant(&cxt_, query_); @@ -243,6 +244,19 @@ TEST_F(ParserTest, selectPseudoColumn) { ASSERT_TRUE(run()); } +TEST_F(ParserTest, selectMultiResFunc) { + setDatabase("root", "test"); + + // bind("SELECT last(*), first(*), last_row(*) FROM t1"); + // ASSERT_TRUE(run()); + + bind("SELECT last(c1, c2), first(t1.*), last_row(c3) FROM t1"); + ASSERT_TRUE(run()); + + bind("SELECT last(t2.*), first(t1.c1, t2.*), last_row(t1.*, t2.*) FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts"); + ASSERT_TRUE(run()); +} + TEST_F(ParserTest, selectClause) { setDatabase("root", "test"); @@ -726,6 +740,22 @@ TEST_F(ParserTest, dropTopic) { ASSERT_TRUE(run()); } +TEST_F(ParserTest, createStream) { + setDatabase("root", "test"); + + bind("create stream s1 as select * from t1"); + ASSERT_TRUE(run()); + + bind("create stream if not exists s1 as select * from t1"); + ASSERT_TRUE(run()); + + bind("create stream s1 into st1 as select * from t1"); + ASSERT_TRUE(run()); + + bind("create stream if not exists s1 trigger window_close watermark 10s into st1 as select * from t1"); + ASSERT_TRUE(run()); +} + TEST_F(ParserTest, explain) { setDatabase("root", "test"); diff --git a/source/libs/parser/test/parserTestMain.cpp b/source/libs/parser/test/parserTestMain.cpp index 9a9711ca96..8cd69418b9 100644 --- a/source/libs/parser/test/parserTestMain.cpp +++ b/source/libs/parser/test/parserTestMain.cpp @@ -15,12 +15,16 @@ #include +#include #include #include "mockCatalog.h" +#include "parserTestUtil.h" #include "parToken.h" #include "functionMgt.h" +bool g_isDump = false; + class ParserEnv : public testing::Environment { public: virtual void SetUp() { @@ -38,8 +42,27 @@ public: virtual ~ParserEnv() {} }; +static void parseArg(int argc, char* argv[]) { + int opt = 0; + const char *optstring = ""; + static struct option long_options[] = { + {"dump", no_argument, NULL, 'd'}, + {0, 0, 0, 0} + }; + while ((opt = getopt_long(argc, argv, optstring, long_options, NULL)) != -1) { + switch (opt) { + case 'd': + g_isDump = true; + break; + default: + break; + } + } +} + int main(int argc, char* argv[]) { testing::AddGlobalTestEnvironment(new ParserEnv()); testing::InitGoogleTest(&argc, argv); + parseArg(argc, argv); return RUN_ALL_TESTS(); } diff --git a/source/libs/parser/test/parserTestUtil.h b/source/libs/parser/test/parserTestUtil.h new file mode 100644 index 0000000000..f5efed50a8 --- /dev/null +++ b/source/libs/parser/test/parserTestUtil.h @@ -0,0 +1,16 @@ +/* + * 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 . + */ + +extern bool g_isDump; \ No newline at end of file diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 3c60b62434..fd0d2758bf 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -200,7 +200,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect strcpy(pScan->tableName.tname, pRealTable->table.tableName); pScan->showRewrite = pCxt->pPlanCxt->showRewrite; pScan->ratio = pRealTable->ratio; - pScan->dataRequired = FUNC_DATA_REQUIRED_ALL_NEEDED; + pScan->dataRequired = FUNC_DATA_REQUIRED_DATA_LOAD; // set columns to scan SNodeList* pCols = NULL; diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 19e6718fe8..656caaf645 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -56,6 +56,20 @@ typedef enum ECondAction { // after supporting outer join, there are other possibilities } ECondAction; +EDealRes haveNormalColImpl(SNode* pNode, void* pContext) { + if (QUERY_NODE_COLUMN == nodeType(pNode)) { + *((bool*)pContext) = (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType); + return *((bool*)pContext) ? DEAL_RES_END : DEAL_RES_IGNORE_CHILD; + } + return DEAL_RES_CONTINUE; +} + +static bool haveNormalCol(SNodeList* pList) { + bool res = false; + nodesWalkExprsPostOrder(pList, haveNormalColImpl, &res); + return res; +} + static bool osdMayBeOptimized(SLogicNode* pNode) { if (OPTIMIZE_FLAG_TEST_MASK(pNode->optimizedFlag, OPTIMIZE_FLAG_OSD)) { return false; @@ -64,10 +78,13 @@ static bool osdMayBeOptimized(SLogicNode* pNode) { return false; } if (NULL == pNode->pParent || - (QUERY_NODE_LOGIC_PLAN_WINDOW != nodeType(pNode->pParent) && QUERY_NODE_LOGIC_PLAN_AGG == nodeType(pNode->pParent))) { + (QUERY_NODE_LOGIC_PLAN_WINDOW != nodeType(pNode->pParent) && QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode->pParent))) { return false; } - return true; + if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode->pParent)) { + return (WINDOW_TYPE_INTERVAL == ((SWindowLogicNode*)pNode->pParent)->winType); + } + return !haveNormalCol(((SAggLogicNode*)pNode->pParent)->pGroupKeys); } static SLogicNode* osdFindPossibleScanNode(SLogicNode* pNode) { @@ -125,12 +142,12 @@ static int32_t osdMatch(SOptimizeContext* pCxt, SLogicNode* pLogicNode, SOsdInfo static EFuncDataRequired osdPromoteDataRequired(EFuncDataRequired l , EFuncDataRequired r) { switch (l) { - case FUNC_DATA_REQUIRED_ALL_NEEDED: + case FUNC_DATA_REQUIRED_DATA_LOAD: return l; - case FUNC_DATA_REQUIRED_STATIS_NEEDED: - return FUNC_DATA_REQUIRED_ALL_NEEDED == r ? r : l; - case FUNC_DATA_REQUIRED_NO_NEEDED: - return FUNC_DATA_REQUIRED_DISCARD == r ? l : r; + case FUNC_DATA_REQUIRED_STATIS_LOAD: + return FUNC_DATA_REQUIRED_DATA_LOAD == r ? r : l; + case FUNC_DATA_REQUIRED_NOT_LOAD: + return FUNC_DATA_REQUIRED_FILTEROUT == r ? l : r; default: break; } @@ -139,9 +156,9 @@ static EFuncDataRequired osdPromoteDataRequired(EFuncDataRequired l , EFuncDataR static int32_t osdGetDataRequired(SNodeList* pFuncs) { if (NULL == pFuncs) { - return FUNC_DATA_REQUIRED_ALL_NEEDED; + return FUNC_DATA_REQUIRED_DATA_LOAD; } - EFuncDataRequired dataRequired = FUNC_DATA_REQUIRED_DISCARD; + EFuncDataRequired dataRequired = FUNC_DATA_REQUIRED_FILTEROUT; SNode* pFunc = NULL; FOREACH(pFunc, pFuncs) { dataRequired = osdPromoteDataRequired(dataRequired, fmFuncDataRequired((SFunctionNode*)pFunc, NULL)); diff --git a/source/libs/planner/test/plannerTest.cpp b/source/libs/planner/test/plannerTest.cpp index 48aa89eae6..1171c9d4ac 100644 --- a/source/libs/planner/test/plannerTest.cpp +++ b/source/libs/planner/test/plannerTest.cpp @@ -45,7 +45,7 @@ protected: int32_t code = qParseQuerySql(&cxt_, &query_); if (code != TSDB_CODE_SUCCESS) { - cout << "sql:[" << cxt_.pSql << "] parser code:" << code << ", strerror:" << tstrerror(code) << ", msg:" << errMagBuf_ << endl; + cout << "sql:[" << cxt_.pSql << "] qParseQuerySql code:" << code << ", strerror:" << tstrerror(code) << ", msg:" << errMagBuf_ << endl; return false; } @@ -196,14 +196,14 @@ TEST_F(PlannerTest, selectGroupBy) { bind("SELECT count(*) FROM t1"); ASSERT_TRUE(run()); - // bind("SELECT c1, max(c3), min(c2), count(*) FROM t1 GROUP BY c1"); - // ASSERT_TRUE(run()); + bind("SELECT c1, max(c3), min(c3), count(*) FROM t1 GROUP BY c1"); + ASSERT_TRUE(run()); - // bind("SELECT c1 + c3, c1 + count(*) FROM t1 where c2 = 'abc' GROUP BY c1, c3"); - // ASSERT_TRUE(run()); + bind("SELECT c1 + c3, c1 + count(*) FROM t1 where c2 = 'abc' GROUP BY c1, c3"); + ASSERT_TRUE(run()); - // bind("SELECT c1 + c3, sum(c4 * c5) FROM t1 where concat(c2, 'wwww') = 'abcwww' GROUP BY c1 + c3"); - // ASSERT_TRUE(run()); + bind("SELECT c1 + c3, sum(c4 * c5) FROM t1 where concat(c2, 'wwww') = 'abcwww' GROUP BY c1 + c3"); + ASSERT_TRUE(run()); } TEST_F(PlannerTest, selectSubquery) { diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index 67871dfe62..a9a360e03e 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -1020,7 +1020,7 @@ int32_t qwProcessReady(QW_FPARAMS_DEF, SQWMsg *qwMsg) { } if (ctx->phase == QW_PHASE_PRE_QUERY) { - ctx->ctrlConnInfo.handle == qwMsg->connInfo.handle; + ctx->ctrlConnInfo.handle = qwMsg->connInfo.handle; ctx->ctrlConnInfo.ahandle = qwMsg->connInfo.ahandle; QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_READY); needRsp = false; diff --git a/source/libs/scheduler/inc/schedulerInt.h b/source/libs/scheduler/inc/schedulerInt.h index 62a96b6438..d1def1bef1 100644 --- a/source/libs/scheduler/inc/schedulerInt.h +++ b/source/libs/scheduler/inc/schedulerInt.h @@ -156,8 +156,8 @@ typedef struct SSchJob { int32_t levelNum; int32_t taskNum; void *transport; - SArray *nodeList; // qnode/vnode list, element is SQueryNodeAddr - SArray *levels; // Element is SQueryLevel, starting from 0. SArray + SArray *nodeList; // qnode/vnode list, SArray + SArray *levels; // starting from 0. SArray SNodeList *subPlans; // subplan pointer copied from DAG, no need to free it in scheduler int32_t levelIdx; diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index c5258afcc1..4e59e1bea6 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -14,12 +14,12 @@ */ #include "catalog.h" +#include "command.h" #include "query.h" #include "schedulerInt.h" #include "tmsg.h" #include "tref.h" #include "trpc.h" -#include "command.h" SSchedulerMgmt schMgmt = {0}; @@ -68,8 +68,8 @@ int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel * } int32_t schInitJob(SSchJob **pSchJob, SQueryPlan *pDag, void *transport, SArray *pNodeList, const char *sql, - int64_t startTs, bool syncSchedule) { - int32_t code = 0; + int64_t startTs, bool syncSchedule) { + int32_t code = 0; SSchJob *pJob = taosMemoryCalloc(1, sizeof(SSchJob)); if (NULL == pJob) { qError("QID:%" PRIx64 " calloc %d failed", pDag->queryId, (int32_t)sizeof(SSchJob)); @@ -141,7 +141,6 @@ _return: SCH_RET(code); } - void schFreeRpcCtx(SRpcCtx *pCtx) { if (NULL == pCtx) { return; @@ -1047,12 +1046,12 @@ _return: int32_t schProcessOnExplainDone(SSchJob *pJob, SSchTask *pTask, SRetrieveTableRsp *pRsp) { SCH_TASK_DLOG("got explain rsp, rows:%d, complete:%d", htonl(pRsp->numOfRows), pRsp->completed); - + atomic_store_32(&pJob->resNumOfRows, htonl(pRsp->numOfRows)); atomic_store_ptr(&pJob->resData, pRsp); SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_SUCCEED); - + schProcessOnDataFetched(pJob); return TSDB_CODE_SUCCESS; @@ -1146,7 +1145,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch if (NULL == msg) { SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); } - + if (!SCH_IS_EXPLAIN_JOB(pJob)) { SCH_TASK_ELOG("invalid msg received for none explain query, msg type:%s", TMSG_INFO(msgType)); SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); @@ -1180,13 +1179,13 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch } if (SCH_IS_EXPLAIN_JOB(pJob)) { - if (rsp->completed) { + if (rsp->completed) { SRetrieveTableRsp *pRsp = NULL; SCH_ERR_JRET(qExecExplainEnd(pJob->explainCtx, &pRsp)); if (pRsp) { SCH_ERR_JRET(schProcessOnExplainDone(pJob, pTask, pRsp)); } - + return TSDB_CODE_SUCCESS; } @@ -1238,23 +1237,24 @@ _return: } int32_t schGetTaskFromTaskList(SHashObj *pTaskList, uint64_t taskId, SSchTask **pTask) { - int32_t s = taosHashGetSize(pTaskList); - if (s <= 0) { - return TSDB_CODE_SUCCESS; - } - - SSchTask **task = taosHashGet(pTaskList, &taskId, sizeof(taskId)); - if (NULL == task || NULL == (*task)) { - return TSDB_CODE_SUCCESS; - } + int32_t s = taosHashGetSize(pTaskList); + if (s <= 0) { + return TSDB_CODE_SUCCESS; + } - *pTask = *task; + SSchTask **task = taosHashGet(pTaskList, &taskId, sizeof(taskId)); + if (NULL == task || NULL == (*task)) { + return TSDB_CODE_SUCCESS; + } - return TSDB_CODE_SUCCESS; + *pTask = *task; + + return TSDB_CODE_SUCCESS; } int32_t schUpdateTaskExecNodeHandle(SSchTask *pTask, void *handle, int32_t rspCode) { - if (rspCode || NULL == pTask->execNodes || taosArrayGetSize(pTask->execNodes) > 1 || taosArrayGetSize(pTask->execNodes) <= 0) { + if (rspCode || NULL == pTask->execNodes || taosArrayGetSize(pTask->execNodes) > 1 || + taosArrayGetSize(pTask->execNodes) <= 0) { return TSDB_CODE_SUCCESS; } @@ -1264,7 +1264,6 @@ int32_t schUpdateTaskExecNodeHandle(SSchTask *pTask, void *handle, int32_t rspCo return TSDB_CODE_SUCCESS; } - int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, int32_t rspCode) { int32_t code = 0; SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param; @@ -1282,13 +1281,15 @@ int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, in if (TDMT_VND_EXPLAIN_RSP == msgType) { schGetTaskFromTaskList(pJob->succTasks, pParam->taskId, &pTask); } else { - SCH_JOB_ELOG("task not found in execTask list, refId:%" PRIx64 ", taskId:%" PRIx64, pParam->refId, pParam->taskId); + SCH_JOB_ELOG("task not found in execTask list, refId:%" PRIx64 ", taskId:%" PRIx64, pParam->refId, + pParam->taskId); SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR); } } - + if (NULL == pTask) { - SCH_JOB_ELOG("task not found in execList & succList, refId:%" PRIx64 ", taskId:%" PRIx64, pParam->refId, pParam->taskId); + SCH_JOB_ELOG("task not found in execList & succList, refId:%" PRIx64 ", taskId:%" PRIx64, pParam->refId, + pParam->taskId); SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR); } @@ -1444,7 +1445,7 @@ int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp) { } int32_t schGenerateTaskCallBackAHandle(SSchJob *pJob, SSchTask *pTask, int32_t msgType, SMsgSendInfo **pMsgSendInfo) { - int32_t code = 0; + int32_t code = 0; SMsgSendInfo *msgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == msgSendInfo) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SMsgSendInfo)); @@ -1565,7 +1566,7 @@ _return: } int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { - int32_t code = 0; + int32_t code = 0; SMsgSendInfo *pReadyMsgSendInfo = NULL; SMsgSendInfo *pExplainMsgSendInfo = NULL; @@ -1578,7 +1579,7 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { SCH_ERR_JRET(schGenerateTaskCallBackAHandle(pJob, pTask, TDMT_VND_RES_READY, &pReadyMsgSendInfo)); SCH_ERR_JRET(schGenerateTaskCallBackAHandle(pJob, pTask, TDMT_VND_EXPLAIN, &pExplainMsgSendInfo)); - int32_t msgType = TDMT_VND_RES_READY_RSP; + int32_t msgType = TDMT_VND_RES_READY_RSP; SRpcCtxVal ctxVal = {.val = pReadyMsgSendInfo, .clone = schCloneSMsgSendInfo, .freeFunc = schFreeRpcCtxVal}; if (taosHashPut(pCtx->args, &msgType, sizeof(msgType), &ctxVal, sizeof(ctxVal))) { SCH_TASK_ELOG("taosHashPut msg %d to rpcCtx failed", msgType); @@ -1599,7 +1600,7 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { _return: taosHashCleanup(pCtx->args); - + if (pReadyMsgSendInfo) { taosMemoryFreeClear(pReadyMsgSendInfo->param); taosMemoryFreeClear(pReadyMsgSendInfo); @@ -1818,7 +1819,7 @@ _return: taosMemoryFreeClear(pMsgSendInfo->param); taosMemoryFreeClear(pMsgSendInfo); } - + SCH_RET(code); } @@ -2319,7 +2320,7 @@ _return: } int32_t schExecStaticExplain(void *transport, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, - bool syncSchedule) { + bool syncSchedule) { qDebug("QID:0x%" PRIx64 " job started", pDag->queryId); int32_t code = 0; @@ -2608,7 +2609,7 @@ int32_t schedulerFetchRows(int64_t job, void **pData) { if (!(pJob->attr.explainMode == EXPLAIN_MODE_STATIC)) { SCH_ERR_JRET(schFetchFromRemote(pJob)); tsem_wait(&pJob->rspSem); - } + } } else { SCH_JOB_ELOG("job status error for fetch, status:%s", jobTaskStatusStr(status)); SCH_ERR_JRET(TSDB_CODE_SCH_STATUS_ERROR); @@ -2655,6 +2656,33 @@ _return: SCH_RET(code); } +int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub) { + int32_t code = 0; + SSchJob *pJob = schAcquireJob(job); + if (NULL == pJob) { + qDebug("acquire job from jobRef list failed, may not started or dropped, refId:%" PRIx64, job); + SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); + } + + if (pJob->status < JOB_TASK_STATUS_NOT_START || pJob->levelNum <= 0 || NULL == pJob->levels) { + qDebug("job not initialized or not executable job, refId:%" PRIx64, job); + SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); + } + + for (int32_t i = pJob->levelNum - 1; i >= 0; --i) { + SSchLevel *pLevel = taosArrayGet(pJob->levels, i); + + for (int32_t m = 0; m < pLevel->taskNum; ++m) { + SSchTask *pTask = taosArrayGet(pLevel->subTasks, m); + SQuerySubDesc subDesc = {.tid = pTask->taskId, .status = pTask->status}; + + taosArrayPush(pSub, &subDesc); + } + } + + return TSDB_CODE_SUCCESS; +} + int32_t scheduleCancelJob(int64_t job) { SSchJob *pJob = schAcquireJob(job); if (NULL == pJob) { @@ -2672,7 +2700,7 @@ int32_t scheduleCancelJob(int64_t job) { void schedulerFreeJob(int64_t job) { SSchJob *pJob = schAcquireJob(job); if (NULL == pJob) { - qError("acquire job from jobRef list failed, may be dropped, refId:%" PRIx64, job); + qDebug("acquire job from jobRef list failed, may be dropped, refId:%" PRIx64, job); return; } @@ -2706,15 +2734,17 @@ void schedulerFreeTaskList(SArray *taskList) { void schedulerDestroy(void) { if (schMgmt.jobRef) { SSchJob *pJob = taosIterateRef(schMgmt.jobRef, 0); - + int64_t refId = 0; + while (pJob) { + refId = pJob->refId; + taosRemoveRef(schMgmt.jobRef, pJob->refId); - pJob = taosIterateRef(schMgmt.jobRef, pJob->refId); + pJob = taosIterateRef(schMgmt.jobRef, refId); } taosCloseRef(schMgmt.jobRef); schMgmt.jobRef = 0; } } - diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 3078324c6b..ef9cccccb7 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -292,7 +292,7 @@ void* transCtxDumpBrokenlinkVal(STransCtx* ctx, int32_t* msgType) { void transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg)) { queue->q = taosArrayInit(2, sizeof(void*)); - queue->freeFunc = freeFunc; + queue->freeFunc = (void (*)(const void*))freeFunc; } bool transQueuePush(STransQueue* queue, void* arg) { if (queue->q == NULL) { diff --git a/source/libs/transport/test/transportTests.cpp b/source/libs/transport/test/transportTests.cpp index ce795b1763..2488dda3f6 100644 --- a/source/libs/transport/test/transportTests.cpp +++ b/source/libs/transport/test/transportTests.cpp @@ -156,14 +156,14 @@ TEST_F(TransCtxEnv, mergeTest) { STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); transCtxInit(src); { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryMalloc(12); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); key++; } { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryMalloc(12); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); key++; @@ -176,14 +176,14 @@ TEST_F(TransCtxEnv, mergeTest) { STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); transCtxInit(src); { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryMalloc(12); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); key++; } { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryMalloc(12); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); key++; @@ -198,7 +198,7 @@ TEST_F(TransCtxEnv, mergeTest) { STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); transCtxInit(src); { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryCalloc(1, 11); memcpy(val1.val, val.c_str(), val.size()); @@ -206,7 +206,7 @@ TEST_F(TransCtxEnv, mergeTest) { key++; } { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryCalloc(1, 11); memcpy(val1.val, val.c_str(), val.size()); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); diff --git a/source/os/src/osMemory.c b/source/os/src/osMemory.c index 3545aabdca..cd756b45e2 100644 --- a/source/os/src/osMemory.c +++ b/source/os/src/osMemory.c @@ -156,7 +156,7 @@ void *taosMemoryStrDup(void *ptr) { } -void taosMemoryFree(const void *ptr) { +void taosMemoryFree(void *ptr) { if (ptr == NULL) return; #ifdef USE_TD_MEMORY @@ -166,10 +166,10 @@ void taosMemoryFree(const void *ptr) { // memset(pTdMemoryInfo, 0, sizeof(TdMemoryInfo)); free(pTdMemoryInfo); } else { - free((void*)ptr); + free(ptr); } #else - return free((void*)ptr); + return free(ptr); #endif } diff --git a/source/util/src/tarray.c b/source/util/src/tarray.c index a74b26a386..4477a5cacd 100644 --- a/source/util/src/tarray.c +++ b/source/util/src/tarray.c @@ -303,6 +303,21 @@ void taosArrayClear(SArray* pArray) { pArray->size = 0; } +void taosArrayClearEx(SArray* pArray, void (*fp)(void*)) { + if (pArray == NULL) return; + if (fp == NULL) { + pArray->size = 0; + return; + } + + for (int32_t i = 0; i < pArray->size; ++i) { + fp(TARRAY_GET_ELEM(pArray, i)); + } + + pArray->size = 0; +} + + void* taosArrayDestroy(SArray* pArray) { if (pArray) { taosMemoryFree(pArray->pData); diff --git a/tests/script/runAllSimCases.sh b/tests/script/runAllSimCases.sh index e1eea1cc38..70f2f86115 100755 --- a/tests/script/runAllSimCases.sh +++ b/tests/script/runAllSimCases.sh @@ -1,4 +1,4 @@ -#!/bin/bash +!/bin/bash ################################################## # @@ -8,13 +8,73 @@ set -e #set -x +VALGRIND=0 +LOG_BK_DIR=/data/valgrind_log_backup # 192.168.0.203 +while getopts "v:r" arg +do + case $arg in + v) + VALGRIND=1 + ;; + r) + LOG_BK_DIR=$(echo $OPTARG) + ;; + ?) #unknow option + echo "unkonw argument" + exit 1 + ;; + esac +done + +echo "VALGRIND: $VALGRIND, LOG_BK_DIR: $LOG_BK_DIR" + +CURRENT_DIR=`pwd` +TSIM_LOG_DIR=$CURRENT_DIR/../../sim/tsim/log +TAOSD_LOG_DIR=$CURRENT_DIR/../../sim + +echo "tsim log dir: $TSIM_LOG_DIR" +echo "taosd log dir: $TAOSD_LOG_DIR" + +if [[ $VALGRIND -eq 1 ]]; then + if [ -d ${LOG_BK_DIR} ]; then + rm -rf ${LOG_BK_DIR}/* + else + mkdir -p $LOG_BK_DIR/ + fi +fi while read line do firstChar=`echo ${line:0:1}` if [[ -n "$line" ]] && [[ $firstChar != "#" ]]; then - echo "======== $line ========" - $line + if [[ $VALGRIND -eq 1 ]]; then + echo "======== $line -v ========" + $line -v + + # move all valgrind log files of the sim case to valgrind back dir + # get current sim case name for + result=`echo ${line%sim*}` + result=`echo ${result#*/}` + result=`echo ${result#*/}` + result=`echo ${result////-}` + tsimLogFile=valgrind-${result}sim.log + + echo "cp ${TSIM_LOG_DIR}/valgrind-tsim.log ${LOG_BK_DIR}/${tsimLogFile} " + cp ${TSIM_LOG_DIR}/valgrind-tsim.log ${LOG_BK_DIR}/${tsimLogFile} + cp ${TAOSD_LOG_DIR}/dnode1/log/valgrind*.log ${LOG_BK_DIR}/ ||: + cp ${TAOSD_LOG_DIR}/dnode2/log/valgrind*.log ${LOG_BK_DIR}/ ||: + cp ${TAOSD_LOG_DIR}/dnode3/log/valgrind*.log ${LOG_BK_DIR}/ ||: + cp ${TAOSD_LOG_DIR}/dnode4/log/valgrind*.log ${LOG_BK_DIR}/ ||: + cp ${TAOSD_LOG_DIR}/dnode5/log/valgrind*.log ${LOG_BK_DIR}/ ||: + cp ${TAOSD_LOG_DIR}/dnode6/log/valgrind*.log ${LOG_BK_DIR}/ ||: + cp ${TAOSD_LOG_DIR}/dnode7/log/valgrind*.log ${LOG_BK_DIR}/ ||: + cp ${TAOSD_LOG_DIR}/dnode8/log/valgrind*.log ${LOG_BK_DIR}/ ||: + cp ${TAOSD_LOG_DIR}/dnode9/log/valgrind*.log ${LOG_BK_DIR}/ ||: + + else + echo "======== $line ========" + $line + fi fi done < ./jenkins/basic.txt diff --git a/tests/script/sh/exec.sh b/tests/script/sh/exec.sh index 50ded73555..606f778920 100755 --- a/tests/script/sh/exec.sh +++ b/tests/script/sh/exec.sh @@ -97,13 +97,14 @@ if [ "$CLEAR_OPTION" = "clear" ]; then fi if [ "$EXEC_OPTON" = "start" ]; then - echo "ExcuteCmd:" $EXE_DIR/taosd -c $CFG_DIR - + #echo "ExcuteCmd:" $EXE_DIR/taosd -c $CFG_DIR if [ "$VALGRIND_OPTION" = "true" ]; then TT=`date +%s` - mkdir ${LOG_DIR}/${TT} - nohup valgrind --log-file=${LOG_DIR}/${TT}/valgrind.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & + #mkdir ${LOG_DIR}/${TT} + echo "nohup valgrind --log-file=${LOG_DIR}/valgrind-taosd-${TT}.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 &" + nohup valgrind --log-file=${LOG_DIR}/valgrind-taosd-${TT}.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & else + echo "nohup $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 &" nohup $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & fi diff --git a/tests/script/sh/stop_dnodes.sh b/tests/script/sh/stop_dnodes.sh index 4c6d8e0351..b431c0627c 100755 --- a/tests/script/sh/stop_dnodes.sh +++ b/tests/script/sh/stop_dnodes.sh @@ -12,7 +12,8 @@ fi PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` while [ -n "$PID" ]; do echo kill -9 $PID - pkill -9 taosd + #pkill -9 taosd + kill -9 $PID echo "Killing processes locking on port 6030" if [ "$OS_TYPE" != "Darwin" ]; then fuser -k -n tcp 6030 diff --git a/tests/script/test.sh b/tests/script/test.sh index f5a9e4187b..27fa4933e0 100755 --- a/tests/script/test.sh +++ b/tests/script/test.sh @@ -126,7 +126,7 @@ if [ -n "$FILE_NAME" ]; then echo "------------------------------------------------------------------------" if [ $VALGRIND -eq 1 ]; then echo valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes --log-file=${CODE_DIR}/../script/valgrind.log $PROGRAM -c $CFG_DIR -f $FILE_NAME -v - valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes --log-file=${CODE_DIR}/../script/valgrind.log $PROGRAM -c $CFG_DIR -f $FILE_NAME -v + valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes --log-file=${LOG_DIR}/valgrind-tsim.log $PROGRAM -c $CFG_DIR -f $FILE_NAME -v else if [[ $MULTIPROCESS -eq 1 ]];then echo "ExcuteCmd(multiprocess):" $PROGRAM -m -c $CFG_DIR -f $FILE_NAME diff --git a/tests/script/tsim/db/alter_option.sim b/tests/script/tsim/db/alter_option.sim index 9c7b2f5424..e9795bd8d2 100644 --- a/tests/script/tsim/db/alter_option.sim +++ b/tests/script/tsim/db/alter_option.sim @@ -350,4 +350,6 @@ sql_error alter database db precision 'ns' sql_error alter database db precision 'ys' sql_error alter database db prec 'xs' -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/tsim/db/create_all_options.sim b/tests/script/tsim/db/create_all_options.sim index 4dda6cd00f..2baba8fb74 100644 --- a/tests/script/tsim/db/create_all_options.sim +++ b/tests/script/tsim/db/create_all_options.sim @@ -484,4 +484,6 @@ sql drop database db sql_error create database db STREAM_MODE 2 sql_error create database db STREAM_MODE -1 -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/tsim/insert/backquote.sim b/tests/script/tsim/insert/backquote.sim index 819b1aea13..ba50e70afa 100644 --- a/tests/script/tsim/insert/backquote.sim +++ b/tests/script/tsim/insert/backquote.sim @@ -353,4 +353,4 @@ while $dbCnt < 2 endw -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/insert/basic0.sim b/tests/script/tsim/insert/basic0.sim index 1ae8b372dc..94bd0f1ecf 100644 --- a/tests/script/tsim/insert/basic0.sim +++ b/tests/script/tsim/insert/basic0.sim @@ -537,4 +537,4 @@ endi #endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/insert/null.sim b/tests/script/tsim/insert/null.sim index fab5335ac5..98a494c960 100644 --- a/tests/script/tsim/insert/null.sim +++ b/tests/script/tsim/insert/null.sim @@ -471,4 +471,4 @@ endi # return -1 #endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/fourArithmetic-basic.sim b/tests/script/tsim/parser/fourArithmetic-basic.sim index ebe20924be..eee294dc80 100644 --- a/tests/script/tsim/parser/fourArithmetic-basic.sim +++ b/tests/script/tsim/parser/fourArithmetic-basic.sim @@ -138,4 +138,4 @@ if $loop_test == 0 then goto loop_test_pos endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/query/charScalarFunction.sim b/tests/script/tsim/query/charScalarFunction.sim index 0468125997..18ee93f610 100644 --- a/tests/script/tsim/query/charScalarFunction.sim +++ b/tests/script/tsim/query/charScalarFunction.sim @@ -727,4 +727,4 @@ if $loop_test == 0 then goto loop_test_pos endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/query/complex_limit.sim b/tests/script/tsim/query/complex_limit.sim index 1691f2d443..4942fec4ee 100644 --- a/tests/script/tsim/query/complex_limit.sim +++ b/tests/script/tsim/query/complex_limit.sim @@ -527,4 +527,4 @@ if $rows != 1 then return -1 endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/query/complex_select.sim b/tests/script/tsim/query/complex_select.sim index 1ebcb2f49a..1f41783383 100644 --- a/tests/script/tsim/query/complex_select.sim +++ b/tests/script/tsim/query/complex_select.sim @@ -577,4 +577,4 @@ if $data00 != 33 then endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/query/complex_where.sim b/tests/script/tsim/query/complex_where.sim index 7cd576400f..8e22a12fcf 100644 --- a/tests/script/tsim/query/complex_where.sim +++ b/tests/script/tsim/query/complex_where.sim @@ -688,4 +688,4 @@ if $rows != 1 then return -1 endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/query/interval-offset.sim b/tests/script/tsim/query/interval-offset.sim index e222077fa4..6c736e9daa 100644 --- a/tests/script/tsim/query/interval-offset.sim +++ b/tests/script/tsim/query/interval-offset.sim @@ -318,4 +318,4 @@ endi #sql select count(*) from car where ts > '2019-05-14 00:00:00' interval(1y, 5d) -#system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/query/interval.sim b/tests/script/tsim/query/interval.sim index 384008c887..9d7104c3de 100644 --- a/tests/script/tsim/query/interval.sim +++ b/tests/script/tsim/query/interval.sim @@ -180,4 +180,4 @@ print =============== clear # return -1 #endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/query/scalarFunction.sim b/tests/script/tsim/query/scalarFunction.sim index 9e6d378bd0..be75e1a21c 100644 --- a/tests/script/tsim/query/scalarFunction.sim +++ b/tests/script/tsim/query/scalarFunction.sim @@ -481,4 +481,4 @@ if $loop_test == 0 then goto loop_test_pos endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/query/session.sim b/tests/script/tsim/query/session.sim index 3aee838625..5062c556a5 100644 --- a/tests/script/tsim/query/session.sim +++ b/tests/script/tsim/query/session.sim @@ -288,7 +288,7 @@ endi print ================> syntax error check not active ================> reactive sql_error select * from dev_001 session(ts,1w) -sql select count(*) from st session(ts,1w) +sql_error select count(*) from st session(ts,1w) sql_error select count(*) from dev_001 group by tagtype session(ts,1w) sql select count(*) from dev_001 session(ts,1n) sql select count(*) from dev_001 session(ts,1y) @@ -347,4 +347,4 @@ if $loop_test == 0 then goto loop_test_pos endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/query/stddev.sim b/tests/script/tsim/query/stddev.sim index 70a9719b40..74bc444da2 100644 --- a/tests/script/tsim/query/stddev.sim +++ b/tests/script/tsim/query/stddev.sim @@ -1,17 +1,16 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c walLevel -v 1 system sh/exec.sh -n dnode1 -s start $loop_cnt = 0 check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi + sql show dnodes print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 if $data00 != 1 then @@ -23,108 +22,410 @@ endi sql connect -$dbPrefix = db -$tbPrefix = ctb -$mtPrefix = stb -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $cc = $x * 60000 - $ms = 1601481600000 + $cc - - sql insert into $tb values ($ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select stddev(tbcol) from $tb -print ===> $data00 -if $data00 != 5.766281297 then - return -1 -endi - -print =============== step3 -$cc = 4 * 60000 -$ms = 1601481600000 + $cc - -print ===> select stddev(tbcol) from $tb where ts <= $ms -sql select stddev(tbcol) from $tb where ts <= $ms -print ====> $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1.414213562 then - return -1 -endi - -print =============== step4 -sql select stddev(tbcol) as b from $tb -print ===> $data00 -if $data00 != 5.766281297 then - return -1 -endi - -print =============== step5 -sql select _wstartts, stddev(tbcol) as b from $tb interval(1m) -print ===> $data01 -if $data01 != 0.000000000 then - print expect 0.000000000, actual: $data01 - return -1 -endi - -sql select _wstartts, stddev(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != 5.766281297 then - return -1 -endi - -print =============== step6 -$cc = 4 * 60000 -$ms = 1601481600000 + $cc - -print select _wstartts, stddev(tbcol) as b from $tb where ts <= $ms interval(1m) -sql select _wstartts, stddev(tbcol) as b from $tb where ts <= $ms interval(1m) -print ===> $data01 -if $data01 != 0.000000000 then - return -1 -endi - -print $data00 , $data10 , $data20 , $data30 , $data40 , $data50 , $data60 - -if $rows != 5 then - print expect 5, actual: $rows - return -1 -endi - -print =============== clear -sql drop database $db +print =============== create database +sql create database db sql show databases +if $rows != 3 then + return -1 +endi + +sql use db + +print =============== create super table and child table +sql create table stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) +sql show stables +print $rows $data00 $data01 $data02 if $rows != 1 then return -1 endi +sql create table ct1 using stb1 tags ( 1 ) +sql create table ct2 using stb1 tags ( 2 ) +sql create table ct3 using stb1 tags ( 3 ) +sql create table ct4 using stb1 tags ( 4 ) +sql show tables +print $rows $data00 $data10 $data20 +if $rows != 4 then + return -1 +endi + +sql create table t1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + +print =============== insert data into child table ct1 (s) +sql insert into ct1 values ( '2022-01-01 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct1 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct1 values ( '2022-01-01 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct1 values ( '2022-01-01 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct1 values ( '2022-01-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct1 values ( '2022-01-01 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into ct1 values ( '2022-01-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+7a ) +sql insert into ct1 values ( '2022-01-01 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+8a ) + +print =============== insert data into child table ct4 (y) +sql insert into ct4 values ( '2019-01-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) +sql insert into ct4 values ( '2019-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct4 values ( '2019-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct4 values ( '2020-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct4 values ( '2020-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct4 values ( '2020-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct4 values ( '2020-12-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) +sql insert into ct4 values ( '2021-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into ct4 values ( '2021-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) +sql insert into ct4 values ( '2021-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) +sql insert into ct4 values ( '2022-02-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) +sql insert into ct4 values ( '2022-05-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + +print =============== insert data into child table t1 +sql insert into t1 values ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into t1 values ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into t1 values ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into t1 values ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into t1 values ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into t1 values ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into t1 values ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) +sql insert into t1 values ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) +sql insert into t1 values ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) + +print ================ start query ====================== + +print =============== step1 +print =====sql : select stddev(c1) as b from ct4 +sql select stddev(c1) as b from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c1) as b from t1 +sql select stddev(c1) as b from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select _wstartts, stddev(c1) as b from ct4 interval(1y) +sql select _wstartts, stddev(c1) as b from ct4 interval(1y) +print ===> $rows +if $rows != 4 then + return -1 +endi + +print =====sql : select _wstartts, stddev(c1) as b from t1 interval(1y) +sql select _wstartts, stddev(c1) as b from t1 interval(1y) +print ===> $rows +if $rows != 3 then + return -1 +endi + +print =====select _wstartts, stddev(c1) as b from ct4 where c1 <= 6 interval(180d) +sql select _wstartts, stddev(c1) as b from ct4 where c1 <= 6 interval(180d) +# print ===> $rows +# if $rows != 3 then +# return -1 +# endi + +print =====select _wstartts, stddev(c1) as b from t1 where c1 <= 6 interval(180d) +sql select _wstartts, stddev(c1) as b from t1 where c1 <= 6 interval(180d) +# print ===> $rows +# if $rows != 3 then +# return -1 +# endi + +print =====sql : select stddev(c1) a1, sum(c1) b1 from ct4 +sql select stddev(c1) a1, sum(c1) b1 from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c1) a1, sum(c1) b1 from t1 +sql select stddev(c1) a1, sum(c1) b1 from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c1)+sum(c1) b1 from ct4 +sql select stddev(c1)+sum(c1) b1 from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c1)+sum(c1) b1 from t1 +sql select stddev(c1)+sum(c1) b1 from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c2) from ct4 +sql select stddev(c2) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c2) from t1 +sql select stddev(c2) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c3) from ct4 +sql select stddev(c3) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c3) from t1 +sql select stddev(c3) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c4) from ct4 +sql select stddev(c4) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c4) from t1 +sql select stddev(c4) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c5) from ct4 +sql select stddev(c5) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c5) from t1 +sql select stddev(c5) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c6) from ct4 +sql select stddev(c6) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c6) from t1 +sql select stddev(c6) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c7) from ct4 +sql_error select stddev(c7) from ct4 +# print ===> $rows +# if $rows != 1 then +# return -1 +# endi + +print =====sql : select stddev(c7) from t1 +sql_error select stddev(c7) from t1 +# print ===> $rows +# if $rows != 1 then +# return -1 +# endi + +#================================================= +print =============== stop and restart taosd system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready_0: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi + +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready_0 +endi + +print =============== step2 after wal +print =====sql : select stddev(c1) as b from ct4 +sql select stddev(c1) as b from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c1) as b from t1 +sql select stddev(c1) as b from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select _wstartts, stddev(c1) as b from ct4 interval(1y) +sql select _wstartts, stddev(c1) as b from ct4 interval(1y) +print ===> $rows +if $rows != 4 then + return -1 +endi + +print =====sql : select _wstartts, stddev(c1) as b from t1 interval(1y) +sql select _wstartts, stddev(c1) as b from t1 interval(1y) +print ===> $rows +if $rows != 3 then + return -1 +endi + +print =====select _wstartts, stddev(c1) as b from ct4 where c1 <= 6 interval(180d) +sql select _wstartts, stddev(c1) as b from ct4 where c1 <= 6 interval(180d) +print ===> $rows +if $rows != 3 then + return -1 +endi + +print =====select _wstartts, stddev(c1) as b from t1 where c1 <= 6 interval(180d) +sql select _wstartts, stddev(c1) as b from t1 where c1 <= 6 interval(180d) +print ===> $rows +if $rows != 3 then + return -1 +endi + +print =====sql : select stddev(c1) a1, sum(c1) b1 from ct4 +sql select stddev(c1) a1, sum(c1) b1 from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c1) a1, sum(c1) b1 from t1 +sql select stddev(c1) a1, sum(c1) b1 from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c1)+sum(c1) b1 from ct4 +sql select stddev(c1)+sum(c1) b1 from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c1)+sum(c1) b1 from t1 +sql select stddev(c1)+sum(c1) b1 from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c2) from ct4 +sql select stddev(c2) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c2) from t1 +sql select stddev(c2) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c3) from ct4 +sql select stddev(c3) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c3) from t1 +sql select stddev(c3) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c4) from ct4 +sql select stddev(c4) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c4) from t1 +sql select stddev(c4) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c5) from ct4 +sql select stddev(c5) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c5) from t1 +sql select stddev(c5) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c6) from ct4 +sql select stddev(c6) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c6) from t1 +sql select stddev(c6) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c7) from ct4 +sql_error select stddev(c7) from ct4 +# print ===> $rows +# if $rows != 1 then +# return -1 +# endi + +print =====sql : select stddev(c7) from t1 +sql_error select stddev(c7) from t1 +# print ===> $rows +# if $rows != 1 then +# return -1 +# endi + +print =============== clear +sql drop database db +sql show databases +if $rows != 2 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/show/basic.sim b/tests/script/tsim/show/basic.sim index 0c0670ff7f..ca6cd1c11a 100644 --- a/tests/script/tsim/show/basic.sim +++ b/tests/script/tsim/show/basic.sim @@ -212,4 +212,5 @@ if $rows != 3 then return -1 endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/stable/dnode3.sim b/tests/script/tsim/stable/dnode3.sim index e388bd9b31..706c4aa499 100644 --- a/tests/script/tsim/stable/dnode3.sim +++ b/tests/script/tsim/stable/dnode3.sim @@ -211,3 +211,6 @@ if $rows != 2 then endi system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT diff --git a/tests/script/tsim/tmq/basic.sim b/tests/script/tsim/tmq/basic.sim index 9f55847965..db2c7fd9a3 100644 --- a/tests/script/tsim/tmq/basic.sim +++ b/tests/script/tsim/tmq/basic.sim @@ -76,4 +76,4 @@ if $data00 != 10000 then return -1 endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/tmq/basic1.sim b/tests/script/tsim/tmq/basic1.sim index ec33e89e84..52e8279322 100644 --- a/tests/script/tsim/tmq/basic1.sim +++ b/tests/script/tsim/tmq/basic1.sim @@ -196,4 +196,4 @@ $dbNamme = d1 sql create database $dbNamme vgroups 4 -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/tmq/main2Con1Cgrp1TopicFrCtb.sim b/tests/script/tsim/tmq/main2Con1Cgrp1TopicFrCtb.sim index 68c2d5a891..16e37e0e12 100644 --- a/tests/script/tsim/tmq/main2Con1Cgrp1TopicFrCtb.sim +++ b/tests/script/tsim/tmq/main2Con1Cgrp1TopicFrCtb.sim @@ -43,6 +43,35 @@ loop_vgroups: print =============== create database $dbNamme vgroups $vgroups sql create database $dbNamme vgroups $vgroups sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 + +if $loop_cnt == 0 then + if $rows != 2 then + return -1 + endi + if $data02 != 2 then # vgroups + print vgroups: $data02 + return -1 + endi +else + if $rows != 3 then + return -1 + endi + if $data00 == d1 then + if $data02 != 4 then # vgroups + print vgroups: $data02 + return -1 + endi + else + if $data12 != 4 then # vgroups + print vgroups: $data12 + return -1 + endi + endi +endi + sql use $dbNamme print =============== create super table @@ -233,4 +262,4 @@ if $loop_cnt == 0 then goto loop_vgroups endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/tmq/main2Con1Cgrp1TopicFrStb.sim b/tests/script/tsim/tmq/main2Con1Cgrp1TopicFrStb.sim index 1b98bcdd5d..9b24e4870d 100644 --- a/tests/script/tsim/tmq/main2Con1Cgrp1TopicFrStb.sim +++ b/tests/script/tsim/tmq/main2Con1Cgrp1TopicFrStb.sim @@ -204,27 +204,27 @@ print expectMsgCntFromStb: $expectMsgCntFromStb #endi $expect_result = @{consume success: @ -$expect_result = $expect_result . $expectConsumeMsgCnt +$expect_result = $expect_result . $expectMsgCntFromStb $expect_result = $expect_result . @, @ $expect_result = $expect_result . 0} print expect_result----> $expect_result -print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 0 +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_column" -k1 "group.id:tg2" -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 0 print cmd result----> $system_content if $system_content != success then return -1 endi -#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb +#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 0 +#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_all" -k1 "group.id:tg2" -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 0 #print cmd result----> $system_content ##if $system_content != @{consume success: 10000, 0}@ then #if $system_content != success then # return -1 #endi -print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 0 +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 0 print cmd result----> $system_content #if $system_content != @{consume success: 10000, 0}@ then if $system_content != success then @@ -237,4 +237,4 @@ if $loop_cnt == 0 then goto loop_vgroups endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/tmq/main2Con1Cgrp2TopicFrCtb.sim b/tests/script/tsim/tmq/main2Con1Cgrp2TopicFrCtb.sim index 9f2b204b60..8c0b3934b1 100644 --- a/tests/script/tsim/tmq/main2Con1Cgrp2TopicFrCtb.sim +++ b/tests/script/tsim/tmq/main2Con1Cgrp2TopicFrCtb.sim @@ -232,4 +232,4 @@ if $loop_cnt == 0 then goto loop_vgroups endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/tmq/main2Con1Cgrp2TopicFrStb.sim b/tests/script/tsim/tmq/main2Con1Cgrp2TopicFrStb.sim index 45dd4fd187..853d842a44 100644 --- a/tests/script/tsim/tmq/main2Con1Cgrp2TopicFrStb.sim +++ b/tests/script/tsim/tmq/main2Con1Cgrp2TopicFrStb.sim @@ -237,4 +237,4 @@ if $loop_cnt == 0 then goto loop_vgroups endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/tmq/mainConsumerInMultiTopic.sim b/tests/script/tsim/tmq/mainConsumerInMultiTopic.sim index 2e2534d104..e9e24d06c6 100644 --- a/tests/script/tsim/tmq/mainConsumerInMultiTopic.sim +++ b/tests/script/tsim/tmq/mainConsumerInMultiTopic.sim @@ -210,4 +210,4 @@ if $loop_cnt == 0 then endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/tmq/mainConsumerInOneTopic.sim b/tests/script/tsim/tmq/mainConsumerInOneTopic.sim index d307723878..24f15ab46d 100644 --- a/tests/script/tsim/tmq/mainConsumerInOneTopic.sim +++ b/tests/script/tsim/tmq/mainConsumerInOneTopic.sim @@ -239,4 +239,4 @@ if $loop_cnt == 0 then goto loop_vgroups endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/tmq/multiTopic.sim b/tests/script/tsim/tmq/multiTopic.sim index 0ce6304799..ea5d7e3e65 100644 --- a/tests/script/tsim/tmq/multiTopic.sim +++ b/tests/script/tsim/tmq/multiTopic.sim @@ -221,4 +221,4 @@ if $loop_cnt == 0 then endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/tmq/oneTopic.sim b/tests/script/tsim/tmq/oneTopic.sim index e3f9d727b9..54b79bc490 100644 --- a/tests/script/tsim/tmq/oneTopic.sim +++ b/tests/script/tsim/tmq/oneTopic.sim @@ -261,4 +261,4 @@ if $loop_cnt == 0 then endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/tmq/overlapTopic2Con1Cgrp.sim b/tests/script/tsim/tmq/overlapTopic2Con1Cgrp.sim index 62ec3149be..943e139196 100644 --- a/tests/script/tsim/tmq/overlapTopic2Con1Cgrp.sim +++ b/tests/script/tsim/tmq/overlapTopic2Con1Cgrp.sim @@ -39,6 +39,7 @@ sql connect $loop_cnt = 0 $vgroups = 1 $dbNamme = d0 + loop_vgroups: print =============== create database $dbNamme vgroups $vgroups sql create database $dbNamme vgroups $vgroups @@ -48,15 +49,15 @@ print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $d print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 if $loop_cnt == 0 then - if $rows != 2 then + if $rows != 3 then return -1 endi - if $data02 != 1 then # vgroups + if $data22 != 1 then # vgroups print vgroups: $data02 return -1 endi else - if $rows != 3 then + if $rows != 4 then return -1 endi if $data00 == d1 then @@ -153,7 +154,7 @@ endw # -g showMsgFlag, default is 0 # -$consumeDelay = 2 +$consumeDelay = 3 $expectMsgCntFromCtb = $rowNum $expectMsgCntFromStb = $rowNum * $tbNum @@ -179,8 +180,18 @@ $expect_result = $expect_result . $totalMsgCntOfmultiTopics $expect_result = $expect_result . @, @ $expect_result = $expect_result . 0} print expect_result----> $expect_result -print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_column, topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function, topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 2 -system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_column, topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function, topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb -j 2 + +$check_mode = 0 +if $loop_cnt == 0 then + $check_mode = 0 +else + $check_mode = 2 +endi + +$expectMsgCntFromStb0 = 2001 +$expectMsgCntFromStb1 = 2001 +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_column, topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function, topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb0 -m1 $expectMsgCntFromStb1 -j 2 +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t1 "topic_stb_column, topic_stb_function" -k1 "group.id:tg2" -t "topic_stb_function, topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectMsgCntFromStb0 -m1 $expectMsgCntFromStb1 -j 2 print cmd result----> $system_content if $system_content != success then return -1 @@ -237,4 +248,4 @@ if $loop_cnt == 0 then endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 1809d99209..ac2010efa3 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -344,6 +344,8 @@ void shellRunCommandOnServer(TAOS *con, char command[]) { atomic_store_64(&result, 0); freeResultWithRid(oresult); + taos_free_result(pSql); + return; }