diff --git a/cmake/cmake.define b/cmake/cmake.define index b89860e29f7251c47cd343d2e012d375b582b703..53d25e10977f73716957ffded17c0409c6ac9865 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -46,16 +46,20 @@ IF (TD_WINDOWS) ENDIF () ELSE () - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3") - #SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3") - #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3") - -MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}") -IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") - ADD_DEFINITIONS("-D_TD_ARM_") -ELSE () - ADD_DEFINITIONS("-msse4.2 -mfma") -ENDIF () + IF (${SANITIZER} MATCHES "true") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3") + MESSAGE(STATUS "Will compile with Address Sanitizer!") + ELSE () + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3") + ENDIF () + + MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}") + IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") + ADD_DEFINITIONS("-D_TD_ARM_") + ELSE () + ADD_DEFINITIONS("-msse4.2 -mfma") + ENDIF () ENDIF () diff --git a/example/src/demoapi.c b/example/src/demoapi.c index ede13b4bb8bcfbe90810d5bad252219ba0c251a4..b1efdb21b961da2046906f269fc63527ce45f710 100644 --- a/example/src/demoapi.c +++ b/example/src/demoapi.c @@ -65,22 +65,32 @@ static void prepare_data(TAOS* taos) { usleep(100000); taos_select_db(taos, "test"); - res = taos_query(taos, "create table meters(ts timestamp, f float, n int, b binary(20)) tags(area int, localtion binary(20));"); + res = taos_query(taos, "create table meters(ts timestamp, f float, n int, b binary(20), c nchar(20)) tags(area int, city binary(20), dist nchar(20));"); taos_free_result(res); char command[1024] = {0}; for (int64_t i = 0; i < g_num_of_tb; i ++) { - sprintf(command, "create table t%"PRId64" using meters tags(%"PRId64", '%s');", - i, i, (i%2)?"beijing":"shanghai"); +// sprintf(command, "create table t%"PRId64" using meters tags(%"PRId64", '%s', '%s');", +// i, i, (i%2)?"beijing":"shanghai", (i%2)?"朝阳区":"黄浦区"); + sprintf(command, "create table t%"PRId64" using meters tags(%"PRId64", '%s', '%s');", + i, i, (i%2)?"beijing":"shanghai", (i%2)?"chaoyang":"huangpu"); res = taos_query(taos, command); + if ((res) && (0 == taos_errno(res))) { + okPrint("t%" PRId64 " created\n", i); + } else { + errorPrint("%s() LN%d: %s\n", + __func__, __LINE__, taos_errstr(res)); + } taos_free_result(res); int64_t j = 0; int64_t total = 0; int64_t affected; for (; j < g_num_of_rec -1; j ++) { - sprintf(command, "insert into t%"PRId64" values(%" PRId64 ", %f, %"PRId64", '%c%d')", - i, 1650000000000+j, (float)j, j, 'a'+(int)j%10, rand()); + sprintf(command, "insert into t%"PRId64" " + "values(%" PRId64 ", %f, %"PRId64", '%c%d', '%c%d')", + i, 1650000000000+j, (float)j, j, 'a'+(int)j%25, rand(), + 'z' - (int)j%25, rand()); res = taos_query(taos, command); if ((res) && (0 == taos_errno(res))) { affected = taos_affected_rows(res); @@ -91,7 +101,7 @@ static void prepare_data(TAOS* taos) { } taos_free_result(res); } - sprintf(command, "insert into t%"PRId64" values(%" PRId64 ", NULL, NULL, NULL)", + sprintf(command, "insert into t%"PRId64" values(%" PRId64 ", NULL, NULL, NULL, NULL)", i, 1650000000000+j+1); res = taos_query(taos, command); if ((res) && (0 == taos_errno(res))) { @@ -107,12 +117,16 @@ static void prepare_data(TAOS* taos) { } } -static int print_result(TAOS_RES* res, int block) { +static int print_result(char *tbname, TAOS_RES* res, int block) { int64_t num_rows = 0; TAOS_ROW row = NULL; int num_fields = taos_num_fields(res); TAOS_FIELD* fields = taos_fetch_fields(res); + for (int f = 0; f < num_fields; f++) { + printf("fields[%d].name=%s, fields[%d].type=%d, fields[%d].bytes=%d\n", + f, fields[f].name, f, fields[f].type, f, fields[f].bytes); + } if (block) { warnPrint("%s() LN%d, call taos_fetch_block()\n", __func__, __LINE__); int rows = 0; @@ -126,6 +140,16 @@ static int print_result(TAOS_RES* res, int block) { taos_print_row(temp, row, fields, num_fields); puts(temp); num_rows ++; + + int* lengths = taos_fetch_lengths(res); + if (lengths) { + for (int c = 0; c < num_fields; c++) { + printf("length of column %d is %d\n", c, lengths[c]); + } + } else { + errorPrint("%s() LN%d: %s's lengths is NULL\n", + __func__, __LINE__, tbname); + } } } @@ -134,28 +158,21 @@ static int print_result(TAOS_RES* res, int block) { static void verify_query(TAOS* taos) { // TODO: select count(tbname) from stable once stable query work + // + char tbname[193] = {0}; char command[1024] = {0}; for (int64_t i = 0; i < g_num_of_tb; i++) { - sprintf(command, "select * from t%"PRId64"", i); + sprintf(tbname, "t%"PRId64"", i); + sprintf(command, "select * from %s", tbname); TAOS_RES* res = taos_query(taos, command); if (res) { if (0 == taos_errno(res)) { int field_count = taos_field_count(res); printf("field_count: %d\n", field_count); - int* lengths = taos_fetch_lengths(res); - if (lengths) { - for (int c = 0; c < field_count; c++) { - printf("length of column %d is %d\n", c, lengths[c]); - } - } else { - errorPrint("%s() LN%d: t%"PRId64"'s lengths is NULL\n", - __func__, __LINE__, i); - } - - int64_t rows = print_result(res, i % 2); - printf("rows is: %"PRId64"\n", rows); + int64_t rows = print_result(tbname, res, i % 2); + printf("rows is: %"PRId64"\n", rows); } else { errorPrint("%s() LN%d: %s\n", diff --git a/examples/lua/build.sh b/examples/lua/build.sh index 9d00c6842515415034ce0b5dc71d5d6af9ffc881..1e6fef632ceb828c9e0eca1a02dc4a6654906474 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 76634ed2545fb0ce0b43291dbf1b486086b34669..3c13b196b991a6bdf18493c111d37028fcb5de9a 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 e67c94f5ad2d59ca37d420e1a87a79bdef8316a7..4e89beabcb34a1522b2b370c40d964774984ebef 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, @@ -86,30 +84,31 @@ enum { typedef enum _mgmt_table { TSDB_MGMT_TABLE_START, - TSDB_MGMT_TABLE_ACCT, - TSDB_MGMT_TABLE_USER, - TSDB_MGMT_TABLE_DB, - TSDB_MGMT_TABLE_TABLE, TSDB_MGMT_TABLE_DNODE, TSDB_MGMT_TABLE_MNODE, + TSDB_MGMT_TABLE_MODULE, TSDB_MGMT_TABLE_QNODE, TSDB_MGMT_TABLE_SNODE, TSDB_MGMT_TABLE_BNODE, - TSDB_MGMT_TABLE_VGROUP, + TSDB_MGMT_TABLE_CLUSTER, + TSDB_MGMT_TABLE_DB, + TSDB_MGMT_TABLE_FUNC, + TSDB_MGMT_TABLE_INDEX, TSDB_MGMT_TABLE_STB, - TSDB_MGMT_TABLE_MODULE, - TSDB_MGMT_TABLE_QUERIES, TSDB_MGMT_TABLE_STREAMS, - TSDB_MGMT_TABLE_VARIABLES, - TSDB_MGMT_TABLE_CONNS, - TSDB_MGMT_TABLE_TRANS, + TSDB_MGMT_TABLE_TABLE, + TSDB_MGMT_TABLE_USER, TSDB_MGMT_TABLE_GRANTS, + TSDB_MGMT_TABLE_VGROUP, + TSDB_MGMT_TABLE_TOPICS, + TSDB_MGMT_TABLE_CONSUMERS, + TSDB_MGMT_TABLE_SUBSCRIBES, + TSDB_MGMT_TABLE_TRANS, + TSDB_MGMT_TABLE_SMAS, + TSDB_MGMT_TABLE_CONFIGS, + TSDB_MGMT_TABLE_CONNS, + TSDB_MGMT_TABLE_QUERIES, TSDB_MGMT_TABLE_VNODES, - TSDB_MGMT_TABLE_CLUSTER, - TSDB_MGMT_TABLE_STREAMTABLES, - TSDB_MGMT_TABLE_TP, - TSDB_MGMT_TABLE_FUNC, - TSDB_MGMT_TABLE_INDEX, TSDB_MGMT_TABLE_MAX, } EShowType; @@ -345,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; @@ -363,7 +362,7 @@ typedef struct { int32_t maxTimeSeries; int32_t maxStreams; int32_t accessState; // Configured only by command - int64_t maxStorage; // In unit of GB + int64_t maxStorage; } SCreateAcctReq, SAlterAcctReq; int32_t tSerializeSCreateAcctReq(void* buf, int32_t bufLen, SCreateAcctReq* pReq); @@ -1047,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; @@ -1683,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 { @@ -1698,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 { @@ -1720,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); @@ -1750,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); } @@ -1778,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; } @@ -1884,7 +1901,6 @@ typedef struct { char topicName[TSDB_TOPIC_FNAME_LEN]; char cgroup[TSDB_CGROUP_LEN]; char* sql; - char* logicalPlan; char* physicalPlan; char* qmsg; } SMqSetCVgReq; @@ -1898,7 +1914,6 @@ static FORCE_INLINE int32_t tEncodeSMqSetCVgReq(void** buf, const SMqSetCVgReq* tlen += taosEncodeString(buf, pReq->topicName); tlen += taosEncodeString(buf, pReq->cgroup); tlen += taosEncodeString(buf, pReq->sql); - tlen += taosEncodeString(buf, pReq->logicalPlan); tlen += taosEncodeString(buf, pReq->physicalPlan); tlen += taosEncodeString(buf, pReq->qmsg); return tlen; @@ -1912,7 +1927,6 @@ static FORCE_INLINE void* tDecodeSMqSetCVgReq(void* buf, SMqSetCVgReq* pReq) { buf = taosDecodeStringTo(buf, pReq->topicName); buf = taosDecodeStringTo(buf, pReq->cgroup); buf = taosDecodeString(buf, &pReq->sql); - buf = taosDecodeString(buf, &pReq->logicalPlan); buf = taosDecodeString(buf, &pReq->physicalPlan); buf = taosDecodeString(buf, &pReq->qmsg); return buf; diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 7840d1825661b97eb194f41cd0bf108c8ee7883e..0137b714797eff64ddc91e6bfd30828bb8d3379b 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -183,47 +183,48 @@ #define TK_LAST 165 #define TK_NOW 166 #define TK_TODAY 167 -#define TK_ROWTS 168 -#define TK_TBNAME 169 -#define TK_QSTARTTS 170 -#define TK_QENDTS 171 -#define TK_WSTARTTS 172 -#define TK_WENDTS 173 -#define TK_WDURATION 174 -#define TK_BETWEEN 175 -#define TK_IS 176 -#define TK_NK_LT 177 -#define TK_NK_GT 178 -#define TK_NK_LE 179 -#define TK_NK_GE 180 -#define TK_NK_NE 181 -#define TK_MATCH 182 -#define TK_NMATCH 183 -#define TK_JOIN 184 -#define TK_INNER 185 -#define TK_SELECT 186 -#define TK_DISTINCT 187 -#define TK_WHERE 188 -#define TK_PARTITION 189 -#define TK_BY 190 -#define TK_SESSION 191 -#define TK_STATE_WINDOW 192 -#define TK_SLIDING 193 -#define TK_FILL 194 -#define TK_VALUE 195 -#define TK_NONE 196 -#define TK_PREV 197 -#define TK_LINEAR 198 -#define TK_NEXT 199 -#define TK_GROUP 200 -#define TK_HAVING 201 -#define TK_ORDER 202 -#define TK_SLIMIT 203 -#define TK_SOFFSET 204 -#define TK_LIMIT 205 -#define TK_OFFSET 206 -#define TK_ASC 207 -#define TK_NULLS 208 +#define TK_CAST 168 +#define TK_ROWTS 169 +#define TK_TBNAME 170 +#define TK_QSTARTTS 171 +#define TK_QENDTS 172 +#define TK_WSTARTTS 173 +#define TK_WENDTS 174 +#define TK_WDURATION 175 +#define TK_BETWEEN 176 +#define TK_IS 177 +#define TK_NK_LT 178 +#define TK_NK_GT 179 +#define TK_NK_LE 180 +#define TK_NK_GE 181 +#define TK_NK_NE 182 +#define TK_MATCH 183 +#define TK_NMATCH 184 +#define TK_JOIN 185 +#define TK_INNER 186 +#define TK_SELECT 187 +#define TK_DISTINCT 188 +#define TK_WHERE 189 +#define TK_PARTITION 190 +#define TK_BY 191 +#define TK_SESSION 192 +#define TK_STATE_WINDOW 193 +#define TK_SLIDING 194 +#define TK_FILL 195 +#define TK_VALUE 196 +#define TK_NONE 197 +#define TK_PREV 198 +#define TK_LINEAR 199 +#define TK_NEXT 200 +#define TK_GROUP 201 +#define TK_HAVING 202 +#define TK_ORDER 203 +#define TK_SLIMIT 204 +#define TK_SOFFSET 205 +#define TK_LIMIT 206 +#define TK_OFFSET 207 +#define TK_ASC 208 +#define TK_NULLS 209 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/common/ttypes.h b/include/common/ttypes.h index 1bce57f1911884b71aca5706ffa1307ef2a57802..23b260849dc382ffaca7466b782d21698dd8b93d 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -181,6 +181,7 @@ typedef struct { #define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT) #define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT) #define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE) +#define IS_INTEGER_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t))) #define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t))) #define IS_MATHABLE_TYPE(_t) (IS_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP)) diff --git a/include/dnode/mnode/mnode.h b/include/dnode/mnode/mnode.h index 9e5f8a4ddd213434de9b4f162d777a529a3796c2..98481259194ba6f87e99e7c465d21c84244747ef 100644 --- a/include/dnode/mnode/mnode.h +++ b/include/dnode/mnode/mnode.h @@ -74,26 +74,12 @@ void mndStop(SMnode *pMnode); * @brief Get mnode monitor info. * * @param pMnode The mnode object. - * @param pClusterInfo - * @param pVgroupInfo - * @param pGrantInfo + * @param pCluster + * @param pVgroup + * @param pGrant * @return int32_t 0 for success, -1 for failure. */ -int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgroupInfo *pVgroupInfo, - SMonGrantInfo *pGrantInfo); - -/** - * @brief Get user authentication info. - * - * @param pMnode The mnode object. - * @param user - * @param spi - * @param encrypt - * @param secret - * @param ckey - * @return int32_t 0 for success, -1 for failure. - */ -int32_t mndRetriveAuth(SMnode *pMnode, char *user, char *spi, char *encrypt, char *secret, char *ckey); +int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pCluster, SMonVgroupInfo *pVgroup, SMonGrantInfo *pGrant); /** * @brief Process the read, write, sync request. @@ -105,7 +91,6 @@ int32_t mndProcessMsg(SNodeMsg *pMsg); /** * @brief Generate machine code - * */ void mndGenerateMachineCode(); diff --git a/include/libs/function/function.h b/include/libs/function/function.h index 9fa89f041578e73045aa2a886ce23757230542d1..1303a1fb6accb9894f875d4a22ba1e35e8129c48 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 148a9f77d6081596332ac1dc4244e86317d69427..a471de3147a999afbec8346afb08ebc833699b12 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -123,7 +123,7 @@ void fmFuncMgtDestroy(); int32_t fmGetFuncInfo(const char* pFuncName, int32_t* pFuncId, int32_t* pFuncType); -int32_t fmGetFuncResultType(SFunctionNode* pFunc); +int32_t fmGetFuncResultType(SFunctionNode* pFunc, char* pErrBuf, int32_t len); bool fmIsAggFunc(int32_t funcId); bool fmIsScalarFunc(int32_t funcId); diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 7d0d0137ec12e9ae311dcfd6a23c4521486db7d7..e1a63bd66bdea3567a5671abf3869b09db71cb21 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -267,6 +267,11 @@ typedef struct SDescribeStmt { STableMeta* pMeta; } SDescribeStmt; +typedef struct SKillStmt { + ENodeType type; + int32_t targetId; +} SKillStmt; + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 4ffacf3787e201b2de55bcbf1f952c1c666ed057..02636a178e403e82d4d6c0ac9be8279b70f510d5 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -52,7 +52,8 @@ extern "C" { for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); (NULL != cell ? (node = &(cell->pNode), true) : (node = NULL, false)); cell = cell->pNext) typedef enum ENodeType { - // Syntax nodes are used in parser and planner module, and some are also used in executor module, such as COLUMN, VALUE, OPERATOR, FUNCTION and so on. + // Syntax nodes are used in parser and planner module, and some are also used in executor module, such as COLUMN, + // VALUE, OPERATOR, FUNCTION and so on. QUERY_NODE_COLUMN = 1, QUERY_NODE_VALUE, QUERY_NODE_OPERATOR, @@ -69,7 +70,7 @@ typedef enum ENodeType { QUERY_NODE_INTERVAL_WINDOW, QUERY_NODE_NODE_LIST, QUERY_NODE_FILL, - QUERY_NODE_RAW_EXPR, // Only be used in parser module. + QUERY_NODE_RAW_EXPR, // Only be used in parser module. QUERY_NODE_TARGET, QUERY_NODE_DATABLOCK_DESC, QUERY_NODE_SLOT_DESC, @@ -126,30 +127,30 @@ typedef enum ENodeType { QUERY_NODE_REDISTRIBUTE_VGROUP_STMT, QUERY_NODE_SPLIT_VGROUP_STMT, QUERY_NODE_SYNCDB_STMT, - QUERY_NODE_SHOW_DATABASES_STMT, - QUERY_NODE_SHOW_TABLES_STMT, - QUERY_NODE_SHOW_STABLES_STMT, - QUERY_NODE_SHOW_USERS_STMT, QUERY_NODE_SHOW_DNODES_STMT, - QUERY_NODE_SHOW_VGROUPS_STMT, QUERY_NODE_SHOW_MNODES_STMT, QUERY_NODE_SHOW_MODULES_STMT, QUERY_NODE_SHOW_QNODES_STMT, + QUERY_NODE_SHOW_SNODES_STMT, + QUERY_NODE_SHOW_BNODES_STMT, + QUERY_NODE_SHOW_DATABASES_STMT, QUERY_NODE_SHOW_FUNCTIONS_STMT, QUERY_NODE_SHOW_INDEXES_STMT, + QUERY_NODE_SHOW_STABLES_STMT, QUERY_NODE_SHOW_STREAMS_STMT, - QUERY_NODE_SHOW_APPS_STMT, - QUERY_NODE_SHOW_CONNECTIONS_STMT, + QUERY_NODE_SHOW_TABLES_STMT, + QUERY_NODE_SHOW_USERS_STMT, QUERY_NODE_SHOW_LICENCE_STMT, - QUERY_NODE_SHOW_CREATE_DATABASE_STMT, - QUERY_NODE_SHOW_CREATE_TABLE_STMT, - QUERY_NODE_SHOW_CREATE_STABLE_STMT, - QUERY_NODE_SHOW_QUERIES_STMT, - QUERY_NODE_SHOW_SCORES_STMT, + QUERY_NODE_SHOW_VGROUPS_STMT, QUERY_NODE_SHOW_TOPICS_STMT, - QUERY_NODE_SHOW_VARIABLE_STMT, - QUERY_NODE_SHOW_BNODES_STMT, - QUERY_NODE_SHOW_SNODES_STMT, + QUERY_NODE_SHOW_CONSUMERS_STMT, + QUERY_NODE_SHOW_SUBSCRIBES_STMT, + QUERY_NODE_SHOW_TRANS_STMT, + QUERY_NODE_SHOW_SMAS_STMT, + QUERY_NODE_SHOW_CONFIGS_STMT, + QUERY_NODE_SHOW_CONNECTIONS_STMT, + QUERY_NODE_SHOW_QUERIES_STMT, + QUERY_NODE_SHOW_VNODES_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 fef624288a7eff2ce9ca83447d20076e15b76149..02cd07322622ab56ccc257f8f4bec140cecb73b7 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/scalar/scalar.h b/include/libs/scalar/scalar.h index 10b4866a965a47aafc03232c9f73168c30d6f597..49af10cd2cfad2c089f13051479284391fae6b3d 100644 --- a/include/libs/scalar/scalar.h +++ b/include/libs/scalar/scalar.h @@ -78,6 +78,8 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam * int32_t toUnixtimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); +int32_t nowFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); +int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); bool getTimePseudoFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); diff --git a/include/libs/scheduler/scheduler.h b/include/libs/scheduler/scheduler.h index 5ab4ead89cde7e0fab4616f9445b0a805ea0d04b..460749243c9b4e7352b409869d613955c1ae0916 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 e516000c66cb24f3f12c41007d7996fe35f2e3a4..4efe69e2046ab33d4a181894adc9c1eac4fe6ff2 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/taoserror.h b/include/util/taoserror.h index 60535e2f493a3bcb1769f067fb7e13a6fb715452..e31eea1b157cf73ac54c7dd42e2c7c803c26d83f 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -566,8 +566,6 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_AMBIGUOUS_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2603) #define TSDB_CODE_PAR_WRONG_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x2604) #define TSDB_CODE_PAR_INVALID_FUNTION TAOS_DEF_ERROR_CODE(0, 0x2605) -#define TSDB_CODE_PAR_FUNTION_PARA_NUM TAOS_DEF_ERROR_CODE(0, 0x2606) -#define TSDB_CODE_PAR_FUNTION_PARA_TYPE TAOS_DEF_ERROR_CODE(0, 0x2607) #define TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION TAOS_DEF_ERROR_CODE(0, 0x2608) #define TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT TAOS_DEF_ERROR_CODE(0, 0x2609) #define TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION TAOS_DEF_ERROR_CODE(0, 0x260A) @@ -601,7 +599,12 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_INVALID_KEEP_UNIT TAOS_DEF_ERROR_CODE(0, 0x2626) //planner -#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700) +#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700) + +//function +#define TSDB_CODE_FUNC_FUNTION_ERROR TAOS_DEF_ERROR_CODE(0, 0x2800) +#define TSDB_CODE_FUNC_FUNTION_PARA_NUM TAOS_DEF_ERROR_CODE(0, 0x2801) +#define TSDB_CODE_FUNC_FUNTION_PARA_TYPE TAOS_DEF_ERROR_CODE(0, 0x2802) #ifdef __cplusplus } diff --git a/include/util/tarray.h b/include/util/tarray.h index 521e54040d6abd8ac53af11d830325bc3b5c053c..383af8309d5798e1d445a1fda2f7abeb7b53f2ea 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 eeaa34007a5ed173ca505254f30418ed0623a0db..5fc30540ee6ad58563795dd1d04c0ef92406d109 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -106,6 +106,7 @@ extern const int32_t TYPE_BYTES[15]; #define TSDB_INS_TABLE_MODULES "modules" #define TSDB_INS_TABLE_QNODES "qnodes" #define TSDB_INS_TABLE_BNODES "bnodes" +#define TSDB_INS_TABLE_SNODES "snodes" #define TSDB_INS_TABLE_CLUSTER "cluster" #define TSDB_INS_TABLE_USER_DATABASES "user_databases" #define TSDB_INS_TABLE_USER_FUNCTIONS "user_functions" @@ -115,10 +116,24 @@ extern const int32_t TYPE_BYTES[15]; #define TSDB_INS_TABLE_USER_TABLES "user_tables" #define TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED "user_table_distributed" #define TSDB_INS_TABLE_USER_USERS "user_users" -#define TSDB_INS_TABLE_VGROUPS "vgroups" -#define TSDB_INS_TABLE_BNODES "bnodes" -#define TSDB_INS_TABLE_SNODES "snodes" #define TSDB_INS_TABLE_LICENCES "grants" +#define TSDB_INS_TABLE_VGROUPS "vgroups" +#define TSDB_INS_TABLE_TOPICS "topics" +#define TSDB_INS_TABLE_CONSUMERS "consumers" +#define TSDB_INS_TABLE_SUBSCRIBES "subscribes" +#define TSDB_INS_TABLE_TRANS "trans" +#define TSDB_INS_TABLE_SMAS "smas" +#define TSDB_INS_TABLE_CONFIGS "configs" +#define TSDB_INS_TABLE_CONNS "connections" +#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" @@ -498,6 +513,15 @@ enum { #define QNODE_HANDLE 1 #define DEFAULT_HANDLE 0 +#define TSDB_CONFIG_OPTION_LEN 16 +#define TSDB_CONIIG_VALUE_LEN 48 +#define TSDB_CONFIG_NUMBER 8 + +#define QUERY_ID_SIZE 20 +#define QUERY_OBJ_ID_SIZE 18 +#define SUBQUERY_INFO_SIZE 6 +#define QUERY_SAVE_SIZE 20 + #define MAX_NUM_STR_SIZE 40 diff --git a/include/util/tencode.h b/include/util/tencode.h index cdde378b69f7954c168fb633b83139967b37545c..7c877ae4283fc662cf5cd43d59b571e931b08a02 100644 --- a/include/util/tencode.h +++ b/include/util/tencode.h @@ -18,7 +18,6 @@ #include "tcoding.h" #include "tfreelist.h" -#include "tmacro.h" #ifdef __cplusplus extern "C" { diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 0f12880272d0d10aebdc00482bafe4972691b60a..772ff5e69afe566c2f7f53394e8b409c051f6ae3 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 0000000000000000000000000000000000000000..c29361758dda67b079ca613651550c8d3ccb5ca8 --- /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 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index fec6c8e5db5d53e15f46b506aff9bcf1c1807246..865c3ead27ce59c29f7815d5ba4c9694056c458b 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 82788b2e112efb5c8baa9cb01f93052045dba451..a6678b2ec0881e74f1fa4c18723285258b1bf6c8 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 96a7230ff3df8ef336d457b8a23231522f2ad216..74b8e711dcc31e9dba4d934c27686d675a9b7a2d 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 e293c8923d3d5f1b329cbe71cb5f7e44ef301820..73ac0592763debae2d19096377795ed144dd5a6f 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,9 +471,13 @@ 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) return -1; + if (pResultInfo == NULL) { + (*numOfRows) = 0; + return 0; + } pResultInfo->current = pResultInfo->numOfRows; (*numOfRows) = pResultInfo->numOfRows; @@ -562,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; + } -TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision) { - // TODO - return NULL; + return stmtAffectedRows(stmt); } int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind) { - // TODO - return -1; + 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) { - // TODO - return -1; + 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) { - // TODO - return -1; + 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) { - // TODO - return -1; + 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) { - // TODO - return -1; + 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) { - // TODO - return -1; + 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) { - // TODO - return -1; + 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) { - // TODO - return NULL; + 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 -1; + return NULL; } + + diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 67c5679cac5156b21ce0b892e6d0d824854c0f6a..74347cabf7bd66170485fa370e313cb421e07024 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 0000000000000000000000000000000000000000..8c4cff92514cc8c850c9a25458865c1741cf2045 --- /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/tglobal.c b/source/common/src/tglobal.c index 2ab8af31b1a74bcb44b2b61bf0a7267fb0446b04..9226e9aa37e25e8ce7c8faed5345588c84229d74 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -495,7 +495,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { tsRpcTimer = cfgGetItem(pCfg, "rpcTimer")->i32; tsRpcMaxTime = cfgGetItem(pCfg, "rpcMaxTime")->i32; tsRpcForceTcp = cfgGetItem(pCfg, "rpcForceTcp")->i32; - tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->bval; + tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32; tsCompressMsgSize = cfgGetItem(pCfg, "compressMsgSize")->i32; tsCompressColData = cfgGetItem(pCfg, "compressColData")->i32; tsMaxWildCardsLen = cfgGetItem(pCfg, "maxWildCardsLength")->i32; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 821f24eedcd74c5b823f2bcf23c21afb20ec089c..3e37c52c26207ee5134c1c41f2d71132dd1c47a2 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}; @@ -2184,7 +2295,6 @@ int32_t tSerializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableReq if (tStartEncode(&encoder) < 0) return -1; if (tEncodeI64(&encoder, pReq->showId) < 0) return -1; if (tEncodeI32(&encoder, pReq->type) < 0) return -1; -// if (tEncodeI8(&encoder, pReq->free) < 0) return -1; if (tEncodeCStr(&encoder, pReq->db) < 0) return -1; if (tEncodeCStr(&encoder, pReq->tb) < 0) return -1; tEndEncode(&encoder); @@ -2201,7 +2311,6 @@ int32_t tDeserializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableR if (tStartDecode(&decoder) < 0) return -1; if (tDecodeI64(&decoder, &pReq->showId) < 0) return -1; if (tDecodeI32(&decoder, &pReq->type) < 0) return -1; -// if (tDecodeI8(&decoder, &pReq->free) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->tb) < 0) return -1; tEndDecode(&decoder); @@ -2569,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; @@ -2588,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/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index 91c4724372456cf8672ceaeca2fde316858dffc0..38885333c9253badd1d9af26cb6ee74510269c80 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -174,7 +174,6 @@ void mmInitMsgHandle(SMgmtWrapper *pWrapper) { dmSetMsgHandle(pWrapper, TDMT_MND_KILL_QUERY, mmProcessWriteMsg, DEFAULT_HANDLE); dmSetMsgHandle(pWrapper, TDMT_MND_KILL_CONN, mmProcessWriteMsg, DEFAULT_HANDLE); dmSetMsgHandle(pWrapper, TDMT_MND_HEARTBEAT, mmProcessWriteMsg, DEFAULT_HANDLE); - dmSetMsgHandle(pWrapper, TDMT_MND_SHOW, mmProcessReadMsg, DEFAULT_HANDLE); dmSetMsgHandle(pWrapper, TDMT_MND_SYSTABLE_RETRIEVE, mmProcessReadMsg, DEFAULT_HANDLE); dmSetMsgHandle(pWrapper, TDMT_MND_STATUS, mmProcessReadMsg, DEFAULT_HANDLE); dmSetMsgHandle(pWrapper, TDMT_MND_KILL_TRANS, mmProcessWriteMsg, DEFAULT_HANDLE); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index ff92cf880b0107f2544d0ef58664fc41c65464f7..2fb29ce944ac4e5f0ee7e6386a76111af6dc4942 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c @@ -115,7 +115,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO } } - vnodeProcessWMsgs(pVnode->pImpl, pArray); + vnodePreprocessWriteReqs(pVnode->pImpl, pArray); numOfMsgs = taosArrayGetSize(pArray); for (int32_t i = 0; i < numOfMsgs; i++) { @@ -123,7 +123,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO SRpcMsg *pRpc = &pMsg->rpcMsg; SRpcMsg *pRsp = NULL; - int32_t code = vnodeApplyWMsg(pVnode->pImpl, pRpc, &pRsp); + int32_t code = vnodeProcessWriteReq(pVnode->pImpl, pRpc, &pRsp); if (pRsp != NULL) { pRsp->ahandle = pRpc->ahandle; tmsgSendRsp(pRsp); @@ -153,7 +153,7 @@ static void vmProcessApplyQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO // todo SRpcMsg *pRsp = NULL; - (void)vnodeApplyWMsg(pVnode->pImpl, &pMsg->rpcMsg, &pRsp); + (void)vnodeProcessWriteReq(pVnode->pImpl, &pMsg->rpcMsg, &pRsp); } } diff --git a/source/dnode/mgmt/test/sut/inc/sut.h b/source/dnode/mgmt/test/sut/inc/sut.h index 1dd68574fec694231fb2d903e41ca35873a67518..268f779fcf81900d990b4327efbdc9be1f482442 100644 --- a/source/dnode/mgmt/test/sut/inc/sut.h +++ b/source/dnode/mgmt/test/sut/inc/sut.h @@ -20,7 +20,6 @@ #include "os.h" #include "dnode.h" -#include "tmsg.h" #include "tdataformat.h" #include "tglobal.h" #include "tmsg.h" @@ -48,92 +47,61 @@ class Testbase { int32_t connId; public: - void SendShowMetaReq(int8_t showType, const char* db); - void SendShowRetrieveReq(); - - STableMetaRsp* GetShowMeta(); - SRetrieveTableRsp* GetRetrieveRsp(); + int32_t SendShowReq(int8_t showType, const char *tb, const char* db); + int32_t GetShowRows(); +#if 0 int32_t GetMetaNum(); const char* GetMetaTbName(); - int32_t GetMetaColId(int32_t index); - int8_t GetMetaType(int32_t index); - int32_t GetMetaBytes(int32_t index); - const char* GetMetaName(int32_t index); - - const char* GetShowName(); - int32_t GetShowRows(); - int8_t GetShowInt8(); - int16_t GetShowInt16(); - int32_t GetShowInt32(); - int64_t GetShowInt64(); - int64_t GetShowTimestamp(); - const char* GetShowBinary(int32_t len); + int8_t GetMetaType(int32_t col); + int32_t GetMetaBytes(int32_t col); + const char* GetMetaName(int32_t col); + + int8_t GetShowInt8(int32_t row, int32_t col); + int16_t GetShowInt16(int32_t row, int32_t col); + int32_t GetShowInt32(int32_t row, int32_t col); + int64_t GetShowInt64(int32_t row, int32_t col); + int64_t GetShowTimestamp(int32_t row, int32_t col); + const char* GetShowBinary(int32_t row, int32_t col); +#endif private: - int64_t showId; - STableMetaRsp metaRsp; - SRetrieveTableRsp* pRetrieveRsp; - char* pData; - int32_t pos; + SRetrieveMetaTableRsp* showRsp; }; +#if 0 + #define CHECK_META(tbName, numOfColumns) \ { \ EXPECT_EQ(test.GetMetaNum(), numOfColumns); \ EXPECT_STREQ(test.GetMetaTbName(), tbName); \ } -#define CHECK_SCHEMA(colId, type, bytes, colName) \ - { \ - EXPECT_EQ(test.GetMetaType(colId), type); \ - EXPECT_EQ(test.GetMetaBytes(colId), bytes); \ - EXPECT_STREQ(test.GetMetaName(colId), colName); \ - } - -#define CheckBinary(val, len) \ - { EXPECT_STREQ(test.GetShowBinary(len), val); } - -#define CheckBinaryByte(b, len) \ +#define CHECK_SCHEMA(col, type, bytes, colName) \ { \ - char* bytes = (char*)taosMemoryCalloc(1, len); \ - for (int32_t i = 0; i < len - 1; ++i) { \ - bytes[i] = b; \ - } \ - EXPECT_STREQ(test.GetShowBinary(len), bytes); \ + EXPECT_EQ(test.GetMetaType(col), type); \ + EXPECT_EQ(test.GetMetaBytes(col), bytes); \ + EXPECT_STREQ(test.GetMetaName(col), colName); \ } +#define CheckBinary(row, col, val) \ + { EXPECT_STREQ(test.GetShowBinary(row, col), val); } + #define CheckInt8(val) \ - { EXPECT_EQ(test.GetShowInt8(), val); } + { EXPECT_EQ(test.GetShowInt8(row, col), val); } #define CheckInt16(val) \ - { EXPECT_EQ(test.GetShowInt16(), val); } + { EXPECT_EQ(test.GetShowInt16(row, col), val); } #define CheckInt32(val) \ - { EXPECT_EQ(test.GetShowInt32(), val); } + { EXPECT_EQ(test.GetShowInt32row, col(), val); } #define CheckInt64(val) \ - { EXPECT_EQ(test.GetShowInt64(), val); } + { EXPECT_EQ(test.GetShowInt64(row, col), val); } #define CheckTimestamp() \ - { EXPECT_GT(test.GetShowTimestamp(), 0); } - -#define IgnoreBinary(len) \ - { test.GetShowBinary(len); } - -#define IgnoreInt8() \ - { test.GetShowInt8(); } - -#define IgnoreInt16() \ - { test.GetShowInt16(); } - -#define IgnoreInt32() \ - { test.GetShowInt32(); } - -#define IgnoreInt64() \ - { test.GetShowInt64(); } + { EXPECT_GT(test.GetShowTimestamp(row, col), 0); } -#define IgnoreTimestamp() \ - { test.GetShowTimestamp(); } +#endif #endif /* _TD_TEST_BASE_H_ */ diff --git a/source/dnode/mgmt/test/sut/src/sut.cpp b/source/dnode/mgmt/test/sut/src/sut.cpp index a805aecd7c73d6d0ea172757f4c365b3cf9a6312..9b4c4798653858ad22beb7ed637da3b6352674f4 100644 --- a/source/dnode/mgmt/test/sut/src/sut.cpp +++ b/source/dnode/mgmt/test/sut/src/sut.cpp @@ -49,16 +49,14 @@ void Testbase::Init(const char* path, int16_t port) { InitLog("/tmp/td"); server.Start(path, fqdn, port, firstEp); client.Init("root", "taosdata", fqdn, port); - - tFreeSTableMetaRsp(&metaRsp); - showId = 0; - pData = 0; - pos = 0; - pRetrieveRsp = NULL; + showRsp = NULL; } void Testbase::Cleanup() { - tFreeSTableMetaRsp(&metaRsp); + if (showRsp != NULL) { + rpcFreeCont(showRsp); + showRsp = NULL; + } client.Cleanup(); taosMsleep(10); server.Stop(); @@ -84,112 +82,40 @@ SRpcMsg* Testbase::SendReq(tmsg_t msgType, void* pCont, int32_t contLen) { return client.SendReq(&rpcMsg); } -void Testbase::SendShowMetaReq(int8_t showType, const char* db) { - SShowReq showReq = {0}; - showReq.type = showType; - strcpy(showReq.db, db); - - int32_t contLen = tSerializeSShowReq(NULL, 0, &showReq); - void* pReq = rpcMallocCont(contLen); - tSerializeSShowReq(pReq, contLen, &showReq); - tFreeSShowReq(&showReq); - - SRpcMsg* pRsp = SendReq(TDMT_MND_SHOW, pReq, contLen); - ASSERT(pRsp->pCont != nullptr); - - if (pRsp->contLen == 0) return; - - SShowRsp showRsp = {0}; - tDeserializeSShowRsp(pRsp->pCont, pRsp->contLen, &showRsp); - tFreeSTableMetaRsp(&metaRsp); - metaRsp = showRsp.tableMeta; - showId = showRsp.showId; -} - -int32_t Testbase::GetMetaColId(int32_t index) { - SSchema* pSchema = &metaRsp.pSchemas[index]; - return pSchema->colId; -} - -int8_t Testbase::GetMetaType(int32_t index) { - SSchema* pSchema = &metaRsp.pSchemas[index]; - return pSchema->type; -} - -int32_t Testbase::GetMetaBytes(int32_t index) { - SSchema* pSchema = &metaRsp.pSchemas[index]; - return pSchema->bytes; -} - -const char* Testbase::GetMetaName(int32_t index) { - SSchema* pSchema = &metaRsp.pSchemas[index]; - return pSchema->name; -} - -int32_t Testbase::GetMetaNum() { return metaRsp.numOfColumns; } - -const char* Testbase::GetMetaTbName() { return metaRsp.tbName; } +int32_t Testbase::SendShowReq(int8_t showType, const char *tb, const char* db) { + if (showRsp != NULL) { + rpcFreeCont(showRsp); + showRsp = NULL; + } -void Testbase::SendShowRetrieveReq() { SRetrieveTableReq retrieveReq = {0}; - retrieveReq.showId = showId; -// retrieveReq.free = 0; + retrieveReq.type = showType; + strcpy(retrieveReq.db, db); + strcpy(retrieveReq.tb, tb); int32_t contLen = tSerializeSRetrieveTableReq(NULL, 0, &retrieveReq); void* pReq = rpcMallocCont(contLen); tSerializeSRetrieveTableReq(pReq, contLen, &retrieveReq); -// SRpcMsg* pRsp = SendReq(TDMT_MND_SHOW_RETRIEVE, pReq, contLen); -// pRetrieveRsp = (SRetrieveTableRsp*)pRsp->pCont; -// pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows); -// pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds); -// pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen); - - pData = pRetrieveRsp->data; - pos = 0; -} - -const char* Testbase::GetShowName() { return metaRsp.tbName; } - -int8_t Testbase::GetShowInt8() { - int8_t data = *((int8_t*)(pData + pos)); - pos += sizeof(int8_t); - return data; -} - -int16_t Testbase::GetShowInt16() { - int16_t data = *((int16_t*)(pData + pos)); - pos += sizeof(int16_t); - return data; -} + SRpcMsg* pRsp = SendReq(TDMT_MND_SYSTABLE_RETRIEVE, pReq, contLen); + ASSERT(pRsp->pCont != nullptr); -int32_t Testbase::GetShowInt32() { - int32_t data = *((int32_t*)(pData + pos)); - pos += sizeof(int32_t); - return data; -} + if (pRsp->contLen == 0) return -1; -int64_t Testbase::GetShowInt64() { - int64_t data = *((int64_t*)(pData + pos)); - pos += sizeof(int64_t); - return data; -} + showRsp = (SRetrieveMetaTableRsp*)pRsp->pCont; + showRsp->handle = htobe64(showRsp->handle); // show Id + showRsp->useconds = htobe64(showRsp->useconds); + showRsp->numOfRows = htonl(showRsp->numOfRows); + showRsp->compLen = htonl(showRsp->compLen); + if (showRsp->numOfRows <= 0) return -1; -int64_t Testbase::GetShowTimestamp() { - int64_t data = *((int64_t*)(pData + pos)); - pos += sizeof(int64_t); - return data; + return 0; } -const char* Testbase::GetShowBinary(int32_t len) { - pos += sizeof(VarDataLenT); - char* data = (char*)(pData + pos); - pos += len; - return data; +int32_t Testbase::GetShowRows() { + if (showRsp != NULL) { + return showRsp->numOfRows; + } else { + return 0; + } } - -int32_t Testbase::GetShowRows() { return pRetrieveRsp->numOfRows; } - -STableMetaRsp* Testbase::GetShowMeta() { return &metaRsp; } - -SRetrieveTableRsp* Testbase::GetRetrieveRsp() { return pRetrieveRsp; } diff --git a/source/dnode/mnode/impl/inc/mndDb.h b/source/dnode/mnode/impl/inc/mndDb.h index c0b25d74d1f302e2947ae4706c6c4b0474d53819..146c6e2523c441ed94444f22e6f6e94d6eff5171 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/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index e827dd5131872b956d8dea9c4d3e4a6f02a9fc81..5b96416fd719ea5b50ddc275f5165a50c4d4f535 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -213,7 +213,7 @@ typedef struct { int32_t maxConsumers; int32_t maxConns; int32_t maxTopics; - int64_t maxStorage; // In unit of GB + int64_t maxStorage; int32_t accessState; // Configured only by command } SAcctCfg; @@ -379,20 +379,20 @@ typedef struct { } SFuncObj; typedef struct { - int64_t id; - int8_t type; - int8_t replica; - int16_t numOfColumns; - int32_t rowSize; - int32_t numOfRows; - int32_t payloadLen; - void* pIter; - SMnode* pMnode; + int64_t id; + int8_t type; + int8_t replica; + int16_t numOfColumns; + int32_t rowSize; + int32_t numOfRows; + int32_t payloadLen; + void* pIter; + SMnode* pMnode; STableMetaRsp* pMeta; - bool sysDbRsp; - char db[TSDB_DB_FNAME_LEN]; - int16_t offset[TSDB_MAX_COLUMNS]; - int32_t bytes[TSDB_MAX_COLUMNS]; + bool sysDbRsp; + char db[TSDB_DB_FNAME_LEN]; + int16_t offset[TSDB_MAX_COLUMNS]; + int32_t bytes[TSDB_MAX_COLUMNS]; } SShowObj; typedef struct { @@ -625,14 +625,14 @@ static FORCE_INLINE void* tDecodeSubscribeObj(void* buf, SMqSubscribeObj* pSub) static FORCE_INLINE void tDeleteSMqSubscribeObj(SMqSubscribeObj* pSub) { if (pSub->consumers) { - //taosArrayDestroyEx(pSub->consumers, (void (*)(void*))tDeleteSMqSubConsumer); - // taosArrayDestroy(pSub->consumers); + // taosArrayDestroyEx(pSub->consumers, (void (*)(void*))tDeleteSMqSubConsumer); + // taosArrayDestroy(pSub->consumers); pSub->consumers = NULL; } if (pSub->unassignedVg) { - //taosArrayDestroyEx(pSub->unassignedVg, (void (*)(void*))tDeleteSMqConsumerEp); - // taosArrayDestroy(pSub->unassignedVg); + // taosArrayDestroyEx(pSub->unassignedVg, (void (*)(void*))tDeleteSMqConsumerEp); + // taosArrayDestroy(pSub->unassignedVg); pSub->unassignedVg = NULL; } } @@ -647,8 +647,9 @@ typedef struct { int32_t version; SRWLatch lock; int32_t sqlLen; + int32_t astLen; char* sql; - char* logicalPlan; + char* ast; char* physicalPlan; SSchemaWrapper schema; } SMqTopicObj; diff --git a/source/dnode/mnode/impl/inc/mndInfoSchema.h b/source/dnode/mnode/impl/inc/mndInfoSchema.h index 7db41254027c3c2924e094ae806bbcc8907f0981..3aea99a909e02796dfbd9862c56339f9f1ba27c4 100644 --- a/source/dnode/mnode/impl/inc/mndInfoSchema.h +++ b/source/dnode/mnode/impl/inc/mndInfoSchema.h @@ -23,20 +23,20 @@ extern "C" { #endif typedef struct SInfosTableSchema { - char *name; - int32_t type; - int32_t bytes; + const char *name; + const int32_t type; + const int32_t bytes; } SInfosTableSchema; typedef struct SInfosTableMeta { - char *name; + const char *name; const SInfosTableSchema *schema; - int32_t colNum; + const int32_t colNum; } SInfosTableMeta; -int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp); int32_t mndInitInfos(SMnode *pMnode); -void mndCleanupInfos(SMnode *pMnode); +void mndCleanupInfos(SMnode *pMnode); +int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/inc/mndInt.h b/source/dnode/mnode/impl/inc/mndInt.h index 11c1b09cc9c10c23d0279fcf35dfac92790f01ad..7b67308876a661252c2c3c0884307cfb6e8fba33 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/include/util/tmacro.h b/source/dnode/mnode/impl/inc/mndPerfSchema.h similarity index 55% rename from include/util/tmacro.h rename to source/dnode/mnode/impl/inc/mndPerfSchema.h index 07c6e6509e4d5eedd7c14a830922b8347111f6e8..2c613e253ccc7cafaf6c75729234f90d9fc97e60 100644 --- a/include/util/tmacro.h +++ b/source/dnode/mnode/impl/inc/mndPerfSchema.h @@ -13,28 +13,33 @@ * along with this program. If not, see . */ -#ifndef _TD_UTIL_MACRO_H_ -#define _TD_UTIL_MACRO_H_ +#ifndef _TD_MND_PERF_SCHEMA_H_ +#define _TD_MND_PERF_SCHEMA_H_ -#include "os.h" +#include "mndInt.h" #ifdef __cplusplus extern "C" { #endif -// Module init/clear MACRO definitions -#define TD_MOD_UNINITIALIZED 0 -#define TD_MOD_INITIALIZED 1 +typedef struct SPerfsTableSchema { + char *name; + int32_t type; + int32_t bytes; +} SPerfsTableSchema; -typedef int8_t td_mode_flag_t; +typedef struct SPerfsTableMeta { + char *name; + const SPerfsTableSchema *schema; + int32_t colNum; +} SPerfsTableMeta; -#define TD_CHECK_AND_SET_MODE_INIT(FLAG) atomic_val_compare_exchange_8((FLAG), TD_MOD_UNINITIALIZED, TD_MOD_INITIALIZED) -#define TD_CHECK_AND_SET_MOD_CLEAR(FLAG) atomic_val_compare_exchange_8((FLAG), TD_MOD_INITIALIZED, TD_MOD_UNINITIALIZED) - -#define TD_IS_NULL(PTR) ((PTR) == NULL) +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_UTIL_MACRO_H_*/ \ No newline at end of file +#endif /*_TD_MND_PERF_SCHEMA_H_*/ diff --git a/source/dnode/mnode/impl/inc/mndShow.h b/source/dnode/mnode/impl/inc/mndShow.h index a269fa35c1ded912ce3be8d463df23132184fb5c..03f901e9c412e1ddf466cf336190d4fe7a590b0c 100644 --- a/source/dnode/mnode/impl/inc/mndShow.h +++ b/source/dnode/mnode/impl/inc/mndShow.h @@ -26,8 +26,6 @@ int32_t mndInitShow(SMnode *pMnode); void mndCleanupShow(SMnode *pMnode); void mndAddShowRetrieveHandle(SMnode *pMnode, EShowType showType, ShowRetrieveFp fp); void mndAddShowFreeIterHandle(SMnode *pMnode, EShowType msgType, ShowFreeIterFp fp); -void mndVacuumResult(char *data, int32_t numOfCols, int32_t rows, int32_t capacity, SShowObj *pShow); -char *mndShowStr(int32_t showType); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/src/mndAcct.c b/source/dnode/mnode/impl/src/mndAcct.c index 68c8c6d12744b79433b5f00a3bfe3f97dab0495b..25bf20fa0d5d53e1352fb838d620d916392f814f 100644 --- a/source/dnode/mnode/impl/src/mndAcct.c +++ b/source/dnode/mnode/impl/src/mndAcct.c @@ -17,7 +17,7 @@ #include "mndAcct.h" #include "mndShow.h" -#define TSDB_ACCT_VER_NUMBER 1 +#define TSDB_ACCT_VER_NUMBER 1 #define TSDB_ACCT_RESERVE_SIZE 128 static int32_t mndCreateDefaultAcct(SMnode *pMnode); @@ -80,32 +80,32 @@ static SSdbRaw *mndAcctActionEncode(SAcctObj *pAcct) { terrno = TSDB_CODE_OUT_OF_MEMORY; SSdbRaw *pRaw = sdbAllocRaw(SDB_ACCT, TSDB_ACCT_VER_NUMBER, sizeof(SAcctObj) + TSDB_ACCT_RESERVE_SIZE); - if (pRaw == NULL) goto ACCT_ENCODE_OVER; + if (pRaw == NULL) goto _OVER; int32_t dataPos = 0; - SDB_SET_BINARY(pRaw, dataPos, pAcct->acct, TSDB_USER_LEN, ACCT_ENCODE_OVER) - SDB_SET_INT64(pRaw, dataPos, pAcct->createdTime, ACCT_ENCODE_OVER) - SDB_SET_INT64(pRaw, dataPos, pAcct->updateTime, ACCT_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pAcct->acctId, ACCT_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pAcct->status, ACCT_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxUsers, ACCT_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxDbs, ACCT_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxStbs, ACCT_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxTbs, ACCT_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxTimeSeries, ACCT_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxStreams, ACCT_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxFuncs, ACCT_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxConsumers, ACCT_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxConns, ACCT_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxTopics, ACCT_ENCODE_OVER) - SDB_SET_INT64(pRaw, dataPos, pAcct->cfg.maxStorage, ACCT_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.accessState, ACCT_ENCODE_OVER) - SDB_SET_RESERVE(pRaw, dataPos, TSDB_ACCT_RESERVE_SIZE, ACCT_ENCODE_OVER) - SDB_SET_DATALEN(pRaw, dataPos, ACCT_ENCODE_OVER) + SDB_SET_BINARY(pRaw, dataPos, pAcct->acct, TSDB_USER_LEN, _OVER) + SDB_SET_INT64(pRaw, dataPos, pAcct->createdTime, _OVER) + SDB_SET_INT64(pRaw, dataPos, pAcct->updateTime, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAcct->acctId, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAcct->status, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxUsers, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxDbs, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxStbs, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxTbs, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxTimeSeries, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxStreams, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxFuncs, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxConsumers, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxConns, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxTopics, _OVER) + SDB_SET_INT64(pRaw, dataPos, pAcct->cfg.maxStorage, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.accessState, _OVER) + SDB_SET_RESERVE(pRaw, dataPos, TSDB_ACCT_RESERVE_SIZE, _OVER) + SDB_SET_DATALEN(pRaw, dataPos, _OVER) terrno = 0; -ACCT_ENCODE_OVER: +_OVER: if (terrno != 0) { mError("acct:%s, failed to encode to raw:%p since %s", pAcct->acct, pRaw, terrstr()); sdbFreeRaw(pRaw); @@ -120,42 +120,42 @@ static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; int8_t sver = 0; - if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto ACCT_DECODE_OVER; + if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; if (sver != TSDB_ACCT_VER_NUMBER) { terrno = TSDB_CODE_SDB_INVALID_DATA_VER; - goto ACCT_DECODE_OVER; + goto _OVER; } SSdbRow *pRow = sdbAllocRow(sizeof(SAcctObj)); - if (pRow == NULL) goto ACCT_DECODE_OVER; + if (pRow == NULL) goto _OVER; SAcctObj *pAcct = sdbGetRowObj(pRow); - if (pAcct == NULL) goto ACCT_DECODE_OVER; + if (pAcct == NULL) goto _OVER; int32_t dataPos = 0; - SDB_GET_BINARY(pRaw, dataPos, pAcct->acct, TSDB_USER_LEN, ACCT_DECODE_OVER) - SDB_GET_INT64(pRaw, dataPos, &pAcct->createdTime, ACCT_DECODE_OVER) - SDB_GET_INT64(pRaw, dataPos, &pAcct->updateTime, ACCT_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pAcct->acctId, ACCT_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pAcct->status, ACCT_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxUsers, ACCT_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxDbs, ACCT_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxStbs, ACCT_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxTbs, ACCT_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxTimeSeries, ACCT_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxStreams, ACCT_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxFuncs, ACCT_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxConsumers, ACCT_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxConns, ACCT_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxTopics, ACCT_DECODE_OVER) - SDB_GET_INT64(pRaw, dataPos, &pAcct->cfg.maxStorage, ACCT_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.accessState, ACCT_DECODE_OVER) - SDB_GET_RESERVE(pRaw, dataPos, TSDB_ACCT_RESERVE_SIZE, ACCT_DECODE_OVER) + SDB_GET_BINARY(pRaw, dataPos, pAcct->acct, TSDB_USER_LEN, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pAcct->createdTime, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pAcct->updateTime, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pAcct->acctId, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pAcct->status, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxUsers, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxDbs, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxStbs, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxTbs, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxTimeSeries, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxStreams, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxFuncs, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxConsumers, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxConns, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxTopics, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pAcct->cfg.maxStorage, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.accessState, _OVER) + SDB_GET_RESERVE(pRaw, dataPos, TSDB_ACCT_RESERVE_SIZE, _OVER) terrno = 0; -ACCT_DECODE_OVER: +_OVER: if (terrno != 0) { mError("acct:%s, failed to decode from raw:%p since %s", pAcct->acct, pRaw, terrstr()); taosMemoryFreeClear(pRow); diff --git a/source/dnode/mnode/impl/src/mndAuth.c b/source/dnode/mnode/impl/src/mndAuth.c index 20dd7f1378ff857dd21c63cb6472668ce4ff2556..fc94ec364590872d87577211e8e8f8780673f643 100644 --- a/source/dnode/mnode/impl/src/mndAuth.c +++ b/source/dnode/mnode/impl/src/mndAuth.c @@ -26,22 +26,22 @@ int32_t mndInitAuth(SMnode *pMnode) { void mndCleanupAuth(SMnode *pMnode) {} -int32_t mndRetriveAuth(SMnode *pMnode, char *user, char *spi, char *encrypt, char *secret, char *ckey) { - SUserObj *pUser = mndAcquireUser(pMnode, user); +static int32_t mndRetriveAuth(SMnode *pMnode, SAuthRsp *pRsp) { + SUserObj *pUser = mndAcquireUser(pMnode, pRsp->user); if (pUser == NULL) { - *secret = 0; - mError("user:%s, failed to auth user since %s", user, terrstr()); + *pRsp->secret = 0; + mError("user:%s, failed to auth user since %s", pRsp->user, terrstr()); return -1; } - *spi = 1; - *encrypt = 0; - *ckey = 0; + pRsp->spi = 1; + pRsp->encrypt = 0; + *pRsp->ckey = 0; - memcpy(secret, pUser->pass, TSDB_PASSWORD_LEN); + memcpy(pRsp->secret, pUser->pass, TSDB_PASSWORD_LEN); mndReleaseUser(pMnode, pUser); - mDebug("user:%s, auth info is returned", user); + mDebug("user:%s, auth info is returned", pRsp->user); return 0; } @@ -55,14 +55,19 @@ static int32_t mndProcessAuthReq(SNodeMsg *pReq) { SAuthReq authRsp = {0}; memcpy(authRsp.user, authReq.user, TSDB_USER_LEN); - int32_t code = - mndRetriveAuth(pReq->pNode, authRsp.user, &authRsp.spi, &authRsp.encrypt, authRsp.secret, authRsp.ckey); + int32_t code = mndRetriveAuth(pReq->pNode, &authRsp); mTrace("user:%s, auth req received, spi:%d encrypt:%d ruser:%s", pReq->user, authRsp.spi, authRsp.encrypt, authRsp.user); int32_t contLen = tSerializeSAuthReq(NULL, 0, &authRsp); void *pRsp = rpcMallocCont(contLen); + if (pRsp == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + tSerializeSAuthReq(pRsp, contLen, &authRsp); + pReq->pRsp = pRsp; pReq->rspLen = contLen; return code; @@ -95,11 +100,11 @@ int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SDbObj *pDb, } } - if (pAlter->alterType == TSDB_ALTER_USER_CLEAR_WRITE_DB || pAlter->alterType == TSDB_ALTER_USER_CLEAR_READ_DB) { - if (pOperUser->superUser) { - return 0; - } + if (pAlter->alterType == TSDB_ALTER_USER_CLEAR_WRITE_DB || pAlter->alterType == TSDB_ALTER_USER_CLEAR_READ_DB) { + if (pOperUser->superUser) { + return 0; } + } if (pAlter->alterType == TSDB_ALTER_USER_ADD_READ_DB || pAlter->alterType == TSDB_ALTER_USER_REMOVE_READ_DB || pAlter->alterType == TSDB_ALTER_USER_ADD_WRITE_DB || pAlter->alterType == TSDB_ALTER_USER_REMOVE_WRITE_DB) { @@ -176,4 +181,4 @@ int32_t mndCheckReadAuth(SUserObj *pOperUser, SDbObj *pDb) { terrno = TSDB_CODE_MND_NO_RIGHTS; return -1; -} \ No newline at end of file +} diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 3db4e9870e9288b925c3b8feb3591c11db8bb7c5..6c797b90446192270f4306e71627e6d499934008 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/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index effb0be4be8a254614327fdfc349bc71c33af556..5ce87a413c7ac3c2637c1fd3f60e9451d3212b45 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -24,9 +24,6 @@ #define TSDB_DNODE_VER_NUMBER 1 #define TSDB_DNODE_RESERVE_SIZE 64 -#define TSDB_CONFIG_OPTION_LEN 16 -#define TSDB_CONIIG_VALUE_LEN 48 -#define TSDB_CONFIG_NUMBER 8 static const char *offlineReason[] = { "", @@ -55,7 +52,6 @@ static int32_t mndProcessConfigDnodeReq(SNodeMsg *pReq); static int32_t mndProcessConfigDnodeRsp(SNodeMsg *pRsp); static int32_t mndProcessStatusReq(SNodeMsg *pReq); -static int32_t mndGetConfigMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta); static int32_t mndRetrieveConfigs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows); static void mndCancelGetNextConfig(SMnode *pMnode, void *pIter); static int32_t mndRetrieveDnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows); @@ -77,8 +73,8 @@ int32_t mndInitDnode(SMnode *pMnode) { mndSetMsgHandle(pMnode, TDMT_DND_CONFIG_DNODE_RSP, mndProcessConfigDnodeRsp); mndSetMsgHandle(pMnode, TDMT_MND_STATUS, mndProcessStatusReq); - mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_VARIABLES, mndRetrieveConfigs); - mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_VARIABLES, mndCancelGetNextConfig); + mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndRetrieveConfigs); + mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndCancelGetNextConfig); mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_DNODE, mndRetrieveDnodes); mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_DNODE, mndCancelGetNextDnode); @@ -638,37 +634,6 @@ static int32_t mndProcessConfigDnodeRsp(SNodeMsg *pRsp) { return TSDB_CODE_SUCCESS; } -static int32_t mndGetConfigMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta) { - int32_t cols = 0; - SSchema *pSchema = pMeta->pSchemas; - - pShow->bytes[cols] = TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "name"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = TSDB_CONIIG_VALUE_LEN + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "value"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pMeta->numOfColumns = cols; - pShow->numOfColumns = cols; - - pShow->offset[0] = 0; - for (int32_t i = 1; i < cols; ++i) { - pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1]; - } - - pShow->numOfRows = TSDB_CONFIG_NUMBER; - pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1]; - strcpy(pMeta->tbName, mndShowStr(pShow->type)); - - return 0; -} - static int32_t mndRetrieveConfigs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows) { SMnode *pMnode = pReq->pNode; int32_t totalRows = 0; diff --git a/source/dnode/mnode/impl/src/mndInfoSchema.c b/source/dnode/mnode/impl/src/mndInfoSchema.c index b210ee0d4fc79102e48dd34acc93e2b13b7b8ef9..d24586aa3659382343d4c66a6cec25fbf8e8d89c 100644 --- a/source/dnode/mnode/impl/src/mndInfoSchema.c +++ b/source/dnode/mnode/impl/src/mndInfoSchema.c @@ -15,12 +15,12 @@ #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) -#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE) +#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE) -//!!!! Note: only APPEND columns in below tables, NO insert !!!! static const SInfosTableSchema dnodesSchema[] = { {.name = "id", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT}, {.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, @@ -30,6 +30,7 @@ static const SInfosTableSchema dnodesSchema[] = { {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, {.name = "note", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, }; + static const SInfosTableSchema mnodesSchema[] = { {.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, @@ -37,31 +38,37 @@ static const SInfosTableSchema mnodesSchema[] = { {.name = "role_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, }; + static const SInfosTableSchema modulesSchema[] = { {.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "endpoint", .bytes = 134, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "module", .bytes = 10, .type = TSDB_DATA_TYPE_VARCHAR}, }; + static const SInfosTableSchema qnodesSchema[] = { {.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, }; + static const SInfosTableSchema snodesSchema[] = { {.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, }; + static const SInfosTableSchema bnodesSchema[] = { {.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, }; + static const SInfosTableSchema clusterSchema[] = { {.name = "id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT}, {.name = "name", .bytes = TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, }; + static const SInfosTableSchema userDBSchema[] = { {.name = "name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, @@ -84,16 +91,19 @@ static const SInfosTableSchema userDBSchema[] = { {.name = "single_stable", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, {.name = "stream_mode", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, {.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, - // {.name = "update", .bytes = 1, .type = - // TSDB_DATA_TYPE_TINYINT}, // disable update + // {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update }; + 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[] = { {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, @@ -103,6 +113,7 @@ static const SInfosTableSchema userIdxSchema[] = { {.name = "index_type", .bytes = 10, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "index_extensions", .bytes = 256, .type = TSDB_DATA_TYPE_VARCHAR}, }; + static const SInfosTableSchema userStbsSchema[] = { {.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, @@ -112,6 +123,7 @@ static const SInfosTableSchema userStbsSchema[] = { {.name = "last_update", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, {.name = "table_comment", .bytes = 1024 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, }; + static const SInfosTableSchema userStreamsSchema[] = { {.name = "stream_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "user_name", .bytes = 23, .type = TSDB_DATA_TYPE_VARCHAR}, @@ -119,6 +131,7 @@ static const SInfosTableSchema userStreamsSchema[] = { {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, {.name = "sql", .bytes = 1024, .type = TSDB_DATA_TYPE_VARCHAR}, }; + static const SInfosTableSchema userTblsSchema[] = { {.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, @@ -130,6 +143,7 @@ static const SInfosTableSchema userTblsSchema[] = { {.name = "ttl", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "table_comment", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, }; + static const SInfosTableSchema userTblDistSchema[] = { {.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "table_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, @@ -145,12 +159,14 @@ static const SInfosTableSchema userTblDistSchema[] = { {.name = "rows_in_mem", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "seek_header_time", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, }; + static const SInfosTableSchema userUsersSchema[] = { {.name = "name", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "privilege", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, {.name = "account", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, }; + static const SInfosTableSchema grantsSchema[] = { {.name = "version", .bytes = 8 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, {.name = "expire time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, @@ -167,6 +183,7 @@ static const SInfosTableSchema grantsSchema[] = { {.name = "speed(PPS)", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, {.name = "querytime", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, }; + static const SInfosTableSchema vgroupsSchema[] = { {.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, @@ -210,14 +227,62 @@ static const SInfosTableSchema subscribeSchema[] = { {.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, }; +static const SInfosTableSchema smaSchema[] = { + {.name = "sma_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, +}; + +static const SInfosTableSchema transSchema[] = { + {.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "stage", .bytes = TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "type", .bytes = TSDB_TRANS_TYPE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "last_exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "last_error", .bytes = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, +}; + +static const SInfosTableSchema configSchema[] = { + {.name = "name", .bytes = TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "value", .bytes = TSDB_CONIIG_VALUE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, +}; + +static const SInfosTableSchema connSchema[] = { + {.name = "connId", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "program", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "ip:port", .bytes = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "login_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, +}; + +static const SInfosTableSchema querySchema[] = { + {.name = "queryId", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "connId", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "ip:port", .bytes = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "qid", .bytes = 22 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "time", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT}, + {.name = "sql_obj_id", .bytes = QUERY_OBJ_ID_SIZE + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "ep", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "stable_query", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL}, + {.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_VARCHAR}, + {.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, +}; + static const SInfosTableMeta infosMeta[] = { {TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema)}, {TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema)}, {TSDB_INS_TABLE_MODULES, modulesSchema, tListLen(modulesSchema)}, {TSDB_INS_TABLE_QNODES, qnodesSchema, tListLen(qnodesSchema)}, + {TSDB_INS_TABLE_SNODES, snodesSchema, tListLen(snodesSchema)}, {TSDB_INS_TABLE_BNODES, bnodesSchema, tListLen(bnodesSchema)}, {TSDB_INS_TABLE_CLUSTER, clusterSchema, tListLen(clusterSchema)}, - {TSDB_INS_TABLE_SNODES, snodesSchema, tListLen(snodesSchema)}, {TSDB_INS_TABLE_USER_DATABASES, userDBSchema, tListLen(userDBSchema)}, {TSDB_INS_TABLE_USER_FUNCTIONS, userFuncSchema, tListLen(userFuncSchema)}, {TSDB_INS_TABLE_USER_INDEXES, userIdxSchema, tListLen(userIdxSchema)}, @@ -226,12 +291,19 @@ static const SInfosTableMeta infosMeta[] = { {TSDB_INS_TABLE_USER_TABLES, userTblsSchema, tListLen(userTblsSchema)}, {TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, userTblDistSchema, tListLen(userTblDistSchema)}, {TSDB_INS_TABLE_USER_USERS, userUsersSchema, tListLen(userUsersSchema)}, - {TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema)}, {TSDB_INS_TABLE_LICENCES, grantsSchema, tListLen(grantsSchema)}, + {TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema)}, + {TSDB_INS_TABLE_TOPICS, topicSchema, tListLen(topicSchema)}, + {TSDB_INS_TABLE_CONSUMERS, consumerSchema, tListLen(consumerSchema)}, + {TSDB_INS_TABLE_SUBSCRIBES, subscribeSchema, tListLen(subscribeSchema)}, + {TSDB_INS_TABLE_TRANS, transSchema, tListLen(transSchema)}, + {TSDB_INS_TABLE_SMAS, smaSchema, tListLen(smaSchema)}, + {TSDB_INS_TABLE_CONFIGS, configSchema, tListLen(configSchema)}, + {TSDB_INS_TABLE_CONNS, connSchema, tListLen(connSchema)}, + {TSDB_INS_TABLE_QUERIES, querySchema, tListLen(querySchema)}, }; -// connection/application/ -int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, SSchema **pDst) { +static int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, SSchema **pDst) { SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema)); if (NULL == schema) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -239,40 +311,39 @@ int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, S } for (int32_t i = 0; i < colNum; ++i) { - strcpy(schema[i].name, pSrc[i].name); - + tstrncpy(schema[i].name, pSrc[i].name, sizeof(schema[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; + return 0; } -int32_t mndInsInitMeta(SHashObj *hash) { +static int32_t mndInsInitMeta(SHashObj *hash) { STableMetaRsp meta = {0}; - strcpy(meta.dbFName, TSDB_INFORMATION_SCHEMA_DB); + tstrncpy(meta.dbFName, TSDB_INFORMATION_SCHEMA_DB, sizeof(meta.dbFName)); meta.tableType = TSDB_SYSTEM_TABLE; meta.sversion = 1; meta.tversion = 1; for (int32_t i = 0; i < tListLen(infosMeta); ++i) { - strcpy(meta.tbName, infosMeta[i].name); + tstrncpy(meta.tbName, infosMeta[i].name, sizeof(meta.tbName)); meta.numOfColumns = infosMeta[i].colNum; if (mndInitInfosTableSchema(infosMeta[i].schema, infosMeta[i].colNum, &meta.pSchemas)) { return -1; } - if (taosHashPut(hash, meta.tbName, strlen(meta.tbName), &meta, sizeof(meta))) { + if (taosHashPut(hash, meta.tbName, strlen(meta.tbName) + 1, &meta, sizeof(meta))) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } } - return TSDB_CODE_SUCCESS; + return 0; } int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp) { @@ -281,24 +352,23 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char * return -1; } - STableMetaRsp *meta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, tbName, strlen(tbName)); - if (NULL == meta) { + STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, tbName, strlen(tbName) + 1); + if (NULL == pMeta) { mError("invalid information schema table name:%s", tbName); terrno = TSDB_CODE_MND_INVALID_INFOS_TBL; return -1; } - *pRsp = *meta; + *pRsp = *pMeta; - pRsp->pSchemas = taosMemoryCalloc(meta->numOfColumns, sizeof(SSchema)); + pRsp->pSchemas = taosMemoryCalloc(pMeta->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)); - + memcpy(pRsp->pSchemas, pMeta->pSchemas, pMeta->numOfColumns * sizeof(SSchema)); return 0; } @@ -317,16 +387,12 @@ void mndCleanupInfos(SMnode *pMnode) { return; } - void *pIter = taosHashIterate(pMnode->infosMeta, NULL); - while (pIter) { - STableMetaRsp *meta = (STableMetaRsp *)pIter; - - taosMemoryFreeClear(meta->pSchemas); - - pIter = taosHashIterate(pMnode->infosMeta, pIter); + STableMetaRsp *pMeta = taosHashIterate(pMnode->infosMeta, NULL); + while (pMeta) { + taosMemoryFreeClear(pMeta->pSchemas); + pMeta = taosHashIterate(pMnode->infosMeta, pMeta); } taosHashCleanup(pMnode->infosMeta); pMnode->infosMeta = NULL; } - diff --git a/source/dnode/mnode/impl/src/mndOffset.c b/source/dnode/mnode/impl/src/mndOffset.c index 22dad48772b2024cb2bb96243de070300aec4e0a..31c16e1e1d1349a11ce89c2ee325f99af9735156 100644 --- a/source/dnode/mnode/impl/src/mndOffset.c +++ b/source/dnode/mnode/impl/src/mndOffset.c @@ -201,6 +201,7 @@ static int32_t mndOffsetActionDelete(SSdb *pSdb, SMqOffsetObj *pOffset) { static int32_t mndOffsetActionUpdate(SSdb *pSdb, SMqOffsetObj *pOldOffset, SMqOffsetObj *pNewOffset) { mTrace("offset:%s, perform update action", pOldOffset->key); + pOldOffset->offset = pNewOffset->offset; return 0; } diff --git a/source/dnode/mnode/impl/src/mndPerfSchema.c b/source/dnode/mnode/impl/src/mndPerfSchema.c new file mode 100644 index 0000000000000000000000000000000000000000..38e9e792286d41bfcc53f5559df0ade2c264de3b --- /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 556e17ad2db0583dc0f6595deb9b2776760d35f0..826a73afc68915c3b161b9896a2bc58677bd409d 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -23,13 +23,8 @@ #include "tglobal.h" #include "version.h" -#define QUERY_ID_SIZE 20 -#define QUERY_OBJ_ID_SIZE 18 -#define SUBQUERY_INFO_SIZE 6 -#define QUERY_SAVE_SIZE 20 - 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 @@ -40,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); @@ -56,9 +51,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq); static int32_t mndProcessConnectReq(SNodeMsg *pReq); static int32_t mndProcessKillQueryReq(SNodeMsg *pReq); static int32_t mndProcessKillConnReq(SNodeMsg *pReq); -static int32_t mndGetConnsMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta); static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows); -static int32_t mndGetQueryMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta); static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows); static void mndCancelGetNextQuery(SMnode *pMnode, void *pIter); @@ -98,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, @@ -111,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}; @@ -126,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); @@ -219,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; @@ -239,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; @@ -252,22 +248,13 @@ CONN_OVER: return code; } -static int32_t mndSaveQueryStreamList(SConnObj *pConn, SHeartBeatReq *pReq) { - pConn->numOfQueries = 0; - int32_t numOfQueries = htonl(pReq->numOfQueries); - - if (numOfQueries > 0) { - if (pConn->pQueries == NULL) { - pConn->pQueries = taosMemoryCalloc(sizeof(SQueryDesc), QUERY_SAVE_SIZE); - } - - pConn->numOfQueries = TMIN(QUERY_SAVE_SIZE, numOfQueries); +static int32_t mndSaveQueryList(SConnObj *pConn, SQueryHbReqBasic *pBasic) { + taosArrayDestroyEx(pConn->pQueries, tFreeClientHbQueryDesc); - 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; } @@ -337,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; @@ -352,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); @@ -423,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) { @@ -520,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; } @@ -558,81 +544,6 @@ static int32_t mndProcessKillConnReq(SNodeMsg *pReq) { } } -static int32_t mndGetConnsMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta) { - SMnode *pMnode = pReq->pNode; - SProfileMgmt *pMgmt = &pMnode->profileMgmt; - - SUserObj *pUser = mndAcquireUser(pMnode, pReq->user); - if (pUser == NULL) return 0; - if (!pUser->superUser) { - mndReleaseUser(pMnode, pUser); - terrno = TSDB_CODE_MND_NO_RIGHTS; - return -1; - } - mndReleaseUser(pMnode, pUser); - - int32_t cols = 0; - SSchema *pSchema = pMeta->pSchemas; - - pShow->bytes[cols] = 4; - pSchema[cols].type = TSDB_DATA_TYPE_INT; - strcpy(pSchema[cols].name, "connId"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = TSDB_USER_LEN + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "user"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - // app name - pShow->bytes[cols] = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "program"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - // app pid - pShow->bytes[cols] = 4; - pSchema[cols].type = TSDB_DATA_TYPE_INT; - strcpy(pSchema[cols].name, "pid"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "ip:port"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = 8; - pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP; - strcpy(pSchema[cols].name, "login_time"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = 8; - pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP; - strcpy(pSchema[cols].name, "last_access"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pMeta->numOfColumns = cols; - pShow->numOfColumns = cols; - - pShow->offset[0] = 0; - for (int32_t i = 1; i < cols; ++i) { - pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1]; - } - - pShow->numOfRows = taosCacheGetNumOfObj(pMgmt->cache); - pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1]; - strcpy(pMeta->tbName, mndShowStr(pShow->type)); - - return 0; -} - static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) { SMnode *pMnode = pReq->pNode; int32_t numOfRows = 0; @@ -653,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; @@ -692,124 +603,10 @@ static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int return numOfRows; } -static int32_t mndGetQueryMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta) { - SMnode *pMnode = pReq->pNode; - SProfileMgmt *pMgmt = &pMnode->profileMgmt; - - SUserObj *pUser = mndAcquireUser(pMnode, pReq->user); - if (pUser == NULL) return 0; - if (!pUser->superUser) { - mndReleaseUser(pMnode, pUser); - terrno = TSDB_CODE_MND_NO_RIGHTS; - return -1; - } - mndReleaseUser(pMnode, pUser); - - int32_t cols = 0; - SSchema *pSchema = pMeta->pSchemas; - - pShow->bytes[cols] = 4; - pSchema[cols].type = TSDB_DATA_TYPE_INT; - strcpy(pSchema[cols].name, "queryId"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = 4; - pSchema[cols].type = TSDB_DATA_TYPE_INT; - strcpy(pSchema[cols].name, "connId"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = TSDB_USER_LEN + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "user"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "ip:port"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = 22 + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "qid"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = 8; - pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP; - strcpy(pSchema[cols].name, "created_time"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = 8; - pSchema[cols].type = TSDB_DATA_TYPE_BIGINT; - strcpy(pSchema[cols].name, "time"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = QUERY_OBJ_ID_SIZE + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "sql_obj_id"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = 4; - pSchema[cols].type = TSDB_DATA_TYPE_INT; - strcpy(pSchema[cols].name, "pid"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = TSDB_EP_LEN + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "ep"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = 1; - pSchema[cols].type = TSDB_DATA_TYPE_BOOL; - strcpy(pSchema[cols].name, "stable_query"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = 4; - pSchema[cols].type = TSDB_DATA_TYPE_INT; - strcpy(pSchema[cols].name, "sub_queries"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "sub_query_info"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "sql"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pMeta->numOfColumns = cols; - pShow->numOfColumns = cols; - - pShow->offset[0] = 0; - for (int32_t i = 1; i < cols; ++i) { - pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1]; - } - - pShow->numOfRows = 1000000; - pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1]; - strcpy(pMeta->tbName, mndShowStr(pShow->type)); - - return 0; -} - 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; @@ -906,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 d9f4f142df786ccef1ef523c107ccbc364f03a21..1a14c94640f5dd8b690f4d4d3506f6baaee16f49 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -115,6 +115,7 @@ static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove) { static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) { SMnode *pMnode = pReq->pNode; SShowMgmt *pMgmt = &pMnode->showMgmt; + SShowObj *pShow = NULL; int32_t rowsToRead = SHOW_STEP_SIZE; int32_t size = 0; int32_t rowsRead = 0; @@ -125,13 +126,18 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) { return -1; } - SShowObj* pShow = NULL; - if (retrieveReq.showId == 0) { SShowReq req = {0}; 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; @@ -139,11 +145,11 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) { return -1; } - pShow->pMeta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb)); + pShow->pMeta = pMeta; pShow->numOfColumns = pShow->pMeta->numOfColumns; int32_t offset = 0; - for(int32_t i = 0; i < pShow->pMeta->numOfColumns; ++i) { + for (int32_t i = 0; i < pShow->pMeta->numOfColumns; ++i) { pShow->offset[i] = offset; int32_t bytes = pShow->pMeta->pSchemas[i].bytes; @@ -162,26 +168,25 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) { ShowRetrieveFp retrieveFp = pMgmt->retrieveFps[pShow->type]; if (retrieveFp == NULL) { - mndReleaseShowObj((SShowObj*) pShow, false); + mndReleaseShowObj(pShow, false); terrno = TSDB_CODE_MSG_NOT_PROCESSED; mError("show:0x%" PRIx64 ", failed to retrieve data since %s", pShow->id, terrstr()); return -1; } - mDebug("show:0x%" PRIx64 ", start retrieve data, type:%s", pShow->id, mndShowStr(pShow->type)); - - int32_t numOfCols = pShow->pMeta->numOfColumns; + mDebug("show:0x%" PRIx64 ", start retrieve data, type:%d", pShow->id, pShow->type); - SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); + int32_t numOfCols = pShow->pMeta->numOfColumns; + SSDataBlock *pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); pBlock->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData)); pBlock->info.numOfCols = numOfCols; - for(int32_t i = 0; i < numOfCols; ++i) { + for (int32_t i = 0; i < numOfCols; ++i) { SColumnInfoData idata = {0}; - SSchema* p = &pShow->pMeta->pSchemas[i]; + SSchema *p = &pShow->pMeta->pSchemas[i]; idata.info.bytes = p->bytes; - idata.info.type = p->type; + idata.info.type = p->type; idata.info.colId = p->colId; taosArrayPush(pBlock->pDataBlock, &idata); @@ -191,15 +196,15 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) { } blockDataEnsureCapacity(pBlock, rowsToRead); - if (mndCheckRetrieveFinished((SShowObj*) pShow)) { + if (mndCheckRetrieveFinished(pShow)) { mDebug("show:0x%" PRIx64 ", read finished, numOfRows:%d", pShow->id, pShow->numOfRows); rowsRead = 0; } else { - rowsRead = (*retrieveFp)(pReq, (SShowObj *)pShow, pBlock, rowsToRead); + rowsRead = (*retrieveFp)(pReq, pShow, pBlock, rowsToRead); if (rowsRead < 0) { terrno = rowsRead; mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id); - mndReleaseShowObj((SShowObj *)pShow, true); + mndReleaseShowObj(pShow, true); return -1; } @@ -207,13 +212,12 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) { mDebug("show:0x%" PRIx64 ", stop retrieve data, rowsRead:%d numOfRows:%d", pShow->id, rowsRead, pShow->numOfRows); } - // numOfCols + sizeof(SSysTableSchema) * numOfCols + data payload - size = sizeof(SRetrieveMetaTableRsp) + sizeof(int32_t) + sizeof(SSysTableSchema) * pShow->pMeta->numOfColumns + blockDataGetSize(pBlock) - + blockDataGetSerialMetaSize(pBlock); + size = sizeof(SRetrieveMetaTableRsp) + sizeof(int32_t) + sizeof(SSysTableSchema) * pShow->pMeta->numOfColumns + + blockDataGetSize(pBlock) + blockDataGetSerialMetaSize(pBlock); SRetrieveMetaTableRsp *pRsp = rpcMallocCont(size); if (pRsp == NULL) { - mndReleaseShowObj((SShowObj*) pShow, false); + mndReleaseShowObj(pShow, false); terrno = TSDB_CODE_OUT_OF_MEMORY; mError("show:0x%" PRIx64 ", failed to retrieve data since %s", pShow->id, terrstr()); blockDataDestroy(pBlock); @@ -222,9 +226,8 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) { pRsp->handle = htobe64(pShow->id); - // if free flag is set, client wants to clean the resources if (rowsRead > 0) { - char * pStart = pRsp->data; + char *pStart = pRsp->data; SSchema *ps = pShow->pMeta->pSchemas; *(int32_t *)pStart = htonl(pShow->pMeta->numOfColumns); @@ -245,77 +248,22 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) { pRsp->numOfRows = htonl(rowsRead); pRsp->precision = TSDB_TIME_PRECISION_MILLI; // millisecond time precision - pReq->pRsp = pRsp; - pReq->rspLen = size; + pReq->pRsp = pRsp; + pReq->rspLen = size; if (rowsRead == 0 || rowsRead < rowsToRead) { pRsp->completed = 1; mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id); - mndReleaseShowObj((SShowObj*) pShow, true); + mndReleaseShowObj(pShow, true); } else { mDebug("show:0x%" PRIx64 ", retrieve not completed yet", pShow->id); - mndReleaseShowObj((SShowObj*) pShow, false); + mndReleaseShowObj(pShow, false); } blockDataDestroy(pBlock); return TSDB_CODE_SUCCESS; } -char *mndShowStr(int32_t showType) { - switch (showType) { - case TSDB_MGMT_TABLE_ACCT: - return "show accounts"; - case TSDB_MGMT_TABLE_USER: - return "show users"; - case TSDB_MGMT_TABLE_DB: - return "show databases"; - case TSDB_MGMT_TABLE_TABLE: - return "show tables"; - case TSDB_MGMT_TABLE_DNODE: - return "show dnodes"; - case TSDB_MGMT_TABLE_MNODE: - return "show mnodes"; - case TSDB_MGMT_TABLE_QNODE: - return "show qnodes"; - case TSDB_MGMT_TABLE_SNODE: - return "show snodes"; - case TSDB_MGMT_TABLE_BNODE: - return "show bnodes"; - case TSDB_MGMT_TABLE_VGROUP: - return "show vgroups"; - case TSDB_MGMT_TABLE_STB: - return "show stables"; - case TSDB_MGMT_TABLE_MODULE: - return "show modules"; - case TSDB_MGMT_TABLE_QUERIES: - return "show queries"; - case TSDB_MGMT_TABLE_STREAMS: - return "show streams"; - case TSDB_MGMT_TABLE_VARIABLES: - return "show configs"; - case TSDB_MGMT_TABLE_CONNS: - return "show connections"; - case TSDB_MGMT_TABLE_TRANS: - return "show trans"; - case TSDB_MGMT_TABLE_GRANTS: - return "show grants"; - case TSDB_MGMT_TABLE_VNODES: - return "show vnodes"; - case TSDB_MGMT_TABLE_CLUSTER: - return "show cluster"; - case TSDB_MGMT_TABLE_STREAMTABLES: - return "show streamtables"; - case TSDB_MGMT_TABLE_TP: - return "show topics"; - case TSDB_MGMT_TABLE_FUNC: - return "show functions"; - case TSDB_MGMT_TABLE_INDEX: - return "show indexes"; - default: - return "undefined"; - } -} - static bool mndCheckRetrieveFinished(SShowObj *pShow) { if (pShow->pIter == NULL && pShow->numOfRows != 0) { return true; @@ -323,14 +271,6 @@ static bool mndCheckRetrieveFinished(SShowObj *pShow) { return false; } -void mndVacuumResult(char *data, int32_t numOfCols, int32_t rows, int32_t capacity, SShowObj *pShow) { - if (rows < capacity) { - for (int32_t i = 0; i < numOfCols; ++i) { - memmove(data + pShow->offset[i] * rows, data + pShow->offset[i] * capacity, pShow->bytes[i] * rows); - } - } -} - void mndAddShowRetrieveHandle(SMnode *pMnode, EShowType showType, ShowRetrieveFp fp) { SShowMgmt *pMgmt = &pMnode->showMgmt; pMgmt->retrieveFps[showType] = fp; diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index 70e41a73b78248141f004c076463d268b1e2d3d2..1e68e8e9c5a27d8294f8e1f86fdd8f62687690f9 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -724,46 +724,6 @@ static int32_t mndProcessVDropSmaRsp(SNodeMsg *pRsp) { return 0; } -static int32_t mndGetSmaMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta) { - SMnode *pMnode = pReq->pNode; - SSdb *pSdb = pMnode->pSdb; - - int32_t cols = 0; - SSchema *pSchema = pMeta->pSchemas; - - pShow->bytes[cols] = TSDB_INDEX_NAME_LEN + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "name"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = 8; - pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP; - strcpy(pSchema[cols].name, "create_time"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "stb"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pMeta->numOfColumns = cols; - pShow->numOfColumns = cols; - - pShow->offset[0] = 0; - for (int32_t i = 1; i < cols; ++i) { - pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1]; - } - - pShow->numOfRows = sdbGetSize(pSdb, SDB_SMA); - pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1]; - strcpy(pMeta->tbName, mndShowStr(pShow->type)); - - return 0; -} - static int32_t mndRetrieveSma(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows) { SMnode *pMnode = pReq->pNode; SSdb *pSdb = pMnode->pSdb; diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 92a67fd7e9401afc44e39fa5283e37bbddd3c8a1..0ce73005e882ef9327086c09ccb0203435c6c10e 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/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index a7285162fad34eca10eddd004f60ea137d31d3a7..a0ee8ff44cad00ff56d5927e98fe0d75bd391d9f 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -58,8 +58,8 @@ int32_t mndInitStream(SMnode *pMnode) { /*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM, mndProcessDropStreamReq);*/ /*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM_RSP, mndProcessDropStreamInRsp);*/ -// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TP, mndRetrieveStream); - mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TP, mndCancelGetNextStream); + // mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndRetrieveStream); + mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndCancelGetNextStream); return sdbSetTable(pMnode->pSdb, table); } @@ -421,50 +421,6 @@ static int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfS return 0; } -static int32_t mndGetStreamMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta) { - SMnode *pMnode = pReq->pNode; - SSdb *pSdb = pMnode->pSdb; - - if (mndGetNumOfStreams(pMnode, pShow->db, &pShow->numOfRows) != 0) { - return -1; - } - - int32_t cols = 0; - SSchema *pSchema = pMeta->pSchemas; - - pShow->bytes[cols] = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "name"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = 8; - pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP; - strcpy(pSchema[cols].name, "create_time"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "sql"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pMeta->numOfColumns = cols; - pShow->numOfColumns = cols; - - pShow->offset[0] = 0; - for (int32_t i = 1; i < cols; ++i) { - pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1]; - } - - pShow->numOfRows = sdbGetSize(pSdb, SDB_STREAM); - pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1]; - strcpy(pMeta->tbName, mndShowStr(pShow->type)); - - return 0; -} - static int32_t mndRetrieveStream(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) { SMnode *pMnode = pReq->pNode; SSdb *pSdb = pMnode->pSdb; diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index e1461c0ebaa8af79b7df32347c553319572c5620..3a31b0abb9ef47e78772d9a8612155b7ed344382 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -469,6 +469,7 @@ static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) { ASSERT(pConsumerEp != NULL); ASSERT(pConsumerEp->consumerId == pSubConsumer->consumerId); taosArrayPush(pSub->unassignedVg, pConsumerEp); + mDebug("mq rebalance: vg %d push to unassignedVg", pConsumerEp->vgId); } SMqConsumerObj *pRebConsumer = mndAcquireConsumer(pMnode, pSubConsumer->consumerId); @@ -512,6 +513,7 @@ static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) { while (taosArrayGetSize(pSubConsumer->vgInfo) < vgThisConsumerAfterRb) { SMqConsumerEp *pConsumerEp = taosArrayPop(pSub->unassignedVg); + mDebug("mq rebalance: vg %d pop from unassignedVg", pConsumerEp->vgId); ASSERT(pConsumerEp != NULL); pConsumerEp->oldConsumerId = pConsumerEp->consumerId; @@ -570,7 +572,6 @@ static int32_t mndPersistMqSetConnReq(SMnode *pMnode, STrans *pTrans, const SMqT .vgId = vgId, .consumerId = pConsumerEp->consumerId, .sql = pTopic->sql, - .logicalPlan = pTopic->logicalPlan, .physicalPlan = pTopic->physicalPlan, .qmsg = pConsumerEp->qmsg, }; diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 65a304e9511a3bdf5819c067e355ad1fc9aef219..b9c42fe899a2bd798ba039b514483b3e38a8c907 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -26,7 +26,7 @@ #include "parser.h" #include "tname.h" -#define MND_TOPIC_VER_NUMBER 1 +#define MND_TOPIC_VER_NUMBER 1 #define MND_TOPIC_RESERVE_SIZE 64 static int32_t mndTopicActionInsert(SSdb *pSdb, SMqTopicObj *pTopic); @@ -35,7 +35,6 @@ static int32_t mndTopicActionUpdate(SSdb *pSdb, SMqTopicObj *pTopic, SMqTopicObj static int32_t mndProcessCreateTopicReq(SNodeMsg *pReq); static int32_t mndProcessDropTopicReq(SNodeMsg *pReq); static int32_t mndProcessDropTopicInRsp(SNodeMsg *pRsp); -static int32_t mndGetTopicMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta); static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows); static void mndCancelGetNextTopic(SMnode *pMnode, void *pIter); @@ -52,8 +51,8 @@ int32_t mndInitTopic(SMnode *pMnode) { mndSetMsgHandle(pMnode, TDMT_MND_DROP_TOPIC, mndProcessDropTopicReq); mndSetMsgHandle(pMnode, TDMT_VND_DROP_TOPIC_RSP, mndProcessDropTopicInRsp); -// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TP, mndRetrieveTopic); - mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TP, mndCancelGetNextTopic); + // mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndRetrieveTopic); + mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndCancelGetNextTopic); return sdbSetTable(pMnode->pSdb, table); } @@ -63,11 +62,10 @@ void mndCleanupTopic(SMnode *pMnode) {} SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) { terrno = TSDB_CODE_OUT_OF_MEMORY; - int32_t logicalPlanLen = strlen(pTopic->logicalPlan) + 1; int32_t physicalPlanLen = strlen(pTopic->physicalPlan) + 1; - int32_t swLen = taosEncodeSSchemaWrapper(NULL, &pTopic->schema); + int32_t schemaLen = taosEncodeSSchemaWrapper(NULL, &pTopic->schema); int32_t size = - sizeof(SMqTopicObj) + logicalPlanLen + physicalPlanLen + pTopic->sqlLen + swLen + MND_TOPIC_RESERVE_SIZE; + sizeof(SMqTopicObj) + physicalPlanLen + pTopic->sqlLen + pTopic->astLen + schemaLen + MND_TOPIC_RESERVE_SIZE; SSdbRaw *pRaw = sdbAllocRaw(SDB_TOPIC, MND_TOPIC_VER_NUMBER, size); if (pRaw == NULL) goto TOPIC_ENCODE_OVER; @@ -81,19 +79,19 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) { SDB_SET_INT32(pRaw, dataPos, pTopic->version, TOPIC_ENCODE_OVER); SDB_SET_INT32(pRaw, dataPos, pTopic->sqlLen, TOPIC_ENCODE_OVER); SDB_SET_BINARY(pRaw, dataPos, pTopic->sql, pTopic->sqlLen, TOPIC_ENCODE_OVER); - SDB_SET_INT32(pRaw, dataPos, logicalPlanLen, TOPIC_ENCODE_OVER); - SDB_SET_BINARY(pRaw, dataPos, pTopic->logicalPlan, logicalPlanLen, TOPIC_ENCODE_OVER); + SDB_SET_INT32(pRaw, dataPos, pTopic->astLen, TOPIC_ENCODE_OVER); + SDB_SET_BINARY(pRaw, dataPos, pTopic->ast, pTopic->astLen, TOPIC_ENCODE_OVER); SDB_SET_INT32(pRaw, dataPos, physicalPlanLen, TOPIC_ENCODE_OVER); SDB_SET_BINARY(pRaw, dataPos, pTopic->physicalPlan, physicalPlanLen, TOPIC_ENCODE_OVER); - void *swBuf = taosMemoryMalloc(swLen); + void *swBuf = taosMemoryMalloc(schemaLen); if (swBuf == NULL) { goto TOPIC_ENCODE_OVER; } void *aswBuf = swBuf; taosEncodeSSchemaWrapper(&aswBuf, &pTopic->schema); - SDB_SET_INT32(pRaw, dataPos, swLen, TOPIC_ENCODE_OVER); - SDB_SET_BINARY(pRaw, dataPos, swBuf, swLen, TOPIC_ENCODE_OVER); + SDB_SET_INT32(pRaw, dataPos, schemaLen, TOPIC_ENCODE_OVER); + SDB_SET_BINARY(pRaw, dataPos, swBuf, schemaLen, TOPIC_ENCODE_OVER); SDB_SET_RESERVE(pRaw, dataPos, MND_TOPIC_RESERVE_SIZE, TOPIC_ENCODE_OVER); SDB_SET_DATALEN(pRaw, dataPos, TOPIC_ENCODE_OVER); @@ -137,23 +135,25 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { SDB_GET_INT64(pRaw, dataPos, &pTopic->uid, TOPIC_DECODE_OVER); SDB_GET_INT64(pRaw, dataPos, &pTopic->dbUid, TOPIC_DECODE_OVER); SDB_GET_INT32(pRaw, dataPos, &pTopic->version, TOPIC_DECODE_OVER); - SDB_GET_INT32(pRaw, dataPos, &pTopic->sqlLen, TOPIC_DECODE_OVER); - pTopic->sql = taosMemoryCalloc(pTopic->sqlLen + 1, sizeof(char)); + SDB_GET_INT32(pRaw, dataPos, &pTopic->sqlLen, TOPIC_DECODE_OVER); + pTopic->sql = taosMemoryCalloc(pTopic->sqlLen, sizeof(char)); + if (pTopic->sql == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto TOPIC_DECODE_OVER; + } SDB_GET_BINARY(pRaw, dataPos, pTopic->sql, pTopic->sqlLen, TOPIC_DECODE_OVER); - SDB_GET_INT32(pRaw, dataPos, &len, TOPIC_DECODE_OVER); - pTopic->logicalPlan = taosMemoryCalloc(len + 1, sizeof(char)); - if (pTopic->logicalPlan == NULL) { + SDB_GET_INT32(pRaw, dataPos, &pTopic->astLen, TOPIC_DECODE_OVER); + pTopic->ast = taosMemoryCalloc(pTopic->astLen, sizeof(char)); + if (pTopic->ast == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; goto TOPIC_DECODE_OVER; } - SDB_GET_BINARY(pRaw, dataPos, pTopic->logicalPlan, len, TOPIC_DECODE_OVER); - + SDB_GET_BINARY(pRaw, dataPos, pTopic->ast, pTopic->astLen, TOPIC_DECODE_OVER); SDB_GET_INT32(pRaw, dataPos, &len, TOPIC_DECODE_OVER); - pTopic->physicalPlan = taosMemoryCalloc(len + 1, sizeof(char)); + pTopic->physicalPlan = taosMemoryCalloc(len, sizeof(char)); if (pTopic->physicalPlan == NULL) { - taosMemoryFree(pTopic->logicalPlan); terrno = TSDB_CODE_OUT_OF_MEMORY; goto TOPIC_DECODE_OVER; } @@ -257,6 +257,7 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) { return 0; } +#if 0 static int32_t mndGetPlanString(const SCMCreateTopicReq *pCreate, char **pStr) { if (NULL == pCreate->ast) { return TSDB_CODE_SUCCESS; @@ -279,6 +280,7 @@ static int32_t mndGetPlanString(const SCMCreateTopicReq *pCreate, char **pStr) { terrno = code; return code; } +#endif static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq *pCreate, SDbObj *pDb) { mDebug("topic:%s to create", pCreate->name); @@ -290,32 +292,39 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq topicObj.uid = mndGenerateUid(pCreate->name, strlen(pCreate->name)); topicObj.dbUid = pDb->uid; topicObj.version = 1; - topicObj.sql = pCreate->sql; - topicObj.physicalPlan = ""; - topicObj.logicalPlan = ""; - topicObj.sqlLen = strlen(pCreate->sql); - - char *pPlanStr = NULL; - if (TSDB_CODE_SUCCESS != mndGetPlanString(pCreate, &pPlanStr)) { - mError("topic:%s, failed to get plan since %s", pCreate->name, terrstr()); + topicObj.sql = strdup(pCreate->sql); + topicObj.sqlLen = strlen(pCreate->sql) + 1; + topicObj.ast = strdup(pCreate->ast); + topicObj.astLen = strlen(pCreate->ast) + 1; + + SNode *pAst = NULL; + if (nodesStringToNode(pCreate->ast, &pAst) != 0) { + mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); return -1; } - if (NULL != pPlanStr) { - topicObj.physicalPlan = pPlanStr; - } - SNode *pAst = NULL; - if (nodesStringToNode(pCreate->ast, &pAst) < 0) { + SQueryPlan *pPlan = NULL; + + SPlanContext cxt = {.pAstRoot = pAst, .topicQuery = true}; + if (qCreateQueryPlan(&cxt, &pPlan, NULL) != 0) { + mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); return -1; } + if (qExtractResultSchema(pAst, &topicObj.schema.nCols, &topicObj.schema.pSchema) != 0) { + mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); + return -1; + } + + if (nodesNodeToString(pPlan, false, &topicObj.physicalPlan, NULL) != 0) { + mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); return -1; } STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_TOPIC, &pReq->rpcMsg); if (pTrans == NULL) { mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); - taosMemoryFreeClear(pPlanStr); + taosMemoryFreeClear(topicObj.physicalPlan); return -1; } mDebug("trans:%d, used to create topic:%s", pTrans->id, pCreate->name); @@ -323,7 +332,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq SSdbRaw *pRedoRaw = mndTopicActionEncode(&topicObj); if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) { mError("trans:%d, failed to append redo log since %s", pTrans->id, terrstr()); - taosMemoryFreeClear(pPlanStr); + taosMemoryFreeClear(topicObj.physicalPlan); mndTransDrop(pTrans); return -1; } @@ -331,12 +340,12 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq if (mndTransPrepare(pMnode, pTrans) != 0) { mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); - taosMemoryFreeClear(pPlanStr); + taosMemoryFreeClear(topicObj.physicalPlan); mndTransDrop(pTrans); return -1; } - taosMemoryFreeClear(pPlanStr); + taosMemoryFreeClear(topicObj.physicalPlan); mndTransDrop(pTrans); return 0; } @@ -500,50 +509,6 @@ static int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTo return 0; } -static int32_t mndGetTopicMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta) { - SMnode *pMnode = pReq->pNode; - SSdb *pSdb = pMnode->pSdb; - - if (mndGetNumOfTopics(pMnode, pShow->db, &pShow->numOfRows) != 0) { - return -1; - } - - int32_t cols = 0; - SSchema *pSchema = pMeta->pSchemas; - - pShow->bytes[cols] = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "name"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = 8; - pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP; - strcpy(pSchema[cols].name, "create_time"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "sql"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pMeta->numOfColumns = cols; - pShow->numOfColumns = cols; - - pShow->offset[0] = 0; - for (int32_t i = 1; i < cols; ++i) { - pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1]; - } - - pShow->numOfRows = sdbGetSize(pSdb, SDB_TOPIC); - pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1]; - strcpy(pMeta->tbName, mndShowStr(pShow->type)); - - return 0; -} - static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) { SMnode *pMnode = pReq->pNode; SSdb *pSdb = pMnode->pSdb; diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index e1bf4b1b7d2b5eb4001ff5447b6d1c7aef48d34e..59fe7d16b92c9c1bd197b8546f40e03ee56f816b 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -58,8 +58,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans); static int32_t mndProcessTransReq(SNodeMsg *pReq); static int32_t mndProcessKillTransReq(SNodeMsg *pReq); -static int32_t mndGetTransMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta); -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) { @@ -74,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); } @@ -1260,70 +1259,7 @@ void mndTransPullup(SMnode *pMnode) { sdbWriteFile(pMnode->pSdb); } -static int32_t mndGetTransMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta) { - SMnode *pMnode = pReq->pNode; - SSdb *pSdb = pMnode->pSdb; - - int32_t cols = 0; - SSchema *pSchema = pMeta->pSchemas; - - pShow->bytes[cols] = 4; - pSchema[cols].type = TSDB_DATA_TYPE_INT; - strcpy(pSchema[cols].name, "id"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = 8; - pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP; - strcpy(pSchema[cols].name, "create_time"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "stage"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = (TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "db"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = TSDB_TRANS_TYPE_LEN + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "type"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = 8; - pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP; - strcpy(pSchema[cols].name, "last_exec_time"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pShow->bytes[cols] = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE; - pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "last_error"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; - - pMeta->numOfColumns = cols; - pShow->numOfColumns = cols; - - pShow->offset[0] = 0; - for (int32_t i = 1; i < cols; ++i) { - pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1]; - } - - pShow->numOfRows = sdbGetSize(pSdb, SDB_TRANS); - pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1]; - strcpy(pMeta->tbName, mndShowStr(pShow->type)); - return 0; -} - -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; @@ -1337,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 f765b0ce113615d31195b3f3682f5858678eb00d..3ac1c522b24b1f5581095ac0ab7e005346693d8c 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 d2aa44f37246362ed4a7e6ed48273edf4f921b8f..15f2aed22ad1ecf25b0a4dc8c290bfb66656d2e6 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(acct) +add_subdirectory(bnode) 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(sma) -#add_subdirectory(func) -#add_subdirectory(topic) +add_subdirectory(topic) +add_subdirectory(trans) +add_subdirectory(user) diff --git a/source/dnode/mnode/impl/test/acct/CMakeLists.txt b/source/dnode/mnode/impl/test/acct/CMakeLists.txt index 8c8bf54bc4f59b7146f479abded66ab8fa1c271f..40f8b0726e28446170a71bbbccde979376448fbb 100644 --- a/source/dnode/mnode/impl/test/acct/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/acct/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. ACCT_SRC) -add_executable(mnode_test_acct ${ACCT_SRC}) +aux_source_directory(. MNODE_ACCT_TEST_SRC) +add_executable(acctTest ${MNODE_ACCT_TEST_SRC}) target_link_libraries( - mnode_test_acct + acctTest PUBLIC sut ) add_test( - NAME mnode_test_acct - COMMAND mnode_test_acct + NAME acctTest + COMMAND acctTest ) diff --git a/source/dnode/mnode/impl/test/acct/acct.cpp b/source/dnode/mnode/impl/test/acct/acct.cpp index 2bc4f40614409c2dfbe99b6bd524dfcda361ee26..0260b5f59ebf1468be576a9192566b0bbb7d1698 100644 --- a/source/dnode/mnode/impl/test/acct/acct.cpp +++ b/source/dnode/mnode/impl/test/acct/acct.cpp @@ -54,17 +54,3 @@ TEST_F(MndTestAcct, 03_Drop_Acct) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_MSG_NOT_PROCESSED); } - -TEST_F(MndTestAcct, 04_Show_Acct) { - SShowReq showReq = {0}; - showReq.type = TSDB_MGMT_TABLE_ACCT; - - int32_t contLen = tSerializeSShowReq(NULL, 0, &showReq); - void* pReq = rpcMallocCont(contLen); - tSerializeSShowReq(pReq, contLen, &showReq); - tFreeSShowReq(&showReq); - - SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen); - ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_MSG_TYPE); -} \ No newline at end of file diff --git a/source/dnode/mnode/impl/test/bnode/CMakeLists.txt b/source/dnode/mnode/impl/test/bnode/CMakeLists.txt index b58b1a856bd4201de19a9c5898786cb2c2814886..310e022a911d4c7cde35e1c804f6c13be696b4f1 100644 --- a/source/dnode/mnode/impl/test/bnode/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/bnode/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. STEST_SRC) -add_executable(mnode_test_bnode ${STEST_SRC}) +aux_source_directory(. MNODE_BNODE_TEST_SRC) +add_executable(mbnodeTest ${MNODE_BNODE_TEST_SRC}) target_link_libraries( - mnode_test_bnode + mbnodeTest PUBLIC sut ) add_test( - NAME mnode_test_bnode - COMMAND mnode_test_bnode + NAME mbnodeTest + COMMAND mbnodeTest ) diff --git a/source/dnode/mnode/impl/test/bnode/bnode.cpp b/source/dnode/mnode/impl/test/bnode/mbnode.cpp similarity index 88% rename from source/dnode/mnode/impl/test/bnode/bnode.cpp rename to source/dnode/mnode/impl/test/bnode/mbnode.cpp index 33816520f2c4d19eb70d296c7a307316cfc06ebf..5e08a9995dde914e0488078e8403b0c39924963f 100644 --- a/source/dnode/mnode/impl/test/bnode/bnode.cpp +++ b/source/dnode/mnode/impl/test/bnode/mbnode.cpp @@ -39,14 +39,7 @@ Testbase MndTestBnode::test; TestServer MndTestBnode::server2; TEST_F(MndTestBnode, 01_Show_Bnode) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_BNODE, ""); - CHECK_META("show bnodes", 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_BNODE, "bnodes", ""); EXPECT_EQ(test.GetShowRows(), 0); } @@ -76,14 +69,8 @@ TEST_F(MndTestBnode, 02_Create_Bnode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_BNODE, ""); - CHECK_META("show bnodes", 3); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_BNODE, "bnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckInt16(1); - CheckBinary("localhost:9018", TSDB_EP_LEN); - CheckTimestamp(); } { @@ -115,8 +102,7 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) { 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(MndTestBnode, 03_Drop_Bnode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_BNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_BNODE, "bnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckInt16(1); - CheckInt16(2); - CheckBinary("localhost:9018", TSDB_EP_LEN); - CheckBinary("localhost:9019", TSDB_EP_LEN); - CheckTimestamp(); - CheckTimestamp(); } { @@ -156,13 +134,8 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_BNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_BNODE, "bnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckInt16(1); - CheckBinary("localhost:9018", TSDB_EP_LEN); - CheckTimestamp(); } { diff --git a/source/dnode/mnode/impl/test/db/CMakeLists.txt b/source/dnode/mnode/impl/test/db/CMakeLists.txt index d1e38854e6f0e7a181c0801bfd76b7249b03a226..3f6a80835ffa7b2a0a6fcdcff21e1cfd39a02c5f 100644 --- a/source/dnode/mnode/impl/test/db/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/db/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. DB_SRC) -add_executable(mnode_test_db ${DB_SRC}) +aux_source_directory(. MNODE_DB_TEST_SRC) +add_executable(dbTest ${MNODE_DB_TEST_SRC}) target_link_libraries( - mnode_test_db + dbTest 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 0282663b17a2ef0a8882e42c76408f76b0a83ef9..adba6ca4344eca08a0f0729d215f0ae2e8965b6d 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.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_DB, "user_databases", ""); + EXPECT_EQ(test.GetShowRows(), 3); + + 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 77cc6f0b5dbefe7dcf4c7de2e836188e19c51c13..d064df90bc8f13f9ae2b9c5bf5d313759ea0ce1e 100644 --- a/source/dnode/mnode/impl/test/dnode/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/dnode/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. DTEST_SRC) -add_executable(mnode_test_dnode ${DTEST_SRC}) +aux_source_directory(. MNODE_DNODE_TEST_SRC) +add_executable(mdnodeTest ${MNODE_DNODE_TEST_SRC}) target_link_libraries( - mnode_test_dnode + mdnodeTest 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/dnode.cpp b/source/dnode/mnode/impl/test/dnode/mdnode.cpp similarity index 70% rename from source/dnode/mnode/impl/test/dnode/dnode.cpp rename to source/dnode/mnode/impl/test/dnode/mdnode.cpp index f5755563457e272f1d293aa2038f906c922ede52..a4cbc201a96d3e5ff64e1e45190f3d3d28eb6be0 100644 --- a/source/dnode/mnode/impl/test/dnode/dnode.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 26b0a60968d9c6f236ecfb08cbccd8c75e357411..ecb4f851be9d95a7c894d1e2ef2b3d9ce83067d3 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 f34f77de0ca62e5395c230a2aed9f0d9a3d8d6a8..6b9c410738dd0e0bf4300299b7df7ede39ee1524 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 4d9b473291fda9a75996d5cd14ad3294ae5b428e..94c25281b27afc08fb59b2a67b045452bf769b22 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 dd2867f7f98fca701d205f5870443e552d95c55f..444c674667917940000ffde17850f3c29c4db8f0 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 88d7366b7d7085966a5a5aded5dc601c9c16123a..8b811ebfed3a56ab139ecfc81f3556af2f9bb032 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 14b31e52827869092d7e6f38e98f35e6c20481b7..2c3be2135b6a679ddbc7231621279057767652b8 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 77ac39e4095f05fb056cd6bf6ef5b87461e5f01c..8259f9f47d93a0685c0209b0f593583b9ab192c2 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 be214cacf24412f3961bcb6d2605d0d79589fd0e..7240e0f183389384844e99f754f41fa6883007ca 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 cc0706ca5031638774e73c981b4afcdc404a2350..69e93e7086147de77676ea02017a6ce5533acf42 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 a57d99a257c59bd3f32721186ea7d0b38057b229..201a42e3efd897dfb3ae44cf6705d03ac05817f3 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 943695abf3a1cc353b50e621d9d7975288b2616d..3f9ec123a80e88371a98fa54c99342726831372d 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 4b0e33a323b51a68092b3d679e48ec958f37b740..4f3b0d6e3769815e1f50d0e6e046b9fd69d4f1ee 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 44a5f35f94b2c1d6368b36d798b94b152d173f9b..9c60da364c3cb25c3e34155c86ffde013f0e168f 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 7d24d8915482d487fd8d6561a6274bc4c129bced..3742c06b0af3dee96a93f404a8efce8b8cd52b2c 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 eca922acc43da5f3fd737c8add16854c6a781e99..d2fe3879979f4f52a215a3d44e25e912be3abb90 100644 --- a/source/dnode/mnode/impl/test/stb/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/stb/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. STB_SRC) -add_executable(mnode_test_stb ${STB_SRC}) +aux_source_directory(. MNODE_STB_TEST_SRC) +add_executable(stbTest ${MNODE_STB_TEST_SRC}) target_link_libraries( - mnode_test_stb + stbTest 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 f45c0795cd6441546a351a0e814f7a25c5d5ae95..f8f8799c9f02828636fecfe5cb5812ee848c8555 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 63a77713d6825a709bc58c4ad5ac41f68724111b..076228ec9d2d88cfb9ede6f8122cf5cddf375445 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 5d603ab5b2059f384975234ad46a0c5af877d968..ee47a3c8b43eb8fe03f3f9fbabe1a473ef0042c6 100644 --- a/source/dnode/mnode/impl/test/topic/topic.cpp +++ b/source/dnode/mnode/impl/test/topic/topic.cpp @@ -88,6 +88,8 @@ void* MndTestTopic::BuildDropTopicReq(const char* topicName, int32_t* pContLen) } TEST_F(MndTestTopic, 01_Create_Topic) { + // TODO add valid ast for unit test +#if 0 const char* dbname = "1.d1"; const char* topicName = "1.d1.t1"; @@ -99,7 +101,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) { ASSERT_EQ(pRsp->code, 0); } - { test.SendShowMetaReq(TSDB_MGMT_TABLE_TP, ""); } + { test.SendShowReq(TSDB_MGMT_TABLE_TOPICS, ""); } { int32_t contLen = 0; @@ -126,7 +128,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) { } { - test.SendShowMetaReq(TSDB_MGMT_TABLE_TP, 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"); @@ -143,7 +145,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) { // restart test.Restart(); - test.SendShowMetaReq(TSDB_MGMT_TABLE_TP, dbname); + test.SendShowReq(TSDB_MGMT_TABLE_TOPICS, dbname); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); @@ -167,8 +169,9 @@ 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_TP, dbname); + test.SendShowReq(TSDB_MGMT_TABLE_TOPICS, dbname); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 0); } +#endif } diff --git a/source/dnode/mnode/impl/test/trans/CMakeLists.txt b/source/dnode/mnode/impl/test/trans/CMakeLists.txt index d7c9756794f810828fe4e7503e57f9b705169959..fa0ef9f26392d977ea4c091d5a714bb7b2a466b4 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 560b30d13c5d16a2ccc5a63c50c27166de7b65b4..bcf6fe8536e5468114bcbc9d736ebac328eabe27 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 c6aeef72211f7fc97bea93ba937028dc03c1997c..b39ea0e73f728cacc648f6eb0723328e028c05f4 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 97a144fdeecd1fd2064caeea0f44a73b52f61703..4e7f3c021389eb4324f70326544e75696056cebe 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 f43f0b427e618d38a718990e2046c37c48584cf7..c0e458219c9f76dc8d1fb9be837348704851a7a5 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -4,17 +4,18 @@ 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" "src/vnd/vnodeModule.c" - # "src/vnd/vnodeMgr.c" + "src/vnd/vnodeSvr.c" # meta # "src/meta/metaBDBImpl.c" @@ -25,7 +26,6 @@ target_sources( "src/meta/metaTDBImpl.c" # tsdb - # "src/tsdb/tsdbBDBImpl.c" "src/tsdb/tsdbTDBImpl.c" "src/tsdb/tsdbCommit.c" "src/tsdb/tsdbCompact.c" diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 7ed0092d36dff9bd37cbf460793454ad5836e52d..25c6ffc1ad36126e65701d3647a306e69dac9e1d 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -42,13 +42,14 @@ 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 vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs); -int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); +void vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs); +int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); int vnodeProcessCMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); int vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg); diff --git a/source/dnode/vnode/src/inc/meta.h b/source/dnode/vnode/src/inc/meta.h index d43503c1ca71df097dd45015e3930c0190dff7b7..94a1266f46a3f63a95982680a7d628523108091e 100644 --- a/source/dnode/vnode/src/inc/meta.h +++ b/source/dnode/vnode/src/inc/meta.h @@ -96,6 +96,7 @@ tb_uid_t metaGenerateUid(SMeta* pMeta); struct SMeta { char* path; + SVnode* pVnode; SMetaCfg options; SMetaDB* pDB; SMetaIdx* pIdx; diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 6fbf265d2ccb1034c40b1f8dc5a56ee729a15fa1..d0e005f990739b75b8d77274b9a1f5111d63226b 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -157,6 +157,7 @@ typedef struct { struct STsdb { int32_t vgId; + SVnode *pVnode; bool repoLocked; TdThreadMutex mutex; char *path; @@ -954,6 +955,43 @@ static FORCE_INLINE int tsdbUnLockFS(STsdbFS *pFs) { // return 0; // } +typedef struct SSmaKey SSmaKey; + +struct SSmaKey { + TSKEY skey; + int64_t groupId; +}; + +typedef struct SDBFile SDBFile; + +struct SDBFile { + int32_t fid; + TDB *pDB; + char *path; +}; + +int32_t tsdbOpenDBEnv(TENV **ppEnv, const char *path); +int32_t tsdbCloseDBEnv(TENV *pEnv); +int32_t tsdbOpenDBF(TENV *pEnv, SDBFile *pDBF); +int32_t tsdbCloseDBF(SDBFile *pDBF); +int32_t tsdbSaveSmaToDB(SDBFile *pDBF, void *pKey, int32_t keyLen, void *pVal, int32_t valLen, TXN *txn); +void *tsdbGetSmaDataByKey(SDBFile *pDBF, const void *pKey, int32_t keyLen, int32_t *valLen); + +void tsdbDestroySmaEnv(SSmaEnv *pSmaEnv); +void *tsdbFreeSmaEnv(SSmaEnv *pSmaEnv); +#if 0 +int32_t tsdbGetTSmaStatus(STsdb *pTsdb, STSma *param, void *result); +int32_t tsdbRemoveTSmaData(STsdb *pTsdb, STSma *param, STimeWindow *pWin); +#endif + +// internal func +static FORCE_INLINE int32_t tsdbEncodeTSmaKey(int64_t groupId, TSKEY tsKey, void **pData) { + int32_t len = 0; + len += taosEncodeFixedI64(pData, tsKey); + len += taosEncodeFixedI64(pData, groupId); + return len; +} + #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/src/inc/tsdbSma.h b/source/dnode/vnode/src/inc/tsdbSma.h deleted file mode 100644 index ce03fa7c678b888e6374cb23ba060f463e1c39c6..0000000000000000000000000000000000000000 --- a/source/dnode/vnode/src/inc/tsdbSma.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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_VNODE_TSDB_SMA_H_ -#define _TD_VNODE_TSDB_SMA_H_ - -#include "tdbInt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct SSmaKey SSmaKey; - -struct SSmaKey { - TSKEY skey; - int64_t groupId; -}; - - -typedef struct SDBFile SDBFile; - -struct SDBFile { - int32_t fid; - TDB *pDB; - char *path; -}; - -int32_t tsdbOpenDBEnv(TENV **ppEnv, const char *path); -int32_t tsdbCloseDBEnv(TENV *pEnv); -int32_t tsdbOpenDBF(TENV *pEnv, SDBFile *pDBF); -int32_t tsdbCloseDBF(SDBFile *pDBF); -int32_t tsdbSaveSmaToDB(SDBFile *pDBF, void *pKey, int32_t keyLen, void *pVal, int32_t valLen, TXN *txn); -void *tsdbGetSmaDataByKey(SDBFile *pDBF, const void *pKey, int32_t keyLen, int32_t *valLen); - -void tsdbDestroySmaEnv(SSmaEnv *pSmaEnv); -void *tsdbFreeSmaEnv(SSmaEnv *pSmaEnv); -#if 0 -int32_t tsdbGetTSmaStatus(STsdb *pTsdb, STSma *param, void *result); -int32_t tsdbRemoveTSmaData(STsdb *pTsdb, STSma *param, STimeWindow *pWin); -#endif - -// internal func -static FORCE_INLINE int32_t tsdbEncodeTSmaKey(int64_t groupId, TSKEY tsKey, void **pData) { - int32_t len = 0; - len += taosEncodeFixedI64(pData, tsKey); - len += taosEncodeFixedI64(pData, groupId); - return len; -} - - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_VNODE_TSDB_SMA_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index 6957cfdb73a02d1a82a6313bc15433829f283001..913fec64ed3e9f88f417641f4d007b4a5a6a0ce4 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -30,12 +30,19 @@ 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); // vnodeQuery ==================== 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); #if 1 // SVBufPool @@ -74,9 +81,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 c956184fc9fd64081c62e0bfdee92460b687a704..b0b87665edcd793537e1d35d089415a500b401f9 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -24,12 +24,12 @@ #include "tcoding.h" #include "tcompression.h" #include "tdatablock.h" +#include "tdbInt.h" #include "tfs.h" #include "tglobal.h" #include "tlist.h" #include "tlockfree.h" #include "tlosertree.h" -#include "tmacro.h" #include "tmallocator.h" #include "tskiplist.h" #include "tstream.h" @@ -43,6 +43,7 @@ extern "C" { #endif +typedef struct SVnodeInfo SVnodeInfo; typedef struct SMeta SMeta; typedef struct STsdb STsdb; typedef struct STQ STQ; @@ -72,6 +73,11 @@ struct SVState { int64_t applied; }; +struct SVnodeInfo { + SVnodeCfg config; + SVState state; +}; + struct SVnode { int32_t vgId; char* path; @@ -100,8 +106,6 @@ void smaHandleRes(void* pVnode, int64_t smaId, const SArray* data); #include "tq.h" -#include "tsdbSma.h" - #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index f57103aab431eb1d1365e7b79dee660f808a2213..bfcc5dd2bb78db54ec7162c682ddf639c0fd760a 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -126,8 +126,8 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t versi int tqCommit(STQ* pTq) { return tqStorePersist(pTq->tqMeta); } int32_t tqGetTopicHandleSize(const STqTopic* pTopic) { - return strlen(pTopic->topicName) + strlen(pTopic->sql) + strlen(pTopic->logicalPlan) + strlen(pTopic->physicalPlan) + - strlen(pTopic->qmsg) + sizeof(int64_t) * 3; + return strlen(pTopic->topicName) + strlen(pTopic->sql) + strlen(pTopic->physicalPlan) + strlen(pTopic->qmsg) + + sizeof(int64_t) * 3; } int32_t tqGetConsumerHandleSize(const STqConsumer* pConsumer) { @@ -144,7 +144,6 @@ static FORCE_INLINE int32_t tEncodeSTqTopic(void** buf, const STqTopic* pTopic) int32_t tlen = 0; tlen += taosEncodeString(buf, pTopic->topicName); /*tlen += taosEncodeString(buf, pTopic->sql);*/ - /*tlen += taosEncodeString(buf, pTopic->logicalPlan);*/ /*tlen += taosEncodeString(buf, pTopic->physicalPlan);*/ tlen += taosEncodeString(buf, pTopic->qmsg); /*tlen += taosEncodeFixedI64(buf, pTopic->persistedOffset);*/ @@ -156,7 +155,6 @@ static FORCE_INLINE int32_t tEncodeSTqTopic(void** buf, const STqTopic* pTopic) static FORCE_INLINE const void* tDecodeSTqTopic(const void* buf, STqTopic* pTopic) { buf = taosDecodeStringTo(buf, pTopic->topicName); /*buf = taosDecodeString(buf, &pTopic->sql);*/ - /*buf = taosDecodeString(buf, &pTopic->logicalPlan);*/ /*buf = taosDecodeString(buf, &pTopic->physicalPlan);*/ buf = taosDecodeString(buf, &pTopic->qmsg); /*buf = taosDecodeFixedI64(buf, &pTopic->persistedOffset);*/ @@ -722,7 +720,6 @@ int32_t tqProcessSetConnReq(STQ* pTq, char* msg) { } strcpy(pTopic->topicName, req.topicName); pTopic->sql = req.sql; - pTopic->logicalPlan = req.logicalPlan; pTopic->physicalPlan = req.physicalPlan; pTopic->qmsg = req.qmsg; /*pTopic->committedOffset = -1;*/ diff --git a/source/dnode/vnode/src/tsdb/tsdbBDBImpl.c b/source/dnode/vnode/src/tsdb/tsdbBDBImpl.c deleted file mode 100644 index acd9c2dcaa72d39dab0576d7ab809e49eb5c24ee..0000000000000000000000000000000000000000 --- a/source/dnode/vnode/src/tsdb/tsdbBDBImpl.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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 ALLOW_FORBID_FUNC -#include "db.h" - -#include "vnodeInt.h" - -#define IMPL_WITH_LOCK 1 - -static int tsdbOpenBDBDb(DB **ppDB, DB_ENV *pEnv, const char *pFName, bool isDup); -static void tsdbCloseBDBDb(DB *pDB); - -#define BDB_PERR(info, code) fprintf(stderr, "%s:%d " info " reason: %s\n", __FILE__, __LINE__, db_strerror(code)) - -int32_t tsdbOpenDBF(TDBEnv pEnv, SDBFile *pDBF) { - // TDBEnv is shared by a group of SDBFile - if (!pEnv) { - terrno = TSDB_CODE_INVALID_PTR; - return -1; - } - - // Open DBF - if (tsdbOpenBDBDb(&(pDBF->pDB), pEnv, pDBF->path, false) < 0) { - terrno = TSDB_CODE_TDB_INIT_FAILED; - tsdbCloseBDBDb(pDBF->pDB); - return -1; - } - - return 0; -} - -void tsdbCloseDBF(SDBFile *pDBF) { - if (pDBF->pDB) { - tsdbCloseBDBDb(pDBF->pDB); - pDBF->pDB = NULL; - } - taosMemoryFreeClear(pDBF->path); -} - -int32_t tsdbOpenBDBEnv(DB_ENV **ppEnv, const char *path) { - int ret = 0; - DB_ENV *pEnv = NULL; - - if (path == NULL) return 0; - - ret = db_env_create(&pEnv, 0); - if (ret != 0) { - BDB_PERR("Failed to create tsdb env", ret); - return -1; - } - - ret = pEnv->open(pEnv, path, DB_CREATE | DB_INIT_CDB | DB_INIT_MPOOL, 0); - if (ret != 0) { - terrno = TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR; - tsdbWarn("Failed to open tsdb env for path %s since ret %d != 0", path ? path : "NULL", ret); - return -1; - } - - *ppEnv = pEnv; - - return 0; -} - -void tsdbCloseBDBEnv(DB_ENV *pEnv) { - if (pEnv) { - pEnv->close(pEnv, 0); - } -} - -static int tsdbOpenBDBDb(DB **ppDB, DB_ENV *pEnv, const char *pFName, bool isDup) { - int ret; - DB *pDB; - - ret = db_create(&(pDB), pEnv, 0); - if (ret != 0) { - BDB_PERR("Failed to create DBP", ret); - return -1; - } - - if (isDup) { - ret = pDB->set_flags(pDB, DB_DUPSORT); - if (ret != 0) { - BDB_PERR("Failed to set DB flags", ret); - return -1; - } - } - - ret = pDB->open(pDB, NULL, pFName, NULL, DB_BTREE, DB_CREATE, 0); - if (ret) { - BDB_PERR("Failed to open DBF", ret); - return -1; - } - - *ppDB = pDB; - - return 0; -} - -static void tsdbCloseBDBDb(DB *pDB) { - if (pDB) { - pDB->close(pDB, 0); - } -} - -int32_t tsdbSaveSmaToDB(SDBFile *pDBF, void *key, uint32_t keySize, void *data, uint32_t dataSize) { - int ret; - DBT key1 = {0}, value1 = {0}; - - key1.data = key; - key1.size = keySize; - - value1.data = data; - value1.size = dataSize; - - // TODO: lock - ret = pDBF->pDB->put(pDBF->pDB, NULL, &key1, &value1, 0); - if (ret) { - BDB_PERR("Failed to put data to DBF", ret); - // TODO: unlock - return -1; - } - // TODO: unlock - - return 0; -} - -void *tsdbGetSmaDataByKey(SDBFile *pDBF, void *key, uint32_t keySize, uint32_t *valueSize) { - void *result = NULL; - DBT key1 = {0}; - DBT value1 = {0}; - int ret; - - // Set key/value - key1.data = key; - key1.size = keySize; - - // Query - // TODO: lock - ret = pDBF->pDB->get(pDBF->pDB, NULL, &key1, &value1, 0); - // TODO: unlock - if (ret != 0) { - return NULL; - } - - result = taosMemoryCalloc(1, value1.size); - - if (result == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; - } - - *valueSize = value1.size; - memcpy(result, value1.data, value1.size); - - return result; -} \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index 54115003cfc8a497743f17598efcb9656a0d7e2f..5a477e646cb4ea2cf94cde85608dd813bb929a14 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -375,6 +375,8 @@ static int tsdbMemTableInsertTbData(STsdb *pTsdb, SSubmitBlk *pBlock, int32_t *p if (pMemTable->keyMin > keyMin) pMemTable->keyMin = keyMin; if (pMemTable->keyMax < keyMax) pMemTable->keyMax = keyMax; + (*pAffectedRows) += pBlock->numOfRows; + // STSRow* lastRow = NULL; // int64_t osize = SL_SIZE(pTableData->pData); // tsdbSetupSkipListHookFns(pTableData->pData, pRepo, pTable, &points, &lastRow); diff --git a/source/dnode/vnode/src/tsdb/tsdbTDBImpl.c b/source/dnode/vnode/src/tsdb/tsdbTDBImpl.c index 519ecd3fa06952609c522f4ef937b8b953bc1948..ebfa1ecaeb7a044f67912c17a4e01400fc69ff2a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbTDBImpl.c +++ b/source/dnode/vnode/src/tsdb/tsdbTDBImpl.c @@ -107,8 +107,7 @@ int32_t tsdbSaveSmaToDB(SDBFile *pDBF, void *pKey, int32_t keyLen, void *pVal, i } void *tsdbGetSmaDataByKey(SDBFile *pDBF, const void *pKey, int32_t keyLen, int32_t *valLen) { - void *result; - void *pVal; + void *pVal = NULL; int ret; ret = tdbDbGet(pDBF->pDB, pKey, keyLen, &pVal, valLen); @@ -120,18 +119,10 @@ void *tsdbGetSmaDataByKey(SDBFile *pDBF, const void *pKey, int32_t keyLen, int32 ASSERT(*valLen >= 0); - result = taosMemoryMalloc(*valLen); - - if (result == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; - } - // TODO: lock? // TODO: Would the key/value be destoryed during return the data? // TODO: How about the key is updated while value length is changed? The original value buffer would be freed // automatically? - memcpy(result, pVal, *valLen); - return result; + return pVal; } \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbWrite.c b/source/dnode/vnode/src/tsdb/tsdbWrite.c index abfcc675eac4df251ecb0da8ace6cfa627754d9a..910b5adc963559f712868937abfe1d5ad160b526 100644 --- a/source/dnode/vnode/src/tsdb/tsdbWrite.c +++ b/source/dnode/vnode/src/tsdb/tsdbWrite.c @@ -31,5 +31,5 @@ int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp) { return -1; } } - return tsdbMemTableInsert(pTsdb, pTsdb->mem, pMsg, NULL); + return tsdbMemTableInsert(pTsdb, pTsdb->mem, pMsg, pRsp); } \ No newline at end of file diff --git a/source/dnode/vnode/src/vnd/vnodeBufferPool2.c b/source/dnode/vnode/src/vnd/vnodeBufferPool2.c new file mode 100644 index 0000000000000000000000000000000000000000..d63c86734a4573112fd449dc8cb23e6a8f91af7e --- /dev/null +++ b/source/dnode/vnode/src/vnd/vnodeBufferPool2.c @@ -0,0 +1,149 @@ +/* + * 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 "vnodeInt.h" + +/* ------------------------ STRUCTURES ------------------------ */ + +static int vnodeBufPoolCreate(int size, SVBufPool **ppPool); +static int vnodeBufPoolDestroy(SVBufPool *pPool); + +int vnodeOpenBufPool(SVnode *pVnode, int64_t size) { + SVBufPool *pPool = NULL; + int ret; + + ASSERT(pVnode->pPool == NULL); + + for (int i = 0; i < 3; i++) { + // create pool + ret = vnodeBufPoolCreate(size, &pPool); + if (ret < 0) { + vError("vgId:%d failed to open vnode buffer pool since %s", TD_VNODE_ID(pVnode), tstrerror(terrno)); + vnodeCloseBufPool(pVnode); + return -1; + } + + // add pool to queue + pPool->next = pVnode->pPool; + pVnode->pPool = pPool; + } + + vDebug("vgId:%d vnode buffer pool is opened, pool size: %" PRId64, TD_VNODE_ID(pVnode), size); + + return 0; +} + +int vnodeCloseBufPool(SVnode *pVnode) { + SVBufPool *pPool; + + for (pPool = pVnode->pPool; pPool; pPool = pVnode->pPool) { + pVnode->pPool = pPool->next; + vnodeBufPoolDestroy(pPool); + } + + vDebug("vgId:%d vnode buffer pool is closed", TD_VNODE_ID(pVnode)); + + return 0; +} + +void vnodeBufPoolReset(SVBufPool *pPool) { + SVBufPoolNode *pNode; + + for (pNode = pPool->pTail; pNode->prev; pNode = pPool->pTail) { + ASSERT(pNode->pnext == &pPool->pTail); + pNode->prev->pnext = &pPool->pTail; + pPool->pTail = pNode->prev; + pPool->size = pPool->size - sizeof(*pNode) - pNode->size; + taosMemoryFree(pNode); + } + + ASSERT(pPool->size == pPool->ptr - pPool->node.data); + + pPool->size = 0; + pPool->ptr = pPool->node.data; +} + +void *vnodeBufPoolMalloc(SVBufPool *pPool, size_t size) { + SVBufPoolNode *pNode; + void *p; + + if (pPool->node.size >= pPool->ptr - pPool->node.data + size) { + // allocate from the anchor node + p = pPool->ptr; + pPool->ptr = pPool->ptr + size; + pPool->size += size; + } else { + // allocate a new node + pNode = taosMemoryMalloc(sizeof(*pNode) + size); + if (pNode == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + + p = pNode->data; + pNode->size = size; + pNode->prev = pPool->pTail; + pNode->pnext = &pPool->pTail; + pPool->pTail->pnext = &pNode->prev; + pPool->pTail = pNode; + + pPool->size = pPool->size + sizeof(*pNode) + size; + } + + return p; +} + +void vnodeBufPoolFree(SVBufPool *pPool, void *p) { + uint8_t *ptr = (uint8_t *)p; + SVBufPoolNode *pNode; + + if (ptr < pPool->node.data || ptr >= pPool->node.data + pPool->node.size) { + pNode = &((SVBufPoolNode *)p)[-1]; + *pNode->pnext = pNode->prev; + pNode->prev->pnext = pNode->pnext; + + pPool->size = pPool->size - sizeof(*pNode) - pNode->size; + taosMemoryFree(pNode); + } +} + +// STATIC METHODS ------------------- +static int vnodeBufPoolCreate(int size, SVBufPool **ppPool) { + SVBufPool *pPool; + + pPool = taosMemoryMalloc(sizeof(SVBufPool) + size); + if (pPool == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + pPool->next = NULL; + pPool->nRef = 0; + pPool->size = 0; + pPool->ptr = pPool->node.data; + pPool->pTail = &pPool->node; + pPool->node.prev = NULL; + pPool->node.pnext = &pPool->pTail; + pPool->node.size = size; + + *ppPool = pPool; + return 0; +} + +static int vnodeBufPoolDestroy(SVBufPool *pPool) { + vnodeBufPoolReset(pPool); + taosMemoryFree(pPool); + return 0; +} \ No newline at end of file diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index ef417cabc6d7e29959e3b5929527c1fca3688671..34b983c20c7f344288bd4f7dad7fb6ad624882fd 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 b4c3725a5e9f402c911f828d21aeb92280006d96..fc74ee92537e7ef533998dde04c465665d229d3b 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -15,11 +15,86 @@ #include "vnodeInt.h" +#define VND_INFO_FNAME "vnode.json" +#define VND_INFO_FNAME_TMP "vnode_tmp.json" + +static int vnodeEncodeInfo(const SVnodeInfo *pInfo, uint8_t **ppData, int *len); +static int vnodeDecodeInfo(uint8_t *pData, int len, 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; + uint8_t *data; + int len; + + snprintf(fname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME_TMP); + + // encode info + data = NULL; + len = 0; + + if (vnodeEncodeInfo(pInfo, &data, &len) < 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, len) < 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) { + // TODO + return 0; +} + int vnodeAsyncCommit(SVnode *pVnode) { vnodeWaitCommit(pVnode); @@ -60,4 +135,14 @@ 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 vnodeEncodeInfo(const SVnodeInfo *pInfo, uint8_t **ppData, int *len) { + // TODO + return 0; +} + +static int vnodeDecodeInfo(uint8_t *pData, int len, SVnodeInfo *pInfo) { + // TODO + return 0; +} diff --git a/source/dnode/vnode/src/vnd/vnodeInt.c b/source/dnode/vnode/src/vnd/vnodeInt.c index 270dc377b97968a28798a96eae37f69c990de8dd..10d8154a15dc40590648b2d661d6e6068897753e 100644 --- a/source/dnode/vnode/src/vnd/vnodeInt.c +++ b/source/dnode/vnode/src/vnd/vnodeInt.c @@ -21,25 +21,4 @@ int32_t vnodeAlter(SVnode *pVnode, const SVnodeCfg *pCfg) { return 0; } int32_t vnodeCompact(SVnode *pVnode) { return 0; } -int32_t vnodeSync(SVnode *pVnode) { return 0; } - -int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { - pLoad->vgId = pVnode->vgId; - pLoad->role = TAOS_SYNC_STATE_LEADER; - pLoad->numOfTables = metaGetTbNum(pVnode->pMeta); - pLoad->numOfTimeSeries = 400; - pLoad->totalStorage = 300; - pLoad->compStorage = 200; - pLoad->pointsWritten = 100; - pLoad->numOfSelectReqs = 1; - pLoad->numOfInsertReqs = 3; - pLoad->numOfInsertSuccessReqs = 2; - pLoad->numOfBatchInsertReqs = 5; - pLoad->numOfBatchInsertSuccessReqs = 4; - return 0; -} - -int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { - /*vInfo("sync message is processed");*/ - return 0; -} +int32_t vnodeSync(SVnode *pVnode) { return 0; } \ No newline at end of file diff --git a/source/dnode/vnode/src/vnd/vnodeMain.c b/source/dnode/vnode/src/vnd/vnodeOpen.c similarity index 81% rename from source/dnode/vnode/src/vnd/vnodeMain.c rename to source/dnode/vnode/src/vnd/vnodeOpen.c index 2fd848a39d07f38b2607ad2f0c40b2b67dde54dc..5fa14f6018bd2bd78516214aec067b74bd82fecd 100644 --- a/source/dnode/vnode/src/vnd/vnodeMain.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -20,11 +20,40 @@ 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; + } + + 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 +65,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/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 87ce471de9b2f6a91ee9b07d444bab384eb1dbc5..75079d50b285ff87bfed713e30d4adf7daba6862 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -15,64 +15,13 @@ #include "vnodeInt.h" -static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg); - int vnodeQueryOpen(SVnode *pVnode) { return qWorkerInit(NODE_TYPE_VNODE, pVnode->vgId, NULL, (void **)&pVnode->pQuery, &pVnode->msgCb); } void vnodeQueryClose(SVnode *pVnode) { qWorkerDestroy((void **)&pVnode->pQuery); } -int vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) { - vTrace("message in query queue is processing"); - SReadHandle handle = {.reader = pVnode->pTsdb, .meta = pVnode->pMeta, .config = &pVnode->config}; - - switch (pMsg->msgType) { - case TDMT_VND_QUERY: - return qWorkerProcessQueryMsg(&handle, pVnode->pQuery, pMsg); - case TDMT_VND_QUERY_CONTINUE: - return qWorkerProcessCQueryMsg(&handle, pVnode->pQuery, pMsg); - default: - vError("unknown msg type:%d in query queue", pMsg->msgType); - return TSDB_CODE_VND_APP_ERROR; - } -} - -int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { - vTrace("message in fetch queue is processing"); - char *msgstr = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); - int32_t msgLen = pMsg->contLen - sizeof(SMsgHead); - switch (pMsg->msgType) { - case TDMT_VND_FETCH: - return qWorkerProcessFetchMsg(pVnode, pVnode->pQuery, pMsg); - case TDMT_VND_FETCH_RSP: - return qWorkerProcessFetchRsp(pVnode, pVnode->pQuery, pMsg); - case TDMT_VND_RES_READY: - return qWorkerProcessReadyMsg(pVnode, pVnode->pQuery, pMsg); - case TDMT_VND_TASKS_STATUS: - return qWorkerProcessStatusMsg(pVnode, pVnode->pQuery, pMsg); - case TDMT_VND_CANCEL_TASK: - return qWorkerProcessCancelMsg(pVnode, pVnode->pQuery, pMsg); - case TDMT_VND_DROP_TASK: - return qWorkerProcessDropMsg(pVnode, pVnode->pQuery, pMsg); - case TDMT_VND_TABLE_META: - return vnodeGetTableMeta(pVnode, pMsg); - case TDMT_VND_CONSUME: - return tqProcessPollReq(pVnode->pTq, pMsg, pInfo->workerId); - case TDMT_VND_TASK_PIPE_EXEC: - case TDMT_VND_TASK_MERGE_EXEC: - return tqProcessTaskExec(pVnode->pTq, msgstr, msgLen, 0); - case TDMT_VND_STREAM_TRIGGER: - return tqProcessStreamTrigger(pVnode->pTq, pMsg->pCont, pMsg->contLen, 0); - case TDMT_VND_QUERY_HEARTBEAT: - return qWorkerProcessHbMsg(pVnode, pVnode->pQuery, pMsg); - default: - vError("unknown msg type:%d in fetch queue", pMsg->msgType); - return TSDB_CODE_VND_APP_ERROR; - } -} - -static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) { +int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) { STbCfg *pTbCfg = NULL; STbCfg *pStbCfg = NULL; tb_uid_t uid; @@ -200,3 +149,19 @@ _exit: tmsgSendRsp(&rpcMsg); return TSDB_CODE_SUCCESS; } + +int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { + pLoad->vgId = pVnode->vgId; + pLoad->role = TAOS_SYNC_STATE_LEADER; + pLoad->numOfTables = metaGetTbNum(pVnode->pMeta); + pLoad->numOfTimeSeries = 400; + pLoad->totalStorage = 300; + pLoad->compStorage = 200; + pLoad->pointsWritten = 100; + pLoad->numOfSelectReqs = 1; + pLoad->numOfInsertReqs = 3; + pLoad->numOfInsertSuccessReqs = 2; + pLoad->numOfBatchInsertReqs = 5; + pLoad->numOfBatchInsertSuccessReqs = 4; + return 0; +} diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c new file mode 100644 index 0000000000000000000000000000000000000000..395f715b8fd1d7e3ceabcdc11c62242d2d5edce3 --- /dev/null +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -0,0 +1,302 @@ +/* + * 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 "vnodeInt.h" + +static int vnodeProcessCreateStbReq(SVnode *pVnode, void *pReq); +static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SRpcMsg **pRsp); +static int vnodeProcessAlterStbReq(SVnode *pVnode, void *pReq); + +void vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs) { + SNodeMsg *pMsg; + SRpcMsg *pRpc; + + for (int i = 0; i < taosArrayGetSize(pMsgs); i++) { + pMsg = *(SNodeMsg **)taosArrayGet(pMsgs, i); + pRpc = &pMsg->rpcMsg; + + // set request version + void *pBuf = POINTER_SHIFT(pRpc->pCont, sizeof(SMsgHead)); + int64_t ver = pVnode->state.processed++; + taosEncodeFixedI64(&pBuf, ver); + + if (walWrite(pVnode->pWal, ver, pRpc->msgType, pRpc->pCont, pRpc->contLen) < 0) { + // TODO: handle error + /*ASSERT(false);*/ + vError("vnode:%d write wal error since %s", pVnode->vgId, terrstr()); + } + } + + walFsync(pVnode->pWal, false); +} + +int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { + void *ptr = NULL; + int ret; + + if (pVnode->config.streamMode == 0) { + ptr = vnodeMalloc(pVnode, pMsg->contLen); + if (ptr == NULL) { + // TODO: handle error + } + + // TODO: copy here need to be extended + memcpy(ptr, pMsg->pCont, pMsg->contLen); + } + + // todo: change the interface here + int64_t ver; + taosDecodeFixedI64(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &ver); + if (tqPushMsg(pVnode->pTq, pMsg->pCont, pMsg->contLen, pMsg->msgType, ver) < 0) { + // TODO: handle error + } + + switch (pMsg->msgType) { + case TDMT_VND_CREATE_STB: + ret = vnodeProcessCreateStbReq(pVnode, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))); + return 0; + case TDMT_VND_CREATE_TABLE: + return vnodeProcessCreateTbReq(pVnode, pMsg, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), pRsp); + case TDMT_VND_ALTER_STB: + return vnodeProcessAlterStbReq(pVnode, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))); + case TDMT_VND_DROP_STB: + vTrace("vgId:%d, process drop stb req", pVnode->vgId); + break; + case TDMT_VND_DROP_TABLE: + break; + case TDMT_VND_SUBMIT: + /*printf("vnode %d write data %ld\n", pVnode->vgId, ver);*/ + if (pVnode->config.streamMode == 0) { + if (tsdbInsertData(pVnode->pTsdb, (SSubmitReq *)ptr, NULL) < 0) { + // TODO: handle error + } + } + break; + case TDMT_VND_MQ_SET_CONN: { + if (tqProcessSetConnReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) { + // TODO: handle error + } + } break; + case TDMT_VND_MQ_REB: { + if (tqProcessRebReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) { + } + } break; + case TDMT_VND_MQ_CANCEL_CONN: { + if (tqProcessCancelConnReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) { + } + } break; + case TDMT_VND_TASK_DEPLOY: { + if (tqProcessTaskDeploy(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), + pMsg->contLen - sizeof(SMsgHead)) < 0) { + } + } break; + case TDMT_VND_TASK_WRITE_EXEC: { + if (tqProcessTaskExec(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), pMsg->contLen - sizeof(SMsgHead), + 0) < 0) { + } + } break; + case TDMT_VND_CREATE_SMA: { // timeRangeSMA + + if (tsdbCreateTSma(pVnode->pTsdb, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) { + // TODO + } + // } break; + // case TDMT_VND_CANCEL_SMA: { // timeRangeSMA + // } break; + // case TDMT_VND_DROP_SMA: { // timeRangeSMA + // if (tsdbDropTSma(pVnode->pTsdb, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) { + // // TODO + // } + + } break; + default: + ASSERT(0); + break; + } + + pVnode->state.applied = ver; + + // Check if it needs to commit + if (vnodeShouldCommit(pVnode)) { + // tsem_wait(&(pVnode->canCommit)); + if (vnodeAsyncCommit(pVnode) < 0) { + // TODO: handle error + } + } + + return 0; +} + +int vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) { + vTrace("message in query queue is processing"); + SReadHandle handle = {.reader = pVnode->pTsdb, .meta = pVnode->pMeta, .config = &pVnode->config}; + + switch (pMsg->msgType) { + case TDMT_VND_QUERY: + return qWorkerProcessQueryMsg(&handle, pVnode->pQuery, pMsg); + case TDMT_VND_QUERY_CONTINUE: + return qWorkerProcessCQueryMsg(&handle, pVnode->pQuery, pMsg); + default: + vError("unknown msg type:%d in query queue", pMsg->msgType); + return TSDB_CODE_VND_APP_ERROR; + } +} + +int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { + vTrace("message in fetch queue is processing"); + char *msgstr = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); + int32_t msgLen = pMsg->contLen - sizeof(SMsgHead); + switch (pMsg->msgType) { + case TDMT_VND_FETCH: + return qWorkerProcessFetchMsg(pVnode, pVnode->pQuery, pMsg); + case TDMT_VND_FETCH_RSP: + return qWorkerProcessFetchRsp(pVnode, pVnode->pQuery, pMsg); + case TDMT_VND_RES_READY: + return qWorkerProcessReadyMsg(pVnode, pVnode->pQuery, pMsg); + case TDMT_VND_TASKS_STATUS: + return qWorkerProcessStatusMsg(pVnode, pVnode->pQuery, pMsg); + case TDMT_VND_CANCEL_TASK: + return qWorkerProcessCancelMsg(pVnode, pVnode->pQuery, pMsg); + case TDMT_VND_DROP_TASK: + return qWorkerProcessDropMsg(pVnode, pVnode->pQuery, pMsg); + case TDMT_VND_TABLE_META: + return vnodeGetTableMeta(pVnode, pMsg); + case TDMT_VND_CONSUME: + return tqProcessPollReq(pVnode->pTq, pMsg, pInfo->workerId); + case TDMT_VND_TASK_PIPE_EXEC: + case TDMT_VND_TASK_MERGE_EXEC: + return tqProcessTaskExec(pVnode->pTq, msgstr, msgLen, 0); + case TDMT_VND_STREAM_TRIGGER: + return tqProcessStreamTrigger(pVnode->pTq, pMsg->pCont, pMsg->contLen, 0); + case TDMT_VND_QUERY_HEARTBEAT: + return qWorkerProcessHbMsg(pVnode, pVnode->pQuery, pMsg); + default: + vError("unknown msg type:%d in fetch queue", pMsg->msgType); + return TSDB_CODE_VND_APP_ERROR; + } +} + +// TODO: remove the function +void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) { + // TODO + + // blockDebugShowData(data); + tsdbInsertTSmaData(((SVnode *)pVnode)->pTsdb, smaId, (const char *)data); +} + +int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { + /*vInfo("sync message is processed");*/ + return 0; +} + +static int vnodeProcessCreateStbReq(SVnode *pVnode, void *pReq) { + SVCreateTbReq vCreateTbReq = {0}; + tDeserializeSVCreateTbReq(pReq, &vCreateTbReq); + if (metaCreateTable(pVnode->pMeta, &(vCreateTbReq)) < 0) { + // TODO + return -1; + } + + taosMemoryFree(vCreateTbReq.stbCfg.pSchema); + taosMemoryFree(vCreateTbReq.stbCfg.pTagSchema); + if (vCreateTbReq.stbCfg.pRSmaParam) { + taosMemoryFree(vCreateTbReq.stbCfg.pRSmaParam->pFuncIds); + taosMemoryFree(vCreateTbReq.stbCfg.pRSmaParam); + } + taosMemoryFree(vCreateTbReq.dbFName); + taosMemoryFree(vCreateTbReq.name); + + return 0; +} + +static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SRpcMsg **pRsp) { + SVCreateTbBatchReq vCreateTbBatchReq = {0}; + SVCreateTbBatchRsp vCreateTbBatchRsp = {0}; + tDeserializeSVCreateTbBatchReq(pReq, &vCreateTbBatchReq); + int reqNum = taosArrayGetSize(vCreateTbBatchReq.pArray); + for (int i = 0; i < reqNum; i++) { + SVCreateTbReq *pCreateTbReq = taosArrayGet(vCreateTbBatchReq.pArray, i); + + char tableFName[TSDB_TABLE_FNAME_LEN]; + SMsgHead *pHead = (SMsgHead *)pMsg->pCont; + sprintf(tableFName, "%s.%s", pCreateTbReq->dbFName, pCreateTbReq->name); + + int32_t code = vnodeValidateTableHash(&pVnode->config, tableFName); + if (code) { + SVCreateTbRsp rsp; + rsp.code = code; + + taosArrayPush(vCreateTbBatchRsp.rspList, &rsp); + } + + if (metaCreateTable(pVnode->pMeta, pCreateTbReq) < 0) { + // TODO: handle error + vError("vgId:%d, failed to create table: %s", pVnode->vgId, pCreateTbReq->name); + } + // TODO: to encapsule a free API + taosMemoryFree(pCreateTbReq->name); + taosMemoryFree(pCreateTbReq->dbFName); + if (pCreateTbReq->type == TD_SUPER_TABLE) { + taosMemoryFree(pCreateTbReq->stbCfg.pSchema); + taosMemoryFree(pCreateTbReq->stbCfg.pTagSchema); + if (pCreateTbReq->stbCfg.pRSmaParam) { + taosMemoryFree(pCreateTbReq->stbCfg.pRSmaParam->pFuncIds); + taosMemoryFree(pCreateTbReq->stbCfg.pRSmaParam); + } + } else if (pCreateTbReq->type == TD_CHILD_TABLE) { + taosMemoryFree(pCreateTbReq->ctbCfg.pTag); + } else { + taosMemoryFree(pCreateTbReq->ntbCfg.pSchema); + if (pCreateTbReq->ntbCfg.pRSmaParam) { + taosMemoryFree(pCreateTbReq->ntbCfg.pRSmaParam->pFuncIds); + taosMemoryFree(pCreateTbReq->ntbCfg.pRSmaParam); + } + } + } + + vTrace("vgId:%d process create %" PRIzu " tables", pVnode->vgId, taosArrayGetSize(vCreateTbBatchReq.pArray)); + taosArrayDestroy(vCreateTbBatchReq.pArray); + if (vCreateTbBatchRsp.rspList) { + int32_t contLen = tSerializeSVCreateTbBatchRsp(NULL, 0, &vCreateTbBatchRsp); + void *msg = rpcMallocCont(contLen); + tSerializeSVCreateTbBatchRsp(msg, contLen, &vCreateTbBatchRsp); + taosArrayDestroy(vCreateTbBatchRsp.rspList); + + *pRsp = taosMemoryCalloc(1, sizeof(SRpcMsg)); + (*pRsp)->msgType = TDMT_VND_CREATE_TABLE_RSP; + (*pRsp)->pCont = msg; + (*pRsp)->contLen = contLen; + (*pRsp)->handle = pMsg->handle; + (*pRsp)->ahandle = pMsg->ahandle; + } + + return 0; +} + +static int vnodeProcessAlterStbReq(SVnode *pVnode, void *pReq) { + SVCreateTbReq vAlterTbReq = {0}; + vTrace("vgId:%d, process alter stb req", pVnode->vgId); + tDeserializeSVCreateTbReq(pReq, &vAlterTbReq); + // TODO: to encapsule a free API + taosMemoryFree(vAlterTbReq.stbCfg.pSchema); + taosMemoryFree(vAlterTbReq.stbCfg.pTagSchema); + if (vAlterTbReq.stbCfg.pRSmaParam) { + taosMemoryFree(vAlterTbReq.stbCfg.pRSmaParam->pFuncIds); + taosMemoryFree(vAlterTbReq.stbCfg.pRSmaParam); + } + taosMemoryFree(vAlterTbReq.dbFName); + taosMemoryFree(vAlterTbReq.name); + return 0; +} \ No newline at end of file diff --git a/source/dnode/vnode/src/vnd/vnodeWrite.c b/source/dnode/vnode/src/vnd/vnodeWrite.c index 24b5d4bae50774f8d7aea3039ad72cf679bb6a87..16b881f00d58f27120ccd3fd0ecd229a84d7935b 100644 --- a/source/dnode/vnode/src/vnd/vnodeWrite.c +++ b/source/dnode/vnode/src/vnd/vnodeWrite.c @@ -15,277 +15,4 @@ #include "vnodeInt.h" -void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) { - // TODO - - // blockDebugShowData(data); - tsdbInsertTSmaData(((SVnode *)pVnode)->pTsdb, smaId, (const char *)data); -} - -void vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) { - SNodeMsg *pMsg; - SRpcMsg *pRpc; - - for (int i = 0; i < taosArrayGetSize(pMsgs); i++) { - pMsg = *(SNodeMsg **)taosArrayGet(pMsgs, i); - pRpc = &pMsg->rpcMsg; - - // set request version - void *pBuf = POINTER_SHIFT(pRpc->pCont, sizeof(SMsgHead)); - int64_t ver = pVnode->state.processed++; - taosEncodeFixedI64(&pBuf, ver); - - if (walWrite(pVnode->pWal, ver, pRpc->msgType, pRpc->pCont, pRpc->contLen) < 0) { - // TODO: handle error - /*ASSERT(false);*/ - vError("vnode:%d write wal error since %s", pVnode->vgId, terrstr()); - } - } - - walFsync(pVnode->pWal, false); - - // TODO: Integrate RAFT module here - - // No results are returned because error handling is difficult - // return 0; -} - -int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { - void *ptr = NULL; - - if (pVnode->config.streamMode == 0) { - ptr = vnodeMalloc(pVnode, pMsg->contLen); - if (ptr == NULL) { - // TODO: handle error - } - - // TODO: copy here need to be extended - memcpy(ptr, pMsg->pCont, pMsg->contLen); - } - - // todo: change the interface here - int64_t ver; - taosDecodeFixedI64(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &ver); - if (tqPushMsg(pVnode->pTq, pMsg->pCont, pMsg->contLen, pMsg->msgType, ver) < 0) { - // TODO: handle error - } - - switch (pMsg->msgType) { - case TDMT_VND_CREATE_STB: { - SVCreateTbReq vCreateTbReq = {0}; - tDeserializeSVCreateTbReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vCreateTbReq); - if (metaCreateTable(pVnode->pMeta, &(vCreateTbReq)) < 0) { - // TODO: handle error - } - - // TODO: to encapsule a free API - taosMemoryFree(vCreateTbReq.stbCfg.pSchema); - taosMemoryFree(vCreateTbReq.stbCfg.pTagSchema); - if (vCreateTbReq.stbCfg.pRSmaParam) { - taosMemoryFree(vCreateTbReq.stbCfg.pRSmaParam->pFuncIds); - taosMemoryFree(vCreateTbReq.stbCfg.pRSmaParam); - } - taosMemoryFree(vCreateTbReq.dbFName); - taosMemoryFree(vCreateTbReq.name); - break; - } - case TDMT_VND_CREATE_TABLE: { - SVCreateTbBatchReq vCreateTbBatchReq = {0}; - SVCreateTbBatchRsp vCreateTbBatchRsp = {0}; - tDeserializeSVCreateTbBatchReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vCreateTbBatchReq); - int reqNum = taosArrayGetSize(vCreateTbBatchReq.pArray); - for (int i = 0; i < reqNum; i++) { - SVCreateTbReq *pCreateTbReq = taosArrayGet(vCreateTbBatchReq.pArray, i); - - char tableFName[TSDB_TABLE_FNAME_LEN]; - SMsgHead *pHead = (SMsgHead *)pMsg->pCont; - sprintf(tableFName, "%s.%s", pCreateTbReq->dbFName, pCreateTbReq->name); - - int32_t code = vnodeValidateTableHash(&pVnode->config, tableFName); - if (code) { - SVCreateTbRsp rsp; - rsp.code = code; - - taosArrayPush(vCreateTbBatchRsp.rspList, &rsp); - } - - if (metaCreateTable(pVnode->pMeta, pCreateTbReq) < 0) { - // TODO: handle error - vError("vgId:%d, failed to create table: %s", pVnode->vgId, pCreateTbReq->name); - } - // TODO: to encapsule a free API - taosMemoryFree(pCreateTbReq->name); - taosMemoryFree(pCreateTbReq->dbFName); - if (pCreateTbReq->type == TD_SUPER_TABLE) { - taosMemoryFree(pCreateTbReq->stbCfg.pSchema); - taosMemoryFree(pCreateTbReq->stbCfg.pTagSchema); - if (pCreateTbReq->stbCfg.pRSmaParam) { - taosMemoryFree(pCreateTbReq->stbCfg.pRSmaParam->pFuncIds); - taosMemoryFree(pCreateTbReq->stbCfg.pRSmaParam); - } - } else if (pCreateTbReq->type == TD_CHILD_TABLE) { - taosMemoryFree(pCreateTbReq->ctbCfg.pTag); - } else { - taosMemoryFree(pCreateTbReq->ntbCfg.pSchema); - if (pCreateTbReq->ntbCfg.pRSmaParam) { - taosMemoryFree(pCreateTbReq->ntbCfg.pRSmaParam->pFuncIds); - taosMemoryFree(pCreateTbReq->ntbCfg.pRSmaParam); - } - } - } - - vTrace("vgId:%d process create %" PRIzu " tables", pVnode->vgId, taosArrayGetSize(vCreateTbBatchReq.pArray)); - taosArrayDestroy(vCreateTbBatchReq.pArray); - if (vCreateTbBatchRsp.rspList) { - int32_t contLen = tSerializeSVCreateTbBatchRsp(NULL, 0, &vCreateTbBatchRsp); - void *msg = rpcMallocCont(contLen); - tSerializeSVCreateTbBatchRsp(msg, contLen, &vCreateTbBatchRsp); - taosArrayDestroy(vCreateTbBatchRsp.rspList); - - *pRsp = taosMemoryCalloc(1, sizeof(SRpcMsg)); - (*pRsp)->msgType = TDMT_VND_CREATE_TABLE_RSP; - (*pRsp)->pCont = msg; - (*pRsp)->contLen = contLen; - (*pRsp)->handle = pMsg->handle; - (*pRsp)->ahandle = pMsg->ahandle; - } - break; - } - case TDMT_VND_ALTER_STB: { - SVCreateTbReq vAlterTbReq = {0}; - vTrace("vgId:%d, process alter stb req", pVnode->vgId); - tDeserializeSVCreateTbReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vAlterTbReq); - // TODO: to encapsule a free API - taosMemoryFree(vAlterTbReq.stbCfg.pSchema); - taosMemoryFree(vAlterTbReq.stbCfg.pTagSchema); - if (vAlterTbReq.stbCfg.pRSmaParam) { - taosMemoryFree(vAlterTbReq.stbCfg.pRSmaParam->pFuncIds); - taosMemoryFree(vAlterTbReq.stbCfg.pRSmaParam); - } - taosMemoryFree(vAlterTbReq.dbFName); - taosMemoryFree(vAlterTbReq.name); - break; - } - case TDMT_VND_DROP_STB: - vTrace("vgId:%d, process drop stb req", pVnode->vgId); - break; - case TDMT_VND_DROP_TABLE: - // if (metaDropTable(pVnode->pMeta, vReq.dtReq.uid) < 0) { - // // TODO: handle error - // } - break; - case TDMT_VND_SUBMIT: - /*printf("vnode %d write data %ld\n", pVnode->vgId, ver);*/ - if (pVnode->config.streamMode == 0) { - if (tsdbInsertData(pVnode->pTsdb, (SSubmitReq *)ptr, NULL) < 0) { - // TODO: handle error - } - } - break; - case TDMT_VND_MQ_SET_CONN: { - if (tqProcessSetConnReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) { - // TODO: handle error - } - } break; - case TDMT_VND_MQ_REB: { - if (tqProcessRebReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) { - } - } break; - case TDMT_VND_MQ_CANCEL_CONN: { - if (tqProcessCancelConnReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) { - } - } break; - case TDMT_VND_TASK_DEPLOY: { - if (tqProcessTaskDeploy(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), - pMsg->contLen - sizeof(SMsgHead)) < 0) { - } - } break; - case TDMT_VND_TASK_WRITE_EXEC: { - if (tqProcessTaskExec(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), pMsg->contLen - sizeof(SMsgHead), - 0) < 0) { - } - } break; - case TDMT_VND_CREATE_SMA: { // timeRangeSMA -#if 0 - - SSmaCfg vCreateSmaReq = {0}; - if (tDeserializeSVCreateTSmaReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vCreateSmaReq) == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - vWarn("vgId:%d TDMT_VND_CREATE_SMA received but deserialize failed since %s", pVnode->config.vgId, - terrstr(terrno)); - return -1; - } - vDebug("vgId:%d TDMT_VND_CREATE_SMA msg received for %s:%" PRIi64, pVnode->config.vgId, - vCreateSmaReq.tSma.indexName, vCreateSmaReq.tSma.indexUid); - - // record current timezone of server side - vCreateSmaReq.tSma.timezoneInt = tsTimezone; - - if (metaCreateTSma(pVnode->pMeta, &vCreateSmaReq) < 0) { - // TODO: handle error - tdDestroyTSma(&vCreateSmaReq.tSma); - return -1; - } - - tsdbTSmaAdd(pVnode->pTsdb, 1); - - tdDestroyTSma(&vCreateSmaReq.tSma); - // TODO: return directly or go on follow steps? -#endif - if (tsdbCreateTSma(pVnode->pTsdb, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) { - // TODO - } - // } break; - // case TDMT_VND_CANCEL_SMA: { // timeRangeSMA - // } break; - // case TDMT_VND_DROP_SMA: { // timeRangeSMA - // if (tsdbDropTSma(pVnode->pTsdb, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) { - // // TODO - // } -#if 0 - tsdbTSmaSub(pVnode->pTsdb, 1); - SVDropTSmaReq vDropSmaReq = {0}; - if (tDeserializeSVDropTSmaReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vDropSmaReq) == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - // TODO: send msg to stream computing to drop tSma - // if ((send msg to stream computing) < 0) { - // tdDestroyTSma(&vCreateSmaReq); - // return -1; - // } - // - - if (metaDropTSma(pVnode->pMeta, vDropSmaReq.indexUid) < 0) { - // TODO: handle error - return -1; - } - - if(tsdbDropTSmaData(pVnode->pTsdb, vDropSmaReq.indexUid) < 0) { - // TODO: handle error - return -1; - } - - // TODO: return directly or go on follow steps? -#endif - } break; - default: - ASSERT(0); - break; - } - - pVnode->state.applied = ver; - - // Check if it needs to commit - if (vnodeShouldCommit(pVnode)) { - // tsem_wait(&(pVnode->canCommit)); - if (vnodeAsyncCommit(pVnode) < 0) { - // TODO: handle error - } - } - - return 0; -} - /* ------------------------ STATIC METHODS ------------------------ */ diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index 09f51dc03e6e926e8599fcc65f3dca0314145e65..8938084724d2f708d269785ee78de7e756a7bdef 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 2aa858fe06744bff622d984aa692df588f027fb5..21e0be40a434e1dd097177a2d21325d8dada9b56 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/executorimpl.h b/source/libs/executor/inc/executorimpl.h index cbd2dc66f5f9dfa8e2c7219ab2a67e659ec3779f..78bc6947cd9cedbcd44800b1445756e92ca83aea 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -549,8 +549,6 @@ typedef struct SStateWindowOperatorInfo { typedef struct SSortedMergeOperatorInfo { SOptrBasicInfo binfo; - bool hasVarCol; - SArray* pSortInfo; int32_t numOfSources; SSortHandle *pSortHandle; @@ -582,6 +580,24 @@ typedef struct SSortOperatorInfo { uint64_t totalElapsed; // total elapsed time } SSortOperatorInfo; +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); int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t num); @@ -628,6 +644,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo* 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); SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, @@ -635,9 +653,6 @@ 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); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 14acff320418e68602a20842333c4865f55bffb6..c911aef45f3fc9deeae30d4432ffdbbfd114b776 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -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; // } @@ -6600,10 +6579,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 +6658,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,7 +6734,7 @@ 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) { @@ -6764,6 +6742,10 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo int32_t numOfCols = 0; tsdbReaderT pDataReader = doCreateDataReader((STableScanPhysiNode*)pPhyNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId); + if (pDataReader == NULL) { + return NULL; + } + SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols); SSDataBlock* pResBlock = createOutputBuf_rv1(pScanPhyNode->node.pOutputDataBlockDesc); @@ -6802,14 +6784,17 @@ 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); @@ -6817,7 +6802,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo SSDataBlock* pResBlock = createOutputBuf_rv1(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); @@ -6831,9 +6816,9 @@ 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; @@ -6851,33 +6836,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); 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); + 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); 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); + pOptr = createStatewindowOperatorInfo(ops[0], pExprInfo, num, pResBlock, pTaskInfo); + } else if (QUERY_NODE_PHYSICAL_PLAN_JOIN == type) { + SJoinPhysiNode* pJoinNode = (SJoinPhysiNode*) pPhyNode; + SSDataBlock* pResBlock = createOutputBuf_rv1(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 +6881,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 +7367,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/scanoperator.c b/source/libs/executor/src/scanoperator.c index 59ef31b2ff494ae766463908a8a16f62e5cc442a..901bfde6a4ae679bf04c365d9cb68fcdb0872c19 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -73,7 +73,7 @@ int32_t loadDataBlock(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableScanInfo, pCost->totalCheckedRows += pBlock->info.rows; pCost->loadBlocks += 1; - *status = BLK_DATA_ALL_NEEDED; + *status = BLK_DATA_DATA_LOAD; SArray* pCols = tsdbRetrieveDataBlock(pTableScanInfo->dataReader, NULL); if (pCols == NULL) { @@ -138,7 +138,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) { // } // this function never returns error? - uint32_t status = BLK_DATA_ALL_NEEDED; + uint32_t status = BLK_DATA_DATA_LOAD; int32_t code = loadDataBlock(pTaskInfo, pTableScanInfo, pBlock, &status); // int32_t code = loadDataBlockOnDemand(pOperator->pRuntimeEnv, pTableScanInfo, pBlock, &status); if (code != TSDB_CODE_SUCCESS) { @@ -146,7 +146,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) { } // 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; } @@ -767,24 +767,22 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataB // TODO remove it int32_t tableType = 0; const char* name = tNameGetTableName(pName); - if (strncasecmp(name, TSDB_INS_TABLE_USER_DATABASES, tListLen(pName->tname)) == 0) { - tableType = TSDB_MGMT_TABLE_DB; - } else if (strncasecmp(name, TSDB_INS_TABLE_USER_USERS, tListLen(pName->tname)) == 0) { - tableType = TSDB_MGMT_TABLE_USER; - } else if (strncasecmp(name, TSDB_INS_TABLE_DNODES, tListLen(pName->tname)) == 0) { + if (strncasecmp(name, TSDB_INS_TABLE_DNODES, tListLen(pName->tname)) == 0) { tableType = TSDB_MGMT_TABLE_DNODE; - } else if (strncasecmp(name, TSDB_INS_TABLE_LICENCES, tListLen(pName->tname)) == 0) { - tableType = TSDB_MGMT_TABLE_GRANTS; } else if (strncasecmp(name, TSDB_INS_TABLE_MNODES, tListLen(pName->tname)) == 0) { tableType = TSDB_MGMT_TABLE_MNODE; } else if (strncasecmp(name, TSDB_INS_TABLE_MODULES, tListLen(pName->tname)) == 0) { tableType = TSDB_MGMT_TABLE_MODULE; } else if (strncasecmp(name, TSDB_INS_TABLE_QNODES, tListLen(pName->tname)) == 0) { tableType = TSDB_MGMT_TABLE_QNODE; - } else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, tListLen(pName->tname)) == 0) { - tableType = TSDB_MGMT_TABLE_SNODE; } else if (strncasecmp(name, TSDB_INS_TABLE_BNODES, tListLen(pName->tname)) == 0) { tableType = TSDB_MGMT_TABLE_BNODE; + } else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_SNODE; + } else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_CLUSTER; + } else if (strncasecmp(name, TSDB_INS_TABLE_USER_DATABASES, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_DB; } else if (strncasecmp(name, TSDB_INS_TABLE_USER_FUNCTIONS, tListLen(pName->tname)) == 0) { tableType = TSDB_MGMT_TABLE_FUNC; } else if (strncasecmp(name, TSDB_INS_TABLE_USER_INDEXES, tListLen(pName->tname)) == 0) { @@ -795,13 +793,33 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataB tableType = TSDB_MGMT_TABLE_STREAMS; } else if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, tListLen(pName->tname)) == 0) { tableType = TSDB_MGMT_TABLE_TABLE; - } else if (strncasecmp(name, TSDB_INS_TABLE_VGROUPS, tListLen(pName->tname)) == 0) { - tableType = TSDB_MGMT_TABLE_VGROUP; } else if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, tListLen(pName->tname)) == 0) { // tableType = TSDB_MGMT_TABLE_DIST; - } else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, tListLen(pName->tname)) == 0) { - tableType = TSDB_MGMT_TABLE_CLUSTER; - } else { + } else if (strncasecmp(name, TSDB_INS_TABLE_USER_USERS, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_USER; + } else if (strncasecmp(name, TSDB_INS_TABLE_LICENCES, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_GRANTS; + } else if (strncasecmp(name, TSDB_INS_TABLE_VGROUPS, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_VGROUP; + } else if (strncasecmp(name, TSDB_INS_TABLE_TOPICS, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_TOPICS; + } else if (strncasecmp(name, TSDB_INS_TABLE_CONSUMERS, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_CONSUMERS; + } else if (strncasecmp(name, TSDB_INS_TABLE_SUBSCRIBES, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_SUBSCRIBES; + } else if (strncasecmp(name, TSDB_INS_TABLE_TRANS, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_TRANS; + } else if (strncasecmp(name, TSDB_INS_TABLE_SMAS, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_SMAS; + } else if (strncasecmp(name, TSDB_INS_TABLE_CONFIGS, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_CONFIGS; + } else if (strncasecmp(name, TSDB_INS_TABLE_CONNS, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_CONNS; + } else if (strncasecmp(name, TSDB_INS_TABLE_QUERIES, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_QUERIES; + } else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, tListLen(pName->tname)) == 0) { + tableType = TSDB_MGMT_TABLE_VNODES; + }else { ASSERT(0); } diff --git a/source/libs/function/inc/builtins.h b/source/libs/function/inc/builtins.h index 624a2953c935997c5c35708a21dbe223c29db62a..814076fc349d20579365e28660021d76f08d1d6e 100644 --- a/source/libs/function/inc/builtins.h +++ b/source/libs/function/inc/builtins.h @@ -40,14 +40,14 @@ extern "C" { #define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0) -typedef int32_t (*FCheckAndGetResultType)(SFunctionNode* pFunc); +typedef int32_t (*FTranslateFunc)(SFunctionNode* pFunc, char* pErrBuf, int32_t len); typedef EFuncDataRequired (*FFuncDataRequired)(SFunctionNode* pFunc, STimeWindow* pTimeWindow); typedef struct SBuiltinFuncDefinition { char name[FUNCTION_NAME_MAX_LENGTH]; EFunctionType type; uint64_t classification; - FCheckAndGetResultType checkFunc; + FTranslateFunc translateFunc; FFuncDataRequired dataRequiredFunc; FExecGetEnv getEnvFunc; FExecInit initFunc; diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 27067fc966288943aaf074f38ecf27a71b1a5be3..6ed1f891a469178435c29f95bbea9d9daa8760c6 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -19,14 +19,363 @@ #include "taoserror.h" #include "tdatablock.h" -int32_t checkAndGetResultType(SFunctionNode* pFunc); +static int32_t buildFuncErrMsg(char* pErrBuf, int32_t len, int32_t errCode, const char* pFormat, ...) { + va_list vArgList; + va_start(vArgList, pFormat); + vsnprintf(pErrBuf, len, pFormat, vArgList); + va_end(vArgList); + return errCode; +} + +static int32_t invaildFuncParaNumErrMsg(char* pErrBuf, int32_t len, const char* pFuncName) { + return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_PARA_NUM, "Invalid number of arguments : %s", pFuncName); +} + +static int32_t invaildFuncParaTypeErrMsg(char* pErrBuf, int32_t len, const char* pFuncName) { + return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_PARA_TYPE, "Inconsistent datatypes : %s", pFuncName); +} + +// There is only one parameter of numeric type, and the return type is parameter type +static int32_t translateInOutNum(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + if (!IS_NUMERIC_TYPE(paraType)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType) { .bytes = tDataTypes[paraType].bytes, .type = paraType }; + return TSDB_CODE_SUCCESS; +} + +// There is only one parameter of numeric type, and the return type is double type +static int32_t translateInNumOutDou(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + if (!IS_NUMERIC_TYPE(paraType)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE }; + return TSDB_CODE_SUCCESS; +} + +// There are two parameters of numeric type, and the return type is double type +static int32_t translateIn2NumOutDou(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (2 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type; + if (!IS_NUMERIC_TYPE(para1Type) || !IS_NUMERIC_TYPE(para2Type)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE }; + return TSDB_CODE_SUCCESS; +} + +// There is only one parameter of string type, and the return type is parameter type +static int32_t translateInOutStr(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + SExprNode* pPara1 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0); + if (!IS_VAR_DATA_TYPE(pPara1->resType.type)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType) { .bytes = pPara1->resType.bytes, .type = pPara1->resType.type }; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateCount(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + pFunc->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_BIGINT}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateSum(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + if (!IS_NUMERIC_TYPE(paraType)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t resType = 0; + if (IS_SIGNED_NUMERIC_TYPE(paraType) || paraType == TSDB_DATA_TYPE_BOOL) { + resType = TSDB_DATA_TYPE_BIGINT; + } else if (IS_UNSIGNED_NUMERIC_TYPE(paraType)) { + resType = TSDB_DATA_TYPE_UBIGINT; + } else if (IS_FLOAT_TYPE(paraType)) { + resType = TSDB_DATA_TYPE_DOUBLE; + } + pFunc->node.resType = (SDataType) { .bytes = tDataTypes[resType].bytes, .type = resType }; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateWduration(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + // pseudo column do not need to check parameters + pFunc->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_BIGINT}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateTimePseudoColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + // pseudo column do not need to check parameters + pFunc->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_TIMESTAMP}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translatePercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (2 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type; + if (!IS_NUMERIC_TYPE(para1Type) || (!IS_SIGNED_NUMERIC_TYPE(para2Type) && !IS_UNSIGNED_NUMERIC_TYPE(para2Type))) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE }; + return TSDB_CODE_SUCCESS; +} + +static bool validAperventileAlgo(const SValueNode* pVal) { + if (TSDB_DATA_TYPE_BINARY != pVal->node.resType.type) { + return false; + } + return (0 == strcasecmp(varDataVal(pVal->datum.p), "default") || 0 == strcasecmp(varDataVal(pVal->datum.p), "t-digest")); +} + +static int32_t translateApercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + int32_t paraNum = LIST_LENGTH(pFunc->pParameterList); + if (2 != paraNum && 3 != paraNum) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type; + if (!IS_NUMERIC_TYPE(para1Type) || !IS_INTEGER_TYPE(para2Type)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + if (3 == paraNum) { + SNode* pPara3 = nodesListGetNode(pFunc->pParameterList, 2); + if (QUERY_NODE_VALUE != nodeType(pPara3) || !validAperventileAlgo((SValueNode*)pPara3)) { + return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, "Third parameter algorithm of apercentile must be 'default' or 't-digest'"); + } + } + + pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE }; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateTop(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + // todo + return TSDB_CODE_SUCCESS; +} + +static int32_t translateBottom(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + // todo + return TSDB_CODE_SUCCESS; +} + +static int32_t translateSpread(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + // todo + return TSDB_CODE_SUCCESS; +} + +static int32_t translateLastRow(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + // todo + return TSDB_CODE_SUCCESS; +} + +static int32_t translateFirstLast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + // first(*)/first(col_list) has been rewritten as first(col) + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); + if (QUERY_NODE_COLUMN != nodeType(pPara)) { + return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, "The parameters of first/last can only be columns"); + } + + uint8_t paraType = ((SExprNode*)pPara)->resType.type; + pFunc->node.resType = (SDataType) { .bytes = tDataTypes[paraType].bytes, .type = paraType }; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateLength(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + if (!IS_VAR_DATA_TYPE(((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_SMALLINT].bytes, .type = TSDB_DATA_TYPE_SMALLINT }; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len, int32_t minParaNum, int32_t maxParaNum, int32_t primaryParaNo) { + int32_t paraNum = LIST_LENGTH(pFunc->pParameterList); + if (paraNum < minParaNum || paraNum > maxParaNum) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t resultType = TSDB_DATA_TYPE_NCHAR; + int32_t resultBytes = 0; + int32_t sepBytes = 0; + for (int32_t i = 0; i < LIST_LENGTH(pFunc->pParameterList); ++i) { + SNode* pPara = nodesListGetNode(pFunc->pParameterList, i); + uint8_t paraType = ((SExprNode*)pPara)->resType.type; + int32_t paraBytes = ((SExprNode*)pPara)->resType.bytes; + if (!IS_VAR_DATA_TYPE(paraType)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + if (i < primaryParaNo) { + sepBytes = paraBytes; + continue; + } + if (TSDB_DATA_TYPE_BINARY == paraType) { + resultType = TSDB_DATA_TYPE_BINARY; + } + resultBytes += paraBytes; + } + if (sepBytes > 0) { + resultBytes += sepBytes * (paraNum - 2); + } + + pFunc->node.resType = (SDataType) { .bytes = resultBytes, .type = resultType }; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateConcat(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + return translateConcatImpl(pFunc, pErrBuf, len, 2, 8, 0); +} + +static int32_t translateConcatWs(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + return translateConcatImpl(pFunc, pErrBuf, len, 3, 9, 1); +} + +static int32_t translateSubstr(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + int32_t paraNum = LIST_LENGTH(pFunc->pParameterList); + if (2 != paraNum && 3 != paraNum) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + SExprNode* pPara1 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0); + uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type; + if (!IS_VAR_DATA_TYPE(pPara1->resType.type) || !IS_INTEGER_TYPE(para2Type)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + if (3 == paraNum) { + uint8_t para3Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type; + if (!IS_INTEGER_TYPE(para3Type)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + } + + pFunc->node.resType = (SDataType) { .bytes = pPara1->resType.bytes, .type = pPara1->resType.type }; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + // The number of parameters has been limited by the syntax definition + uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + // The function return type has been set during syntax parsing + uint8_t para2Type = pFunc->node.resType.type; + if ((TSDB_DATA_TYPE_JSON == para1Type || TSDB_DATA_TYPE_BLOB == para1Type || TSDB_DATA_TYPE_MEDIUMBLOB == para1Type) || + (TSDB_DATA_TYPE_JSON == para2Type || TSDB_DATA_TYPE_BLOB == para2Type || TSDB_DATA_TYPE_MEDIUMBLOB == para2Type)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + return TSDB_CODE_SUCCESS; +} + +static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + if (!IS_VAR_DATA_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType) { .bytes = 64, .type = TSDB_DATA_TYPE_BINARY}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateToUnixtimestamp(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + if (!IS_VAR_DATA_TYPE(((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (2 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type; + if ((!IS_VAR_DATA_TYPE(para1Type) && TSDB_DATA_TYPE_TIMESTAMP != para1Type) || !IS_INTEGER_TYPE(para2Type)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + int32_t paraNum = LIST_LENGTH(pFunc->pParameterList); + if (2 != paraNum && 3 != paraNum) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type; + if ((!IS_VAR_DATA_TYPE(para1Type) && TSDB_DATA_TYPE_TIMESTAMP != para1Type) || + (!IS_VAR_DATA_TYPE(para2Type) && TSDB_DATA_TYPE_TIMESTAMP != para2Type)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + if (3 == paraNum) { + if (!IS_INTEGER_TYPE(((SExprNode*)nodesListGetNode(pFunc->pParameterList, 2))->resType.type)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + } + + pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT}; + return TSDB_CODE_SUCCESS; +} const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "count", .type = FUNCTION_TYPE_COUNT, .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED, - .checkFunc = checkAndGetResultType, + .translateFunc = translateCount, .dataRequiredFunc = countDataRequired, .getEnvFunc = getCountFuncEnv, .initFunc = functionSetup, @@ -37,7 +386,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "sum", .type = FUNCTION_TYPE_SUM, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateSum, .getEnvFunc = getSumFuncEnv, .initFunc = functionSetup, .processFunc = sumFunction, @@ -47,7 +396,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "min", .type = FUNCTION_TYPE_MIN, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInOutNum, .getEnvFunc = getMinmaxFuncEnv, .initFunc = minFunctionSetup, .processFunc = minFunction, @@ -57,7 +406,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "max", .type = FUNCTION_TYPE_MAX, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInOutNum, .getEnvFunc = getMinmaxFuncEnv, .initFunc = maxFunctionSetup, .processFunc = maxFunction, @@ -67,7 +416,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "stddev", .type = FUNCTION_TYPE_STDDEV, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInNumOutDou, .getEnvFunc = getStddevFuncEnv, .initFunc = stddevFunctionSetup, .processFunc = stddevFunction, @@ -77,7 +426,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "percentile", .type = FUNCTION_TYPE_PERCENTILE, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translatePercentile, .getEnvFunc = getPercentileFuncEnv, .initFunc = percentileFunctionSetup, .processFunc = percentileFunction, @@ -87,7 +436,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "apercentile", .type = FUNCTION_TYPE_APERCENTILE, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateApercentile, .getEnvFunc = getMinmaxFuncEnv, .initFunc = maxFunctionSetup, .processFunc = maxFunction, @@ -97,7 +446,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "top", .type = FUNCTION_TYPE_TOP, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateTop, .getEnvFunc = getMinmaxFuncEnv, .initFunc = maxFunctionSetup, .processFunc = maxFunction, @@ -107,7 +456,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "bottom", .type = FUNCTION_TYPE_BOTTOM, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateBottom, .getEnvFunc = getMinmaxFuncEnv, .initFunc = maxFunctionSetup, .processFunc = maxFunction, @@ -117,7 +466,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "spread", .type = FUNCTION_TYPE_SPREAD, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateSpread, .getEnvFunc = getMinmaxFuncEnv, .initFunc = maxFunctionSetup, .processFunc = maxFunction, @@ -127,7 +476,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "last_row", .type = FUNCTION_TYPE_LAST_ROW, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateLastRow, .getEnvFunc = getMinmaxFuncEnv, .initFunc = maxFunctionSetup, .processFunc = maxFunction, @@ -137,7 +486,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "first", .type = FUNCTION_TYPE_FIRST, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateFirstLast, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, .processFunc = firstFunction, @@ -147,7 +496,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "last", .type = FUNCTION_TYPE_LAST, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateFirstLast, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, .processFunc = lastFunction, @@ -157,7 +506,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "diff", .type = FUNCTION_TYPE_DIFF, .classification = FUNC_MGT_NONSTANDARD_SQL_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInOutNum, .getEnvFunc = getDiffFuncEnv, .initFunc = diffFunctionSetup, .processFunc = diffFunction, @@ -167,7 +516,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "abs", .type = FUNCTION_TYPE_ABS, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInOutNum, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = absFunction, @@ -177,7 +526,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "log", .type = FUNCTION_TYPE_LOG, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateIn2NumOutDou, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = logFunction, @@ -187,7 +536,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "pow", .type = FUNCTION_TYPE_POW, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateIn2NumOutDou, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = powFunction, @@ -197,7 +546,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "sqrt", .type = FUNCTION_TYPE_SQRT, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInNumOutDou, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = sqrtFunction, @@ -207,7 +556,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "ceil", .type = FUNCTION_TYPE_CEIL, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInOutNum, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = ceilFunction, @@ -217,7 +566,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "floor", .type = FUNCTION_TYPE_FLOOR, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInOutNum, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = floorFunction, @@ -227,7 +576,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "round", .type = FUNCTION_TYPE_ROUND, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInOutNum, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = roundFunction, @@ -237,7 +586,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "sin", .type = FUNCTION_TYPE_SIN, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInNumOutDou, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = sinFunction, @@ -247,7 +596,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "cos", .type = FUNCTION_TYPE_COS, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInNumOutDou, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = cosFunction, @@ -257,7 +606,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "tan", .type = FUNCTION_TYPE_TAN, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInNumOutDou, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = tanFunction, @@ -267,7 +616,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "asin", .type = FUNCTION_TYPE_ASIN, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInNumOutDou, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = asinFunction, @@ -277,7 +626,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "acos", .type = FUNCTION_TYPE_ACOS, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInNumOutDou, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = acosFunction, @@ -287,7 +636,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "atan", .type = FUNCTION_TYPE_ATAN, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInNumOutDou, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = atanFunction, @@ -297,7 +646,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "length", .type = FUNCTION_TYPE_LENGTH, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateLength, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = lengthFunction, @@ -307,7 +656,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "char_length", .type = FUNCTION_TYPE_CHAR_LENGTH, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateLength, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = charLengthFunction, @@ -317,7 +666,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "concat", .type = FUNCTION_TYPE_CONCAT, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateConcat, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = concatFunction, @@ -327,7 +676,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "concat_ws", .type = FUNCTION_TYPE_CONCAT_WS, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateConcatWs, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = concatWsFunction, @@ -337,7 +686,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "lower", .type = FUNCTION_TYPE_LOWER, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInOutStr, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = lowerFunction, @@ -347,7 +696,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "upper", .type = FUNCTION_TYPE_UPPER, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInOutStr, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = upperFunction, @@ -357,7 +706,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "ltrim", .type = FUNCTION_TYPE_LTRIM, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInOutStr, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = ltrimFunction, @@ -367,7 +716,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "rtrim", .type = FUNCTION_TYPE_RTRIM, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateInOutStr, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = rtrimFunction, @@ -377,7 +726,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "substr", .type = FUNCTION_TYPE_SUBSTR, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateSubstr, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = substrFunction, @@ -387,7 +736,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "cast", .type = FUNCTION_TYPE_CAST, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateCast, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = castFunction, @@ -397,7 +746,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "to_iso8601", .type = FUNCTION_TYPE_TO_ISO8601, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateToIso8601, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = toISO8601Function, @@ -407,7 +756,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "to_unixtimestamp", .type = FUNCTION_TYPE_TO_UNIXTIMESTAMP, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateToUnixtimestamp, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = toUnixtimestampFunction, @@ -417,7 +766,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "timetruncate", .type = FUNCTION_TYPE_TIMETRUNCATE, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateTimeTruncate, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = timeTruncateFunction, @@ -427,17 +776,37 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "timediff", .type = FUNCTION_TYPE_TIMEDIFF, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateTimeDiff, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = timeDiffFunction, .finalizeFunc = NULL }, + { + .name = "now", + .type = FUNCTION_TYPE_NOW, + .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC, + .translateFunc = translateTimePseudoColumn, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = nowFunction, + .finalizeFunc = NULL + }, + { + .name = "today", + .type = FUNCTION_TYPE_TODAY, + .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC, + .translateFunc = translateTimePseudoColumn, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = todayFunction, + .finalizeFunc = NULL + }, { .name = "_rowts", .type = FUNCTION_TYPE_ROWTS, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateTimePseudoColumn, .getEnvFunc = getTimePseudoFuncEnv, .initFunc = NULL, .sprocessFunc = NULL, @@ -447,7 +816,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "tbname", .type = FUNCTION_TYPE_TBNAME, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = NULL, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = NULL, @@ -457,7 +826,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "_qstartts", .type = FUNCTION_TYPE_QSTARTTS, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateTimePseudoColumn, .getEnvFunc = getTimePseudoFuncEnv, .initFunc = NULL, .sprocessFunc = qStartTsFunction, @@ -467,7 +836,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "_qendts", .type = FUNCTION_TYPE_QENDTS, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateTimePseudoColumn, .getEnvFunc = getTimePseudoFuncEnv, .initFunc = NULL, .sprocessFunc = qEndTsFunction, @@ -477,7 +846,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "_wstartts", .type = FUNCTION_TYPE_WSTARTTS, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateTimePseudoColumn, .getEnvFunc = getTimePseudoFuncEnv, .initFunc = NULL, .sprocessFunc = winStartTsFunction, @@ -487,7 +856,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "_wendts", .type = FUNCTION_TYPE_QENDTS, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateTimePseudoColumn, .getEnvFunc = getTimePseudoFuncEnv, .initFunc = NULL, .sprocessFunc = winEndTsFunction, @@ -497,17 +866,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "_wduration", .type = FUNCTION_TYPE_WDURATION, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, - .checkFunc = checkAndGetResultType, - .getEnvFunc = getTimePseudoFuncEnv, - .initFunc = NULL, - .sprocessFunc = winDurFunction, - .finalizeFunc = NULL - }, - { - .name = "now", - .type = FUNCTION_TYPE_NOW, - .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC, - .checkFunc = checkAndGetResultType, + .translateFunc = translateWduration, .getEnvFunc = getTimePseudoFuncEnv, .initFunc = NULL, .sprocessFunc = winDurFunction, @@ -516,167 +875,3 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { }; const int32_t funcMgtBuiltinsNum = (sizeof(funcMgtBuiltins) / sizeof(SBuiltinFuncDefinition)); - -int32_t checkAndGetResultType(SFunctionNode* pFunc) { - switch(pFunc->funcType) { - case FUNCTION_TYPE_WDURATION: - case FUNCTION_TYPE_COUNT: { - pFunc->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_BIGINT}; - break; - } - - case FUNCTION_TYPE_SUM: { - SColumnNode* pParam = nodesListGetNode(pFunc->pParameterList, 0); - int32_t paraType = pParam->node.resType.type; - - int32_t resType = 0; - if (IS_SIGNED_NUMERIC_TYPE(paraType) || paraType == TSDB_DATA_TYPE_BOOL) { - resType = TSDB_DATA_TYPE_BIGINT; - } else if (IS_UNSIGNED_NUMERIC_TYPE(paraType)) { - resType = TSDB_DATA_TYPE_UBIGINT; - } else if (IS_FLOAT_TYPE(paraType)) { - resType = TSDB_DATA_TYPE_DOUBLE; - } else { - ASSERT(0); - } - - pFunc->node.resType = (SDataType) { .bytes = tDataTypes[resType].bytes, .type = resType }; - break; - } - - case FUNCTION_TYPE_DIFF: - case FUNCTION_TYPE_FIRST: - case FUNCTION_TYPE_LAST: - case FUNCTION_TYPE_MIN: - case FUNCTION_TYPE_MAX: { - SColumnNode* pParam = nodesListGetNode(pFunc->pParameterList, 0); - int32_t paraType = pParam->node.resType.type; - pFunc->node.resType = (SDataType) { .bytes = tDataTypes[paraType].bytes, .type = paraType }; - break; - } - - case FUNCTION_TYPE_ROWTS: - case FUNCTION_TYPE_QSTARTTS: - case FUNCTION_TYPE_QENDTS: - case FUNCTION_TYPE_WSTARTTS: - case FUNCTION_TYPE_WENDTS:{ - pFunc->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_TIMESTAMP}; - break; - } - - case FUNCTION_TYPE_ABS: - case FUNCTION_TYPE_CEIL: - case FUNCTION_TYPE_FLOOR: - case FUNCTION_TYPE_ROUND: { - SColumnNode* pParam = nodesListGetNode(pFunc->pParameterList, 0); - int32_t paraType = pParam->node.resType.type; - pFunc->node.resType = (SDataType) { .bytes = tDataTypes[paraType].bytes, .type = paraType }; - break; - } - - case FUNCTION_TYPE_PERCENTILE: - case FUNCTION_TYPE_STDDEV: - case FUNCTION_TYPE_SIN: - case FUNCTION_TYPE_COS: - case FUNCTION_TYPE_TAN: - case FUNCTION_TYPE_ASIN: - case FUNCTION_TYPE_ACOS: - case FUNCTION_TYPE_ATAN: - case FUNCTION_TYPE_SQRT: - case FUNCTION_TYPE_LOG: - case FUNCTION_TYPE_POW: { - pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE }; - break; - } - - case FUNCTION_TYPE_LENGTH: - case FUNCTION_TYPE_CHAR_LENGTH: { - pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_SMALLINT].bytes, .type = TSDB_DATA_TYPE_SMALLINT }; - break; - } - - case FUNCTION_TYPE_CONCAT: - case FUNCTION_TYPE_CONCAT_WS: { - int32_t paraType, paraBytes = 0; - bool typeSet = false; - for (int32_t i = 0; i < pFunc->pParameterList->length; ++i) { - SColumnNode* pParam = nodesListGetNode(pFunc->pParameterList, i); - if (pParam->node.type == QUERY_NODE_COLUMN) { - if (typeSet == false) { - paraType = pParam->node.resType.type; - typeSet = true; - } else { - //columns have to be the same type - if (paraType != pParam->node.resType.type) { - return TSDB_CODE_FAILED; - } - } - paraBytes += pParam->node.resType.bytes; - } - } - - for (int32_t i = 0; i < pFunc->pParameterList->length; ++i) { - SColumnNode* pParam = nodesListGetNode(pFunc->pParameterList, i); - if (pParam->node.type == QUERY_NODE_VALUE) { - if (paraType == TSDB_DATA_TYPE_NCHAR) { - paraBytes += pParam->node.resType.bytes * TSDB_NCHAR_SIZE; - } else { - paraBytes += pParam->node.resType.bytes; - } - } - } - pFunc->node.resType = (SDataType) { .bytes = paraBytes, .type = paraType }; - break; - } - case FUNCTION_TYPE_LOWER: - case FUNCTION_TYPE_UPPER: - case FUNCTION_TYPE_LTRIM: - case FUNCTION_TYPE_RTRIM: - case FUNCTION_TYPE_SUBSTR: { - SColumnNode* pParam = nodesListGetNode(pFunc->pParameterList, 0); - int32_t paraType = pParam->node.resType.type; - int32_t paraBytes = pParam->node.resType.bytes; - pFunc->node.resType = (SDataType) { .bytes = paraBytes, .type = paraType }; - break; - } - case FUNCTION_TYPE_CAST: { - //type - SValueNode* pParam = nodesListGetNode(pFunc->pParameterList, 1); - int32_t paraType = pParam->datum.i; - //bytes - pParam = nodesListGetNode(pFunc->pParameterList, 2); - int32_t paraBytes = pParam->datum.i; - pFunc->node.resType = (SDataType) { .bytes = paraBytes, .type = paraType}; - break; - } - case FUNCTION_TYPE_TO_ISO8601: { - pFunc->node.resType = (SDataType) { .bytes = 64, .type = TSDB_DATA_TYPE_BINARY}; - break; - } - case FUNCTION_TYPE_TO_UNIXTIMESTAMP: { - pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT}; - break; - } - case FUNCTION_TYPE_TIMETRUNCATE: { - pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP}; - break; - } - case FUNCTION_TYPE_TIMEDIFF: { - pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT}; - break; - } - - case FUNCTION_TYPE_TBNAME: { - // todo - break; - } - - case FUNCTION_TYPE_NOW: - // todo - break; - default: - ASSERT(0); // to found the fault ASAP. - } - - return TSDB_CODE_SUCCESS; -} diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index ea9b3bdf18481dec906b170a7e52351aa3528034..aec75a0365ef42c8a23b021af4050d18fd6246c6 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -69,11 +69,11 @@ int32_t fmGetFuncInfo(const char* pFuncName, int32_t* pFuncId, int32_t* pFuncTyp return TSDB_CODE_SUCCESS; } -int32_t fmGetFuncResultType(SFunctionNode* pFunc) { +int32_t fmGetFuncResultType(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { if (pFunc->funcId < 0 || pFunc->funcId >= funcMgtBuiltinsNum) { return TSDB_CODE_FAILED; } - return funcMgtBuiltins[pFunc->funcId].checkFunc(pFunc); + return funcMgtBuiltins[pFunc->funcId].translateFunc(pFunc, pErrBuf, len); } EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) { diff --git a/source/libs/function/src/taggfunction.c b/source/libs/function/src/taggfunction.c index 60566d00d8b4be2e83ca62881f158db92bb35f59..e001ef407146ccdf1709be63e11e0a259f9f6775 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/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 8ab76f57147471c9d987cce1e0c65f60fb219a49..ce74748c0c76b49aaef5ec69c0a828b6d7cb5c8d 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -132,30 +132,52 @@ const char* nodesNodeName(ENodeType type) { return "DropTopicStmt"; case QUERY_NODE_ALTER_LOCAL_STMT: return "AlterLocalStmt"; - case QUERY_NODE_SHOW_DATABASES_STMT: - return "ShowDatabaseStmt"; - case QUERY_NODE_SHOW_TABLES_STMT: - return "ShowTablesStmt"; - case QUERY_NODE_SHOW_STABLES_STMT: - return "ShowStablesStmt"; - case QUERY_NODE_SHOW_USERS_STMT: - return "ShowUsersStmt"; case QUERY_NODE_SHOW_DNODES_STMT: return "ShowDnodesStmt"; - case QUERY_NODE_SHOW_VGROUPS_STMT: - return "ShowVgroupsStmt"; case QUERY_NODE_SHOW_MNODES_STMT: return "ShowMnodesStmt"; case QUERY_NODE_SHOW_MODULES_STMT: return "ShowModulesStmt"; case QUERY_NODE_SHOW_QNODES_STMT: return "ShowQnodesStmt"; + case QUERY_NODE_SHOW_SNODES_STMT: + return "ShowSnodesStmt"; + case QUERY_NODE_SHOW_BNODES_STMT: + return "ShowBnodesStmt"; + case QUERY_NODE_SHOW_DATABASES_STMT: + return "ShowDatabaseStmt"; case QUERY_NODE_SHOW_FUNCTIONS_STMT: return "ShowFunctionsStmt"; case QUERY_NODE_SHOW_INDEXES_STMT: return "ShowIndexesStmt"; + case QUERY_NODE_SHOW_STABLES_STMT: + return "ShowStablesStmt"; case QUERY_NODE_SHOW_STREAMS_STMT: return "ShowStreamsStmt"; + case QUERY_NODE_SHOW_TABLES_STMT: + return "ShowTablesStmt"; + case QUERY_NODE_SHOW_USERS_STMT: + return "ShowUsersStmt"; + case QUERY_NODE_SHOW_LICENCE_STMT: + return "ShowGrantsStmt"; + case QUERY_NODE_SHOW_VGROUPS_STMT: + return "ShowVgroupsStmt"; + case QUERY_NODE_SHOW_TOPICS_STMT: + return "ShowTopicsStmt"; + case QUERY_NODE_SHOW_CONSUMERS_STMT: + return "ShowConsumersStmt"; + case QUERY_NODE_SHOW_SUBSCRIBES_STMT: + return "ShowSubscribesStmt"; + case QUERY_NODE_SHOW_TRANS_STMT: + return "ShowTransStmt"; + case QUERY_NODE_SHOW_SMAS_STMT: + return "ShowSmasStmt"; + case QUERY_NODE_SHOW_CONFIGS_STMT: + return "ShowConfigsStmt"; + case QUERY_NODE_SHOW_QUERIES_STMT: + return "ShowQueriesStmt"; + case QUERY_NODE_SHOW_VNODES_STMT: + return "ShowVnodeStmt"; case QUERY_NODE_LOGIC_PLAN_SCAN: return "LogicScan"; case QUERY_NODE_LOGIC_PLAN_JOIN: diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 1c565ddd37b9c4142121cea55c8f94f595a1b0ac..8731b26c4a15900a862390b9ab37d3d90e81f34f 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -146,30 +146,29 @@ SNodeptr nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SDescribeStmt)); case QUERY_NODE_RESET_QUERY_CACHE_STMT: return makeNode(type, sizeof(SNode)); - case QUERY_NODE_SHOW_DATABASES_STMT: - case QUERY_NODE_SHOW_TABLES_STMT: - case QUERY_NODE_SHOW_STABLES_STMT: - case QUERY_NODE_SHOW_USERS_STMT: case QUERY_NODE_SHOW_DNODES_STMT: - case QUERY_NODE_SHOW_VGROUPS_STMT: case QUERY_NODE_SHOW_MNODES_STMT: case QUERY_NODE_SHOW_MODULES_STMT: case QUERY_NODE_SHOW_QNODES_STMT: + case QUERY_NODE_SHOW_SNODES_STMT: + case QUERY_NODE_SHOW_BNODES_STMT: + case QUERY_NODE_SHOW_DATABASES_STMT: case QUERY_NODE_SHOW_FUNCTIONS_STMT: case QUERY_NODE_SHOW_INDEXES_STMT: + case QUERY_NODE_SHOW_STABLES_STMT: case QUERY_NODE_SHOW_STREAMS_STMT: - case QUERY_NODE_SHOW_APPS_STMT: - case QUERY_NODE_SHOW_CONNECTIONS_STMT: + case QUERY_NODE_SHOW_TABLES_STMT: + case QUERY_NODE_SHOW_USERS_STMT: case QUERY_NODE_SHOW_LICENCE_STMT: - case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: - case QUERY_NODE_SHOW_CREATE_TABLE_STMT: - case QUERY_NODE_SHOW_CREATE_STABLE_STMT: - case QUERY_NODE_SHOW_QUERIES_STMT: - case QUERY_NODE_SHOW_SCORES_STMT: + case QUERY_NODE_SHOW_VGROUPS_STMT: case QUERY_NODE_SHOW_TOPICS_STMT: - case QUERY_NODE_SHOW_VARIABLE_STMT: - case QUERY_NODE_SHOW_BNODES_STMT: - case QUERY_NODE_SHOW_SNODES_STMT: + case QUERY_NODE_SHOW_CONSUMERS_STMT: + case QUERY_NODE_SHOW_SUBSCRIBES_STMT: + case QUERY_NODE_SHOW_TRANS_STMT: + case QUERY_NODE_SHOW_SMAS_STMT: + case QUERY_NODE_SHOW_CONFIGS_STMT: + case QUERY_NODE_SHOW_QUERIES_STMT: + case QUERY_NODE_SHOW_VNODES_STMT: return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_LOGIC_PLAN_SCAN: return makeNode(type, sizeof(SScanLogicNode)); @@ -1202,7 +1201,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 e78101421629d1ea9f9ef0ee521c737bb5840d4c..b4319b4747b58e4edd6cb0e27745141b82b3f7d9 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -81,7 +81,6 @@ SToken getTokenFromRawExprNode(SAstCreateContext* pCxt, SNode* pNode); SNodeList* createNodeList(SAstCreateContext* pCxt, SNode* pNode); SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode); -SNodeList* addValueNodeFromTypeToList(SAstCreateContext* pCxt, SDataType dataType, SNodeList* pList); SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pColumnName); SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral); @@ -93,6 +92,8 @@ SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pL 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* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType dt); SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList); SNode* createNodeListNodeEx(SAstCreateContext* pCxt, SNode* p1, SNode* p2); SNode* createRealTableNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pTableName, SToken* pTableAlias); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 12ae5819b47d509e07fc59b6fd98a9d719eca40f..d6fc9432655beddd53365591ae951a0542e95b40 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -503,6 +503,8 @@ column_name(A) ::= NK_ID(B). 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; } %type table_alias { SToken } %destructor table_alias { } @@ -535,13 +537,8 @@ expression(A) ::= pseudo_column(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)))); } -//for CAST function CAST(expr AS type_name) -expression(A) ::= function_name(B) NK_LP expression(C) AS type_name(D) NK_RP(E). { - SNodeList *p = createNodeList(pCxt, releaseRawExprNode(pCxt, C)); - p = addValueNodeFromTypeToList(pCxt, D, p); - A = createRawExprNodeExt(pCxt, &B, &E, createFunctionNode(pCxt, &B, p)); - } -//expression(A) ::= cast_expression(B). { A = B; } +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) ::= 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)); } @@ -587,8 +584,8 @@ 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) ::= 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)); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 4d09dfee192b90d8a8a45478c81b2a3b9a4ef120..884549b118e189029beb1add1c3d1feb2558a57e 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -208,7 +208,9 @@ SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) { SRawExprNode* pRawExpr = (SRawExprNode*)pNode; SNode* pExpr = pRawExpr->pNode; if (nodesIsExprNode(pExpr)) { - strncpy(((SExprNode*)pExpr)->aliasName, pRawExpr->p, pRawExpr->n); + int32_t len = TMIN(sizeof(((SExprNode*)pExpr)->aliasName) - 1, pRawExpr->n); + strncpy(((SExprNode*)pExpr)->aliasName, pRawExpr->p, len); + ((SExprNode*)pExpr)->aliasName[len] = '\0'; } taosMemoryFreeClear(pNode); return pExpr; @@ -253,33 +255,6 @@ SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pC return (SNode*)col; } -SNodeList* addValueNodeFromTypeToList(SAstCreateContext* pCxt, SDataType dataType, SNodeList* pList) { - char buf[64] = {0}; - //add value node for type - snprintf(buf, sizeof(buf), "%u", dataType.type); - SToken token = {.type = TSDB_DATA_TYPE_SMALLINT, .n = strlen(buf), .z = buf}; - SNode* pNode = createValueNode(pCxt, token.type, &token); - addNodeToList(pCxt, pList, pNode); - - //add value node for bytes - memset(buf, 0, sizeof(buf)); - int32_t bytes; - if (IS_VAR_DATA_TYPE(dataType.type)) { - bytes = (dataType.type == TSDB_DATA_TYPE_NCHAR) ? dataType.bytes * TSDB_NCHAR_SIZE : dataType.bytes; - bytes += VARSTR_HEADER_SIZE; - } else { - bytes = dataType.bytes; - } - snprintf(buf, sizeof(buf), "%d", bytes); - token.type = TSDB_DATA_TYPE_BIGINT; - token.n = strlen(buf); - token.z = buf; - pNode = createValueNode(pCxt, token.type, &token); - addNodeToList(pCxt, pList, pNode); - - return pList; -} - SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral) { SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); CHECK_OUT_OF_MEM(val); @@ -385,6 +360,48 @@ SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNod return (SNode*)func; } +SNode* createFunctionNodeNoParam(SAstCreateContext* pCxt, const SToken* pFuncName) { + SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); + CHECK_OUT_OF_MEM(func); + char buf[64] = {0}; + + int32_t dataType; + switch (pFuncName->type) { + case TK_NOW: { + int64_t ts = taosGetTimestamp(TSDB_TIME_PRECISION_MILLI); + snprintf(buf, sizeof(buf), "%"PRId64, ts); + dataType = TSDB_DATA_TYPE_BIGINT; + break; + } + case TK_TODAY: { + int64_t ts = taosGetTimestampToday(TSDB_TIME_PRECISION_MILLI); + snprintf(buf, sizeof(buf), "%"PRId64, ts); + dataType = TSDB_DATA_TYPE_BIGINT; + break; + } + //case TK_TIMEZONE: { + // strncpy(buf, tsTimezoneStr, strlen(tsTimezoneStr)); + // dataType = TSDB_DATA_TYPE_BINARY; + // break; + //} + } + SToken token = {.type = pFuncName->type, .n = strlen(buf), .z = buf}; + + SNodeList *pParameterList = createNodeList(pCxt, createValueNode(pCxt, dataType, &token)); + strncpy(func->functionName, pFuncName->z, pFuncName->n); + func->pParameterList = pParameterList; + return (SNode*)func; +} + +SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType dt) { + SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); + CHECK_OUT_OF_MEM(func); + strcpy(func->functionName, "cast"); + func->node.resType = dt; + nodesListMakeAppend(&func->pParameterList, pExpr); + return (SNode*)func; +} + SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList) { SNodeListNode* list = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST); CHECK_OUT_OF_MEM(list); @@ -927,18 +944,6 @@ 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)) { diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 9e53eee5c8d16ce329487aed3e0ab60e38c3824f..acc597d61bc4ea9a430f86cc90e637ae158cc13d 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/parTranslater.c b/source/libs/parser/src/parTranslater.c index 7919fcedd1f12c827644625b102573f6041fdd09..f89f5fbb221c8b845fb8f27d5ab20dc3338b3a04 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -415,7 +415,6 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) { pVal->datum.d = strtold(pVal->literal, &endPtr); break; } - case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARBINARY: { pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1); @@ -433,6 +432,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) { } break; } + case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_JSON: case TSDB_DATA_TYPE_DECIMAL: case TSDB_DATA_TYPE_BLOB: @@ -485,9 +485,9 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc) if (TSDB_CODE_SUCCESS != fmGetFuncInfo(pFunc->functionName, &pFunc->funcId, &pFunc->funcType)) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_FUNTION, pFunc->functionName); } - int32_t code = fmGetFuncResultType(pFunc); - if (TSDB_CODE_SUCCESS != code) { - return generateDealNodeErrMsg(pCxt, code, pFunc->functionName); + pCxt->errCode = fmGetFuncResultType(pFunc, pCxt->msgBuf.buf, pCxt->msgBuf.len); + if (TSDB_CODE_SUCCESS != pCxt->errCode) { + return DEAL_RES_ERROR; } if (fmIsAggFunc(pFunc->funcId) && beforeHaving(pCxt->currClause)) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION); @@ -1366,6 +1366,25 @@ static int32_t checkCreateDatabase(STranslateContext* pCxt, SCreateDatabaseStmt* return checkDatabaseOptions(pCxt, pStmt->pOptions); } +typedef int32_t (*FSerializeFunc)(void *pBuf, int32_t bufLen, void *pReq); + +static int32_t buildCmdMsg(STranslateContext* pCxt, int16_t msgType, FSerializeFunc func, void* pReq) { + pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = msgType; + pCxt->pCmdMsg->msgLen = func(NULL, 0, pReq); + pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + func(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, pReq); + + return TSDB_CODE_SUCCESS; +} + static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt) { SCreateDbReq createReq = {0}; @@ -1375,18 +1394,7 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS } if (TSDB_CODE_SUCCESS == code) { - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_DB; - pCxt->pCmdMsg->msgLen = tSerializeSCreateDbReq(NULL, 0, &createReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSCreateDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); + code = buildCmdMsg(pCxt, TDMT_MND_CREATE_DB, (FSerializeFunc)tSerializeSCreateDbReq, &createReq); } return code; @@ -1394,25 +1402,12 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS static int32_t translateDropDatabase(STranslateContext* pCxt, SDropDatabaseStmt* pStmt) { SDropDbReq dropReq = {0}; - SName name = {0}; + SName name = {0}; tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); tNameGetFullDbName(&name, dropReq.db); dropReq.ignoreNotExists = pStmt->ignoreNotExists; - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_DROP_DB; - pCxt->pCmdMsg->msgLen = tSerializeSDropDbReq(NULL, 0, &dropReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSDropDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); - - return TSDB_CODE_SUCCESS; + return buildCmdMsg(pCxt, TDMT_MND_DROP_DB, (FSerializeFunc)tSerializeSDropDbReq, &dropReq); } static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt, SAlterDbReq* pReq) { @@ -1440,20 +1435,7 @@ static int32_t translateAlterDatabase(STranslateContext* pCxt, SAlterDatabaseStm SAlterDbReq alterReq = {0}; buildAlterDbReq(pCxt, pStmt, &alterReq); - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_ALTER_DB; - pCxt->pCmdMsg->msgLen = tSerializeSAlterDbReq(NULL, 0, &alterReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSAlterDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &alterReq); - - return TSDB_CODE_SUCCESS; + return buildCmdMsg(pCxt, TDMT_MND_ALTER_DB, (FSerializeFunc)tSerializeSAlterDbReq, &alterReq); } static int32_t calcTypeBytes(SDataType dt) { @@ -1615,23 +1597,9 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt strcpy(tableName.tname, pStmt->tableName); tNameExtractFullName(&tableName, createReq.name); - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - tFreeSMCreateStbReq(&createReq); - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_STB; - pCxt->pCmdMsg->msgLen = tSerializeSMCreateStbReq(NULL, 0, &createReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - tFreeSMCreateStbReq(&createReq); - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSMCreateStbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); - + code = buildCmdMsg(pCxt, TDMT_MND_CREATE_STB, (FSerializeFunc)tSerializeSMCreateStbReq, &createReq); tFreeSMCreateStbReq(&createReq); - return TSDB_CODE_SUCCESS; + return code; } static int32_t doTranslateDropSuperTable(STranslateContext* pCxt, const SName* pTableName, bool ignoreNotExists) { @@ -1639,20 +1607,7 @@ static int32_t doTranslateDropSuperTable(STranslateContext* pCxt, const SName* p tNameExtractFullName(pTableName, dropReq.name); dropReq.igNotExists = ignoreNotExists; - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_DROP_STB; - pCxt->pCmdMsg->msgLen = tSerializeSMDropStbReq(NULL, 0, &dropReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSMDropStbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); - - return TSDB_CODE_SUCCESS; + return buildCmdMsg(pCxt, TDMT_MND_DROP_STB, (FSerializeFunc)tSerializeSMDropStbReq, &dropReq); } static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt) { @@ -1736,20 +1691,7 @@ static int32_t translateAlterTable(STranslateContext* pCxt, SAlterTableStmt* pSt } } - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_ALTER_STB; - pCxt->pCmdMsg->msgLen = tSerializeSMAlterStbReq(NULL, 0, &alterReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSMAlterStbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &alterReq); - - return TSDB_CODE_SUCCESS; + return buildCmdMsg(pCxt, TDMT_MND_ALTER_STB, (FSerializeFunc)tSerializeSMAlterStbReq, &alterReq); } static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* pStmt) { @@ -1758,24 +1700,10 @@ static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* p tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); tNameExtractFullName(&name, usedbReq.db); int32_t code = getDBVgVersion(pCxt, usedbReq.db, &usedbReq.vgVersion, &usedbReq.dbId, &usedbReq.numOfTable); - if (TSDB_CODE_SUCCESS != code) { - return code; - } - - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_USE_DB; - pCxt->pCmdMsg->msgLen = tSerializeSUseDbReq(NULL, 0, &usedbReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; + if (TSDB_CODE_SUCCESS == code) { + code = buildCmdMsg(pCxt, TDMT_MND_USE_DB, (FSerializeFunc)tSerializeSUseDbReq, &usedbReq); } - tSerializeSUseDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &usedbReq); - - return TSDB_CODE_SUCCESS; + return code; } static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pStmt) { @@ -1785,20 +1713,7 @@ static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pSt createReq.superUser = 0; strcpy(createReq.pass, pStmt->password); - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_USER; - pCxt->pCmdMsg->msgLen = tSerializeSCreateUserReq(NULL, 0, &createReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSCreateUserReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); - - return TSDB_CODE_SUCCESS; + return buildCmdMsg(pCxt, TDMT_MND_CREATE_USER, (FSerializeFunc)tSerializeSCreateUserReq, &createReq); } static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt) { @@ -1811,40 +1726,14 @@ static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt strcpy(alterReq.dbname, pCxt->pParseCxt->db); } - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_ALTER_USER; - pCxt->pCmdMsg->msgLen = tSerializeSAlterUserReq(NULL, 0, &alterReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSAlterUserReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &alterReq); - - return TSDB_CODE_SUCCESS; + return buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &alterReq); } static int32_t translateDropUser(STranslateContext* pCxt, SDropUserStmt* pStmt) { SDropUserReq dropReq = {0}; strcpy(dropReq.user, pStmt->useName); - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_DROP_USER; - pCxt->pCmdMsg->msgLen = tSerializeSDropUserReq(NULL, 0, &dropReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSDropUserReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); - - return TSDB_CODE_SUCCESS; + return buildCmdMsg(pCxt, TDMT_MND_DROP_USER, (FSerializeFunc)tSerializeSDropUserReq, &dropReq); } static int32_t translateCreateDnode(STranslateContext* pCxt, SCreateDnodeStmt* pStmt) { @@ -1852,20 +1741,7 @@ static int32_t translateCreateDnode(STranslateContext* pCxt, SCreateDnodeStmt* p strcpy(createReq.fqdn, pStmt->fqdn); createReq.port = pStmt->port; - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_DNODE; - pCxt->pCmdMsg->msgLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSCreateDnodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); - - return TSDB_CODE_SUCCESS; + return buildCmdMsg(pCxt, TDMT_MND_CREATE_DNODE, (FSerializeFunc)tSerializeSCreateDnodeReq, &createReq); } static int32_t translateDropDnode(STranslateContext* pCxt, SDropDnodeStmt* pStmt) { @@ -1874,20 +1750,7 @@ static int32_t translateDropDnode(STranslateContext* pCxt, SDropDnodeStmt* pStmt strcpy(dropReq.fqdn, pStmt->fqdn); dropReq.port = pStmt->port; - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_DROP_DNODE; - pCxt->pCmdMsg->msgLen = tSerializeSDropDnodeReq(NULL, 0, &dropReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSDropDnodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); - - return TSDB_CODE_SUCCESS; + return buildCmdMsg(pCxt, TDMT_MND_DROP_DNODE, (FSerializeFunc)tSerializeSDropDnodeReq, &dropReq); } static int32_t translateAlterDnode(STranslateContext* pCxt, SAlterDnodeStmt* pStmt) { @@ -1896,61 +1759,30 @@ static int32_t translateAlterDnode(STranslateContext* pCxt, SAlterDnodeStmt* pSt strcpy(cfgReq.config, pStmt->config); strcpy(cfgReq.value, pStmt->value); - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_CONFIG_DNODE; - pCxt->pCmdMsg->msgLen = tSerializeSMCfgDnodeReq(NULL, 0, &cfgReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSMCfgDnodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &cfgReq); - - return TSDB_CODE_SUCCESS; + return buildCmdMsg(pCxt, TDMT_MND_CONFIG_DNODE, (FSerializeFunc)tSerializeSMCfgDnodeReq, &cfgReq); } static int32_t nodeTypeToShowType(ENodeType nt) { - switch (nt) { - case QUERY_NODE_SHOW_APPS_STMT: - return 0; // todo - case QUERY_NODE_SHOW_CONNECTIONS_STMT: - return TSDB_MGMT_TABLE_CONNS; - case QUERY_NODE_SHOW_LICENCE_STMT: - return TSDB_MGMT_TABLE_GRANTS; - case QUERY_NODE_SHOW_QUERIES_STMT: - return TSDB_MGMT_TABLE_QUERIES; - case QUERY_NODE_SHOW_SCORES_STMT: - return 0; // todo - case QUERY_NODE_SHOW_TOPICS_STMT: - return 0; // todo - case QUERY_NODE_SHOW_VARIABLE_STMT: - return TSDB_MGMT_TABLE_VARIABLES; - default: - break; - } + // switch (nt) { + // case QUERY_NODE_SHOW_CONNECTIONS_STMT: + // return TSDB_MGMT_TABLE_CONNS; + // case QUERY_NODE_SHOW_LICENCE_STMT: + // return TSDB_MGMT_TABLE_GRANTS; + // case QUERY_NODE_SHOW_QUERIES_STMT: + // return TSDB_MGMT_TABLE_QUERIES; + // case QUERY_NODE_SHOW_TOPICS_STMT: + // return 0; // todo + // case QUERY_NODE_SHOW_VARIABLE_STMT: + // return TSDB_MGMT_TABLE_VARIABLES; + // default: + // break; + // } return 0; } static int32_t translateShow(STranslateContext* pCxt, SShowStmt* pStmt) { SShowReq showReq = {.type = nodeTypeToShowType(nodeType(pStmt))}; - - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_SHOW; - pCxt->pCmdMsg->msgLen = tSerializeSShowReq(NULL, 0, &showReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSShowReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &showReq); - - return TSDB_CODE_SUCCESS; + return buildCmdMsg(pCxt, TDMT_MND_SHOW, (FSerializeFunc)tSerializeSShowReq, &showReq); } static int32_t getSmaIndexDstVgId(STranslateContext* pCxt, char* pTableName, int32_t* pVgId) { @@ -2070,61 +1902,25 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt } SMCreateSmaReq createSmaReq = {0}; - int32_t code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq); - if (TSDB_CODE_SUCCESS != code) { - return code; - } - - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_SMA; - pCxt->pCmdMsg->msgLen = tSerializeSMCreateSmaReq(NULL, 0, &createSmaReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; + if (TSDB_CODE_SUCCESS == code) { + code = buildCmdMsg(pCxt, TDMT_MND_CREATE_SMA, (FSerializeFunc)tSerializeSMCreateSmaReq, &createSmaReq); } - tSerializeSMCreateSmaReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createSmaReq); tFreeSMCreateSmaReq(&createSmaReq); - - return TSDB_CODE_SUCCESS; + return code; } static int32_t buildCreateFullTextReq(STranslateContext* pCxt, SCreateIndexStmt* pStmt, SMCreateFullTextReq* pReq) { // impl later return 0; } static int32_t translateCreateFullTextIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { - if (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pInterval) || - (NULL != pStmt->pOptions->pOffset && - DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pOffset)) || - (NULL != pStmt->pOptions->pSliding && - DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding))) { - return pCxt->errCode; - } SMCreateFullTextReq createFTReq = {0}; - int32_t code = buildCreateFullTextReq(pCxt, pStmt, &createFTReq); - if (TSDB_CODE_SUCCESS != code) { - return code; - } - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_INDEX; - pCxt->pCmdMsg->msgLen = tSerializeSMCreateFullTextReq(NULL, 0, &createFTReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; + if (TSDB_CODE_SUCCESS == code) { + code = buildCmdMsg(pCxt, TDMT_MND_CREATE_INDEX, (FSerializeFunc)tSerializeSMCreateFullTextReq, &createFTReq); } - tSerializeSMCreateFullTextReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createFTReq); tFreeSMCreateFullTextReq(&createFTReq); - - return TSDB_CODE_SUCCESS; + return code; } static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { @@ -2132,7 +1928,6 @@ static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* p return translateCreateSmaIndex(pCxt, pStmt); } else if (INDEX_TYPE_FULLTEXT == pStmt->indexType) { return translateCreateFullTextIndex(pCxt, pStmt); - // todo fulltext index } return TSDB_CODE_FAILED; } @@ -2176,21 +1971,7 @@ static int16_t getCreateComponentNodeMsgType(ENodeType type) { static int32_t translateCreateComponentNode(STranslateContext* pCxt, SCreateComponentNodeStmt* pStmt) { SMCreateQnodeReq createReq = {.dnodeId = pStmt->dnodeId}; - - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = getCreateComponentNodeMsgType(nodeType(pStmt)); - pCxt->pCmdMsg->msgLen = tSerializeSCreateDropMQSBNodeReq(NULL, 0, &createReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSCreateDropMQSBNodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); - - return TSDB_CODE_SUCCESS; + return buildCmdMsg(pCxt, getCreateComponentNodeMsgType(nodeType(pStmt)), (FSerializeFunc)tSerializeSCreateDropMQSBNodeReq, &createReq); } static int16_t getDropComponentNodeMsgType(ENodeType type) { @@ -2211,21 +1992,7 @@ static int16_t getDropComponentNodeMsgType(ENodeType type) { static int32_t translateDropComponentNode(STranslateContext* pCxt, SDropComponentNodeStmt* pStmt) { SDDropQnodeReq dropReq = {.dnodeId = pStmt->dnodeId}; - - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = getDropComponentNodeMsgType(nodeType(pStmt)); - pCxt->pCmdMsg->msgLen = tSerializeSCreateDropMQSBNodeReq(NULL, 0, &dropReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSCreateDropMQSBNodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); - - return TSDB_CODE_SUCCESS; + return buildCmdMsg(pCxt, getDropComponentNodeMsgType(nodeType(pStmt)), (FSerializeFunc)tSerializeSCreateDropMQSBNodeReq, &dropReq); } static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* pStmt) { @@ -2255,21 +2022,9 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p tNameExtractFullName(&name, createReq.name); createReq.igExists = pStmt->ignoreExists; - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_TOPIC; - pCxt->pCmdMsg->msgLen = tSerializeSCMCreateTopicReq(NULL, 0, &createReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSCMCreateTopicReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); + int32_t code = buildCmdMsg(pCxt, TDMT_MND_CREATE_TOPIC, (FSerializeFunc)tSerializeSCMCreateTopicReq, &createReq); tFreeSCMCreateTopicReq(&createReq); - - return TSDB_CODE_SUCCESS; + return code; } static int32_t translateDropTopic(STranslateContext* pCxt, SDropTopicStmt* pStmt) { @@ -2281,20 +2036,7 @@ static int32_t translateDropTopic(STranslateContext* pCxt, SDropTopicStmt* pStmt tNameExtractFullName(&name, dropReq.name); dropReq.igNotExists = pStmt->ignoreNotExists; - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_MND_DROP_TOPIC; - pCxt->pCmdMsg->msgLen = tSerializeSMDropTopicReq(NULL, 0, &dropReq); - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - tSerializeSMDropTopicReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); - - return TSDB_CODE_SUCCESS; + return buildCmdMsg(pCxt, TDMT_MND_DROP_TOPIC, (FSerializeFunc)tSerializeSMDropTopicReq, &dropReq); } static int32_t translateAlterLocal(STranslateContext* pCxt, SAlterLocalStmt* pStmt) { @@ -2313,6 +2055,19 @@ static int32_t translateDescribe(STranslateContext* pCxt, SDescribeStmt* pStmt) return getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pStmt->pMeta); } +static int32_t translateKillConnection(STranslateContext* pCxt, SKillStmt* pStmt) { + SKillConnReq killReq = {0}; + killReq.connId = pStmt->targetId; + return buildCmdMsg(pCxt, TDMT_MND_KILL_CONN, (FSerializeFunc)tSerializeSKillQueryReq, &killReq); +} + +static int32_t translateKillQuery(STranslateContext* pCxt, SKillStmt* pStmt) { + SKillQueryReq killReq = {0}; + killReq.queryId = pStmt->targetId; + return buildCmdMsg(pCxt, TDMT_MND_KILL_QUERY, (FSerializeFunc)tSerializeSKillQueryReq, &killReq); +} + + static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pNode)) { @@ -2361,19 +2116,11 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_ALTER_DNODE_STMT: code = translateAlterDnode(pCxt, (SAlterDnodeStmt*)pNode); break; - case QUERY_NODE_SHOW_APPS_STMT: case QUERY_NODE_SHOW_CONNECTIONS_STMT: case QUERY_NODE_SHOW_QUERIES_STMT: - case QUERY_NODE_SHOW_SCORES_STMT: case QUERY_NODE_SHOW_TOPICS_STMT: - case QUERY_NODE_SHOW_VARIABLE_STMT: code = translateShow(pCxt, (SShowStmt*)pNode); break; - case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: - case QUERY_NODE_SHOW_CREATE_TABLE_STMT: - case QUERY_NODE_SHOW_CREATE_STABLE_STMT: - // todo - break; case QUERY_NODE_CREATE_INDEX_STMT: code = translateCreateIndex(pCxt, (SCreateIndexStmt*)pNode); break; @@ -2407,6 +2154,12 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_DESCRIBE_STMT: code = translateDescribe(pCxt, (SDescribeStmt*)pNode); break; + case QUERY_NODE_KILL_CONNECTION_STMT: + code = translateKillConnection(pCxt, (SKillStmt*)pNode); + break; + case QUERY_NODE_KILL_QUERY_STMT: + code = translateKillQuery(pCxt, (SKillStmt*)pNode); + break; default: break; } @@ -2445,6 +2198,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)); @@ -2466,19 +2223,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; } @@ -2520,6 +2277,33 @@ static void destroyTranslateContext(STranslateContext* pCxt) { taosHashCleanup(pCxt->pTables); } +static const char* getSysDbName(ENodeType type) { + switch (type) { + case QUERY_NODE_SHOW_DATABASES_STMT: + case QUERY_NODE_SHOW_TABLES_STMT: + case QUERY_NODE_SHOW_STABLES_STMT: + case QUERY_NODE_SHOW_USERS_STMT: + case QUERY_NODE_SHOW_DNODES_STMT: + case QUERY_NODE_SHOW_VGROUPS_STMT: + case QUERY_NODE_SHOW_MNODES_STMT: + case QUERY_NODE_SHOW_MODULES_STMT: + case QUERY_NODE_SHOW_QNODES_STMT: + case QUERY_NODE_SHOW_FUNCTIONS_STMT: + case QUERY_NODE_SHOW_INDEXES_STMT: + case QUERY_NODE_SHOW_STREAMS_STMT: + case QUERY_NODE_SHOW_BNODES_STMT: + case QUERY_NODE_SHOW_SNODES_STMT: + case QUERY_NODE_SHOW_LICENCE_STMT: + return TSDB_INFORMATION_SCHEMA_DB; + case QUERY_NODE_SHOW_CONNECTIONS_STMT: + case QUERY_NODE_SHOW_QUERIES_STMT: + return TSDB_PERFORMANCE_SCHEMA_DB; + default: + break; + } + return NULL; +} + static const char* getSysTableName(ENodeType type) { switch (type) { case QUERY_NODE_SHOW_DATABASES_STMT: @@ -2552,6 +2336,9 @@ static const char* getSysTableName(ENodeType type) { return TSDB_INS_TABLE_SNODES; case QUERY_NODE_SHOW_LICENCE_STMT: return TSDB_INS_TABLE_LICENCES; + case QUERY_NODE_SHOW_CONNECTIONS_STMT: + case QUERY_NODE_SHOW_QUERIES_STMT: + // todo default: break; } @@ -2570,7 +2357,7 @@ static int32_t createSelectStmtForShow(ENodeType showType, SSelectStmt** pStmt) nodesDestroyNode(pSelect); return TSDB_CODE_OUT_OF_MEMORY; } - strcpy(pTable->table.dbName, TSDB_INFORMATION_SCHEMA_DB); + strcpy(pTable->table.dbName, getSysDbName(showType)); strcpy(pTable->table.tableName, getSysTableName(showType)); strcpy(pTable->table.tableAlias, pTable->table.tableName); pSelect->pFromTable = (SNode*)pTable; @@ -3074,6 +2861,8 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) { case QUERY_NODE_SHOW_STREAMS_STMT: case QUERY_NODE_SHOW_BNODES_STMT: case QUERY_NODE_SHOW_SNODES_STMT: + case QUERY_NODE_SHOW_CONNECTIONS_STMT: + case QUERY_NODE_SHOW_QUERIES_STMT: code = rewriteShow(pCxt, pQuery); break; case QUERY_NODE_CREATE_TABLE_STMT: @@ -3127,6 +2916,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/parUtil.c b/source/libs/parser/src/parUtil.c index 85d574d9e7e4d79c9a26e8d32f3ea503b9e90e93..efc807850f4c25fb27addd8b7b1f40e76467dc9c 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -31,10 +31,6 @@ static char* getSyntaxErrFormat(int32_t errCode) { return "Invalid value type : %s"; case TSDB_CODE_PAR_INVALID_FUNTION: return "Invalid function name : %s"; - case TSDB_CODE_PAR_FUNTION_PARA_NUM: - return "Invalid number of arguments : %s"; - case TSDB_CODE_PAR_FUNTION_PARA_TYPE: - return "Inconsistent datatypes : %s"; case TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION: return "There mustn't be aggregation"; case TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT: diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index b1f8a24a83cb638777fbeba6b2a6c4c05b22600e..f4436bb3e2a72cbf78cfc3ceaba94d6e97212519 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 315 +#define YYNOCODE 316 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SToken yy29; - bool yy47; - EFillMode yy144; - EJoinType yy162; - SNode* yy182; - EOrder yy218; - SNodeList* yy334; - EOperatorType yy380; - ENullOrder yy487; - SAlterOption yy515; - int32_t yy550; - SDataType yy574; + SAlterOption yy21; + EFillMode yy22; + EOperatorType yy84; + bool yy121; + SDataType yy160; + ENullOrder yy281; + SToken yy409; + int32_t yy452; + SNodeList* yy488; + SNode* yy504; + EOrder yy522; + EJoinType yy556; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -132,18 +132,18 @@ typedef union { #define ParseCTX_PARAM #define ParseCTX_FETCH #define ParseCTX_STORE -#define YYNSTATE 548 -#define YYNRULE 411 -#define YYNRULE_WITH_ACTION 411 -#define YYNTOKEN 209 -#define YY_MAX_SHIFT 547 -#define YY_MIN_SHIFTREDUCE 808 -#define YY_MAX_SHIFTREDUCE 1218 -#define YY_ERROR_ACTION 1219 -#define YY_ACCEPT_ACTION 1220 -#define YY_NO_ACTION 1221 -#define YY_MIN_REDUCE 1222 -#define YY_MAX_REDUCE 1632 +#define YYNSTATE 550 +#define YYNRULE 412 +#define YYNRULE_WITH_ACTION 412 +#define YYNTOKEN 210 +#define YY_MAX_SHIFT 549 +#define YY_MIN_SHIFTREDUCE 811 +#define YY_MAX_SHIFTREDUCE 1222 +#define YY_ERROR_ACTION 1223 +#define YY_ACCEPT_ACTION 1224 +#define YY_NO_ACTION 1225 +#define YY_MIN_REDUCE 1226 +#define YY_MAX_REDUCE 1637 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -210,483 +210,487 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (1539) +#define YY_ACTTAB_COUNT (1559) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 450, 257, 1483, 269, 25, 194, 1432, 117, 122, 1234, - /* 10 */ 312, 1331, 30, 28, 1479, 1486, 306, 1499, 1483, 1382, - /* 20 */ 266, 462, 1053, 21, 1075, 32, 31, 29, 27, 26, - /* 30 */ 1479, 1485, 23, 32, 31, 29, 27, 26, 1051, 274, - /* 40 */ 238, 1516, 32, 31, 29, 27, 26, 1611, 446, 1073, - /* 50 */ 11, 30, 28, 1161, 348, 406, 1483, 1058, 449, 266, - /* 60 */ 131, 1053, 1470, 1320, 1609, 30, 28, 434, 1479, 1485, - /* 70 */ 430, 9, 8, 266, 1, 1053, 463, 1051, 68, 1500, - /* 80 */ 1501, 1505, 1550, 540, 539, 72, 240, 1546, 1175, 11, - /* 90 */ 1499, 1051, 369, 424, 450, 100, 1058, 544, 1611, 407, - /* 100 */ 1433, 1342, 1261, 11, 32, 31, 29, 27, 26, 1052, - /* 110 */ 1058, 131, 348, 1, 1516, 1609, 32, 31, 29, 27, - /* 120 */ 26, 433, 118, 1389, 384, 277, 1300, 1, 98, 256, - /* 130 */ 1611, 449, 1423, 1425, 1387, 1470, 544, 432, 127, 1557, - /* 140 */ 1558, 270, 1562, 131, 498, 1137, 1054, 1609, 1052, 115, - /* 150 */ 544, 69, 1500, 1501, 1505, 1550, 845, 1344, 844, 259, - /* 160 */ 1546, 126, 1052, 1057, 1077, 1078, 1104, 1105, 1106, 1107, - /* 170 */ 1108, 1109, 1110, 1111, 1112, 164, 846, 381, 380, 372, - /* 180 */ 1578, 462, 1564, 1220, 84, 1054, 132, 83, 82, 81, - /* 190 */ 80, 79, 78, 77, 76, 75, 29, 27, 26, 1054, - /* 200 */ 1561, 374, 1057, 1077, 1078, 1104, 1105, 1106, 1107, 1108, - /* 210 */ 1109, 1110, 1111, 1112, 1319, 132, 1057, 1077, 1078, 1104, - /* 220 */ 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1318, 30, - /* 230 */ 28, 547, 305, 1564, 304, 12, 282, 266, 383, 1053, - /* 240 */ 377, 896, 132, 1215, 382, 213, 462, 97, 95, 378, - /* 250 */ 376, 1560, 379, 115, 536, 1051, 532, 528, 524, 212, - /* 260 */ 898, 1345, 32, 31, 29, 27, 26, 1611, 30, 28, - /* 270 */ 448, 1499, 463, 132, 1058, 209, 266, 498, 1053, 494, - /* 280 */ 131, 310, 30, 28, 1609, 66, 52, 1076, 206, 1074, - /* 290 */ 266, 7, 1053, 1333, 1051, 1516, 65, 1342, 1516, 96, - /* 300 */ 12, 496, 433, 1245, 334, 446, 463, 1337, 1051, 489, - /* 310 */ 101, 1214, 449, 1058, 544, 311, 1470, 1334, 459, 438, - /* 320 */ 493, 492, 491, 1185, 490, 1092, 1052, 1058, 513, 511, - /* 330 */ 7, 1342, 69, 1500, 1501, 1505, 1550, 423, 1470, 395, - /* 340 */ 259, 1546, 126, 1274, 7, 1222, 412, 132, 1470, 171, - /* 350 */ 141, 140, 393, 544, 190, 417, 1183, 1184, 1186, 1187, - /* 360 */ 413, 1577, 500, 1054, 1037, 1052, 168, 544, 1244, 93, - /* 370 */ 92, 91, 90, 89, 88, 87, 86, 85, 1327, 1052, - /* 380 */ 1057, 1077, 1078, 1104, 1105, 1106, 1107, 1108, 1109, 1110, - /* 390 */ 1111, 1112, 1079, 430, 1389, 383, 52, 377, 1611, 1329, - /* 400 */ 271, 382, 1054, 132, 97, 1387, 378, 376, 1243, 379, - /* 410 */ 1242, 1610, 405, 1470, 1241, 1609, 1054, 1338, 100, 1057, - /* 420 */ 1077, 1078, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, - /* 430 */ 1112, 1077, 1078, 1057, 1077, 1078, 1104, 1105, 1106, 1107, - /* 440 */ 1108, 1109, 1110, 1111, 1112, 430, 30, 28, 237, 420, - /* 450 */ 1073, 98, 439, 1470, 266, 1470, 1053, 327, 59, 1470, - /* 460 */ 339, 128, 1557, 1558, 1420, 1562, 1080, 1160, 397, 340, - /* 470 */ 100, 139, 1051, 32, 31, 29, 27, 26, 437, 1335, - /* 480 */ 934, 486, 485, 484, 938, 483, 940, 941, 482, 943, - /* 490 */ 479, 1058, 949, 476, 951, 952, 473, 470, 1223, 1611, - /* 500 */ 1569, 1156, 1564, 98, 425, 421, 9, 8, 1, 463, - /* 510 */ 189, 241, 131, 129, 1557, 1558, 1609, 1562, 319, 84, - /* 520 */ 1559, 1240, 83, 82, 81, 80, 79, 78, 77, 76, - /* 530 */ 75, 544, 216, 1325, 1342, 1372, 1092, 32, 31, 29, - /* 540 */ 27, 26, 338, 1052, 1124, 333, 332, 331, 330, 329, - /* 550 */ 1239, 326, 325, 324, 323, 322, 318, 317, 316, 315, - /* 560 */ 314, 313, 1271, 137, 116, 463, 1470, 1238, 501, 222, - /* 570 */ 1314, 1389, 1389, 6, 320, 32, 31, 29, 27, 26, - /* 580 */ 1054, 220, 1424, 1388, 175, 1168, 169, 447, 1237, 50, - /* 590 */ 1342, 1075, 49, 1125, 142, 1470, 488, 1057, 1077, 1078, - /* 600 */ 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1235, - /* 610 */ 1236, 1129, 1470, 241, 520, 519, 518, 517, 281, 1233, - /* 620 */ 516, 515, 514, 102, 509, 508, 507, 506, 505, 504, - /* 630 */ 503, 502, 108, 1470, 1232, 1499, 24, 264, 1119, 1120, - /* 640 */ 1121, 1122, 1123, 1127, 1128, 463, 1124, 463, 1231, 463, - /* 650 */ 1159, 844, 276, 463, 72, 1470, 347, 67, 1339, 1516, - /* 660 */ 115, 375, 460, 114, 1470, 279, 446, 367, 1344, 1256, - /* 670 */ 1342, 870, 1342, 115, 1342, 463, 449, 436, 1342, 1470, - /* 680 */ 1470, 1344, 1230, 1229, 461, 48, 47, 309, 1499, 136, - /* 690 */ 871, 386, 463, 1470, 303, 1125, 119, 1500, 1501, 1505, - /* 700 */ 1342, 208, 246, 297, 295, 1389, 291, 287, 133, 1301, - /* 710 */ 512, 278, 1516, 1129, 300, 1156, 1387, 1342, 299, 446, - /* 720 */ 157, 1053, 463, 155, 1499, 1228, 1227, 1470, 1470, 449, - /* 730 */ 445, 280, 132, 1470, 435, 1624, 1126, 1051, 24, 264, - /* 740 */ 1119, 1120, 1121, 1122, 1123, 1127, 1128, 1342, 1516, 69, - /* 750 */ 1500, 1501, 1505, 1550, 1130, 446, 1058, 259, 1546, 1623, - /* 760 */ 1499, 1459, 1226, 152, 1225, 449, 125, 191, 1584, 1470, - /* 770 */ 1470, 1470, 365, 343, 361, 357, 353, 151, 159, 22, - /* 780 */ 161, 158, 418, 160, 1516, 69, 1500, 1501, 1505, 1550, - /* 790 */ 1254, 446, 441, 259, 1546, 1623, 544, 289, 1217, 1218, - /* 800 */ 1383, 449, 250, 53, 1607, 1470, 149, 1470, 1052, 1470, - /* 810 */ 1499, 163, 389, 106, 162, 44, 178, 409, 404, 1182, - /* 820 */ 180, 69, 1500, 1501, 1505, 1550, 1490, 184, 164, 259, - /* 830 */ 1546, 1623, 372, 366, 1516, 33, 1580, 1499, 1488, 1131, - /* 840 */ 1568, 446, 431, 1116, 251, 1054, 249, 248, 1061, 371, - /* 850 */ 1517, 449, 1499, 33, 374, 1470, 193, 1088, 1073, 1060, - /* 860 */ 434, 1516, 1057, 148, 2, 121, 33, 145, 446, 284, - /* 870 */ 1020, 228, 1500, 1501, 1505, 288, 1516, 197, 449, 1499, - /* 880 */ 245, 199, 1470, 446, 143, 94, 273, 272, 104, 455, - /* 890 */ 896, 1611, 205, 449, 247, 1029, 1066, 1470, 70, 1500, - /* 900 */ 1501, 1505, 1550, 1516, 131, 321, 1549, 1546, 1609, 214, - /* 910 */ 446, 1422, 1059, 70, 1500, 1501, 1505, 1550, 64, 1064, - /* 920 */ 449, 444, 1546, 430, 1470, 106, 328, 442, 61, 927, - /* 930 */ 1063, 1058, 44, 468, 104, 138, 922, 955, 959, 336, - /* 940 */ 70, 1500, 1501, 1505, 1550, 335, 105, 337, 100, 1547, - /* 950 */ 965, 1084, 341, 106, 104, 1499, 342, 964, 107, 1083, - /* 960 */ 144, 345, 344, 1082, 346, 349, 147, 434, 51, 150, - /* 970 */ 1081, 464, 368, 370, 1332, 154, 373, 1328, 74, 1516, - /* 980 */ 399, 98, 1499, 1062, 400, 401, 446, 255, 408, 156, - /* 990 */ 1499, 187, 1557, 429, 170, 428, 449, 173, 1611, 109, - /* 1000 */ 1470, 110, 1330, 265, 1326, 111, 1516, 112, 1080, 411, - /* 1010 */ 419, 131, 1591, 446, 1516, 1609, 229, 1500, 1501, 1505, - /* 1020 */ 1067, 446, 398, 449, 410, 453, 1058, 1470, 1581, 416, - /* 1030 */ 414, 449, 176, 179, 1499, 1470, 5, 1070, 1590, 415, - /* 1040 */ 258, 422, 427, 233, 1500, 1501, 1505, 4, 99, 1079, - /* 1050 */ 1571, 232, 1500, 1501, 1505, 185, 183, 1156, 1516, 124, - /* 1060 */ 1565, 34, 443, 260, 17, 446, 1431, 1532, 1499, 186, - /* 1070 */ 440, 1430, 456, 457, 60, 449, 1499, 451, 458, 1470, - /* 1080 */ 452, 1499, 268, 426, 201, 203, 1343, 466, 58, 221, - /* 1090 */ 1626, 1315, 1516, 211, 192, 119, 1500, 1501, 1505, 446, - /* 1100 */ 1516, 1608, 215, 495, 217, 1516, 543, 446, 223, 449, - /* 1110 */ 40, 1464, 446, 1470, 224, 219, 263, 449, 1463, 283, - /* 1120 */ 1460, 1470, 449, 1499, 267, 285, 1470, 1047, 1499, 233, - /* 1130 */ 1500, 1501, 1505, 388, 1625, 286, 1499, 233, 1500, 1501, - /* 1140 */ 1505, 1048, 225, 1500, 1501, 1505, 290, 1516, 396, 1458, - /* 1150 */ 134, 294, 1516, 292, 446, 293, 1457, 296, 1456, 446, - /* 1160 */ 1516, 298, 166, 1447, 449, 391, 135, 446, 1470, 449, - /* 1170 */ 385, 301, 302, 1470, 1317, 1441, 165, 449, 1032, 1031, - /* 1180 */ 1499, 1470, 1440, 307, 231, 1500, 1501, 1505, 308, 234, - /* 1190 */ 1500, 1501, 1505, 1439, 1438, 1499, 1003, 226, 1500, 1501, - /* 1200 */ 1505, 1415, 42, 1414, 1516, 41, 1499, 1413, 1412, 1411, - /* 1210 */ 1410, 446, 1409, 1408, 1407, 1406, 1405, 1404, 1403, 1516, - /* 1220 */ 1402, 449, 1401, 1400, 103, 1470, 446, 1399, 1398, 1397, - /* 1230 */ 1516, 1499, 1396, 1395, 1394, 209, 449, 446, 1393, 494, - /* 1240 */ 1470, 235, 1500, 1501, 1505, 1392, 1005, 449, 1391, 1390, - /* 1250 */ 1273, 1470, 1455, 1449, 1437, 1516, 227, 1500, 1501, 1505, - /* 1260 */ 1428, 496, 446, 1321, 146, 1499, 1272, 236, 1500, 1501, - /* 1270 */ 1505, 1270, 449, 350, 352, 351, 1470, 863, 1499, 1268, - /* 1280 */ 493, 492, 491, 356, 490, 354, 1266, 355, 1264, 1516, - /* 1290 */ 1253, 359, 1513, 1500, 1501, 1505, 446, 358, 1252, 360, - /* 1300 */ 362, 363, 1516, 1249, 364, 1323, 449, 972, 73, 446, - /* 1310 */ 1470, 153, 1499, 512, 970, 1322, 895, 510, 894, 449, - /* 1320 */ 1499, 893, 892, 1470, 1262, 1499, 1512, 1500, 1501, 1505, - /* 1330 */ 252, 889, 888, 1257, 253, 387, 1516, 1255, 254, 243, - /* 1340 */ 1500, 1501, 1505, 446, 1516, 390, 1248, 392, 1247, 1516, - /* 1350 */ 394, 446, 71, 449, 1454, 167, 446, 1470, 1039, 1448, - /* 1360 */ 402, 449, 113, 1436, 1435, 1470, 449, 1499, 1427, 54, - /* 1370 */ 1470, 123, 1499, 1511, 1500, 1501, 1505, 172, 14, 43, - /* 1380 */ 3, 244, 1500, 1501, 1505, 33, 242, 1500, 1501, 1505, - /* 1390 */ 38, 1516, 177, 1181, 15, 403, 1516, 120, 446, 1488, - /* 1400 */ 174, 181, 37, 446, 19, 56, 1174, 182, 449, 55, - /* 1410 */ 20, 1203, 1470, 449, 36, 1153, 1152, 1470, 16, 1208, - /* 1420 */ 1202, 35, 261, 1207, 1206, 262, 8, 13, 239, 1500, - /* 1430 */ 1501, 1505, 1090, 230, 1500, 1501, 1505, 188, 130, 1117, - /* 1440 */ 1089, 195, 196, 18, 1426, 1179, 198, 454, 10, 200, - /* 1450 */ 45, 202, 57, 1068, 204, 61, 956, 39, 467, 275, - /* 1460 */ 1487, 471, 469, 207, 465, 953, 472, 474, 950, 475, - /* 1470 */ 477, 944, 478, 480, 942, 933, 481, 62, 967, 948, - /* 1480 */ 46, 63, 961, 963, 487, 861, 497, 902, 947, 499, - /* 1490 */ 946, 877, 884, 945, 883, 882, 210, 881, 899, 880, - /* 1500 */ 879, 878, 897, 874, 873, 872, 869, 1269, 868, 966, - /* 1510 */ 867, 866, 521, 522, 523, 1267, 525, 526, 527, 1265, - /* 1520 */ 529, 530, 531, 1263, 533, 534, 535, 1251, 537, 538, - /* 1530 */ 1250, 1246, 541, 542, 1221, 1055, 218, 545, 546, + /* 0 */ 452, 1224, 258, 270, 452, 465, 1436, 25, 195, 118, + /* 10 */ 1437, 1238, 30, 28, 73, 21, 307, 1505, 1337, 1487, + /* 20 */ 267, 370, 1056, 23, 464, 32, 31, 29, 27, 26, + /* 30 */ 1346, 1483, 1489, 32, 31, 29, 27, 26, 1054, 275, + /* 40 */ 1078, 1523, 32, 31, 29, 27, 26, 1616, 434, 464, + /* 50 */ 11, 30, 28, 1165, 283, 1324, 1487, 1061, 451, 267, + /* 60 */ 132, 1056, 1474, 1474, 1614, 30, 28, 450, 1483, 1489, + /* 70 */ 1505, 464, 349, 267, 1, 1056, 278, 1054, 70, 1506, + /* 80 */ 1507, 1512, 1555, 1427, 1429, 1616, 260, 1551, 127, 11, + /* 90 */ 1076, 1054, 1226, 1278, 1523, 1616, 1061, 546, 132, 1164, + /* 100 */ 191, 434, 1614, 12, 349, 1098, 414, 1582, 1615, 1055, + /* 110 */ 1061, 451, 1614, 1, 500, 1474, 94, 93, 92, 91, + /* 120 */ 90, 89, 88, 87, 86, 12, 124, 7, 1095, 138, + /* 130 */ 1487, 70, 1506, 1507, 1512, 1555, 546, 1386, 1393, 260, + /* 140 */ 1551, 127, 1483, 1490, 257, 384, 1057, 378, 1055, 1391, + /* 150 */ 546, 383, 465, 313, 98, 51, 379, 377, 50, 380, + /* 160 */ 1583, 311, 1055, 1060, 1080, 1081, 1082, 1083, 449, 1110, + /* 170 */ 1111, 1112, 1113, 1114, 1115, 1116, 431, 1346, 32, 31, + /* 180 */ 29, 27, 26, 239, 1079, 1057, 85, 133, 133, 84, + /* 190 */ 83, 82, 81, 80, 79, 78, 77, 76, 503, 1057, + /* 200 */ 1318, 101, 1060, 1080, 1081, 1082, 1083, 449, 1110, 1111, + /* 210 */ 1112, 1113, 1114, 1115, 1116, 1249, 1060, 1080, 1081, 1082, + /* 220 */ 1083, 449, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 30, + /* 230 */ 28, 306, 119, 305, 99, 425, 1304, 267, 133, 1056, + /* 240 */ 1523, 398, 30, 28, 129, 1562, 1563, 447, 1567, 238, + /* 250 */ 267, 1076, 1056, 542, 541, 1054, 251, 133, 328, 1569, + /* 260 */ 1474, 340, 32, 31, 29, 27, 26, 11, 1054, 1077, + /* 270 */ 341, 1505, 1616, 133, 1061, 899, 271, 1566, 53, 424, + /* 280 */ 30, 28, 165, 1163, 116, 132, 373, 1061, 267, 1614, + /* 290 */ 1056, 1, 1348, 165, 901, 1523, 66, 373, 252, 1342, + /* 300 */ 250, 249, 447, 372, 7, 1219, 1054, 491, 375, 384, + /* 310 */ 102, 378, 451, 465, 546, 383, 1474, 1338, 98, 375, + /* 320 */ 379, 377, 312, 380, 53, 1061, 1055, 546, 1080, 1081, + /* 330 */ 1082, 1083, 71, 1506, 1507, 1512, 1555, 97, 1346, 1055, + /* 340 */ 1554, 1551, 7, 339, 6, 1341, 334, 333, 332, 331, + /* 350 */ 330, 502, 327, 326, 325, 324, 323, 319, 318, 317, + /* 360 */ 316, 315, 314, 1057, 421, 546, 32, 31, 29, 27, + /* 370 */ 26, 382, 381, 1189, 1218, 514, 1057, 1055, 335, 301, + /* 380 */ 1060, 1080, 1081, 1082, 1083, 449, 1110, 1111, 1112, 1113, + /* 390 */ 1114, 1115, 1116, 1060, 1080, 1081, 1082, 1083, 449, 1110, + /* 400 */ 1111, 1112, 1113, 1114, 1115, 1116, 418, 1187, 1188, 1190, + /* 410 */ 1191, 29, 27, 26, 1057, 116, 1393, 133, 30, 28, + /* 420 */ 426, 422, 272, 1349, 142, 141, 267, 1391, 1056, 1179, + /* 430 */ 60, 1060, 1080, 1081, 1082, 1083, 449, 1110, 1111, 1112, + /* 440 */ 1113, 1114, 1115, 1116, 1054, 32, 31, 29, 27, 26, + /* 450 */ 1084, 1339, 937, 488, 487, 486, 941, 485, 943, 944, + /* 460 */ 484, 946, 481, 1061, 952, 478, 954, 955, 475, 472, + /* 470 */ 32, 31, 29, 27, 26, 515, 513, 1335, 1393, 1056, + /* 480 */ 1, 1275, 465, 242, 465, 465, 1248, 1160, 465, 1428, + /* 490 */ 1393, 73, 1424, 320, 321, 1054, 277, 348, 376, 140, + /* 500 */ 117, 1392, 465, 546, 116, 223, 1322, 1346, 1098, 1346, + /* 510 */ 1346, 1343, 1348, 1346, 1061, 1055, 1128, 221, 848, 1247, + /* 520 */ 847, 32, 31, 29, 27, 26, 217, 1346, 1331, 1376, + /* 530 */ 143, 1474, 431, 522, 521, 520, 519, 282, 849, 518, + /* 540 */ 517, 516, 103, 511, 510, 509, 508, 507, 506, 505, + /* 550 */ 504, 109, 1057, 1246, 546, 500, 1393, 101, 1333, 242, + /* 560 */ 438, 1245, 279, 1244, 1474, 1129, 1055, 1391, 190, 1060, + /* 570 */ 1080, 1081, 1082, 1083, 449, 1110, 1111, 1112, 1113, 1114, + /* 580 */ 1115, 1116, 465, 1133, 1329, 407, 442, 9, 8, 280, + /* 590 */ 99, 462, 1128, 68, 1243, 170, 115, 116, 1474, 433, + /* 600 */ 128, 1562, 1563, 1057, 1567, 1348, 1474, 1346, 1474, 24, + /* 610 */ 265, 1123, 1124, 1125, 1126, 1127, 1131, 1132, 1242, 406, + /* 620 */ 1060, 49, 48, 310, 1227, 137, 1241, 1240, 448, 408, + /* 630 */ 304, 1085, 1463, 1505, 1237, 1236, 1235, 465, 247, 1474, + /* 640 */ 296, 1129, 292, 288, 134, 85, 463, 1569, 84, 83, + /* 650 */ 82, 81, 80, 79, 78, 77, 76, 1523, 1569, 1133, + /* 660 */ 1616, 1141, 1346, 1474, 447, 1565, 1234, 1233, 290, 133, + /* 670 */ 490, 1474, 1474, 132, 451, 1505, 1564, 1614, 1474, 1474, + /* 680 */ 1474, 1474, 1130, 435, 431, 24, 265, 1123, 1124, 1125, + /* 690 */ 1126, 1127, 1131, 1132, 69, 1506, 1507, 1512, 1555, 1523, + /* 700 */ 1134, 1239, 241, 1551, 465, 1232, 447, 549, 1323, 101, + /* 710 */ 439, 1474, 1474, 209, 1616, 107, 451, 1505, 1231, 410, + /* 720 */ 1474, 214, 443, 1230, 96, 1229, 22, 132, 435, 1346, + /* 730 */ 538, 1614, 534, 530, 526, 213, 70, 1506, 1507, 1512, + /* 740 */ 1555, 1523, 99, 45, 260, 1551, 1628, 1186, 447, 176, + /* 750 */ 1474, 847, 188, 1562, 430, 1589, 429, 1305, 451, 1616, + /* 760 */ 437, 67, 1474, 1474, 207, 1505, 465, 368, 1474, 210, + /* 770 */ 1474, 1172, 132, 496, 446, 281, 1614, 1078, 70, 1506, + /* 780 */ 1507, 1512, 1555, 1574, 1160, 298, 260, 1551, 1628, 1523, + /* 790 */ 158, 1346, 431, 156, 461, 498, 447, 1612, 1265, 160, + /* 800 */ 300, 1260, 159, 9, 8, 162, 451, 1505, 161, 164, + /* 810 */ 1474, 1258, 163, 873, 495, 494, 493, 101, 492, 419, + /* 820 */ 385, 192, 413, 387, 396, 172, 70, 1506, 1507, 1512, + /* 830 */ 1555, 1523, 874, 390, 260, 1551, 1628, 394, 447, 179, + /* 840 */ 1040, 344, 169, 181, 440, 1573, 1221, 1222, 451, 34, + /* 850 */ 99, 34, 1474, 1135, 1505, 1093, 1064, 435, 405, 1387, + /* 860 */ 130, 1562, 1563, 153, 1567, 1063, 126, 1494, 229, 1506, + /* 870 */ 1507, 1512, 366, 65, 362, 358, 354, 152, 1523, 1492, + /* 880 */ 34, 185, 367, 62, 1023, 447, 198, 1120, 1616, 1505, + /* 890 */ 200, 1585, 95, 432, 105, 451, 457, 1505, 206, 1474, + /* 900 */ 1524, 132, 2, 54, 194, 1614, 150, 1076, 107, 285, + /* 910 */ 45, 389, 930, 1523, 925, 71, 1506, 1507, 1512, 1555, + /* 920 */ 447, 1523, 289, 445, 1551, 470, 397, 1067, 447, 958, + /* 930 */ 451, 1505, 899, 105, 1474, 106, 1066, 962, 451, 968, + /* 940 */ 167, 1032, 1474, 392, 246, 266, 248, 215, 386, 322, + /* 950 */ 120, 1506, 1507, 1512, 166, 1523, 1426, 329, 234, 1506, + /* 960 */ 1507, 1512, 447, 149, 107, 122, 1505, 146, 967, 105, + /* 970 */ 139, 342, 451, 108, 337, 1505, 1474, 1089, 336, 343, + /* 980 */ 43, 1088, 338, 42, 144, 145, 346, 345, 436, 1629, + /* 990 */ 1523, 1087, 71, 1506, 1507, 1512, 1555, 447, 347, 1523, + /* 1000 */ 1505, 1552, 148, 52, 350, 151, 447, 451, 1086, 369, + /* 1010 */ 371, 1474, 400, 1336, 415, 374, 451, 402, 399, 75, + /* 1020 */ 1474, 1321, 401, 155, 1523, 1332, 157, 234, 1506, 1507, + /* 1030 */ 1512, 447, 110, 111, 256, 171, 233, 1506, 1507, 1512, + /* 1040 */ 174, 451, 1505, 1334, 1330, 1474, 412, 112, 1505, 113, + /* 1050 */ 1085, 420, 409, 1596, 1505, 455, 1586, 411, 1595, 1061, + /* 1060 */ 5, 120, 1506, 1507, 1512, 184, 1523, 177, 427, 428, + /* 1070 */ 1576, 416, 1523, 447, 417, 125, 186, 4, 1523, 447, + /* 1080 */ 100, 1160, 210, 451, 180, 447, 496, 1474, 1084, 451, + /* 1090 */ 264, 259, 423, 1474, 35, 451, 268, 444, 1570, 1474, + /* 1100 */ 1630, 261, 1505, 234, 1506, 1507, 1512, 441, 498, 234, + /* 1110 */ 1506, 1507, 1512, 1505, 193, 226, 1506, 1507, 1512, 1631, + /* 1120 */ 17, 1537, 1435, 187, 1613, 453, 1523, 495, 494, 493, + /* 1130 */ 454, 492, 1434, 447, 269, 458, 459, 1523, 1505, 460, + /* 1140 */ 202, 204, 216, 451, 447, 59, 1347, 1474, 61, 497, + /* 1150 */ 468, 1319, 218, 212, 451, 545, 220, 222, 1474, 224, + /* 1160 */ 225, 1468, 1523, 232, 1506, 1507, 1512, 1505, 1467, 447, + /* 1170 */ 41, 284, 1505, 286, 235, 1506, 1507, 1512, 1464, 451, + /* 1180 */ 1505, 287, 291, 1474, 1050, 1051, 135, 1462, 293, 294, + /* 1190 */ 295, 1523, 1461, 297, 1460, 299, 1523, 1451, 447, 227, + /* 1200 */ 1506, 1507, 1512, 447, 1523, 136, 302, 303, 451, 1035, + /* 1210 */ 1034, 447, 1474, 451, 1505, 1445, 1444, 1474, 308, 309, + /* 1220 */ 1443, 451, 1442, 1006, 1419, 1474, 1418, 1417, 236, 1506, + /* 1230 */ 1507, 1512, 1416, 228, 1506, 1507, 1512, 1415, 1523, 1414, + /* 1240 */ 1413, 237, 1506, 1507, 1512, 447, 1412, 1411, 1410, 1409, + /* 1250 */ 1505, 1408, 1407, 1406, 1405, 451, 1505, 1404, 1403, 1474, + /* 1260 */ 104, 1402, 1505, 1401, 1400, 1399, 1398, 1008, 1397, 1396, + /* 1270 */ 1395, 1394, 1277, 1459, 1523, 1520, 1506, 1507, 1512, 1453, + /* 1280 */ 1523, 447, 1441, 1432, 147, 1325, 1523, 447, 1276, 866, + /* 1290 */ 1274, 451, 1272, 447, 351, 1474, 352, 451, 353, 1270, + /* 1300 */ 355, 1474, 357, 451, 1505, 359, 1268, 1474, 1257, 1505, + /* 1310 */ 356, 1519, 1506, 1507, 1512, 363, 360, 244, 1506, 1507, + /* 1320 */ 1512, 361, 364, 1518, 1506, 1507, 1512, 365, 1523, 1256, + /* 1330 */ 1253, 1327, 975, 1523, 973, 447, 1326, 1266, 274, 273, + /* 1340 */ 447, 898, 897, 896, 253, 451, 1261, 514, 1069, 1474, + /* 1350 */ 451, 1505, 895, 892, 1474, 891, 254, 1505, 74, 388, + /* 1360 */ 512, 1259, 154, 255, 1062, 245, 1506, 1507, 1512, 1252, + /* 1370 */ 243, 1506, 1507, 1512, 393, 1523, 391, 1251, 395, 72, + /* 1380 */ 1458, 1523, 447, 1061, 168, 1042, 1505, 1452, 447, 403, + /* 1390 */ 1440, 1439, 451, 114, 1431, 55, 1474, 173, 451, 3, + /* 1400 */ 14, 121, 1474, 34, 1492, 15, 39, 57, 178, 189, + /* 1410 */ 1523, 183, 240, 1506, 1507, 1512, 182, 447, 230, 1506, + /* 1420 */ 1507, 1512, 19, 466, 1185, 44, 1178, 451, 123, 404, + /* 1430 */ 175, 1474, 56, 38, 20, 1065, 37, 1157, 1207, 1156, + /* 1440 */ 1206, 131, 16, 1212, 262, 1211, 1210, 231, 1506, 1507, + /* 1450 */ 1512, 263, 8, 1096, 1094, 33, 196, 13, 18, 1430, + /* 1460 */ 197, 1121, 203, 1183, 1071, 469, 199, 201, 1491, 46, + /* 1470 */ 58, 467, 1070, 62, 959, 456, 205, 276, 40, 471, + /* 1480 */ 936, 36, 473, 208, 956, 474, 476, 953, 477, 1073, + /* 1490 */ 947, 10, 479, 945, 480, 482, 483, 951, 63, 970, + /* 1500 */ 950, 966, 47, 64, 489, 964, 864, 501, 905, 949, + /* 1510 */ 499, 211, 887, 886, 885, 948, 884, 883, 882, 881, + /* 1520 */ 880, 902, 900, 877, 876, 875, 872, 871, 870, 869, + /* 1530 */ 969, 1273, 523, 524, 1271, 525, 528, 527, 529, 1269, + /* 1540 */ 531, 532, 1267, 1255, 533, 535, 536, 537, 1254, 539, + /* 1550 */ 540, 1250, 543, 544, 1225, 1058, 548, 219, 547, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 253, 240, 257, 256, 278, 279, 259, 211, 235, 213, - /* 10 */ 218, 237, 12, 13, 269, 270, 262, 212, 257, 246, - /* 20 */ 20, 20, 22, 2, 20, 12, 13, 14, 15, 16, - /* 30 */ 269, 270, 2, 12, 13, 14, 15, 16, 38, 240, - /* 40 */ 248, 236, 12, 13, 14, 15, 16, 293, 243, 20, - /* 50 */ 50, 12, 13, 14, 49, 218, 257, 57, 253, 20, - /* 60 */ 306, 22, 257, 0, 310, 12, 13, 262, 269, 270, - /* 70 */ 218, 1, 2, 20, 74, 22, 218, 38, 273, 274, - /* 80 */ 275, 276, 277, 215, 216, 227, 281, 282, 75, 50, - /* 90 */ 212, 38, 234, 20, 253, 243, 57, 97, 293, 262, - /* 100 */ 259, 243, 0, 50, 12, 13, 14, 15, 16, 109, - /* 110 */ 57, 306, 49, 74, 236, 310, 12, 13, 14, 15, - /* 120 */ 16, 243, 221, 236, 22, 245, 225, 74, 276, 242, - /* 130 */ 293, 253, 252, 253, 247, 257, 97, 285, 286, 287, - /* 140 */ 288, 228, 290, 306, 49, 75, 146, 310, 109, 236, - /* 150 */ 97, 273, 274, 275, 276, 277, 20, 244, 22, 281, - /* 160 */ 282, 283, 109, 163, 164, 165, 166, 167, 168, 169, - /* 170 */ 170, 171, 172, 173, 174, 61, 40, 222, 223, 65, - /* 180 */ 302, 20, 271, 209, 21, 146, 186, 24, 25, 26, - /* 190 */ 27, 28, 29, 30, 31, 32, 14, 15, 16, 146, - /* 200 */ 289, 87, 163, 164, 165, 166, 167, 168, 169, 170, - /* 210 */ 171, 172, 173, 174, 0, 186, 163, 164, 165, 166, - /* 220 */ 167, 168, 169, 170, 171, 172, 173, 174, 0, 12, - /* 230 */ 13, 19, 145, 271, 147, 74, 262, 20, 52, 22, - /* 240 */ 54, 38, 186, 139, 58, 33, 20, 61, 36, 63, - /* 250 */ 64, 289, 66, 236, 42, 38, 44, 45, 46, 47, - /* 260 */ 57, 244, 12, 13, 14, 15, 16, 293, 12, 13, - /* 270 */ 14, 212, 218, 186, 57, 61, 20, 49, 22, 65, - /* 280 */ 306, 227, 12, 13, 310, 73, 220, 20, 76, 20, - /* 290 */ 20, 74, 22, 212, 38, 236, 217, 243, 236, 233, - /* 300 */ 74, 87, 243, 212, 67, 243, 218, 241, 38, 85, - /* 310 */ 231, 207, 253, 57, 97, 227, 257, 238, 106, 71, - /* 320 */ 106, 107, 108, 163, 110, 75, 109, 57, 222, 223, - /* 330 */ 74, 243, 273, 274, 275, 276, 277, 275, 257, 21, - /* 340 */ 281, 282, 283, 0, 74, 0, 134, 186, 257, 137, - /* 350 */ 113, 114, 34, 97, 295, 195, 196, 197, 198, 199, - /* 360 */ 301, 302, 57, 146, 152, 109, 154, 97, 212, 24, - /* 370 */ 25, 26, 27, 28, 29, 30, 31, 32, 237, 109, + /* 0 */ 254, 210, 241, 257, 254, 219, 260, 279, 280, 212, + /* 10 */ 260, 214, 12, 13, 228, 2, 263, 213, 213, 258, + /* 20 */ 20, 235, 22, 2, 20, 12, 13, 14, 15, 16, + /* 30 */ 244, 270, 271, 12, 13, 14, 15, 16, 38, 241, + /* 40 */ 20, 237, 12, 13, 14, 15, 16, 294, 244, 20, + /* 50 */ 50, 12, 13, 14, 263, 0, 258, 57, 254, 20, + /* 60 */ 307, 22, 258, 258, 311, 12, 13, 14, 270, 271, + /* 70 */ 213, 20, 49, 20, 74, 22, 246, 38, 274, 275, + /* 80 */ 276, 277, 278, 253, 254, 294, 282, 283, 284, 50, + /* 90 */ 20, 38, 0, 0, 237, 294, 57, 97, 307, 4, + /* 100 */ 296, 244, 311, 74, 49, 75, 302, 303, 307, 109, + /* 110 */ 57, 254, 311, 74, 49, 258, 24, 25, 26, 27, + /* 120 */ 28, 29, 30, 31, 32, 74, 236, 74, 75, 47, + /* 130 */ 258, 274, 275, 276, 277, 278, 97, 247, 237, 282, + /* 140 */ 283, 284, 270, 271, 243, 52, 146, 54, 109, 248, + /* 150 */ 97, 58, 219, 219, 61, 73, 63, 64, 76, 66, + /* 160 */ 303, 228, 109, 163, 164, 165, 166, 167, 168, 169, + /* 170 */ 170, 171, 172, 173, 174, 175, 219, 244, 12, 13, + /* 180 */ 14, 15, 16, 249, 20, 146, 21, 187, 187, 24, + /* 190 */ 25, 26, 27, 28, 29, 30, 31, 32, 225, 146, + /* 200 */ 227, 244, 163, 164, 165, 166, 167, 168, 169, 170, + /* 210 */ 171, 172, 173, 174, 175, 213, 163, 164, 165, 166, + /* 220 */ 167, 168, 169, 170, 171, 172, 173, 174, 175, 12, + /* 230 */ 13, 145, 222, 147, 277, 20, 226, 20, 187, 22, + /* 240 */ 237, 263, 12, 13, 287, 288, 289, 244, 291, 18, + /* 250 */ 20, 20, 22, 216, 217, 38, 35, 187, 27, 272, + /* 260 */ 258, 30, 12, 13, 14, 15, 16, 50, 38, 20, + /* 270 */ 39, 213, 294, 187, 57, 38, 229, 290, 221, 276, + /* 280 */ 12, 13, 61, 188, 237, 307, 65, 57, 20, 311, + /* 290 */ 22, 74, 245, 61, 57, 237, 218, 65, 77, 242, + /* 300 */ 79, 80, 244, 82, 74, 139, 38, 85, 87, 52, + /* 310 */ 232, 54, 254, 219, 97, 58, 258, 239, 61, 87, + /* 320 */ 63, 64, 228, 66, 221, 57, 109, 97, 164, 165, + /* 330 */ 166, 167, 274, 275, 276, 277, 278, 234, 244, 109, + /* 340 */ 282, 283, 74, 112, 43, 242, 115, 116, 117, 118, + /* 350 */ 119, 57, 121, 122, 123, 124, 125, 126, 127, 128, + /* 360 */ 129, 130, 131, 146, 136, 97, 12, 13, 14, 15, + /* 370 */ 16, 223, 224, 163, 208, 71, 146, 109, 67, 75, /* 380 */ 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, - /* 390 */ 173, 174, 20, 218, 236, 52, 220, 54, 293, 237, - /* 400 */ 242, 58, 146, 186, 61, 247, 63, 64, 212, 66, - /* 410 */ 212, 306, 265, 257, 212, 310, 146, 241, 243, 163, - /* 420 */ 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, - /* 430 */ 174, 164, 165, 163, 164, 165, 166, 167, 168, 169, - /* 440 */ 170, 171, 172, 173, 174, 218, 12, 13, 18, 136, - /* 450 */ 20, 276, 204, 257, 20, 257, 22, 27, 217, 257, - /* 460 */ 30, 286, 287, 288, 243, 290, 20, 4, 262, 39, - /* 470 */ 243, 250, 38, 12, 13, 14, 15, 16, 3, 238, - /* 480 */ 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, - /* 490 */ 98, 57, 100, 101, 102, 103, 104, 105, 0, 293, - /* 500 */ 184, 185, 271, 276, 191, 192, 1, 2, 74, 218, - /* 510 */ 138, 50, 306, 286, 287, 288, 310, 290, 227, 21, - /* 520 */ 289, 212, 24, 25, 26, 27, 28, 29, 30, 31, - /* 530 */ 32, 97, 229, 237, 243, 232, 75, 12, 13, 14, - /* 540 */ 15, 16, 112, 109, 83, 115, 116, 117, 118, 119, - /* 550 */ 212, 121, 122, 123, 124, 125, 126, 127, 128, 129, - /* 560 */ 130, 131, 0, 47, 18, 218, 257, 212, 224, 23, - /* 570 */ 226, 236, 236, 43, 227, 12, 13, 14, 15, 16, - /* 580 */ 146, 35, 247, 247, 138, 14, 237, 237, 212, 73, - /* 590 */ 243, 20, 76, 132, 48, 257, 237, 163, 164, 165, - /* 600 */ 166, 167, 168, 169, 170, 171, 172, 173, 174, 213, - /* 610 */ 212, 150, 257, 50, 52, 53, 54, 55, 56, 212, - /* 620 */ 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - /* 630 */ 68, 69, 70, 257, 212, 212, 175, 176, 177, 178, - /* 640 */ 179, 180, 181, 182, 183, 218, 83, 218, 212, 218, - /* 650 */ 187, 22, 228, 218, 227, 257, 227, 111, 227, 236, - /* 660 */ 236, 234, 227, 138, 257, 228, 243, 38, 244, 0, - /* 670 */ 243, 38, 243, 236, 243, 218, 253, 202, 243, 257, - /* 680 */ 257, 244, 212, 212, 227, 139, 140, 141, 212, 143, - /* 690 */ 57, 22, 218, 257, 148, 132, 273, 274, 275, 276, - /* 700 */ 243, 227, 156, 142, 158, 236, 160, 161, 162, 225, - /* 710 */ 71, 242, 236, 150, 75, 185, 247, 243, 157, 243, - /* 720 */ 78, 22, 218, 81, 212, 212, 212, 257, 257, 253, - /* 730 */ 50, 227, 186, 257, 311, 312, 132, 38, 175, 176, - /* 740 */ 177, 178, 179, 180, 181, 182, 183, 243, 236, 273, - /* 750 */ 274, 275, 276, 277, 150, 243, 57, 281, 282, 283, - /* 760 */ 212, 0, 212, 33, 212, 253, 36, 313, 292, 257, - /* 770 */ 257, 257, 42, 253, 44, 45, 46, 47, 78, 175, - /* 780 */ 78, 81, 304, 81, 236, 273, 274, 275, 276, 277, - /* 790 */ 0, 243, 71, 281, 282, 283, 97, 36, 164, 165, - /* 800 */ 246, 253, 35, 73, 292, 257, 76, 257, 109, 257, - /* 810 */ 212, 78, 22, 71, 81, 71, 71, 75, 253, 75, - /* 820 */ 75, 273, 274, 275, 276, 277, 74, 298, 61, 281, - /* 830 */ 282, 283, 65, 215, 236, 71, 272, 212, 86, 75, - /* 840 */ 292, 243, 291, 163, 77, 146, 79, 80, 38, 82, - /* 850 */ 236, 253, 212, 71, 87, 257, 307, 75, 20, 38, - /* 860 */ 262, 236, 163, 133, 294, 135, 71, 137, 243, 218, - /* 870 */ 75, 273, 274, 275, 276, 36, 236, 71, 253, 212, - /* 880 */ 268, 75, 257, 243, 154, 71, 12, 13, 71, 75, - /* 890 */ 38, 293, 75, 253, 222, 144, 22, 257, 273, 274, - /* 900 */ 275, 276, 277, 236, 306, 218, 281, 282, 310, 263, - /* 910 */ 243, 218, 38, 273, 274, 275, 276, 277, 74, 109, - /* 920 */ 253, 281, 282, 218, 257, 71, 251, 206, 84, 75, - /* 930 */ 109, 57, 71, 71, 71, 120, 75, 75, 75, 132, - /* 940 */ 273, 274, 275, 276, 277, 249, 71, 249, 243, 282, - /* 950 */ 75, 20, 218, 71, 71, 212, 267, 75, 75, 20, - /* 960 */ 220, 243, 261, 20, 254, 218, 220, 262, 220, 220, - /* 970 */ 20, 97, 214, 236, 236, 236, 222, 236, 218, 236, - /* 980 */ 267, 276, 212, 109, 153, 266, 243, 214, 261, 236, - /* 990 */ 212, 286, 287, 288, 217, 290, 253, 217, 293, 236, - /* 1000 */ 257, 236, 236, 260, 236, 236, 236, 236, 20, 254, - /* 1010 */ 194, 306, 303, 243, 236, 310, 273, 274, 275, 276, - /* 1020 */ 146, 243, 243, 253, 243, 193, 57, 257, 272, 257, - /* 1030 */ 260, 253, 258, 258, 212, 257, 201, 163, 303, 189, - /* 1040 */ 257, 257, 200, 273, 274, 275, 276, 188, 243, 20, - /* 1050 */ 300, 273, 274, 275, 276, 296, 299, 185, 236, 297, - /* 1060 */ 271, 120, 205, 208, 74, 243, 258, 280, 212, 284, - /* 1070 */ 203, 258, 135, 255, 74, 253, 212, 257, 254, 257, - /* 1080 */ 257, 212, 257, 305, 243, 217, 243, 239, 217, 210, - /* 1090 */ 314, 226, 236, 217, 308, 273, 274, 275, 276, 243, - /* 1100 */ 236, 309, 232, 222, 218, 236, 214, 243, 230, 253, - /* 1110 */ 264, 0, 243, 257, 230, 219, 260, 253, 0, 64, - /* 1120 */ 0, 257, 253, 212, 260, 38, 257, 38, 212, 273, - /* 1130 */ 274, 275, 276, 4, 312, 159, 212, 273, 274, 275, - /* 1140 */ 276, 38, 273, 274, 275, 276, 159, 236, 19, 0, - /* 1150 */ 38, 159, 236, 38, 243, 38, 0, 38, 0, 243, - /* 1160 */ 236, 38, 33, 0, 253, 36, 74, 243, 257, 253, - /* 1170 */ 41, 150, 149, 257, 0, 0, 47, 253, 109, 146, - /* 1180 */ 212, 257, 0, 53, 273, 274, 275, 276, 142, 273, - /* 1190 */ 274, 275, 276, 0, 0, 212, 86, 273, 274, 275, - /* 1200 */ 276, 0, 73, 0, 236, 76, 212, 0, 0, 0, - /* 1210 */ 0, 243, 0, 0, 0, 0, 0, 0, 0, 236, - /* 1220 */ 0, 253, 0, 0, 120, 257, 243, 0, 0, 0, - /* 1230 */ 236, 212, 0, 0, 0, 61, 253, 243, 0, 65, - /* 1240 */ 257, 273, 274, 275, 276, 0, 22, 253, 0, 0, - /* 1250 */ 0, 257, 0, 0, 0, 236, 273, 274, 275, 276, - /* 1260 */ 0, 87, 243, 0, 43, 212, 0, 273, 274, 275, - /* 1270 */ 276, 0, 253, 38, 43, 36, 257, 51, 212, 0, - /* 1280 */ 106, 107, 108, 43, 110, 38, 0, 36, 0, 236, - /* 1290 */ 0, 36, 273, 274, 275, 276, 243, 38, 0, 43, - /* 1300 */ 38, 36, 236, 0, 43, 0, 253, 38, 83, 243, - /* 1310 */ 257, 81, 212, 71, 22, 0, 38, 71, 38, 253, - /* 1320 */ 212, 38, 38, 257, 0, 212, 273, 274, 275, 276, - /* 1330 */ 22, 38, 38, 0, 22, 39, 236, 0, 22, 273, - /* 1340 */ 274, 275, 276, 243, 236, 38, 0, 22, 0, 236, - /* 1350 */ 22, 243, 20, 253, 0, 155, 243, 257, 38, 0, - /* 1360 */ 22, 253, 151, 0, 0, 257, 253, 212, 0, 74, - /* 1370 */ 257, 135, 212, 273, 274, 275, 276, 43, 190, 138, - /* 1380 */ 71, 273, 274, 275, 276, 71, 273, 274, 275, 276, - /* 1390 */ 71, 236, 75, 75, 190, 138, 236, 74, 243, 86, - /* 1400 */ 133, 74, 138, 243, 74, 4, 75, 71, 253, 74, - /* 1410 */ 71, 38, 257, 253, 71, 75, 75, 257, 71, 75, - /* 1420 */ 38, 184, 38, 38, 38, 38, 2, 74, 273, 274, - /* 1430 */ 275, 276, 75, 273, 274, 275, 276, 86, 86, 163, - /* 1440 */ 75, 86, 75, 74, 0, 75, 74, 136, 190, 74, - /* 1450 */ 74, 43, 74, 22, 133, 84, 75, 74, 38, 38, - /* 1460 */ 86, 38, 74, 86, 85, 75, 74, 38, 75, 74, - /* 1470 */ 38, 75, 74, 38, 75, 22, 74, 74, 38, 99, - /* 1480 */ 74, 74, 22, 38, 87, 51, 50, 57, 99, 72, - /* 1490 */ 99, 22, 38, 99, 38, 38, 71, 38, 57, 38, - /* 1500 */ 38, 38, 38, 38, 38, 38, 38, 0, 38, 109, - /* 1510 */ 38, 38, 38, 36, 43, 0, 38, 36, 43, 0, - /* 1520 */ 38, 36, 43, 0, 38, 36, 43, 0, 38, 37, - /* 1530 */ 0, 0, 22, 21, 315, 22, 22, 21, 20, 315, - /* 1540 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1550 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1560 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1570 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1580 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1590 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1600 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1610 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1620 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1630 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1640 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1650 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1660 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1670 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1680 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1690 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1700 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1710 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1720 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1730 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1740 */ 315, 315, 315, 315, 315, 315, 315, 315, + /* 390 */ 173, 174, 175, 163, 164, 165, 166, 167, 168, 169, + /* 400 */ 170, 171, 172, 173, 174, 175, 196, 197, 198, 199, + /* 410 */ 200, 14, 15, 16, 146, 237, 237, 187, 12, 13, + /* 420 */ 192, 193, 243, 245, 113, 114, 20, 248, 22, 75, + /* 430 */ 218, 163, 164, 165, 166, 167, 168, 169, 170, 171, + /* 440 */ 172, 173, 174, 175, 38, 12, 13, 14, 15, 16, + /* 450 */ 20, 239, 88, 89, 90, 91, 92, 93, 94, 95, + /* 460 */ 96, 97, 98, 57, 100, 101, 102, 103, 104, 105, + /* 470 */ 12, 13, 14, 15, 16, 223, 224, 238, 237, 22, + /* 480 */ 74, 0, 219, 50, 219, 219, 213, 186, 219, 248, + /* 490 */ 237, 228, 244, 228, 228, 38, 229, 228, 235, 251, + /* 500 */ 18, 248, 219, 97, 237, 23, 0, 244, 75, 244, + /* 510 */ 244, 228, 245, 244, 57, 109, 83, 35, 20, 213, + /* 520 */ 22, 12, 13, 14, 15, 16, 230, 244, 238, 233, + /* 530 */ 48, 258, 219, 52, 53, 54, 55, 56, 40, 58, + /* 540 */ 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + /* 550 */ 69, 70, 146, 213, 97, 49, 237, 244, 238, 50, + /* 560 */ 3, 213, 243, 213, 258, 132, 109, 248, 138, 163, + /* 570 */ 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, + /* 580 */ 174, 175, 219, 150, 238, 219, 71, 1, 2, 229, + /* 590 */ 277, 228, 83, 111, 213, 238, 138, 237, 258, 286, + /* 600 */ 287, 288, 289, 146, 291, 245, 258, 244, 258, 176, + /* 610 */ 177, 178, 179, 180, 181, 182, 183, 184, 213, 266, + /* 620 */ 163, 139, 140, 141, 0, 143, 213, 213, 238, 263, + /* 630 */ 148, 20, 0, 213, 213, 213, 213, 219, 156, 258, + /* 640 */ 158, 132, 160, 161, 162, 21, 228, 272, 24, 25, + /* 650 */ 26, 27, 28, 29, 30, 31, 32, 237, 272, 150, + /* 660 */ 294, 75, 244, 258, 244, 290, 213, 213, 36, 187, + /* 670 */ 238, 258, 258, 307, 254, 213, 290, 311, 258, 258, + /* 680 */ 258, 258, 132, 263, 219, 176, 177, 178, 179, 180, + /* 690 */ 181, 182, 183, 184, 274, 275, 276, 277, 278, 237, + /* 700 */ 150, 214, 282, 283, 219, 213, 244, 19, 0, 244, + /* 710 */ 71, 258, 258, 228, 294, 71, 254, 213, 213, 75, + /* 720 */ 258, 33, 207, 213, 36, 213, 176, 307, 263, 244, + /* 730 */ 42, 311, 44, 45, 46, 47, 274, 275, 276, 277, + /* 740 */ 278, 237, 277, 71, 282, 283, 284, 75, 244, 138, + /* 750 */ 258, 22, 287, 288, 289, 293, 291, 226, 254, 294, + /* 760 */ 203, 73, 258, 258, 76, 213, 219, 38, 258, 61, + /* 770 */ 258, 14, 307, 65, 50, 228, 311, 20, 274, 275, + /* 780 */ 276, 277, 278, 185, 186, 142, 282, 283, 284, 237, + /* 790 */ 78, 244, 219, 81, 106, 87, 244, 293, 0, 78, + /* 800 */ 157, 0, 81, 1, 2, 78, 254, 213, 81, 78, + /* 810 */ 258, 0, 81, 38, 106, 107, 108, 244, 110, 305, + /* 820 */ 22, 314, 134, 22, 21, 137, 274, 275, 276, 277, + /* 830 */ 278, 237, 57, 22, 282, 283, 284, 34, 244, 71, + /* 840 */ 152, 254, 154, 75, 205, 293, 164, 165, 254, 71, + /* 850 */ 277, 71, 258, 75, 213, 75, 38, 263, 254, 247, + /* 860 */ 287, 288, 289, 33, 291, 38, 36, 74, 274, 275, + /* 870 */ 276, 277, 42, 74, 44, 45, 46, 47, 237, 86, + /* 880 */ 71, 299, 216, 84, 75, 244, 71, 163, 294, 213, + /* 890 */ 75, 273, 71, 292, 71, 254, 75, 213, 75, 258, + /* 900 */ 237, 307, 295, 73, 308, 311, 76, 20, 71, 219, + /* 910 */ 71, 4, 75, 237, 75, 274, 275, 276, 277, 278, + /* 920 */ 244, 237, 36, 282, 283, 71, 19, 109, 244, 75, + /* 930 */ 254, 213, 38, 71, 258, 71, 109, 75, 254, 75, + /* 940 */ 33, 144, 258, 36, 269, 261, 223, 264, 41, 219, + /* 950 */ 274, 275, 276, 277, 47, 237, 219, 252, 274, 275, + /* 960 */ 276, 277, 244, 133, 71, 135, 213, 137, 75, 71, + /* 970 */ 120, 219, 254, 75, 132, 213, 258, 20, 250, 268, + /* 980 */ 73, 20, 250, 76, 154, 221, 244, 262, 312, 313, + /* 990 */ 237, 20, 274, 275, 276, 277, 278, 244, 255, 237, + /* 1000 */ 213, 283, 221, 221, 219, 221, 244, 254, 20, 215, + /* 1010 */ 237, 258, 268, 237, 261, 223, 254, 267, 244, 219, + /* 1020 */ 258, 0, 153, 237, 237, 237, 237, 274, 275, 276, + /* 1030 */ 277, 244, 237, 237, 215, 218, 274, 275, 276, 277, + /* 1040 */ 218, 254, 213, 237, 237, 258, 255, 237, 213, 237, + /* 1050 */ 20, 195, 262, 304, 213, 194, 273, 244, 304, 57, + /* 1060 */ 202, 274, 275, 276, 277, 300, 237, 259, 306, 201, + /* 1070 */ 301, 190, 237, 244, 258, 298, 297, 189, 237, 244, + /* 1080 */ 244, 186, 61, 254, 259, 244, 65, 258, 20, 254, + /* 1090 */ 261, 258, 258, 258, 120, 254, 261, 206, 272, 258, + /* 1100 */ 313, 209, 213, 274, 275, 276, 277, 204, 87, 274, + /* 1110 */ 275, 276, 277, 213, 309, 274, 275, 276, 277, 315, + /* 1120 */ 74, 281, 259, 285, 310, 258, 237, 106, 107, 108, + /* 1130 */ 258, 110, 259, 244, 258, 135, 256, 237, 213, 255, + /* 1140 */ 244, 218, 233, 254, 244, 218, 244, 258, 74, 223, + /* 1150 */ 240, 227, 219, 218, 254, 215, 220, 211, 258, 231, + /* 1160 */ 231, 0, 237, 274, 275, 276, 277, 213, 0, 244, + /* 1170 */ 265, 64, 213, 38, 274, 275, 276, 277, 0, 254, + /* 1180 */ 213, 159, 159, 258, 38, 38, 38, 0, 38, 38, + /* 1190 */ 159, 237, 0, 38, 0, 38, 237, 0, 244, 274, + /* 1200 */ 275, 276, 277, 244, 237, 74, 150, 149, 254, 109, + /* 1210 */ 146, 244, 258, 254, 213, 0, 0, 258, 53, 142, + /* 1220 */ 0, 254, 0, 86, 0, 258, 0, 0, 274, 275, + /* 1230 */ 276, 277, 0, 274, 275, 276, 277, 0, 237, 0, + /* 1240 */ 0, 274, 275, 276, 277, 244, 0, 0, 0, 0, + /* 1250 */ 213, 0, 0, 0, 0, 254, 213, 0, 0, 258, + /* 1260 */ 120, 0, 213, 0, 0, 0, 0, 22, 0, 0, + /* 1270 */ 0, 0, 0, 0, 237, 274, 275, 276, 277, 0, + /* 1280 */ 237, 244, 0, 0, 43, 0, 237, 244, 0, 51, + /* 1290 */ 0, 254, 0, 244, 38, 258, 36, 254, 43, 0, + /* 1300 */ 38, 258, 43, 254, 213, 38, 0, 258, 0, 213, + /* 1310 */ 36, 274, 275, 276, 277, 38, 36, 274, 275, 276, + /* 1320 */ 277, 43, 36, 274, 275, 276, 277, 43, 237, 0, + /* 1330 */ 0, 0, 38, 237, 22, 244, 0, 0, 12, 13, + /* 1340 */ 244, 38, 38, 38, 22, 254, 0, 71, 22, 258, + /* 1350 */ 254, 213, 38, 38, 258, 38, 22, 213, 83, 39, + /* 1360 */ 71, 0, 81, 22, 38, 274, 275, 276, 277, 0, + /* 1370 */ 274, 275, 276, 277, 22, 237, 38, 0, 22, 20, + /* 1380 */ 0, 237, 244, 57, 155, 38, 213, 0, 244, 22, + /* 1390 */ 0, 0, 254, 151, 0, 74, 258, 43, 254, 71, + /* 1400 */ 191, 74, 258, 71, 86, 191, 71, 4, 75, 86, + /* 1410 */ 237, 71, 274, 275, 276, 277, 74, 244, 274, 275, + /* 1420 */ 276, 277, 74, 97, 75, 138, 75, 254, 135, 138, + /* 1430 */ 133, 258, 74, 138, 71, 109, 71, 75, 38, 75, + /* 1440 */ 38, 86, 71, 75, 38, 38, 38, 274, 275, 276, + /* 1450 */ 277, 38, 2, 75, 75, 74, 86, 74, 74, 0, + /* 1460 */ 75, 163, 43, 75, 22, 38, 74, 74, 86, 74, + /* 1470 */ 74, 85, 146, 84, 75, 136, 133, 38, 74, 74, + /* 1480 */ 22, 185, 38, 86, 75, 74, 38, 75, 74, 163, + /* 1490 */ 75, 191, 38, 75, 74, 38, 74, 99, 74, 38, + /* 1500 */ 99, 38, 74, 74, 87, 22, 51, 72, 57, 99, + /* 1510 */ 50, 71, 38, 38, 38, 99, 38, 38, 38, 38, + /* 1520 */ 22, 57, 38, 38, 38, 38, 38, 38, 38, 38, + /* 1530 */ 109, 0, 38, 36, 0, 43, 36, 38, 43, 0, + /* 1540 */ 38, 36, 0, 0, 43, 38, 36, 43, 0, 38, + /* 1550 */ 37, 0, 22, 21, 316, 22, 20, 22, 21, 316, + /* 1560 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1570 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1580 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1590 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1600 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1610 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1620 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1630 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1640 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1650 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1660 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1670 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1680 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1690 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1700 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1710 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1720 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1730 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1740 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1750 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + /* 1760 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, }; -#define YY_SHIFT_COUNT (547) +#define YY_SHIFT_COUNT (549) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1531) +#define YY_SHIFT_MAX (1551) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 546, 0, 39, 53, 53, 53, 53, 217, 53, 53, - /* 10 */ 270, 434, 161, 256, 270, 270, 270, 270, 270, 270, - /* 20 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 30 */ 270, 270, 270, 270, 226, 226, 226, 29, 874, 874, - /* 40 */ 87, 1, 1, 56, 874, 267, 267, 1, 1, 1, - /* 50 */ 1, 1, 1, 5, 4, 73, 56, 4, 1, 1, - /* 60 */ 4, 1, 4, 4, 4, 1, 95, 430, 461, 563, - /* 70 */ 563, 163, 767, 699, 186, 699, 699, 699, 699, 699, - /* 80 */ 699, 699, 699, 699, 699, 699, 699, 699, 699, 699, - /* 90 */ 699, 699, 699, 699, 267, 136, 63, 203, 372, 372, - /* 100 */ 372, 228, 203, 269, 4, 4, 4, 224, 305, 392, - /* 110 */ 392, 392, 392, 392, 392, 392, 212, 498, 343, 104, - /* 120 */ 160, 267, 114, 267, 313, 629, 446, 316, 530, 316, - /* 130 */ 571, 475, 463, 838, 839, 852, 751, 838, 838, 815, - /* 140 */ 807, 807, 838, 931, 939, 5, 269, 943, 5, 5, - /* 150 */ 838, 5, 950, 4, 4, 4, 4, 4, 4, 4, - /* 160 */ 4, 4, 4, 4, 852, 838, 950, 269, 931, 831, - /* 170 */ 939, 95, 269, 943, 95, 988, 816, 832, 969, 816, - /* 180 */ 832, 969, 969, 835, 842, 850, 859, 872, 269, 1029, - /* 190 */ 941, 855, 857, 867, 990, 4, 832, 969, 969, 832, - /* 200 */ 969, 937, 269, 943, 95, 224, 95, 269, 1000, 852, - /* 210 */ 305, 838, 95, 950, 1539, 1539, 1539, 1539, 1539, 562, - /* 220 */ 730, 345, 1129, 214, 1174, 13, 21, 30, 250, 525, - /* 230 */ 92, 92, 92, 92, 92, 92, 92, 516, 237, 182, - /* 240 */ 70, 604, 182, 182, 182, 761, 561, 639, 642, 700, - /* 250 */ 702, 733, 102, 669, 790, 318, 742, 744, 745, 505, - /* 260 */ 634, 248, 721, 764, 680, 782, 752, 795, 806, 814, - /* 270 */ 817, 854, 810, 821, 861, 862, 863, 875, 882, 883, - /* 280 */ 844, 633, 1111, 1118, 1055, 1120, 1087, 976, 1089, 1103, - /* 290 */ 1112, 987, 1149, 1115, 1117, 992, 1156, 1119, 1158, 1123, - /* 300 */ 1163, 1092, 1021, 1023, 1069, 1033, 1175, 1182, 1130, 1046, - /* 310 */ 1193, 1194, 1110, 1201, 1203, 1207, 1208, 1209, 1210, 1212, - /* 320 */ 1213, 1214, 1215, 1216, 1217, 1218, 1220, 1222, 1223, 1104, - /* 330 */ 1227, 1228, 1229, 1232, 1233, 1234, 1224, 1238, 1245, 1248, - /* 340 */ 1249, 1250, 1252, 1253, 1254, 1260, 1221, 1263, 1226, 1266, - /* 350 */ 1271, 1235, 1239, 1231, 1279, 1247, 1251, 1240, 1286, 1259, - /* 360 */ 1255, 1256, 1288, 1262, 1265, 1261, 1290, 1298, 1303, 1305, - /* 370 */ 1225, 1230, 1269, 1242, 1292, 1315, 1278, 1280, 1283, 1284, - /* 380 */ 1246, 1242, 1293, 1294, 1324, 1308, 1333, 1312, 1296, 1337, - /* 390 */ 1316, 1307, 1346, 1325, 1348, 1328, 1332, 1354, 1241, 1200, - /* 400 */ 1320, 1359, 1211, 1338, 1257, 1236, 1363, 1364, 1264, 1368, - /* 410 */ 1295, 1334, 1267, 1309, 1314, 1188, 1317, 1319, 1318, 1323, - /* 420 */ 1327, 1330, 1331, 1336, 1313, 1335, 1339, 1204, 1340, 1341, - /* 430 */ 1351, 1237, 1343, 1352, 1344, 1347, 1258, 1401, 1373, 1382, - /* 440 */ 1384, 1385, 1386, 1387, 1424, 1276, 1355, 1357, 1365, 1353, - /* 450 */ 1369, 1367, 1370, 1372, 1375, 1311, 1376, 1444, 1408, 1321, - /* 460 */ 1378, 1371, 1374, 1377, 1431, 1383, 1379, 1381, 1420, 1421, - /* 470 */ 1388, 1390, 1423, 1392, 1393, 1429, 1395, 1396, 1432, 1398, - /* 480 */ 1399, 1435, 1402, 1380, 1389, 1391, 1394, 1453, 1397, 1403, - /* 490 */ 1440, 1400, 1406, 1407, 1445, 1242, 1460, 1434, 1436, 1430, - /* 500 */ 1417, 1425, 1454, 1456, 1457, 1459, 1461, 1462, 1463, 1469, - /* 510 */ 1441, 1246, 1464, 1242, 1465, 1466, 1467, 1468, 1470, 1472, - /* 520 */ 1473, 1507, 1474, 1477, 1471, 1515, 1478, 1481, 1475, 1519, - /* 530 */ 1482, 1485, 1479, 1523, 1486, 1489, 1483, 1527, 1490, 1492, - /* 540 */ 1530, 1531, 1510, 1512, 1513, 1514, 1516, 1518, + /* 0 */ 482, 0, 39, 217, 217, 217, 217, 230, 217, 217, + /* 10 */ 268, 406, 51, 53, 268, 268, 268, 268, 268, 268, + /* 20 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 30 */ 268, 268, 268, 268, 268, 29, 29, 29, 70, 1326, + /* 40 */ 1326, 86, 4, 4, 1, 1326, 164, 164, 4, 4, + /* 50 */ 4, 4, 4, 4, 23, 20, 215, 1, 20, 4, + /* 60 */ 4, 20, 4, 20, 20, 20, 4, 65, 231, 433, + /* 70 */ 509, 509, 165, 221, 457, 257, 457, 457, 457, 457, + /* 80 */ 457, 457, 457, 457, 457, 457, 457, 457, 457, 457, + /* 90 */ 457, 457, 457, 457, 457, 164, 498, 55, 237, 430, + /* 100 */ 430, 430, 506, 237, 249, 20, 20, 20, 222, 294, + /* 110 */ 364, 364, 364, 364, 364, 364, 364, 688, 624, 93, + /* 120 */ 166, 210, 164, 164, 232, 228, 729, 611, 598, 301, + /* 130 */ 598, 757, 557, 95, 887, 886, 894, 797, 887, 887, + /* 140 */ 850, 842, 842, 887, 957, 961, 23, 249, 971, 23, + /* 150 */ 23, 887, 23, 988, 20, 20, 20, 20, 20, 20, + /* 160 */ 20, 20, 20, 20, 20, 894, 887, 988, 249, 957, + /* 170 */ 869, 961, 65, 249, 971, 65, 1030, 856, 861, 1002, + /* 180 */ 856, 861, 1002, 1002, 858, 868, 881, 888, 895, 249, + /* 190 */ 1068, 974, 892, 891, 903, 1046, 20, 861, 1002, 1002, + /* 200 */ 861, 1002, 1000, 249, 971, 65, 222, 65, 249, 1074, + /* 210 */ 894, 294, 887, 65, 988, 1559, 1559, 1559, 1559, 1559, + /* 220 */ 481, 830, 92, 907, 708, 1021, 354, 13, 21, 30, + /* 230 */ 458, 250, 250, 250, 250, 250, 250, 250, 82, 311, + /* 240 */ 397, 586, 550, 397, 397, 397, 632, 643, 304, 712, + /* 250 */ 721, 727, 731, 798, 801, 811, 803, 644, 672, 768, + /* 260 */ 802, 682, 639, 515, 778, 724, 780, 793, 809, 815, + /* 270 */ 821, 823, 837, 818, 827, 839, 854, 862, 864, 893, + /* 280 */ 898, 799, 775, 1161, 1168, 1107, 1178, 1135, 1022, 1146, + /* 290 */ 1147, 1148, 1023, 1187, 1150, 1151, 1031, 1192, 1155, 1194, + /* 300 */ 1157, 1197, 1131, 1056, 1058, 1100, 1064, 1215, 1216, 1165, + /* 310 */ 1077, 1220, 1222, 1137, 1224, 1226, 1227, 1232, 1237, 1239, + /* 320 */ 1240, 1246, 1247, 1248, 1249, 1251, 1252, 1253, 1254, 1257, + /* 330 */ 1140, 1258, 1261, 1263, 1264, 1265, 1266, 1245, 1268, 1269, + /* 340 */ 1270, 1271, 1272, 1273, 1279, 1282, 1283, 1241, 1285, 1238, + /* 350 */ 1288, 1290, 1256, 1260, 1255, 1292, 1262, 1274, 1259, 1299, + /* 360 */ 1267, 1280, 1278, 1306, 1277, 1286, 1284, 1308, 1329, 1330, + /* 370 */ 1331, 1275, 1281, 1294, 1276, 1312, 1336, 1303, 1304, 1305, + /* 380 */ 1314, 1289, 1276, 1315, 1317, 1337, 1322, 1346, 1334, 1320, + /* 390 */ 1361, 1341, 1338, 1369, 1352, 1377, 1356, 1359, 1380, 1287, + /* 400 */ 1229, 1347, 1387, 1242, 1367, 1291, 1293, 1390, 1391, 1295, + /* 410 */ 1394, 1321, 1354, 1297, 1328, 1332, 1209, 1333, 1335, 1349, + /* 420 */ 1327, 1342, 1348, 1351, 1340, 1318, 1358, 1363, 1214, 1362, + /* 430 */ 1364, 1323, 1296, 1365, 1355, 1368, 1371, 1300, 1403, 1400, + /* 440 */ 1402, 1406, 1407, 1408, 1413, 1450, 1298, 1370, 1378, 1381, + /* 450 */ 1379, 1383, 1384, 1385, 1388, 1392, 1393, 1339, 1395, 1459, + /* 460 */ 1419, 1343, 1396, 1389, 1382, 1397, 1442, 1404, 1386, 1399, + /* 470 */ 1427, 1439, 1405, 1409, 1444, 1411, 1412, 1448, 1414, 1415, + /* 480 */ 1454, 1420, 1418, 1457, 1422, 1398, 1401, 1410, 1416, 1458, + /* 490 */ 1417, 1424, 1461, 1421, 1428, 1429, 1463, 1276, 1483, 1455, + /* 500 */ 1460, 1451, 1435, 1440, 1474, 1475, 1476, 1478, 1479, 1480, + /* 510 */ 1481, 1498, 1464, 1289, 1484, 1276, 1485, 1486, 1487, 1488, + /* 520 */ 1489, 1490, 1491, 1531, 1494, 1497, 1492, 1534, 1499, 1500, + /* 530 */ 1495, 1539, 1502, 1505, 1501, 1542, 1507, 1510, 1504, 1543, + /* 540 */ 1511, 1513, 1548, 1551, 1530, 1532, 1533, 1535, 1537, 1536, }; -#define YY_REDUCE_COUNT (218) -#define YY_REDUCE_MIN (-274) -#define YY_REDUCE_MAX (1160) +#define YY_REDUCE_COUNT (219) +#define YY_REDUCE_MIN (-272) +#define YY_REDUCE_MAX (1173) static const short yy_reduce_ofst[] = { - /* 0 */ -26, -195, 59, -122, 476, 512, 548, 598, 625, 640, - /* 10 */ 423, 667, 705, 743, 770, 778, 822, 856, 864, 869, - /* 20 */ 911, 916, 924, 968, 983, 994, 1019, 1053, 1066, 1100, - /* 30 */ 1108, 1113, 1155, 1160, -148, 175, 227, -163, -239, -201, - /* 40 */ -246, -142, 427, 206, -255, -253, -120, 54, 88, 291, - /* 50 */ 347, 429, 431, 66, -113, 62, 105, -87, 435, 457, - /* 60 */ 158, 474, 424, 469, 437, 504, 79, -208, -274, -274, - /* 70 */ -274, -204, -227, 81, -99, 91, 156, 196, 198, 202, - /* 80 */ 309, 338, 355, 376, 398, 407, 422, 436, 470, 471, - /* 90 */ 513, 514, 550, 552, -159, -132, 176, -45, -89, -38, - /* 100 */ 231, 241, 106, 221, 17, 335, 336, 303, 344, -226, - /* 110 */ 141, 162, 296, 349, 350, 359, 147, 396, 484, 454, - /* 120 */ 478, 520, 554, 565, 529, 618, 564, 551, 551, 551, - /* 130 */ 614, 549, 570, 651, 612, 672, 646, 687, 693, 675, - /* 140 */ 696, 698, 734, 689, 701, 740, 718, 710, 746, 748, - /* 150 */ 747, 749, 758, 737, 738, 739, 741, 753, 763, 765, - /* 160 */ 766, 768, 769, 771, 754, 760, 773, 779, 713, 719, - /* 170 */ 727, 777, 781, 755, 780, 756, 709, 774, 772, 735, - /* 180 */ 775, 783, 784, 750, 757, 762, 759, 551, 805, 789, - /* 190 */ 785, 776, 792, 786, 787, 614, 808, 820, 823, 813, - /* 200 */ 825, 818, 841, 824, 868, 870, 871, 843, 848, 881, - /* 210 */ 865, 886, 876, 892, 846, 878, 884, 896, 879, + /* 0 */ -209, 420, -196, -143, 462, 504, 552, 594, 58, 641, + /* 10 */ 676, 718, 465, 684, 753, 762, 787, 829, 835, 841, + /* 20 */ 889, 900, 925, 954, 959, 967, 1001, 1037, 1043, 1049, + /* 30 */ 1091, 1096, 1138, 1144, 1173, 313, -43, 573, 366, -239, + /* 40 */ -202, -247, -214, 263, -22, -128, -254, -170, -67, 94, + /* 50 */ 265, 266, 269, 283, 103, -99, 3, -199, 47, 363, + /* 60 */ 418, 179, 485, 267, 319, 360, 547, 78, -66, -272, + /* 70 */ -272, -272, -203, -110, -195, 10, 2, 273, 306, 340, + /* 80 */ 348, 350, 381, 405, 413, 414, 421, 422, 423, 453, + /* 90 */ 454, 492, 505, 510, 512, -250, 37, 57, 148, -13, + /* 100 */ 375, 386, 212, 252, 248, 178, 241, 253, 296, -27, + /* 110 */ 239, 290, 320, 346, 357, 390, 432, 353, 487, 531, + /* 120 */ 507, 514, 587, 604, 612, 582, 666, 618, 601, 601, + /* 130 */ 601, 663, 596, 607, 690, 675, 723, 683, 730, 737, + /* 140 */ 705, 728, 732, 752, 711, 725, 764, 742, 743, 781, + /* 150 */ 782, 785, 784, 794, 773, 776, 786, 788, 789, 795, + /* 160 */ 796, 806, 807, 810, 812, 792, 800, 819, 774, 744, + /* 170 */ 750, 790, 817, 813, 791, 822, 783, 749, 808, 816, + /* 180 */ 754, 825, 833, 834, 769, 765, 777, 779, 601, 836, + /* 190 */ 826, 838, 804, 814, 805, 840, 663, 863, 867, 872, + /* 200 */ 873, 876, 880, 896, 884, 923, 909, 927, 902, 910, + /* 210 */ 926, 924, 933, 935, 940, 905, 928, 929, 936, 946, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 10 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 20 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 30 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 40 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 50 */ 1219, 1219, 1219, 1278, 1219, 1219, 1219, 1219, 1219, 1219, - /* 60 */ 1219, 1219, 1219, 1219, 1219, 1219, 1276, 1416, 1219, 1552, - /* 70 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 80 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 90 */ 1219, 1219, 1219, 1219, 1219, 1219, 1278, 1219, 1563, 1563, - /* 100 */ 1563, 1276, 1219, 1219, 1219, 1219, 1219, 1371, 1219, 1219, - /* 110 */ 1219, 1219, 1219, 1219, 1219, 1219, 1450, 1219, 1219, 1627, - /* 120 */ 1219, 1219, 1324, 1219, 1587, 1219, 1579, 1555, 1569, 1556, - /* 130 */ 1219, 1612, 1572, 1219, 1219, 1219, 1442, 1219, 1219, 1421, - /* 140 */ 1418, 1418, 1219, 1219, 1219, 1278, 1219, 1219, 1278, 1278, - /* 150 */ 1219, 1278, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 160 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1452, - /* 170 */ 1219, 1276, 1219, 1219, 1276, 1219, 1594, 1592, 1219, 1594, - /* 180 */ 1592, 1219, 1219, 1606, 1602, 1585, 1583, 1569, 1219, 1219, - /* 190 */ 1219, 1630, 1618, 1614, 1219, 1219, 1592, 1219, 1219, 1592, - /* 200 */ 1219, 1429, 1219, 1219, 1276, 1219, 1276, 1219, 1340, 1219, - /* 210 */ 1219, 1219, 1276, 1219, 1444, 1374, 1374, 1279, 1224, 1219, - /* 220 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1514, - /* 230 */ 1515, 1605, 1604, 1514, 1529, 1528, 1527, 1219, 1219, 1509, - /* 240 */ 1219, 1219, 1510, 1508, 1507, 1219, 1219, 1219, 1219, 1219, - /* 250 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1553, - /* 260 */ 1219, 1615, 1619, 1219, 1219, 1219, 1489, 1219, 1219, 1219, - /* 270 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 280 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 290 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 300 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 310 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 320 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 330 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 340 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 350 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 360 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 370 */ 1219, 1219, 1219, 1385, 1219, 1219, 1219, 1219, 1219, 1219, - /* 380 */ 1305, 1304, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 390 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 400 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 410 */ 1219, 1219, 1219, 1576, 1586, 1219, 1219, 1219, 1219, 1219, - /* 420 */ 1219, 1219, 1219, 1219, 1489, 1219, 1603, 1219, 1562, 1558, - /* 430 */ 1219, 1219, 1554, 1219, 1219, 1613, 1219, 1219, 1219, 1219, - /* 440 */ 1219, 1219, 1219, 1219, 1548, 1219, 1219, 1219, 1219, 1219, - /* 450 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 460 */ 1219, 1219, 1488, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 470 */ 1368, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 480 */ 1219, 1219, 1219, 1353, 1351, 1350, 1349, 1219, 1346, 1219, - /* 490 */ 1219, 1219, 1219, 1219, 1219, 1376, 1219, 1219, 1219, 1219, - /* 500 */ 1219, 1299, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 510 */ 1219, 1290, 1219, 1289, 1219, 1219, 1219, 1219, 1219, 1219, - /* 520 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 530 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 540 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, + /* 0 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 10 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 20 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 30 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 40 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 50 */ 1223, 1223, 1223, 1223, 1282, 1223, 1223, 1223, 1223, 1223, + /* 60 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1280, 1420, 1223, + /* 70 */ 1557, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 80 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 90 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1282, 1223, 1568, + /* 100 */ 1568, 1568, 1280, 1223, 1223, 1223, 1223, 1223, 1375, 1223, + /* 110 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1454, 1223, 1223, + /* 120 */ 1632, 1223, 1223, 1223, 1328, 1592, 1223, 1584, 1560, 1574, + /* 130 */ 1561, 1223, 1617, 1577, 1223, 1223, 1223, 1446, 1223, 1223, + /* 140 */ 1425, 1422, 1422, 1223, 1223, 1223, 1282, 1223, 1223, 1282, + /* 150 */ 1282, 1223, 1282, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 160 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 170 */ 1456, 1223, 1280, 1223, 1223, 1280, 1223, 1599, 1597, 1223, + /* 180 */ 1599, 1597, 1223, 1223, 1611, 1607, 1590, 1588, 1574, 1223, + /* 190 */ 1223, 1223, 1635, 1623, 1619, 1223, 1223, 1597, 1223, 1223, + /* 200 */ 1597, 1223, 1433, 1223, 1223, 1280, 1223, 1280, 1223, 1344, + /* 210 */ 1223, 1223, 1223, 1280, 1223, 1448, 1378, 1378, 1283, 1228, + /* 220 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 230 */ 1223, 1522, 1610, 1609, 1521, 1534, 1533, 1532, 1223, 1223, + /* 240 */ 1516, 1223, 1223, 1517, 1515, 1514, 1223, 1223, 1223, 1223, + /* 250 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 260 */ 1558, 1223, 1620, 1624, 1223, 1223, 1223, 1493, 1223, 1223, + /* 270 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 280 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 290 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 300 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 310 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 320 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 330 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 340 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 350 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 360 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 370 */ 1223, 1223, 1223, 1223, 1389, 1223, 1223, 1223, 1223, 1223, + /* 380 */ 1223, 1309, 1308, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 390 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 400 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 410 */ 1223, 1223, 1223, 1223, 1581, 1591, 1223, 1223, 1223, 1223, + /* 420 */ 1223, 1223, 1223, 1223, 1223, 1493, 1223, 1608, 1223, 1567, + /* 430 */ 1563, 1223, 1223, 1559, 1223, 1223, 1618, 1223, 1223, 1223, + /* 440 */ 1223, 1223, 1223, 1223, 1223, 1553, 1223, 1223, 1223, 1223, + /* 450 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 460 */ 1223, 1223, 1223, 1223, 1492, 1223, 1223, 1223, 1223, 1223, + /* 470 */ 1223, 1223, 1372, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 480 */ 1223, 1223, 1223, 1223, 1223, 1357, 1355, 1354, 1353, 1223, + /* 490 */ 1350, 1223, 1223, 1223, 1223, 1223, 1223, 1380, 1223, 1223, + /* 500 */ 1223, 1223, 1223, 1303, 1223, 1223, 1223, 1223, 1223, 1223, + /* 510 */ 1223, 1223, 1223, 1294, 1223, 1293, 1223, 1223, 1223, 1223, + /* 520 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 530 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, + /* 540 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, }; /********** End of lemon-generated parsing tables *****************************/ @@ -961,153 +965,154 @@ static const char *const yyTokenName[] = { /* 165 */ "LAST", /* 166 */ "NOW", /* 167 */ "TODAY", - /* 168 */ "ROWTS", - /* 169 */ "TBNAME", - /* 170 */ "QSTARTTS", - /* 171 */ "QENDTS", - /* 172 */ "WSTARTTS", - /* 173 */ "WENDTS", - /* 174 */ "WDURATION", - /* 175 */ "BETWEEN", - /* 176 */ "IS", - /* 177 */ "NK_LT", - /* 178 */ "NK_GT", - /* 179 */ "NK_LE", - /* 180 */ "NK_GE", - /* 181 */ "NK_NE", - /* 182 */ "MATCH", - /* 183 */ "NMATCH", - /* 184 */ "JOIN", - /* 185 */ "INNER", - /* 186 */ "SELECT", - /* 187 */ "DISTINCT", - /* 188 */ "WHERE", - /* 189 */ "PARTITION", - /* 190 */ "BY", - /* 191 */ "SESSION", - /* 192 */ "STATE_WINDOW", - /* 193 */ "SLIDING", - /* 194 */ "FILL", - /* 195 */ "VALUE", - /* 196 */ "NONE", - /* 197 */ "PREV", - /* 198 */ "LINEAR", - /* 199 */ "NEXT", - /* 200 */ "GROUP", - /* 201 */ "HAVING", - /* 202 */ "ORDER", - /* 203 */ "SLIMIT", - /* 204 */ "SOFFSET", - /* 205 */ "LIMIT", - /* 206 */ "OFFSET", - /* 207 */ "ASC", - /* 208 */ "NULLS", - /* 209 */ "cmd", - /* 210 */ "account_options", - /* 211 */ "alter_account_options", - /* 212 */ "literal", - /* 213 */ "alter_account_option", - /* 214 */ "user_name", - /* 215 */ "dnode_endpoint", - /* 216 */ "dnode_host_name", - /* 217 */ "not_exists_opt", - /* 218 */ "db_name", - /* 219 */ "db_options", - /* 220 */ "exists_opt", - /* 221 */ "alter_db_options", - /* 222 */ "integer_list", - /* 223 */ "variable_list", - /* 224 */ "retention_list", - /* 225 */ "alter_db_option", - /* 226 */ "retention", - /* 227 */ "full_table_name", - /* 228 */ "column_def_list", - /* 229 */ "tags_def_opt", - /* 230 */ "table_options", - /* 231 */ "multi_create_clause", - /* 232 */ "tags_def", - /* 233 */ "multi_drop_clause", - /* 234 */ "alter_table_clause", - /* 235 */ "alter_table_options", - /* 236 */ "column_name", - /* 237 */ "type_name", - /* 238 */ "create_subtable_clause", - /* 239 */ "specific_tags_opt", - /* 240 */ "literal_list", - /* 241 */ "drop_table_clause", - /* 242 */ "col_name_list", - /* 243 */ "table_name", - /* 244 */ "column_def", - /* 245 */ "func_name_list", - /* 246 */ "alter_table_option", - /* 247 */ "col_name", - /* 248 */ "db_name_cond_opt", - /* 249 */ "like_pattern_opt", - /* 250 */ "table_name_cond", - /* 251 */ "from_db_opt", - /* 252 */ "func_name", - /* 253 */ "function_name", - /* 254 */ "index_name", - /* 255 */ "index_options", - /* 256 */ "func_list", - /* 257 */ "duration_literal", - /* 258 */ "sliding_opt", - /* 259 */ "func", - /* 260 */ "expression_list", - /* 261 */ "topic_name", - /* 262 */ "query_expression", - /* 263 */ "analyze_opt", - /* 264 */ "explain_options", - /* 265 */ "agg_func_opt", - /* 266 */ "bufsize_opt", - /* 267 */ "stream_name", - /* 268 */ "dnode_list", - /* 269 */ "signed", - /* 270 */ "signed_literal", - /* 271 */ "table_alias", - /* 272 */ "column_alias", - /* 273 */ "expression", - /* 274 */ "pseudo_column", - /* 275 */ "column_reference", - /* 276 */ "subquery", - /* 277 */ "predicate", - /* 278 */ "compare_op", - /* 279 */ "in_op", - /* 280 */ "in_predicate_value", - /* 281 */ "boolean_value_expression", - /* 282 */ "boolean_primary", - /* 283 */ "common_expression", - /* 284 */ "from_clause", - /* 285 */ "table_reference_list", - /* 286 */ "table_reference", - /* 287 */ "table_primary", - /* 288 */ "joined_table", - /* 289 */ "alias_opt", - /* 290 */ "parenthesized_joined_table", - /* 291 */ "join_type", - /* 292 */ "search_condition", - /* 293 */ "query_specification", - /* 294 */ "set_quantifier_opt", - /* 295 */ "select_list", - /* 296 */ "where_clause_opt", - /* 297 */ "partition_by_clause_opt", - /* 298 */ "twindow_clause_opt", - /* 299 */ "group_by_clause_opt", - /* 300 */ "having_clause_opt", - /* 301 */ "select_sublist", - /* 302 */ "select_item", - /* 303 */ "fill_opt", - /* 304 */ "fill_mode", - /* 305 */ "group_by_list", - /* 306 */ "query_expression_body", - /* 307 */ "order_by_clause_opt", - /* 308 */ "slimit_clause_opt", - /* 309 */ "limit_clause_opt", - /* 310 */ "query_primary", - /* 311 */ "sort_specification_list", - /* 312 */ "sort_specification", - /* 313 */ "ordering_specification_opt", - /* 314 */ "null_ordering_opt", + /* 168 */ "CAST", + /* 169 */ "ROWTS", + /* 170 */ "TBNAME", + /* 171 */ "QSTARTTS", + /* 172 */ "QENDTS", + /* 173 */ "WSTARTTS", + /* 174 */ "WENDTS", + /* 175 */ "WDURATION", + /* 176 */ "BETWEEN", + /* 177 */ "IS", + /* 178 */ "NK_LT", + /* 179 */ "NK_GT", + /* 180 */ "NK_LE", + /* 181 */ "NK_GE", + /* 182 */ "NK_NE", + /* 183 */ "MATCH", + /* 184 */ "NMATCH", + /* 185 */ "JOIN", + /* 186 */ "INNER", + /* 187 */ "SELECT", + /* 188 */ "DISTINCT", + /* 189 */ "WHERE", + /* 190 */ "PARTITION", + /* 191 */ "BY", + /* 192 */ "SESSION", + /* 193 */ "STATE_WINDOW", + /* 194 */ "SLIDING", + /* 195 */ "FILL", + /* 196 */ "VALUE", + /* 197 */ "NONE", + /* 198 */ "PREV", + /* 199 */ "LINEAR", + /* 200 */ "NEXT", + /* 201 */ "GROUP", + /* 202 */ "HAVING", + /* 203 */ "ORDER", + /* 204 */ "SLIMIT", + /* 205 */ "SOFFSET", + /* 206 */ "LIMIT", + /* 207 */ "OFFSET", + /* 208 */ "ASC", + /* 209 */ "NULLS", + /* 210 */ "cmd", + /* 211 */ "account_options", + /* 212 */ "alter_account_options", + /* 213 */ "literal", + /* 214 */ "alter_account_option", + /* 215 */ "user_name", + /* 216 */ "dnode_endpoint", + /* 217 */ "dnode_host_name", + /* 218 */ "not_exists_opt", + /* 219 */ "db_name", + /* 220 */ "db_options", + /* 221 */ "exists_opt", + /* 222 */ "alter_db_options", + /* 223 */ "integer_list", + /* 224 */ "variable_list", + /* 225 */ "retention_list", + /* 226 */ "alter_db_option", + /* 227 */ "retention", + /* 228 */ "full_table_name", + /* 229 */ "column_def_list", + /* 230 */ "tags_def_opt", + /* 231 */ "table_options", + /* 232 */ "multi_create_clause", + /* 233 */ "tags_def", + /* 234 */ "multi_drop_clause", + /* 235 */ "alter_table_clause", + /* 236 */ "alter_table_options", + /* 237 */ "column_name", + /* 238 */ "type_name", + /* 239 */ "create_subtable_clause", + /* 240 */ "specific_tags_opt", + /* 241 */ "literal_list", + /* 242 */ "drop_table_clause", + /* 243 */ "col_name_list", + /* 244 */ "table_name", + /* 245 */ "column_def", + /* 246 */ "func_name_list", + /* 247 */ "alter_table_option", + /* 248 */ "col_name", + /* 249 */ "db_name_cond_opt", + /* 250 */ "like_pattern_opt", + /* 251 */ "table_name_cond", + /* 252 */ "from_db_opt", + /* 253 */ "func_name", + /* 254 */ "function_name", + /* 255 */ "index_name", + /* 256 */ "index_options", + /* 257 */ "func_list", + /* 258 */ "duration_literal", + /* 259 */ "sliding_opt", + /* 260 */ "func", + /* 261 */ "expression_list", + /* 262 */ "topic_name", + /* 263 */ "query_expression", + /* 264 */ "analyze_opt", + /* 265 */ "explain_options", + /* 266 */ "agg_func_opt", + /* 267 */ "bufsize_opt", + /* 268 */ "stream_name", + /* 269 */ "dnode_list", + /* 270 */ "signed", + /* 271 */ "signed_literal", + /* 272 */ "table_alias", + /* 273 */ "column_alias", + /* 274 */ "expression", + /* 275 */ "pseudo_column", + /* 276 */ "column_reference", + /* 277 */ "subquery", + /* 278 */ "predicate", + /* 279 */ "compare_op", + /* 280 */ "in_op", + /* 281 */ "in_predicate_value", + /* 282 */ "boolean_value_expression", + /* 283 */ "boolean_primary", + /* 284 */ "common_expression", + /* 285 */ "from_clause", + /* 286 */ "table_reference_list", + /* 287 */ "table_reference", + /* 288 */ "table_primary", + /* 289 */ "joined_table", + /* 290 */ "alias_opt", + /* 291 */ "parenthesized_joined_table", + /* 292 */ "join_type", + /* 293 */ "search_condition", + /* 294 */ "query_specification", + /* 295 */ "set_quantifier_opt", + /* 296 */ "select_list", + /* 297 */ "where_clause_opt", + /* 298 */ "partition_by_clause_opt", + /* 299 */ "twindow_clause_opt", + /* 300 */ "group_by_clause_opt", + /* 301 */ "having_clause_opt", + /* 302 */ "select_sublist", + /* 303 */ "select_item", + /* 304 */ "fill_opt", + /* 305 */ "fill_mode", + /* 306 */ "group_by_list", + /* 307 */ "query_expression_body", + /* 308 */ "order_by_clause_opt", + /* 309 */ "slimit_clause_opt", + /* 310 */ "limit_clause_opt", + /* 311 */ "query_primary", + /* 312 */ "sort_specification_list", + /* 313 */ "sort_specification", + /* 314 */ "ordering_specification_opt", + /* 315 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1386,146 +1391,147 @@ static const char *const yyRuleName[] = { /* 268 */ "function_name ::= NK_ID", /* 269 */ "function_name ::= FIRST", /* 270 */ "function_name ::= LAST", - /* 271 */ "table_alias ::= NK_ID", - /* 272 */ "column_alias ::= NK_ID", - /* 273 */ "user_name ::= NK_ID", - /* 274 */ "index_name ::= NK_ID", - /* 275 */ "topic_name ::= NK_ID", - /* 276 */ "stream_name ::= NK_ID", - /* 277 */ "expression ::= literal", - /* 278 */ "expression ::= pseudo_column", - /* 279 */ "expression ::= column_reference", - /* 280 */ "expression ::= function_name NK_LP expression_list NK_RP", - /* 281 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 282 */ "expression ::= function_name NK_LP expression AS type_name NK_RP", - /* 283 */ "expression ::= subquery", - /* 284 */ "expression ::= NK_LP expression NK_RP", - /* 285 */ "expression ::= NK_PLUS expression", - /* 286 */ "expression ::= NK_MINUS expression", - /* 287 */ "expression ::= expression NK_PLUS expression", - /* 288 */ "expression ::= expression NK_MINUS expression", - /* 289 */ "expression ::= expression NK_STAR expression", - /* 290 */ "expression ::= expression NK_SLASH expression", - /* 291 */ "expression ::= expression NK_REM expression", - /* 292 */ "expression_list ::= expression", - /* 293 */ "expression_list ::= expression_list NK_COMMA expression", - /* 294 */ "column_reference ::= column_name", - /* 295 */ "column_reference ::= table_name NK_DOT column_name", - /* 296 */ "pseudo_column ::= NOW", - /* 297 */ "pseudo_column ::= TODAY", - /* 298 */ "pseudo_column ::= ROWTS", - /* 299 */ "pseudo_column ::= TBNAME", - /* 300 */ "pseudo_column ::= QSTARTTS", - /* 301 */ "pseudo_column ::= QENDTS", - /* 302 */ "pseudo_column ::= WSTARTTS", - /* 303 */ "pseudo_column ::= WENDTS", - /* 304 */ "pseudo_column ::= WDURATION", - /* 305 */ "predicate ::= expression compare_op expression", - /* 306 */ "predicate ::= expression BETWEEN expression AND expression", - /* 307 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 308 */ "predicate ::= expression IS NULL", - /* 309 */ "predicate ::= expression IS NOT NULL", - /* 310 */ "predicate ::= expression in_op in_predicate_value", - /* 311 */ "compare_op ::= NK_LT", - /* 312 */ "compare_op ::= NK_GT", - /* 313 */ "compare_op ::= NK_LE", - /* 314 */ "compare_op ::= NK_GE", - /* 315 */ "compare_op ::= NK_NE", - /* 316 */ "compare_op ::= NK_EQ", - /* 317 */ "compare_op ::= LIKE", - /* 318 */ "compare_op ::= NOT LIKE", - /* 319 */ "compare_op ::= MATCH", - /* 320 */ "compare_op ::= NMATCH", - /* 321 */ "in_op ::= IN", - /* 322 */ "in_op ::= NOT IN", - /* 323 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 324 */ "boolean_value_expression ::= boolean_primary", - /* 325 */ "boolean_value_expression ::= NOT boolean_primary", - /* 326 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 327 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 328 */ "boolean_primary ::= predicate", - /* 329 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 330 */ "common_expression ::= expression", - /* 331 */ "common_expression ::= boolean_value_expression", - /* 332 */ "from_clause ::= FROM table_reference_list", - /* 333 */ "table_reference_list ::= table_reference", - /* 334 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 335 */ "table_reference ::= table_primary", - /* 336 */ "table_reference ::= joined_table", - /* 337 */ "table_primary ::= table_name alias_opt", - /* 338 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 339 */ "table_primary ::= subquery alias_opt", - /* 340 */ "table_primary ::= parenthesized_joined_table", - /* 341 */ "alias_opt ::=", - /* 342 */ "alias_opt ::= table_alias", - /* 343 */ "alias_opt ::= AS table_alias", - /* 344 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 345 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 346 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 347 */ "join_type ::=", - /* 348 */ "join_type ::= INNER", - /* 349 */ "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", - /* 350 */ "set_quantifier_opt ::=", - /* 351 */ "set_quantifier_opt ::= DISTINCT", - /* 352 */ "set_quantifier_opt ::= ALL", - /* 353 */ "select_list ::= NK_STAR", - /* 354 */ "select_list ::= select_sublist", - /* 355 */ "select_sublist ::= select_item", - /* 356 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 357 */ "select_item ::= common_expression", - /* 358 */ "select_item ::= common_expression column_alias", - /* 359 */ "select_item ::= common_expression AS column_alias", - /* 360 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 361 */ "where_clause_opt ::=", - /* 362 */ "where_clause_opt ::= WHERE search_condition", - /* 363 */ "partition_by_clause_opt ::=", - /* 364 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 365 */ "twindow_clause_opt ::=", - /* 366 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 367 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 368 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 369 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 370 */ "sliding_opt ::=", - /* 371 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 372 */ "fill_opt ::=", - /* 373 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 374 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 375 */ "fill_mode ::= NONE", - /* 376 */ "fill_mode ::= PREV", - /* 377 */ "fill_mode ::= NULL", - /* 378 */ "fill_mode ::= LINEAR", - /* 379 */ "fill_mode ::= NEXT", - /* 380 */ "group_by_clause_opt ::=", - /* 381 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 382 */ "group_by_list ::= expression", - /* 383 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 384 */ "having_clause_opt ::=", - /* 385 */ "having_clause_opt ::= HAVING search_condition", - /* 386 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 387 */ "query_expression_body ::= query_primary", - /* 388 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 389 */ "query_primary ::= query_specification", - /* 390 */ "order_by_clause_opt ::=", - /* 391 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 392 */ "slimit_clause_opt ::=", - /* 393 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 394 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 395 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 396 */ "limit_clause_opt ::=", - /* 397 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 398 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 399 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 400 */ "subquery ::= NK_LP query_expression NK_RP", - /* 401 */ "search_condition ::= common_expression", - /* 402 */ "sort_specification_list ::= sort_specification", - /* 403 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 404 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 405 */ "ordering_specification_opt ::=", - /* 406 */ "ordering_specification_opt ::= ASC", - /* 407 */ "ordering_specification_opt ::= DESC", - /* 408 */ "null_ordering_opt ::=", - /* 409 */ "null_ordering_opt ::= NULLS FIRST", - /* 410 */ "null_ordering_opt ::= NULLS LAST", + /* 271 */ "function_name ::= NOW", + /* 272 */ "function_name ::= TODAY", + /* 273 */ "table_alias ::= NK_ID", + /* 274 */ "column_alias ::= NK_ID", + /* 275 */ "user_name ::= NK_ID", + /* 276 */ "index_name ::= NK_ID", + /* 277 */ "topic_name ::= NK_ID", + /* 278 */ "stream_name ::= NK_ID", + /* 279 */ "expression ::= literal", + /* 280 */ "expression ::= pseudo_column", + /* 281 */ "expression ::= column_reference", + /* 282 */ "expression ::= function_name NK_LP expression_list NK_RP", + /* 283 */ "expression ::= function_name NK_LP NK_STAR NK_RP", + /* 284 */ "expression ::= function_name NK_LP NK_RP", + /* 285 */ "expression ::= CAST NK_LP expression AS type_name NK_RP", + /* 286 */ "expression ::= subquery", + /* 287 */ "expression ::= NK_LP expression NK_RP", + /* 288 */ "expression ::= NK_PLUS expression", + /* 289 */ "expression ::= NK_MINUS expression", + /* 290 */ "expression ::= expression NK_PLUS expression", + /* 291 */ "expression ::= expression NK_MINUS expression", + /* 292 */ "expression ::= expression NK_STAR expression", + /* 293 */ "expression ::= expression NK_SLASH expression", + /* 294 */ "expression ::= expression NK_REM expression", + /* 295 */ "expression_list ::= expression", + /* 296 */ "expression_list ::= expression_list NK_COMMA expression", + /* 297 */ "column_reference ::= column_name", + /* 298 */ "column_reference ::= table_name NK_DOT column_name", + /* 299 */ "pseudo_column ::= ROWTS", + /* 300 */ "pseudo_column ::= TBNAME", + /* 301 */ "pseudo_column ::= QSTARTTS", + /* 302 */ "pseudo_column ::= QENDTS", + /* 303 */ "pseudo_column ::= WSTARTTS", + /* 304 */ "pseudo_column ::= WENDTS", + /* 305 */ "pseudo_column ::= WDURATION", + /* 306 */ "predicate ::= expression compare_op expression", + /* 307 */ "predicate ::= expression BETWEEN expression AND expression", + /* 308 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 309 */ "predicate ::= expression IS NULL", + /* 310 */ "predicate ::= expression IS NOT NULL", + /* 311 */ "predicate ::= expression in_op in_predicate_value", + /* 312 */ "compare_op ::= NK_LT", + /* 313 */ "compare_op ::= NK_GT", + /* 314 */ "compare_op ::= NK_LE", + /* 315 */ "compare_op ::= NK_GE", + /* 316 */ "compare_op ::= NK_NE", + /* 317 */ "compare_op ::= NK_EQ", + /* 318 */ "compare_op ::= LIKE", + /* 319 */ "compare_op ::= NOT LIKE", + /* 320 */ "compare_op ::= MATCH", + /* 321 */ "compare_op ::= NMATCH", + /* 322 */ "in_op ::= IN", + /* 323 */ "in_op ::= NOT IN", + /* 324 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 325 */ "boolean_value_expression ::= boolean_primary", + /* 326 */ "boolean_value_expression ::= NOT boolean_primary", + /* 327 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 328 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 329 */ "boolean_primary ::= predicate", + /* 330 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 331 */ "common_expression ::= expression", + /* 332 */ "common_expression ::= boolean_value_expression", + /* 333 */ "from_clause ::= FROM table_reference_list", + /* 334 */ "table_reference_list ::= table_reference", + /* 335 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 336 */ "table_reference ::= table_primary", + /* 337 */ "table_reference ::= joined_table", + /* 338 */ "table_primary ::= table_name alias_opt", + /* 339 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 340 */ "table_primary ::= subquery alias_opt", + /* 341 */ "table_primary ::= parenthesized_joined_table", + /* 342 */ "alias_opt ::=", + /* 343 */ "alias_opt ::= table_alias", + /* 344 */ "alias_opt ::= AS table_alias", + /* 345 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 346 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 347 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 348 */ "join_type ::=", + /* 349 */ "join_type ::= INNER", + /* 350 */ "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", + /* 351 */ "set_quantifier_opt ::=", + /* 352 */ "set_quantifier_opt ::= DISTINCT", + /* 353 */ "set_quantifier_opt ::= ALL", + /* 354 */ "select_list ::= NK_STAR", + /* 355 */ "select_list ::= select_sublist", + /* 356 */ "select_sublist ::= select_item", + /* 357 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 358 */ "select_item ::= common_expression", + /* 359 */ "select_item ::= common_expression column_alias", + /* 360 */ "select_item ::= common_expression AS column_alias", + /* 361 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 362 */ "where_clause_opt ::=", + /* 363 */ "where_clause_opt ::= WHERE search_condition", + /* 364 */ "partition_by_clause_opt ::=", + /* 365 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 366 */ "twindow_clause_opt ::=", + /* 367 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 368 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 369 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 370 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 371 */ "sliding_opt ::=", + /* 372 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 373 */ "fill_opt ::=", + /* 374 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 375 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 376 */ "fill_mode ::= NONE", + /* 377 */ "fill_mode ::= PREV", + /* 378 */ "fill_mode ::= NULL", + /* 379 */ "fill_mode ::= LINEAR", + /* 380 */ "fill_mode ::= NEXT", + /* 381 */ "group_by_clause_opt ::=", + /* 382 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 383 */ "group_by_list ::= expression", + /* 384 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 385 */ "having_clause_opt ::=", + /* 386 */ "having_clause_opt ::= HAVING search_condition", + /* 387 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 388 */ "query_expression_body ::= query_primary", + /* 389 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 390 */ "query_primary ::= query_specification", + /* 391 */ "order_by_clause_opt ::=", + /* 392 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 393 */ "slimit_clause_opt ::=", + /* 394 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 395 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 396 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 397 */ "limit_clause_opt ::=", + /* 398 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 399 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 400 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 401 */ "subquery ::= NK_LP query_expression NK_RP", + /* 402 */ "search_condition ::= common_expression", + /* 403 */ "sort_specification_list ::= sort_specification", + /* 404 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 405 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 406 */ "ordering_specification_opt ::=", + /* 407 */ "ordering_specification_opt ::= ASC", + /* 408 */ "ordering_specification_opt ::= DESC", + /* 409 */ "null_ordering_opt ::=", + /* 410 */ "null_ordering_opt ::= NULLS FIRST", + /* 411 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1652,156 +1658,156 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 209: /* cmd */ - case 212: /* literal */ - case 219: /* db_options */ - case 221: /* alter_db_options */ - case 226: /* retention */ - case 227: /* full_table_name */ - case 230: /* table_options */ - case 234: /* alter_table_clause */ - case 235: /* alter_table_options */ - case 238: /* create_subtable_clause */ - case 241: /* drop_table_clause */ - case 244: /* column_def */ - case 247: /* col_name */ - case 248: /* db_name_cond_opt */ - case 249: /* like_pattern_opt */ - case 250: /* table_name_cond */ - case 251: /* from_db_opt */ - case 252: /* func_name */ - case 255: /* index_options */ - case 257: /* duration_literal */ - case 258: /* sliding_opt */ - case 259: /* func */ - case 262: /* query_expression */ - case 264: /* explain_options */ - case 269: /* signed */ - case 270: /* signed_literal */ - case 273: /* expression */ - case 274: /* pseudo_column */ - case 275: /* column_reference */ - case 276: /* subquery */ - case 277: /* predicate */ - case 280: /* in_predicate_value */ - case 281: /* boolean_value_expression */ - case 282: /* boolean_primary */ - case 283: /* common_expression */ - case 284: /* from_clause */ - case 285: /* table_reference_list */ - case 286: /* table_reference */ - case 287: /* table_primary */ - case 288: /* joined_table */ - case 290: /* parenthesized_joined_table */ - case 292: /* search_condition */ - case 293: /* query_specification */ - case 296: /* where_clause_opt */ - case 298: /* twindow_clause_opt */ - case 300: /* having_clause_opt */ - case 302: /* select_item */ - case 303: /* fill_opt */ - case 306: /* query_expression_body */ - case 308: /* slimit_clause_opt */ - case 309: /* limit_clause_opt */ - case 310: /* query_primary */ - case 312: /* sort_specification */ + case 210: /* cmd */ + case 213: /* literal */ + case 220: /* db_options */ + case 222: /* alter_db_options */ + case 227: /* retention */ + case 228: /* full_table_name */ + case 231: /* table_options */ + case 235: /* alter_table_clause */ + case 236: /* alter_table_options */ + case 239: /* create_subtable_clause */ + case 242: /* drop_table_clause */ + case 245: /* column_def */ + case 248: /* col_name */ + case 249: /* db_name_cond_opt */ + case 250: /* like_pattern_opt */ + case 251: /* table_name_cond */ + case 252: /* from_db_opt */ + case 253: /* func_name */ + case 256: /* index_options */ + case 258: /* duration_literal */ + case 259: /* sliding_opt */ + case 260: /* func */ + case 263: /* query_expression */ + case 265: /* explain_options */ + case 270: /* signed */ + case 271: /* signed_literal */ + case 274: /* expression */ + case 275: /* pseudo_column */ + case 276: /* column_reference */ + case 277: /* subquery */ + case 278: /* predicate */ + case 281: /* in_predicate_value */ + case 282: /* boolean_value_expression */ + case 283: /* boolean_primary */ + case 284: /* common_expression */ + case 285: /* from_clause */ + case 286: /* table_reference_list */ + case 287: /* table_reference */ + case 288: /* table_primary */ + case 289: /* joined_table */ + case 291: /* parenthesized_joined_table */ + case 293: /* search_condition */ + case 294: /* query_specification */ + case 297: /* where_clause_opt */ + case 299: /* twindow_clause_opt */ + case 301: /* having_clause_opt */ + case 303: /* select_item */ + case 304: /* fill_opt */ + case 307: /* query_expression_body */ + case 309: /* slimit_clause_opt */ + case 310: /* limit_clause_opt */ + case 311: /* query_primary */ + case 313: /* sort_specification */ { - nodesDestroyNode((yypminor->yy182)); + nodesDestroyNode((yypminor->yy504)); } break; - case 210: /* account_options */ - case 211: /* alter_account_options */ - case 213: /* alter_account_option */ - case 266: /* bufsize_opt */ + case 211: /* account_options */ + case 212: /* alter_account_options */ + case 214: /* alter_account_option */ + case 267: /* bufsize_opt */ { } break; - case 214: /* user_name */ - case 215: /* dnode_endpoint */ - case 216: /* dnode_host_name */ - case 218: /* db_name */ - case 236: /* column_name */ - case 243: /* table_name */ - case 253: /* function_name */ - case 254: /* index_name */ - case 261: /* topic_name */ - case 267: /* stream_name */ - case 271: /* table_alias */ - case 272: /* column_alias */ - case 289: /* alias_opt */ + case 215: /* user_name */ + case 216: /* dnode_endpoint */ + case 217: /* dnode_host_name */ + case 219: /* db_name */ + case 237: /* column_name */ + case 244: /* table_name */ + case 254: /* function_name */ + case 255: /* index_name */ + case 262: /* topic_name */ + case 268: /* stream_name */ + case 272: /* table_alias */ + case 273: /* column_alias */ + case 290: /* alias_opt */ { } break; - case 217: /* not_exists_opt */ - case 220: /* exists_opt */ - case 263: /* analyze_opt */ - case 265: /* agg_func_opt */ - case 294: /* set_quantifier_opt */ + case 218: /* not_exists_opt */ + case 221: /* exists_opt */ + case 264: /* analyze_opt */ + case 266: /* agg_func_opt */ + case 295: /* set_quantifier_opt */ { } break; - case 222: /* integer_list */ - case 223: /* variable_list */ - case 224: /* retention_list */ - case 228: /* column_def_list */ - case 229: /* tags_def_opt */ - case 231: /* multi_create_clause */ - case 232: /* tags_def */ - case 233: /* multi_drop_clause */ - case 239: /* specific_tags_opt */ - case 240: /* literal_list */ - case 242: /* col_name_list */ - case 245: /* func_name_list */ - case 256: /* func_list */ - case 260: /* expression_list */ - case 268: /* dnode_list */ - case 295: /* select_list */ - case 297: /* partition_by_clause_opt */ - case 299: /* group_by_clause_opt */ - case 301: /* select_sublist */ - case 305: /* group_by_list */ - case 307: /* order_by_clause_opt */ - case 311: /* sort_specification_list */ + case 223: /* integer_list */ + case 224: /* variable_list */ + case 225: /* retention_list */ + case 229: /* column_def_list */ + case 230: /* tags_def_opt */ + case 232: /* multi_create_clause */ + case 233: /* tags_def */ + case 234: /* multi_drop_clause */ + case 240: /* specific_tags_opt */ + case 241: /* literal_list */ + case 243: /* col_name_list */ + case 246: /* func_name_list */ + case 257: /* func_list */ + case 261: /* expression_list */ + case 269: /* dnode_list */ + case 296: /* select_list */ + case 298: /* partition_by_clause_opt */ + case 300: /* group_by_clause_opt */ + case 302: /* select_sublist */ + case 306: /* group_by_list */ + case 308: /* order_by_clause_opt */ + case 312: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy334)); + nodesDestroyList((yypminor->yy488)); } break; - case 225: /* alter_db_option */ - case 246: /* alter_table_option */ + case 226: /* alter_db_option */ + case 247: /* alter_table_option */ { } break; - case 237: /* type_name */ + case 238: /* type_name */ { } break; - case 278: /* compare_op */ - case 279: /* in_op */ + case 279: /* compare_op */ + case 280: /* in_op */ { } break; - case 291: /* join_type */ + case 292: /* join_type */ { } break; - case 304: /* fill_mode */ + case 305: /* fill_mode */ { } break; - case 313: /* ordering_specification_opt */ + case 314: /* ordering_specification_opt */ { } break; - case 314: /* null_ordering_opt */ + case 315: /* null_ordering_opt */ { } @@ -2092,417 +2098,418 @@ static void yy_shift( /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side ** of that rule */ static const YYCODETYPE yyRuleInfoLhs[] = { - 209, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - 209, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - 210, /* (2) account_options ::= */ - 210, /* (3) account_options ::= account_options PPS literal */ - 210, /* (4) account_options ::= account_options TSERIES literal */ - 210, /* (5) account_options ::= account_options STORAGE literal */ - 210, /* (6) account_options ::= account_options STREAMS literal */ - 210, /* (7) account_options ::= account_options QTIME literal */ - 210, /* (8) account_options ::= account_options DBS literal */ - 210, /* (9) account_options ::= account_options USERS literal */ - 210, /* (10) account_options ::= account_options CONNS literal */ - 210, /* (11) account_options ::= account_options STATE literal */ - 211, /* (12) alter_account_options ::= alter_account_option */ - 211, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - 213, /* (14) alter_account_option ::= PASS literal */ - 213, /* (15) alter_account_option ::= PPS literal */ - 213, /* (16) alter_account_option ::= TSERIES literal */ - 213, /* (17) alter_account_option ::= STORAGE literal */ - 213, /* (18) alter_account_option ::= STREAMS literal */ - 213, /* (19) alter_account_option ::= QTIME literal */ - 213, /* (20) alter_account_option ::= DBS literal */ - 213, /* (21) alter_account_option ::= USERS literal */ - 213, /* (22) alter_account_option ::= CONNS literal */ - 213, /* (23) alter_account_option ::= STATE literal */ - 209, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ - 209, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - 209, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - 209, /* (27) cmd ::= DROP USER user_name */ - 209, /* (28) cmd ::= CREATE DNODE dnode_endpoint */ - 209, /* (29) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - 209, /* (30) cmd ::= DROP DNODE NK_INTEGER */ - 209, /* (31) cmd ::= DROP DNODE dnode_endpoint */ - 209, /* (32) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - 209, /* (33) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - 209, /* (34) cmd ::= ALTER ALL DNODES NK_STRING */ - 209, /* (35) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - 215, /* (36) dnode_endpoint ::= NK_STRING */ - 216, /* (37) dnode_host_name ::= NK_ID */ - 216, /* (38) dnode_host_name ::= NK_IPTOKEN */ - 209, /* (39) cmd ::= ALTER LOCAL NK_STRING */ - 209, /* (40) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - 209, /* (41) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - 209, /* (42) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - 209, /* (43) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - 209, /* (44) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - 209, /* (45) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - 209, /* (46) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - 209, /* (47) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - 209, /* (48) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - 209, /* (49) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - 209, /* (50) cmd ::= DROP DATABASE exists_opt db_name */ - 209, /* (51) cmd ::= USE db_name */ - 209, /* (52) cmd ::= ALTER DATABASE db_name alter_db_options */ - 217, /* (53) not_exists_opt ::= IF NOT EXISTS */ - 217, /* (54) not_exists_opt ::= */ - 220, /* (55) exists_opt ::= IF EXISTS */ - 220, /* (56) exists_opt ::= */ - 219, /* (57) db_options ::= */ - 219, /* (58) db_options ::= db_options BLOCKS NK_INTEGER */ - 219, /* (59) db_options ::= db_options CACHE NK_INTEGER */ - 219, /* (60) db_options ::= db_options CACHELAST NK_INTEGER */ - 219, /* (61) db_options ::= db_options COMP NK_INTEGER */ - 219, /* (62) db_options ::= db_options DAYS NK_INTEGER */ - 219, /* (63) db_options ::= db_options DAYS NK_VARIABLE */ - 219, /* (64) db_options ::= db_options FSYNC NK_INTEGER */ - 219, /* (65) db_options ::= db_options MAXROWS NK_INTEGER */ - 219, /* (66) db_options ::= db_options MINROWS NK_INTEGER */ - 219, /* (67) db_options ::= db_options KEEP integer_list */ - 219, /* (68) db_options ::= db_options KEEP variable_list */ - 219, /* (69) db_options ::= db_options PRECISION NK_STRING */ - 219, /* (70) db_options ::= db_options QUORUM NK_INTEGER */ - 219, /* (71) db_options ::= db_options REPLICA NK_INTEGER */ - 219, /* (72) db_options ::= db_options TTL NK_INTEGER */ - 219, /* (73) db_options ::= db_options WAL NK_INTEGER */ - 219, /* (74) db_options ::= db_options VGROUPS NK_INTEGER */ - 219, /* (75) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - 219, /* (76) db_options ::= db_options STREAM_MODE NK_INTEGER */ - 219, /* (77) db_options ::= db_options RETENTIONS retention_list */ - 221, /* (78) alter_db_options ::= alter_db_option */ - 221, /* (79) alter_db_options ::= alter_db_options alter_db_option */ - 225, /* (80) alter_db_option ::= BLOCKS NK_INTEGER */ - 225, /* (81) alter_db_option ::= FSYNC NK_INTEGER */ - 225, /* (82) alter_db_option ::= KEEP integer_list */ - 225, /* (83) alter_db_option ::= KEEP variable_list */ - 225, /* (84) alter_db_option ::= WAL NK_INTEGER */ - 225, /* (85) alter_db_option ::= QUORUM NK_INTEGER */ - 225, /* (86) alter_db_option ::= CACHELAST NK_INTEGER */ - 225, /* (87) alter_db_option ::= REPLICA NK_INTEGER */ - 222, /* (88) integer_list ::= NK_INTEGER */ - 222, /* (89) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - 223, /* (90) variable_list ::= NK_VARIABLE */ - 223, /* (91) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - 224, /* (92) retention_list ::= retention */ - 224, /* (93) retention_list ::= retention_list NK_COMMA retention */ - 226, /* (94) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - 209, /* (95) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - 209, /* (96) cmd ::= CREATE TABLE multi_create_clause */ - 209, /* (97) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - 209, /* (98) cmd ::= DROP TABLE multi_drop_clause */ - 209, /* (99) cmd ::= DROP STABLE exists_opt full_table_name */ - 209, /* (100) cmd ::= ALTER TABLE alter_table_clause */ - 209, /* (101) cmd ::= ALTER STABLE alter_table_clause */ - 234, /* (102) alter_table_clause ::= full_table_name alter_table_options */ - 234, /* (103) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - 234, /* (104) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - 234, /* (105) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - 234, /* (106) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - 234, /* (107) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - 234, /* (108) alter_table_clause ::= full_table_name DROP TAG column_name */ - 234, /* (109) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - 234, /* (110) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - 234, /* (111) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ - 231, /* (112) multi_create_clause ::= create_subtable_clause */ - 231, /* (113) multi_create_clause ::= multi_create_clause create_subtable_clause */ - 238, /* (114) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ - 233, /* (115) multi_drop_clause ::= drop_table_clause */ - 233, /* (116) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - 241, /* (117) drop_table_clause ::= exists_opt full_table_name */ - 239, /* (118) specific_tags_opt ::= */ - 239, /* (119) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - 227, /* (120) full_table_name ::= table_name */ - 227, /* (121) full_table_name ::= db_name NK_DOT table_name */ - 228, /* (122) column_def_list ::= column_def */ - 228, /* (123) column_def_list ::= column_def_list NK_COMMA column_def */ - 244, /* (124) column_def ::= column_name type_name */ - 244, /* (125) column_def ::= column_name type_name COMMENT NK_STRING */ - 237, /* (126) type_name ::= BOOL */ - 237, /* (127) type_name ::= TINYINT */ - 237, /* (128) type_name ::= SMALLINT */ - 237, /* (129) type_name ::= INT */ - 237, /* (130) type_name ::= INTEGER */ - 237, /* (131) type_name ::= BIGINT */ - 237, /* (132) type_name ::= FLOAT */ - 237, /* (133) type_name ::= DOUBLE */ - 237, /* (134) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - 237, /* (135) type_name ::= TIMESTAMP */ - 237, /* (136) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - 237, /* (137) type_name ::= TINYINT UNSIGNED */ - 237, /* (138) type_name ::= SMALLINT UNSIGNED */ - 237, /* (139) type_name ::= INT UNSIGNED */ - 237, /* (140) type_name ::= BIGINT UNSIGNED */ - 237, /* (141) type_name ::= JSON */ - 237, /* (142) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - 237, /* (143) type_name ::= MEDIUMBLOB */ - 237, /* (144) type_name ::= BLOB */ - 237, /* (145) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - 237, /* (146) type_name ::= DECIMAL */ - 237, /* (147) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - 237, /* (148) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 229, /* (149) tags_def_opt ::= */ - 229, /* (150) tags_def_opt ::= tags_def */ - 232, /* (151) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - 230, /* (152) table_options ::= */ - 230, /* (153) table_options ::= table_options COMMENT NK_STRING */ - 230, /* (154) table_options ::= table_options KEEP integer_list */ - 230, /* (155) table_options ::= table_options TTL NK_INTEGER */ - 230, /* (156) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - 230, /* (157) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ - 230, /* (158) table_options ::= table_options FILE_FACTOR NK_FLOAT */ - 230, /* (159) table_options ::= table_options DELAY NK_INTEGER */ - 235, /* (160) alter_table_options ::= alter_table_option */ - 235, /* (161) alter_table_options ::= alter_table_options alter_table_option */ - 246, /* (162) alter_table_option ::= COMMENT NK_STRING */ - 246, /* (163) alter_table_option ::= KEEP integer_list */ - 246, /* (164) alter_table_option ::= TTL NK_INTEGER */ - 242, /* (165) col_name_list ::= col_name */ - 242, /* (166) col_name_list ::= col_name_list NK_COMMA col_name */ - 247, /* (167) col_name ::= column_name */ - 209, /* (168) cmd ::= SHOW DNODES */ - 209, /* (169) cmd ::= SHOW USERS */ - 209, /* (170) cmd ::= SHOW DATABASES */ - 209, /* (171) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - 209, /* (172) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - 209, /* (173) cmd ::= SHOW db_name_cond_opt VGROUPS */ - 209, /* (174) cmd ::= SHOW MNODES */ - 209, /* (175) cmd ::= SHOW MODULES */ - 209, /* (176) cmd ::= SHOW QNODES */ - 209, /* (177) cmd ::= SHOW FUNCTIONS */ - 209, /* (178) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - 209, /* (179) cmd ::= SHOW STREAMS */ - 209, /* (180) cmd ::= SHOW ACCOUNTS */ - 209, /* (181) cmd ::= SHOW APPS */ - 209, /* (182) cmd ::= SHOW CONNECTIONS */ - 209, /* (183) cmd ::= SHOW LICENCE */ - 209, /* (184) cmd ::= SHOW GRANTS */ - 209, /* (185) cmd ::= SHOW CREATE DATABASE db_name */ - 209, /* (186) cmd ::= SHOW CREATE TABLE full_table_name */ - 209, /* (187) cmd ::= SHOW CREATE STABLE full_table_name */ - 209, /* (188) cmd ::= SHOW QUERIES */ - 209, /* (189) cmd ::= SHOW SCORES */ - 209, /* (190) cmd ::= SHOW TOPICS */ - 209, /* (191) cmd ::= SHOW VARIABLES */ - 209, /* (192) cmd ::= SHOW BNODES */ - 209, /* (193) cmd ::= SHOW SNODES */ - 248, /* (194) db_name_cond_opt ::= */ - 248, /* (195) db_name_cond_opt ::= db_name NK_DOT */ - 249, /* (196) like_pattern_opt ::= */ - 249, /* (197) like_pattern_opt ::= LIKE NK_STRING */ - 250, /* (198) table_name_cond ::= table_name */ - 251, /* (199) from_db_opt ::= */ - 251, /* (200) from_db_opt ::= FROM db_name */ - 245, /* (201) func_name_list ::= func_name */ - 245, /* (202) func_name_list ::= func_name_list NK_COMMA col_name */ - 252, /* (203) func_name ::= function_name */ - 209, /* (204) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - 209, /* (205) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ - 209, /* (206) cmd ::= DROP INDEX exists_opt index_name ON table_name */ - 255, /* (207) index_options ::= */ - 255, /* (208) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - 255, /* (209) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - 256, /* (210) func_list ::= func */ - 256, /* (211) func_list ::= func_list NK_COMMA func */ - 259, /* (212) func ::= function_name NK_LP expression_list NK_RP */ - 209, /* (213) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - 209, /* (214) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ - 209, /* (215) cmd ::= DROP TOPIC exists_opt topic_name */ - 209, /* (216) cmd ::= DESC full_table_name */ - 209, /* (217) cmd ::= DESCRIBE full_table_name */ - 209, /* (218) cmd ::= RESET QUERY CACHE */ - 209, /* (219) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - 263, /* (220) analyze_opt ::= */ - 263, /* (221) analyze_opt ::= ANALYZE */ - 264, /* (222) explain_options ::= */ - 264, /* (223) explain_options ::= explain_options VERBOSE NK_BOOL */ - 264, /* (224) explain_options ::= explain_options RATIO NK_FLOAT */ - 209, /* (225) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ - 209, /* (226) cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - 209, /* (227) cmd ::= DROP FUNCTION function_name */ - 265, /* (228) agg_func_opt ::= */ - 265, /* (229) agg_func_opt ::= AGGREGATE */ - 266, /* (230) bufsize_opt ::= */ - 266, /* (231) bufsize_opt ::= BUFSIZE NK_INTEGER */ - 209, /* (232) cmd ::= CREATE STREAM stream_name INTO table_name AS query_expression */ - 209, /* (233) cmd ::= DROP STREAM stream_name */ - 209, /* (234) cmd ::= KILL CONNECTION NK_INTEGER */ - 209, /* (235) cmd ::= KILL QUERY NK_INTEGER */ - 209, /* (236) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - 209, /* (237) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - 209, /* (238) cmd ::= SPLIT VGROUP NK_INTEGER */ - 268, /* (239) dnode_list ::= DNODE NK_INTEGER */ - 268, /* (240) dnode_list ::= dnode_list DNODE NK_INTEGER */ - 209, /* (241) cmd ::= SYNCDB db_name REPLICA */ - 209, /* (242) cmd ::= query_expression */ - 212, /* (243) literal ::= NK_INTEGER */ - 212, /* (244) literal ::= NK_FLOAT */ - 212, /* (245) literal ::= NK_STRING */ - 212, /* (246) literal ::= NK_BOOL */ - 212, /* (247) literal ::= TIMESTAMP NK_STRING */ - 212, /* (248) literal ::= duration_literal */ - 212, /* (249) literal ::= NULL */ - 257, /* (250) duration_literal ::= NK_VARIABLE */ - 269, /* (251) signed ::= NK_INTEGER */ - 269, /* (252) signed ::= NK_PLUS NK_INTEGER */ - 269, /* (253) signed ::= NK_MINUS NK_INTEGER */ - 269, /* (254) signed ::= NK_FLOAT */ - 269, /* (255) signed ::= NK_PLUS NK_FLOAT */ - 269, /* (256) signed ::= NK_MINUS NK_FLOAT */ - 270, /* (257) signed_literal ::= signed */ - 270, /* (258) signed_literal ::= NK_STRING */ - 270, /* (259) signed_literal ::= NK_BOOL */ - 270, /* (260) signed_literal ::= TIMESTAMP NK_STRING */ - 270, /* (261) signed_literal ::= duration_literal */ - 270, /* (262) signed_literal ::= NULL */ - 240, /* (263) literal_list ::= signed_literal */ - 240, /* (264) literal_list ::= literal_list NK_COMMA signed_literal */ - 218, /* (265) db_name ::= NK_ID */ - 243, /* (266) table_name ::= NK_ID */ - 236, /* (267) column_name ::= NK_ID */ - 253, /* (268) function_name ::= NK_ID */ - 253, /* (269) function_name ::= FIRST */ - 253, /* (270) function_name ::= LAST */ - 271, /* (271) table_alias ::= NK_ID */ - 272, /* (272) column_alias ::= NK_ID */ - 214, /* (273) user_name ::= NK_ID */ - 254, /* (274) index_name ::= NK_ID */ - 261, /* (275) topic_name ::= NK_ID */ - 267, /* (276) stream_name ::= NK_ID */ - 273, /* (277) expression ::= literal */ - 273, /* (278) expression ::= pseudo_column */ - 273, /* (279) expression ::= column_reference */ - 273, /* (280) expression ::= function_name NK_LP expression_list NK_RP */ - 273, /* (281) expression ::= function_name NK_LP NK_STAR NK_RP */ - 273, /* (282) expression ::= function_name NK_LP expression AS type_name NK_RP */ - 273, /* (283) expression ::= subquery */ - 273, /* (284) expression ::= NK_LP expression NK_RP */ - 273, /* (285) expression ::= NK_PLUS expression */ - 273, /* (286) expression ::= NK_MINUS expression */ - 273, /* (287) expression ::= expression NK_PLUS expression */ - 273, /* (288) expression ::= expression NK_MINUS expression */ - 273, /* (289) expression ::= expression NK_STAR expression */ - 273, /* (290) expression ::= expression NK_SLASH expression */ - 273, /* (291) expression ::= expression NK_REM expression */ - 260, /* (292) expression_list ::= expression */ - 260, /* (293) expression_list ::= expression_list NK_COMMA expression */ - 275, /* (294) column_reference ::= column_name */ - 275, /* (295) column_reference ::= table_name NK_DOT column_name */ - 274, /* (296) pseudo_column ::= NOW */ - 274, /* (297) pseudo_column ::= TODAY */ - 274, /* (298) pseudo_column ::= ROWTS */ - 274, /* (299) pseudo_column ::= TBNAME */ - 274, /* (300) pseudo_column ::= QSTARTTS */ - 274, /* (301) pseudo_column ::= QENDTS */ - 274, /* (302) pseudo_column ::= WSTARTTS */ - 274, /* (303) pseudo_column ::= WENDTS */ - 274, /* (304) pseudo_column ::= WDURATION */ - 277, /* (305) predicate ::= expression compare_op expression */ - 277, /* (306) predicate ::= expression BETWEEN expression AND expression */ - 277, /* (307) predicate ::= expression NOT BETWEEN expression AND expression */ - 277, /* (308) predicate ::= expression IS NULL */ - 277, /* (309) predicate ::= expression IS NOT NULL */ - 277, /* (310) predicate ::= expression in_op in_predicate_value */ - 278, /* (311) compare_op ::= NK_LT */ - 278, /* (312) compare_op ::= NK_GT */ - 278, /* (313) compare_op ::= NK_LE */ - 278, /* (314) compare_op ::= NK_GE */ - 278, /* (315) compare_op ::= NK_NE */ - 278, /* (316) compare_op ::= NK_EQ */ - 278, /* (317) compare_op ::= LIKE */ - 278, /* (318) compare_op ::= NOT LIKE */ - 278, /* (319) compare_op ::= MATCH */ - 278, /* (320) compare_op ::= NMATCH */ - 279, /* (321) in_op ::= IN */ - 279, /* (322) in_op ::= NOT IN */ - 280, /* (323) in_predicate_value ::= NK_LP expression_list NK_RP */ - 281, /* (324) boolean_value_expression ::= boolean_primary */ - 281, /* (325) boolean_value_expression ::= NOT boolean_primary */ - 281, /* (326) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - 281, /* (327) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - 282, /* (328) boolean_primary ::= predicate */ - 282, /* (329) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - 283, /* (330) common_expression ::= expression */ - 283, /* (331) common_expression ::= boolean_value_expression */ - 284, /* (332) from_clause ::= FROM table_reference_list */ - 285, /* (333) table_reference_list ::= table_reference */ - 285, /* (334) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - 286, /* (335) table_reference ::= table_primary */ - 286, /* (336) table_reference ::= joined_table */ - 287, /* (337) table_primary ::= table_name alias_opt */ - 287, /* (338) table_primary ::= db_name NK_DOT table_name alias_opt */ - 287, /* (339) table_primary ::= subquery alias_opt */ - 287, /* (340) table_primary ::= parenthesized_joined_table */ - 289, /* (341) alias_opt ::= */ - 289, /* (342) alias_opt ::= table_alias */ - 289, /* (343) alias_opt ::= AS table_alias */ - 290, /* (344) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - 290, /* (345) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - 288, /* (346) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - 291, /* (347) join_type ::= */ - 291, /* (348) join_type ::= INNER */ - 293, /* (349) 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 */ - 294, /* (350) set_quantifier_opt ::= */ - 294, /* (351) set_quantifier_opt ::= DISTINCT */ - 294, /* (352) set_quantifier_opt ::= ALL */ - 295, /* (353) select_list ::= NK_STAR */ - 295, /* (354) select_list ::= select_sublist */ - 301, /* (355) select_sublist ::= select_item */ - 301, /* (356) select_sublist ::= select_sublist NK_COMMA select_item */ - 302, /* (357) select_item ::= common_expression */ - 302, /* (358) select_item ::= common_expression column_alias */ - 302, /* (359) select_item ::= common_expression AS column_alias */ - 302, /* (360) select_item ::= table_name NK_DOT NK_STAR */ - 296, /* (361) where_clause_opt ::= */ - 296, /* (362) where_clause_opt ::= WHERE search_condition */ - 297, /* (363) partition_by_clause_opt ::= */ - 297, /* (364) partition_by_clause_opt ::= PARTITION BY expression_list */ - 298, /* (365) twindow_clause_opt ::= */ - 298, /* (366) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - 298, /* (367) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - 298, /* (368) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - 298, /* (369) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - 258, /* (370) sliding_opt ::= */ - 258, /* (371) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - 303, /* (372) fill_opt ::= */ - 303, /* (373) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - 303, /* (374) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - 304, /* (375) fill_mode ::= NONE */ - 304, /* (376) fill_mode ::= PREV */ - 304, /* (377) fill_mode ::= NULL */ - 304, /* (378) fill_mode ::= LINEAR */ - 304, /* (379) fill_mode ::= NEXT */ - 299, /* (380) group_by_clause_opt ::= */ - 299, /* (381) group_by_clause_opt ::= GROUP BY group_by_list */ - 305, /* (382) group_by_list ::= expression */ - 305, /* (383) group_by_list ::= group_by_list NK_COMMA expression */ - 300, /* (384) having_clause_opt ::= */ - 300, /* (385) having_clause_opt ::= HAVING search_condition */ - 262, /* (386) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - 306, /* (387) query_expression_body ::= query_primary */ - 306, /* (388) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - 310, /* (389) query_primary ::= query_specification */ - 307, /* (390) order_by_clause_opt ::= */ - 307, /* (391) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 308, /* (392) slimit_clause_opt ::= */ - 308, /* (393) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - 308, /* (394) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - 308, /* (395) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 309, /* (396) limit_clause_opt ::= */ - 309, /* (397) limit_clause_opt ::= LIMIT NK_INTEGER */ - 309, /* (398) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - 309, /* (399) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 276, /* (400) subquery ::= NK_LP query_expression NK_RP */ - 292, /* (401) search_condition ::= common_expression */ - 311, /* (402) sort_specification_list ::= sort_specification */ - 311, /* (403) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - 312, /* (404) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - 313, /* (405) ordering_specification_opt ::= */ - 313, /* (406) ordering_specification_opt ::= ASC */ - 313, /* (407) ordering_specification_opt ::= DESC */ - 314, /* (408) null_ordering_opt ::= */ - 314, /* (409) null_ordering_opt ::= NULLS FIRST */ - 314, /* (410) null_ordering_opt ::= NULLS LAST */ + 210, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + 210, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + 211, /* (2) account_options ::= */ + 211, /* (3) account_options ::= account_options PPS literal */ + 211, /* (4) account_options ::= account_options TSERIES literal */ + 211, /* (5) account_options ::= account_options STORAGE literal */ + 211, /* (6) account_options ::= account_options STREAMS literal */ + 211, /* (7) account_options ::= account_options QTIME literal */ + 211, /* (8) account_options ::= account_options DBS literal */ + 211, /* (9) account_options ::= account_options USERS literal */ + 211, /* (10) account_options ::= account_options CONNS literal */ + 211, /* (11) account_options ::= account_options STATE literal */ + 212, /* (12) alter_account_options ::= alter_account_option */ + 212, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + 214, /* (14) alter_account_option ::= PASS literal */ + 214, /* (15) alter_account_option ::= PPS literal */ + 214, /* (16) alter_account_option ::= TSERIES literal */ + 214, /* (17) alter_account_option ::= STORAGE literal */ + 214, /* (18) alter_account_option ::= STREAMS literal */ + 214, /* (19) alter_account_option ::= QTIME literal */ + 214, /* (20) alter_account_option ::= DBS literal */ + 214, /* (21) alter_account_option ::= USERS literal */ + 214, /* (22) alter_account_option ::= CONNS literal */ + 214, /* (23) alter_account_option ::= STATE literal */ + 210, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ + 210, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + 210, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + 210, /* (27) cmd ::= DROP USER user_name */ + 210, /* (28) cmd ::= CREATE DNODE dnode_endpoint */ + 210, /* (29) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + 210, /* (30) cmd ::= DROP DNODE NK_INTEGER */ + 210, /* (31) cmd ::= DROP DNODE dnode_endpoint */ + 210, /* (32) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + 210, /* (33) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + 210, /* (34) cmd ::= ALTER ALL DNODES NK_STRING */ + 210, /* (35) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + 216, /* (36) dnode_endpoint ::= NK_STRING */ + 217, /* (37) dnode_host_name ::= NK_ID */ + 217, /* (38) dnode_host_name ::= NK_IPTOKEN */ + 210, /* (39) cmd ::= ALTER LOCAL NK_STRING */ + 210, /* (40) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + 210, /* (41) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + 210, /* (42) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + 210, /* (43) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + 210, /* (44) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + 210, /* (45) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + 210, /* (46) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + 210, /* (47) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + 210, /* (48) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + 210, /* (49) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + 210, /* (50) cmd ::= DROP DATABASE exists_opt db_name */ + 210, /* (51) cmd ::= USE db_name */ + 210, /* (52) cmd ::= ALTER DATABASE db_name alter_db_options */ + 218, /* (53) not_exists_opt ::= IF NOT EXISTS */ + 218, /* (54) not_exists_opt ::= */ + 221, /* (55) exists_opt ::= IF EXISTS */ + 221, /* (56) exists_opt ::= */ + 220, /* (57) db_options ::= */ + 220, /* (58) db_options ::= db_options BLOCKS NK_INTEGER */ + 220, /* (59) db_options ::= db_options CACHE NK_INTEGER */ + 220, /* (60) db_options ::= db_options CACHELAST NK_INTEGER */ + 220, /* (61) db_options ::= db_options COMP NK_INTEGER */ + 220, /* (62) db_options ::= db_options DAYS NK_INTEGER */ + 220, /* (63) db_options ::= db_options DAYS NK_VARIABLE */ + 220, /* (64) db_options ::= db_options FSYNC NK_INTEGER */ + 220, /* (65) db_options ::= db_options MAXROWS NK_INTEGER */ + 220, /* (66) db_options ::= db_options MINROWS NK_INTEGER */ + 220, /* (67) db_options ::= db_options KEEP integer_list */ + 220, /* (68) db_options ::= db_options KEEP variable_list */ + 220, /* (69) db_options ::= db_options PRECISION NK_STRING */ + 220, /* (70) db_options ::= db_options QUORUM NK_INTEGER */ + 220, /* (71) db_options ::= db_options REPLICA NK_INTEGER */ + 220, /* (72) db_options ::= db_options TTL NK_INTEGER */ + 220, /* (73) db_options ::= db_options WAL NK_INTEGER */ + 220, /* (74) db_options ::= db_options VGROUPS NK_INTEGER */ + 220, /* (75) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + 220, /* (76) db_options ::= db_options STREAM_MODE NK_INTEGER */ + 220, /* (77) db_options ::= db_options RETENTIONS retention_list */ + 222, /* (78) alter_db_options ::= alter_db_option */ + 222, /* (79) alter_db_options ::= alter_db_options alter_db_option */ + 226, /* (80) alter_db_option ::= BLOCKS NK_INTEGER */ + 226, /* (81) alter_db_option ::= FSYNC NK_INTEGER */ + 226, /* (82) alter_db_option ::= KEEP integer_list */ + 226, /* (83) alter_db_option ::= KEEP variable_list */ + 226, /* (84) alter_db_option ::= WAL NK_INTEGER */ + 226, /* (85) alter_db_option ::= QUORUM NK_INTEGER */ + 226, /* (86) alter_db_option ::= CACHELAST NK_INTEGER */ + 226, /* (87) alter_db_option ::= REPLICA NK_INTEGER */ + 223, /* (88) integer_list ::= NK_INTEGER */ + 223, /* (89) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + 224, /* (90) variable_list ::= NK_VARIABLE */ + 224, /* (91) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + 225, /* (92) retention_list ::= retention */ + 225, /* (93) retention_list ::= retention_list NK_COMMA retention */ + 227, /* (94) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + 210, /* (95) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + 210, /* (96) cmd ::= CREATE TABLE multi_create_clause */ + 210, /* (97) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + 210, /* (98) cmd ::= DROP TABLE multi_drop_clause */ + 210, /* (99) cmd ::= DROP STABLE exists_opt full_table_name */ + 210, /* (100) cmd ::= ALTER TABLE alter_table_clause */ + 210, /* (101) cmd ::= ALTER STABLE alter_table_clause */ + 235, /* (102) alter_table_clause ::= full_table_name alter_table_options */ + 235, /* (103) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + 235, /* (104) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + 235, /* (105) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + 235, /* (106) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + 235, /* (107) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + 235, /* (108) alter_table_clause ::= full_table_name DROP TAG column_name */ + 235, /* (109) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + 235, /* (110) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + 235, /* (111) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ + 232, /* (112) multi_create_clause ::= create_subtable_clause */ + 232, /* (113) multi_create_clause ::= multi_create_clause create_subtable_clause */ + 239, /* (114) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ + 234, /* (115) multi_drop_clause ::= drop_table_clause */ + 234, /* (116) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + 242, /* (117) drop_table_clause ::= exists_opt full_table_name */ + 240, /* (118) specific_tags_opt ::= */ + 240, /* (119) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + 228, /* (120) full_table_name ::= table_name */ + 228, /* (121) full_table_name ::= db_name NK_DOT table_name */ + 229, /* (122) column_def_list ::= column_def */ + 229, /* (123) column_def_list ::= column_def_list NK_COMMA column_def */ + 245, /* (124) column_def ::= column_name type_name */ + 245, /* (125) column_def ::= column_name type_name COMMENT NK_STRING */ + 238, /* (126) type_name ::= BOOL */ + 238, /* (127) type_name ::= TINYINT */ + 238, /* (128) type_name ::= SMALLINT */ + 238, /* (129) type_name ::= INT */ + 238, /* (130) type_name ::= INTEGER */ + 238, /* (131) type_name ::= BIGINT */ + 238, /* (132) type_name ::= FLOAT */ + 238, /* (133) type_name ::= DOUBLE */ + 238, /* (134) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + 238, /* (135) type_name ::= TIMESTAMP */ + 238, /* (136) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + 238, /* (137) type_name ::= TINYINT UNSIGNED */ + 238, /* (138) type_name ::= SMALLINT UNSIGNED */ + 238, /* (139) type_name ::= INT UNSIGNED */ + 238, /* (140) type_name ::= BIGINT UNSIGNED */ + 238, /* (141) type_name ::= JSON */ + 238, /* (142) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + 238, /* (143) type_name ::= MEDIUMBLOB */ + 238, /* (144) type_name ::= BLOB */ + 238, /* (145) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + 238, /* (146) type_name ::= DECIMAL */ + 238, /* (147) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + 238, /* (148) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 230, /* (149) tags_def_opt ::= */ + 230, /* (150) tags_def_opt ::= tags_def */ + 233, /* (151) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + 231, /* (152) table_options ::= */ + 231, /* (153) table_options ::= table_options COMMENT NK_STRING */ + 231, /* (154) table_options ::= table_options KEEP integer_list */ + 231, /* (155) table_options ::= table_options TTL NK_INTEGER */ + 231, /* (156) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + 231, /* (157) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ + 231, /* (158) table_options ::= table_options FILE_FACTOR NK_FLOAT */ + 231, /* (159) table_options ::= table_options DELAY NK_INTEGER */ + 236, /* (160) alter_table_options ::= alter_table_option */ + 236, /* (161) alter_table_options ::= alter_table_options alter_table_option */ + 247, /* (162) alter_table_option ::= COMMENT NK_STRING */ + 247, /* (163) alter_table_option ::= KEEP integer_list */ + 247, /* (164) alter_table_option ::= TTL NK_INTEGER */ + 243, /* (165) col_name_list ::= col_name */ + 243, /* (166) col_name_list ::= col_name_list NK_COMMA col_name */ + 248, /* (167) col_name ::= column_name */ + 210, /* (168) cmd ::= SHOW DNODES */ + 210, /* (169) cmd ::= SHOW USERS */ + 210, /* (170) cmd ::= SHOW DATABASES */ + 210, /* (171) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + 210, /* (172) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + 210, /* (173) cmd ::= SHOW db_name_cond_opt VGROUPS */ + 210, /* (174) cmd ::= SHOW MNODES */ + 210, /* (175) cmd ::= SHOW MODULES */ + 210, /* (176) cmd ::= SHOW QNODES */ + 210, /* (177) cmd ::= SHOW FUNCTIONS */ + 210, /* (178) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + 210, /* (179) cmd ::= SHOW STREAMS */ + 210, /* (180) cmd ::= SHOW ACCOUNTS */ + 210, /* (181) cmd ::= SHOW APPS */ + 210, /* (182) cmd ::= SHOW CONNECTIONS */ + 210, /* (183) cmd ::= SHOW LICENCE */ + 210, /* (184) cmd ::= SHOW GRANTS */ + 210, /* (185) cmd ::= SHOW CREATE DATABASE db_name */ + 210, /* (186) cmd ::= SHOW CREATE TABLE full_table_name */ + 210, /* (187) cmd ::= SHOW CREATE STABLE full_table_name */ + 210, /* (188) cmd ::= SHOW QUERIES */ + 210, /* (189) cmd ::= SHOW SCORES */ + 210, /* (190) cmd ::= SHOW TOPICS */ + 210, /* (191) cmd ::= SHOW VARIABLES */ + 210, /* (192) cmd ::= SHOW BNODES */ + 210, /* (193) cmd ::= SHOW SNODES */ + 249, /* (194) db_name_cond_opt ::= */ + 249, /* (195) db_name_cond_opt ::= db_name NK_DOT */ + 250, /* (196) like_pattern_opt ::= */ + 250, /* (197) like_pattern_opt ::= LIKE NK_STRING */ + 251, /* (198) table_name_cond ::= table_name */ + 252, /* (199) from_db_opt ::= */ + 252, /* (200) from_db_opt ::= FROM db_name */ + 246, /* (201) func_name_list ::= func_name */ + 246, /* (202) func_name_list ::= func_name_list NK_COMMA col_name */ + 253, /* (203) func_name ::= function_name */ + 210, /* (204) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + 210, /* (205) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ + 210, /* (206) cmd ::= DROP INDEX exists_opt index_name ON table_name */ + 256, /* (207) index_options ::= */ + 256, /* (208) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + 256, /* (209) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + 257, /* (210) func_list ::= func */ + 257, /* (211) func_list ::= func_list NK_COMMA func */ + 260, /* (212) func ::= function_name NK_LP expression_list NK_RP */ + 210, /* (213) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + 210, /* (214) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ + 210, /* (215) cmd ::= DROP TOPIC exists_opt topic_name */ + 210, /* (216) cmd ::= DESC full_table_name */ + 210, /* (217) cmd ::= DESCRIBE full_table_name */ + 210, /* (218) cmd ::= RESET QUERY CACHE */ + 210, /* (219) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + 264, /* (220) analyze_opt ::= */ + 264, /* (221) analyze_opt ::= ANALYZE */ + 265, /* (222) explain_options ::= */ + 265, /* (223) explain_options ::= explain_options VERBOSE NK_BOOL */ + 265, /* (224) explain_options ::= explain_options RATIO NK_FLOAT */ + 210, /* (225) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ + 210, /* (226) cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + 210, /* (227) cmd ::= DROP FUNCTION function_name */ + 266, /* (228) agg_func_opt ::= */ + 266, /* (229) agg_func_opt ::= AGGREGATE */ + 267, /* (230) bufsize_opt ::= */ + 267, /* (231) bufsize_opt ::= BUFSIZE NK_INTEGER */ + 210, /* (232) cmd ::= CREATE STREAM stream_name INTO table_name AS query_expression */ + 210, /* (233) cmd ::= DROP STREAM stream_name */ + 210, /* (234) cmd ::= KILL CONNECTION NK_INTEGER */ + 210, /* (235) cmd ::= KILL QUERY NK_INTEGER */ + 210, /* (236) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + 210, /* (237) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + 210, /* (238) cmd ::= SPLIT VGROUP NK_INTEGER */ + 269, /* (239) dnode_list ::= DNODE NK_INTEGER */ + 269, /* (240) dnode_list ::= dnode_list DNODE NK_INTEGER */ + 210, /* (241) cmd ::= SYNCDB db_name REPLICA */ + 210, /* (242) cmd ::= query_expression */ + 213, /* (243) literal ::= NK_INTEGER */ + 213, /* (244) literal ::= NK_FLOAT */ + 213, /* (245) literal ::= NK_STRING */ + 213, /* (246) literal ::= NK_BOOL */ + 213, /* (247) literal ::= TIMESTAMP NK_STRING */ + 213, /* (248) literal ::= duration_literal */ + 213, /* (249) literal ::= NULL */ + 258, /* (250) duration_literal ::= NK_VARIABLE */ + 270, /* (251) signed ::= NK_INTEGER */ + 270, /* (252) signed ::= NK_PLUS NK_INTEGER */ + 270, /* (253) signed ::= NK_MINUS NK_INTEGER */ + 270, /* (254) signed ::= NK_FLOAT */ + 270, /* (255) signed ::= NK_PLUS NK_FLOAT */ + 270, /* (256) signed ::= NK_MINUS NK_FLOAT */ + 271, /* (257) signed_literal ::= signed */ + 271, /* (258) signed_literal ::= NK_STRING */ + 271, /* (259) signed_literal ::= NK_BOOL */ + 271, /* (260) signed_literal ::= TIMESTAMP NK_STRING */ + 271, /* (261) signed_literal ::= duration_literal */ + 271, /* (262) signed_literal ::= NULL */ + 241, /* (263) literal_list ::= signed_literal */ + 241, /* (264) literal_list ::= literal_list NK_COMMA signed_literal */ + 219, /* (265) db_name ::= NK_ID */ + 244, /* (266) table_name ::= NK_ID */ + 237, /* (267) column_name ::= NK_ID */ + 254, /* (268) function_name ::= NK_ID */ + 254, /* (269) function_name ::= FIRST */ + 254, /* (270) function_name ::= LAST */ + 254, /* (271) function_name ::= NOW */ + 254, /* (272) function_name ::= TODAY */ + 272, /* (273) table_alias ::= NK_ID */ + 273, /* (274) column_alias ::= NK_ID */ + 215, /* (275) user_name ::= NK_ID */ + 255, /* (276) index_name ::= NK_ID */ + 262, /* (277) topic_name ::= NK_ID */ + 268, /* (278) stream_name ::= NK_ID */ + 274, /* (279) expression ::= literal */ + 274, /* (280) expression ::= pseudo_column */ + 274, /* (281) expression ::= column_reference */ + 274, /* (282) expression ::= function_name NK_LP expression_list NK_RP */ + 274, /* (283) expression ::= function_name NK_LP NK_STAR NK_RP */ + 274, /* (284) expression ::= function_name NK_LP NK_RP */ + 274, /* (285) expression ::= CAST NK_LP expression AS type_name NK_RP */ + 274, /* (286) expression ::= subquery */ + 274, /* (287) expression ::= NK_LP expression NK_RP */ + 274, /* (288) expression ::= NK_PLUS expression */ + 274, /* (289) expression ::= NK_MINUS expression */ + 274, /* (290) expression ::= expression NK_PLUS expression */ + 274, /* (291) expression ::= expression NK_MINUS expression */ + 274, /* (292) expression ::= expression NK_STAR expression */ + 274, /* (293) expression ::= expression NK_SLASH expression */ + 274, /* (294) expression ::= expression NK_REM expression */ + 261, /* (295) expression_list ::= expression */ + 261, /* (296) expression_list ::= expression_list NK_COMMA expression */ + 276, /* (297) column_reference ::= column_name */ + 276, /* (298) column_reference ::= table_name NK_DOT column_name */ + 275, /* (299) pseudo_column ::= ROWTS */ + 275, /* (300) pseudo_column ::= TBNAME */ + 275, /* (301) pseudo_column ::= QSTARTTS */ + 275, /* (302) pseudo_column ::= QENDTS */ + 275, /* (303) pseudo_column ::= WSTARTTS */ + 275, /* (304) pseudo_column ::= WENDTS */ + 275, /* (305) pseudo_column ::= WDURATION */ + 278, /* (306) predicate ::= expression compare_op expression */ + 278, /* (307) predicate ::= expression BETWEEN expression AND expression */ + 278, /* (308) predicate ::= expression NOT BETWEEN expression AND expression */ + 278, /* (309) predicate ::= expression IS NULL */ + 278, /* (310) predicate ::= expression IS NOT NULL */ + 278, /* (311) predicate ::= expression in_op in_predicate_value */ + 279, /* (312) compare_op ::= NK_LT */ + 279, /* (313) compare_op ::= NK_GT */ + 279, /* (314) compare_op ::= NK_LE */ + 279, /* (315) compare_op ::= NK_GE */ + 279, /* (316) compare_op ::= NK_NE */ + 279, /* (317) compare_op ::= NK_EQ */ + 279, /* (318) compare_op ::= LIKE */ + 279, /* (319) compare_op ::= NOT LIKE */ + 279, /* (320) compare_op ::= MATCH */ + 279, /* (321) compare_op ::= NMATCH */ + 280, /* (322) in_op ::= IN */ + 280, /* (323) in_op ::= NOT IN */ + 281, /* (324) in_predicate_value ::= NK_LP expression_list NK_RP */ + 282, /* (325) boolean_value_expression ::= boolean_primary */ + 282, /* (326) boolean_value_expression ::= NOT boolean_primary */ + 282, /* (327) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + 282, /* (328) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + 283, /* (329) boolean_primary ::= predicate */ + 283, /* (330) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + 284, /* (331) common_expression ::= expression */ + 284, /* (332) common_expression ::= boolean_value_expression */ + 285, /* (333) from_clause ::= FROM table_reference_list */ + 286, /* (334) table_reference_list ::= table_reference */ + 286, /* (335) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + 287, /* (336) table_reference ::= table_primary */ + 287, /* (337) table_reference ::= joined_table */ + 288, /* (338) table_primary ::= table_name alias_opt */ + 288, /* (339) table_primary ::= db_name NK_DOT table_name alias_opt */ + 288, /* (340) table_primary ::= subquery alias_opt */ + 288, /* (341) table_primary ::= parenthesized_joined_table */ + 290, /* (342) alias_opt ::= */ + 290, /* (343) alias_opt ::= table_alias */ + 290, /* (344) alias_opt ::= AS table_alias */ + 291, /* (345) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + 291, /* (346) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + 289, /* (347) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + 292, /* (348) join_type ::= */ + 292, /* (349) join_type ::= INNER */ + 294, /* (350) 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 */ + 295, /* (351) set_quantifier_opt ::= */ + 295, /* (352) set_quantifier_opt ::= DISTINCT */ + 295, /* (353) set_quantifier_opt ::= ALL */ + 296, /* (354) select_list ::= NK_STAR */ + 296, /* (355) select_list ::= select_sublist */ + 302, /* (356) select_sublist ::= select_item */ + 302, /* (357) select_sublist ::= select_sublist NK_COMMA select_item */ + 303, /* (358) select_item ::= common_expression */ + 303, /* (359) select_item ::= common_expression column_alias */ + 303, /* (360) select_item ::= common_expression AS column_alias */ + 303, /* (361) select_item ::= table_name NK_DOT NK_STAR */ + 297, /* (362) where_clause_opt ::= */ + 297, /* (363) where_clause_opt ::= WHERE search_condition */ + 298, /* (364) partition_by_clause_opt ::= */ + 298, /* (365) partition_by_clause_opt ::= PARTITION BY expression_list */ + 299, /* (366) twindow_clause_opt ::= */ + 299, /* (367) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + 299, /* (368) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + 299, /* (369) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + 299, /* (370) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + 259, /* (371) sliding_opt ::= */ + 259, /* (372) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + 304, /* (373) fill_opt ::= */ + 304, /* (374) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + 304, /* (375) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + 305, /* (376) fill_mode ::= NONE */ + 305, /* (377) fill_mode ::= PREV */ + 305, /* (378) fill_mode ::= NULL */ + 305, /* (379) fill_mode ::= LINEAR */ + 305, /* (380) fill_mode ::= NEXT */ + 300, /* (381) group_by_clause_opt ::= */ + 300, /* (382) group_by_clause_opt ::= GROUP BY group_by_list */ + 306, /* (383) group_by_list ::= expression */ + 306, /* (384) group_by_list ::= group_by_list NK_COMMA expression */ + 301, /* (385) having_clause_opt ::= */ + 301, /* (386) having_clause_opt ::= HAVING search_condition */ + 263, /* (387) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + 307, /* (388) query_expression_body ::= query_primary */ + 307, /* (389) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + 311, /* (390) query_primary ::= query_specification */ + 308, /* (391) order_by_clause_opt ::= */ + 308, /* (392) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 309, /* (393) slimit_clause_opt ::= */ + 309, /* (394) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + 309, /* (395) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + 309, /* (396) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 310, /* (397) limit_clause_opt ::= */ + 310, /* (398) limit_clause_opt ::= LIMIT NK_INTEGER */ + 310, /* (399) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + 310, /* (400) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 277, /* (401) subquery ::= NK_LP query_expression NK_RP */ + 293, /* (402) search_condition ::= common_expression */ + 312, /* (403) sort_specification_list ::= sort_specification */ + 312, /* (404) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + 313, /* (405) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + 314, /* (406) ordering_specification_opt ::= */ + 314, /* (407) ordering_specification_opt ::= ASC */ + 314, /* (408) ordering_specification_opt ::= DESC */ + 315, /* (409) null_ordering_opt ::= */ + 315, /* (410) null_ordering_opt ::= NULLS FIRST */ + 315, /* (411) null_ordering_opt ::= NULLS LAST */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -2779,146 +2786,147 @@ static const signed char yyRuleInfoNRhs[] = { -1, /* (268) function_name ::= NK_ID */ -1, /* (269) function_name ::= FIRST */ -1, /* (270) function_name ::= LAST */ - -1, /* (271) table_alias ::= NK_ID */ - -1, /* (272) column_alias ::= NK_ID */ - -1, /* (273) user_name ::= NK_ID */ - -1, /* (274) index_name ::= NK_ID */ - -1, /* (275) topic_name ::= NK_ID */ - -1, /* (276) stream_name ::= NK_ID */ - -1, /* (277) expression ::= literal */ - -1, /* (278) expression ::= pseudo_column */ - -1, /* (279) expression ::= column_reference */ - -4, /* (280) expression ::= function_name NK_LP expression_list NK_RP */ - -4, /* (281) expression ::= function_name NK_LP NK_STAR NK_RP */ - -6, /* (282) expression ::= function_name NK_LP expression AS type_name NK_RP */ - -1, /* (283) expression ::= subquery */ - -3, /* (284) expression ::= NK_LP expression NK_RP */ - -2, /* (285) expression ::= NK_PLUS expression */ - -2, /* (286) expression ::= NK_MINUS expression */ - -3, /* (287) expression ::= expression NK_PLUS expression */ - -3, /* (288) expression ::= expression NK_MINUS expression */ - -3, /* (289) expression ::= expression NK_STAR expression */ - -3, /* (290) expression ::= expression NK_SLASH expression */ - -3, /* (291) expression ::= expression NK_REM expression */ - -1, /* (292) expression_list ::= expression */ - -3, /* (293) expression_list ::= expression_list NK_COMMA expression */ - -1, /* (294) column_reference ::= column_name */ - -3, /* (295) column_reference ::= table_name NK_DOT column_name */ - -1, /* (296) pseudo_column ::= NOW */ - -1, /* (297) pseudo_column ::= TODAY */ - -1, /* (298) pseudo_column ::= ROWTS */ - -1, /* (299) pseudo_column ::= TBNAME */ - -1, /* (300) pseudo_column ::= QSTARTTS */ - -1, /* (301) pseudo_column ::= QENDTS */ - -1, /* (302) pseudo_column ::= WSTARTTS */ - -1, /* (303) pseudo_column ::= WENDTS */ - -1, /* (304) pseudo_column ::= WDURATION */ - -3, /* (305) predicate ::= expression compare_op expression */ - -5, /* (306) predicate ::= expression BETWEEN expression AND expression */ - -6, /* (307) predicate ::= expression NOT BETWEEN expression AND expression */ - -3, /* (308) predicate ::= expression IS NULL */ - -4, /* (309) predicate ::= expression IS NOT NULL */ - -3, /* (310) predicate ::= expression in_op in_predicate_value */ - -1, /* (311) compare_op ::= NK_LT */ - -1, /* (312) compare_op ::= NK_GT */ - -1, /* (313) compare_op ::= NK_LE */ - -1, /* (314) compare_op ::= NK_GE */ - -1, /* (315) compare_op ::= NK_NE */ - -1, /* (316) compare_op ::= NK_EQ */ - -1, /* (317) compare_op ::= LIKE */ - -2, /* (318) compare_op ::= NOT LIKE */ - -1, /* (319) compare_op ::= MATCH */ - -1, /* (320) compare_op ::= NMATCH */ - -1, /* (321) in_op ::= IN */ - -2, /* (322) in_op ::= NOT IN */ - -3, /* (323) in_predicate_value ::= NK_LP expression_list NK_RP */ - -1, /* (324) boolean_value_expression ::= boolean_primary */ - -2, /* (325) boolean_value_expression ::= NOT boolean_primary */ - -3, /* (326) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - -3, /* (327) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - -1, /* (328) boolean_primary ::= predicate */ - -3, /* (329) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - -1, /* (330) common_expression ::= expression */ - -1, /* (331) common_expression ::= boolean_value_expression */ - -2, /* (332) from_clause ::= FROM table_reference_list */ - -1, /* (333) table_reference_list ::= table_reference */ - -3, /* (334) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - -1, /* (335) table_reference ::= table_primary */ - -1, /* (336) table_reference ::= joined_table */ - -2, /* (337) table_primary ::= table_name alias_opt */ - -4, /* (338) table_primary ::= db_name NK_DOT table_name alias_opt */ - -2, /* (339) table_primary ::= subquery alias_opt */ - -1, /* (340) table_primary ::= parenthesized_joined_table */ - 0, /* (341) alias_opt ::= */ - -1, /* (342) alias_opt ::= table_alias */ - -2, /* (343) alias_opt ::= AS table_alias */ - -3, /* (344) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - -3, /* (345) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - -6, /* (346) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - 0, /* (347) join_type ::= */ - -1, /* (348) join_type ::= INNER */ - -9, /* (349) 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, /* (350) set_quantifier_opt ::= */ - -1, /* (351) set_quantifier_opt ::= DISTINCT */ - -1, /* (352) set_quantifier_opt ::= ALL */ - -1, /* (353) select_list ::= NK_STAR */ - -1, /* (354) select_list ::= select_sublist */ - -1, /* (355) select_sublist ::= select_item */ - -3, /* (356) select_sublist ::= select_sublist NK_COMMA select_item */ - -1, /* (357) select_item ::= common_expression */ - -2, /* (358) select_item ::= common_expression column_alias */ - -3, /* (359) select_item ::= common_expression AS column_alias */ - -3, /* (360) select_item ::= table_name NK_DOT NK_STAR */ - 0, /* (361) where_clause_opt ::= */ - -2, /* (362) where_clause_opt ::= WHERE search_condition */ - 0, /* (363) partition_by_clause_opt ::= */ - -3, /* (364) partition_by_clause_opt ::= PARTITION BY expression_list */ - 0, /* (365) twindow_clause_opt ::= */ - -6, /* (366) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - -4, /* (367) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - -6, /* (368) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - -8, /* (369) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - 0, /* (370) sliding_opt ::= */ - -4, /* (371) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - 0, /* (372) fill_opt ::= */ - -4, /* (373) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - -6, /* (374) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - -1, /* (375) fill_mode ::= NONE */ - -1, /* (376) fill_mode ::= PREV */ - -1, /* (377) fill_mode ::= NULL */ - -1, /* (378) fill_mode ::= LINEAR */ - -1, /* (379) fill_mode ::= NEXT */ - 0, /* (380) group_by_clause_opt ::= */ - -3, /* (381) group_by_clause_opt ::= GROUP BY group_by_list */ - -1, /* (382) group_by_list ::= expression */ - -3, /* (383) group_by_list ::= group_by_list NK_COMMA expression */ - 0, /* (384) having_clause_opt ::= */ - -2, /* (385) having_clause_opt ::= HAVING search_condition */ - -4, /* (386) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - -1, /* (387) query_expression_body ::= query_primary */ - -4, /* (388) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - -1, /* (389) query_primary ::= query_specification */ - 0, /* (390) order_by_clause_opt ::= */ - -3, /* (391) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 0, /* (392) slimit_clause_opt ::= */ - -2, /* (393) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - -4, /* (394) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - -4, /* (395) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 0, /* (396) limit_clause_opt ::= */ - -2, /* (397) limit_clause_opt ::= LIMIT NK_INTEGER */ - -4, /* (398) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - -4, /* (399) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - -3, /* (400) subquery ::= NK_LP query_expression NK_RP */ - -1, /* (401) search_condition ::= common_expression */ - -1, /* (402) sort_specification_list ::= sort_specification */ - -3, /* (403) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - -3, /* (404) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - 0, /* (405) ordering_specification_opt ::= */ - -1, /* (406) ordering_specification_opt ::= ASC */ - -1, /* (407) ordering_specification_opt ::= DESC */ - 0, /* (408) null_ordering_opt ::= */ - -2, /* (409) null_ordering_opt ::= NULLS FIRST */ - -2, /* (410) null_ordering_opt ::= NULLS LAST */ + -1, /* (271) function_name ::= NOW */ + -1, /* (272) function_name ::= TODAY */ + -1, /* (273) table_alias ::= NK_ID */ + -1, /* (274) column_alias ::= NK_ID */ + -1, /* (275) user_name ::= NK_ID */ + -1, /* (276) index_name ::= NK_ID */ + -1, /* (277) topic_name ::= NK_ID */ + -1, /* (278) stream_name ::= NK_ID */ + -1, /* (279) expression ::= literal */ + -1, /* (280) expression ::= pseudo_column */ + -1, /* (281) expression ::= column_reference */ + -4, /* (282) expression ::= function_name NK_LP expression_list NK_RP */ + -4, /* (283) expression ::= function_name NK_LP NK_STAR NK_RP */ + -3, /* (284) expression ::= function_name NK_LP NK_RP */ + -6, /* (285) expression ::= CAST NK_LP expression AS type_name NK_RP */ + -1, /* (286) expression ::= subquery */ + -3, /* (287) expression ::= NK_LP expression NK_RP */ + -2, /* (288) expression ::= NK_PLUS expression */ + -2, /* (289) expression ::= NK_MINUS expression */ + -3, /* (290) expression ::= expression NK_PLUS expression */ + -3, /* (291) expression ::= expression NK_MINUS expression */ + -3, /* (292) expression ::= expression NK_STAR expression */ + -3, /* (293) expression ::= expression NK_SLASH expression */ + -3, /* (294) expression ::= expression NK_REM expression */ + -1, /* (295) expression_list ::= expression */ + -3, /* (296) expression_list ::= expression_list NK_COMMA expression */ + -1, /* (297) column_reference ::= column_name */ + -3, /* (298) column_reference ::= table_name NK_DOT column_name */ + -1, /* (299) pseudo_column ::= ROWTS */ + -1, /* (300) pseudo_column ::= TBNAME */ + -1, /* (301) pseudo_column ::= QSTARTTS */ + -1, /* (302) pseudo_column ::= QENDTS */ + -1, /* (303) pseudo_column ::= WSTARTTS */ + -1, /* (304) pseudo_column ::= WENDTS */ + -1, /* (305) pseudo_column ::= WDURATION */ + -3, /* (306) predicate ::= expression compare_op expression */ + -5, /* (307) predicate ::= expression BETWEEN expression AND expression */ + -6, /* (308) predicate ::= expression NOT BETWEEN expression AND expression */ + -3, /* (309) predicate ::= expression IS NULL */ + -4, /* (310) predicate ::= expression IS NOT NULL */ + -3, /* (311) predicate ::= expression in_op in_predicate_value */ + -1, /* (312) compare_op ::= NK_LT */ + -1, /* (313) compare_op ::= NK_GT */ + -1, /* (314) compare_op ::= NK_LE */ + -1, /* (315) compare_op ::= NK_GE */ + -1, /* (316) compare_op ::= NK_NE */ + -1, /* (317) compare_op ::= NK_EQ */ + -1, /* (318) compare_op ::= LIKE */ + -2, /* (319) compare_op ::= NOT LIKE */ + -1, /* (320) compare_op ::= MATCH */ + -1, /* (321) compare_op ::= NMATCH */ + -1, /* (322) in_op ::= IN */ + -2, /* (323) in_op ::= NOT IN */ + -3, /* (324) in_predicate_value ::= NK_LP expression_list NK_RP */ + -1, /* (325) boolean_value_expression ::= boolean_primary */ + -2, /* (326) boolean_value_expression ::= NOT boolean_primary */ + -3, /* (327) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + -3, /* (328) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + -1, /* (329) boolean_primary ::= predicate */ + -3, /* (330) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + -1, /* (331) common_expression ::= expression */ + -1, /* (332) common_expression ::= boolean_value_expression */ + -2, /* (333) from_clause ::= FROM table_reference_list */ + -1, /* (334) table_reference_list ::= table_reference */ + -3, /* (335) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + -1, /* (336) table_reference ::= table_primary */ + -1, /* (337) table_reference ::= joined_table */ + -2, /* (338) table_primary ::= table_name alias_opt */ + -4, /* (339) table_primary ::= db_name NK_DOT table_name alias_opt */ + -2, /* (340) table_primary ::= subquery alias_opt */ + -1, /* (341) table_primary ::= parenthesized_joined_table */ + 0, /* (342) alias_opt ::= */ + -1, /* (343) alias_opt ::= table_alias */ + -2, /* (344) alias_opt ::= AS table_alias */ + -3, /* (345) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + -3, /* (346) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + -6, /* (347) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + 0, /* (348) join_type ::= */ + -1, /* (349) join_type ::= INNER */ + -9, /* (350) 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, /* (351) set_quantifier_opt ::= */ + -1, /* (352) set_quantifier_opt ::= DISTINCT */ + -1, /* (353) set_quantifier_opt ::= ALL */ + -1, /* (354) select_list ::= NK_STAR */ + -1, /* (355) select_list ::= select_sublist */ + -1, /* (356) select_sublist ::= select_item */ + -3, /* (357) select_sublist ::= select_sublist NK_COMMA select_item */ + -1, /* (358) select_item ::= common_expression */ + -2, /* (359) select_item ::= common_expression column_alias */ + -3, /* (360) select_item ::= common_expression AS column_alias */ + -3, /* (361) select_item ::= table_name NK_DOT NK_STAR */ + 0, /* (362) where_clause_opt ::= */ + -2, /* (363) where_clause_opt ::= WHERE search_condition */ + 0, /* (364) partition_by_clause_opt ::= */ + -3, /* (365) partition_by_clause_opt ::= PARTITION BY expression_list */ + 0, /* (366) twindow_clause_opt ::= */ + -6, /* (367) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + -4, /* (368) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + -6, /* (369) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + -8, /* (370) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + 0, /* (371) sliding_opt ::= */ + -4, /* (372) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + 0, /* (373) fill_opt ::= */ + -4, /* (374) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + -6, /* (375) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + -1, /* (376) fill_mode ::= NONE */ + -1, /* (377) fill_mode ::= PREV */ + -1, /* (378) fill_mode ::= NULL */ + -1, /* (379) fill_mode ::= LINEAR */ + -1, /* (380) fill_mode ::= NEXT */ + 0, /* (381) group_by_clause_opt ::= */ + -3, /* (382) group_by_clause_opt ::= GROUP BY group_by_list */ + -1, /* (383) group_by_list ::= expression */ + -3, /* (384) group_by_list ::= group_by_list NK_COMMA expression */ + 0, /* (385) having_clause_opt ::= */ + -2, /* (386) having_clause_opt ::= HAVING search_condition */ + -4, /* (387) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + -1, /* (388) query_expression_body ::= query_primary */ + -4, /* (389) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + -1, /* (390) query_primary ::= query_specification */ + 0, /* (391) order_by_clause_opt ::= */ + -3, /* (392) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 0, /* (393) slimit_clause_opt ::= */ + -2, /* (394) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + -4, /* (395) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + -4, /* (396) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 0, /* (397) limit_clause_opt ::= */ + -2, /* (398) limit_clause_opt ::= LIMIT NK_INTEGER */ + -4, /* (399) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + -4, /* (400) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + -3, /* (401) subquery ::= NK_LP query_expression NK_RP */ + -1, /* (402) search_condition ::= common_expression */ + -1, /* (403) sort_specification_list ::= sort_specification */ + -3, /* (404) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + -3, /* (405) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + 0, /* (406) ordering_specification_opt ::= */ + -1, /* (407) ordering_specification_opt ::= ASC */ + -1, /* (408) ordering_specification_opt ::= DESC */ + 0, /* (409) null_ordering_opt ::= */ + -2, /* (410) null_ordering_opt ::= NULLS FIRST */ + -2, /* (411) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3010,11 +3018,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,210,&yymsp[0].minor); + yy_destructor(yypParser,211,&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,211,&yymsp[0].minor); + yy_destructor(yypParser,212,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3028,20 +3036,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,210,&yymsp[-2].minor); +{ yy_destructor(yypParser,211,&yymsp[-2].minor); { } - yy_destructor(yypParser,212,&yymsp[0].minor); + yy_destructor(yypParser,213,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,213,&yymsp[0].minor); +{ yy_destructor(yypParser,214,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,211,&yymsp[-1].minor); +{ yy_destructor(yypParser,212,&yymsp[-1].minor); { } - yy_destructor(yypParser,213,&yymsp[0].minor); + yy_destructor(yypParser,214,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3055,31 +3063,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,212,&yymsp[0].minor); + yy_destructor(yypParser,213,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy29, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy409, &yymsp[0].minor.yy0); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy29, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy409, 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.yy29, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy409, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy29); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy409); } break; case 28: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy29, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy409, NULL); } break; case 29: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy29, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy409, &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.yy29); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy409); } break; case 32: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3102,14 +3110,16 @@ static YYACTIONTYPE yy_reduce( 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: /* table_alias ::= NK_ID */ yytestcase(yyruleno==271); - case 272: /* column_alias ::= NK_ID */ yytestcase(yyruleno==272); - case 273: /* user_name ::= NK_ID */ yytestcase(yyruleno==273); - case 274: /* index_name ::= NK_ID */ yytestcase(yyruleno==274); - case 275: /* topic_name ::= NK_ID */ yytestcase(yyruleno==275); - case 276: /* stream_name ::= NK_ID */ yytestcase(yyruleno==276); -{ yylhsminor.yy29 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy29 = yylhsminor.yy29; + case 271: /* function_name ::= NOW */ yytestcase(yyruleno==271); + case 272: /* function_name ::= TODAY */ yytestcase(yyruleno==272); + case 273: /* table_alias ::= NK_ID */ yytestcase(yyruleno==273); + case 274: /* column_alias ::= NK_ID */ yytestcase(yyruleno==274); + case 275: /* user_name ::= NK_ID */ yytestcase(yyruleno==275); + case 276: /* index_name ::= NK_ID */ yytestcase(yyruleno==276); + case 277: /* topic_name ::= NK_ID */ yytestcase(yyruleno==277); + case 278: /* stream_name ::= NK_ID */ yytestcase(yyruleno==278); +{ yylhsminor.yy409 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy409 = yylhsminor.yy409; break; case 39: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3142,156 +3152,156 @@ 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.yy47, &yymsp[-1].minor.yy29, yymsp[0].minor.yy182); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy121, &yymsp[-1].minor.yy409, yymsp[0].minor.yy504); } break; case 50: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy47, &yymsp[0].minor.yy29); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy121, &yymsp[0].minor.yy409); } break; case 51: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy29); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy409); } break; case 52: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy29, yymsp[0].minor.yy182); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy409, yymsp[0].minor.yy504); } break; case 53: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy47 = true; } +{ yymsp[-2].minor.yy121 = 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 350: /* set_quantifier_opt ::= */ yytestcase(yyruleno==350); -{ yymsp[1].minor.yy47 = false; } + case 351: /* set_quantifier_opt ::= */ yytestcase(yyruleno==351); +{ yymsp[1].minor.yy121 = false; } break; case 55: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy47 = true; } +{ yymsp[-1].minor.yy121 = true; } break; case 57: /* db_options ::= */ -{ yymsp[1].minor.yy182 = createDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy504 = createDatabaseOptions(pCxt); } break; case 58: /* db_options ::= db_options BLOCKS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pNumOfBlocks = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pNumOfBlocks = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 59: /* db_options ::= db_options CACHE NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pCacheBlockSize = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pCacheBlockSize = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 60: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pCachelast = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pCachelast = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 61: /* db_options ::= db_options COMP NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pCompressionLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pCompressionLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 62: /* db_options ::= db_options DAYS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pDaysPerFile = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pDaysPerFile = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 63: /* db_options ::= db_options DAYS NK_VARIABLE */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pDaysPerFile = (SValueNode*)createDurationValueNode(pCxt, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pDaysPerFile = (SValueNode*)createDurationValueNode(pCxt, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 64: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pFsyncPeriod = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pFsyncPeriod = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 65: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pMaxRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pMaxRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 66: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pMinRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pMinRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; 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.yy182)->pKeep = yymsp[0].minor.yy334; yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pKeep = yymsp[0].minor.yy488; yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 69: /* db_options ::= db_options PRECISION NK_STRING */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pPrecision = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pPrecision = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 70: /* db_options ::= db_options QUORUM NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pQuorum = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pQuorum = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 71: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pReplica = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pReplica = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 72: /* db_options ::= db_options TTL NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 73: /* db_options ::= db_options WAL NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pWalLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pWalLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 74: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pNumOfVgroups = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pNumOfVgroups = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 75: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pSingleStable = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pSingleStable = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 76: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pStreamMode = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pStreamMode = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 77: /* db_options ::= db_options RETENTIONS retention_list */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy182)->pRetentions = yymsp[0].minor.yy334; yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy504)->pRetentions = yymsp[0].minor.yy488; yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 78: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy182 = createDatabaseOptions(pCxt); yylhsminor.yy182 = setDatabaseAlterOption(pCxt, yylhsminor.yy182, &yymsp[0].minor.yy515); } - yymsp[0].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createDatabaseOptions(pCxt); yylhsminor.yy504 = setDatabaseAlterOption(pCxt, yylhsminor.yy504, &yymsp[0].minor.yy21); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 79: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy182 = setDatabaseAlterOption(pCxt, yymsp[-1].minor.yy182, &yymsp[0].minor.yy515); } - yymsp[-1].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = setDatabaseAlterOption(pCxt, yymsp[-1].minor.yy504, &yymsp[0].minor.yy21); } + yymsp[-1].minor.yy504 = yylhsminor.yy504; break; case 80: /* alter_db_option ::= BLOCKS NK_INTEGER */ -{ yymsp[-1].minor.yy515.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy515.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy21.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy21.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 81: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy515.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy515.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy21.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy21.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.yy515.type = DB_OPTION_KEEP; yymsp[-1].minor.yy515.pList = yymsp[0].minor.yy334; } +{ yymsp[-1].minor.yy21.type = DB_OPTION_KEEP; yymsp[-1].minor.yy21.pList = yymsp[0].minor.yy488; } break; case 84: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy515.type = DB_OPTION_WAL; yymsp[-1].minor.yy515.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy21.type = DB_OPTION_WAL; yymsp[-1].minor.yy21.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 85: /* alter_db_option ::= QUORUM NK_INTEGER */ -{ yymsp[-1].minor.yy515.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy515.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy21.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy21.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 86: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy515.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy515.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy21.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy21.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 87: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy515.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy515.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy21.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy21.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 88: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy334 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy334 = yylhsminor.yy334; +{ yylhsminor.yy488 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy488 = yylhsminor.yy488; break; case 89: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ case 240: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==240); -{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy334 = yylhsminor.yy334; +{ yylhsminor.yy488 = addNodeToList(pCxt, yymsp[-2].minor.yy488, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy488 = yylhsminor.yy488; break; case 90: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy334 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy334 = yylhsminor.yy334; +{ yylhsminor.yy488 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy488 = yylhsminor.yy488; break; case 91: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy334 = yylhsminor.yy334; +{ yylhsminor.yy488 = addNodeToList(pCxt, yymsp[-2].minor.yy488, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy488 = yylhsminor.yy488; break; case 92: /* retention_list ::= retention */ case 112: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==112); @@ -3301,10 +3311,10 @@ static YYACTIONTYPE yy_reduce( 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 355: /* select_sublist ::= select_item */ yytestcase(yyruleno==355); - case 402: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==402); -{ yylhsminor.yy334 = createNodeList(pCxt, yymsp[0].minor.yy182); } - yymsp[0].minor.yy334 = yylhsminor.yy334; + case 356: /* select_sublist ::= select_item */ yytestcase(yyruleno==356); + case 403: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==403); +{ yylhsminor.yy488 = createNodeList(pCxt, yymsp[0].minor.yy504); } + yymsp[0].minor.yy488 = yylhsminor.yy488; 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); @@ -3312,238 +3322,238 @@ static YYACTIONTYPE yy_reduce( 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 356: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==356); - case 403: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==403); -{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, yymsp[0].minor.yy182); } - yymsp[-2].minor.yy334 = yylhsminor.yy334; + case 357: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==357); + case 404: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==404); +{ yylhsminor.yy488 = addNodeToList(pCxt, yymsp[-2].minor.yy488, yymsp[0].minor.yy504); } + yymsp[-2].minor.yy488 = yylhsminor.yy488; break; case 94: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy182 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; 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.yy47, yymsp[-5].minor.yy182, yymsp[-3].minor.yy334, yymsp[-1].minor.yy334, yymsp[0].minor.yy182); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy121, yymsp[-5].minor.yy504, yymsp[-3].minor.yy488, yymsp[-1].minor.yy488, yymsp[0].minor.yy504); } break; case 96: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy334); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy488); } break; case 98: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy334); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy488); } break; case 99: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy47, yymsp[0].minor.yy182); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy121, yymsp[0].minor.yy504); } 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.yy182; } +{ pCxt->pRootNode = yymsp[0].minor.yy504; } break; case 102: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy182 = createAlterTableOption(pCxt, yymsp[-1].minor.yy182, yymsp[0].minor.yy182); } - yymsp[-1].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createAlterTableOption(pCxt, yymsp[-1].minor.yy504, yymsp[0].minor.yy504); } + yymsp[-1].minor.yy504 = yylhsminor.yy504; break; case 103: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy182 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy182, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy29, yymsp[0].minor.yy574); } - yymsp[-4].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy504, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy409, yymsp[0].minor.yy160); } + yymsp[-4].minor.yy504 = yylhsminor.yy504; break; case 104: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy182 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy182, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy29); } - yymsp[-3].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy504, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy409); } + yymsp[-3].minor.yy504 = yylhsminor.yy504; break; case 105: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy182 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy182, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy29, yymsp[0].minor.yy574); } - yymsp[-4].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy504, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy409, yymsp[0].minor.yy160); } + yymsp[-4].minor.yy504 = yylhsminor.yy504; break; case 106: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy182 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy182, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy29, &yymsp[0].minor.yy29); } - yymsp[-4].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy504, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy409, &yymsp[0].minor.yy409); } + yymsp[-4].minor.yy504 = yylhsminor.yy504; break; case 107: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy182 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy182, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy29, yymsp[0].minor.yy574); } - yymsp[-4].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy504, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy409, yymsp[0].minor.yy160); } + yymsp[-4].minor.yy504 = yylhsminor.yy504; break; case 108: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy182 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy182, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy29); } - yymsp[-3].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy504, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy409); } + yymsp[-3].minor.yy504 = yylhsminor.yy504; break; case 109: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy182 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy182, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy29, yymsp[0].minor.yy574); } - yymsp[-4].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy504, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy409, yymsp[0].minor.yy160); } + yymsp[-4].minor.yy504 = yylhsminor.yy504; break; case 110: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy182 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy182, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy29, &yymsp[0].minor.yy29); } - yymsp[-4].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy504, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy409, &yymsp[0].minor.yy409); } + yymsp[-4].minor.yy504 = yylhsminor.yy504; break; case 111: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ -{ yylhsminor.yy182 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy182, &yymsp[-2].minor.yy29, yymsp[0].minor.yy182); } - yymsp[-5].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy504, &yymsp[-2].minor.yy409, yymsp[0].minor.yy504); } + yymsp[-5].minor.yy504 = yylhsminor.yy504; 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.yy334 = addNodeToList(pCxt, yymsp[-1].minor.yy334, yymsp[0].minor.yy182); } - yymsp[-1].minor.yy334 = yylhsminor.yy334; +{ yylhsminor.yy488 = addNodeToList(pCxt, yymsp[-1].minor.yy488, yymsp[0].minor.yy504); } + yymsp[-1].minor.yy488 = yylhsminor.yy488; 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.yy182 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy47, yymsp[-7].minor.yy182, yymsp[-5].minor.yy182, yymsp[-4].minor.yy334, yymsp[-1].minor.yy334); } - yymsp[-8].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy121, yymsp[-7].minor.yy504, yymsp[-5].minor.yy504, yymsp[-4].minor.yy488, yymsp[-1].minor.yy488); } + yymsp[-8].minor.yy504 = yylhsminor.yy504; break; case 117: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy182 = createDropTableClause(pCxt, yymsp[-1].minor.yy47, yymsp[0].minor.yy182); } - yymsp[-1].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createDropTableClause(pCxt, yymsp[-1].minor.yy121, yymsp[0].minor.yy504); } + yymsp[-1].minor.yy504 = yylhsminor.yy504; break; case 118: /* specific_tags_opt ::= */ case 149: /* tags_def_opt ::= */ yytestcase(yyruleno==149); - case 363: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==363); - case 380: /* group_by_clause_opt ::= */ yytestcase(yyruleno==380); - case 390: /* order_by_clause_opt ::= */ yytestcase(yyruleno==390); -{ yymsp[1].minor.yy334 = NULL; } + case 364: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==364); + case 381: /* group_by_clause_opt ::= */ yytestcase(yyruleno==381); + case 391: /* order_by_clause_opt ::= */ yytestcase(yyruleno==391); +{ yymsp[1].minor.yy488 = NULL; } break; case 119: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy334 = yymsp[-1].minor.yy334; } +{ yymsp[-2].minor.yy488 = yymsp[-1].minor.yy488; } break; case 120: /* full_table_name ::= table_name */ -{ yylhsminor.yy182 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy29, NULL); } - yymsp[0].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy409, NULL); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 121: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy182 = createRealTableNode(pCxt, &yymsp[-2].minor.yy29, &yymsp[0].minor.yy29, NULL); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createRealTableNode(pCxt, &yymsp[-2].minor.yy409, &yymsp[0].minor.yy409, NULL); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 124: /* column_def ::= column_name type_name */ -{ yylhsminor.yy182 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy29, yymsp[0].minor.yy574, NULL); } - yymsp[-1].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy409, yymsp[0].minor.yy160, NULL); } + yymsp[-1].minor.yy504 = yylhsminor.yy504; break; case 125: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy182 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy29, yymsp[-2].minor.yy574, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy409, yymsp[-2].minor.yy160, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy504 = yylhsminor.yy504; break; case 126: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy160 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 127: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy160 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 128: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy160 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 129: /* type_name ::= INT */ case 130: /* type_name ::= INTEGER */ yytestcase(yyruleno==130); -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy160 = createDataType(TSDB_DATA_TYPE_INT); } break; case 131: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy160 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 132: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy160 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 133: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy160 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 134: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy574 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy160 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 135: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy160 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 136: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy574 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy160 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 137: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy574 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy160 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 138: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy574 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy160 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 139: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy574 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy160 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 140: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy574 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy160 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 141: /* type_name ::= JSON */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy160 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 142: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy574 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy160 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 143: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy160 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 144: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy160 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 145: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy574 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy160 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 146: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy160 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 147: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy574 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy160 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 148: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy574 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy160 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 150: /* tags_def_opt ::= tags_def */ - case 354: /* select_list ::= select_sublist */ yytestcase(yyruleno==354); -{ yylhsminor.yy334 = yymsp[0].minor.yy334; } - yymsp[0].minor.yy334 = yylhsminor.yy334; + case 355: /* select_list ::= select_sublist */ yytestcase(yyruleno==355); +{ yylhsminor.yy488 = yymsp[0].minor.yy488; } + yymsp[0].minor.yy488 = yylhsminor.yy488; break; case 151: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy334 = yymsp[-1].minor.yy334; } +{ yymsp[-3].minor.yy488 = yymsp[-1].minor.yy488; } break; case 152: /* table_options ::= */ -{ yymsp[1].minor.yy182 = createTableOptions(pCxt); } +{ yymsp[1].minor.yy504 = createTableOptions(pCxt); } break; case 153: /* table_options ::= table_options COMMENT NK_STRING */ -{ ((STableOptions*)yymsp[-2].minor.yy182)->pComments = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((STableOptions*)yymsp[-2].minor.yy504)->pComments = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 154: /* table_options ::= table_options KEEP integer_list */ -{ ((STableOptions*)yymsp[-2].minor.yy182)->pKeep = yymsp[0].minor.yy334; yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((STableOptions*)yymsp[-2].minor.yy504)->pKeep = yymsp[0].minor.yy488; yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 155: /* table_options ::= table_options TTL NK_INTEGER */ -{ ((STableOptions*)yymsp[-2].minor.yy182)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((STableOptions*)yymsp[-2].minor.yy504)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 156: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ ((STableOptions*)yymsp[-4].minor.yy182)->pSma = yymsp[-1].minor.yy334; yylhsminor.yy182 = yymsp[-4].minor.yy182; } - yymsp[-4].minor.yy182 = yylhsminor.yy182; +{ ((STableOptions*)yymsp[-4].minor.yy504)->pSma = yymsp[-1].minor.yy488; yylhsminor.yy504 = yymsp[-4].minor.yy504; } + yymsp[-4].minor.yy504 = yylhsminor.yy504; break; case 157: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ -{ ((STableOptions*)yymsp[-4].minor.yy182)->pFuncs = yymsp[-1].minor.yy334; yylhsminor.yy182 = yymsp[-4].minor.yy182; } - yymsp[-4].minor.yy182 = yylhsminor.yy182; +{ ((STableOptions*)yymsp[-4].minor.yy504)->pFuncs = yymsp[-1].minor.yy488; yylhsminor.yy504 = yymsp[-4].minor.yy504; } + yymsp[-4].minor.yy504 = yylhsminor.yy504; break; case 158: /* table_options ::= table_options FILE_FACTOR NK_FLOAT */ -{ ((STableOptions*)yymsp[-2].minor.yy182)->pFilesFactor = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((STableOptions*)yymsp[-2].minor.yy504)->pFilesFactor = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 159: /* table_options ::= table_options DELAY NK_INTEGER */ -{ ((STableOptions*)yymsp[-2].minor.yy182)->pDelay = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy182 = yymsp[-2].minor.yy182; } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ ((STableOptions*)yymsp[-2].minor.yy504)->pDelay = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy504 = yymsp[-2].minor.yy504; } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 160: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy182 = createTableOptions(pCxt); yylhsminor.yy182 = setTableAlterOption(pCxt, yylhsminor.yy182, &yymsp[0].minor.yy515); } - yymsp[0].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createTableOptions(pCxt); yylhsminor.yy504 = setTableAlterOption(pCxt, yylhsminor.yy504, &yymsp[0].minor.yy21); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 161: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy182 = setTableAlterOption(pCxt, yymsp[-1].minor.yy182, &yymsp[0].minor.yy515); } - yymsp[-1].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = setTableAlterOption(pCxt, yymsp[-1].minor.yy504, &yymsp[0].minor.yy21); } + yymsp[-1].minor.yy504 = yylhsminor.yy504; break; case 162: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy515.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy515.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy21.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy21.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; case 163: /* alter_table_option ::= KEEP integer_list */ -{ yymsp[-1].minor.yy515.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy515.pList = yymsp[0].minor.yy334; } +{ yymsp[-1].minor.yy21.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy21.pList = yymsp[0].minor.yy488; } break; case 164: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy515.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy515.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy21.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy21.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 167: /* col_name ::= column_name */ -{ yylhsminor.yy182 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy29); } - yymsp[0].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy409); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 168: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL, NULL); } @@ -3555,13 +3565,13 @@ static YYACTIONTYPE yy_reduce( { 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.yy182, yymsp[0].minor.yy182); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy504, yymsp[0].minor.yy504); } 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.yy182, yymsp[0].minor.yy182); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy504, yymsp[0].minor.yy504); } break; case 173: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy182, NULL); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy504, NULL); } break; case 174: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL, NULL); } @@ -3576,7 +3586,7 @@ static YYACTIONTYPE yy_reduce( { 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.yy182, yymsp[0].minor.yy182); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy504, yymsp[0].minor.yy504); } break; case 179: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); } @@ -3585,7 +3595,7 @@ static YYACTIONTYPE yy_reduce( { 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); } +//{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT, NULL, NULL); } break; case 182: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT, NULL, NULL); } @@ -3595,25 +3605,25 @@ static YYACTIONTYPE yy_reduce( { 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.yy29); } +//{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy409); } break; case 186: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy182); } +//{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy504); } break; case 187: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy182); } +//{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy504); } break; case 188: /* 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); } +//{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT, NULL, NULL); } break; case 190: /* 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); } +//{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLE_STMT, NULL, NULL); } break; case 192: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT, NULL, NULL); } @@ -3623,111 +3633,111 @@ static YYACTIONTYPE yy_reduce( break; case 194: /* db_name_cond_opt ::= */ case 199: /* from_db_opt ::= */ yytestcase(yyruleno==199); -{ yymsp[1].minor.yy182 = createDefaultDatabaseCondValue(pCxt); } +{ yymsp[1].minor.yy504 = createDefaultDatabaseCondValue(pCxt); } break; case 195: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy182 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy29); } - yymsp[-1].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy409); } + yymsp[-1].minor.yy504 = yylhsminor.yy504; break; case 196: /* like_pattern_opt ::= */ case 207: /* index_options ::= */ yytestcase(yyruleno==207); - case 361: /* where_clause_opt ::= */ yytestcase(yyruleno==361); - case 365: /* twindow_clause_opt ::= */ yytestcase(yyruleno==365); - case 370: /* sliding_opt ::= */ yytestcase(yyruleno==370); - case 372: /* fill_opt ::= */ yytestcase(yyruleno==372); - case 384: /* having_clause_opt ::= */ yytestcase(yyruleno==384); - case 392: /* slimit_clause_opt ::= */ yytestcase(yyruleno==392); - case 396: /* limit_clause_opt ::= */ yytestcase(yyruleno==396); -{ yymsp[1].minor.yy182 = NULL; } + case 362: /* where_clause_opt ::= */ yytestcase(yyruleno==362); + case 366: /* twindow_clause_opt ::= */ yytestcase(yyruleno==366); + case 371: /* sliding_opt ::= */ yytestcase(yyruleno==371); + case 373: /* fill_opt ::= */ yytestcase(yyruleno==373); + case 385: /* having_clause_opt ::= */ yytestcase(yyruleno==385); + case 393: /* slimit_clause_opt ::= */ yytestcase(yyruleno==393); + case 397: /* limit_clause_opt ::= */ yytestcase(yyruleno==397); +{ yymsp[1].minor.yy504 = NULL; } break; case 197: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy182 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy504 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; case 198: /* table_name_cond ::= table_name */ -{ yylhsminor.yy182 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy29); } - yymsp[0].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy409); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 200: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy182 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy29); } +{ yymsp[-1].minor.yy504 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy409); } break; case 203: /* func_name ::= function_name */ -{ yylhsminor.yy182 = createFunctionNode(pCxt, &yymsp[0].minor.yy29, NULL); } - yymsp[0].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createFunctionNode(pCxt, &yymsp[0].minor.yy409, NULL); } + yymsp[0].minor.yy504 = yylhsminor.yy504; 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.yy47, &yymsp[-3].minor.yy29, &yymsp[-1].minor.yy29, NULL, yymsp[0].minor.yy182); } +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy121, &yymsp[-3].minor.yy409, &yymsp[-1].minor.yy409, NULL, yymsp[0].minor.yy504); } 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.yy47, &yymsp[-5].minor.yy29, &yymsp[-3].minor.yy29, yymsp[-1].minor.yy334, NULL); } +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy121, &yymsp[-5].minor.yy409, &yymsp[-3].minor.yy409, yymsp[-1].minor.yy488, NULL); } break; case 206: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy47, &yymsp[-2].minor.yy29, &yymsp[0].minor.yy29); } +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy121, &yymsp[-2].minor.yy409, &yymsp[0].minor.yy409); } break; case 208: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy182 = createIndexOption(pCxt, yymsp[-6].minor.yy334, releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), NULL, yymsp[0].minor.yy182); } +{ yymsp[-8].minor.yy504 = createIndexOption(pCxt, yymsp[-6].minor.yy488, releaseRawExprNode(pCxt, yymsp[-2].minor.yy504), NULL, yymsp[0].minor.yy504); } 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.yy182 = createIndexOption(pCxt, yymsp[-8].minor.yy334, releaseRawExprNode(pCxt, yymsp[-4].minor.yy182), releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), yymsp[0].minor.yy182); } +{ yymsp[-10].minor.yy504 = createIndexOption(pCxt, yymsp[-8].minor.yy488, releaseRawExprNode(pCxt, yymsp[-4].minor.yy504), releaseRawExprNode(pCxt, yymsp[-2].minor.yy504), yymsp[0].minor.yy504); } break; case 212: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy182 = createFunctionNode(pCxt, &yymsp[-3].minor.yy29, yymsp[-1].minor.yy334); } - yymsp[-3].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createFunctionNode(pCxt, &yymsp[-3].minor.yy409, yymsp[-1].minor.yy488); } + yymsp[-3].minor.yy504 = yylhsminor.yy504; break; case 213: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy47, &yymsp[-2].minor.yy29, yymsp[0].minor.yy182, NULL); } +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy121, &yymsp[-2].minor.yy409, yymsp[0].minor.yy504, NULL); } break; case 214: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy47, &yymsp[-2].minor.yy29, NULL, &yymsp[0].minor.yy29); } +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy121, &yymsp[-2].minor.yy409, NULL, &yymsp[0].minor.yy409); } break; case 215: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy47, &yymsp[0].minor.yy29); } +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy121, &yymsp[0].minor.yy409); } 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.yy182); } +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy504); } break; case 218: /* 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.yy47, yymsp[-1].minor.yy182, yymsp[0].minor.yy182); } +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy121, yymsp[-1].minor.yy504, yymsp[0].minor.yy504); } break; case 221: /* analyze_opt ::= ANALYZE */ case 229: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==229); - case 351: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==351); -{ yymsp[0].minor.yy47 = true; } + case 352: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==352); +{ yymsp[0].minor.yy121 = true; } break; case 222: /* explain_options ::= */ -{ yymsp[1].minor.yy182 = createDefaultExplainOptions(pCxt); } +{ yymsp[1].minor.yy504 = createDefaultExplainOptions(pCxt); } break; case 223: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy182 = setExplainVerbose(pCxt, yymsp[-2].minor.yy182, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = setExplainVerbose(pCxt, yymsp[-2].minor.yy504, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 224: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy182 = setExplainRatio(pCxt, yymsp[-2].minor.yy182, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = setExplainRatio(pCxt, yymsp[-2].minor.yy504, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; case 225: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ -{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy334); } +{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy488); } 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.yy47, &yymsp[-5].minor.yy29, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy574, yymsp[0].minor.yy550); } +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy121, &yymsp[-5].minor.yy409, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy160, yymsp[0].minor.yy452); } break; case 227: /* cmd ::= DROP FUNCTION function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, &yymsp[0].minor.yy29); } +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, &yymsp[0].minor.yy409); } break; case 230: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy550 = 0; } +{ yymsp[1].minor.yy452 = 0; } break; case 231: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy550 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy452 = 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.yy29, &yymsp[-2].minor.yy29, yymsp[0].minor.yy182); } +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, &yymsp[-4].minor.yy409, &yymsp[-2].minor.yy409, yymsp[0].minor.yy504); } break; case 233: /* cmd ::= DROP STREAM stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, &yymsp[0].minor.yy29); } +{ pCxt->pRootNode = createDropStreamStmt(pCxt, &yymsp[0].minor.yy409); } break; case 234: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } @@ -3739,490 +3749,488 @@ static YYACTIONTYPE yy_reduce( { 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.yy334); } +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy488); } break; case 238: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; case 239: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy334 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +{ yymsp[-1].minor.yy488 = 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.yy29); } +{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy409); } break; case 243: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy182 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 244: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy182 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 245: /* literal ::= NK_STRING */ -{ yylhsminor.yy182 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 246: /* literal ::= NK_BOOL */ -{ yylhsminor.yy182 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 247: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy504 = yylhsminor.yy504; break; case 248: /* literal ::= duration_literal */ case 257: /* signed_literal ::= signed */ yytestcase(yyruleno==257); - case 277: /* expression ::= literal */ yytestcase(yyruleno==277); - case 278: /* expression ::= pseudo_column */ yytestcase(yyruleno==278); - case 279: /* expression ::= column_reference */ yytestcase(yyruleno==279); - case 283: /* expression ::= subquery */ yytestcase(yyruleno==283); - case 324: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==324); - case 328: /* boolean_primary ::= predicate */ yytestcase(yyruleno==328); - case 330: /* common_expression ::= expression */ yytestcase(yyruleno==330); - case 331: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==331); - case 333: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==333); - case 335: /* table_reference ::= table_primary */ yytestcase(yyruleno==335); - case 336: /* table_reference ::= joined_table */ yytestcase(yyruleno==336); - case 340: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==340); - case 387: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==387); - case 389: /* query_primary ::= query_specification */ yytestcase(yyruleno==389); -{ yylhsminor.yy182 = yymsp[0].minor.yy182; } - yymsp[0].minor.yy182 = yylhsminor.yy182; + case 279: /* expression ::= literal */ yytestcase(yyruleno==279); + case 280: /* expression ::= pseudo_column */ yytestcase(yyruleno==280); + case 281: /* expression ::= column_reference */ yytestcase(yyruleno==281); + case 286: /* expression ::= subquery */ yytestcase(yyruleno==286); + case 325: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==325); + case 329: /* boolean_primary ::= predicate */ yytestcase(yyruleno==329); + case 331: /* common_expression ::= expression */ yytestcase(yyruleno==331); + case 332: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==332); + case 334: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==334); + case 336: /* table_reference ::= table_primary */ yytestcase(yyruleno==336); + case 337: /* table_reference ::= joined_table */ yytestcase(yyruleno==337); + case 341: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==341); + case 388: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==388); + case 390: /* query_primary ::= query_specification */ yytestcase(yyruleno==390); +{ yylhsminor.yy504 = yymsp[0].minor.yy504; } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 249: /* literal ::= NULL */ -{ yylhsminor.yy182 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL)); } - yymsp[0].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL)); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 250: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy182 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 251: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy182 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 252: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy182 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy504 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 253: /* 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.yy182 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy504 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy182 = yylhsminor.yy182; + yymsp[-1].minor.yy504 = yylhsminor.yy504; break; case 254: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy182 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 255: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy182 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy504 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; case 256: /* 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.yy182 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy504 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy182 = yylhsminor.yy182; + yymsp[-1].minor.yy504 = yylhsminor.yy504; break; case 258: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy182 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 259: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy182 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy182 = yylhsminor.yy182; +{ yylhsminor.yy504 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 260: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy182 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy504 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; case 261: /* signed_literal ::= duration_literal */ - case 357: /* select_item ::= common_expression */ yytestcase(yyruleno==357); - case 401: /* search_condition ::= common_expression */ yytestcase(yyruleno==401); -{ yylhsminor.yy182 = releaseRawExprNode(pCxt, yymsp[0].minor.yy182); } - yymsp[0].minor.yy182 = yylhsminor.yy182; + case 358: /* select_item ::= common_expression */ yytestcase(yyruleno==358); + case 402: /* search_condition ::= common_expression */ yytestcase(yyruleno==402); +{ yylhsminor.yy504 = releaseRawExprNode(pCxt, yymsp[0].minor.yy504); } + yymsp[0].minor.yy504 = yylhsminor.yy504; break; case 262: /* signed_literal ::= NULL */ -{ yymsp[0].minor.yy182 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL); } +{ yymsp[0].minor.yy504 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL); } break; - case 280: /* expression ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy29, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy29, yymsp[-1].minor.yy334)); } - yymsp[-3].minor.yy182 = yylhsminor.yy182; + case 282: /* expression ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy504 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy409, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy409, yymsp[-1].minor.yy488)); } + yymsp[-3].minor.yy504 = yylhsminor.yy504; break; - case 281: /* expression ::= function_name NK_LP NK_STAR NK_RP */ -{ yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy29, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy29, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } - yymsp[-3].minor.yy182 = yylhsminor.yy182; + case 283: /* expression ::= function_name NK_LP NK_STAR NK_RP */ +{ yylhsminor.yy504 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy409, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy409, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } + yymsp[-3].minor.yy504 = yylhsminor.yy504; break; - case 282: /* expression ::= function_name NK_LP expression AS type_name NK_RP */ -{ - SNodeList *p = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy182)); - p = addValueNodeFromTypeToList(pCxt, yymsp[-1].minor.yy574, p); - yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy29, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-5].minor.yy29, p)); - } - yymsp[-5].minor.yy182 = yylhsminor.yy182; + case 284: /* expression ::= function_name NK_LP NK_RP */ +{ yylhsminor.yy504 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy409, &yymsp[0].minor.yy0, createFunctionNodeNoParam(pCxt, &yymsp[-2].minor.yy409)); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; + break; + case 285: /* expression ::= CAST NK_LP expression AS type_name NK_RP */ +{ yylhsminor.yy504 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy504), yymsp[-1].minor.yy160)); } + yymsp[-5].minor.yy504 = yylhsminor.yy504; break; - case 284: /* expression ::= NK_LP expression NK_RP */ - case 329: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==329); -{ yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy182)); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; + case 287: /* expression ::= NK_LP expression NK_RP */ + case 330: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==330); +{ yylhsminor.yy504 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy504)); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 285: /* expression ::= NK_PLUS expression */ + case 288: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); - yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy182)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); + yylhsminor.yy504 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy504)); } - yymsp[-1].minor.yy182 = yylhsminor.yy182; + yymsp[-1].minor.yy504 = yylhsminor.yy504; break; - case 286: /* expression ::= NK_MINUS expression */ + case 289: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); - yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy182), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); + yylhsminor.yy504 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy504), NULL)); } - yymsp[-1].minor.yy182 = yylhsminor.yy182; + yymsp[-1].minor.yy504 = yylhsminor.yy504; break; - case 287: /* expression ::= expression NK_PLUS expression */ + case 290: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); - yylhsminor.yy182 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), releaseRawExprNode(pCxt, yymsp[0].minor.yy182))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy504); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); + yylhsminor.yy504 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy504), releaseRawExprNode(pCxt, yymsp[0].minor.yy504))); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 288: /* expression ::= expression NK_MINUS expression */ + case 291: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); - yylhsminor.yy182 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), releaseRawExprNode(pCxt, yymsp[0].minor.yy182))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy504); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); + yylhsminor.yy504 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy504), releaseRawExprNode(pCxt, yymsp[0].minor.yy504))); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 289: /* expression ::= expression NK_STAR expression */ + case 292: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); - yylhsminor.yy182 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), releaseRawExprNode(pCxt, yymsp[0].minor.yy182))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy504); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); + yylhsminor.yy504 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy504), releaseRawExprNode(pCxt, yymsp[0].minor.yy504))); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 290: /* expression ::= expression NK_SLASH expression */ + case 293: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); - yylhsminor.yy182 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), releaseRawExprNode(pCxt, yymsp[0].minor.yy182))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy504); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); + yylhsminor.yy504 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy504), releaseRawExprNode(pCxt, yymsp[0].minor.yy504))); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 291: /* expression ::= expression NK_REM expression */ + case 294: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); - yylhsminor.yy182 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), releaseRawExprNode(pCxt, yymsp[0].minor.yy182))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy504); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); + yylhsminor.yy504 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy504), releaseRawExprNode(pCxt, yymsp[0].minor.yy504))); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; - break; - case 292: /* expression_list ::= expression */ -{ yylhsminor.yy334 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy182)); } - yymsp[0].minor.yy334 = yylhsminor.yy334; - break; - case 293: /* expression_list ::= expression_list NK_COMMA expression */ -{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, releaseRawExprNode(pCxt, yymsp[0].minor.yy182)); } - yymsp[-2].minor.yy334 = yylhsminor.yy334; - break; - case 294: /* column_reference ::= column_name */ -{ yylhsminor.yy182 = createRawExprNode(pCxt, &yymsp[0].minor.yy29, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy29)); } - yymsp[0].minor.yy182 = yylhsminor.yy182; - break; - case 295: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy29, &yymsp[0].minor.yy29, createColumnNode(pCxt, &yymsp[-2].minor.yy29, &yymsp[0].minor.yy29)); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; - break; - case 296: /* pseudo_column ::= NOW */ - case 297: /* pseudo_column ::= TODAY */ yytestcase(yyruleno==297); - case 298: /* pseudo_column ::= ROWTS */ yytestcase(yyruleno==298); - case 299: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==299); - case 300: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==300); - case 301: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==301); - case 302: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==302); - case 303: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==303); - case 304: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==304); -{ yylhsminor.yy182 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy182 = yylhsminor.yy182; - break; - case 305: /* predicate ::= expression compare_op expression */ - case 310: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==310); + yymsp[-2].minor.yy504 = yylhsminor.yy504; + break; + case 295: /* expression_list ::= expression */ +{ yylhsminor.yy488 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy504)); } + yymsp[0].minor.yy488 = yylhsminor.yy488; + break; + case 296: /* expression_list ::= expression_list NK_COMMA expression */ +{ yylhsminor.yy488 = addNodeToList(pCxt, yymsp[-2].minor.yy488, releaseRawExprNode(pCxt, yymsp[0].minor.yy504)); } + yymsp[-2].minor.yy488 = yylhsminor.yy488; + break; + case 297: /* column_reference ::= column_name */ +{ yylhsminor.yy504 = createRawExprNode(pCxt, &yymsp[0].minor.yy409, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy409)); } + yymsp[0].minor.yy504 = yylhsminor.yy504; + break; + case 298: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy504 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy409, &yymsp[0].minor.yy409, createColumnNode(pCxt, &yymsp[-2].minor.yy409, &yymsp[0].minor.yy409)); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; + break; + case 299: /* pseudo_column ::= ROWTS */ + case 300: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==300); + case 301: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==301); + case 302: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==302); + case 303: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==303); + case 304: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==304); + case 305: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==305); +{ yylhsminor.yy504 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy504 = yylhsminor.yy504; + break; + case 306: /* predicate ::= expression compare_op expression */ + case 311: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==311); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); - yylhsminor.yy182 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy380, releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), releaseRawExprNode(pCxt, yymsp[0].minor.yy182))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy504); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); + yylhsminor.yy504 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy84, releaseRawExprNode(pCxt, yymsp[-2].minor.yy504), releaseRawExprNode(pCxt, yymsp[0].minor.yy504))); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 306: /* predicate ::= expression BETWEEN expression AND expression */ + case 307: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy182); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); - yylhsminor.yy182 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy182), releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), releaseRawExprNode(pCxt, yymsp[0].minor.yy182))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy504); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); + yylhsminor.yy504 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy504), releaseRawExprNode(pCxt, yymsp[-2].minor.yy504), releaseRawExprNode(pCxt, yymsp[0].minor.yy504))); } - yymsp[-4].minor.yy182 = yylhsminor.yy182; + yymsp[-4].minor.yy504 = yylhsminor.yy504; break; - case 307: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 308: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy182); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); - yylhsminor.yy182 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), releaseRawExprNode(pCxt, yymsp[-5].minor.yy182), releaseRawExprNode(pCxt, yymsp[0].minor.yy182))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy504); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); + yylhsminor.yy504 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy504), releaseRawExprNode(pCxt, yymsp[-5].minor.yy504), releaseRawExprNode(pCxt, yymsp[0].minor.yy504))); } - yymsp[-5].minor.yy182 = yylhsminor.yy182; + yymsp[-5].minor.yy504 = yylhsminor.yy504; break; - case 308: /* predicate ::= expression IS NULL */ + case 309: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); - yylhsminor.yy182 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy504); + yylhsminor.yy504 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy504), NULL)); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 309: /* predicate ::= expression IS NOT NULL */ + case 310: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy182); - yylhsminor.yy182 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy182), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy504); + yylhsminor.yy504 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy504), NULL)); } - yymsp[-3].minor.yy182 = yylhsminor.yy182; + yymsp[-3].minor.yy504 = yylhsminor.yy504; break; - case 311: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy380 = OP_TYPE_LOWER_THAN; } + case 312: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy84 = OP_TYPE_LOWER_THAN; } break; - case 312: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy380 = OP_TYPE_GREATER_THAN; } + case 313: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy84 = OP_TYPE_GREATER_THAN; } break; - case 313: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy380 = OP_TYPE_LOWER_EQUAL; } + case 314: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy84 = OP_TYPE_LOWER_EQUAL; } break; - case 314: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy380 = OP_TYPE_GREATER_EQUAL; } + case 315: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy84 = OP_TYPE_GREATER_EQUAL; } break; - case 315: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy380 = OP_TYPE_NOT_EQUAL; } + case 316: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy84 = OP_TYPE_NOT_EQUAL; } break; - case 316: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy380 = OP_TYPE_EQUAL; } + case 317: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy84 = OP_TYPE_EQUAL; } break; - case 317: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy380 = OP_TYPE_LIKE; } + case 318: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy84 = OP_TYPE_LIKE; } break; - case 318: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy380 = OP_TYPE_NOT_LIKE; } + case 319: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy84 = OP_TYPE_NOT_LIKE; } break; - case 319: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy380 = OP_TYPE_MATCH; } + case 320: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy84 = OP_TYPE_MATCH; } break; - case 320: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy380 = OP_TYPE_NMATCH; } + case 321: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy84 = OP_TYPE_NMATCH; } break; - case 321: /* in_op ::= IN */ -{ yymsp[0].minor.yy380 = OP_TYPE_IN; } + case 322: /* in_op ::= IN */ +{ yymsp[0].minor.yy84 = OP_TYPE_IN; } break; - case 322: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy380 = OP_TYPE_NOT_IN; } + case 323: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy84 = OP_TYPE_NOT_IN; } break; - case 323: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy334)); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; + case 324: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy504 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy488)); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 325: /* boolean_value_expression ::= NOT boolean_primary */ + case 326: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); - yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy182), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); + yylhsminor.yy504 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy504), NULL)); } - yymsp[-1].minor.yy182 = yylhsminor.yy182; + yymsp[-1].minor.yy504 = yylhsminor.yy504; break; - case 326: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 327: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); - yylhsminor.yy182 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), releaseRawExprNode(pCxt, yymsp[0].minor.yy182))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy504); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); + yylhsminor.yy504 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy504), releaseRawExprNode(pCxt, yymsp[0].minor.yy504))); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 327: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 328: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); - yylhsminor.yy182 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), releaseRawExprNode(pCxt, yymsp[0].minor.yy182))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy504); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); + yylhsminor.yy504 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy504), releaseRawExprNode(pCxt, yymsp[0].minor.yy504))); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 332: /* from_clause ::= FROM table_reference_list */ - case 362: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==362); - case 385: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==385); -{ yymsp[-1].minor.yy182 = yymsp[0].minor.yy182; } + case 333: /* from_clause ::= FROM table_reference_list */ + case 363: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==363); + case 386: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==386); +{ yymsp[-1].minor.yy504 = yymsp[0].minor.yy504; } break; - case 334: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy182 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy182, yymsp[0].minor.yy182, NULL); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; + case 335: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy504 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy504, yymsp[0].minor.yy504, NULL); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 337: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy182 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy29, &yymsp[0].minor.yy29); } - yymsp[-1].minor.yy182 = yylhsminor.yy182; + case 338: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy504 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy409, &yymsp[0].minor.yy409); } + yymsp[-1].minor.yy504 = yylhsminor.yy504; break; - case 338: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy182 = createRealTableNode(pCxt, &yymsp[-3].minor.yy29, &yymsp[-1].minor.yy29, &yymsp[0].minor.yy29); } - yymsp[-3].minor.yy182 = yylhsminor.yy182; + case 339: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy504 = createRealTableNode(pCxt, &yymsp[-3].minor.yy409, &yymsp[-1].minor.yy409, &yymsp[0].minor.yy409); } + yymsp[-3].minor.yy504 = yylhsminor.yy504; break; - case 339: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy182 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy182), &yymsp[0].minor.yy29); } - yymsp[-1].minor.yy182 = yylhsminor.yy182; + case 340: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy504 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy504), &yymsp[0].minor.yy409); } + yymsp[-1].minor.yy504 = yylhsminor.yy504; break; - case 341: /* alias_opt ::= */ -{ yymsp[1].minor.yy29 = nil_token; } + case 342: /* alias_opt ::= */ +{ yymsp[1].minor.yy409 = nil_token; } break; - case 342: /* alias_opt ::= table_alias */ -{ yylhsminor.yy29 = yymsp[0].minor.yy29; } - yymsp[0].minor.yy29 = yylhsminor.yy29; + case 343: /* alias_opt ::= table_alias */ +{ yylhsminor.yy409 = yymsp[0].minor.yy409; } + yymsp[0].minor.yy409 = yylhsminor.yy409; break; - case 343: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy29 = yymsp[0].minor.yy29; } + case 344: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy409 = yymsp[0].minor.yy409; } break; - case 344: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 345: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==345); -{ yymsp[-2].minor.yy182 = yymsp[-1].minor.yy182; } + case 345: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 346: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==346); +{ yymsp[-2].minor.yy504 = yymsp[-1].minor.yy504; } break; - case 346: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy182 = createJoinTableNode(pCxt, yymsp[-4].minor.yy162, yymsp[-5].minor.yy182, yymsp[-2].minor.yy182, yymsp[0].minor.yy182); } - yymsp[-5].minor.yy182 = yylhsminor.yy182; + case 347: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy504 = createJoinTableNode(pCxt, yymsp[-4].minor.yy556, yymsp[-5].minor.yy504, yymsp[-2].minor.yy504, yymsp[0].minor.yy504); } + yymsp[-5].minor.yy504 = yylhsminor.yy504; break; - case 347: /* join_type ::= */ -{ yymsp[1].minor.yy162 = JOIN_TYPE_INNER; } + case 348: /* join_type ::= */ +{ yymsp[1].minor.yy556 = JOIN_TYPE_INNER; } break; - case 348: /* join_type ::= INNER */ -{ yymsp[0].minor.yy162 = JOIN_TYPE_INNER; } + case 349: /* join_type ::= INNER */ +{ yymsp[0].minor.yy556 = JOIN_TYPE_INNER; } break; - case 349: /* 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 350: /* 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.yy182 = createSelectStmt(pCxt, yymsp[-7].minor.yy47, yymsp[-6].minor.yy334, yymsp[-5].minor.yy182); - yymsp[-8].minor.yy182 = addWhereClause(pCxt, yymsp[-8].minor.yy182, yymsp[-4].minor.yy182); - yymsp[-8].minor.yy182 = addPartitionByClause(pCxt, yymsp[-8].minor.yy182, yymsp[-3].minor.yy334); - yymsp[-8].minor.yy182 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy182, yymsp[-2].minor.yy182); - yymsp[-8].minor.yy182 = addGroupByClause(pCxt, yymsp[-8].minor.yy182, yymsp[-1].minor.yy334); - yymsp[-8].minor.yy182 = addHavingClause(pCxt, yymsp[-8].minor.yy182, yymsp[0].minor.yy182); + yymsp[-8].minor.yy504 = createSelectStmt(pCxt, yymsp[-7].minor.yy121, yymsp[-6].minor.yy488, yymsp[-5].minor.yy504); + yymsp[-8].minor.yy504 = addWhereClause(pCxt, yymsp[-8].minor.yy504, yymsp[-4].minor.yy504); + yymsp[-8].minor.yy504 = addPartitionByClause(pCxt, yymsp[-8].minor.yy504, yymsp[-3].minor.yy488); + yymsp[-8].minor.yy504 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy504, yymsp[-2].minor.yy504); + yymsp[-8].minor.yy504 = addGroupByClause(pCxt, yymsp[-8].minor.yy504, yymsp[-1].minor.yy488); + yymsp[-8].minor.yy504 = addHavingClause(pCxt, yymsp[-8].minor.yy504, yymsp[0].minor.yy504); } break; - case 352: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy47 = false; } + case 353: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy121 = false; } break; - case 353: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy334 = NULL; } + case 354: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy488 = NULL; } break; - case 358: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy182 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy182), &yymsp[0].minor.yy29); } - yymsp[-1].minor.yy182 = yylhsminor.yy182; + case 359: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy504 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy504), &yymsp[0].minor.yy409); } + yymsp[-1].minor.yy504 = yylhsminor.yy504; break; - case 359: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy182 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), &yymsp[0].minor.yy29); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; + case 360: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy504 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy504), &yymsp[0].minor.yy409); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 360: /* select_item ::= table_name NK_DOT NK_STAR */ -{ yylhsminor.yy182 = createColumnNode(pCxt, &yymsp[-2].minor.yy29, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; + case 361: /* select_item ::= table_name NK_DOT NK_STAR */ +{ yylhsminor.yy504 = createColumnNode(pCxt, &yymsp[-2].minor.yy409, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 364: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 381: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==381); - case 391: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==391); -{ yymsp[-2].minor.yy334 = yymsp[0].minor.yy334; } + case 365: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 382: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==382); + case 392: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==392); +{ yymsp[-2].minor.yy488 = yymsp[0].minor.yy488; } break; - case 366: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy182 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy182), releaseRawExprNode(pCxt, yymsp[-1].minor.yy182)); } + case 367: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy504 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy504), releaseRawExprNode(pCxt, yymsp[-1].minor.yy504)); } break; - case 367: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ -{ yymsp[-3].minor.yy182 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy182)); } + case 368: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ +{ yymsp[-3].minor.yy504 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy504)); } break; - case 368: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy182 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy182), NULL, yymsp[-1].minor.yy182, yymsp[0].minor.yy182); } + case 369: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy504 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy504), NULL, yymsp[-1].minor.yy504, yymsp[0].minor.yy504); } break; - case 369: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy182 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy182), releaseRawExprNode(pCxt, yymsp[-3].minor.yy182), yymsp[-1].minor.yy182, yymsp[0].minor.yy182); } + case 370: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy504 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy504), releaseRawExprNode(pCxt, yymsp[-3].minor.yy504), yymsp[-1].minor.yy504, yymsp[0].minor.yy504); } break; - case 371: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy182 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy182); } + case 372: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy504 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy504); } break; - case 373: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy182 = createFillNode(pCxt, yymsp[-1].minor.yy144, NULL); } + case 374: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy504 = createFillNode(pCxt, yymsp[-1].minor.yy22, NULL); } break; - case 374: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy182 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy334)); } + case 375: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy504 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy488)); } break; - case 375: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy144 = FILL_MODE_NONE; } + case 376: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy22 = FILL_MODE_NONE; } break; - case 376: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy144 = FILL_MODE_PREV; } + case 377: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy22 = FILL_MODE_PREV; } break; - case 377: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy144 = FILL_MODE_NULL; } + case 378: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy22 = FILL_MODE_NULL; } break; - case 378: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy144 = FILL_MODE_LINEAR; } + case 379: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy22 = FILL_MODE_LINEAR; } break; - case 379: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy144 = FILL_MODE_NEXT; } + case 380: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy22 = FILL_MODE_NEXT; } break; - case 382: /* group_by_list ::= expression */ -{ yylhsminor.yy334 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy182))); } - yymsp[0].minor.yy334 = yylhsminor.yy334; + case 383: /* group_by_list ::= expression */ +{ yylhsminor.yy488 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy504))); } + yymsp[0].minor.yy488 = yylhsminor.yy488; break; - case 383: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy182))); } - yymsp[-2].minor.yy334 = yylhsminor.yy334; + case 384: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy488 = addNodeToList(pCxt, yymsp[-2].minor.yy488, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy504))); } + yymsp[-2].minor.yy488 = yylhsminor.yy488; break; - case 386: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 387: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy182 = addOrderByClause(pCxt, yymsp[-3].minor.yy182, yymsp[-2].minor.yy334); - yylhsminor.yy182 = addSlimitClause(pCxt, yylhsminor.yy182, yymsp[-1].minor.yy182); - yylhsminor.yy182 = addLimitClause(pCxt, yylhsminor.yy182, yymsp[0].minor.yy182); + yylhsminor.yy504 = addOrderByClause(pCxt, yymsp[-3].minor.yy504, yymsp[-2].minor.yy488); + yylhsminor.yy504 = addSlimitClause(pCxt, yylhsminor.yy504, yymsp[-1].minor.yy504); + yylhsminor.yy504 = addLimitClause(pCxt, yylhsminor.yy504, yymsp[0].minor.yy504); } - yymsp[-3].minor.yy182 = yylhsminor.yy182; + yymsp[-3].minor.yy504 = yylhsminor.yy504; break; - case 388: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy182 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy182, yymsp[0].minor.yy182); } - yymsp[-3].minor.yy182 = yylhsminor.yy182; + case 389: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy504 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy504, yymsp[0].minor.yy504); } + yymsp[-3].minor.yy504 = yylhsminor.yy504; break; - case 393: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 397: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==397); -{ yymsp[-1].minor.yy182 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 394: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 398: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==398); +{ yymsp[-1].minor.yy504 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 394: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 398: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==398); -{ yymsp[-3].minor.yy182 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 395: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 399: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==399); +{ yymsp[-3].minor.yy504 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 395: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 399: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==399); -{ yymsp[-3].minor.yy182 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 396: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 400: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==400); +{ yymsp[-3].minor.yy504 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 400: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy182); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; + case 401: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy504 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy504); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 404: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy182 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), yymsp[-1].minor.yy218, yymsp[0].minor.yy487); } - yymsp[-2].minor.yy182 = yylhsminor.yy182; + case 405: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy504 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy504), yymsp[-1].minor.yy522, yymsp[0].minor.yy281); } + yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 405: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy218 = ORDER_ASC; } + case 406: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy522 = ORDER_ASC; } break; - case 406: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy218 = ORDER_ASC; } + case 407: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy522 = ORDER_ASC; } break; - case 407: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy218 = ORDER_DESC; } + case 408: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy522 = ORDER_DESC; } break; - case 408: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy487 = NULL_ORDER_DEFAULT; } + case 409: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy281 = NULL_ORDER_DEFAULT; } break; - case 409: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy487 = NULL_ORDER_FIRST; } + case 410: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy281 = NULL_ORDER_FIRST; } break; - case 410: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy487 = NULL_ORDER_LAST; } + case 411: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy281 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 8459f4bebaced1bf67e754b96e6c03fc24cba2f1..a45fabd8288556af8303eef94e41e420eec682ba 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -498,19 +498,16 @@ static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren return TSDB_CODE_OUT_OF_MEMORY; } + SDataBlockDescNode* pLeftDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc; + SDataBlockDescNode* pRightDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 1))->pOutputDataBlockDesc; int32_t code = TSDB_CODE_SUCCESS; pJoin->joinType = pJoinLogicNode->joinType; if (NULL != pJoinLogicNode->pOnConditions) { - SDataBlockDescNode* pLeftDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc; - SDataBlockDescNode* pRightDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 1))->pOutputDataBlockDesc; code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pOnConditions, &pJoin->pOnConditions); } if (TSDB_CODE_SUCCESS == code) { - pJoin->pTargets = nodesCloneList(pJoinLogicNode->node.pTargets); - if (NULL == pJoin->pTargets) { - code = TSDB_CODE_OUT_OF_MEMORY; - } + code = setListSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->node.pTargets, &pJoin->pTargets); } if (TSDB_CODE_SUCCESS == code) { code = addDataBlockSlots(pCxt, pJoin->pTargets, pJoin->node.pOutputDataBlockDesc); diff --git a/source/libs/planner/test/plannerTest.cpp b/source/libs/planner/test/plannerTest.cpp index 69c76fc3aef0433656d046abf9a226506d4970fd..48aa89eae6721f4fcd7ab3566c565330230b88cf 100644 --- a/source/libs/planner/test/plannerTest.cpp +++ b/source/libs/planner/test/plannerTest.cpp @@ -180,11 +180,11 @@ TEST_F(PlannerTest, selectStableBasic) { TEST_F(PlannerTest, selectJoin) { setDatabase("root", "test"); - // bind("SELECT t1.c1, t2.c2 FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts"); - // ASSERT_TRUE(run()); + bind("SELECT t1.c1, t2.c2 FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts"); + ASSERT_TRUE(run()); - // bind("SELECT t1.*, t2.* FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts"); - // ASSERT_TRUE(run()); + bind("SELECT t1.*, t2.* FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts"); + ASSERT_TRUE(run()); bind("SELECT t1.c1, t2.c1 FROM st1s1 t1 join st1s2 t2 on t1.ts = t2.ts where t1.c1 > t2.c1 and t1.c2 = 'abc' and t2.c2 = 'qwe'"); ASSERT_TRUE(run()); diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index 67871dfe6241b0b1c3e48856f6068e96d4d09916..a9a360e03e05049f802853a25131c956bd85524b 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/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index a3806893c775ccf7456f95aa84130d9c6c498ae4..97cc80b946b33f4e8c2d07595b3312d2a1615fc8 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1259,6 +1259,22 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p return TSDB_CODE_SUCCESS; } +int32_t nowFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { + if (inputNum != 1) { + return TSDB_CODE_FAILED; + } + colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 0)); + return TSDB_CODE_SUCCESS; +} + +int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { + if (inputNum != 1) { + return TSDB_CODE_FAILED; + } + colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 0)); + return TSDB_CODE_SUCCESS; +} + int32_t atanFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { return doScalarFunctionUnique(pInput, inputNum, pOutput, atan); } diff --git a/source/libs/scheduler/inc/schedulerInt.h b/source/libs/scheduler/inc/schedulerInt.h index 62a96b6438d67fdd0d72fb22d9e3d275db44a24b..d1def1bef116ccca66647d173f41efabda85126d 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 c5258afcc18bc1e23333cee63a8fc88c18b6ea28..93bc16a7a2e2669d5e8c36c59408f3e1fb72d66b 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -2655,6 +2655,34 @@ _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; } diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 3078324c6bd611563e690f31eac246dc67436529..ef9cccccb71e202e622fab87362b5d1a4dad5310 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 ce795b17631bc0a497fae825e1ebbd8fdb95a1a5..2488dda3f6c8fd2c2a466b377bf4225094282c02 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 3545aabdca9da2c1d8e530979692f8121bcae41c..cd756b45e2ff9d6bb4ddb6a3bdefe62b269ccae2 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 a74b26a38666afe4e54817e9f8a773b156476e8b..4477a5cacdeb1675c16daaedd05b040bddf38203 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/pytest/insert/bigint.py b/tests/pytest/insert/bigint.py index 7c7d2d0f9507e8688dd73bcefe88632361c80c70..5431cf8106fdbcd74bdd310de45039badb3bce7f 100644 --- a/tests/pytest/insert/bigint.py +++ b/tests/pytest/insert/bigint.py @@ -54,10 +54,6 @@ class TDTestCase: tdSql.checkData(0, 1, 9223372036854770000) tdLog.info('drop database db') tdSql.execute('drop database db') - tdLog.info('show databases') - tdSql.query('show databases') - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) # convert end def stop(self): diff --git a/tests/pytest/insert/double.py b/tests/pytest/insert/double.py index 1b66ed1c44c7cec645be1f0f23866c7f06501ebc..2699f4b0e95897de47d461f885690e2b8a7863d7 100644 --- a/tests/pytest/insert/double.py +++ b/tests/pytest/insert/double.py @@ -75,10 +75,6 @@ class TDTestCase: tdSql.checkData(0, 1, 2.000000000) tdLog.info('drop database db') tdSql.execute('drop database db') - tdLog.info('show databases') - tdSql.query('show databases') - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) # convert end def stop(self): diff --git a/tests/pytest/insert/smallint.py b/tests/pytest/insert/smallint.py index 16322e9aeb801ae92b75b920922991206a4b2e35..1a1eab6a98912639aa845e7aae552fdd49278a5b 100644 --- a/tests/pytest/insert/smallint.py +++ b/tests/pytest/insert/smallint.py @@ -91,10 +91,6 @@ class TDTestCase: tdSql.checkData(0, 1, 2) tdLog.info('drop database db') tdSql.execute('drop database db') - tdLog.info('show databases') - tdSql.query('show databases') - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) # convert end def stop(self): diff --git a/tests/pytest/insert/timestamp.py b/tests/pytest/insert/timestamp.py new file mode 100644 index 0000000000000000000000000000000000000000..d5ddffcfafbade7b59fb32269a58b5ae0c9c0fdc --- /dev/null +++ b/tests/pytest/insert/timestamp.py @@ -0,0 +1,93 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.ts = 1607281690000 + + def run(self): + tdSql.prepare() + + # TS-806 + tdLog.info("test case for TS-806") + + # Case 1 + tdSql.execute("create table t1(ts timestamp, c1 int)") + tdSql.execute("insert into t1(c1, ts) values(1, %d)" % self.ts) + tdSql.query("select * from t1") + tdSql.checkRows(1) + + # Case 2 + tdSql.execute( + "insert into t1(c1, ts) values(2, %d)(3, %d)" % + (self.ts + 1000, self.ts + 2000)) + tdSql.query("select * from t1") + tdSql.checkRows(3) + + # Case 3 + tdSql.execute("create table t2(ts timestamp, c1 timestamp)") + tdSql.execute( + " insert into t2(c1, ts) values(%d, %d)" % + (self.ts, self.ts + 5000)) + tdSql.query("select * from t2") + tdSql.checkRows(1) + + tdSql.execute( + " insert into t2(c1, ts) values(%d, %d)(%d, %d)" % + (self.ts, self.ts + 6000, self.ts + 3000, self.ts + 8000)) + tdSql.query("select * from t2") + tdSql.checkRows(3) + + # Case 4 + tdSql.execute( + "create table stb(ts timestamp, c1 int, c2 binary(20)) tags(tstag timestamp, t1 int)") + tdSql.execute( + "insert into tb1(c2, ts, c1) using stb(t1, tstag) tags(1, now) values('test', %d, 1)" % + self.ts) + tdSql.query("select * from stb") + tdSql.checkRows(1) + + # Case 5 + tdSql.execute( + "insert into tb1(c2, ts, c1) using stb(t1, tstag) tags(1, now) values('test', now, 1) tb2(c1, ts) using stb tags(now + 2m, 1000) values(1, now - 1h)") + tdSql.query("select * from stb") + tdSql.checkRows(3) + + tdSql.execute(" insert into tb1(c2, ts, c1) using stb(t1, tstag) tags(1, now) values('test', now + 10s, 1) tb2(c1, ts) using stb(tstag) tags(now + 2m) values(1, now - 3h)(2, now - 2h)") + tdSql.query("select * from stb") + tdSql.checkRows(6) + + # Case 6 + tdSql.execute( + "create table stb2 (ts timestamp, c1 timestamp, c2 timestamp) tags(t1 timestamp, t2 timestamp)") + tdSql.execute(" insert into tb4(c1, c2, ts) using stb2(t2, t1) tags(now, now + 1h) values(now + 1s, now + 2s, now + 3s)(now -1s, now - 2s, now - 3s) tb5(c2, ts, c1) using stb2(t2) tags(now + 1h) values(now, now, now)") + tdSql.query("select * from stb2") + tdSql.checkRows(3) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/tinyint.py b/tests/pytest/insert/tinyint.py index a10c999e8c2f0fe070347651f9246e3734104eca..a27b60aa724a93c7ccd40d521f0ee09c066c53d3 100644 --- a/tests/pytest/insert/tinyint.py +++ b/tests/pytest/insert/tinyint.py @@ -91,10 +91,6 @@ class TDTestCase: tdSql.checkData(0, 1, 2) tdLog.info('drop database db') tdSql.execute('drop database db') - tdLog.info('show databases') - tdSql.query('show databases') - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) # convert end def stop(self): diff --git a/tests/pytest/insert/unsignedBigint.py b/tests/pytest/insert/unsignedBigint.py index b222f2cd0195e14fddf1f10662447cef97f0e841..0e99afa14207ed7e4426483c2276ec9b643f5873 100644 --- a/tests/pytest/insert/unsignedBigint.py +++ b/tests/pytest/insert/unsignedBigint.py @@ -93,10 +93,6 @@ class TDTestCase: tdSql.checkData(0, 1, 2) tdLog.info('drop database db') tdSql.execute('drop database db') - tdLog.info('show databases') - tdSql.query('show databases') - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) # convert end def stop(self): diff --git a/tests/pytest/insert/unsignedInt.py b/tests/pytest/insert/unsignedInt.py index ed18999bc415022da34788a79e9045a5f67cf8ee..f38964677f99b945a136fe9e9ae58073edaba102 100644 --- a/tests/pytest/insert/unsignedInt.py +++ b/tests/pytest/insert/unsignedInt.py @@ -93,10 +93,6 @@ class TDTestCase: tdSql.checkData(0, 1, 2) tdLog.info('drop database db') tdSql.execute('drop database db') - tdLog.info('show databases') - tdSql.query('show databases') - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) # convert end def stop(self): diff --git a/tests/pytest/insert/unsignedSmallint.py b/tests/pytest/insert/unsignedSmallint.py index 9893c470ce1a53a05138dd9d5c18e2b0a9f21374..815390868b530ed4321b23ee8776421941640176 100644 --- a/tests/pytest/insert/unsignedSmallint.py +++ b/tests/pytest/insert/unsignedSmallint.py @@ -93,10 +93,6 @@ class TDTestCase: tdSql.checkData(0, 1, 2) tdLog.info('drop database db') tdSql.execute('drop database db') - tdLog.info('show databases') - tdSql.query('show databases') - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) # convert end def stop(self): diff --git a/tests/pytest/insert/unsignedTinyint.py b/tests/pytest/insert/unsignedTinyint.py index 5bdfe7580b198ccaffcab7005e88aa72e1c437af..200ac00eb00b673339cd35601e8ed0f7663f06b0 100644 --- a/tests/pytest/insert/unsignedTinyint.py +++ b/tests/pytest/insert/unsignedTinyint.py @@ -91,10 +91,6 @@ class TDTestCase: tdSql.checkData(0, 1, 2) tdLog.info('drop database db') tdSql.execute('drop database db') - tdLog.info('show databases') - tdSql.query('show databases') - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) def stop(self): diff --git a/tests/pytest/smoketest.sh b/tests/pytest/smoketest.sh index cbe80882fbb6dfb6cfa9695f66d0b22d09068ae5..7ac5d4f6d375d194077af80e2a89f0d34a8c32d1 100755 --- a/tests/pytest/smoketest.sh +++ b/tests/pytest/smoketest.sh @@ -4,10 +4,32 @@ ulimit -c unlimited # insert python3 ./test.py $1 -f insert/basic.py python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/bool.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/tinyint.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/smallint.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/int.py +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f insert/bigint.py python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/float.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/double.py +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f insert/nchar.py python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/timestamp.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/unsignedTinyint.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/unsignedSmallint.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/unsignedInt.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/unsignedBigint.py +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f insert/multi.py python3 ./test.py $1 -s && sleep 1 diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 8dc7fb920effa5554fd0fc77d11fdd27971e8e95..3df1d4287b663d37837029390a438d01fabf137b 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -31,7 +31,7 @@ ./test.sh -f tsim/query/interval.sim ./test.sh -f tsim/query/interval-offset.sim ./test.sh -f tsim/query/scalarFunction.sim -./test.sh -f tsim/query/charScalarFunction.sim +#./test.sh -f tsim/query/charScalarFunction.sim ./test.sh -f tsim/query/explain.sim ./test.sh -f tsim/query/session.sim diff --git a/tests/script/test.sh b/tests/script/test.sh index 7721f21db7470b223ef7d4e4317b9e36a75349f8..f5a9e4187bb85ea4f0ddeadde92dec0bfc0a6fd0 100755 --- a/tests/script/test.sh +++ b/tests/script/test.sh @@ -125,8 +125,8 @@ ulimit -c unlimited 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 - 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 + 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 else if [[ $MULTIPROCESS -eq 1 ]];then echo "ExcuteCmd(multiprocess):" $PROGRAM -m -c $CFG_DIR -f $FILE_NAME diff --git a/tests/script/tsim/query/session.sim b/tests/script/tsim/query/session.sim index 3aee8386257b316f3c1d9f93af8d5b1b0d97ecb3..d4920ea25512e8ce33af2f39d44d1db985accd9d 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) diff --git a/tests/tsim/inc/simInt.h b/tests/tsim/inc/simInt.h index a667139de1934fab479c8ed2c3d857b7ee111dea..c8b13736c7cb752c7fa52500f132ede02988089e 100644 --- a/tests/tsim/inc/simInt.h +++ b/tests/tsim/inc/simInt.h @@ -156,6 +156,7 @@ extern int32_t simDebugFlag; extern char simScriptDir[]; extern bool abortExecution; extern bool useMultiProcess; +extern bool useValgrind; SScript *simParseScript(char *fileName); SScript *simProcessCallOver(SScript *script); diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index d71323336292cccf3d4cdb951c3ce457bded0667..5a18084fff254de271c4c68a2472c283de331797 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -340,6 +340,10 @@ bool simExecuteSystemCmd(SScript *script, char *option) { simReplaceStr(buf, "deploy.sh", "deploy.sh -m"); } + if (useValgrind) { + simReplaceStr(buf, "exec.sh", "exec.sh -v"); + } + simLogSql(buf, true); int32_t code = system(buf); int32_t repeatTimes = 0; diff --git a/tests/tsim/src/simMain.c b/tests/tsim/src/simMain.c index 8898f1b201da5e41db81982a8261a2d792888912..713e46df58e8957be2593eb5d78698ed46e5a69b 100644 --- a/tests/tsim/src/simMain.c +++ b/tests/tsim/src/simMain.c @@ -19,6 +19,7 @@ bool simExecSuccess = false; bool abortExecution = false; bool useMultiProcess = false; +bool useValgrind = false; void simHandleSignal(int32_t signo, void *sigInfo, void *context) { simSystemCleanUp(); @@ -35,6 +36,8 @@ int32_t main(int32_t argc, char *argv[]) { strcpy(scriptFile, argv[++i]); } else if (strcmp(argv[i], "-m") == 0) { useMultiProcess = true; + } else if (strcmp(argv[i], "-v") == 0) { + useValgrind = true; } else { printf("usage: %s [options] \n", argv[0]); printf(" [-c config]: config directory, default is: %s\n", configDir); diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 1809d99209b89fc77a7b1fdd7dd2dec13cc993c6..ac2010efa3a759c79073aca3e935d278bd2ab31e 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; }