diff --git a/examples/lua/build.sh b/examples/lua/build.sh index 9d00c68425..1e6fef632c 100755 --- a/examples/lua/build.sh +++ b/examples/lua/build.sh @@ -4,5 +4,5 @@ if [ "$lua_header_installed" = "0" ]; then sudo apt install -y liblua5.3-dev fi -gcc -std=c99 lua_connector.c -fPIC -shared -o luaconnector.so -Wall -ltaos -I/usr/include/lua5.3 +gcc -std=c99 lua_connector.c -fPIC -shared -o luaconnector.so -Wall -ltaos -I/usr/include/lua5.3 -I../../include/client diff --git a/examples/lua/lua_connector.c b/examples/lua/lua_connector.c index 76634ed254..3c13b196b9 100644 --- a/examples/lua/lua_connector.c +++ b/examples/lua/lua_connector.c @@ -1,11 +1,11 @@ -#include -#include -#include +#include #include #include -#include #include -#include "../../../include/client/taos.h" +#include +#include +#include +#include "taos.h" struct cb_param{ lua_State* state; @@ -28,14 +28,14 @@ static int l_connect(lua_State *L){ luaL_checktype(L, 1, LUA_TTABLE); - lua_getfield(L,1,"host"); + lua_getfield(L, 1,"host"); if (lua_isstring(L,-1)){ host = lua_tostring(L, -1); // printf("host = %s\n", host); } lua_getfield(L, 1, "port"); - if (lua_isinteger(L,-1)){ + if (lua_isinteger(L, -1)){ port = lua_tointeger(L, -1); //printf("port = %d\n", port); } @@ -60,8 +60,6 @@ static int l_connect(lua_State *L){ lua_settop(L,0); - taos_init(); - lua_newtable(L); int table_index = lua_gettop(L); @@ -102,7 +100,7 @@ static int l_query(lua_State *L){ printf("failed, reason:%s\n", taos_errstr(result)); lua_pushinteger(L, -1); lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); + lua_pushstring(L, taos_errstr(result)); lua_setfield(L, table_index, "error"); return 1; @@ -113,7 +111,6 @@ static int l_query(lua_State *L){ int rows = 0; int num_fields = taos_field_count(result); const TAOS_FIELD *fields = taos_fetch_fields(result); - //char temp[256]; const int affectRows = taos_affected_rows(result); // printf(" affect rows:%d\r\n", affectRows); @@ -122,7 +119,7 @@ static int l_query(lua_State *L){ lua_pushinteger(L, affectRows); lua_setfield(L, table_index, "affected"); lua_newtable(L); - + while ((row = taos_fetch_row(result))) { //printf("row index:%d\n",rows); rows++; @@ -136,17 +133,21 @@ static int l_query(lua_State *L){ } lua_pushstring(L,fields[i].name); - + int32_t* length = taos_fetch_lengths(result); switch (fields[i].type) { + case TSDB_DATA_TYPE_UTINYINT: case TSDB_DATA_TYPE_TINYINT: lua_pushinteger(L,*((char *)row[i])); break; + case TSDB_DATA_TYPE_USMALLINT: case TSDB_DATA_TYPE_SMALLINT: lua_pushinteger(L,*((short *)row[i])); break; + case TSDB_DATA_TYPE_UINT: case TSDB_DATA_TYPE_INT: lua_pushinteger(L,*((int *)row[i])); break; + case TSDB_DATA_TYPE_UBIGINT: case TSDB_DATA_TYPE_BIGINT: lua_pushinteger(L,*((int64_t *)row[i])); break; @@ -156,9 +157,11 @@ static int l_query(lua_State *L){ case TSDB_DATA_TYPE_DOUBLE: lua_pushnumber(L,*((double *)row[i])); break; + case TSDB_DATA_TYPE_JSON: case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: - lua_pushstring(L,(char *)row[i]); + //printf("type:%d, max len:%d, current len:%d\n",fields[i].type, fields[i].bytes, length[i]); + lua_pushlstring(L,(char *)row[i], length[i]); break; case TSDB_DATA_TYPE_TIMESTAMP: lua_pushinteger(L,*((int64_t *)row[i])); @@ -166,6 +169,7 @@ static int l_query(lua_State *L){ case TSDB_DATA_TYPE_BOOL: lua_pushinteger(L,*((char *)row[i])); break; + case TSDB_DATA_TYPE_NULL: default: lua_pushnil(L); break; @@ -235,112 +239,6 @@ static int l_async_query(lua_State *L){ return 1; } -void stream_cb(void *param, TAOS_RES *result, TAOS_ROW row){ - struct cb_param* p = (struct cb_param*) param; - TAOS_FIELD *fields = taos_fetch_fields(result); - int numFields = taos_num_fields(result); - - // printf("\nnumfields:%d\n", numFields); - //printf("\n\r-----------------------------------------------------------------------------------\n"); - - lua_State *L = p->state; - lua_rawgeti(L, LUA_REGISTRYINDEX, p->callback); - - lua_newtable(L); - - for (int i = 0; i < numFields; ++i) { - if (row[i] == NULL) { - continue; - } - - lua_pushstring(L,fields[i].name); - - switch (fields[i].type) { - case TSDB_DATA_TYPE_TINYINT: - lua_pushinteger(L,*((char *)row[i])); - break; - case TSDB_DATA_TYPE_SMALLINT: - lua_pushinteger(L,*((short *)row[i])); - break; - case TSDB_DATA_TYPE_INT: - lua_pushinteger(L,*((int *)row[i])); - break; - case TSDB_DATA_TYPE_BIGINT: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_FLOAT: - lua_pushnumber(L,*((float *)row[i])); - break; - case TSDB_DATA_TYPE_DOUBLE: - lua_pushnumber(L,*((double *)row[i])); - break; - case TSDB_DATA_TYPE_BINARY: - case TSDB_DATA_TYPE_NCHAR: - lua_pushstring(L,(char *)row[i]); - break; - case TSDB_DATA_TYPE_TIMESTAMP: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_BOOL: - lua_pushinteger(L,*((char *)row[i])); - break; - default: - lua_pushnil(L); - break; - } - - lua_settable(L, -3); - } - - lua_call(L, 1, 0); - - // printf("-----------------------------------------------------------------------------------\n\r"); -} - -static int l_open_stream(lua_State *L){ - int r = luaL_ref(L, LUA_REGISTRYINDEX); - TAOS * taos = (TAOS*)lua_topointer(L,1); - const char * sqlstr = lua_tostring(L,2); - int stime = luaL_checknumber(L,3); - - lua_newtable(L); - int table_index = lua_gettop(L); - - struct cb_param *p = malloc(sizeof(struct cb_param)); - p->state = L; - p->callback=r; - // printf("r:%d, L:%d\n",r,L); - void * s = taos_open_stream(taos,sqlstr,stream_cb,stime,p,NULL); - if (s == NULL) { - printf("failed to open stream, reason:%s\n", taos_errstr(taos)); - free(p); - lua_pushnumber(L, -1); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - lua_pushlightuserdata(L,NULL); - lua_setfield(L, table_index, "stream"); - }else{ - // printf("success to open stream\n"); - lua_pushnumber(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - p->stream = s; - lua_pushlightuserdata(L,p); - lua_setfield(L, table_index, "stream");//stream has different content in lua and c. - } - - return 1; -} - -static int l_close_stream(lua_State *L){ - //TODO:get stream and free cb_param - struct cb_param *p = lua_touserdata(L,1); - taos_close_stream(p->stream); - free(p); - return 0; -} static int l_close(lua_State *L){ TAOS *taos= (TAOS*)lua_topointer(L,1); @@ -367,8 +265,6 @@ static const struct luaL_Reg lib[] = { {"query", l_query}, {"query_a",l_async_query}, {"close", l_close}, - {"open_stream", l_open_stream}, - {"close_stream", l_close_stream}, {NULL, NULL} }; diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 8686d91a10..4e89beabcb 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -70,13 +70,11 @@ typedef uint16_t tmsg_t; #define TSDB_IE_TYPE_DNODE_EXT 6 #define TSDB_IE_TYPE_DNODE_STATE 7 -typedef enum { - HEARTBEAT_TYPE_MQ = 0, - HEARTBEAT_TYPE_QUERY, - // types can be added here - // - HEARTBEAT_TYPE_MAX -} EHbType; +enum { + CONN_TYPE__QUERY = 1, + CONN_TYPE__TMQ, + CONN_TYPE__MAX +}; enum { HEARTBEAT_KEY_DBINFO = 1, @@ -346,7 +344,7 @@ int32_t tDeserializeSConnectReq(void* buf, int32_t bufLen, SConnectReq* pReq); typedef struct { int32_t acctId; int64_t clusterId; - int32_t connId; + uint32_t connId; int8_t superUser; int8_t connType; SEpSet epSet; @@ -1048,40 +1046,6 @@ typedef struct { int32_t tSerializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq); int32_t tDeserializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq); -typedef struct { - char sql[TSDB_SHOW_SQL_LEN]; - int32_t queryId; - int64_t useconds; - int64_t stime; - int64_t qId; - int64_t sqlObjId; - int32_t pid; - char fqdn[TSDB_FQDN_LEN]; - int8_t stableQuery; - int32_t numOfSub; - char subSqlInfo[TSDB_SHOW_SUBQUERY_LEN]; // include subqueries' index, Obj IDs and states(C-complete/I-imcomplete) -} SQueryDesc; - -typedef struct { - int32_t connId; - int32_t pid; - int32_t numOfQueries; - int32_t numOfStreams; - char app[TSDB_APP_NAME_LEN]; - char pData[]; -} SHeartBeatReq; - -typedef struct { - int32_t connId; - int32_t queryId; - int32_t streamId; - int32_t totalDnodes; - int32_t onlineDnodes; - int8_t killConnection; - int8_t align[3]; - SEpSet epSet; -} SHeartBeatRsp; - typedef struct { int32_t connId; int32_t queryId; @@ -1684,13 +1648,48 @@ typedef struct { } SKv; typedef struct { - int32_t connId; - int32_t hbType; + int64_t tscRid; + int8_t connType; } SClientHbKey; typedef struct { - SClientHbKey connKey; - SHashObj* info; // hash + int64_t tid; + int32_t status; +} SQuerySubDesc; + +typedef struct { + char sql[TSDB_SHOW_SQL_LEN]; + uint64_t queryId; + int64_t useconds; + int64_t stime; + int64_t reqRid; + int32_t pid; + char fqdn[TSDB_FQDN_LEN]; + int32_t subPlanNum; + SArray* subDesc; // SArray +} SQueryDesc; + +typedef struct { + uint32_t connId; + int32_t pid; + char app[TSDB_APP_NAME_LEN]; + SArray* queryDesc; // SArray +} SQueryHbReqBasic; + +typedef struct { + uint32_t connId; + uint64_t killRid; + int32_t totalDnodes; + int32_t onlineDnodes; + int8_t killConnection; + int8_t align[3]; + SEpSet epSet; +} SQueryHbRspBasic; + +typedef struct { + SClientHbKey connKey; + SQueryHbReqBasic* query; + SHashObj* info; // hash } SClientHbReq; typedef struct { @@ -1699,9 +1698,10 @@ typedef struct { } SClientHbBatchReq; typedef struct { - SClientHbKey connKey; - int32_t status; - SArray* info; // Array + SClientHbKey connKey; + int32_t status; + SQueryHbRspBasic* query; + SArray* info; // Array } SClientHbRsp; typedef struct { @@ -1721,8 +1721,23 @@ static FORCE_INLINE void tFreeReqKvHash(SHashObj* info) { } } +static FORCE_INLINE void tFreeClientHbQueryDesc(void* pDesc) { + SQueryDesc* desc = (SQueryDesc*)pDesc; + if (desc->subDesc) { + taosArrayDestroy(desc->subDesc); + desc->subDesc = NULL; + } +} + static FORCE_INLINE void tFreeClientHbReq(void* pReq) { SClientHbReq* req = (SClientHbReq*)pReq; + if (req->query) { + if (req->query->queryDesc) { + taosArrayDestroyEx(req->query->queryDesc, tFreeClientHbQueryDesc); + } + taosMemoryFreeClear(req->query); + } + if (req->info) { tFreeReqKvHash(req->info); taosHashCleanup(req->info); @@ -1751,6 +1766,7 @@ static FORCE_INLINE void tFreeClientKv(void* pKv) { static FORCE_INLINE void tFreeClientHbRsp(void* pRsp) { SClientHbRsp* rsp = (SClientHbRsp*)pRsp; + taosMemoryFreeClear(rsp->query); if (rsp->info) taosArrayDestroyEx(rsp->info, tFreeClientKv); } @@ -1779,14 +1795,14 @@ static FORCE_INLINE int32_t tDecodeSKv(SCoder* pDecoder, SKv* pKv) { } static FORCE_INLINE int32_t tEncodeSClientHbKey(SCoder* pEncoder, const SClientHbKey* pKey) { - if (tEncodeI32(pEncoder, pKey->connId) < 0) return -1; - if (tEncodeI32(pEncoder, pKey->hbType) < 0) return -1; + if (tEncodeI64(pEncoder, pKey->tscRid) < 0) return -1; + if (tEncodeI8(pEncoder, pKey->connType) < 0) return -1; return 0; } static FORCE_INLINE int32_t tDecodeSClientHbKey(SCoder* pDecoder, SClientHbKey* pKey) { - if (tDecodeI32(pDecoder, &pKey->connId) < 0) return -1; - if (tDecodeI32(pDecoder, &pKey->hbType) < 0) return -1; + if (tDecodeI64(pDecoder, &pKey->tscRid) < 0) return -1; + if (tDecodeI8(pDecoder, &pKey->connType) < 0) return -1; return 0; } diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 23dd4b38ff..0137b71479 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -181,9 +181,9 @@ #define TK_NULL 163 #define TK_FIRST 164 #define TK_LAST 165 -#define TK_CAST 166 -#define TK_NOW 167 -#define TK_TODAY 168 +#define TK_NOW 166 +#define TK_TODAY 167 +#define TK_CAST 168 #define TK_ROWTS 169 #define TK_TBNAME 170 #define TK_QSTARTTS 171 diff --git a/include/libs/scalar/scalar.h b/include/libs/scalar/scalar.h index 10b4866a96..49af10cd2c 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 5ab4ead89c..460749243c 100644 --- a/include/libs/scheduler/scheduler.h +++ b/include/libs/scheduler/scheduler.h @@ -89,6 +89,8 @@ int32_t schedulerAsyncExecJob(void *transport, SArray *pNodeList, SQueryPlan* pD */ int32_t schedulerFetchRows(int64_t job, void **data); +int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub); + /** * Cancel query job diff --git a/include/os/osMemory.h b/include/os/osMemory.h index e516000c66..4efe69e204 100644 --- a/include/os/osMemory.h +++ b/include/os/osMemory.h @@ -33,13 +33,13 @@ void *taosMemoryMalloc(int32_t size); void *taosMemoryCalloc(int32_t num, int32_t size); void *taosMemoryRealloc(void *ptr, int32_t size); void *taosMemoryStrDup(void *ptr); -void taosMemoryFree(const void *ptr); +void taosMemoryFree(void *ptr); int32_t taosMemorySize(void *ptr); #define taosMemoryFreeClear(ptr) \ do { \ if (ptr) { \ - taosMemoryFree(ptr); \ + taosMemoryFree((void*)ptr); \ (ptr) = NULL; \ } \ } while (0) diff --git a/include/util/tarray.h b/include/util/tarray.h index 521e54040d..383af8309d 100644 --- a/include/util/tarray.h +++ b/include/util/tarray.h @@ -205,6 +205,14 @@ SArray* taosArrayDup(const SArray* pSrc); */ void taosArrayClear(SArray* pArray); +/** + * clear the array (remove all element) + * @param pArray + * @param fp + */ +void taosArrayClearEx(SArray* pArray, void (*fp)(void*)); + + /** * destroy array list * @param pArray diff --git a/include/util/tdef.h b/include/util/tdef.h index 6baf784fe3..5fc30540ee 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -128,6 +128,13 @@ extern const int32_t TYPE_BYTES[15]; #define TSDB_INS_TABLE_QUERIES "queries" #define TSDB_INS_TABLE_VNODES "vnodes" +#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema" +#define TSDB_PERFS_TABLE_CONNECTIONS "connections" +#define TSDB_PERFS_TABLE_QUERIES "queries" +#define TSDB_PERFS_TABLE_TOPICS "topics" +#define TSDB_PERFS_TABLE_CONSUMERS "consumers" +#define TSDB_PERFS_TABLE_SUBSCRIBES "subscribes" + #define TSDB_INDEX_TYPE_SMA "SMA" #define TSDB_INDEX_TYPE_FULLTEXT "FULLTEXT" diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 0f12880272..79d6b2fdf1 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -45,11 +45,6 @@ extern "C" { #define HEARTBEAT_INTERVAL 1500 // ms -enum { - CONN_TYPE__QUERY = 1, - CONN_TYPE__TMQ, -}; - typedef struct SAppInstInfo SAppInstInfo; typedef struct { @@ -84,8 +79,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 +139,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 { @@ -256,11 +252,15 @@ 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); @@ -302,7 +302,7 @@ SAppHbMgr* appHbMgrInit(SAppInstInfo* pAppInstInfo, char* key); void appHbMgrCleanup(void); // conn level -int hbRegisterConn(SAppHbMgr* pAppHbMgr, int32_t connId, int64_t clusterId, int32_t hbType); +int hbRegisterConn(SAppHbMgr *pAppHbMgr, int64_t tscRefId, int64_t clusterId, int8_t connType); void hbDeregisterConn(SAppHbMgr* pAppHbMgr, SClientHbKey connKey); int hbAddConnInfo(SAppHbMgr* pAppHbMgr, SClientHbKey connKey, void* key, void* value, int32_t keyLen, int32_t valueLen); diff --git a/source/client/inc/clientStmt.h b/source/client/inc/clientStmt.h new file mode 100644 index 0000000000..c29361758d --- /dev/null +++ b/source/client/inc/clientStmt.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_CLIENTSTMT_H +#define TDENGINE_CLIENTSTMT_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + STMT_TYPE_INSERT = 1, + STMT_TYPE_MULTI_INSERT, + STMT_TYPE_QUERY, +} STMT_TYPE; + +typedef struct STscStmt { + STMT_TYPE type; + //int16_t last; + //STscObj* taos; + //SSqlObj* pSql; + //SMultiTbStmt mtb; + //SNormalStmt normal; + + //int numOfRows; +} STscStmt; + +#define STMT_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) +#define STMT_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) +#define STMT_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) + +TAOS_STMT *stmtInit(TAOS *taos); +int stmtClose(TAOS_STMT *stmt); +int stmtExec(TAOS_STMT *stmt); +char *stmtErrstr(TAOS_STMT *stmt); +int stmtAffectedRows(TAOS_STMT *stmt); +int stmtBind(TAOS_STMT *stmt, TAOS_BIND *bind); +int stmtPrepare(TAOS_STMT *stmt, const char *sql, unsigned long length); +int stmtSetTbNameTags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags); +int stmtIsInsert(TAOS_STMT *stmt, int *insert); +int stmtGetParamNum(TAOS_STMT *stmt, int *nums); +int stmtAddBatch(TAOS_STMT *stmt); +TAOS_RES *stmtUseResult(TAOS_STMT *stmt); +int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind); + + +#ifdef __cplusplus +} +#endif + +#endif // TDENGINE_CLIENTSTMT_H diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index fec6c8e5db..969b18f067 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -37,7 +37,8 @@ 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. @@ -69,7 +70,7 @@ static void deregisterRequest(SRequestObj *pRequest) { 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,6 +215,8 @@ 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); @@ -214,9 +245,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 +497,18 @@ uint64_t generateRequestId() { } } - int64_t ts = taosGetTimestampMs(); - uint64_t pid = taosGetPId(); - int32_t val = atomic_add_fetch_32(&requestSerialId, 1); + uint64_t id = 0; + + while (true) { + int64_t ts = taosGetTimestampMs(); + uint64_t pid = taosGetPId(); + int32_t val = atomic_add_fetch_32(&requestSerialId, 1); - uint64_t id = ((hashId & 0x0FFF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); + id = ((hashId & 0x0FFF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); + if (id) { + break; + } + } return id; } diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index 82788b2e11..a6678b2ec0 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -14,6 +14,7 @@ */ #include "catalog.h" +#include "scheduler.h" #include "clientInt.h" #include "clientLog.h" #include "trpc.h" @@ -109,10 +110,36 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) { SHbConnInfo *info = taosHashGet(pAppHbMgr->connInfo, &pRsp->connKey, sizeof(SClientHbKey)); if (NULL == info) { - tscWarn("fail to get connInfo, may be dropped, connId:%d, type:%d", pRsp->connKey.connId, pRsp->connKey.hbType); + tscWarn("fail to get connInfo, may be dropped, refId:%" PRIx64 ", type:%d", pRsp->connKey.tscRid, pRsp->connKey.connType); return TSDB_CODE_SUCCESS; } + if (pRsp->query) { + STscObj *pTscObj = (STscObj *)acquireTscObj(pRsp->connKey.tscRid); + if (NULL == pTscObj) { + tscDebug("tscObj rid %" PRIx64 " not exist", pRsp->connKey.tscRid); + } else { + updateEpSet_s(&pTscObj->pAppInfo->mgmtEp, &pRsp->query->epSet); + pTscObj->connId = pRsp->query->connId; + + if (pRsp->query->killRid) { + SRequestObj *pRequest = acquireRequest(pRsp->query->killRid); + if (NULL == pRequest) { + tscDebug("request 0x%" PRIx64 " not exist to kill", pRsp->query->killRid); + } else { + taos_stop_query((TAOS_RES *)pRequest); + releaseRequest(pRsp->query->killRid); + } + } + + if (pRsp->query->killConnection) { + taos_close(pTscObj); + } + + releaseTscObj(pRsp->connKey.tscRid); + } + } + int32_t kvNum = pRsp->info ? taosArrayGetSize(pRsp->info) : 0; tscDebug("hb got %d rsp kv", kvNum); @@ -197,7 +224,7 @@ static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code) for (int32_t i = 0; i < rspNum; ++i) { SClientHbRsp *rsp = taosArrayGet(pRsp.rsps, i); - code = (*clientHbMgr.rspHandle[rsp->connKey.hbType])((*pInst)->pAppHbMgr, rsp); + code = (*clientHbMgr.rspHandle[rsp->connKey.connType])((*pInst)->pAppHbMgr, rsp); if (code) { break; } @@ -208,6 +235,97 @@ static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code) return code; } +int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) { + int64_t now = taosGetTimestampUs(); + SQueryDesc desc = {0}; + int32_t code = 0; + + void *pIter = taosHashIterate(pObj->pRequests, NULL); + while (pIter != NULL) { + int64_t *rid = pIter; + SRequestObj *pRequest = acquireRequest(*rid); + if (NULL == pRequest) { + continue; + } + + tstrncpy(desc.sql, pRequest->sqlstr, sizeof(desc.sql)); + desc.stime = pRequest->metric.start; + desc.queryId = pRequest->requestId; + desc.useconds = now - pRequest->metric.start; + desc.reqRid = pRequest->self; + desc.pid = hbBasic->pid; + taosGetFqdn(desc.fqdn); + desc.subPlanNum = pRequest->body.pDag ? pRequest->body.pDag->numOfSubplans : 0; + + if (desc.subPlanNum) { + desc.subDesc = taosArrayInit(desc.subPlanNum, sizeof(SQuerySubDesc)); + if (NULL == desc.subDesc) { + releaseRequest(*rid); + return TSDB_CODE_QRY_OUT_OF_MEMORY; + } + + code = schedulerGetTasksStatus(pRequest->body.queryJob, desc.subDesc); + if (code) { + taosArrayDestroy(desc.subDesc); + desc.subDesc = NULL; + } + } + + releaseRequest(*rid); + taosArrayPush(hbBasic->queryDesc, &desc); + + pIter = taosHashIterate(pObj->pRequests, pIter); + } + + return TSDB_CODE_SUCCESS; +} + +int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) { + STscObj *pTscObj = (STscObj *)acquireTscObj(connKey->tscRid); + if (NULL == pTscObj) { + tscWarn("tscObj rid %" PRIx64 " not exist", connKey->tscRid); + return TSDB_CODE_QRY_APP_ERROR; + } + + int32_t numOfQueries = pTscObj->pRequests ? taosHashGetSize(pTscObj->pRequests) : 0; + if (numOfQueries <= 0) { + releaseTscObj(connKey->tscRid); + tscDebug("no queries on connection"); + return TSDB_CODE_QRY_APP_ERROR; + } + + SQueryHbReqBasic *hbBasic = (SQueryHbReqBasic *)taosMemoryCalloc(1, sizeof(SQueryHbReqBasic)); + if (NULL == hbBasic) { + tscError("calloc %d failed", (int32_t)sizeof(SQueryHbReqBasic)); + releaseTscObj(connKey->tscRid); + return TSDB_CODE_QRY_OUT_OF_MEMORY; + } + + hbBasic->queryDesc = taosArrayInit(numOfQueries, sizeof(SQueryDesc)); + if (NULL == hbBasic->queryDesc) { + tscWarn("taosArrayInit %d queryDesc failed", numOfQueries); + releaseTscObj(connKey->tscRid); + taosMemoryFree(hbBasic); + return TSDB_CODE_QRY_OUT_OF_MEMORY; + } + + hbBasic->connId = pTscObj->connId; + hbBasic->pid = taosGetPId(); + taosGetAppName(hbBasic->app, NULL); + + int32_t code = hbBuildQueryDesc(hbBasic, pTscObj); + if (code) { + releaseTscObj(connKey->tscRid); + taosMemoryFree(hbBasic); + return code; + } + + req->query = hbBasic; + releaseTscObj(connKey->tscRid); + + return TSDB_CODE_SUCCESS; +} + int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SClientHbReq *req) { SDbVgVersion *dbs = NULL; uint32_t dbNum = 0; @@ -286,6 +404,8 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req return code; } + hbGetQueryBasicInfo(connKey, req); + code = hbGetExpiredDBInfo(connKey, pCatalog, req); if (TSDB_CODE_SUCCESS != code) { return code; @@ -300,11 +420,11 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req } void hbMgrInitMqHbHandle() { - clientHbMgr.reqHandle[HEARTBEAT_TYPE_QUERY] = hbQueryHbReqHandle; - clientHbMgr.reqHandle[HEARTBEAT_TYPE_MQ] = hbMqHbReqHandle; + clientHbMgr.reqHandle[CONN_TYPE__QUERY] = hbQueryHbReqHandle; + clientHbMgr.reqHandle[CONN_TYPE__TMQ] = hbMqHbReqHandle; - clientHbMgr.rspHandle[HEARTBEAT_TYPE_QUERY] = hbQueryHbRspHandle; - clientHbMgr.rspHandle[HEARTBEAT_TYPE_MQ] = hbMqHbRspHandle; + clientHbMgr.rspHandle[CONN_TYPE__QUERY] = hbQueryHbRspHandle; + clientHbMgr.rspHandle[CONN_TYPE__TMQ] = hbMqHbRspHandle; } static FORCE_INLINE void hbMgrInitHandle() { @@ -317,6 +437,11 @@ void hbFreeReq(void *req) { tFreeReqKvHash(pReq->info); } +void hbClearClientHbReq(SClientHbReq *pReq) { + pReq->query = NULL; + pReq->info = NULL; +} + SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) { SClientHbBatchReq *pBatchReq = taosMemoryCalloc(1, sizeof(SClientHbBatchReq)); if (pBatchReq == NULL) { @@ -333,22 +458,23 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) { SHbConnInfo *info = taosHashGet(pAppHbMgr->connInfo, &pOneReq->connKey, sizeof(SClientHbKey)); if (info) { - code = (*clientHbMgr.reqHandle[pOneReq->connKey.hbType])(&pOneReq->connKey, info->param, pOneReq); + code = (*clientHbMgr.reqHandle[pOneReq->connKey.connType])(&pOneReq->connKey, info->param, pOneReq); if (code) { - taosHashCancelIterate(pAppHbMgr->activeInfo, pIter); - break; + pIter = taosHashIterate(pAppHbMgr->activeInfo, pIter); + continue; } } taosArrayPush(pBatchReq->reqs, pOneReq); + hbClearClientHbReq(pOneReq); pIter = taosHashIterate(pAppHbMgr->activeInfo, pIter); } - if (code) { - taosArrayDestroyEx(pBatchReq->reqs, hbFreeReq); - taosMemoryFreeClear(pBatchReq); - } +// if (code) { +// taosArrayDestroyEx(pBatchReq->reqs, hbFreeReq); +// taosMemoryFreeClear(pBatchReq); +// } return pBatchReq; } @@ -523,13 +649,13 @@ int hbMgrInit() { hbMgrInitHandle(); // init backgroud thread - hbCreateThread(); + //hbCreateThread(); return 0; } void hbMgrCleanUp() { - hbStopThread(); + //hbStopThread(); // destroy all appHbMgr int8_t old = atomic_val_compare_exchange_8(&clientHbMgr.inited, 1, 0); @@ -549,7 +675,7 @@ int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, SHbConnInfo * if (data != NULL) { return 0; } - SClientHbReq hbReq; + SClientHbReq hbReq = {0}; hbReq.connKey = connKey; hbReq.info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK); @@ -566,22 +692,22 @@ int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, SHbConnInfo * return 0; } -int hbRegisterConn(SAppHbMgr *pAppHbMgr, int32_t connId, int64_t clusterId, int32_t hbType) { +int hbRegisterConn(SAppHbMgr *pAppHbMgr, int64_t tscRefId, int64_t clusterId, int8_t connType) { SClientHbKey connKey = { - .connId = connId, - .hbType = hbType, + .tscRid = tscRefId, + .connType = connType, }; SHbConnInfo info = {0}; - switch (hbType) { - case HEARTBEAT_TYPE_QUERY: { + switch (connType) { + case CONN_TYPE__QUERY: { int64_t *pClusterId = taosMemoryMalloc(sizeof(int64_t)); *pClusterId = clusterId; info.param = pClusterId; return hbRegisterConnImpl(pAppHbMgr, connKey, &info); } - case HEARTBEAT_TYPE_MQ: { + case CONN_TYPE__TMQ: { return 0; } default: diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 96a7230ff3..75b4537364 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -132,6 +132,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; } @@ -447,7 +454,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t taos_close(pTscObj); pTscObj = NULL; } else { - tscDebug("0x%" PRIx64 " connection is opening, connId:%d, dnodeConn:%p, reqId:0x%" PRIx64, pTscObj->id, + tscDebug("0x%" PRIx64 " connection is opening, connId:%u, dnodeConn:%p, reqId:0x%" PRIx64, pTscObj->id, pTscObj->connId, pTscObj->pAppInfo->pTransporter, pRequest->requestId); destroyRequest(pRequest); } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 42d204284e..ae8a31f367 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) { @@ -400,7 +403,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) { @@ -565,76 +568,149 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { } TAOS_STMT *taos_stmt_init(TAOS *taos) { - // TODO - return NULL; + if (taos == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return NULL; + } + + return stmtInit(taos); } int taos_stmt_close(TAOS_STMT *stmt) { - // TODO - return -1; + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtClose(stmt); } int taos_stmt_execute(TAOS_STMT *stmt) { - // TODO - return -1; + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtExec(stmt); } char *taos_stmt_errstr(TAOS_STMT *stmt) { - // TODO - return NULL; + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return NULL; + } + + return stmtErrstr(stmt); } int taos_stmt_affected_rows(TAOS_STMT *stmt) { - // TODO - return -1; + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return 0; + } + + return stmtAffectedRows(stmt); } +int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind) { + if (stmt == NULL || bind == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtBind(stmt, bind); +} + +int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) { + if (stmt == NULL || sql == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtPrepare(stmt, sql, length); +} + +int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags) { + if (stmt == NULL || name == NULL || tags == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtSetTbNameTags(stmt, name, tags); +} + +int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) { + if (stmt == NULL || name == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtSetTbNameTags(stmt, name, NULL); +} + +int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert) { + if (stmt == NULL || insert == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtIsInsert(stmt, insert); +} + +int taos_stmt_num_params(TAOS_STMT *stmt, int *nums) { + if (stmt == NULL || nums == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtGetParamNum(stmt, nums); +} + +int taos_stmt_add_batch(TAOS_STMT *stmt) { + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtAddBatch(stmt); +} + +TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt) { + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return NULL; + } + + return stmtUseResult(stmt); +} + +int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) { + if (stmt == NULL || bind == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtBindBatch(stmt, bind); +} + + TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision) { // TODO return NULL; } -int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind) { - // TODO - return -1; -} -int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) { - // TODO - return -1; -} - -int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags) { - // TODO - return -1; -} - -int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) { - // TODO - return -1; -} - -int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert) { - // TODO - return -1; -} - -int taos_stmt_num_params(TAOS_STMT *stmt, int *nums) { - // TODO - return -1; -} - -int taos_stmt_add_batch(TAOS_STMT *stmt) { - // TODO - return -1; -} - -TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt) { - // TODO - return NULL; -} - -int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) { - // TODO - return -1; -} diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 67c5679cac..f822da7c8d 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, diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c new file mode 100644 index 0000000000..8c4cff9251 --- /dev/null +++ b/source/client/src/clientStmt.c @@ -0,0 +1,99 @@ + +#include "clientInt.h" +#include "clientLog.h" +#include "clientStmt.h" +#include "tdef.h" + +TAOS_STMT *stmtInit(TAOS *taos) { + STscObj* pObj = (STscObj*)taos; + STscStmt* pStmt = NULL; + +#if 0 + pStmt = taosMemoryCalloc(1, sizeof(STscStmt)); + if (pStmt == NULL) { + terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + tscError("failed to allocate memory for statement"); + return NULL; + } + pStmt->taos = pObj; + + SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); + + if (pSql == NULL) { + free(pStmt); + terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + tscError("failed to allocate memory for statement"); + return NULL; + } + + if (TSDB_CODE_SUCCESS != tscAllocPayload(&pSql->cmd, TSDB_DEFAULT_PAYLOAD_SIZE)) { + free(pSql); + free(pStmt); + terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + tscError("failed to malloc payload buffer"); + return NULL; + } + + tsem_init(&pSql->rspSem, 0, 0); + pSql->signature = pSql; + pSql->pTscObj = pObj; + pSql->maxRetry = TSDB_MAX_REPLICA; + pStmt->pSql = pSql; + pStmt->last = STMT_INIT; + pStmt->numOfRows = 0; + registerSqlObj(pSql); +#endif + + return pStmt; +} + +int stmtClose(TAOS_STMT *stmt) { + return TSDB_CODE_SUCCESS; +} + +int stmtExec(TAOS_STMT *stmt) { + return TSDB_CODE_SUCCESS; +} + +char *stmtErrstr(TAOS_STMT *stmt) { + return NULL; +} + +int stmtAffectedRows(TAOS_STMT *stmt) { + return TSDB_CODE_SUCCESS; +} + +int stmtBind(TAOS_STMT *stmt, TAOS_BIND *bind) { + return TSDB_CODE_SUCCESS; +} + +int stmtPrepare(TAOS_STMT *stmt, const char *sql, unsigned long length) { + return TSDB_CODE_SUCCESS; +} + +int stmtSetTbNameTags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags) { + return TSDB_CODE_SUCCESS; +} + +int stmtIsInsert(TAOS_STMT *stmt, int *insert) { + return TSDB_CODE_SUCCESS; +} + +int stmtGetParamNum(TAOS_STMT *stmt, int *nums) { + return TSDB_CODE_SUCCESS; +} + +int stmtAddBatch(TAOS_STMT *stmt) { + return TSDB_CODE_SUCCESS; +} + +TAOS_RES *stmtUseResult(TAOS_STMT *stmt) { + return NULL; +} + +int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) { + return TSDB_CODE_SUCCESS; +} + + + diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 031ebdaf49..3e37c52c26 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -134,6 +134,42 @@ void *taosDecodeSEpSet(void *buf, SEpSet *pEp) { static int32_t tSerializeSClientHbReq(SCoder *pEncoder, const SClientHbReq *pReq) { if (tEncodeSClientHbKey(pEncoder, &pReq->connKey) < 0) return -1; + if (pReq->connKey.connType == CONN_TYPE__QUERY) { + int32_t queryNum = 0; + if (pReq->query) { + queryNum = 1; + if (tEncodeI32(pEncoder, queryNum) < 0) return -1; + if (tEncodeU32(pEncoder, pReq->query->connId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->query->pid) < 0) return -1; + if (tEncodeCStr(pEncoder, pReq->query->app) < 0) return -1; + + int32_t num = taosArrayGetSize(pReq->query->queryDesc); + if (tEncodeI32(pEncoder, num) < 0) return -1; + + for (int32_t i = 0; i < num; ++i) { + SQueryDesc *desc = taosArrayGet(pReq->query->queryDesc, i); + if (tEncodeCStr(pEncoder, desc->sql) < 0) return -1; + if (tEncodeU64(pEncoder, desc->queryId) < 0) return -1; + if (tEncodeI64(pEncoder, desc->useconds) < 0) return -1; + if (tEncodeI64(pEncoder, desc->stime) < 0) return -1; + if (tEncodeI64(pEncoder, desc->reqRid) < 0) return -1; + if (tEncodeI32(pEncoder, desc->pid) < 0) return -1; + if (tEncodeCStr(pEncoder, desc->fqdn) < 0) return -1; + if (tEncodeI32(pEncoder, desc->subPlanNum) < 0) return -1; + + int32_t snum = desc->subDesc ? taosArrayGetSize(desc->subDesc) : 0; + if (tEncodeI32(pEncoder, snum) < 0) return -1; + for (int32_t m = 0; m < snum; ++m) { + SQuerySubDesc *sDesc = taosArrayGet(desc->subDesc, m); + if (tEncodeI64(pEncoder, sDesc->tid) < 0) return -1; + if (tEncodeI32(pEncoder, sDesc->status) < 0) return -1; + } + } + } else { + if (tEncodeI32(pEncoder, queryNum) < 0) return -1; + } + } + int32_t kvNum = taosHashGetSize(pReq->info); if (tEncodeI32(pEncoder, kvNum) < 0) return -1; void *pIter = taosHashIterate(pReq->info, NULL); @@ -149,6 +185,53 @@ static int32_t tSerializeSClientHbReq(SCoder *pEncoder, const SClientHbReq *pReq static int32_t tDeserializeSClientHbReq(SCoder *pDecoder, SClientHbReq *pReq) { if (tDecodeSClientHbKey(pDecoder, &pReq->connKey) < 0) return -1; + if (pReq->connKey.connType == CONN_TYPE__QUERY) { + int32_t queryNum = 0; + if (tDecodeI32(pDecoder, &queryNum) < 0) return -1; + if (queryNum) { + pReq->query = taosMemoryCalloc(1, sizeof(*pReq->query)); + if (NULL == pReq->query) return -1; + if (tDecodeU32(pDecoder, &pReq->query->connId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->query->pid) < 0) return -1; + if (tDecodeCStrTo(pDecoder, pReq->query->app) < 0) return -1; + + int32_t num = 0; + if (tDecodeI32(pDecoder, &num) < 0) return -1; + if (num > 0) { + pReq->query->queryDesc = taosArrayInit(num, sizeof(SQueryDesc)); + if (NULL == pReq->query->queryDesc) return -1; + + for (int32_t i = 0; i < num; ++i) { + SQueryDesc desc = {0}; + if (tDecodeCStrTo(pDecoder, desc.sql) < 0) return -1; + if (tDecodeU64(pDecoder, &desc.queryId) < 0) return -1; + if (tDecodeI64(pDecoder, &desc.useconds) < 0) return -1; + if (tDecodeI64(pDecoder, &desc.stime) < 0) return -1; + if (tDecodeI64(pDecoder, &desc.reqRid) < 0) return -1; + if (tDecodeI32(pDecoder, &desc.pid) < 0) return -1; + if (tDecodeCStrTo(pDecoder, desc.fqdn) < 0) return -1; + if (tDecodeI32(pDecoder, &desc.subPlanNum) < 0) return -1; + + int32_t snum = 0; + if (tDecodeI32(pDecoder, &snum) < 0) return -1; + if (snum > 0) { + desc.subDesc = taosArrayInit(snum, sizeof(SQuerySubDesc)); + if (NULL == desc.subDesc) return -1; + + for (int32_t m = 0; m < snum; ++m) { + SQuerySubDesc sDesc = {0}; + if (tDecodeI64(pDecoder, &sDesc.tid) < 0) return -1; + if (tDecodeI32(pDecoder, &sDesc.status) < 0) return -1; + taosArrayPush(desc.subDesc, &sDesc); + } + } + + taosArrayPush(pReq->query->queryDesc, &desc); + } + } + } + } + int32_t kvNum = 0; if (tDecodeI32(pDecoder, &kvNum) < 0) return -1; if (pReq->info == NULL) { @@ -168,6 +251,20 @@ static int32_t tSerializeSClientHbRsp(SCoder *pEncoder, const SClientHbRsp *pRsp if (tEncodeSClientHbKey(pEncoder, &pRsp->connKey) < 0) return -1; if (tEncodeI32(pEncoder, pRsp->status) < 0) return -1; + int32_t queryNum = 0; + if (pRsp->query) { + queryNum = 1; + if (tEncodeI32(pEncoder, queryNum) < 0) return -1; + if (tEncodeU32(pEncoder, pRsp->query->connId) < 0) return -1; + if (tEncodeU64(pEncoder, pRsp->query->killRid) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->query->totalDnodes) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->query->onlineDnodes) < 0) return -1; + if (tEncodeI8(pEncoder, pRsp->query->killConnection) < 0) return -1; + if (tEncodeSEpSet(pEncoder, &pRsp->query->epSet) < 0) return -1; + } else { + if (tEncodeI32(pEncoder, queryNum) < 0) return -1; + } + int32_t kvNum = taosArrayGetSize(pRsp->info); if (tEncodeI32(pEncoder, kvNum) < 0) return -1; for (int32_t i = 0; i < kvNum; i++) { @@ -182,6 +279,19 @@ static int32_t tDeserializeSClientHbRsp(SCoder *pDecoder, SClientHbRsp *pRsp) { if (tDecodeSClientHbKey(pDecoder, &pRsp->connKey) < 0) return -1; if (tDecodeI32(pDecoder, &pRsp->status) < 0) return -1; + int32_t queryNum = 0; + if (tDecodeI32(pDecoder, &queryNum) < 0) return -1; + if (queryNum) { + pRsp->query = taosMemoryCalloc(1, sizeof(*pRsp->query)); + if (NULL == pRsp->query) return -1; + if (tDecodeU32(pDecoder, &pRsp->query->connId) < 0) return -1; + if (tDecodeU64(pDecoder, &pRsp->query->killRid) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->query->totalDnodes) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->query->onlineDnodes) < 0) return -1; + if (tDecodeI8(pDecoder, &pRsp->query->killConnection) < 0) return -1; + if (tDecodeSEpSet(pDecoder, &pRsp->query->epSet) < 0) return -1; + } + int32_t kvNum = 0; if (tDecodeI32(pDecoder, &kvNum) < 0) return -1; pRsp->info = taosArrayInit(kvNum, sizeof(SKv)); @@ -224,8 +334,9 @@ int32_t tDeserializeSClientHbBatchReq(void *buf, int32_t bufLen, SClientHbBatchR int32_t reqNum = 0; if (tDecodeI32(&decoder, &reqNum) < 0) return -1; - if (pBatchReq->reqs == NULL) { + if (reqNum > 0) { pBatchReq->reqs = taosArrayInit(reqNum, sizeof(SClientHbReq)); + if (NULL == pBatchReq->reqs) return -1; } for (int32_t i = 0; i < reqNum; i++) { SClientHbReq req = {0}; @@ -2567,7 +2678,7 @@ int32_t tSerializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) { if (tStartEncode(&encoder) < 0) return -1; if (tEncodeI32(&encoder, pRsp->acctId) < 0) return -1; if (tEncodeI64(&encoder, pRsp->clusterId) < 0) return -1; - if (tEncodeI32(&encoder, pRsp->connId) < 0) return -1; + if (tEncodeU32(&encoder, pRsp->connId) < 0) return -1; if (tEncodeI8(&encoder, pRsp->superUser) < 0) return -1; if (tEncodeI8(&encoder, pRsp->connType) < 0) return -1; if (tEncodeSEpSet(&encoder, &pRsp->epSet) < 0) return -1; @@ -2586,7 +2697,7 @@ int32_t tDeserializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) { if (tStartDecode(&decoder) < 0) return -1; if (tDecodeI32(&decoder, &pRsp->acctId) < 0) return -1; if (tDecodeI64(&decoder, &pRsp->clusterId) < 0) return -1; - if (tDecodeI32(&decoder, &pRsp->connId) < 0) return -1; + if (tDecodeU32(&decoder, &pRsp->connId) < 0) return -1; if (tDecodeI8(&decoder, &pRsp->superUser) < 0) return -1; if (tDecodeI8(&decoder, &pRsp->connType) < 0) return -1; if (tDecodeSEpSet(&decoder, &pRsp->epSet) < 0) return -1; diff --git a/source/dnode/mnode/impl/inc/mndInt.h b/source/dnode/mnode/impl/inc/mndInt.h index 11c1b09cc9..7b67308876 100644 --- a/source/dnode/mnode/impl/inc/mndInt.h +++ b/source/dnode/mnode/impl/inc/mndInt.h @@ -38,6 +38,10 @@ extern "C" { #define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", DEBUG_DEBUG, mDebugFlag, __VA_ARGS__); }} #define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }} +#define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE) +#define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE) +#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE) + typedef int32_t (*MndMsgFp)(SNodeMsg *pMsg); typedef int32_t (*MndInitFp)(SMnode *pMnode); typedef void (*MndCleanupFp)(SMnode *pMnode); @@ -74,7 +78,6 @@ typedef struct { } SShowMgmt; typedef struct { - int32_t connId; SCacheObj *cache; } SProfileMgmt; @@ -118,6 +121,7 @@ struct SMnode { STelemMgmt telemMgmt; SSyncMgmt syncMgmt; SHashObj *infosMeta; + SHashObj *perfsMeta; SGrantInfo grant; MndMsgFp msgFp[TDMT_MAX]; SMsgCb msgCb; diff --git a/source/dnode/mnode/impl/inc/mndPerfSchema.h b/source/dnode/mnode/impl/inc/mndPerfSchema.h new file mode 100644 index 0000000000..2c613e253c --- /dev/null +++ b/source/dnode/mnode/impl/inc/mndPerfSchema.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_MND_PERF_SCHEMA_H_ +#define _TD_MND_PERF_SCHEMA_H_ + +#include "mndInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct SPerfsTableSchema { + char *name; + int32_t type; + int32_t bytes; +} SPerfsTableSchema; + +typedef struct SPerfsTableMeta { + char *name; + const SPerfsTableSchema *schema; + int32_t colNum; +} SPerfsTableMeta; + +int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp); +int32_t mndInitPerfs(SMnode *pMnode); +void mndCleanupPerfs(SMnode *pMnode); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MND_PERF_SCHEMA_H_*/ diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 2ea95f8f8d..6c797b9044 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -1128,6 +1128,8 @@ static int32_t mndProcessUseDbReq(SNodeMsg *pReq) { if (taosArrayGetSize(usedbRsp.pVgroupInfos) <= 0) { terrno = TSDB_CODE_MND_DB_NOT_EXIST; + } else { + code = 0; } } else { usedbRsp.vgVersion = usedbReq.vgVersion; diff --git a/source/dnode/mnode/impl/src/mndInfoSchema.c b/source/dnode/mnode/impl/src/mndInfoSchema.c index 32c9847fea..d24586aa36 100644 --- a/source/dnode/mnode/impl/src/mndInfoSchema.c +++ b/source/dnode/mnode/impl/src/mndInfoSchema.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "mndInfoSchema.h" +#include "mndInt.h" #define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE) #define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE) diff --git a/source/dnode/mnode/impl/src/mndPerfSchema.c b/source/dnode/mnode/impl/src/mndPerfSchema.c new file mode 100644 index 0000000000..38e9e79228 --- /dev/null +++ b/source/dnode/mnode/impl/src/mndPerfSchema.c @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "mndPerfSchema.h" +#include "mndInt.h" + +//!!!! Note: only APPEND columns in below tables, NO insert !!!! +static const SPerfsTableSchema connectionsSchema[] = { + {.name = "conn_id", .bytes = 4, .type = TSDB_DATA_TYPE_UINT}, + {.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "program", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "end_point", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "login_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, +}; +static const SPerfsTableSchema queriesSchema[] = { + {.name = "query_id", .bytes = 4, .type = TSDB_DATA_TYPE_UBIGINT}, + {.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "fqdn", .bytes = TSDB_FQDN_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT}, + {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "sub_queries", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "sub_query_info", .bytes = TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, +}; + +static const SPerfsTableSchema topicSchema[] = { + {.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "row_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, +}; + +static const SPerfsTableSchema consumerSchema[] = { + {.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "status", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + // ep + // up time + // topics +}; + +static const SPerfsTableSchema subscribeSchema[] = { + {.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, +}; + +static const SPerfsTableMeta perfsMeta[] = { + {TSDB_PERFS_TABLE_CONNECTIONS, connectionsSchema, tListLen(connectionsSchema)}, + {TSDB_PERFS_TABLE_QUERIES, queriesSchema, tListLen(queriesSchema)}, + {TSDB_PERFS_TABLE_TOPICS, topicSchema, tListLen(topicSchema)}, + {TSDB_PERFS_TABLE_CONSUMERS, consumerSchema, tListLen(consumerSchema)}, + {TSDB_PERFS_TABLE_SUBSCRIBES, subscribeSchema, tListLen(subscribeSchema)}, +}; + +// connection/application/ +int32_t mndInitPerfsTableSchema(const SPerfsTableSchema *pSrc, int32_t colNum, SSchema **pDst) { + SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema)); + if (NULL == schema) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + for (int32_t i = 0; i < colNum; ++i) { + strcpy(schema[i].name, pSrc[i].name); + + schema[i].type = pSrc[i].type; + schema[i].colId = i + 1; + schema[i].bytes = pSrc[i].bytes; + } + + *pDst = schema; + return TSDB_CODE_SUCCESS; +} + +int32_t mndPerfsInitMeta(SHashObj *hash) { + STableMetaRsp meta = {0}; + + strcpy(meta.dbFName, TSDB_INFORMATION_SCHEMA_DB); + meta.tableType = TSDB_SYSTEM_TABLE; + meta.sversion = 1; + meta.tversion = 1; + + for (int32_t i = 0; i < tListLen(perfsMeta); ++i) { + strcpy(meta.tbName, perfsMeta[i].name); + meta.numOfColumns = perfsMeta[i].colNum; + + if (mndInitPerfsTableSchema(perfsMeta[i].schema, perfsMeta[i].colNum, &meta.pSchemas)) { + return -1; + } + + if (taosHashPut(hash, meta.tbName, strlen(meta.tbName), &meta, sizeof(meta))) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + } + + return TSDB_CODE_SUCCESS; +} + +int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp) { + if (NULL == pMnode->perfsMeta) { + terrno = TSDB_CODE_MND_NOT_READY; + return -1; + } + + STableMetaRsp *meta = (STableMetaRsp *)taosHashGet(pMnode->perfsMeta, tbName, strlen(tbName)); + if (NULL == meta) { + mError("invalid performance schema table name:%s", tbName); + terrno = TSDB_CODE_MND_INVALID_INFOS_TBL; + return -1; + } + + *pRsp = *meta; + + pRsp->pSchemas = taosMemoryCalloc(meta->numOfColumns, sizeof(SSchema)); + if (pRsp->pSchemas == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + pRsp->pSchemas = NULL; + return -1; + } + + memcpy(pRsp->pSchemas, meta->pSchemas, meta->numOfColumns * sizeof(SSchema)); + + return 0; +} + +int32_t mndInitPerfs(SMnode *pMnode) { + pMnode->perfsMeta = taosHashInit(20, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); + if (pMnode->perfsMeta == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + return mndPerfsInitMeta(pMnode->perfsMeta); +} + +void mndCleanupPerfs(SMnode *pMnode) { + if (NULL == pMnode->perfsMeta) { + return; + } + + void *pIter = taosHashIterate(pMnode->perfsMeta, NULL); + while (pIter) { + STableMetaRsp *meta = (STableMetaRsp *)pIter; + + taosMemoryFreeClear(meta->pSchemas); + + pIter = taosHashIterate(pMnode->perfsMeta, pIter); + } + + taosHashCleanup(pMnode->perfsMeta); + pMnode->perfsMeta = NULL; +} + diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 353a147a92..826a73afc6 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -24,7 +24,7 @@ #include "version.h" typedef struct { - int32_t id; + uint32_t id; int8_t connType; char user[TSDB_USER_LEN]; char app[TSDB_APP_NAME_LEN]; // app name that invokes taosc @@ -35,15 +35,15 @@ typedef struct { int8_t killed; int64_t loginTimeMs; int64_t lastAccessTimeMs; - int32_t queryId; + uint64_t killId; int32_t numOfQueries; - SQueryDesc *pQueries; + SArray *pQueries; //SArray } SConnObj; static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType, uint32_t ip, uint16_t port, int32_t pid, const char *app, int64_t startTime); static void mndFreeConn(SConnObj *pConn); -static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId); +static SConnObj *mndAcquireConn(SMnode *pMnode, uint32_t connId); static void mndReleaseConn(SMnode *pMnode, SConnObj *pConn); static void *mndGetNextConn(SMnode *pMnode, SCacheIter *pIter); static void mndCancelGetNextConn(SMnode *pMnode, void *pIter); @@ -91,8 +91,9 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType int32_t pid, const char *app, int64_t startTime) { SProfileMgmt *pMgmt = &pMnode->profileMgmt; - int32_t connId = atomic_add_fetch_32(&pMgmt->connId, 1); - if (connId == 0) atomic_add_fetch_32(&pMgmt->connId, 1); + char connStr[255] = {0}; + int32_t len = snprintf(connStr, sizeof(connStr), "%s%d%d%d%s", user, ip, port, pid, app); + int32_t connId = mndGenerateUid(connStr, len); if (startTime == 0) startTime = taosGetTimestampMs(); SConnObj connObj = {.id = connId, @@ -104,7 +105,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType .killed = 0, .loginTimeMs = taosGetTimestampMs(), .lastAccessTimeMs = 0, - .queryId = 0, + .killId = 0, .numOfQueries = 0, .pQueries = NULL}; @@ -119,35 +120,35 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType mError("conn:%d, failed to put into cache since %s, user:%s", connId, user, terrstr()); return NULL; } else { - mTrace("conn:%d, is created, data:%p user:%s", pConn->id, pConn, user); + mTrace("conn:%u, is created, data:%p user:%s", pConn->id, pConn, user); return pConn; } } static void mndFreeConn(SConnObj *pConn) { taosMemoryFreeClear(pConn->pQueries); - mTrace("conn:%d, is destroyed, data:%p", pConn->id, pConn); + mTrace("conn:%u, is destroyed, data:%p", pConn->id, pConn); } -static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId) { +static SConnObj *mndAcquireConn(SMnode *pMnode, uint32_t connId) { SProfileMgmt *pMgmt = &pMnode->profileMgmt; - SConnObj *pConn = taosCacheAcquireByKey(pMgmt->cache, &connId, sizeof(int32_t)); + SConnObj *pConn = taosCacheAcquireByKey(pMgmt->cache, &connId, sizeof(connId)); if (pConn == NULL) { - mDebug("conn:%d, already destroyed", connId); + mDebug("conn:%u, already destroyed", connId); return NULL; } int32_t keepTime = tsShellActivityTimer * 3; pConn->lastAccessTimeMs = keepTime * 1000 + (uint64_t)taosGetTimestampMs(); - mTrace("conn:%d, acquired from cache, data:%p", pConn->id, pConn); + mTrace("conn:%u, acquired from cache, data:%p", pConn->id, pConn); return pConn; } static void mndReleaseConn(SMnode *pMnode, SConnObj *pConn) { if (pConn == NULL) return; - mTrace("conn:%d, released from cache, data:%p", pConn->id, pConn); + mTrace("conn:%u, released from cache, data:%p", pConn->id, pConn); SProfileMgmt *pMgmt = &pMnode->profileMgmt; taosCacheRelease(pMgmt->cache, (void **)&pConn, false); @@ -212,6 +213,8 @@ static int32_t mndProcessConnectReq(SNodeMsg *pReq) { goto CONN_OVER; } + mndAcquireConn(pMnode, pConn->id); + SConnectRsp connectRsp = {0}; connectRsp.acctId = pUser->acctId; connectRsp.superUser = pUser->superUser; @@ -232,7 +235,7 @@ static int32_t mndProcessConnectReq(SNodeMsg *pReq) { pReq->rspLen = contLen; pReq->pRsp = pRsp; - mDebug("user:%s, login from %s, conn:%d, app:%s", pReq->user, ip, pConn->id, connReq.app); + mDebug("user:%s, login from %s:%d, conn:%u, app:%s", pReq->user, ip, pConn->port, pConn->id, connReq.app); code = 0; @@ -245,22 +248,13 @@ CONN_OVER: return code; } -static int32_t mndSaveQueryStreamList(SConnObj *pConn, SHeartBeatReq *pReq) { - pConn->numOfQueries = 0; - int32_t numOfQueries = htonl(pReq->numOfQueries); +static int32_t mndSaveQueryList(SConnObj *pConn, SQueryHbReqBasic *pBasic) { + taosArrayDestroyEx(pConn->pQueries, tFreeClientHbQueryDesc); - if (numOfQueries > 0) { - if (pConn->pQueries == NULL) { - pConn->pQueries = taosMemoryCalloc(sizeof(SQueryDesc), QUERY_SAVE_SIZE); - } - - pConn->numOfQueries = TMIN(QUERY_SAVE_SIZE, numOfQueries); - - int32_t saveSize = pConn->numOfQueries * sizeof(SQueryDesc); - if (saveSize > 0 && pConn->pQueries != NULL) { - memcpy(pConn->pQueries, pReq->pData, saveSize); - } - } + pConn->pQueries = pBasic->queryDesc; + pBasic->queryDesc = NULL; + + pConn->numOfQueries = pBasic->queryDesc ? taosArrayGetSize(pBasic->queryDesc) : 0; return TSDB_CODE_SUCCESS; } @@ -330,6 +324,111 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) { return NULL; } +static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHbReq *pHbReq, SClientHbBatchRsp *pBatchRsp) { + SProfileMgmt *pMgmt = &pMnode->profileMgmt; + SClientHbRsp hbRsp = {.connKey = pHbReq->connKey, .status = 0, .info = NULL, .query = NULL}; + + if (pHbReq->query) { + SQueryHbReqBasic *pBasic = pHbReq->query; + + SRpcConnInfo connInfo = {0}; + rpcGetConnInfo(pMsg->handle, &connInfo); + + SConnObj *pConn = mndAcquireConn(pMnode, pBasic->connId); + if (pConn == NULL) { + pConn = mndCreateConn(pMnode, connInfo.user, CONN_TYPE__QUERY, connInfo.clientIp, connInfo.clientPort, pBasic->pid, pBasic->app, 0); + if (pConn == NULL) { + mError("user:%s, conn:%u is freed and failed to create new since %s", connInfo.user, pBasic->connId, terrstr()); + return -1; + } else { + mDebug("user:%s, conn:%u is freed and create a new conn:%u", connInfo.user, pBasic->connId, pConn->id); + } + } else if (pConn->killed) { + mError("user:%s, conn:%u is already killed", connInfo.user, pConn->id); + mndReleaseConn(pMnode, pConn); + terrno = TSDB_CODE_MND_INVALID_CONNECTION; + return -1; + } + + SQueryHbRspBasic *rspBasic = taosMemoryCalloc(1, sizeof(SQueryHbRspBasic)); + if (rspBasic == NULL) { + mndReleaseConn(pMnode, pConn); + terrno = TSDB_CODE_OUT_OF_MEMORY; + mError("user:%s, conn:%u failed to process hb while since %s", pConn->user, pBasic->connId, terrstr()); + return -1; + } + + mndSaveQueryList(pConn, pBasic); + if (pConn->killed != 0) { + rspBasic->killConnection = 1; + } + + if (pConn->killId != 0) { + rspBasic->killRid = pConn->killId; + pConn->killId = 0; + } + + rspBasic->connId = pConn->id; + rspBasic->totalDnodes = 1; //TODO + rspBasic->onlineDnodes = 1; //TODO + mndGetMnodeEpSet(pMnode, &rspBasic->epSet); + mndReleaseConn(pMnode, pConn); + + hbRsp.query = rspBasic; + } + + int32_t kvNum = taosHashGetSize(pHbReq->info); + if (NULL == pHbReq->info || kvNum <= 0) { + taosArrayPush(pBatchRsp->rsps, &hbRsp); + return TSDB_CODE_SUCCESS; + } + + hbRsp.info = taosArrayInit(kvNum, sizeof(SKv)); + if (NULL == hbRsp.info) { + mError("taosArrayInit %d rsp kv failed", kvNum); + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + void *pIter = taosHashIterate(pHbReq->info, NULL); + while (pIter != NULL) { + SKv *kv = pIter; + + switch (kv->key) { + case HEARTBEAT_KEY_DBINFO: { + void *rspMsg = NULL; + int32_t rspLen = 0; + mndValidateDbInfo(pMnode, kv->value, kv->valueLen / sizeof(SDbVgVersion), &rspMsg, &rspLen); + if (rspMsg && rspLen > 0) { + SKv kv1 = {.key = HEARTBEAT_KEY_DBINFO, .valueLen = rspLen, .value = rspMsg}; + taosArrayPush(hbRsp.info, &kv1); + } + break; + } + case HEARTBEAT_KEY_STBINFO: { + void *rspMsg = NULL; + int32_t rspLen = 0; + mndValidateStbInfo(pMnode, kv->value, kv->valueLen / sizeof(SSTableMetaVersion), &rspMsg, &rspLen); + if (rspMsg && rspLen > 0) { + SKv kv1 = {.key = HEARTBEAT_KEY_STBINFO, .valueLen = rspLen, .value = rspMsg}; + taosArrayPush(hbRsp.info, &kv1); + } + break; + } + default: + mError("invalid kv key:%d", kv->key); + hbRsp.status = TSDB_CODE_MND_APP_ERROR; + break; + } + + pIter = taosHashIterate(pHbReq->info, pIter); + } + + taosArrayPush(pBatchRsp->rsps, &hbRsp); + + return TSDB_CODE_SUCCESS; +} + static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) { SMnode *pMnode = pReq->pNode; @@ -345,50 +444,9 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) { int32_t sz = taosArrayGetSize(batchReq.reqs); for (int i = 0; i < sz; i++) { SClientHbReq *pHbReq = taosArrayGet(batchReq.reqs, i); - if (pHbReq->connKey.hbType == HEARTBEAT_TYPE_QUERY) { - int32_t kvNum = taosHashGetSize(pHbReq->info); - if (NULL == pHbReq->info || kvNum <= 0) { - continue; - } - - SClientHbRsp hbRsp = {.connKey = pHbReq->connKey, .status = 0, .info = taosArrayInit(kvNum, sizeof(SKv))}; - - void *pIter = taosHashIterate(pHbReq->info, NULL); - while (pIter != NULL) { - SKv *kv = pIter; - - switch (kv->key) { - case HEARTBEAT_KEY_DBINFO: { - void *rspMsg = NULL; - int32_t rspLen = 0; - mndValidateDbInfo(pMnode, kv->value, kv->valueLen / sizeof(SDbVgVersion), &rspMsg, &rspLen); - if (rspMsg && rspLen > 0) { - SKv kv1 = {.key = HEARTBEAT_KEY_DBINFO, .valueLen = rspLen, .value = rspMsg}; - taosArrayPush(hbRsp.info, &kv1); - } - break; - } - case HEARTBEAT_KEY_STBINFO: { - void *rspMsg = NULL; - int32_t rspLen = 0; - mndValidateStbInfo(pMnode, kv->value, kv->valueLen / sizeof(SSTableMetaVersion), &rspMsg, &rspLen); - if (rspMsg && rspLen > 0) { - SKv kv1 = {.key = HEARTBEAT_KEY_STBINFO, .valueLen = rspLen, .value = rspMsg}; - taosArrayPush(hbRsp.info, &kv1); - } - break; - } - default: - mError("invalid kv key:%d", kv->key); - hbRsp.status = TSDB_CODE_MND_APP_ERROR; - break; - } - - pIter = taosHashIterate(pHbReq->info, pIter); - } - - taosArrayPush(batchRsp.rsps, &hbRsp); - } else if (pHbReq->connKey.hbType == HEARTBEAT_TYPE_MQ) { + if (pHbReq->connKey.connType == CONN_TYPE__QUERY) { + mndProcessQueryHeartBeat(pMnode, &pReq->rpcMsg, pHbReq, &batchRsp); + } else if (pHbReq->connKey.connType == CONN_TYPE__TMQ) { SClientHbRsp *pRsp = mndMqHbBuildRsp(pMnode, pHbReq); if (pRsp != NULL) { taosArrayPush(batchRsp.rsps, pRsp); @@ -416,73 +474,8 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) { taosArrayDestroy(batchRsp.rsps); pReq->rspLen = tlen; pReq->pRsp = buf; + return 0; - -#if 0 - SMnode *pMnode = pReq->pNode; - SProfileMgmt *pMgmt = &pMnode->profileMgmt; - - SHeartBeatReq *pHeartbeat = pReq->rpcMsg.pCont; - pHeartbeat->connId = htonl(pHeartbeat->connId); - pHeartbeat->pid = htonl(pHeartbeat->pid); - - SConnObj *pConn = mndAcquireConn(pMnode, pHeartbeat->connId); - if (pConn == NULL) { - pConn = mndCreateConn(pMnode, &info, pHeartbeat->pid, pHeartbeat->app, 0); - if (pConn == NULL) { - mError("user:%s, conn:%d is freed and failed to create new since %s", pReq->user, pHeartbeat->connId, terrstr()); - return -1; - } else { - mDebug("user:%s, conn:%d is freed and create a new conn:%d", pReq->user, pHeartbeat->connId, pConn->id); - } - } else if (pConn->killed) { - mError("user:%s, conn:%d is already killed", pReq->user, pConn->id); - terrno = TSDB_CODE_MND_INVALID_CONNECTION; - return -1; - } else { - if (pConn->ip != info.clientIp || pConn->port != info.clientPort /* || strcmp(pConn->user, info.user) != 0 */) { - char oldIpStr[40]; - char newIpStr[40]; - taosIpPort2String(pConn->ip, pConn->port, oldIpStr); - taosIpPort2String(info.clientIp, info.clientPort, newIpStr); - mError("conn:%d, incoming conn user:%s ip:%s, not match exist user:%s ip:%s", pConn->id, info.user, newIpStr, - pConn->user, oldIpStr); - - if (pMgmt->connId < pConn->id) pMgmt->connId = pConn->id + 1; - taosCacheRelease(pMgmt->cache, (void **)&pConn, false); - terrno = TSDB_CODE_MND_INVALID_CONNECTION; - return -1; - } - } - - SHeartBeatRsp *pRsp = rpcMallocCont(sizeof(SHeartBeatRsp)); - if (pRsp == NULL) { - mndReleaseConn(pMnode, pConn); - terrno = TSDB_CODE_OUT_OF_MEMORY; - mError("user:%s, conn:%d failed to process hb while since %s", pReq->user, pHeartbeat->connId, terrstr()); - return -1; - } - - mndSaveQueryStreamList(pConn, pHeartbeat); - if (pConn->killed != 0) { - pRsp->killConnection = 1; - } - - if (pConn->queryId != 0) { - pRsp->queryId = htonl(pConn->queryId); - pConn->queryId = 0; - } - - pRsp->connId = htonl(pConn->id); - pRsp->totalDnodes = htonl(1); - pRsp->onlineDnodes = htonl(1); - mndGetMnodeEpSet(pMnode, &pRsp->epSet); - mndReleaseConn(pMnode, pConn); - - pReq->contLen = sizeof(SConnectRsp); - pReq->pRsp = pRsp; - return 0; -#endif } static int32_t mndProcessKillQueryReq(SNodeMsg *pReq) { @@ -513,7 +506,7 @@ static int32_t mndProcessKillQueryReq(SNodeMsg *pReq) { return -1; } else { mInfo("connId:%d, queryId:%d is killed by user:%s", killReq.connId, killReq.queryId, pReq->user); - pConn->queryId = killReq.queryId; + pConn->killId = killReq.queryId; taosCacheRelease(pMgmt->cache, (void **)&pConn, false); return 0; } @@ -571,7 +564,7 @@ static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int cols = 0; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int32_t *)pWrite = pConn->id; + *(uint32_t *)pWrite = pConn->id; cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; @@ -613,6 +606,7 @@ static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) { SMnode *pMnode = pReq->pNode; int32_t numOfRows = 0; +#if 0 SConnObj *pConn = NULL; int32_t cols = 0; char *pWrite; @@ -709,6 +703,7 @@ static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, i } pShow->numOfRows += numOfRows; +#endif return numOfRows; } diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 92a67fd7e9..0ce73005e8 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -18,6 +18,7 @@ #include "mndDb.h" #include "mndDnode.h" #include "mndInfoSchema.h" +#include "mndPerfSchema.h" #include "mndMnode.h" #include "mndShow.h" #include "mndTrans.h" @@ -1516,6 +1517,11 @@ static int32_t mndProcessTableMetaReq(SNodeMsg *pReq) { if (mndBuildInsTableSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) { goto RETRIEVE_META_OVER; } + } else if (0 == strcmp(infoReq.dbFName, TSDB_PERFORMANCE_SCHEMA_DB)) { + mDebug("performance_schema table:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName); + if (mndBuildPerfsTableSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) { + goto RETRIEVE_META_OVER; + } } else { mDebug("stb:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName); if (mndBuildStbSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) { diff --git a/source/dnode/mnode/impl/src/mnode.c b/source/dnode/mnode/impl/src/mnode.c index f765b0ce11..3ac1c522b2 100644 --- a/source/dnode/mnode/impl/src/mnode.c +++ b/source/dnode/mnode/impl/src/mnode.c @@ -23,6 +23,7 @@ #include "mndDnode.h" #include "mndFunc.h" #include "mndInfoSchema.h" +#include "mndPerfSchema.h" #include "mndMnode.h" #include "mndOffset.h" #include "mndProfile.h" @@ -210,6 +211,7 @@ static int32_t mndInitSteps(SMnode *pMnode, bool deploy) { if (mndAllocStep(pMnode, "mnode-stb", mndInitStb, mndCleanupStb) != 0) return -1; if (mndAllocStep(pMnode, "mnode-stb", mndInitSma, mndCleanupSma) != 0) return -1; if (mndAllocStep(pMnode, "mnode-infos", mndInitInfos, mndCleanupInfos) != 0) return -1; + if (mndAllocStep(pMnode, "mnode-perfs", mndInitPerfs, mndCleanupPerfs) != 0) return -1; if (mndAllocStep(pMnode, "mnode-db", mndInitDb, mndCleanupDb) != 0) return -1; if (mndAllocStep(pMnode, "mnode-func", mndInitFunc, mndCleanupFunc) != 0) return -1; if (deploy) { diff --git a/source/dnode/mnode/impl/test/profile/profile.cpp b/source/dnode/mnode/impl/test/profile/profile.cpp index f4be703d72..b9b21ebed9 100644 --- a/source/dnode/mnode/impl/test/profile/profile.cpp +++ b/source/dnode/mnode/impl/test/profile/profile.cpp @@ -82,7 +82,7 @@ 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 = {.connId = 123, .hbType = CONN_TYPE__TMQ}; req.info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK); SKv kv = {0}; kv.key = 123; diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index 3ab007e3a2..c0e458219c 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -4,13 +4,13 @@ target_sources( vnode PRIVATE # vnode + "src/vnd/vnodeOpen.c" "src/vnd/vnodeArenaMAImpl.c" "src/vnd/vnodeBufferPool.c" # "src/vnd/vnodeBufferPool2.c" "src/vnd/vnodeCfg.c" "src/vnd/vnodeCommit.c" "src/vnd/vnodeInt.c" - "src/vnd/vnodeMain.c" "src/vnd/vnodeQuery.c" "src/vnd/vnodeStateMgr.c" "src/vnd/vnodeWrite.c" diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 76fc09ca1d..25c6ffc1ad 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -42,11 +42,12 @@ typedef struct STsdbCfg STsdbCfg; // todo: remove typedef struct STqCfg STqCfg; // todo: remove typedef struct SVnodeCfg SVnodeCfg; -int vnodeInit(); +int vnodeInit(int nthreads); void vnodeCleanup(); +int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs); +void vnodeDestroy(const char *path); SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg); void vnodeClose(SVnode *pVnode); -void vnodeDestroy(const char *path); void vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs); int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); int vnodeProcessCMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index 1cdb38b650..913fec64ed 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -30,6 +30,8 @@ extern "C" { #define vTrace(...) do { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", DEBUG_TRACE, vDebugFlag, __VA_ARGS__); }} while(0) // clang-format on +// vnodeCfg ==================== + // vnodeModule ==================== int vnodeScheduleTask(int (*execute)(void*), void* arg); @@ -38,6 +40,10 @@ 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 int vnodeOpenBufPool(SVnode* pVnode); @@ -75,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 f988df01cb..b0b87665ed 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.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; diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index ef417cabc6..34b983c20c 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -15,14 +15,15 @@ #include "vnodeInt.h" -const SVnodeCfg defaultVnodeOptions = { - .wsize = 96 * 1024 * 1024, .ssize = 1 * 1024 * 1024, .lsize = 1024, .walCfg = {.level = TAOS_WAL_WRITE}}; /* TODO */ +const SVnodeCfg vnodeCfgDefault = { + .wsize = 96 * 1024 * 1024, .ssize = 1 * 1024 * 1024, .lsize = 1024, .walCfg = {.level = TAOS_WAL_WRITE}}; -int vnodeValidateOptions(const SVnodeCfg *pVnodeOptions) { +int vnodeCheckCfg(const SVnodeCfg *pCfg) { // TODO return 0; } +#if 1 //====================================================================== void vnodeOptionsCopy(SVnodeCfg *pDest, const SVnodeCfg *pSrc) { memcpy((void *)pDest, (void *)pSrc, sizeof(SVnodeCfg)); } @@ -46,3 +47,5 @@ int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName) { return TSDB_CODE_SUCCESS; } + +#endif \ No newline at end of file diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index b4c3725a5e..fc74ee9253 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/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 2fd848a39d..5fa14f6018 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/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index 09f51dc03e..8938084724 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -227,20 +227,20 @@ typedef struct SCtgAction { #define CTG_FLAG_STB 0x1 #define CTG_FLAG_NOT_STB 0x2 #define CTG_FLAG_UNKNOWN_STB 0x4 -#define CTG_FLAG_INF_DB 0x8 +#define CTG_FLAG_SYS_DB 0x8 #define CTG_FLAG_FORCE_UPDATE 0x10 #define CTG_FLAG_IS_STB(_flag) ((_flag) & CTG_FLAG_STB) #define CTG_FLAG_IS_NOT_STB(_flag) ((_flag) & CTG_FLAG_NOT_STB) #define CTG_FLAG_IS_UNKNOWN_STB(_flag) ((_flag) & CTG_FLAG_UNKNOWN_STB) -#define CTG_FLAG_IS_INF_DB(_flag) ((_flag) & CTG_FLAG_INF_DB) +#define CTG_FLAG_IS_SYS_DB(_flag) ((_flag) & CTG_FLAG_SYS_DB) #define CTG_FLAG_IS_FORCE_UPDATE(_flag) ((_flag) & CTG_FLAG_FORCE_UPDATE) -#define CTG_FLAG_SET_INF_DB(_flag) ((_flag) |= CTG_FLAG_INF_DB) +#define CTG_FLAG_SET_SYS_DB(_flag) ((_flag) |= CTG_FLAG_SYS_DB) #define CTG_FLAG_SET_STB(_flag, tbType) do { (_flag) |= ((tbType) == TSDB_SUPER_TABLE) ? CTG_FLAG_STB : ((tbType) > TSDB_SUPER_TABLE ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB); } while (0) #define CTG_FLAG_MAKE_STB(_isStb) (((_isStb) == 1) ? CTG_FLAG_STB : ((_isStb) == 0 ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB)) #define CTG_FLAG_MATCH_STB(_flag, tbType) (CTG_FLAG_IS_UNKNOWN_STB(_flag) || (CTG_FLAG_IS_STB(_flag) && (tbType) == TSDB_SUPER_TABLE) || (CTG_FLAG_IS_NOT_STB(_flag) && (tbType) != TSDB_SUPER_TABLE)) -#define CTG_IS_INF_DBNAME(_dbname) ((*(_dbname) == 'i') && (0 == strcmp(_dbname, TSDB_INFORMATION_SCHEMA_DB))) +#define CTG_IS_SYS_DBNAME(_dbname) (((*(_dbname) == 'i') && (0 == strcmp(_dbname, TSDB_INFORMATION_SCHEMA_DB))) || ((*(_dbname) == 'p') && (0 == strcmp(_dbname, TSDB_PERFORMANCE_SCHEMA_DB)))) #define CTG_META_SIZE(pMeta) (sizeof(STableMeta) + ((pMeta)->tableInfo.numOfTags + (pMeta)->tableInfo.numOfColumns) * sizeof(SSchema)) diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 2aa858fe06..21e0be40a4 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -217,7 +217,7 @@ int32_t ctgPushRmDBMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId) } char *p = strchr(dbFName, '.'); - if (p && CTG_IS_INF_DBNAME(p + 1)) { + if (p && CTG_IS_SYS_DBNAME(p + 1)) { dbFName = p + 1; } @@ -304,7 +304,7 @@ int32_t ctgPushUpdateVgMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t d } char *p = strchr(dbFName, '.'); - if (p && CTG_IS_INF_DBNAME(p + 1)) { + if (p && CTG_IS_SYS_DBNAME(p + 1)) { dbFName = p + 1; } @@ -336,7 +336,7 @@ int32_t ctgPushUpdateTblMsgInQueue(SCatalog* pCtg, STableMetaOutput *output, boo } char *p = strchr(output->dbFName, '.'); - if (p && CTG_IS_INF_DBNAME(p + 1)) { + if (p && CTG_IS_SYS_DBNAME(p + 1)) { memmove(output->dbFName, p + 1, strlen(p + 1)); } @@ -410,7 +410,7 @@ void ctgWReleaseVgInfo(SCtgDBCache *dbCache) { int32_t ctgAcquireDBCacheImpl(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache, bool acquire) { char *p = strchr(dbFName, '.'); - if (p && CTG_IS_INF_DBNAME(p + 1)) { + if (p && CTG_IS_SYS_DBNAME(p + 1)) { dbFName = p + 1; } @@ -688,7 +688,7 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable } char dbFName[TSDB_DB_FNAME_LEN] = {0}; - if (CTG_FLAG_IS_INF_DB(flag)) { + if (CTG_FLAG_IS_SYS_DB(flag)) { strcpy(dbFName, pTableName->dbname); } else { tNameGetFullDbName(pTableName, dbFName); @@ -1721,7 +1721,7 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, SVgroupInfo vgroupInfo = {0}; int32_t code = 0; - if (!CTG_FLAG_IS_INF_DB(flag)) { + if (!CTG_FLAG_IS_SYS_DB(flag)) { CTG_ERR_RET(catalogGetTableHashVgroup(pCtg, pTrans, pMgmtEps, pTableName, &vgroupInfo)); } @@ -1732,7 +1732,7 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); } - if (CTG_FLAG_IS_INF_DB(flag)) { + if (CTG_FLAG_IS_SYS_DB(flag)) { ctgDebug("will refresh tbmeta, supposed in information_schema, tbName:%s", tNameGetTableName(pTableName)); CTG_ERR_JRET(ctgGetTableMetaFromMnodeImpl(pCtg, pTrans, pMgmtEps, (char *)pTableName->dbname, (char *)pTableName->tname, output)); @@ -1820,8 +1820,8 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons uint64_t suid = 0; STableMetaOutput *output = NULL; - if (CTG_IS_INF_DBNAME(pTableName->dbname)) { - CTG_FLAG_SET_INF_DB(flag); + if (CTG_IS_SYS_DBNAME(pTableName->dbname)) { + CTG_FLAG_SET_SYS_DB(flag); } CTG_ERR_RET(ctgGetTableMetaFromCache(pCtg, pTableName, pTableMeta, &inCache, flag, &dbId)); @@ -1829,7 +1829,7 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons int32_t tbType = 0; if (inCache) { - if (CTG_FLAG_MATCH_STB(flag, (*pTableMeta)->tableType) && ((!CTG_FLAG_IS_FORCE_UPDATE(flag)) || (CTG_FLAG_IS_INF_DB(flag)))) { + if (CTG_FLAG_MATCH_STB(flag, (*pTableMeta)->tableType) && ((!CTG_FLAG_IS_FORCE_UPDATE(flag)) || (CTG_FLAG_IS_SYS_DB(flag)))) { goto _return; } @@ -1885,7 +1885,7 @@ _return: if (CTG_TABLE_NOT_EXIST(code) && inCache) { char dbFName[TSDB_DB_FNAME_LEN] = {0}; - if (CTG_FLAG_IS_INF_DB(flag)) { + if (CTG_FLAG_IS_SYS_DB(flag)) { strcpy(dbFName, pTableName->dbname); } else { tNameGetFullDbName(pTableName, dbFName); @@ -2633,7 +2633,7 @@ int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgm CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } - if (CTG_IS_INF_DBNAME(pTableName->dbname)) { + if (CTG_IS_SYS_DBNAME(pTableName->dbname)) { ctgError("no valid vgInfo for db, dbname:%s", pTableName->dbname); CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } @@ -2666,7 +2666,7 @@ _return: int32_t catalogGetTableHashVgroup(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, SVgroupInfo *pVgroup) { CTG_API_ENTER(); - if (CTG_IS_INF_DBNAME(pTableName->dbname)) { + if (CTG_IS_SYS_DBNAME(pTableName->dbname)) { ctgError("no valid vgInfo for db, dbname:%s", pTableName->dbname); CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 49504b2cd4..6ed1f891a4 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -782,6 +782,26 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .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, @@ -851,16 +871,6 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .initFunc = NULL, .sprocessFunc = winDurFunction, .finalizeFunc = NULL - }, - { - .name = "now", - .type = FUNCTION_TYPE_NOW, - .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC, - .translateFunc = translateTimePseudoColumn, - .getEnvFunc = getTimePseudoFuncEnv, - .initFunc = NULL, - .sprocessFunc = winDurFunction, - .finalizeFunc = NULL } }; diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index e1a486d8b1..8731b26c4a 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -1201,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 1fa3a18668..b4319b4747 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -92,6 +92,7 @@ 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); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 3c3cea8ea3..d6fc943265 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,6 +537,7 @@ 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)))); } +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; } @@ -581,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 accf99606a..884549b118 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -360,6 +360,39 @@ 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); diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 9e53eee5c8..acc597d61b 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -223,11 +223,15 @@ static int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pPar return code; } -static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) { +static int32_t getTableMetaImpl(SInsertParseContext* pCxt, SToken* pTname, bool isStb) { SParseContext* pBasicCtx = pCxt->pComCxt; SName name = {0}; createSName(&name, pTname, pBasicCtx, &pCxt->msg); - CHECK_CODE(catalogGetTableMeta(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &pCxt->pTableMeta)); + if (isStb) { + CHECK_CODE(catalogGetSTableMeta(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &pCxt->pTableMeta)); + } else { + CHECK_CODE(catalogGetTableMeta(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &pCxt->pTableMeta)); + } SVgroupInfo vg; CHECK_CODE(catalogGetTableHashVgroup(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &vg)); CHECK_CODE(taosHashPut(pCxt->pVgroupsHashObj, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg))); @@ -235,6 +239,15 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) { return TSDB_CODE_SUCCESS; } +static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) { + return getTableMetaImpl(pCxt, pTname, false); +} + +static int32_t getSTableMeta(SInsertParseContext* pCxt, SToken* pTname) { + return getTableMetaImpl(pCxt, pTname, true); +} + + static int32_t findCol(SToken* pColname, int32_t start, int32_t end, SSchema* pSchema) { while (start < end) { if (strlen(pSchema[start].name) == pColname->n && strncmp(pColname->z, pSchema[start].name, pColname->n) == 0) { @@ -818,7 +831,7 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SToken* pTbnameToken) SToken sToken; // pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...) NEXT_TOKEN(pCxt->pSql, sToken); - CHECK_CODE(getTableMeta(pCxt, &sToken)); + CHECK_CODE(getSTableMeta(pCxt, &sToken)); if (TSDB_SUPER_TABLE != pCxt->pTableMeta->tableType) { return buildInvalidOperationMsg(&pCxt->msg, "create table only from super table is allowed"); } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index d3f5af3eb2..f4436bb3e2 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -133,16 +133,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYNSTATE 550 -#define YYNRULE 411 +#define YYNRULE 412 +#define YYNRULE_WITH_ACTION 412 #define YYNTOKEN 210 #define YY_MAX_SHIFT 549 -#define YY_MIN_SHIFTREDUCE 810 -#define YY_MAX_SHIFTREDUCE 1220 -#define YY_ERROR_ACTION 1221 -#define YY_ACCEPT_ACTION 1222 -#define YY_NO_ACTION 1223 -#define YY_MIN_REDUCE 1224 -#define YY_MAX_REDUCE 1634 +#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]))) @@ -209,322 +210,322 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (1556) +#define YY_ACTTAB_COUNT (1559) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 452, 258, 1485, 270, 275, 452, 1434, 25, 195, 313, - /* 10 */ 465, 1435, 30, 28, 1481, 1488, 307, 1501, 1485, 311, - /* 20 */ 267, 1485, 1055, 1613, 1335, 32, 31, 29, 27, 26, - /* 30 */ 1481, 1487, 21, 1481, 1487, 1344, 1612, 1078, 1053, 239, - /* 40 */ 1611, 1518, 32, 31, 29, 27, 26, 1613, 447, 464, - /* 50 */ 11, 30, 28, 1163, 118, 407, 1236, 1060, 451, 267, - /* 60 */ 132, 1055, 1472, 1162, 1611, 30, 28, 435, 165, 1472, - /* 70 */ 431, 1075, 373, 267, 1, 1055, 465, 1053, 69, 1502, - /* 80 */ 1503, 1507, 1552, 542, 541, 73, 241, 1548, 1177, 11, - /* 90 */ 1501, 1053, 370, 1518, 375, 101, 1060, 546, 1613, 408, - /* 100 */ 447, 1344, 446, 11, 32, 31, 29, 27, 26, 1054, - /* 110 */ 1060, 132, 23, 1, 1518, 1611, 32, 31, 29, 27, - /* 120 */ 26, 434, 32, 31, 29, 27, 26, 1, 99, 119, - /* 130 */ 1613, 451, 424, 1302, 123, 1472, 546, 433, 128, 1559, - /* 140 */ 1560, 1077, 1564, 132, 464, 1384, 1056, 1611, 1054, 278, - /* 150 */ 546, 70, 1502, 1503, 1507, 1552, 1425, 1427, 349, 260, - /* 160 */ 1548, 127, 1054, 1059, 1079, 1080, 449, 1106, 1107, 1108, - /* 170 */ 1109, 1110, 1111, 1112, 1113, 1114, 29, 27, 26, 1094, - /* 180 */ 1580, 1079, 1080, 1222, 425, 1056, 85, 133, 1276, 84, - /* 190 */ 83, 82, 81, 80, 79, 78, 77, 76, 12, 1056, - /* 200 */ 382, 381, 1059, 1079, 1080, 449, 1106, 1107, 1108, 1109, - /* 210 */ 1110, 1111, 1112, 1113, 1114, 1118, 1059, 1079, 1080, 449, - /* 220 */ 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 30, - /* 230 */ 28, 1217, 442, 398, 1501, 53, 283, 267, 133, 1055, - /* 240 */ 384, 465, 378, 306, 1247, 305, 383, 1161, 97, 98, - /* 250 */ 73, 379, 377, 1322, 380, 1053, 1339, 376, 1518, 32, - /* 260 */ 31, 29, 27, 26, 1613, 434, 1344, 1613, 30, 28, - /* 270 */ 450, 1246, 1055, 133, 1060, 451, 267, 132, 1055, 1472, - /* 280 */ 132, 1611, 30, 28, 1611, 133, 421, 1501, 1053, 1472, - /* 290 */ 267, 7, 1055, 138, 1053, 70, 1502, 1503, 1507, 1552, - /* 300 */ 1216, 464, 349, 260, 1548, 127, 465, 1060, 1053, 1224, - /* 310 */ 898, 1518, 396, 1060, 546, 312, 1472, 191, 447, 51, - /* 320 */ 9, 8, 50, 414, 1579, 394, 1054, 1060, 451, 900, - /* 330 */ 7, 1344, 1472, 94, 93, 92, 91, 90, 89, 88, - /* 340 */ 87, 86, 426, 422, 7, 1225, 271, 546, 71, 1502, - /* 350 */ 1503, 1507, 1552, 546, 116, 12, 1551, 1548, 847, 1054, - /* 360 */ 846, 335, 1346, 1056, 500, 1054, 85, 546, 443, 84, - /* 370 */ 83, 82, 81, 80, 79, 78, 77, 76, 848, 1054, - /* 380 */ 1059, 1079, 1080, 449, 1106, 1107, 1108, 1109, 1110, 1111, - /* 390 */ 1112, 1113, 1114, 431, 1139, 1391, 1056, 32, 31, 29, - /* 400 */ 27, 26, 1056, 384, 133, 378, 1426, 142, 141, 383, - /* 410 */ 1245, 53, 98, 1059, 379, 377, 1056, 380, 101, 1059, - /* 420 */ 1079, 1080, 449, 1106, 1107, 1108, 1109, 1110, 1111, 1112, - /* 430 */ 1113, 1114, 1340, 1059, 1079, 1080, 449, 1106, 1107, 1108, - /* 440 */ 1109, 1110, 1111, 1112, 1113, 1114, 30, 28, 238, 438, - /* 450 */ 1075, 99, 1566, 1566, 267, 1472, 1055, 328, 60, 1422, - /* 460 */ 340, 129, 1559, 1560, 1244, 1564, 140, 1187, 133, 341, - /* 470 */ 1563, 1562, 1053, 32, 31, 29, 27, 26, 1076, 1337, - /* 480 */ 936, 488, 487, 486, 940, 485, 942, 943, 484, 945, - /* 490 */ 481, 1060, 951, 478, 953, 954, 475, 472, 389, 1391, - /* 500 */ 418, 1185, 1186, 1188, 1189, 257, 1391, 465, 1, 1472, - /* 510 */ 1389, 242, 465, 397, 431, 465, 320, 1390, 1243, 1571, - /* 520 */ 1158, 321, 1391, 115, 348, 465, 502, 167, 272, 1081, - /* 530 */ 392, 546, 1344, 1389, 1341, 386, 1094, 1344, 1082, 101, - /* 540 */ 1344, 166, 339, 1054, 1126, 334, 333, 332, 331, 330, - /* 550 */ 1344, 327, 326, 325, 324, 323, 319, 318, 317, 316, - /* 560 */ 315, 314, 1273, 1472, 117, 465, 503, 43, 1316, 223, - /* 570 */ 42, 66, 99, 1566, 462, 32, 31, 29, 27, 26, - /* 580 */ 1056, 221, 130, 1559, 1560, 102, 1564, 465, 6, 1242, - /* 590 */ 1344, 1561, 1336, 1127, 143, 491, 463, 1059, 1079, 1080, - /* 600 */ 449, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, - /* 610 */ 465, 1131, 1344, 242, 522, 521, 520, 519, 282, 209, - /* 620 */ 518, 517, 516, 103, 511, 510, 509, 508, 507, 506, - /* 630 */ 505, 504, 109, 1128, 1472, 1344, 549, 24, 265, 1121, - /* 640 */ 1122, 1123, 1124, 1125, 1129, 1130, 1126, 190, 1320, 437, - /* 650 */ 214, 1132, 277, 96, 1241, 1240, 176, 68, 280, 538, - /* 660 */ 116, 534, 530, 526, 213, 1391, 116, 846, 1346, 1239, - /* 670 */ 1238, 279, 515, 513, 1346, 251, 1389, 22, 1170, 1235, - /* 680 */ 116, 1234, 439, 368, 1077, 49, 48, 310, 1347, 137, - /* 690 */ 67, 1233, 1333, 207, 304, 1127, 298, 500, 1329, 1472, - /* 700 */ 1472, 165, 247, 465, 296, 373, 292, 288, 134, 1492, - /* 710 */ 1232, 300, 281, 1131, 1472, 1472, 1461, 252, 1231, 250, - /* 720 */ 249, 1490, 372, 461, 1472, 1501, 1472, 375, 1344, 1230, - /* 730 */ 1229, 1158, 1228, 133, 217, 1227, 1472, 1374, 1263, 24, - /* 740 */ 265, 1121, 1122, 1123, 1124, 1125, 1129, 1130, 1063, 1518, - /* 750 */ 1258, 413, 290, 514, 172, 1472, 447, 301, 1331, 158, - /* 760 */ 385, 1501, 156, 1472, 160, 162, 451, 159, 161, 1039, - /* 770 */ 1472, 169, 387, 1501, 1472, 1472, 164, 1472, 1256, 163, - /* 780 */ 1472, 9, 8, 1219, 1220, 1518, 70, 1502, 1503, 1507, - /* 790 */ 1552, 65, 447, 1327, 260, 1548, 1625, 1518, 406, 107, - /* 800 */ 390, 62, 451, 410, 447, 1586, 1472, 45, 179, 1062, - /* 810 */ 170, 1184, 181, 34, 451, 1501, 440, 1133, 1472, 1066, - /* 820 */ 448, 1501, 70, 1502, 1503, 1507, 1552, 490, 1237, 34, - /* 830 */ 260, 1548, 1625, 1090, 70, 1502, 1503, 1507, 1552, 1518, - /* 840 */ 192, 1609, 260, 1548, 1625, 1518, 447, 34, 1303, 419, - /* 850 */ 198, 1022, 447, 1570, 200, 95, 451, 344, 153, 457, - /* 860 */ 1472, 126, 451, 1385, 105, 435, 1472, 366, 206, 362, - /* 870 */ 358, 354, 152, 1501, 405, 185, 229, 1502, 1503, 1507, - /* 880 */ 1065, 872, 71, 1502, 1503, 1507, 1552, 367, 107, 45, - /* 890 */ 445, 1548, 929, 924, 1582, 470, 1613, 1518, 54, 957, - /* 900 */ 873, 150, 432, 105, 447, 1519, 106, 961, 107, 132, - /* 910 */ 967, 105, 966, 1611, 451, 108, 1075, 194, 1472, 2, - /* 920 */ 1501, 285, 289, 246, 248, 898, 1031, 215, 322, 139, - /* 930 */ 1424, 329, 337, 336, 120, 1502, 1503, 1507, 338, 342, - /* 940 */ 1086, 343, 1085, 431, 1518, 1084, 345, 145, 346, 347, - /* 950 */ 148, 447, 52, 350, 151, 1083, 369, 399, 149, 371, - /* 960 */ 122, 451, 146, 75, 1334, 1472, 401, 155, 101, 1330, - /* 970 */ 374, 256, 436, 1626, 400, 1501, 157, 110, 171, 144, - /* 980 */ 111, 71, 1502, 1503, 1507, 1552, 1332, 435, 1328, 112, - /* 990 */ 1549, 113, 402, 174, 1082, 274, 273, 409, 420, 1518, - /* 1000 */ 412, 99, 1501, 411, 1593, 1068, 447, 177, 455, 1592, - /* 1010 */ 1501, 188, 1559, 430, 1060, 429, 451, 5, 1613, 1583, - /* 1020 */ 1472, 1061, 417, 266, 180, 259, 1518, 423, 428, 100, - /* 1030 */ 4, 132, 416, 447, 1518, 1611, 234, 1502, 1503, 1507, - /* 1040 */ 1060, 447, 1158, 451, 1501, 1081, 1567, 1472, 35, 441, - /* 1050 */ 415, 451, 1501, 125, 1573, 1472, 261, 1501, 187, 444, - /* 1060 */ 186, 184, 17, 234, 1502, 1503, 1507, 1610, 1518, 1534, - /* 1070 */ 1433, 233, 1502, 1503, 1507, 447, 1518, 193, 453, 454, - /* 1080 */ 466, 1518, 1432, 447, 269, 451, 1501, 1628, 447, 1472, - /* 1090 */ 458, 460, 1064, 451, 459, 202, 204, 1472, 451, 216, - /* 1100 */ 264, 59, 1472, 427, 1345, 120, 1502, 1503, 1507, 61, - /* 1110 */ 1518, 1501, 468, 234, 1502, 1503, 1507, 447, 226, 1502, - /* 1120 */ 1503, 1507, 497, 218, 1317, 212, 545, 451, 41, 1069, - /* 1130 */ 220, 1472, 224, 225, 268, 1518, 1466, 222, 1465, 284, - /* 1140 */ 1462, 286, 447, 287, 1627, 1049, 1072, 234, 1502, 1503, - /* 1150 */ 1507, 1050, 451, 135, 291, 1460, 1472, 1501, 293, 295, - /* 1160 */ 294, 1459, 297, 1458, 299, 1501, 1449, 136, 302, 303, - /* 1170 */ 1034, 1443, 232, 1502, 1503, 1507, 1033, 1442, 308, 1441, - /* 1180 */ 309, 1518, 1440, 1005, 1417, 1416, 1415, 1414, 447, 1518, - /* 1190 */ 1413, 1412, 1411, 1501, 104, 1401, 447, 1410, 451, 1501, - /* 1200 */ 1007, 1395, 1472, 1409, 1408, 1407, 451, 1406, 1405, 1404, - /* 1210 */ 1472, 1403, 1402, 1400, 1399, 1398, 1397, 1518, 235, 1502, - /* 1220 */ 1503, 1507, 1396, 1518, 447, 1394, 227, 1502, 1503, 1507, - /* 1230 */ 447, 1393, 1392, 1275, 451, 1457, 1451, 1439, 1472, 1430, - /* 1240 */ 451, 147, 1323, 1274, 1472, 1501, 352, 865, 1272, 353, - /* 1250 */ 1501, 1270, 1268, 356, 236, 1502, 1503, 1507, 1501, 351, - /* 1260 */ 228, 1502, 1503, 1507, 355, 359, 357, 361, 1266, 1518, - /* 1270 */ 360, 365, 1255, 1254, 1518, 1251, 447, 364, 363, 1325, - /* 1280 */ 154, 447, 1518, 974, 972, 74, 451, 1324, 897, 447, - /* 1290 */ 1472, 451, 896, 895, 894, 1472, 891, 890, 1264, 451, - /* 1300 */ 1501, 514, 253, 1472, 1259, 254, 237, 1502, 1503, 1507, - /* 1310 */ 388, 1515, 1502, 1503, 1507, 512, 1257, 255, 1250, 1514, - /* 1320 */ 1502, 1503, 1507, 391, 1518, 1501, 1249, 393, 395, 72, - /* 1330 */ 1456, 447, 1041, 1450, 1501, 168, 403, 1438, 1437, 114, - /* 1340 */ 1429, 451, 173, 55, 14, 1472, 1490, 3, 34, 1518, - /* 1350 */ 15, 189, 39, 124, 36, 10, 447, 44, 1518, 178, - /* 1360 */ 121, 244, 1502, 1503, 1507, 447, 451, 404, 1183, 57, - /* 1370 */ 1472, 182, 183, 1205, 19, 451, 38, 1176, 1155, 1472, - /* 1380 */ 175, 56, 20, 1154, 37, 1210, 1513, 1502, 1503, 1507, - /* 1390 */ 16, 1204, 262, 1209, 1208, 245, 1502, 1503, 1507, 263, - /* 1400 */ 8, 131, 1501, 196, 1092, 33, 13, 1501, 1428, 1091, - /* 1410 */ 18, 203, 1119, 1501, 197, 205, 1181, 199, 201, 46, - /* 1420 */ 58, 1070, 40, 469, 456, 276, 1518, 1321, 1489, 473, - /* 1430 */ 476, 1518, 1319, 447, 62, 208, 467, 1518, 447, 958, - /* 1440 */ 471, 479, 955, 451, 447, 474, 477, 1472, 451, 952, - /* 1450 */ 946, 480, 1472, 944, 451, 482, 483, 950, 1472, 1501, - /* 1460 */ 935, 949, 948, 243, 1502, 1503, 1507, 489, 240, 1502, - /* 1470 */ 1503, 1507, 947, 969, 230, 1502, 1503, 1507, 63, 968, - /* 1480 */ 47, 64, 965, 1518, 963, 863, 499, 904, 210, 211, - /* 1490 */ 447, 501, 496, 210, 886, 885, 884, 496, 883, 882, - /* 1500 */ 451, 881, 880, 879, 1472, 901, 899, 876, 875, 874, - /* 1510 */ 871, 870, 869, 868, 498, 1271, 523, 1269, 524, 498, - /* 1520 */ 231, 1502, 1503, 1507, 527, 528, 525, 529, 1267, 531, - /* 1530 */ 532, 533, 1265, 495, 494, 493, 535, 492, 495, 494, - /* 1540 */ 493, 536, 492, 537, 1253, 539, 540, 1252, 1248, 543, - /* 1550 */ 544, 1223, 1057, 219, 547, 548, + /* 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 */ 254, 241, 258, 257, 241, 254, 260, 279, 280, 219, - /* 10 */ 219, 260, 12, 13, 270, 271, 263, 213, 258, 228, - /* 20 */ 20, 258, 22, 294, 213, 12, 13, 14, 15, 16, - /* 30 */ 270, 271, 2, 270, 271, 244, 307, 20, 38, 249, - /* 40 */ 311, 237, 12, 13, 14, 15, 16, 294, 244, 20, - /* 50 */ 50, 12, 13, 14, 212, 219, 214, 57, 254, 20, - /* 60 */ 307, 22, 258, 4, 311, 12, 13, 263, 61, 258, - /* 70 */ 219, 20, 65, 20, 74, 22, 219, 38, 274, 275, - /* 80 */ 276, 277, 278, 216, 217, 228, 282, 283, 75, 50, - /* 90 */ 213, 38, 235, 237, 87, 244, 57, 97, 294, 263, - /* 100 */ 244, 244, 50, 50, 12, 13, 14, 15, 16, 109, - /* 110 */ 57, 307, 2, 74, 237, 311, 12, 13, 14, 15, - /* 120 */ 16, 244, 12, 13, 14, 15, 16, 74, 277, 222, - /* 130 */ 294, 254, 276, 226, 236, 258, 97, 286, 287, 288, - /* 140 */ 289, 20, 291, 307, 20, 247, 146, 311, 109, 246, - /* 150 */ 97, 274, 275, 276, 277, 278, 253, 254, 49, 282, - /* 160 */ 283, 284, 109, 163, 164, 165, 166, 167, 168, 169, - /* 170 */ 170, 171, 172, 173, 174, 175, 14, 15, 16, 75, - /* 180 */ 303, 164, 165, 210, 20, 146, 21, 187, 0, 24, - /* 190 */ 25, 26, 27, 28, 29, 30, 31, 32, 74, 146, - /* 200 */ 223, 224, 163, 164, 165, 166, 167, 168, 169, 170, - /* 210 */ 171, 172, 173, 174, 175, 163, 163, 164, 165, 166, + /* 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, 139, 71, 263, 213, 221, 263, 20, 187, 22, - /* 240 */ 52, 219, 54, 145, 213, 147, 58, 188, 234, 61, - /* 250 */ 228, 63, 64, 0, 66, 38, 242, 235, 237, 12, - /* 260 */ 13, 14, 15, 16, 294, 244, 244, 294, 12, 13, - /* 270 */ 14, 213, 22, 187, 57, 254, 20, 307, 22, 258, - /* 280 */ 307, 311, 12, 13, 311, 187, 136, 213, 38, 258, - /* 290 */ 20, 74, 22, 47, 38, 274, 275, 276, 277, 278, - /* 300 */ 208, 20, 49, 282, 283, 284, 219, 57, 38, 0, - /* 310 */ 38, 237, 21, 57, 97, 228, 258, 296, 244, 73, - /* 320 */ 1, 2, 76, 302, 303, 34, 109, 57, 254, 57, - /* 330 */ 74, 244, 258, 24, 25, 26, 27, 28, 29, 30, - /* 340 */ 31, 32, 192, 193, 74, 0, 229, 97, 274, 275, - /* 350 */ 276, 277, 278, 97, 237, 74, 282, 283, 20, 109, - /* 360 */ 22, 67, 245, 146, 49, 109, 21, 97, 207, 24, - /* 370 */ 25, 26, 27, 28, 29, 30, 31, 32, 40, 109, + /* 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, 175, 219, 75, 237, 146, 12, 13, 14, - /* 400 */ 15, 16, 146, 52, 187, 54, 248, 113, 114, 58, - /* 410 */ 213, 221, 61, 163, 63, 64, 146, 66, 244, 163, - /* 420 */ 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, - /* 430 */ 174, 175, 242, 163, 164, 165, 166, 167, 168, 169, - /* 440 */ 170, 171, 172, 173, 174, 175, 12, 13, 18, 3, - /* 450 */ 20, 277, 272, 272, 20, 258, 22, 27, 218, 244, - /* 460 */ 30, 287, 288, 289, 213, 291, 251, 163, 187, 39, - /* 470 */ 290, 290, 38, 12, 13, 14, 15, 16, 20, 239, - /* 480 */ 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, - /* 490 */ 98, 57, 100, 101, 102, 103, 104, 105, 4, 237, - /* 500 */ 196, 197, 198, 199, 200, 243, 237, 219, 74, 258, - /* 510 */ 248, 50, 219, 19, 219, 219, 228, 248, 213, 185, - /* 520 */ 186, 228, 237, 138, 228, 219, 57, 33, 243, 20, - /* 530 */ 36, 97, 244, 248, 228, 41, 75, 244, 20, 244, - /* 540 */ 244, 47, 112, 109, 83, 115, 116, 117, 118, 119, - /* 550 */ 244, 121, 122, 123, 124, 125, 126, 127, 128, 129, - /* 560 */ 130, 131, 0, 258, 18, 219, 225, 73, 227, 23, - /* 570 */ 76, 218, 277, 272, 228, 12, 13, 14, 15, 16, - /* 580 */ 146, 35, 287, 288, 289, 232, 291, 219, 43, 213, - /* 590 */ 244, 290, 239, 132, 48, 85, 228, 163, 164, 165, - /* 600 */ 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, - /* 610 */ 219, 150, 244, 50, 52, 53, 54, 55, 56, 228, - /* 620 */ 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - /* 630 */ 68, 69, 70, 132, 258, 244, 19, 176, 177, 178, - /* 640 */ 179, 180, 181, 182, 183, 184, 83, 138, 0, 203, - /* 650 */ 33, 150, 229, 36, 213, 213, 138, 111, 229, 42, - /* 660 */ 237, 44, 45, 46, 47, 237, 237, 22, 245, 213, - /* 670 */ 213, 243, 223, 224, 245, 35, 248, 176, 14, 213, - /* 680 */ 237, 213, 71, 38, 20, 139, 140, 141, 245, 143, - /* 690 */ 73, 213, 238, 76, 148, 132, 142, 49, 238, 258, - /* 700 */ 258, 61, 156, 219, 158, 65, 160, 161, 162, 74, - /* 710 */ 213, 157, 228, 150, 258, 258, 0, 77, 213, 79, - /* 720 */ 80, 86, 82, 106, 258, 213, 258, 87, 244, 213, - /* 730 */ 213, 186, 213, 187, 230, 213, 258, 233, 0, 176, - /* 740 */ 177, 178, 179, 180, 181, 182, 183, 184, 38, 237, - /* 750 */ 0, 134, 36, 71, 137, 258, 244, 75, 238, 78, - /* 760 */ 22, 213, 81, 258, 78, 78, 254, 81, 81, 152, - /* 770 */ 258, 154, 22, 213, 258, 258, 78, 258, 0, 81, - /* 780 */ 258, 1, 2, 164, 165, 237, 274, 275, 276, 277, - /* 790 */ 278, 74, 244, 238, 282, 283, 284, 237, 266, 71, - /* 800 */ 22, 84, 254, 75, 244, 293, 258, 71, 71, 38, - /* 810 */ 238, 75, 75, 71, 254, 213, 205, 75, 258, 109, - /* 820 */ 238, 213, 274, 275, 276, 277, 278, 238, 214, 71, - /* 830 */ 282, 283, 284, 75, 274, 275, 276, 277, 278, 237, - /* 840 */ 314, 293, 282, 283, 284, 237, 244, 71, 226, 305, - /* 850 */ 71, 75, 244, 293, 75, 71, 254, 254, 33, 75, - /* 860 */ 258, 36, 254, 247, 71, 263, 258, 42, 75, 44, - /* 870 */ 45, 46, 47, 213, 254, 299, 274, 275, 276, 277, - /* 880 */ 109, 38, 274, 275, 276, 277, 278, 216, 71, 71, - /* 890 */ 282, 283, 75, 75, 273, 71, 294, 237, 73, 75, - /* 900 */ 57, 76, 292, 71, 244, 237, 71, 75, 71, 307, - /* 910 */ 75, 71, 75, 311, 254, 75, 20, 308, 258, 295, - /* 920 */ 213, 219, 36, 269, 223, 38, 144, 264, 219, 120, - /* 930 */ 219, 252, 132, 250, 274, 275, 276, 277, 250, 219, - /* 940 */ 20, 268, 20, 219, 237, 20, 262, 221, 244, 255, - /* 950 */ 221, 244, 221, 219, 221, 20, 215, 244, 133, 237, - /* 960 */ 135, 254, 137, 219, 237, 258, 153, 237, 244, 237, - /* 970 */ 223, 215, 312, 313, 268, 213, 237, 237, 218, 154, - /* 980 */ 237, 274, 275, 276, 277, 278, 237, 263, 237, 237, - /* 990 */ 283, 237, 267, 218, 20, 12, 13, 262, 195, 237, - /* 1000 */ 255, 277, 213, 244, 304, 22, 244, 259, 194, 304, - /* 1010 */ 213, 287, 288, 289, 57, 291, 254, 202, 294, 273, - /* 1020 */ 258, 38, 258, 261, 259, 258, 237, 258, 201, 244, - /* 1030 */ 189, 307, 190, 244, 237, 311, 274, 275, 276, 277, - /* 1040 */ 57, 244, 186, 254, 213, 20, 272, 258, 120, 204, - /* 1050 */ 261, 254, 213, 298, 301, 258, 209, 213, 285, 206, - /* 1060 */ 297, 300, 74, 274, 275, 276, 277, 310, 237, 281, - /* 1070 */ 259, 274, 275, 276, 277, 244, 237, 309, 258, 258, - /* 1080 */ 97, 237, 259, 244, 258, 254, 213, 315, 244, 258, - /* 1090 */ 135, 255, 109, 254, 256, 244, 218, 258, 254, 233, - /* 1100 */ 261, 218, 258, 306, 244, 274, 275, 276, 277, 74, - /* 1110 */ 237, 213, 240, 274, 275, 276, 277, 244, 274, 275, - /* 1120 */ 276, 277, 223, 219, 227, 218, 215, 254, 265, 146, - /* 1130 */ 220, 258, 231, 231, 261, 237, 0, 211, 0, 64, - /* 1140 */ 0, 38, 244, 159, 313, 38, 163, 274, 275, 276, - /* 1150 */ 277, 38, 254, 38, 159, 0, 258, 213, 38, 159, - /* 1160 */ 38, 0, 38, 0, 38, 213, 0, 74, 150, 149, - /* 1170 */ 109, 0, 274, 275, 276, 277, 146, 0, 53, 0, - /* 1180 */ 142, 237, 0, 86, 0, 0, 0, 0, 244, 237, - /* 1190 */ 0, 0, 0, 213, 120, 0, 244, 0, 254, 213, - /* 1200 */ 22, 0, 258, 0, 0, 0, 254, 0, 0, 0, - /* 1210 */ 258, 0, 0, 0, 0, 0, 0, 237, 274, 275, - /* 1220 */ 276, 277, 0, 237, 244, 0, 274, 275, 276, 277, - /* 1230 */ 244, 0, 0, 0, 254, 0, 0, 0, 258, 0, - /* 1240 */ 254, 43, 0, 0, 258, 213, 36, 51, 0, 43, - /* 1250 */ 213, 0, 0, 36, 274, 275, 276, 277, 213, 38, - /* 1260 */ 274, 275, 276, 277, 38, 38, 43, 43, 0, 237, - /* 1270 */ 36, 43, 0, 0, 237, 0, 244, 36, 38, 0, - /* 1280 */ 81, 244, 237, 38, 22, 83, 254, 0, 38, 244, - /* 1290 */ 258, 254, 38, 38, 38, 258, 38, 38, 0, 254, - /* 1300 */ 213, 71, 22, 258, 0, 22, 274, 275, 276, 277, - /* 1310 */ 39, 274, 275, 276, 277, 71, 0, 22, 0, 274, - /* 1320 */ 275, 276, 277, 38, 237, 213, 0, 22, 22, 20, - /* 1330 */ 0, 244, 38, 0, 213, 155, 22, 0, 0, 151, - /* 1340 */ 0, 254, 43, 74, 191, 258, 86, 71, 71, 237, - /* 1350 */ 191, 86, 71, 135, 185, 191, 244, 138, 237, 75, - /* 1360 */ 74, 274, 275, 276, 277, 244, 254, 138, 75, 4, - /* 1370 */ 258, 74, 71, 38, 74, 254, 138, 75, 75, 258, - /* 1380 */ 133, 74, 71, 75, 71, 75, 274, 275, 276, 277, - /* 1390 */ 71, 38, 38, 38, 38, 274, 275, 276, 277, 38, - /* 1400 */ 2, 86, 213, 86, 75, 74, 74, 213, 0, 75, - /* 1410 */ 74, 43, 163, 213, 75, 133, 75, 74, 74, 74, - /* 1420 */ 74, 22, 74, 38, 136, 38, 237, 0, 86, 38, - /* 1430 */ 38, 237, 0, 244, 84, 86, 85, 237, 244, 75, - /* 1440 */ 74, 38, 75, 254, 244, 74, 74, 258, 254, 75, - /* 1450 */ 75, 74, 258, 75, 254, 38, 74, 99, 258, 213, - /* 1460 */ 22, 99, 99, 274, 275, 276, 277, 87, 274, 275, - /* 1470 */ 276, 277, 99, 38, 274, 275, 276, 277, 74, 109, - /* 1480 */ 74, 74, 38, 237, 22, 51, 50, 57, 61, 71, - /* 1490 */ 244, 72, 65, 61, 38, 38, 38, 65, 38, 38, - /* 1500 */ 254, 38, 38, 22, 258, 57, 38, 38, 38, 38, - /* 1510 */ 38, 38, 38, 38, 87, 0, 38, 0, 36, 87, - /* 1520 */ 274, 275, 276, 277, 38, 36, 43, 43, 0, 38, - /* 1530 */ 36, 43, 0, 106, 107, 108, 38, 110, 106, 107, - /* 1540 */ 108, 36, 110, 43, 0, 38, 37, 0, 0, 22, - /* 1550 */ 21, 316, 22, 22, 21, 20, 316, 316, 316, 316, + /* 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, @@ -545,151 +546,151 @@ static const YYCODETYPE yy_lookahead[] = { /* 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, + /* 1760 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, }; #define YY_SHIFT_COUNT (549) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1548) +#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, 281, 256, 270, 270, 270, 270, 270, 270, - /* 20 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 30 */ 270, 270, 270, 270, 270, 124, 124, 124, 51, 983, - /* 40 */ 983, 98, 29, 29, 86, 983, 17, 17, 29, 29, - /* 50 */ 29, 29, 29, 29, 109, 121, 164, 86, 121, 29, - /* 60 */ 29, 121, 29, 121, 121, 121, 29, 315, 430, 461, - /* 70 */ 563, 563, 165, 640, 250, 351, 250, 250, 250, 250, - /* 80 */ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, - /* 90 */ 250, 250, 250, 250, 250, 17, 338, 253, 272, 509, - /* 100 */ 509, 509, 648, 272, 458, 121, 121, 121, 510, 469, - /* 110 */ 392, 392, 392, 392, 392, 392, 392, 617, 345, 188, - /* 120 */ 92, 304, 17, 7, 17, 150, 645, 518, 334, 545, - /* 130 */ 334, 664, 446, 59, 896, 886, 887, 782, 896, 896, - /* 140 */ 809, 800, 800, 896, 920, 922, 109, 458, 925, 109, - /* 150 */ 109, 896, 109, 935, 121, 121, 121, 121, 121, 121, - /* 160 */ 121, 121, 121, 121, 121, 887, 896, 935, 458, 920, - /* 170 */ 813, 922, 315, 458, 925, 315, 974, 803, 814, 957, - /* 180 */ 803, 814, 957, 957, 815, 827, 842, 841, 856, 458, - /* 190 */ 1025, 928, 847, 853, 845, 988, 121, 814, 957, 957, - /* 200 */ 814, 957, 955, 458, 925, 315, 510, 315, 458, 1035, - /* 210 */ 887, 469, 896, 315, 935, 1556, 1556, 1556, 1556, 1556, - /* 220 */ 562, 825, 309, 494, 1427, 1432, 13, 30, 110, 104, - /* 230 */ 385, 247, 247, 247, 247, 247, 247, 247, 246, 294, - /* 240 */ 162, 319, 501, 162, 162, 162, 716, 554, 682, 681, - /* 250 */ 686, 687, 698, 738, 750, 778, 291, 728, 736, 737, - /* 260 */ 780, 619, 611, 161, 742, 52, 758, 635, 776, 779, - /* 270 */ 784, 793, 817, 710, 771, 818, 824, 832, 835, 837, - /* 280 */ 840, 717, 843, 1136, 1138, 1075, 1140, 1103, 984, 1107, - /* 290 */ 1113, 1115, 995, 1155, 1120, 1122, 1000, 1161, 1124, 1163, - /* 300 */ 1126, 1166, 1093, 1018, 1020, 1061, 1030, 1171, 1177, 1125, - /* 310 */ 1038, 1179, 1182, 1097, 1184, 1185, 1186, 1187, 1190, 1191, - /* 320 */ 1192, 1197, 1203, 1204, 1205, 1207, 1208, 1209, 1211, 1212, - /* 330 */ 1074, 1195, 1213, 1214, 1215, 1216, 1222, 1178, 1201, 1225, - /* 340 */ 1231, 1232, 1233, 1235, 1236, 1237, 1239, 1198, 1242, 1196, - /* 350 */ 1243, 1248, 1221, 1210, 1206, 1251, 1226, 1217, 1223, 1252, - /* 360 */ 1227, 1234, 1224, 1268, 1240, 1241, 1228, 1272, 1273, 1275, - /* 370 */ 1279, 1202, 1199, 1245, 1230, 1262, 1287, 1250, 1254, 1255, - /* 380 */ 1256, 1244, 1230, 1258, 1259, 1298, 1280, 1304, 1283, 1271, - /* 390 */ 1316, 1295, 1285, 1318, 1305, 1326, 1306, 1309, 1330, 1219, - /* 400 */ 1180, 1294, 1333, 1188, 1314, 1229, 1218, 1337, 1338, 1238, - /* 410 */ 1340, 1269, 1299, 1247, 1276, 1277, 1153, 1284, 1281, 1293, - /* 420 */ 1286, 1297, 1300, 1302, 1301, 1260, 1307, 1311, 1159, 1303, - /* 430 */ 1308, 1265, 1169, 1313, 1315, 1310, 1319, 1164, 1365, 1335, - /* 440 */ 1353, 1354, 1355, 1356, 1361, 1398, 1249, 1317, 1329, 1331, - /* 450 */ 1334, 1332, 1336, 1339, 1341, 1343, 1344, 1288, 1345, 1408, - /* 460 */ 1368, 1282, 1346, 1350, 1342, 1349, 1399, 1348, 1351, 1364, - /* 470 */ 1385, 1387, 1366, 1367, 1391, 1371, 1374, 1392, 1372, 1375, - /* 480 */ 1403, 1377, 1378, 1417, 1382, 1358, 1362, 1363, 1373, 1438, - /* 490 */ 1380, 1404, 1435, 1370, 1406, 1407, 1444, 1230, 1462, 1434, - /* 500 */ 1436, 1430, 1419, 1418, 1456, 1457, 1458, 1460, 1461, 1463, - /* 510 */ 1464, 1481, 1448, 1244, 1468, 1230, 1469, 1470, 1471, 1472, - /* 520 */ 1473, 1474, 1475, 1515, 1478, 1482, 1483, 1517, 1486, 1489, - /* 530 */ 1484, 1528, 1491, 1494, 1488, 1532, 1498, 1505, 1500, 1544, - /* 540 */ 1507, 1509, 1547, 1548, 1527, 1529, 1530, 1531, 1533, 1535, + /* 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 (219) #define YY_REDUCE_MIN (-272) -#define YY_REDUCE_MAX (1246) +#define YY_REDUCE_MAX (1173) static const short yy_reduce_ofst[] = { - /* 0 */ -27, -196, 21, -123, 512, 548, 560, 602, 74, 608, - /* 10 */ 660, 707, 724, 762, 789, 797, 831, 839, 873, 844, - /* 20 */ 898, 944, 952, 980, 986, 1032, 1037, 1045, 1087, 1112, - /* 30 */ 1121, 1189, 1194, 1200, 1246, -149, 174, 295, -164, -240, - /* 40 */ -237, -247, -143, 22, -30, -256, -254, -97, -209, 87, - /* 50 */ 288, 293, 296, 306, 14, 262, -144, -271, 117, 346, - /* 60 */ 368, 285, 391, 423, 428, 429, 484, 353, -210, -272, - /* 70 */ -272, -272, -158, -102, -189, -93, 31, 58, 197, 251, - /* 80 */ 305, 376, 441, 442, 456, 457, 466, 468, 478, 497, - /* 90 */ 505, 516, 517, 519, 522, -249, -133, 190, -23, 180, - /* 100 */ 181, 301, 240, 449, 215, 443, 158, 269, 504, 341, - /* 110 */ 454, 460, 520, 555, 572, 582, 589, 532, 614, 622, - /* 120 */ 526, 544, 603, 616, 620, 576, 671, 621, 610, 610, - /* 130 */ 610, 668, 609, 624, 702, 654, 701, 663, 709, 711, - /* 140 */ 679, 683, 688, 720, 673, 684, 726, 704, 694, 729, - /* 150 */ 731, 734, 733, 741, 722, 727, 730, 732, 739, 740, - /* 160 */ 743, 749, 751, 752, 754, 747, 744, 756, 713, 706, - /* 170 */ 725, 735, 760, 759, 745, 775, 746, 700, 748, 764, - /* 180 */ 705, 765, 767, 769, 753, 761, 755, 763, 610, 785, - /* 190 */ 774, 773, 772, 757, 768, 788, 668, 811, 820, 821, - /* 200 */ 823, 826, 838, 851, 836, 878, 866, 883, 860, 872, - /* 210 */ 899, 897, 904, 907, 911, 863, 901, 902, 910, 926, + /* 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 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 10 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 20 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 30 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 40 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 50 */ 1221, 1221, 1221, 1221, 1280, 1221, 1221, 1221, 1221, 1221, - /* 60 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1278, 1418, 1221, - /* 70 */ 1554, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 80 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 90 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1280, 1221, 1565, - /* 100 */ 1565, 1565, 1278, 1221, 1221, 1221, 1221, 1221, 1373, 1221, - /* 110 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1452, 1221, 1221, - /* 120 */ 1629, 1221, 1221, 1326, 1221, 1589, 1221, 1581, 1557, 1571, - /* 130 */ 1558, 1221, 1614, 1574, 1221, 1221, 1221, 1444, 1221, 1221, - /* 140 */ 1423, 1420, 1420, 1221, 1221, 1221, 1280, 1221, 1221, 1280, - /* 150 */ 1280, 1221, 1280, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 160 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 170 */ 1454, 1221, 1278, 1221, 1221, 1278, 1221, 1596, 1594, 1221, - /* 180 */ 1596, 1594, 1221, 1221, 1608, 1604, 1587, 1585, 1571, 1221, - /* 190 */ 1221, 1221, 1632, 1620, 1616, 1221, 1221, 1594, 1221, 1221, - /* 200 */ 1594, 1221, 1431, 1221, 1221, 1278, 1221, 1278, 1221, 1342, - /* 210 */ 1221, 1221, 1221, 1278, 1221, 1446, 1376, 1376, 1281, 1226, - /* 220 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 230 */ 1221, 1517, 1607, 1606, 1516, 1531, 1530, 1529, 1221, 1221, - /* 240 */ 1511, 1221, 1221, 1512, 1510, 1509, 1221, 1221, 1221, 1221, - /* 250 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 260 */ 1555, 1221, 1617, 1621, 1221, 1221, 1221, 1491, 1221, 1221, - /* 270 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 280 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 290 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 300 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 310 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 320 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 330 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 340 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 350 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 360 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 370 */ 1221, 1221, 1221, 1221, 1387, 1221, 1221, 1221, 1221, 1221, - /* 380 */ 1221, 1307, 1306, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 390 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 400 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 410 */ 1221, 1221, 1221, 1221, 1578, 1588, 1221, 1221, 1221, 1221, - /* 420 */ 1221, 1221, 1221, 1221, 1221, 1491, 1221, 1605, 1221, 1564, - /* 430 */ 1560, 1221, 1221, 1556, 1221, 1221, 1615, 1221, 1221, 1221, - /* 440 */ 1221, 1221, 1221, 1221, 1221, 1550, 1221, 1221, 1221, 1221, - /* 450 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 460 */ 1221, 1221, 1221, 1221, 1490, 1221, 1221, 1221, 1221, 1221, - /* 470 */ 1221, 1221, 1370, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 480 */ 1221, 1221, 1221, 1221, 1221, 1355, 1353, 1352, 1351, 1221, - /* 490 */ 1348, 1221, 1221, 1221, 1221, 1221, 1221, 1378, 1221, 1221, - /* 500 */ 1221, 1221, 1221, 1301, 1221, 1221, 1221, 1221, 1221, 1221, - /* 510 */ 1221, 1221, 1221, 1292, 1221, 1291, 1221, 1221, 1221, 1221, - /* 520 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 530 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, - /* 540 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 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 *****************************/ @@ -962,9 +963,9 @@ static const char *const yyTokenName[] = { /* 163 */ "NULL", /* 164 */ "FIRST", /* 165 */ "LAST", - /* 166 */ "CAST", - /* 167 */ "NOW", - /* 168 */ "TODAY", + /* 166 */ "NOW", + /* 167 */ "TODAY", + /* 168 */ "CAST", /* 169 */ "ROWTS", /* 170 */ "TBNAME", /* 171 */ "QSTARTTS", @@ -1390,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 ::= CAST 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 */ @@ -1933,15 +1935,18 @@ static YYACTIONTYPE yy_find_shift_action( do{ i = yy_shift_ofst[stateno]; assert( i>=0 ); - /* assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); */ + assert( i<=YY_ACTTAB_COUNT ); + assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); assert( iLookAhead!=YYNOCODE ); assert( iLookAhead < YYNTOKEN ); i += iLookAhead; - if( i>=YY_NLOOKAHEAD || yy_lookahead[i]!=iLookAhead ){ + assert( i<(int)YY_NLOOKAHEAD ); + if( yy_lookahead[i]!=iLookAhead ){ #ifdef YYFALLBACK YYCODETYPE iFallback; /* Fallback token */ - if( iLookAhead %s\n", @@ -1956,16 +1961,8 @@ static YYACTIONTYPE yy_find_shift_action( #ifdef YYWILDCARD { int j = i - iLookAhead + YYWILDCARD; - if( -#if YY_SHIFT_MIN+YYWILDCARD<0 - j>=0 && -#endif -#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT - j0 - ){ + assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) ); + if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", @@ -1979,6 +1976,7 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ + assert( i>=0 && iyytos; #ifndef NDEBUG if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ - yysize = yyRuleInfo[yyruleno].nrhs; + yysize = yyRuleInfoNRhs[yyruleno]; if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", + fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", yyTracePrompt, - yyruleno, yyRuleName[yyruleno], yymsp[yysize].stateno); + yyruleno, yyRuleName[yyruleno], + yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ yypParser->yyhwm++; @@ -2695,12 +3110,14 @@ 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); + 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; @@ -2753,7 +3170,7 @@ static YYACTIONTYPE yy_reduce( 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); + case 351: /* set_quantifier_opt ::= */ yytestcase(yyruleno==351); { yymsp[1].minor.yy121 = false; } break; case 55: /* exists_opt ::= IF EXISTS */ @@ -2894,8 +3311,8 @@ 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); + 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; @@ -2905,8 +3322,8 @@ 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); + 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; @@ -2987,9 +3404,9 @@ static YYACTIONTYPE yy_reduce( 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); + 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 */ @@ -3079,7 +3496,7 @@ static YYACTIONTYPE yy_reduce( { 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); + case 355: /* select_list ::= select_sublist */ yytestcase(yyruleno==355); { yylhsminor.yy488 = yymsp[0].minor.yy488; } yymsp[0].minor.yy488 = yylhsminor.yy488; break; @@ -3178,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); } @@ -3188,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); } @@ -3224,13 +3641,13 @@ static YYACTIONTYPE yy_reduce( 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); + 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 */ @@ -3287,7 +3704,7 @@ static YYACTIONTYPE yy_reduce( break; case 221: /* analyze_opt ::= ANALYZE */ case 229: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==229); - case 351: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==351); + case 352: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==352); { yymsp[0].minor.yy121 = true; } break; case 222: /* explain_options ::= */ @@ -3365,20 +3782,20 @@ static YYACTIONTYPE yy_reduce( 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); + 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; @@ -3432,46 +3849,50 @@ static YYACTIONTYPE yy_reduce( { 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); + 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.yy504 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL); } break; - case 280: /* expression ::= function_name NK_LP expression_list NK_RP */ + 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 */ + 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 ::= CAST NK_LP expression AS type_name NK_RP */ + 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); + 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.yy504); yylhsminor.yy504 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy504)); } 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.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.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.yy504); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); @@ -3479,7 +3900,7 @@ static YYACTIONTYPE yy_reduce( } 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.yy504); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); @@ -3487,7 +3908,7 @@ static YYACTIONTYPE yy_reduce( } 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.yy504); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); @@ -3495,7 +3916,7 @@ static YYACTIONTYPE yy_reduce( } 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.yy504); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); @@ -3503,7 +3924,7 @@ static YYACTIONTYPE yy_reduce( } 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.yy504); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); @@ -3511,36 +3932,34 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy504 = yylhsminor.yy504; break; - case 292: /* expression_list ::= expression */ + case 295: /* expression_list ::= expression */ { yylhsminor.yy488 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy504)); } yymsp[0].minor.yy488 = yylhsminor.yy488; break; - case 293: /* expression_list ::= expression_list NK_COMMA expression */ + 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 294: /* column_reference ::= column_name */ + 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 295: /* column_reference ::= table_name NK_DOT column_name */ + 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 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); + 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 305: /* predicate ::= expression compare_op expression */ - case 310: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==310); + 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.yy504); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); @@ -3548,7 +3967,7 @@ static YYACTIONTYPE yy_reduce( } 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.yy504); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); @@ -3556,7 +3975,7 @@ static YYACTIONTYPE yy_reduce( } 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.yy504); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); @@ -3564,68 +3983,68 @@ static YYACTIONTYPE yy_reduce( } 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.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.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.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.yy504 = yylhsminor.yy504; break; - case 311: /* compare_op ::= NK_LT */ + case 312: /* compare_op ::= NK_LT */ { yymsp[0].minor.yy84 = OP_TYPE_LOWER_THAN; } break; - case 312: /* compare_op ::= NK_GT */ + case 313: /* compare_op ::= NK_GT */ { yymsp[0].minor.yy84 = OP_TYPE_GREATER_THAN; } break; - case 313: /* compare_op ::= NK_LE */ + case 314: /* compare_op ::= NK_LE */ { yymsp[0].minor.yy84 = OP_TYPE_LOWER_EQUAL; } break; - case 314: /* compare_op ::= NK_GE */ + case 315: /* compare_op ::= NK_GE */ { yymsp[0].minor.yy84 = OP_TYPE_GREATER_EQUAL; } break; - case 315: /* compare_op ::= NK_NE */ + case 316: /* compare_op ::= NK_NE */ { yymsp[0].minor.yy84 = OP_TYPE_NOT_EQUAL; } break; - case 316: /* compare_op ::= NK_EQ */ + case 317: /* compare_op ::= NK_EQ */ { yymsp[0].minor.yy84 = OP_TYPE_EQUAL; } break; - case 317: /* compare_op ::= LIKE */ + case 318: /* compare_op ::= LIKE */ { yymsp[0].minor.yy84 = OP_TYPE_LIKE; } break; - case 318: /* compare_op ::= NOT LIKE */ + case 319: /* compare_op ::= NOT LIKE */ { yymsp[-1].minor.yy84 = OP_TYPE_NOT_LIKE; } break; - case 319: /* compare_op ::= MATCH */ + case 320: /* compare_op ::= MATCH */ { yymsp[0].minor.yy84 = OP_TYPE_MATCH; } break; - case 320: /* compare_op ::= NMATCH */ + case 321: /* compare_op ::= NMATCH */ { yymsp[0].minor.yy84 = OP_TYPE_NMATCH; } break; - case 321: /* in_op ::= IN */ + case 322: /* in_op ::= IN */ { yymsp[0].minor.yy84 = OP_TYPE_IN; } break; - case 322: /* in_op ::= 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 */ + 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.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.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.yy504); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); @@ -3633,7 +4052,7 @@ static YYACTIONTYPE yy_reduce( } 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.yy504); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy504); @@ -3641,52 +4060,52 @@ static YYACTIONTYPE yy_reduce( } 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); + 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 */ + 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 */ + 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 */ + 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 */ + 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 ::= */ + case 342: /* alias_opt ::= */ { yymsp[1].minor.yy409 = nil_token; } break; - case 342: /* alias_opt ::= table_alias */ + 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 */ + 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); + 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 */ + 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 ::= */ + case 348: /* join_type ::= */ { yymsp[1].minor.yy556 = JOIN_TYPE_INNER; } break; - case 348: /* 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.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); @@ -3696,74 +4115,74 @@ static YYACTIONTYPE yy_reduce( yymsp[-8].minor.yy504 = addHavingClause(pCxt, yymsp[-8].minor.yy504, yymsp[0].minor.yy504); } break; - case 352: /* set_quantifier_opt ::= ALL */ + case 353: /* set_quantifier_opt ::= ALL */ { yymsp[0].minor.yy121 = false; } break; - case 353: /* select_list ::= NK_STAR */ + case 354: /* select_list ::= NK_STAR */ { yymsp[0].minor.yy488 = NULL; } break; - case 358: /* select_item ::= common_expression column_alias */ + 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 */ + 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 */ + 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); + 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 */ + 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 */ + 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 */ + 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 */ + 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 */ + 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 */ + 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 */ + 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 */ + case 376: /* fill_mode ::= NONE */ { yymsp[0].minor.yy22 = FILL_MODE_NONE; } break; - case 376: /* fill_mode ::= PREV */ + case 377: /* fill_mode ::= PREV */ { yymsp[0].minor.yy22 = FILL_MODE_PREV; } break; - case 377: /* fill_mode ::= NULL */ + case 378: /* fill_mode ::= NULL */ { yymsp[0].minor.yy22 = FILL_MODE_NULL; } break; - case 378: /* fill_mode ::= LINEAR */ + case 379: /* fill_mode ::= LINEAR */ { yymsp[0].minor.yy22 = FILL_MODE_LINEAR; } break; - case 379: /* fill_mode ::= NEXT */ + case 380: /* fill_mode ::= NEXT */ { yymsp[0].minor.yy22 = FILL_MODE_NEXT; } break; - case 382: /* group_by_list ::= expression */ + 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 */ + 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.yy504 = addOrderByClause(pCxt, yymsp[-3].minor.yy504, yymsp[-2].minor.yy488); yylhsminor.yy504 = addSlimitClause(pCxt, yylhsminor.yy504, yymsp[-1].minor.yy504); @@ -3771,55 +4190,55 @@ static YYACTIONTYPE yy_reduce( } yymsp[-3].minor.yy504 = yylhsminor.yy504; break; - case 388: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + 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); + 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); + 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); + 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 */ + 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 */ + 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 ::= */ + case 406: /* ordering_specification_opt ::= */ { yymsp[1].minor.yy522 = ORDER_ASC; } break; - case 406: /* ordering_specification_opt ::= ASC */ + case 407: /* ordering_specification_opt ::= ASC */ { yymsp[0].minor.yy522 = ORDER_ASC; } break; - case 407: /* ordering_specification_opt ::= DESC */ + case 408: /* ordering_specification_opt ::= DESC */ { yymsp[0].minor.yy522 = ORDER_DESC; } break; - case 408: /* null_ordering_opt ::= */ + case 409: /* null_ordering_opt ::= */ { yymsp[1].minor.yy281 = NULL_ORDER_DEFAULT; } break; - case 409: /* null_ordering_opt ::= NULLS FIRST */ + case 410: /* null_ordering_opt ::= NULLS FIRST */ { yymsp[-1].minor.yy281 = NULL_ORDER_FIRST; } break; - case 410: /* null_ordering_opt ::= NULLS LAST */ + case 411: /* null_ordering_opt ::= NULLS LAST */ { yymsp[-1].minor.yy281 = NULL_ORDER_LAST; } break; default: break; /********** End reduce actions ************************************************/ }; - assert( yyrulenocolumnData, 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 62a96b6438..d1def1bef1 100644 --- a/source/libs/scheduler/inc/schedulerInt.h +++ b/source/libs/scheduler/inc/schedulerInt.h @@ -156,8 +156,8 @@ typedef struct SSchJob { int32_t levelNum; int32_t taskNum; void *transport; - SArray *nodeList; // qnode/vnode list, element is SQueryNodeAddr - SArray *levels; // Element is SQueryLevel, starting from 0. SArray + SArray *nodeList; // qnode/vnode list, SArray + SArray *levels; // starting from 0. SArray SNodeList *subPlans; // subplan pointer copied from DAG, no need to free it in scheduler int32_t levelIdx; diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index c5258afcc1..93bc16a7a2 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 3078324c6b..ef9cccccb7 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -292,7 +292,7 @@ void* transCtxDumpBrokenlinkVal(STransCtx* ctx, int32_t* msgType) { void transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg)) { queue->q = taosArrayInit(2, sizeof(void*)); - queue->freeFunc = freeFunc; + queue->freeFunc = (void (*)(const void*))freeFunc; } bool transQueuePush(STransQueue* queue, void* arg) { if (queue->q == NULL) { diff --git a/source/libs/transport/test/transportTests.cpp b/source/libs/transport/test/transportTests.cpp index ce795b1763..2488dda3f6 100644 --- a/source/libs/transport/test/transportTests.cpp +++ b/source/libs/transport/test/transportTests.cpp @@ -156,14 +156,14 @@ TEST_F(TransCtxEnv, mergeTest) { STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); transCtxInit(src); { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryMalloc(12); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); key++; } { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryMalloc(12); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); key++; @@ -176,14 +176,14 @@ TEST_F(TransCtxEnv, mergeTest) { STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); transCtxInit(src); { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryMalloc(12); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); key++; } { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryMalloc(12); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); key++; @@ -198,7 +198,7 @@ TEST_F(TransCtxEnv, mergeTest) { STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); transCtxInit(src); { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryCalloc(1, 11); memcpy(val1.val, val.c_str(), val.size()); @@ -206,7 +206,7 @@ TEST_F(TransCtxEnv, mergeTest) { key++; } { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryCalloc(1, 11); memcpy(val1.val, val.c_str(), val.size()); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); diff --git a/source/os/src/osMemory.c b/source/os/src/osMemory.c index 3545aabdca..cd756b45e2 100644 --- a/source/os/src/osMemory.c +++ b/source/os/src/osMemory.c @@ -156,7 +156,7 @@ void *taosMemoryStrDup(void *ptr) { } -void taosMemoryFree(const void *ptr) { +void taosMemoryFree(void *ptr) { if (ptr == NULL) return; #ifdef USE_TD_MEMORY @@ -166,10 +166,10 @@ void taosMemoryFree(const void *ptr) { // memset(pTdMemoryInfo, 0, sizeof(TdMemoryInfo)); free(pTdMemoryInfo); } else { - free((void*)ptr); + free(ptr); } #else - return free((void*)ptr); + return free(ptr); #endif } diff --git a/source/util/src/tarray.c b/source/util/src/tarray.c index a74b26a386..4477a5cacd 100644 --- a/source/util/src/tarray.c +++ b/source/util/src/tarray.c @@ -303,6 +303,21 @@ void taosArrayClear(SArray* pArray) { pArray->size = 0; } +void taosArrayClearEx(SArray* pArray, void (*fp)(void*)) { + if (pArray == NULL) return; + if (fp == NULL) { + pArray->size = 0; + return; + } + + for (int32_t i = 0; i < pArray->size; ++i) { + fp(TARRAY_GET_ELEM(pArray, i)); + } + + pArray->size = 0; +} + + void* taosArrayDestroy(SArray* pArray) { if (pArray) { taosMemoryFree(pArray->pData); diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 1809d99209..ac2010efa3 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -344,6 +344,8 @@ void shellRunCommandOnServer(TAOS *con, char command[]) { atomic_store_64(&result, 0); freeResultWithRid(oresult); + taos_free_result(pSql); + return; }