diff --git a/example/src/tmq.c b/example/src/tmq.c index ac7098b254652b9486bf5bd49ff5fe922f943f02..26e5ea82c19a3f0ac90689a4b4f1362caa193ec6 100644 --- a/example/src/tmq.c +++ b/example/src/tmq.c @@ -28,7 +28,7 @@ int32_t init_env() { return -1; } - TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 2"); + TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1"); if (taos_errno(pRes) != 0) { printf("error in create db, reason:%s\n", taos_errstr(pRes)); return -1; @@ -62,6 +62,23 @@ int32_t init_env() { return -1; } taos_free_result(pRes); + return 0; +} + +int32_t create_topic() { + printf("create topic"); + TAOS_RES* pRes; + TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); + if (pConn == NULL) { + return -1; + } + + pRes = taos_query(pConn, "use abc1"); + if (taos_errno(pRes) != 0) { + printf("error in use db, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); const char* sql = "select * from tu1"; pRes = tmq_create_topic(pConn, "test_stb_topic_1", sql, strlen(sql)); @@ -193,6 +210,7 @@ int main(int argc, char* argv[]) { printf("env init\n"); code = init_env(); } + create_topic(); tmq_t* tmq = build_consumer(); tmq_list_t* topic_list = build_topic_list(); /*perf_loop(tmq, topic_list);*/ diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 48e352bb481261dd22a2b65e6d9e54151fdde49a..5164fb6ccd2323764ac3aec259559ee572fbde4f 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -524,6 +524,7 @@ typedef struct { int8_t update; int8_t cacheLastRow; int8_t ignoreExist; + int8_t streamMode; } SCreateDbReq; int32_t tSerializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq); @@ -744,6 +745,7 @@ typedef struct { int8_t cacheLastRow; int8_t replica; int8_t selfIndex; + int8_t streamMode; SReplica replicas[TSDB_MAX_REPLICA]; } SCreateVnodeReq, SAlterVnodeReq; @@ -1758,6 +1760,11 @@ typedef struct { char cgroup[TSDB_CONSUMER_GROUP_LEN]; } SMqOffset; +typedef struct { + int32_t vgId; + SArray* offsets; // SArray +} SMqVgOffsets; + typedef struct { int32_t num; SMqOffset* offsets; @@ -1768,8 +1775,8 @@ typedef struct { } SMqCMResetOffsetRsp; typedef struct { - int32_t num; - SMqOffset* offsets; + int64_t leftForVer; + SMqVgOffsets offsets; } SMqMVResetOffsetReq; typedef struct { @@ -1780,7 +1787,6 @@ int32_t tEncodeSMqOffset(SCoder* encoder, const SMqOffset* pOffset); int32_t tDecodeSMqOffset(SCoder* decoder, SMqOffset* pOffset); int32_t tEncodeSMqCMResetOffsetReq(SCoder* encoder, const SMqCMResetOffsetReq* pReq); int32_t tDecodeSMqCMResetOffsetReq(SCoder* decoder, SMqCMResetOffsetReq* pReq); - int32_t tEncodeSMqMVResetOffsetReq(SCoder* encoder, const SMqMVResetOffsetReq* pReq); int32_t tDecodeSMqMVResetOffsetReq(SCoder* decoder, SMqMVResetOffsetReq* pReq); diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 98903f5617868bdc644319ebca59b1a8c4e0e3dc..7501f61983ad36d943966d33b47138cda0f38068 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -126,86 +126,87 @@ #define TK_PRECISION 108 #define TK_UPDATE 109 #define TK_CACHELAST 110 -#define TK_UNSIGNED 111 -#define TK_TAGS 112 -#define TK_USING 113 -#define TK_NULL 114 -#define TK_NOW 115 -#define TK_SELECT 116 -#define TK_UNION 117 -#define TK_ALL 118 -#define TK_DISTINCT 119 -#define TK_FROM 120 -#define TK_VARIABLE 121 -#define TK_INTERVAL 122 -#define TK_EVERY 123 -#define TK_SESSION 124 -#define TK_STATE_WINDOW 125 -#define TK_FILL 126 -#define TK_SLIDING 127 -#define TK_ORDER 128 -#define TK_BY 129 -#define TK_ASC 130 -#define TK_GROUP 131 -#define TK_HAVING 132 -#define TK_LIMIT 133 -#define TK_OFFSET 134 -#define TK_SLIMIT 135 -#define TK_SOFFSET 136 -#define TK_WHERE 137 -#define TK_RESET 138 -#define TK_QUERY 139 -#define TK_SYNCDB 140 -#define TK_ADD 141 -#define TK_COLUMN 142 -#define TK_MODIFY 143 -#define TK_TAG 144 -#define TK_CHANGE 145 -#define TK_SET 146 -#define TK_KILL 147 -#define TK_CONNECTION 148 -#define TK_STREAM 149 -#define TK_COLON 150 -#define TK_ABORT 151 -#define TK_AFTER 152 -#define TK_ATTACH 153 -#define TK_BEFORE 154 -#define TK_BEGIN 155 -#define TK_CASCADE 156 -#define TK_CLUSTER 157 -#define TK_CONFLICT 158 -#define TK_COPY 159 -#define TK_DEFERRED 160 -#define TK_DELIMITERS 161 -#define TK_DETACH 162 -#define TK_EACH 163 -#define TK_END 164 -#define TK_EXPLAIN 165 -#define TK_FAIL 166 -#define TK_FOR 167 -#define TK_IGNORE 168 -#define TK_IMMEDIATE 169 -#define TK_INITIALLY 170 -#define TK_INSTEAD 171 -#define TK_KEY 172 -#define TK_OF 173 -#define TK_RAISE 174 -#define TK_REPLACE 175 -#define TK_RESTRICT 176 -#define TK_ROW 177 -#define TK_STATEMENT 178 -#define TK_TRIGGER 179 -#define TK_VIEW 180 -#define TK_SEMI 181 -#define TK_NONE 182 -#define TK_PREV 183 -#define TK_LINEAR 184 -#define TK_IMPORT 185 -#define TK_TBNAME 186 -#define TK_JOIN 187 -#define TK_INSERT 188 -#define TK_INTO 189 -#define TK_VALUES 190 +#define TK_STREAM 111 +#define TK_MODE 112 +#define TK_UNSIGNED 113 +#define TK_TAGS 114 +#define TK_USING 115 +#define TK_NULL 116 +#define TK_NOW 117 +#define TK_SELECT 118 +#define TK_UNION 119 +#define TK_ALL 120 +#define TK_DISTINCT 121 +#define TK_FROM 122 +#define TK_VARIABLE 123 +#define TK_INTERVAL 124 +#define TK_EVERY 125 +#define TK_SESSION 126 +#define TK_STATE_WINDOW 127 +#define TK_FILL 128 +#define TK_SLIDING 129 +#define TK_ORDER 130 +#define TK_BY 131 +#define TK_ASC 132 +#define TK_GROUP 133 +#define TK_HAVING 134 +#define TK_LIMIT 135 +#define TK_OFFSET 136 +#define TK_SLIMIT 137 +#define TK_SOFFSET 138 +#define TK_WHERE 139 +#define TK_RESET 140 +#define TK_QUERY 141 +#define TK_SYNCDB 142 +#define TK_ADD 143 +#define TK_COLUMN 144 +#define TK_MODIFY 145 +#define TK_TAG 146 +#define TK_CHANGE 147 +#define TK_SET 148 +#define TK_KILL 149 +#define TK_CONNECTION 150 +#define TK_COLON 151 +#define TK_ABORT 152 +#define TK_AFTER 153 +#define TK_ATTACH 154 +#define TK_BEFORE 155 +#define TK_BEGIN 156 +#define TK_CASCADE 157 +#define TK_CLUSTER 158 +#define TK_CONFLICT 159 +#define TK_COPY 160 +#define TK_DEFERRED 161 +#define TK_DELIMITERS 162 +#define TK_DETACH 163 +#define TK_EACH 164 +#define TK_END 165 +#define TK_EXPLAIN 166 +#define TK_FAIL 167 +#define TK_FOR 168 +#define TK_IGNORE 169 +#define TK_IMMEDIATE 170 +#define TK_INITIALLY 171 +#define TK_INSTEAD 172 +#define TK_KEY 173 +#define TK_OF 174 +#define TK_RAISE 175 +#define TK_REPLACE 176 +#define TK_RESTRICT 177 +#define TK_ROW 178 +#define TK_STATEMENT 179 +#define TK_TRIGGER 180 +#define TK_VIEW 181 +#define TK_SEMI 182 +#define TK_NONE 183 +#define TK_PREV 184 +#define TK_LINEAR 185 +#define TK_IMPORT 186 +#define TK_TBNAME 187 +#define TK_JOIN 188 +#define TK_INSERT 189 +#define TK_INTO 190 +#define TK_VALUES 191 #define NEW_TK_OR 1 #define NEW_TK_AND 2 diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 1ea1f0316a1c8db4c24ba896976f46aa67a64c60..6a0422cd80d6a8b4bf2208e9f27403d47f41c466 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -62,6 +62,7 @@ typedef enum ENodeType { QUERY_NODE_NODE_LIST, QUERY_NODE_FILL, QUERY_NODE_COLUMN_REF, + QUERY_NODE_TARGET, // Only be used in parser module. QUERY_NODE_RAW_EXPR, @@ -72,8 +73,10 @@ typedef enum ENodeType { QUERY_NODE_SHOW_STMT, QUERY_NODE_LOGIC_PLAN_SCAN, + QUERY_NODE_LOGIC_PLAN_JOIN, QUERY_NODE_LOGIC_PLAN_FILTER, - QUERY_NODE_LOGIC_PLAN_AGG + QUERY_NODE_LOGIC_PLAN_AGG, + QUERY_NODE_LOGIC_PLAN_PROJECT } ENodeType; /** @@ -91,7 +94,7 @@ typedef struct SListCell { } SListCell; typedef struct SNodeList { - int16_t length; + int32_t length; SListCell* pHead; SListCell* pTail; } SNodeList; @@ -101,6 +104,7 @@ void nodesDestroyNode(SNode* pNode); SNodeList* nodesMakeList(); int32_t nodesListAppend(SNodeList* pList, SNode* pNode); +int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc); SListCell* nodesListErase(SNodeList* pList, SListCell* pCell); SNode* nodesListGetNode(SNodeList* pList, int32_t index); void nodesDestroyList(SNodeList* pList); diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h new file mode 100644 index 0000000000000000000000000000000000000000..3668f256eb068c224c2f375a0b2da6a081637549 --- /dev/null +++ b/include/libs/nodes/plannodes.h @@ -0,0 +1,65 @@ +/* + * 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_PLANN_NODES_H_ +#define _TD_PLANN_NODES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "querynodes.h" + +typedef struct SLogicNode { + ENodeType type; + int32_t id; + SNodeList* pTargets; // SColumnNode + SNode* pConditions; + SNodeList* pChildren; + struct SLogicNode* pParent; +} SLogicNode; + +typedef struct SScanLogicNode { + SLogicNode node; + SNodeList* pScanCols; + struct STableMeta* pMeta; +} SScanLogicNode; + +typedef struct SJoinLogicNode { + SLogicNode node; + EJoinType joinType; + SNode* pOnConditions; +} SJoinLogicNode; + +typedef struct SFilterLogicNode { + SLogicNode node; +} SFilterLogicNode; + +typedef struct SAggLogicNode { + SLogicNode node; + SNodeList* pGroupKeys; + SNodeList* pAggFuncs; +} SAggLogicNode; + +typedef struct SProjectLogicNode { + SLogicNode node; + SNodeList* pProjections; +} SProjectLogicNode; + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_PLANN_NODES_H_*/ diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 6046770ed1b877b97421ec73be8e27e6466eac26..024967289ad488341bb54204d9ca97e70caf33a6 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -62,8 +62,10 @@ typedef struct SColumnNode { typedef struct SColumnRefNode { ENodeType type; - int32_t tupleId; - int32_t slotId; + SDataType dataType; + int16_t tupleId; + int16_t slotId; + int16_t columnId; } SColumnRefNode; typedef struct SValueNode { @@ -106,6 +108,12 @@ typedef enum EOperatorType { OP_TYPE_NMATCH, OP_TYPE_IS_NULL, OP_TYPE_IS_NOT_NULL, + OP_TYPE_IS_TRUE, + OP_TYPE_IS_FALSE, + OP_TYPE_IS_UNKNOWN, + OP_TYPE_IS_NOT_TRUE, + OP_TYPE_IS_NOT_FALSE, + OP_TYPE_IS_NOT_UNKNOWN, // json operator OP_TYPE_JSON_GET_VALUE, @@ -285,7 +293,7 @@ typedef enum ESqlClause { void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker walker, void* pContext); void nodesRewriteSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeRewriter rewriter, void* pContext); -int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, uint64_t tableId, bool realCol, SNodeList** pCols); +int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char* pTableAlias, SNodeList** pCols); typedef bool (*FFuncClassifier)(int32_t funcId); int32_t nodesCollectFuncs(SSelectStmt* pSelect, FFuncClassifier classifier, SNodeList** pFuncs); diff --git a/source/libs/tdb/src/inc/tdb_db.h b/include/libs/parser/newParser.h similarity index 61% rename from source/libs/tdb/src/inc/tdb_db.h rename to include/libs/parser/newParser.h index 5f0529462b0f592b3d3adf927865c048d882b6f3..fd631087db0029599d1c4f3a500170ffc038cfab 100644 --- a/source/libs/tdb/src/inc/tdb_db.h +++ b/include/libs/parser/newParser.h @@ -13,33 +13,31 @@ * along with this program. If not, see . */ -#ifndef _TD_TDB_DB_H_ -#define _TD_TDB_DB_H_ - -#include "tdb_mpool.h" +#ifndef _TD_NEW_PARSER_H_ +#define _TD_NEW_PARSER_H_ #ifdef __cplusplus extern "C" { #endif -typedef struct TDB TDB; +#include "parser.h" + +typedef enum EStmtType { + STMT_TYPE_CMD = 1, + STMT_TYPE_QUERY +} EStmtType; -struct TDB { - char * fname; - char * dbname; - TDB_MPFILE *mpf; - // union { - // TDB_BTREE *btree; - // TDB_HASH * hash; - // TDB_HEAP * heap; - // } dbam; // db access method -}; +typedef struct SQuery { + EStmtType stmtType; + SNode* pRoot; + int32_t numOfResCols; + SSchema* pResSchema; +} SQuery; -int tdbOpen(TDB **dbpp, const char *fname, const char *dbname, uint32_t flags); -int tdbClose(TDB *dbp, uint32_t flags); +int32_t parser(SParseContext* pParseCxt, SQuery* pQuery); #ifdef __cplusplus } #endif -#endif /*_TD_TDB_DB_H_*/ \ No newline at end of file +#endif /*_TD_NEW_PARSER_H_*/ diff --git a/include/util/tdef.h b/include/util/tdef.h index 35655c8eaf4d1f8046aa77e5b47fd57995d56de3..f57d9b6f358dee73303c879a41fd2e62561cd001 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -333,6 +333,8 @@ do { \ #define TSDB_QUERY_TYPE_NON_TYPE 0x00u // none type #define TSDB_QUERY_TYPE_FREE_RESOURCE 0x01u // free qhandle at vnode +#define TSDB_QUERY_TYPE_NON_TYPE 0x00u // none type +#define TSDB_QUERY_TYPE_FREE_RESOURCE 0x01u // free qhandle at vnode #define TSDB_META_COMPACT_RATIO 0 // disable tsdb meta compact by default diff --git a/include/util/tjson.h b/include/util/tjson.h new file mode 100644 index 0000000000000000000000000000000000000000..a4eb6e5385effc567eb554eed2182f2ce1375fab --- /dev/null +++ b/include/util/tjson.h @@ -0,0 +1,50 @@ +/* + * 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_UTIL_JSON_H_ +#define _TD_UTIL_JSON_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "os.h" + +typedef void SJson; + +SJson* tjsonCreateObject(); +void tjsonDelete(SJson* pJson); + +SJson* tjsonAddArrayToObject(SJson* pJson, const char* pName); + +int32_t tjsonAddIntegerToObject(SJson* pJson, const char* pName, const uint64_t number); +int32_t tjsonAddStringToObject(SJson* pJson, const char* pName, const char* pVal); +int32_t tjsonAddItemToObject(SJson* pJson, const char* pName, SJson* pItem); +int32_t tjsonAddItemToArray(SJson* pJson, SJson* pItem); + +typedef int32_t (*FToJson)(const void* pObj, SJson* pJson); + +int32_t tjsonAddObject(SJson* pJson, const char* pName, FToJson func, const void* pObj); +int32_t tjsonAddItem(SJson* pJson, FToJson func, const void* pObj); + +typedef int32_t (*FFromJson)(const SJson* pJson, void* pObj); + +char* tjsonToString(const SJson* pJson); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_UTIL_JSON_H_*/ diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index e602cee302885a7b2b8671f6d93db315814011e6..229d3a9ec319472f3ead8f0a1a984d5a800ea842 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -75,7 +75,7 @@ struct tmq_message_t { SMqConsumeRsp rsp; }; -typedef struct SMqClientVg { +typedef struct { // statistics int64_t pollCnt; // offset @@ -86,7 +86,7 @@ typedef struct SMqClientVg { SEpSet epSet; } SMqClientVg; -typedef struct SMqClientTopic { +typedef struct { // subscribe info int32_t sqlLen; char* sql; @@ -269,7 +269,7 @@ tmq_resp_err_t tmq_reset_offset(tmq_t* tmq, const tmq_topic_vgroup_list_t* offse tsem_wait(¶m.rspSem); tsem_destroy(¶m.rspSem); - return TMQ_RESP_ERR__SUCCESS; + return param.rspErr; } tmq_resp_err_t tmq_subscribe(tmq_t* tmq, tmq_list_t* topic_list) { @@ -779,11 +779,9 @@ tmq_message_t* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) { param->pVg = pVg; tsem_init(¶m->rspSem, 0, 0); - SRequestObj* pRequest = createRequest(tmq->pTscObj, NULL, NULL, TDMT_VND_CONSUME); pRequest->body.requestMsg = (SDataBuf){.pData = pReq, .len = sizeof(SMqConsumeReq), .handle = NULL}; - SMsgSendInfo* sendInfo = buildMsgInfoImpl(pRequest); sendInfo->requestObjRefId = 0; sendInfo->param = param; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index ba7ce144660ab9346fc21f6deae0499cbfd63902..46feab779144f89272f977f58a7ae463d8063250 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -34,6 +34,7 @@ int32_t tInitSubmitMsgIter(SSubmitReq *pMsg, SSubmitMsgIter *pIter) { } pIter->totalLen = pMsg->length; + ASSERT(pIter->totalLen > 0); pIter->len = 0; pIter->pMsg = pMsg; if (pMsg->length <= sizeof(SSubmitReq)) { @@ -45,11 +46,14 @@ int32_t tInitSubmitMsgIter(SSubmitReq *pMsg, SSubmitMsgIter *pIter) { } int32_t tGetSubmitMsgNext(SSubmitMsgIter *pIter, SSubmitBlk **pPBlock) { + ASSERT(pIter->len >= 0); + if (pIter->len == 0) { pIter->len += sizeof(SSubmitReq); } else { SSubmitBlk *pSubmitBlk = (SSubmitBlk *)POINTER_SHIFT(pIter->pMsg, pIter->len); pIter->len += (sizeof(SSubmitBlk) + pSubmitBlk->dataLen + pSubmitBlk->schemaLen); + ASSERT(pIter->len > 0); } if (pIter->len > pIter->totalLen) { @@ -1275,6 +1279,7 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) { if (tEncodeI8(&encoder, pReq->update) < 0) return -1; if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1; if (tEncodeI8(&encoder, pReq->ignoreExist) < 0) return -1; + if (tEncodeI8(&encoder, pReq->streamMode) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -1307,6 +1312,7 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) if (tDecodeI8(&decoder, &pReq->update) < 0) return -1; if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1; if (tDecodeI8(&decoder, &pReq->ignoreExist) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->streamMode) < 0) return -1; tEndDecode(&decoder); tCoderClear(&decoder); @@ -2107,6 +2113,7 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1; if (tEncodeI8(&encoder, pReq->replica) < 0) return -1; if (tEncodeI8(&encoder, pReq->selfIndex) < 0) return -1; + if (tEncodeI8(&encoder, pReq->streamMode) < 0) return -1; for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) { SReplica *pReplica = &pReq->replicas[i]; if (tEncodeSReplica(&encoder, pReplica) < 0) return -1; @@ -2146,6 +2153,7 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq * if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1; if (tDecodeI8(&decoder, &pReq->replica) < 0) return -1; if (tDecodeI8(&decoder, &pReq->selfIndex) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->streamMode) < 0) return -1; for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) { SReplica *pReplica = &pReq->replicas[i]; if (tDecodeSReplica(&decoder, pReplica) < 0) return -1; @@ -2348,6 +2356,34 @@ int32_t tDecodeSMqOffset(SCoder *decoder, SMqOffset *pOffset) { return 0; } +int32_t tEncodeSMqVgOffsets(SCoder *encoder, const SMqVgOffsets *pOffsets) { + if (tStartEncode(encoder) < 0) return -1; + if (tEncodeI32(encoder, pOffsets->vgId) < 0) return -1; + int32_t sz = taosArrayGetSize(pOffsets->offsets); + if (tEncodeI32(encoder, sz) < 0) return -1; + for (int32_t i = 0; i < sz; i++) { + SMqOffset *offset = taosArrayGet(pOffsets->offsets, i); + if (tEncodeSMqOffset(encoder, offset) < 0) return -1; + } + tEndEncode(encoder); + return encoder->pos; +} + +int32_t tDecodeSMqVgOffsets(SCoder *decoder, SMqVgOffsets *pOffsets) { + int32_t sz; + if (tStartDecode(decoder) < 0) return -1; + if (tDecodeI32(decoder, &pOffsets->vgId) < 0) return -1; + if (tDecodeI32(decoder, &sz) < 0) return -1; + pOffsets->offsets = taosArrayInit(sz, sizeof(SMqOffset)); + for (int32_t i = 0; i < sz; i++) { + SMqOffset offset; + if (tDecodeSMqOffset(decoder, &offset) < 0) return -1; + taosArrayPush(pOffsets->offsets, &offset); + } + tEndDecode(decoder); + return 0; +} + int32_t tEncodeSMqCMResetOffsetReq(SCoder *encoder, const SMqCMResetOffsetReq *pReq) { if (tStartEncode(encoder) < 0) return -1; if (tEncodeI32(encoder, pReq->num) < 0) return -1; @@ -2359,17 +2395,20 @@ int32_t tEncodeSMqCMResetOffsetReq(SCoder *encoder, const SMqCMResetOffsetReq *p } int32_t tDecodeSMqCMResetOffsetReq(SCoder *decoder, SMqCMResetOffsetReq *pReq) { + if (tStartDecode(decoder) < 0) return -1; if (tDecodeI32(decoder, &pReq->num) < 0) return -1; pReq->offsets = TCODER_MALLOC(pReq->num * sizeof(SMqOffset), decoder); if (pReq->offsets == NULL) return -1; for (int32_t i = 0; i < pReq->num; i++) { tDecodeSMqOffset(decoder, &pReq->offsets[i]); } + tEndDecode(decoder); return 0; } +#if 0 int32_t tEncodeSMqMVResetOffsetReq(SCoder *encoder, const SMqMVResetOffsetReq *pReq) { - if (tEncodeI32(encoder, pReq->num) < 0) return -1; + if (tEncodeI64(encoder, pReq->leftForVer) < 0) return -1; for (int32_t i = 0; i < pReq->num; i++) { tEncodeSMqOffset(encoder, &pReq->offsets[i]); } @@ -2385,3 +2424,4 @@ int32_t tDecodeSMqMVResetOffsetReq(SCoder *decoder, SMqMVResetOffsetReq *pReq) { } return 0; } +#endif diff --git a/source/dnode/mgmt/impl/src/dndVnodes.c b/source/dnode/mgmt/impl/src/dndVnodes.c index ebb2d1b4f0e4b9d63ae862bfa47b755bb3dcb9f9..b82d991179a8b698b4be348a8f51ff164cb5e2d6 100644 --- a/source/dnode/mgmt/impl/src/dndVnodes.c +++ b/source/dnode/mgmt/impl/src/dndVnodes.c @@ -507,6 +507,7 @@ static void dndGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { pCfg->isHeapAllocator = true; pCfg->ttl = 4; pCfg->keep = pCreate->daysToKeep0; + pCfg->streamMode = pCreate->streamMode; pCfg->isWeak = true; pCfg->tsdbCfg.keep = pCreate->daysToKeep0; pCfg->tsdbCfg.keep1 = pCreate->daysToKeep2; diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index f30301c72e7484e712a95329ff9464b212e4a705..e64191f7153c87301fa14d74e44cdb75b5f2cd89 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -300,6 +300,7 @@ typedef struct { int8_t quorum; int8_t update; int8_t cacheLastRow; + int8_t streamMode; } SDbCfg; typedef struct { @@ -336,6 +337,7 @@ typedef struct { int64_t pointsWritten; int8_t compact; int8_t replica; + int8_t streamMode; SVnodeGid vnodeGid[TSDB_MAX_REPLICA]; } SVgObj; @@ -467,9 +469,9 @@ typedef struct { char key[TSDB_SUBSCRIBE_KEY_LEN]; int32_t status; int32_t vgNum; - SArray* consumers; // SArray - SArray* lostConsumers; // SArray - SArray* unassignedVg; // SArray + SArray* consumers; // SArray + SArray* lostConsumers; // SArray + SArray* unassignedVg; // SArray } SMqSubscribeObj; static FORCE_INLINE SMqSubscribeObj* tNewSubscribeObj() { @@ -583,13 +585,13 @@ static FORCE_INLINE void* tDecodeSubscribeObj(void* buf, SMqSubscribeObj* pSub) static FORCE_INLINE void tDeleteSMqSubscribeObj(SMqSubscribeObj* pSub) { if (pSub->consumers) { taosArrayDestroyEx(pSub->consumers, (void (*)(void*))tDeleteSMqSubConsumer); - //taosArrayDestroy(pSub->consumers); + // taosArrayDestroy(pSub->consumers); pSub->consumers = NULL; } if (pSub->unassignedVg) { taosArrayDestroyEx(pSub->unassignedVg, (void (*)(void*))tDeleteSMqConsumerEp); - //taosArrayDestroy(pSub->unassignedVg); + // taosArrayDestroy(pSub->unassignedVg); pSub->unassignedVg = NULL; } } @@ -614,8 +616,8 @@ typedef struct { int64_t connId; SRWLatch lock; char cgroup[TSDB_CONSUMER_GROUP_LEN]; - SArray* currentTopics; // SArray - SArray* recentRemovedTopics; // SArray + SArray* currentTopics; // SArray + SArray* recentRemovedTopics; // SArray int32_t epoch; // stat int64_t pollCnt; diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 122982b7f26176e793746b8a6c803845efd28d85..9c8a4ce586fc81db61759df6819435f1c9911680 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -395,24 +395,27 @@ static int32_t mndCreateDb(SMnode *pMnode, SMnodeMsg *pReq, SCreateDbReq *pCreat dbObj.vgVersion = 1; dbObj.hashMethod = 1; memcpy(dbObj.createUser, pUser->user, TSDB_USER_LEN); - dbObj.cfg = (SDbCfg){.numOfVgroups = pCreate->numOfVgroups, - .cacheBlockSize = pCreate->cacheBlockSize, - .totalBlocks = pCreate->totalBlocks, - .daysPerFile = pCreate->daysPerFile, - .daysToKeep0 = pCreate->daysToKeep0, - .daysToKeep1 = pCreate->daysToKeep1, - .daysToKeep2 = pCreate->daysToKeep2, - .minRows = pCreate->minRows, - .maxRows = pCreate->maxRows, - .fsyncPeriod = pCreate->fsyncPeriod, - .commitTime = pCreate->commitTime, - .precision = pCreate->precision, - .compression = pCreate->compression, - .walLevel = pCreate->walLevel, - .replications = pCreate->replications, - .quorum = pCreate->quorum, - .update = pCreate->update, - .cacheLastRow = pCreate->cacheLastRow}; + dbObj.cfg = (SDbCfg){ + .numOfVgroups = pCreate->numOfVgroups, + .cacheBlockSize = pCreate->cacheBlockSize, + .totalBlocks = pCreate->totalBlocks, + .daysPerFile = pCreate->daysPerFile, + .daysToKeep0 = pCreate->daysToKeep0, + .daysToKeep1 = pCreate->daysToKeep1, + .daysToKeep2 = pCreate->daysToKeep2, + .minRows = pCreate->minRows, + .maxRows = pCreate->maxRows, + .fsyncPeriod = pCreate->fsyncPeriod, + .commitTime = pCreate->commitTime, + .precision = pCreate->precision, + .compression = pCreate->compression, + .walLevel = pCreate->walLevel, + .replications = pCreate->replications, + .quorum = pCreate->quorum, + .update = pCreate->update, + .cacheLastRow = pCreate->cacheLastRow, + .streamMode = pCreate->streamMode, + }; mndSetDefaultDbCfg(&dbObj.cfg); @@ -1400,4 +1403,4 @@ static int32_t mndRetrieveDbs(SMnodeMsg *pReq, SShowObj *pShow, char *data, int3 static void mndCancelGetNextDb(SMnode *pMnode, void *pIter) { SSdb *pSdb = pMnode->pSdb; sdbCancelFetch(pSdb, pIter); -} \ No newline at end of file +} diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index 6169aaa78aa9dd4b538352caff1c36c76cb450c3..a5c4c41244e32d79d99b6072601267f4e923e4bb 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -53,6 +53,7 @@ static int32_t mndProcessSubscribeInternalRsp(SMnodeMsg *pMsg); static int32_t mndProcessMqTimerMsg(SMnodeMsg *pMsg); static int32_t mndProcessGetSubEpReq(SMnodeMsg *pMsg); static int32_t mndProcessDoRebalanceMsg(SMnodeMsg *pMsg); +static int32_t mndProcessResetOffsetReq(SMnodeMsg *pMsg); static int32_t mndPersistMqSetConnReq(SMnode *pMnode, STrans *pTrans, const SMqTopicObj *pTopic, const char *cgroup, const SMqConsumerEp *pConsumerEp); @@ -205,6 +206,45 @@ static int32_t mndPersistCancelConnReq(SMnode *pMnode, STrans *pTrans, const SMq return 0; } +#if 0 +static int32_t mndProcessResetOffsetReq(SMnodeMsg *pMsg) { + SMnode *pMnode = pMsg->pMnode; + uint8_t *str = pMsg->rpcMsg.pCont; + SMqCMResetOffsetReq req; + + SCoder decoder; + tCoderInit(&decoder, TD_LITTLE_ENDIAN, str, pMsg->rpcMsg.contLen, TD_DECODER); + tDecodeSMqCMResetOffsetReq(&decoder, &req); + + SHashObj *pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + if (pHash == NULL) { + return -1; + } + + for (int32_t i = 0; i < req.num; i++) { + SMqOffset *pOffset = &req.offsets[i]; + SMqVgOffsets *pVgOffset = taosHashGet(pHash, &pOffset->vgId, sizeof(int32_t)); + if (pVgOffset == NULL) { + pVgOffset = malloc(sizeof(SMqVgOffsets)); + if (pVgOffset == NULL) { + return -1; + } + pVgOffset->offsets = taosArrayInit(0, sizeof(void *)); + taosArrayPush(pVgOffset->offsets, &pOffset); + } + taosHashPut(pHash, &pOffset->vgId, sizeof(int32_t), &pVgOffset, sizeof(void *)); + } + + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg); + if (pTrans == NULL) { + mError("mq-reset-offset: failed since %s", terrstr()); + return -1; + } + + return 0; +} +#endif + static int32_t mndProcessGetSubEpReq(SMnodeMsg *pMsg) { SMnode *pMnode = pMsg->pMnode; SMqCMGetSubEpReq *pReq = (SMqCMGetSubEpReq *)pMsg->rpcMsg.pCont; @@ -1059,6 +1099,8 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) { pConsumerEp->consumerId = consumerId; taosArrayPush(mqSubConsumer.vgInfo, pConsumerEp); if (pConsumerEp->oldConsumerId == -1) { + mInfo("mq set conn: assign vgroup %d of topic %s to consumer %ld", pConsumerEp->vgId, newTopicName, + pConsumerEp->consumerId); mndPersistMqSetConnReq(pMnode, pTrans, pTopic, cgroup, pConsumerEp); } else { mndPersistRebalanceMsg(pMnode, pTrans, pConsumerEp); diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index a2438a3b8ee0d3167e95f7e771b7ff16dc719ffb..b437b444177d5594c2c637b2741fe367b0305674 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -21,7 +21,7 @@ #include "mndShow.h" #include "mndTrans.h" -#define TSDB_VGROUP_VER_NUMBER 1 +#define TSDB_VGROUP_VER_NUMBER 1 #define TSDB_VGROUP_RESERVE_SIZE 64 static SSdbRow *mndVgroupActionDecode(SSdbRaw *pRaw); @@ -214,6 +214,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg createReq.cacheLastRow = pDb->cfg.cacheLastRow; createReq.replica = pVgroup->replica; createReq.selfIndex = -1; + createReq.streamMode = pVgroup->streamMode; for (int32_t v = 0; v < pVgroup->replica; ++v) { SReplica *pReplica = &createReq.replicas[v]; @@ -255,8 +256,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg return pReq; } -void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, - int32_t *pContLen) { +void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen) { SDropVnodeReq dropReq = {0}; dropReq.dnodeId = pDnode->id; dropReq.vgId = pVgroup->vgId; @@ -399,6 +399,7 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) { pVgroup->createdTime = taosGetTimestampMs(); pVgroup->updateTime = pVgroups->createdTime; pVgroup->version = 1; + pVgroup->streamMode = pDb->cfg.streamMode; pVgroup->hashBegin = hashMin + hashInterval * v; if (v == pDb->cfg.numOfVgroups - 1) { pVgroup->hashEnd = hashMax; @@ -700,4 +701,4 @@ static int32_t mndRetrieveVnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, i static void mndCancelGetNextVnode(SMnode *pMnode, void *pIter) { SSdb *pSdb = pMnode->pSdb; sdbCancelFetch(pSdb, pIter); -} \ No newline at end of file +} diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index e15a2ee8837eb88e20728b1aefc1420bf4f0339e..3c0d45df633a6b5abbd249690e4fe20c824e3a67 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -1,7 +1,24 @@ +set(META_DB_IMPL_LIST "BDB" "TDB") +set(META_DB_IMPL "BDB" CACHE STRING "Use BDB as the default META implementation") +set_property(CACHE META_DB_IMPL PROPERTY STRINGS ${META_DB_IMPL_LIST}) + +if(META_DB_IMPL IN_LIST META_DB_IMPL_LIST) + message(STATUS "META DB Impl: ${META_DB_IMPL}==============") +else() + message(FATAL_ERROR "Invalid META DB IMPL: ${META_DB_IMPL}==============") +endif() + aux_source_directory(src/meta META_SRC) +if(${META_DB_IMPL} STREQUAL "BDB") + list(REMOVE_ITEM META_SRC "src/meta/metaTDBImpl.c") +elseif(${META_DB_IMPL} STREQUAL "TDB") + list(REMOVE_ITEM META_SRC "src/meta/metaBDBImpl.c") +endif() + aux_source_directory(src/tq TQ_SRC) aux_source_directory(src/tsdb TSDB_SRC) aux_source_directory(src/vnd VND_SRC) + list(APPEND VNODE_SRC ${META_SRC} @@ -22,7 +39,6 @@ target_link_libraries( PUBLIC util PUBLIC common PUBLIC transport - PUBLIC bdb PUBLIC tfs PUBLIC wal PUBLIC scheduler @@ -31,6 +47,12 @@ target_link_libraries( PUBLIC sync ) +if(${META_DB_IMPL} STREQUAL "BDB") + target_link_libraries(vnode PUBLIC bdb) +elseif(${META_DB_IMPL} STREQUAL "TDB") + target_link_libraries(vnode PUBLIC tdb) +endif() + if(${BUILD_TEST}) # add_subdirectory(test) endif(${BUILD_TEST}) diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index eaf30da1bb8bcc3a47e828988c0a977587a2ea1e..3a06674e3ce50a58a23800f50d55ca76bed46046 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -51,6 +51,7 @@ typedef struct { bool isHeapAllocator; uint32_t ttl; uint32_t keep; + int8_t streamMode; bool isWeak; STsdbCfg tsdbCfg; SMetaCfg metaCfg; @@ -225,9 +226,9 @@ static FORCE_INLINE int tqReadHandleSetTbUidList(STqReadHandle *pHandle, const S return 0; } -void tqReadHandleSetMsg(STqReadHandle *pHandle, SSubmitReq *pMsg, int64_t ver); -bool tqNextDataBlock(STqReadHandle *pHandle); -int tqRetrieveDataBlockInfo(STqReadHandle *pHandle, SDataBlockInfo *pBlockInfo); +int32_t tqReadHandleSetMsg(STqReadHandle *pHandle, SSubmitReq *pMsg, int64_t ver); +bool tqNextDataBlock(STqReadHandle *pHandle); +int tqRetrieveDataBlockInfo(STqReadHandle *pHandle, SDataBlockInfo *pBlockInfo); // return SArray SArray *tqRetrieveDataBlock(STqReadHandle *pHandle); diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index f442697fb01423a265f95bd676379661cc838f4d..fb81ddbc5ce992c699faa4cecf1d0d16a429fbcd 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -23,8 +23,8 @@ #include "tlist.h" #include "tlockfree.h" #include "tmacro.h" -#include "wal.h" #include "tq.h" +#include "wal.h" #include "vnode.h" @@ -175,7 +175,6 @@ void* vmaMalloc(SVMemAllocator* pVMA, uint64_t size); void vmaFree(SVMemAllocator* pVMA, void* ptr); bool vmaIsFull(SVMemAllocator* pVMA); - #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/src/meta/metaTDBImpl.c b/source/dnode/vnode/src/meta/metaTDBImpl.c new file mode 100644 index 0000000000000000000000000000000000000000..4a65cf277b9dd11aeb9a0ee47cea6e19f314d10c --- /dev/null +++ b/source/dnode/vnode/src/meta/metaTDBImpl.c @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "metaDef.h" + +#include "tdb.h" + +struct SMetaDB { + TENV *pEnv; + TDB * pTbDB; + TDB * pSchemaDB; + TDB * pNameIdx; + TDB * pStbIdx; + TDB * pNtbIdx; + TDB * pCtbIdx; + // tag index hash table + // suid+colid --> TDB * + struct { + } tagIdxHt; +}; + +#define A(op, flag) \ + do { \ + if ((ret = op) != 0) goto flag; \ + } while (0) + +int metaOpenDB(SMeta *pMeta) { + SMetaDB *pDb; + TENV * pEnv; + TDB * pTbDB; + TDB * pSchemaDB; + TDB * pNameIdx; + TDB * pStbIdx; + TDB * pNtbIdx; + TDB * pCtbIdx; + int ret; + + pDb = (SMetaDB *)calloc(1, sizeof(*pDb)); + if (pDb == NULL) { + return -1; + } + + // Create and open the ENV + A((tdbEnvCreate(&pEnv)), _err); +#if 0 + // Set options of the environment + A(tdbEnvSetPageSize(pEnv, 8192), _err); + A(tdbEnvSetCacheSize(pEnv, 16 * 1024 * 1024), _err); +#endif + A((tdbEnvOpen(&pEnv)), _err); + + // Create and open each DB + A(tdbCreate(&pTbDB), _err); + A(tdbOpen(&pTbDB, "table.db", NULL, pEnv), _err); + + A(tdbCreate(&pSchemaDB), _err); + A(tdbOpen(&pSchemaDB, "schema.db", NULL, pEnv), _err); + + A(tdbCreate(&pNameIdx), _err); + A(tdbOpen(&pNameIdx, "name.db", NULL, pEnv), _err); + // tdbAssociate(); + + pDb->pEnv = pEnv; + pDb->pTbDB = pTbDB; + pDb->pSchemaDB = pSchemaDB; + pMeta->pDB = pDb; + return 0; + +_err: + return -1; +} + +void metaCloseDB(SMeta *pMeta) { + // TODO +} + +int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) { + // TODO + return 0; +} + +int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid) { + // TODO + return 0; +} + +STbCfg *metaGetTbInfoByUid(SMeta *pMeta, tb_uid_t uid) { + // TODO + return NULL; +} + +STbCfg *metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid) { + // TODO + return NULL; +} + +SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, bool isinline) { + // TODO + return NULL; +} + +STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) { + // TODO + return NULL; +} + +SMTbCursor *metaOpenTbCursor(SMeta *pMeta) { + // TODO + return NULL; +} + +void metaCloseTbCursor(SMTbCursor *pTbCur) { + // TODO +} + +char *metaTbCursorNext(SMTbCursor *pTbCur) { + // TODO + return NULL; +} + +SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid) { + // TODO + return NULL; +} + +void metaCloseCtbCurosr(SMCtbCursor *pCtbCur) { + // TODO +} + +tb_uid_t metaCtbCursorNext(SMCtbCursor *pCtbCur) { + // TODO + return 0; +} \ No newline at end of file diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index e76d43becd93af540d6245f6aa61be4af9cfb95d..bfa811feecf7a33037152c2ed41110b2fa60f49b 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -31,13 +31,28 @@ STqReadHandle* tqInitSubmitMsgScanner(SMeta* pMeta) { return pReadHandle; } -void tqReadHandleSetMsg(STqReadHandle* pReadHandle, SSubmitReq* pMsg, int64_t ver) { +int32_t tqReadHandleSetMsg(STqReadHandle* pReadHandle, SSubmitReq* pMsg, int64_t ver) { pReadHandle->pMsg = pMsg; pMsg->length = htonl(pMsg->length); pMsg->numOfBlocks = htonl(pMsg->numOfBlocks); - tInitSubmitMsgIter(pMsg, &pReadHandle->msgIter); + + if (tInitSubmitMsgIter(pMsg, &pReadHandle->msgIter) < 0) return -1; + while (true) { + if (tGetSubmitMsgNext(&pReadHandle->msgIter, &pReadHandle->pBlock) < 0) return -1; + if (pReadHandle->pBlock == NULL) break; + + pReadHandle->pBlock->uid = htobe64(pReadHandle->pBlock->uid); + pReadHandle->pBlock->tid = htonl(pReadHandle->pBlock->tid); + pReadHandle->pBlock->sversion = htonl(pReadHandle->pBlock->sversion); + pReadHandle->pBlock->dataLen = htonl(pReadHandle->pBlock->dataLen); + pReadHandle->pBlock->schemaLen = htonl(pReadHandle->pBlock->schemaLen); + pReadHandle->pBlock->numOfRows = htons(pReadHandle->pBlock->numOfRows); + } + + if (tInitSubmitMsgIter(pMsg, &pReadHandle->msgIter) < 0) return -1; pReadHandle->ver = ver; memset(&pReadHandle->blkIter, 0, sizeof(SSubmitBlkIter)); + return 0; } bool tqNextDataBlock(STqReadHandle* pHandle) { @@ -47,19 +62,19 @@ bool tqNextDataBlock(STqReadHandle* pHandle) { } if (pHandle->pBlock == NULL) return false; - pHandle->pBlock->uid = htobe64(pHandle->pBlock->uid); + /*pHandle->pBlock->uid = htobe64(pHandle->pBlock->uid);*/ /*if (pHandle->tbUid == pHandle->pBlock->uid) {*/ ASSERT(pHandle->tbIdHash); void* ret = taosHashGet(pHandle->tbIdHash, &pHandle->pBlock->uid, sizeof(int64_t)); if (ret != NULL) { /*printf("retrieve one tb %ld\n", pHandle->pBlock->uid);*/ - pHandle->pBlock->tid = htonl(pHandle->pBlock->tid); - pHandle->pBlock->sversion = htonl(pHandle->pBlock->sversion); - pHandle->pBlock->dataLen = htonl(pHandle->pBlock->dataLen); - pHandle->pBlock->schemaLen = htonl(pHandle->pBlock->schemaLen); - pHandle->pBlock->numOfRows = htons(pHandle->pBlock->numOfRows); + /*pHandle->pBlock->tid = htonl(pHandle->pBlock->tid);*/ + /*pHandle->pBlock->sversion = htonl(pHandle->pBlock->sversion);*/ + /*pHandle->pBlock->dataLen = htonl(pHandle->pBlock->dataLen);*/ + /*pHandle->pBlock->schemaLen = htonl(pHandle->pBlock->schemaLen);*/ + /*pHandle->pBlock->numOfRows = htons(pHandle->pBlock->numOfRows);*/ return true; - } else { + /*} else {*/ /*printf("skip one tb %ld\n", pHandle->pBlock->uid);*/ } } diff --git a/source/dnode/vnode/src/vnd/vnodeWrite.c b/source/dnode/vnode/src/vnd/vnodeWrite.c index 5c39c65f9ff12d25c881213ac4ac53e29c6dda45..ade280eecc85f9346331bf5a91a79c8afbdf1198 100644 --- a/source/dnode/vnode/src/vnd/vnodeWrite.c +++ b/source/dnode/vnode/src/vnd/vnodeWrite.c @@ -43,13 +43,17 @@ int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) { int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { SVCreateTbReq vCreateTbReq; SVCreateTbBatchReq vCreateTbBatchReq; - void *ptr = vnodeMalloc(pVnode, pMsg->contLen); - if (ptr == NULL) { - // TODO: handle error - } + void *ptr = NULL; - // TODO: copy here need to be extended - memcpy(ptr, pMsg->pCont, pMsg->contLen); + if (pVnode->config.streamMode == 0) { + ptr = vnodeMalloc(pVnode, pMsg->contLen); + if (ptr == NULL) { + // TODO: handle error + } + + // TODO: copy here need to be extended + memcpy(ptr, pMsg->pCont, pMsg->contLen); + } // todo: change the interface here int64_t ver; @@ -109,17 +113,19 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { // } break; case TDMT_VND_SUBMIT: - if (tsdbInsertData(pVnode->pTsdb, (SSubmitReq *)ptr, NULL) < 0) { - // TODO: handle error + if (pVnode->config.streamMode == 0) { + if (tsdbInsertData(pVnode->pTsdb, (SSubmitReq *)ptr, NULL) < 0) { + // TODO: handle error + } } break; case TDMT_VND_MQ_SET_CONN: { - if (tqProcessSetConnReq(pVnode->pTq, POINTER_SHIFT(ptr, sizeof(SMsgHead))) < 0) { + if (tqProcessSetConnReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) { // TODO: handle error } } break; case TDMT_VND_MQ_REB: { - if (tqProcessRebReq(pVnode->pTq, POINTER_SHIFT(ptr, sizeof(SMsgHead))) < 0) { + if (tqProcessRebReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) { } } break; default: diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index c47c83ba2981e5872d177399075770f142812da6..18485249b39f47faf19e25d8079016af2acd213d 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -14,9 +14,9 @@ */ #include "executor.h" -#include "tq.h" #include "executorimpl.h" #include "planner.h" +#include "tq.h" static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, char* id) { ASSERT(pOperator != NULL); @@ -34,7 +34,10 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, char* id) return doSetStreamBlock(pOperator->pDownstream[0], input, id); } else { SStreamBlockScanInfo* pInfo = pOperator->info; - tqReadHandleSetMsg(pInfo->readerHandle, input, 0); + if (tqReadHandleSetMsg(pInfo->readerHandle, input, 0) < 0) { + qError("submit msg error while set stream msg, %s" PRIx64, id); + return TSDB_CODE_QRY_APP_ERROR; + } return TSDB_CODE_SUCCESS; } } @@ -48,9 +51,9 @@ int32_t qSetStreamInput(qTaskInfo_t tinfo, const void* input) { return TSDB_CODE_SUCCESS; } - SExecTaskInfo* pTaskInfo = (SExecTaskInfo*) tinfo; + SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - int32_t code = doSetStreamBlock(pTaskInfo->pRoot, (void*) input, GET_TASKID(pTaskInfo)); + int32_t code = doSetStreamBlock(pTaskInfo->pRoot, (void*)input, GET_TASKID(pTaskInfo)); if (code != TSDB_CODE_SUCCESS) { qError("%s failed to set the stream block data", GET_TASKID(pTaskInfo)); } else { diff --git a/source/libs/nodes/CMakeLists.txt b/source/libs/nodes/CMakeLists.txt index 9a826e034cca5c8b9680250c1c843f808a25b8b7..e20cdc39ba59f5264aa1be40c01d9a8a4fe11b15 100644 --- a/source/libs/nodes/CMakeLists.txt +++ b/source/libs/nodes/CMakeLists.txt @@ -7,7 +7,7 @@ target_include_directories( ) target_link_libraries( nodes - PRIVATE os util + PRIVATE os util common qcom ) if(${BUILD_TEST}) diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index ad83bdbd191665e5c986778374c30c25a25fa8aa..d1f32ae31483d2919a7e181be5fe365768b35bde 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -13,11 +13,18 @@ * along with this program. If not, see . */ -#include "nodes.h" +#include "plannodes.h" +#include "querynodes.h" +#include "query.h" +#include "taoserror.h" +#include "tjson.h" -int32_t nodesNodeToString(const SNode* pNode, char** pStr, int32_t* pLen) { - switch (nodeType(pNode)) { +static int32_t nodeToJson(const void* pObj, SJson* pJson); + +static char* nodeName(ENodeType type) { + switch (type) { case QUERY_NODE_COLUMN: + return "Column"; case QUERY_NODE_VALUE: case QUERY_NODE_OPERATOR: case QUERY_NODE_LOGIC_CONDITION: @@ -31,14 +38,230 @@ int32_t nodesNodeToString(const SNode* pNode, char** pStr, int32_t* pLen) { case QUERY_NODE_STATE_WINDOW: case QUERY_NODE_SESSION_WINDOW: case QUERY_NODE_INTERVAL_WINDOW: + case QUERY_NODE_NODE_LIST: + case QUERY_NODE_FILL: + case QUERY_NODE_COLUMN_REF: + case QUERY_NODE_TARGET: + case QUERY_NODE_RAW_EXPR: case QUERY_NODE_SET_OPERATOR: case QUERY_NODE_SELECT_STMT: case QUERY_NODE_SHOW_STMT: + break; + case QUERY_NODE_LOGIC_PLAN_SCAN: + return "LogicScan"; + case QUERY_NODE_LOGIC_PLAN_JOIN: + return "LogicJoin"; + case QUERY_NODE_LOGIC_PLAN_FILTER: + return "LogicFilter"; + case QUERY_NODE_LOGIC_PLAN_AGG: + return "LogicAgg"; + case QUERY_NODE_LOGIC_PLAN_PROJECT: + return "LogicProject"; default: break; } + return "Unknown"; } -int32_t nodesStringToNode(const char* pStr, SNode** pNode) { +static int32_t addNodeList(SJson* pJson, const char* pName, FToJson func, const SNodeList* pList) { + if (LIST_LENGTH(pList) > 0) { + SJson* jList = tjsonAddArrayToObject(pJson, pName); + if (NULL == jList) { + return TSDB_CODE_OUT_OF_MEMORY; + } + SNode* pNode; + FOREACH(pNode, pList) { + int32_t code = tjsonAddItem(jList, func, pNode); + if (TSDB_CODE_SUCCESS != code) { + return code; + } + } + } + return TSDB_CODE_SUCCESS; +} + +static const char* jkTableMetaUid = "TableMetaUid"; +static const char* jkTableMetaSuid = "TableMetaSuid"; + +static int32_t tableMetaToJson(const void* pObj, SJson* pJson) { + const STableMeta* pNode = (const STableMeta*)pObj; + + int32_t code = tjsonAddIntegerToObject(pJson, jkTableMetaUid, pNode->uid); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkTableMetaSuid, pNode->suid); + } + + return code; +} + +static const char* jkLogicPlanId = "Id"; +static const char* jkLogicPlanTargets = "Targets"; +static const char* jkLogicPlanConditions = "Conditions"; +static const char* jkLogicPlanChildren = "Children"; + +static int32_t logicPlanNodeToJson(const void* pObj, SJson* pJson) { + const SLogicNode* pNode = (const SLogicNode*)pObj; + + int32_t code = tjsonAddIntegerToObject(pJson, jkLogicPlanId, pNode->id); + if (TSDB_CODE_SUCCESS == code) { + code = addNodeList(pJson, jkLogicPlanTargets, nodeToJson, pNode->pTargets); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkLogicPlanConditions, nodeToJson, pNode->pConditions); + } + if (TSDB_CODE_SUCCESS == code) { + code = addNodeList(pJson, jkLogicPlanChildren, nodeToJson, pNode->pChildren); + } + + return code; +} + +static const char* jkScanLogicPlanScanCols = "ScanCols"; +static const char* jkScanLogicPlanTableMeta = "TableMeta"; + +static int32_t logicScanToJson(const void* pObj, SJson* pJson) { + const SScanLogicNode* pNode = (const SScanLogicNode*)pObj; + + int32_t code = logicPlanNodeToJson(pObj, pJson); + if (TSDB_CODE_SUCCESS == code) { + code = addNodeList(pJson, jkScanLogicPlanScanCols, nodeToJson, pNode->pScanCols); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkScanLogicPlanTableMeta, tableMetaToJson, pNode->pMeta); + } + + return code; +} + +static const char* jkProjectLogicPlanProjections = "Projections"; + +static int32_t logicProjectToJson(const void* pObj, SJson* pJson) { + const SProjectLogicNode* pNode = (const SProjectLogicNode*)pObj; + + int32_t code = logicPlanNodeToJson(pObj, pJson); + if (TSDB_CODE_SUCCESS == code) { + code = addNodeList(pJson, jkProjectLogicPlanProjections, nodeToJson, pNode->pProjections); + } + + return code; +} + +static const char* jkJoinLogicPlanJoinType = "JoinType"; +static const char* jkJoinLogicPlanOnConditions = "OnConditions"; + +static int32_t logicJoinToJson(const void* pObj, SJson* pJson) { + const SJoinLogicNode* pNode = (const SJoinLogicNode*)pObj; + + int32_t code = logicPlanNodeToJson(pObj, pJson); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkJoinLogicPlanJoinType, pNode->joinType); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkJoinLogicPlanOnConditions, nodeToJson, pNode->pOnConditions); + } + + return code; +} + +static int32_t logicFilterToJson(const void* pObj, SJson* pJson) { + return logicPlanNodeToJson(pObj, pJson); +} + +static const char* jkAggLogicPlanGroupKeys = "GroupKeys"; +static const char* jkAggLogicPlanAggFuncs = "AggFuncs"; + +static int32_t logicAggToJson(const void* pObj, SJson* pJson) { + const SAggLogicNode* pNode = (const SAggLogicNode*)pObj; + int32_t code = logicPlanNodeToJson(pObj, pJson); + if (TSDB_CODE_SUCCESS == code) { + code = addNodeList(pJson, jkAggLogicPlanGroupKeys, nodeToJson, pNode->pGroupKeys); + } + if (TSDB_CODE_SUCCESS == code) { + code = addNodeList(pJson, jkAggLogicPlanAggFuncs, nodeToJson, pNode->pAggFuncs); + } + + return code; +} + +static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { + switch (nodeType(pObj)) { + case QUERY_NODE_COLUMN: + case QUERY_NODE_VALUE: + case QUERY_NODE_OPERATOR: + case QUERY_NODE_LOGIC_CONDITION: + case QUERY_NODE_FUNCTION: + case QUERY_NODE_REAL_TABLE: + case QUERY_NODE_TEMP_TABLE: + case QUERY_NODE_JOIN_TABLE: + case QUERY_NODE_GROUPING_SET: + case QUERY_NODE_ORDER_BY_EXPR: + case QUERY_NODE_LIMIT: + case QUERY_NODE_STATE_WINDOW: + case QUERY_NODE_SESSION_WINDOW: + case QUERY_NODE_INTERVAL_WINDOW: + case QUERY_NODE_NODE_LIST: + case QUERY_NODE_FILL: + case QUERY_NODE_COLUMN_REF: + case QUERY_NODE_TARGET: + case QUERY_NODE_RAW_EXPR: + case QUERY_NODE_SET_OPERATOR: + case QUERY_NODE_SELECT_STMT: + case QUERY_NODE_SHOW_STMT: + break; + case QUERY_NODE_LOGIC_PLAN_SCAN: + return logicScanToJson(pObj, pJson); + case QUERY_NODE_LOGIC_PLAN_JOIN: + return logicJoinToJson(pObj, pJson); + case QUERY_NODE_LOGIC_PLAN_FILTER: + return logicFilterToJson(pObj, pJson); + case QUERY_NODE_LOGIC_PLAN_AGG: + return logicAggToJson(pObj, pJson); + case QUERY_NODE_LOGIC_PLAN_PROJECT: + return logicProjectToJson(pObj, pJson); + default: + break; + } + return TSDB_CODE_SUCCESS; +} + +static const char* jkNodeType = "Type"; +static int32_t nodeToJson(const void* pObj, SJson* pJson) { + const SNode* pNode = (const SNode*)pObj; + + char* pNodeName = nodeName(nodeType(pNode)); + int32_t code = tjsonAddStringToObject(pJson, jkNodeType, pNodeName); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, pNodeName, specificNodeToJson, pNode); + } + + return code; +} + +int32_t nodesNodeToString(const SNode* pNode, char** pStr, int32_t* pLen) { + if (NULL == pNode || NULL == pStr || NULL == pLen) { + return TSDB_CODE_SUCCESS; + } + + SJson* pJson = tjsonCreateObject(); + if (NULL == pJson) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; + } + + int32_t code = nodeToJson(pNode, pJson); + if (TSDB_CODE_SUCCESS != code) { + terrno = code; + return code; + } + + *pStr = tjsonToString(pJson); + tjsonDelete(pJson); + + *pLen = strlen(*pStr) + 1; + return TSDB_CODE_SUCCESS; +} + +int32_t nodesStringToNode(const char* pStr, SNode** pNode) { + return TSDB_CODE_SUCCESS; } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 50ddd14bf5f718c22caa4682282575490f51a6fb..868af93c92bf26ce3afc727c143efd4fe90987e3 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -14,7 +14,7 @@ */ #include "querynodes.h" -#include "nodesShowStmts.h" +#include "plannodes.h" #include "taos.h" #include "taoserror.h" #include "thash.h" @@ -68,8 +68,18 @@ SNode* nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SSetOperator)); case QUERY_NODE_SELECT_STMT: return makeNode(type, sizeof(SSelectStmt)); - case QUERY_NODE_SHOW_STMT: - return makeNode(type, sizeof(SShowStmt)); + // case QUERY_NODE_SHOW_STMT: + // return makeNode(type, sizeof(SShowStmt)); + case QUERY_NODE_LOGIC_PLAN_SCAN: + return makeNode(type, sizeof(SScanLogicNode)); + case QUERY_NODE_LOGIC_PLAN_JOIN: + return makeNode(type, sizeof(SJoinLogicNode)); + case QUERY_NODE_LOGIC_PLAN_FILTER: + return makeNode(type, sizeof(SFilterLogicNode)); + case QUERY_NODE_LOGIC_PLAN_AGG: + return makeNode(type, sizeof(SAggLogicNode)); + case QUERY_NODE_LOGIC_PLAN_PROJECT: + return makeNode(type, sizeof(SProjectLogicNode)); default: break; } @@ -121,6 +131,15 @@ int32_t nodesListAppend(SNodeList* pList, SNode* pNode) { return TSDB_CODE_SUCCESS; } +int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc) { + pTarget->pTail->pNext = pSrc->pHead; + pSrc->pHead->pPrev = pTarget->pTail; + pTarget->pTail = pSrc->pTail; + pTarget->length += pSrc->length; + tfree(pSrc); + return TSDB_CODE_SUCCESS; +} + SListCell* nodesListErase(SNodeList* pList, SListCell* pCell) { if (NULL == pCell->pPrev) { pList->pHead = pCell->pNext; @@ -129,6 +148,7 @@ SListCell* nodesListErase(SNodeList* pList, SListCell* pCell) { pCell->pNext->pPrev = pCell->pPrev; } SListCell* pNext = pCell->pNext; + nodesDestroyNode(pCell->pNode); tfree(pCell); --(pList->length); return pNext; @@ -185,6 +205,14 @@ bool nodesIsComparisonOp(const SOperatorNode* pOp) { case OP_TYPE_NOT_LIKE: case OP_TYPE_MATCH: case OP_TYPE_NMATCH: + case OP_TYPE_IS_NULL: + case OP_TYPE_IS_NOT_NULL: + case OP_TYPE_IS_TRUE: + case OP_TYPE_IS_FALSE: + case OP_TYPE_IS_UNKNOWN: + case OP_TYPE_IS_NOT_TRUE: + case OP_TYPE_IS_NOT_FALSE: + case OP_TYPE_IS_NOT_UNKNOWN: return true; default: break; @@ -213,8 +241,7 @@ bool nodesIsTimelineQuery(const SNode* pQuery) { typedef struct SCollectColumnsCxt { int32_t errCode; - uint64_t tableId; - bool realCol; + const char* pTableAlias; SNodeList* pCols; SHashObj* pColIdHash; } SCollectColumnsCxt; @@ -232,27 +259,24 @@ static EDealRes doCollect(SCollectColumnsCxt* pCxt, int32_t id, SNode* pNode) { static EDealRes collectColumns(SNode* pNode, void* pContext) { SCollectColumnsCxt* pCxt = (SCollectColumnsCxt*)pContext; - - if (pCxt->realCol && QUERY_NODE_COLUMN == nodeType(pNode)) { + if (QUERY_NODE_COLUMN == nodeType(pNode)) { SColumnNode* pCol = (SColumnNode*)pNode; int32_t colId = pCol->colId; - if (pCxt->tableId == pCol->tableId && colId > 0) { + if (0 == strcmp(pCxt->pTableAlias, pCol->tableAlias)) { return doCollect(pCxt, colId, pNode); } - } else if (!pCxt->realCol && QUERY_NODE_COLUMN_REF == nodeType(pNode)) { - return doCollect(pCxt, ((SColumnRefNode*)pNode)->slotId, pNode); } return DEAL_RES_CONTINUE; } -int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, uint64_t tableId, bool realCol, SNodeList** pCols) { +int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char* pTableAlias, SNodeList** pCols) { if (NULL == pSelect || NULL == pCols) { return TSDB_CODE_SUCCESS; } SCollectColumnsCxt cxt = { .errCode = TSDB_CODE_SUCCESS, - .realCol = realCol, + .pTableAlias = pTableAlias, .pCols = nodesMakeList(), .pColIdHash = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK) }; @@ -303,6 +327,12 @@ int32_t nodesCollectFuncs(SSelectStmt* pSelect, FFuncClassifier classifier, SNod nodesDestroyList(cxt.pFuncs); return cxt.errCode; } - *pFuncs = cxt.pFuncs; + if (LIST_LENGTH(cxt.pFuncs) > 0) { + *pFuncs = cxt.pFuncs; + } else { + nodesDestroyList(cxt.pFuncs); + *pFuncs = NULL; + } + return TSDB_CODE_SUCCESS; } diff --git a/source/libs/parser/inc/astGenerator.h b/source/libs/parser/inc/astGenerator.h index c601c4e3e35a82e6248cc4f24a001dfb2bfb1a56..1327259a51b793d152fc7dffc123c55459fe3b26 100644 --- a/source/libs/parser/inc/astGenerator.h +++ b/source/libs/parser/inc/astGenerator.h @@ -170,6 +170,7 @@ typedef struct SCreateDbInfo { int8_t update; int8_t cachelast; SArray *keep; + int8_t streamMode; } SCreateDbInfo; typedef struct SCreateFuncInfo { diff --git a/source/libs/parser/inc/parserImpl.h b/source/libs/parser/inc/parserImpl.h index 4f6f0cf3875f9097ea05e87dbffd98051157b7f6..f2777a236881a94a3b3f68395118b5e63e60bb84 100644 --- a/source/libs/parser/inc/parserImpl.h +++ b/source/libs/parser/inc/parserImpl.h @@ -13,27 +13,15 @@ * along with this program. If not, see . */ -#ifndef _TD_AST_CREATE_FUNCS_H_ -#define _TD_AST_CREATE_FUNCS_H_ +#ifndef _TD_PARSER_IMPL_H_ +#define _TD_PARSER_IMPL_H_ #ifdef __cplusplus extern "C" { #endif #include "querynodes.h" -#include "parser.h" - -typedef enum EStmtType { - STMT_TYPE_CMD = 1, - STMT_TYPE_QUERY -} EStmtType; - -typedef struct SQuery { - EStmtType stmtType; - SNode* pRoot; - int32_t numOfResCols; - SSchema* pResSchema; -} SQuery; +#include "newParser.h" int32_t doParse(SParseContext* pParseCxt, SQuery* pQuery); int32_t doTranslate(SParseContext* pParseCxt, SQuery* pQuery); @@ -42,4 +30,4 @@ int32_t doTranslate(SParseContext* pParseCxt, SQuery* pQuery); } #endif -#endif /*_TD_AST_CREATE_FUNCS_H_*/ +#endif /*_TD_PARSER_IMPL_H_*/ diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 06154ca19240d776a98eb6c9703e91f142433d8d..242f659288880de268d3f4edb8b10375ff50527e 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -282,6 +282,7 @@ update(Y) ::= UPDATE INTEGER(X). { Y = X; } cachelast(Y) ::= CACHELAST INTEGER(X). { Y = X; } vgroups(Y) ::= VGROUPS INTEGER(X). { Y = X; } //partitions(Y) ::= PARTITIONS INTEGER(X). { Y = X; } +stream_mode(Y) ::= STREAM MODE INTEGER(X). { Y = X; } %type db_optr {SCreateDbInfo} db_optr(Y) ::= . {setDefaultCreateDbOption(&Y);} @@ -302,6 +303,7 @@ db_optr(Y) ::= db_optr(Z) keep(X). { Y = Z; Y.keep = X; } db_optr(Y) ::= db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); } db_optr(Y) ::= db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); } db_optr(Y) ::= db_optr(Z) vgroups(X). { Y = Z; Y.numOfVgroups = strtol(X.z, NULL, 10); } +db_optr(Y) ::= db_optr(Z) stream_mode(X). { Y = Z; Y.streamMode = strtol(X.z, NULL, 10); } //%type topic_optr {SCreateDbInfo} // diff --git a/source/libs/parser/src/astToMsg.c b/source/libs/parser/src/astToMsg.c index 0b4867de0381611572761bb96f73425be7c17e4f..963255527aeb5ade62c3de797404d9c9f6d005ce 100644 --- a/source/libs/parser/src/astToMsg.c +++ b/source/libs/parser/src/astToMsg.c @@ -242,6 +242,7 @@ static void doSetDbOptions(SCreateDbReq* pMsg, const SCreateDbInfo* pCreateDb) { pMsg->update = pCreateDb->update; pMsg->cacheLastRow = pCreateDb->cachelast; pMsg->numOfVgroups = pCreateDb->numOfVgroups; + pMsg->streamMode = pCreateDb->streamMode; } int32_t setDbOptions(SCreateDbReq* pCreateDbMsg, const SCreateDbInfo* pCreateDbSql, SMsgBuf* pMsgBuf) { diff --git a/source/libs/parser/src/parserImpl.c b/source/libs/parser/src/parserImpl.c index ec53f266bf76ba4fb6dba74a8fcd1170f536e236..d353c245cb61c9d3529e6e695c60f21087f256f5 100644 --- a/source/libs/parser/src/parserImpl.c +++ b/source/libs/parser/src/parserImpl.c @@ -349,14 +349,15 @@ static SNodeList* getProjectList(SNode* pNode) { return NULL; } -static void setColumnInfoBySchema(const STableNode* pTable, const SSchema* pColSchema, SColumnNode* pCol) { - strcpy(pCol->dbName, pTable->dbName); - strcpy(pCol->tableAlias, pTable->tableAlias); - strcpy(pCol->tableName, pTable->tableName); +static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* pColSchema, SColumnNode* pCol) { + strcpy(pCol->dbName, pTable->table.dbName); + strcpy(pCol->tableAlias, pTable->table.tableAlias); + strcpy(pCol->tableName, pTable->table.tableName); strcpy(pCol->colName, pColSchema->name); if ('\0' == pCol->node.aliasName[0]) { strcpy(pCol->node.aliasName, pColSchema->name); } + pCol->tableId = pTable->pMeta->uid; pCol->colId = pColSchema->colId; // pCol->colType = pColSchema->type; pCol->node.resType.type = pColSchema->type; @@ -382,7 +383,7 @@ static int32_t createColumnNodeByTable(STranslateContext* pCxt, const STableNode if (NULL == pCol) { return generateSyntaxErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY); } - setColumnInfoBySchema(pTable, pMeta->schema + i, pCol); + setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema + i, pCol); nodesListAppend(pList, (SNode*)pCol); } } else { @@ -407,7 +408,7 @@ static bool findAndSetColumn(SColumnNode* pCol, const STableNode* pTable) { int32_t nums = pMeta->tableInfo.numOfTags + pMeta->tableInfo.numOfColumns; for (int32_t i = 0; i < nums; ++i) { if (0 == strcmp(pCol->colName, pMeta->schema[i].name)) { - setColumnInfoBySchema(pTable, pMeta->schema + i, pCol); + setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema + i, pCol); found = true; break; } @@ -879,7 +880,6 @@ static int32_t translateOrderByPosition(STranslateContext* pCxt, SNodeList* pPro int32_t pos = getPositionValue(pVal); if (pos < 0) { ERASE_NODE(pOrderByList); - nodesDestroyNode(pNode); continue; } else if (0 == pos || pos > LIST_LENGTH(pProjectionList)) { return generateSyntaxErrMsg(pCxt, TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT); @@ -1057,3 +1057,11 @@ int32_t doTranslate(SParseContext* pParseCxt, SQuery* pQuery) { } return code; } + +int32_t parser(SParseContext* pParseCxt, SQuery* pQuery) { + int32_t code = doParse(pParseCxt, pQuery); + if (TSDB_CODE_SUCCESS == code) { + code = doTranslate(pParseCxt, pQuery); + } + return code; +} diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index f6585e41fffd79b62d7d332480f0bf5221d44137..ed96737837165ac8c306830d768dc012c5b04431 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -23,6 +23,7 @@ ** input grammar file: */ #include +#include /************ Begin %include sections from the grammar ************************/ #include @@ -76,8 +77,10 @@ ** zero the stack is dynamically sized using realloc() ** ParseARG_SDECL A static variable declaration for the %extra_argument ** ParseARG_PDECL A parameter declaration for the %extra_argument +** ParseARG_PARAM Code to pass %extra_argument as a subroutine parameter ** ParseARG_STORE Code to store %extra_argument into yypParser ** ParseARG_FETCH Code to extract %extra_argument from yypParser +** ParseCTX_* As ParseARG_ except for %extra_context ** YYERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. ** YYNSTATE the combined number of states. @@ -103,45 +106,52 @@ typedef union { int yyinit; ParseTOKENTYPE yy0; - SWindowStateVal yy6; - SRelationInfo* yy10; - SCreateDbInfo yy16; - int32_t yy46; - int yy47; - SSessionWindowVal yy97; - SField yy106; - SCreatedTableInfo yy150; - SArray* yy165; - tSqlExpr* yy202; - int64_t yy207; - SCreateAcctInfo yy211; - SSqlNode* yy278; - SCreateTableSql* yy326; - SLimit yy367; - SVariant yy425; - SSubclause* yy503; - SIntervalVal yy532; + SVariant yy1; + SField yy16; + int yy40; + SIntervalVal yy52; + int64_t yy61; + SSubclause* yy93; + SWindowStateVal yy112; + SRelationInfo* yy160; + SCreatedTableInfo yy184; + SSqlNode* yy185; + SArray* yy225; + tSqlExpr* yy226; + SCreateDbInfo yy326; + int32_t yy460; + SSessionWindowVal yy463; + SCreateTableSql* yy482; + SLimit yy495; + SCreateAcctInfo yy523; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 #endif #define ParseARG_SDECL SSqlInfo* pInfo; #define ParseARG_PDECL ,SSqlInfo* pInfo -#define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo -#define ParseARG_STORE yypParser->pInfo = pInfo +#define ParseARG_PARAM ,pInfo +#define ParseARG_FETCH SSqlInfo* pInfo=yypParser->pInfo; +#define ParseARG_STORE yypParser->pInfo=pInfo; +#define ParseCTX_SDECL +#define ParseCTX_PDECL +#define ParseCTX_PARAM +#define ParseCTX_FETCH +#define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 366 -#define YYNRULE 302 -#define YYNTOKEN 191 -#define YY_MAX_SHIFT 365 -#define YY_MIN_SHIFTREDUCE 586 -#define YY_MAX_SHIFTREDUCE 887 -#define YY_ERROR_ACTION 888 -#define YY_ACCEPT_ACTION 889 -#define YY_NO_ACTION 890 -#define YY_MIN_REDUCE 891 -#define YY_MAX_REDUCE 1192 +#define YYNSTATE 368 +#define YYNRULE 304 +#define YYNTOKEN 192 +#define YY_MAX_SHIFT 367 +#define YY_MIN_SHIFTREDUCE 590 +#define YY_MAX_SHIFTREDUCE 893 +#define YY_ERROR_ACTION 894 +#define YY_ACCEPT_ACTION 895 +#define YY_NO_ACTION 896 +#define YY_MIN_REDUCE 897 +#define YY_MAX_REDUCE 1200 /************* End control #defines *******************************************/ +#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) /* Define the yytestcase() macro to be a no-op if is not already defined ** otherwise. @@ -206,292 +216,294 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (777) +#define YY_ACTTAB_COUNT (781) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 249, 637, 637, 1077, 83, 717, 248, 55, 56, 88, - /* 10 */ 59, 60, 364, 230, 252, 49, 48, 47, 78, 58, - /* 20 */ 323, 63, 61, 64, 62, 236, 1054, 889, 365, 54, - /* 30 */ 53, 343, 342, 52, 51, 50, 253, 55, 56, 242, - /* 40 */ 59, 60, 1027, 1042, 252, 49, 48, 47, 104, 58, - /* 50 */ 323, 63, 61, 64, 62, 1014, 637, 1012, 1013, 54, - /* 60 */ 53, 206, 1015, 52, 51, 50, 1016, 206, 1017, 1018, - /* 70 */ 121, 1074, 1169, 55, 56, 1067, 59, 60, 1169, 27, - /* 80 */ 252, 49, 48, 47, 89, 58, 323, 63, 61, 64, - /* 90 */ 62, 206, 39, 274, 246, 54, 53, 206, 1042, 52, - /* 100 */ 51, 50, 1168, 55, 57, 1030, 59, 60, 1169, 824, - /* 110 */ 252, 49, 48, 47, 80, 58, 323, 63, 61, 64, - /* 120 */ 62, 294, 637, 81, 159, 54, 53, 91, 319, 52, - /* 130 */ 51, 50, 104, 1067, 56, 232, 59, 60, 353, 1039, - /* 140 */ 252, 49, 48, 47, 261, 58, 323, 63, 61, 64, - /* 150 */ 62, 233, 43, 124, 79, 54, 53, 80, 39, 52, - /* 160 */ 51, 50, 587, 588, 589, 590, 591, 592, 593, 594, - /* 170 */ 595, 596, 597, 598, 599, 600, 199, 309, 231, 59, - /* 180 */ 60, 939, 1067, 252, 49, 48, 47, 158, 58, 323, - /* 190 */ 63, 61, 64, 62, 353, 43, 280, 279, 54, 53, - /* 200 */ 234, 240, 52, 51, 50, 1039, 14, 1116, 13, 292, - /* 210 */ 42, 317, 359, 358, 316, 315, 314, 357, 313, 312, - /* 220 */ 311, 356, 310, 355, 354, 1007, 995, 996, 997, 998, - /* 230 */ 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1008, 1009, - /* 240 */ 1010, 266, 12, 22, 63, 61, 64, 62, 84, 21, - /* 250 */ 270, 269, 54, 53, 789, 790, 52, 51, 50, 946, - /* 260 */ 215, 113, 251, 839, 828, 831, 834, 216, 753, 750, - /* 270 */ 751, 752, 672, 175, 174, 172, 217, 119, 261, 282, - /* 280 */ 328, 80, 251, 839, 828, 831, 834, 127, 116, 203, - /* 290 */ 228, 229, 255, 39, 324, 257, 258, 745, 742, 743, - /* 300 */ 744, 204, 39, 1036, 3, 32, 131, 261, 209, 260, - /* 310 */ 228, 229, 129, 85, 123, 133, 1040, 39, 39, 43, - /* 320 */ 1025, 1026, 30, 1029, 244, 245, 189, 186, 183, 52, - /* 330 */ 51, 50, 305, 181, 179, 178, 177, 176, 319, 65, - /* 340 */ 1038, 273, 637, 86, 42, 241, 359, 358, 243, 1039, - /* 350 */ 224, 357, 770, 830, 833, 356, 39, 355, 354, 65, - /* 360 */ 332, 333, 54, 53, 1039, 1039, 52, 51, 50, 256, - /* 370 */ 39, 254, 39, 331, 330, 840, 835, 104, 39, 39, - /* 380 */ 754, 755, 836, 149, 142, 162, 262, 39, 259, 806, - /* 390 */ 338, 337, 167, 170, 160, 840, 835, 829, 832, 334, - /* 400 */ 104, 164, 836, 1039, 826, 363, 362, 190, 767, 746, - /* 410 */ 747, 92, 949, 335, 940, 339, 93, 1039, 158, 1039, - /* 420 */ 158, 340, 341, 71, 321, 1039, 1039, 198, 195, 193, - /* 430 */ 345, 360, 976, 7, 1039, 275, 827, 786, 774, 796, - /* 440 */ 797, 74, 727, 297, 729, 299, 325, 805, 35, 70, - /* 450 */ 210, 40, 1115, 97, 70, 66, 24, 728, 40, 40, - /* 460 */ 67, 117, 740, 741, 72, 738, 739, 862, 841, 250, - /* 470 */ 636, 837, 140, 67, 139, 82, 16, 18, 15, 17, - /* 480 */ 75, 211, 300, 23, 23, 77, 23, 758, 759, 169, - /* 490 */ 168, 4, 756, 757, 147, 20, 146, 19, 1163, 1162, - /* 500 */ 1161, 226, 227, 207, 208, 212, 1053, 1041, 205, 1126, - /* 510 */ 213, 214, 219, 220, 221, 838, 218, 202, 716, 1188, - /* 520 */ 1180, 1125, 1069, 238, 1122, 1121, 239, 44, 1068, 344, - /* 530 */ 277, 114, 322, 1108, 1107, 196, 271, 785, 1037, 276, - /* 540 */ 1065, 87, 1076, 1087, 281, 235, 73, 90, 1084, 1085, - /* 550 */ 76, 843, 283, 1089, 295, 46, 105, 106, 94, 107, - /* 560 */ 293, 95, 101, 108, 285, 291, 288, 286, 109, 1109, - /* 570 */ 289, 110, 287, 111, 284, 112, 29, 45, 225, 115, - /* 580 */ 1035, 306, 150, 247, 118, 952, 346, 120, 301, 953, - /* 590 */ 302, 303, 304, 974, 307, 308, 200, 347, 348, 38, - /* 600 */ 320, 349, 948, 951, 947, 130, 329, 350, 1187, 351, - /* 610 */ 352, 361, 137, 1186, 1183, 887, 141, 222, 336, 1179, - /* 620 */ 152, 144, 1178, 265, 1175, 886, 148, 223, 973, 268, - /* 630 */ 885, 868, 867, 70, 296, 8, 28, 41, 31, 761, - /* 640 */ 278, 96, 153, 201, 937, 151, 154, 156, 157, 155, - /* 650 */ 163, 935, 165, 1, 166, 933, 264, 932, 263, 171, - /* 660 */ 267, 975, 931, 930, 173, 929, 928, 927, 926, 925, - /* 670 */ 924, 272, 923, 787, 180, 184, 98, 182, 922, 798, - /* 680 */ 185, 921, 99, 188, 187, 920, 918, 792, 100, 916, - /* 690 */ 914, 102, 194, 913, 911, 912, 197, 907, 794, 2, - /* 700 */ 237, 103, 290, 9, 33, 34, 10, 11, 25, 298, - /* 710 */ 26, 122, 119, 36, 126, 125, 650, 688, 37, 128, - /* 720 */ 685, 683, 682, 681, 679, 678, 677, 674, 640, 132, - /* 730 */ 5, 134, 135, 842, 318, 844, 6, 326, 327, 68, - /* 740 */ 136, 40, 69, 719, 718, 138, 143, 145, 715, 666, - /* 750 */ 664, 656, 662, 658, 660, 654, 652, 687, 686, 684, - /* 760 */ 680, 676, 675, 161, 604, 638, 891, 890, 890, 890, - /* 770 */ 890, 890, 890, 890, 890, 191, 192, + /* 0 */ 91, 641, 242, 1085, 676, 249, 1050, 55, 56, 641, + /* 10 */ 59, 60, 895, 367, 252, 49, 48, 47, 1075, 58, + /* 20 */ 325, 63, 61, 64, 62, 641, 641, 366, 230, 54, + /* 30 */ 53, 206, 248, 52, 51, 50, 233, 55, 56, 246, + /* 40 */ 59, 60, 1176, 1050, 252, 49, 48, 47, 104, 58, + /* 50 */ 325, 63, 61, 64, 62, 1022, 21, 1020, 1021, 54, + /* 60 */ 53, 1075, 1023, 52, 51, 50, 1024, 206, 1025, 1026, + /* 70 */ 280, 279, 1082, 55, 56, 1044, 59, 60, 1177, 274, + /* 80 */ 252, 49, 48, 47, 89, 58, 325, 63, 61, 64, + /* 90 */ 62, 39, 236, 1062, 206, 54, 53, 362, 982, 52, + /* 100 */ 51, 50, 27, 55, 57, 1177, 59, 60, 323, 830, + /* 110 */ 252, 49, 48, 47, 1075, 58, 325, 63, 61, 64, + /* 120 */ 62, 243, 294, 80, 81, 54, 53, 795, 796, 52, + /* 130 */ 51, 50, 234, 116, 56, 232, 59, 60, 311, 1047, + /* 140 */ 252, 49, 48, 47, 104, 58, 325, 63, 61, 64, + /* 150 */ 62, 42, 776, 361, 360, 54, 53, 952, 359, 52, + /* 160 */ 51, 50, 358, 43, 357, 356, 1033, 1034, 30, 1037, + /* 170 */ 253, 42, 319, 361, 360, 318, 317, 316, 359, 315, + /* 180 */ 314, 313, 358, 312, 357, 356, 310, 1014, 1002, 1003, + /* 190 */ 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, + /* 200 */ 1015, 1016, 1017, 1018, 641, 59, 60, 159, 773, 252, + /* 210 */ 49, 48, 47, 113, 58, 325, 63, 61, 64, 62, + /* 220 */ 1124, 355, 292, 355, 54, 53, 836, 839, 52, 51, + /* 230 */ 50, 282, 206, 54, 53, 7, 321, 52, 51, 50, + /* 240 */ 780, 723, 22, 1177, 591, 592, 593, 594, 595, 596, + /* 250 */ 597, 598, 599, 600, 601, 602, 603, 604, 199, 215, + /* 260 */ 231, 251, 845, 834, 837, 840, 216, 345, 344, 198, + /* 270 */ 195, 193, 175, 174, 172, 217, 80, 321, 83, 330, + /* 280 */ 80, 251, 845, 834, 837, 840, 52, 51, 50, 228, + /* 290 */ 229, 121, 78, 326, 63, 61, 64, 62, 759, 756, + /* 300 */ 757, 758, 54, 53, 835, 838, 52, 51, 50, 228, + /* 310 */ 229, 255, 751, 748, 749, 750, 43, 1061, 79, 203, + /* 320 */ 43, 3, 32, 131, 39, 257, 258, 1038, 104, 129, + /* 330 */ 85, 123, 133, 104, 39, 945, 39, 39, 65, 244, + /* 340 */ 245, 158, 273, 39, 86, 39, 843, 746, 747, 305, + /* 350 */ 260, 224, 189, 186, 183, 149, 142, 162, 65, 181, + /* 360 */ 179, 178, 177, 176, 167, 170, 160, 39, 240, 269, + /* 370 */ 39, 88, 1047, 164, 204, 39, 846, 841, 241, 209, + /* 380 */ 334, 335, 1047, 842, 1047, 1047, 812, 336, 39, 337, + /* 390 */ 256, 1047, 254, 1047, 333, 332, 846, 841, 327, 266, + /* 400 */ 12, 261, 39, 842, 1123, 1035, 84, 261, 270, 82, + /* 410 */ 124, 341, 760, 761, 342, 1047, 127, 92, 1047, 343, + /* 420 */ 365, 364, 190, 1047, 844, 93, 752, 753, 71, 262, + /* 430 */ 35, 259, 347, 340, 339, 275, 1047, 119, 955, 261, + /* 440 */ 792, 946, 802, 803, 158, 74, 811, 158, 1048, 832, + /* 450 */ 1046, 40, 733, 297, 744, 745, 97, 70, 66, 24, + /* 460 */ 735, 299, 734, 868, 847, 70, 300, 250, 40, 40, + /* 470 */ 1049, 72, 640, 14, 77, 13, 67, 117, 67, 23, + /* 480 */ 23, 833, 210, 140, 211, 139, 75, 1171, 23, 4, + /* 490 */ 1170, 16, 18, 15, 17, 764, 765, 762, 763, 147, + /* 500 */ 1134, 146, 20, 1169, 19, 849, 169, 168, 226, 722, + /* 510 */ 227, 207, 208, 212, 205, 1196, 213, 214, 219, 220, + /* 520 */ 1188, 221, 1077, 218, 202, 1133, 238, 44, 1130, 1076, + /* 530 */ 277, 1129, 239, 346, 114, 1116, 1115, 324, 196, 271, + /* 540 */ 791, 76, 281, 1045, 235, 276, 73, 87, 1084, 283, + /* 550 */ 285, 1095, 295, 46, 293, 291, 90, 108, 94, 1092, + /* 560 */ 1093, 1097, 95, 1073, 101, 286, 288, 1117, 105, 106, + /* 570 */ 107, 109, 289, 110, 111, 287, 284, 112, 45, 29, + /* 580 */ 306, 115, 225, 958, 1043, 150, 118, 247, 980, 120, + /* 590 */ 301, 959, 302, 303, 304, 348, 307, 308, 200, 349, + /* 600 */ 151, 38, 322, 350, 954, 957, 130, 953, 331, 1195, + /* 610 */ 137, 351, 1194, 352, 1191, 353, 354, 363, 141, 222, + /* 620 */ 338, 223, 1187, 144, 1186, 1183, 893, 148, 979, 265, + /* 630 */ 264, 892, 268, 891, 874, 873, 41, 31, 8, 70, + /* 640 */ 201, 28, 296, 153, 157, 272, 152, 154, 155, 943, + /* 650 */ 156, 163, 941, 165, 166, 939, 938, 263, 1, 981, + /* 660 */ 937, 171, 936, 173, 935, 934, 933, 932, 931, 930, + /* 670 */ 767, 929, 267, 180, 278, 182, 928, 184, 185, 187, + /* 680 */ 927, 926, 924, 188, 922, 919, 793, 96, 98, 920, + /* 690 */ 194, 917, 804, 197, 918, 913, 99, 100, 2, 798, + /* 700 */ 102, 237, 9, 800, 33, 103, 34, 10, 298, 290, + /* 710 */ 11, 25, 26, 119, 122, 126, 654, 693, 309, 692, + /* 720 */ 36, 125, 689, 37, 687, 128, 686, 685, 683, 682, + /* 730 */ 681, 678, 644, 132, 134, 135, 5, 850, 320, 848, + /* 740 */ 6, 329, 328, 68, 69, 136, 138, 143, 725, 40, + /* 750 */ 145, 724, 721, 670, 668, 660, 666, 662, 664, 658, + /* 760 */ 656, 691, 690, 688, 684, 680, 679, 161, 642, 897, + /* 770 */ 896, 608, 896, 896, 896, 896, 896, 896, 896, 191, + /* 780 */ 192, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 200, 1, 1, 194, 245, 3, 200, 7, 8, 201, - /* 10 */ 10, 11, 194, 195, 14, 15, 16, 17, 259, 19, - /* 20 */ 20, 21, 22, 23, 24, 243, 244, 192, 193, 29, - /* 30 */ 30, 29, 30, 33, 34, 35, 200, 7, 8, 238, - /* 40 */ 10, 11, 234, 242, 14, 15, 16, 17, 194, 19, - /* 50 */ 20, 21, 22, 23, 24, 216, 1, 218, 219, 29, - /* 60 */ 30, 261, 223, 33, 34, 35, 227, 261, 229, 230, - /* 70 */ 201, 262, 272, 7, 8, 240, 10, 11, 272, 78, + /* 0 */ 194, 1, 239, 194, 3, 200, 243, 7, 8, 1, + /* 10 */ 10, 11, 192, 193, 14, 15, 16, 17, 241, 19, + /* 20 */ 20, 21, 22, 23, 24, 1, 1, 194, 195, 29, + /* 30 */ 30, 262, 200, 33, 34, 35, 259, 7, 8, 239, + /* 40 */ 10, 11, 273, 243, 14, 15, 16, 17, 194, 19, + /* 50 */ 20, 21, 22, 23, 24, 216, 262, 218, 219, 29, + /* 60 */ 30, 241, 223, 33, 34, 35, 227, 262, 229, 230, + /* 70 */ 264, 265, 263, 7, 8, 194, 10, 11, 273, 259, /* 80 */ 14, 15, 16, 17, 84, 19, 20, 21, 22, 23, - /* 90 */ 24, 261, 194, 258, 238, 29, 30, 261, 242, 33, - /* 100 */ 34, 35, 272, 7, 8, 236, 10, 11, 272, 79, - /* 110 */ 14, 15, 16, 17, 78, 19, 20, 21, 22, 23, - /* 120 */ 24, 267, 1, 269, 74, 29, 30, 194, 80, 33, - /* 130 */ 34, 35, 194, 240, 8, 237, 10, 11, 88, 241, + /* 90 */ 24, 194, 244, 245, 262, 29, 30, 214, 215, 33, + /* 100 */ 34, 35, 78, 7, 8, 273, 10, 11, 83, 79, + /* 110 */ 14, 15, 16, 17, 241, 19, 20, 21, 22, 23, + /* 120 */ 24, 240, 268, 78, 270, 29, 30, 124, 125, 33, + /* 130 */ 34, 35, 259, 201, 8, 238, 10, 11, 63, 242, /* 140 */ 14, 15, 16, 17, 194, 19, 20, 21, 22, 23, - /* 150 */ 24, 258, 116, 203, 118, 29, 30, 78, 194, 33, - /* 160 */ 34, 35, 41, 42, 43, 44, 45, 46, 47, 48, - /* 170 */ 49, 50, 51, 52, 53, 54, 55, 63, 57, 10, - /* 180 */ 11, 199, 240, 14, 15, 16, 17, 205, 19, 20, - /* 190 */ 21, 22, 23, 24, 88, 116, 263, 264, 29, 30, - /* 200 */ 258, 237, 33, 34, 35, 241, 142, 269, 144, 271, - /* 210 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, - /* 220 */ 106, 107, 108, 109, 110, 216, 217, 218, 219, 220, - /* 230 */ 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, - /* 240 */ 231, 139, 78, 40, 21, 22, 23, 24, 84, 261, - /* 250 */ 148, 149, 29, 30, 122, 123, 33, 34, 35, 1, - /* 260 */ 57, 248, 1, 2, 3, 4, 5, 64, 2, 3, - /* 270 */ 4, 5, 3, 70, 71, 72, 73, 113, 194, 266, - /* 280 */ 77, 78, 1, 2, 3, 4, 5, 203, 201, 261, - /* 290 */ 29, 30, 64, 194, 33, 29, 30, 2, 3, 4, - /* 300 */ 5, 261, 194, 194, 58, 59, 60, 194, 261, 64, - /* 310 */ 29, 30, 66, 67, 68, 69, 203, 194, 194, 116, - /* 320 */ 233, 234, 235, 236, 29, 30, 58, 59, 60, 33, - /* 330 */ 34, 35, 86, 65, 66, 67, 68, 69, 80, 78, - /* 340 */ 241, 138, 1, 140, 96, 237, 98, 99, 239, 241, - /* 350 */ 147, 103, 33, 3, 4, 107, 194, 109, 110, 78, - /* 360 */ 237, 237, 29, 30, 241, 241, 33, 34, 35, 141, - /* 370 */ 194, 143, 194, 145, 146, 114, 115, 194, 194, 194, - /* 380 */ 114, 115, 121, 58, 59, 60, 141, 194, 143, 72, - /* 390 */ 145, 146, 67, 68, 69, 114, 115, 3, 4, 237, - /* 400 */ 194, 76, 121, 241, 1, 61, 62, 63, 95, 114, - /* 410 */ 115, 79, 199, 237, 199, 237, 79, 241, 205, 241, - /* 420 */ 205, 237, 237, 95, 83, 241, 241, 58, 59, 60, - /* 430 */ 237, 214, 215, 120, 241, 79, 33, 79, 119, 79, - /* 440 */ 79, 95, 79, 79, 79, 79, 9, 130, 78, 117, - /* 450 */ 261, 95, 269, 95, 117, 95, 95, 79, 95, 95, - /* 460 */ 95, 95, 3, 4, 136, 3, 4, 79, 79, 56, - /* 470 */ 79, 121, 142, 95, 144, 269, 142, 142, 144, 144, - /* 480 */ 134, 261, 112, 95, 95, 78, 95, 3, 4, 74, - /* 490 */ 75, 78, 3, 4, 142, 142, 144, 144, 261, 261, - /* 500 */ 261, 261, 261, 261, 261, 261, 244, 242, 261, 232, - /* 510 */ 261, 261, 261, 261, 261, 121, 261, 261, 111, 244, - /* 520 */ 244, 232, 240, 232, 232, 232, 232, 260, 240, 232, - /* 530 */ 240, 246, 194, 270, 270, 56, 194, 121, 240, 196, - /* 540 */ 257, 194, 194, 194, 265, 265, 135, 196, 194, 194, - /* 550 */ 133, 114, 265, 194, 128, 132, 256, 255, 196, 254, - /* 560 */ 131, 194, 194, 253, 265, 126, 194, 196, 252, 196, - /* 570 */ 125, 251, 124, 250, 127, 249, 247, 137, 196, 194, - /* 580 */ 194, 87, 94, 196, 194, 204, 93, 194, 196, 194, - /* 590 */ 194, 194, 194, 213, 194, 194, 194, 47, 90, 194, - /* 600 */ 194, 92, 194, 204, 194, 201, 194, 51, 194, 91, - /* 610 */ 89, 80, 194, 194, 194, 3, 194, 196, 194, 194, - /* 620 */ 211, 194, 194, 3, 194, 3, 194, 196, 194, 3, - /* 630 */ 3, 98, 97, 117, 112, 78, 78, 194, 194, 79, - /* 640 */ 95, 95, 207, 194, 194, 212, 210, 209, 206, 208, - /* 650 */ 194, 194, 194, 202, 194, 194, 150, 194, 194, 194, - /* 660 */ 150, 215, 196, 196, 194, 194, 194, 194, 194, 194, - /* 670 */ 194, 139, 194, 79, 197, 194, 78, 197, 196, 79, - /* 680 */ 197, 196, 78, 197, 194, 194, 194, 79, 95, 194, - /* 690 */ 194, 78, 194, 196, 194, 196, 194, 194, 79, 198, - /* 700 */ 1, 78, 78, 129, 95, 95, 129, 78, 78, 112, - /* 710 */ 78, 74, 113, 85, 66, 84, 3, 3, 85, 84, - /* 720 */ 5, 3, 3, 3, 3, 3, 3, 3, 81, 74, - /* 730 */ 78, 82, 82, 79, 9, 114, 78, 20, 55, 10, - /* 740 */ 144, 95, 10, 3, 3, 144, 144, 144, 79, 3, - /* 750 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 760 */ 3, 3, 3, 95, 56, 81, 0, 273, 273, 273, - /* 770 */ 273, 273, 273, 273, 273, 15, 15, 273, 273, 273, - /* 780 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 790 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 800 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 810 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 820 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 830 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 840 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 850 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 860 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 870 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 880 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 890 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 900 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 910 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 920 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 930 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 940 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 950 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, - /* 960 */ 273, 273, 273, 273, 273, 273, 273, 273, + /* 150 */ 24, 96, 33, 98, 99, 29, 30, 1, 103, 33, + /* 160 */ 34, 35, 107, 118, 109, 110, 234, 235, 236, 237, + /* 170 */ 200, 96, 97, 98, 99, 100, 101, 102, 103, 104, + /* 180 */ 105, 106, 107, 108, 109, 110, 111, 216, 217, 218, + /* 190 */ 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, + /* 200 */ 229, 230, 231, 232, 1, 10, 11, 74, 95, 14, + /* 210 */ 15, 16, 17, 249, 19, 20, 21, 22, 23, 24, + /* 220 */ 270, 88, 272, 88, 29, 30, 3, 4, 33, 34, + /* 230 */ 35, 267, 262, 29, 30, 122, 80, 33, 34, 35, + /* 240 */ 121, 3, 40, 273, 41, 42, 43, 44, 45, 46, + /* 250 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 57, + /* 260 */ 57, 1, 2, 3, 4, 5, 64, 29, 30, 58, + /* 270 */ 59, 60, 70, 71, 72, 73, 78, 80, 246, 77, + /* 280 */ 78, 1, 2, 3, 4, 5, 33, 34, 35, 29, + /* 290 */ 30, 201, 260, 33, 21, 22, 23, 24, 2, 3, + /* 300 */ 4, 5, 29, 30, 3, 4, 33, 34, 35, 29, + /* 310 */ 30, 64, 2, 3, 4, 5, 118, 245, 120, 262, + /* 320 */ 118, 58, 59, 60, 194, 29, 30, 237, 194, 66, + /* 330 */ 67, 68, 69, 194, 194, 199, 194, 194, 78, 29, + /* 340 */ 30, 205, 140, 194, 142, 194, 123, 3, 4, 86, + /* 350 */ 64, 149, 58, 59, 60, 58, 59, 60, 78, 65, + /* 360 */ 66, 67, 68, 69, 67, 68, 69, 194, 238, 111, + /* 370 */ 194, 201, 242, 76, 262, 194, 116, 117, 238, 262, + /* 380 */ 238, 238, 242, 123, 242, 242, 72, 238, 194, 238, + /* 390 */ 143, 242, 145, 242, 147, 148, 116, 117, 9, 141, + /* 400 */ 78, 194, 194, 123, 270, 235, 84, 194, 150, 270, + /* 410 */ 203, 238, 116, 117, 238, 242, 203, 79, 242, 238, + /* 420 */ 61, 62, 63, 242, 123, 79, 116, 117, 95, 143, + /* 430 */ 78, 145, 238, 147, 148, 79, 242, 115, 199, 194, + /* 440 */ 79, 199, 79, 79, 205, 95, 132, 205, 203, 1, + /* 450 */ 242, 95, 79, 79, 3, 4, 95, 119, 95, 95, + /* 460 */ 79, 79, 79, 79, 79, 119, 114, 56, 95, 95, + /* 470 */ 243, 138, 79, 144, 78, 146, 95, 95, 95, 95, + /* 480 */ 95, 33, 262, 144, 262, 146, 136, 262, 95, 78, + /* 490 */ 262, 144, 144, 146, 146, 3, 4, 3, 4, 144, + /* 500 */ 233, 146, 144, 262, 146, 116, 74, 75, 262, 113, + /* 510 */ 262, 262, 262, 262, 262, 245, 262, 262, 262, 262, + /* 520 */ 245, 262, 241, 262, 262, 233, 233, 261, 233, 241, + /* 530 */ 241, 233, 233, 233, 247, 271, 271, 194, 56, 194, + /* 540 */ 123, 135, 266, 241, 266, 196, 137, 194, 194, 266, + /* 550 */ 266, 194, 130, 134, 133, 128, 196, 254, 196, 194, + /* 560 */ 194, 194, 194, 258, 194, 196, 194, 196, 257, 256, + /* 570 */ 255, 253, 127, 252, 251, 126, 129, 250, 139, 248, + /* 580 */ 87, 194, 196, 204, 194, 94, 194, 196, 213, 194, + /* 590 */ 196, 194, 194, 194, 194, 93, 194, 194, 194, 47, + /* 600 */ 212, 194, 194, 90, 194, 204, 201, 194, 194, 194, + /* 610 */ 194, 92, 194, 51, 194, 91, 89, 80, 194, 196, + /* 620 */ 194, 196, 194, 194, 194, 194, 3, 194, 194, 3, + /* 630 */ 151, 3, 3, 3, 98, 97, 194, 194, 78, 119, + /* 640 */ 194, 78, 114, 207, 206, 141, 211, 210, 208, 194, + /* 650 */ 209, 194, 194, 194, 194, 194, 194, 194, 202, 215, + /* 660 */ 196, 194, 196, 194, 194, 194, 194, 194, 194, 194, + /* 670 */ 79, 194, 151, 197, 95, 197, 196, 194, 197, 194, + /* 680 */ 196, 194, 194, 197, 194, 196, 79, 95, 78, 194, + /* 690 */ 194, 194, 79, 194, 196, 194, 78, 95, 198, 79, + /* 700 */ 78, 1, 131, 79, 95, 78, 95, 131, 114, 78, + /* 710 */ 78, 78, 78, 115, 74, 66, 3, 3, 112, 3, + /* 720 */ 85, 84, 5, 85, 3, 84, 3, 3, 3, 3, + /* 730 */ 3, 3, 81, 74, 82, 82, 78, 116, 9, 79, + /* 740 */ 78, 55, 20, 10, 10, 146, 146, 146, 3, 95, + /* 750 */ 146, 3, 79, 3, 3, 3, 3, 3, 3, 3, + /* 760 */ 3, 3, 3, 3, 3, 3, 3, 95, 81, 0, + /* 770 */ 274, 56, 274, 274, 274, 274, 274, 274, 274, 15, + /* 780 */ 15, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 790 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 800 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 810 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 820 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 830 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 840 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 850 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 860 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 870 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 880 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 890 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 900 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 910 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 920 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 930 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 940 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 950 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 960 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 970 */ 274, 274, 274, }; -#define YY_SHIFT_COUNT (365) +#define YY_SHIFT_COUNT (367) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (766) +#define YY_SHIFT_MAX (769) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 203, 114, 248, 48, 261, 281, 281, 1, 55, 55, - /* 10 */ 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - /* 20 */ 55, 0, 121, 281, 266, 295, 295, 79, 79, 132, - /* 30 */ 258, 50, 48, 55, 55, 55, 55, 55, 106, 55, - /* 40 */ 55, 106, 269, 777, 281, 281, 281, 281, 281, 281, - /* 50 */ 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, - /* 60 */ 281, 281, 281, 281, 281, 281, 266, 295, 266, 266, - /* 70 */ 36, 2, 2, 2, 2, 2, 2, 2, 319, 79, - /* 80 */ 79, 317, 317, 313, 79, 341, 55, 479, 55, 55, - /* 90 */ 55, 479, 55, 55, 55, 479, 55, 416, 416, 416, - /* 100 */ 416, 479, 55, 55, 479, 417, 411, 426, 423, 429, - /* 110 */ 439, 445, 448, 447, 440, 479, 55, 55, 479, 55, - /* 120 */ 479, 55, 55, 55, 494, 55, 55, 494, 55, 55, - /* 130 */ 55, 48, 55, 55, 55, 55, 55, 55, 55, 55, - /* 140 */ 55, 479, 55, 55, 55, 55, 55, 55, 479, 55, - /* 150 */ 55, 488, 493, 550, 508, 509, 556, 518, 521, 55, - /* 160 */ 55, 269, 55, 55, 55, 55, 55, 55, 55, 55, - /* 170 */ 55, 479, 55, 479, 55, 55, 55, 55, 55, 55, - /* 180 */ 55, 531, 55, 531, 479, 55, 531, 479, 55, 531, - /* 190 */ 55, 55, 55, 55, 479, 55, 55, 479, 55, 55, - /* 200 */ 777, 777, 30, 66, 66, 96, 66, 126, 169, 223, - /* 210 */ 223, 223, 223, 223, 223, 246, 268, 325, 333, 333, - /* 220 */ 333, 333, 228, 245, 102, 164, 296, 296, 350, 394, - /* 230 */ 344, 369, 356, 332, 337, 358, 360, 361, 328, 346, - /* 240 */ 363, 364, 365, 366, 459, 462, 378, 370, 388, 389, - /* 250 */ 403, 413, 437, 391, 64, 330, 334, 484, 489, 335, - /* 260 */ 352, 407, 353, 415, 612, 506, 620, 622, 510, 626, - /* 270 */ 627, 533, 535, 532, 516, 522, 557, 560, 558, 545, - /* 280 */ 546, 594, 598, 600, 604, 608, 593, 613, 619, 623, - /* 290 */ 699, 624, 609, 574, 610, 577, 629, 522, 630, 597, - /* 300 */ 632, 599, 637, 628, 631, 648, 713, 633, 635, 714, - /* 310 */ 715, 718, 719, 720, 721, 722, 723, 724, 647, 725, - /* 320 */ 655, 649, 650, 652, 654, 621, 658, 717, 683, 729, - /* 330 */ 596, 601, 646, 646, 646, 646, 732, 602, 603, 646, - /* 340 */ 646, 646, 740, 741, 669, 646, 746, 747, 748, 749, - /* 350 */ 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, - /* 360 */ 668, 684, 760, 761, 708, 766, + /* 0 */ 202, 75, 55, 197, 260, 280, 280, 24, 8, 8, + /* 10 */ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + /* 20 */ 8, 0, 203, 280, 296, 310, 310, 45, 45, 3, + /* 30 */ 156, 133, 197, 8, 8, 8, 8, 8, 135, 8, + /* 40 */ 8, 135, 1, 781, 280, 280, 280, 280, 280, 280, + /* 50 */ 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + /* 60 */ 280, 280, 280, 280, 280, 280, 296, 310, 296, 296, + /* 70 */ 198, 238, 238, 238, 238, 238, 238, 238, 119, 45, + /* 80 */ 45, 314, 314, 113, 45, 25, 8, 482, 8, 8, + /* 90 */ 8, 482, 8, 8, 8, 482, 8, 417, 417, 417, + /* 100 */ 417, 482, 8, 8, 482, 406, 409, 422, 419, 421, + /* 110 */ 427, 445, 449, 447, 439, 482, 8, 8, 482, 8, + /* 120 */ 482, 8, 8, 8, 493, 8, 8, 493, 8, 8, + /* 130 */ 8, 197, 8, 8, 8, 8, 8, 8, 8, 8, + /* 140 */ 8, 482, 8, 8, 8, 8, 8, 8, 482, 8, + /* 150 */ 8, 491, 502, 552, 513, 519, 562, 524, 527, 8, + /* 160 */ 8, 1, 8, 8, 8, 8, 8, 8, 8, 8, + /* 170 */ 8, 482, 8, 482, 8, 8, 8, 8, 8, 8, + /* 180 */ 8, 537, 8, 537, 482, 8, 537, 482, 8, 537, + /* 190 */ 8, 8, 8, 8, 482, 8, 8, 482, 8, 8, + /* 200 */ 781, 781, 30, 66, 66, 96, 66, 126, 195, 273, + /* 210 */ 273, 273, 273, 273, 273, 263, 294, 297, 204, 204, + /* 220 */ 204, 204, 247, 286, 258, 322, 253, 253, 223, 301, + /* 230 */ 359, 211, 356, 338, 346, 361, 363, 364, 333, 350, + /* 240 */ 373, 374, 381, 382, 344, 451, 383, 352, 384, 385, + /* 250 */ 448, 411, 389, 393, 329, 339, 347, 492, 494, 348, + /* 260 */ 355, 396, 358, 432, 623, 479, 626, 628, 521, 629, + /* 270 */ 630, 536, 538, 504, 520, 528, 560, 591, 563, 579, + /* 280 */ 592, 607, 610, 613, 618, 620, 602, 622, 624, 627, + /* 290 */ 700, 631, 609, 571, 611, 576, 632, 528, 633, 594, + /* 300 */ 634, 598, 640, 635, 637, 649, 713, 638, 641, 714, + /* 310 */ 606, 716, 717, 721, 723, 724, 725, 726, 727, 728, + /* 320 */ 651, 729, 659, 652, 653, 658, 660, 621, 662, 722, + /* 330 */ 686, 733, 599, 600, 654, 654, 654, 654, 734, 601, + /* 340 */ 604, 654, 654, 654, 745, 748, 673, 654, 750, 751, + /* 350 */ 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, + /* 360 */ 762, 763, 672, 687, 764, 765, 715, 769, }; #define YY_REDUCE_COUNT (201) -#define YY_REDUCE_MIN (-241) -#define YY_REDUCE_MAX (503) +#define YY_REDUCE_MIN (-237) +#define YY_REDUCE_MAX (501) static const short yy_reduce_ofst[] = { - /* 0 */ -165, 9, -161, 87, -200, -194, -164, -67, -102, -62, - /* 10 */ -146, -36, 108, 123, 124, 162, 176, 178, 184, 185, - /* 20 */ 193, -191, -182, -170, -218, -199, -144, -107, -58, 13, - /* 30 */ -131, -18, -192, 183, 206, 109, -50, 84, 213, 113, - /* 40 */ 99, 215, 217, -241, -12, 28, 40, 47, 189, 220, - /* 50 */ 237, 238, 239, 240, 241, 242, 243, 244, 247, 249, - /* 60 */ 250, 251, 252, 253, 255, 256, 262, 265, 275, 276, - /* 70 */ 282, 277, 289, 291, 292, 293, 294, 297, 267, 288, - /* 80 */ 290, 263, 264, 285, 298, 338, 342, 343, 347, 348, - /* 90 */ 349, 351, 354, 355, 359, 362, 367, 279, 280, 287, - /* 100 */ 299, 371, 368, 372, 373, 283, 300, 302, 305, 310, - /* 110 */ 316, 320, 323, 326, 329, 382, 385, 386, 387, 390, - /* 120 */ 392, 393, 395, 396, 381, 397, 398, 399, 400, 401, - /* 130 */ 402, 404, 405, 406, 408, 410, 412, 414, 418, 419, - /* 140 */ 420, 421, 422, 424, 425, 427, 428, 430, 431, 432, - /* 150 */ 434, 380, 433, 409, 435, 436, 441, 438, 442, 443, - /* 160 */ 444, 446, 449, 450, 456, 457, 458, 460, 461, 463, - /* 170 */ 464, 466, 465, 467, 470, 471, 472, 473, 474, 475, - /* 180 */ 476, 477, 478, 480, 482, 481, 483, 485, 490, 486, - /* 190 */ 491, 492, 495, 496, 497, 498, 500, 499, 502, 503, - /* 200 */ 451, 501, + /* 0 */ -180, -29, -161, -68, -195, -168, -30, -194, -103, -50, + /* 10 */ -146, 130, 140, 142, 143, 149, 151, 173, 176, 181, + /* 20 */ 194, -191, -167, -231, -152, -237, -200, -223, -127, -36, + /* 30 */ 90, 136, 170, 134, 139, -119, 207, 213, 239, 245, + /* 40 */ 208, 242, -117, 32, -206, 57, 112, 117, 220, 222, + /* 50 */ 225, 228, 241, 246, 248, 249, 250, 251, 252, 254, + /* 60 */ 255, 256, 257, 259, 261, 262, 72, 227, 270, 275, + /* 70 */ 281, 267, 292, 293, 295, 298, 299, 300, 266, 288, + /* 80 */ 289, 264, 265, 287, 302, 343, 345, 349, 353, 354, + /* 90 */ 357, 360, 365, 366, 367, 362, 368, 276, 278, 283, + /* 100 */ 284, 369, 370, 372, 371, 305, 311, 313, 315, 303, + /* 110 */ 318, 321, 323, 327, 331, 386, 387, 390, 391, 392, + /* 120 */ 394, 395, 397, 398, 379, 399, 400, 401, 402, 403, + /* 130 */ 404, 405, 407, 408, 410, 413, 414, 415, 416, 418, + /* 140 */ 420, 423, 424, 426, 428, 429, 430, 431, 425, 433, + /* 150 */ 434, 375, 388, 435, 436, 437, 440, 441, 438, 442, + /* 160 */ 443, 444, 446, 455, 457, 458, 459, 460, 461, 462, + /* 170 */ 463, 464, 467, 466, 469, 470, 471, 472, 473, 474, + /* 180 */ 475, 476, 477, 478, 480, 483, 481, 484, 485, 486, + /* 190 */ 487, 488, 490, 495, 489, 496, 497, 498, 499, 501, + /* 200 */ 456, 500, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 888, 950, 938, 946, 1171, 1171, 1171, 888, 888, 888, - /* 10 */ 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, - /* 20 */ 888, 1078, 908, 1171, 888, 888, 888, 888, 888, 1093, - /* 30 */ 1028, 956, 946, 888, 888, 888, 888, 888, 956, 888, - /* 40 */ 888, 956, 888, 1073, 888, 888, 888, 888, 888, 888, - /* 50 */ 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, - /* 60 */ 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, - /* 70 */ 888, 888, 888, 888, 888, 888, 888, 888, 1080, 888, - /* 80 */ 888, 1112, 1112, 1071, 888, 888, 888, 910, 888, 888, - /* 90 */ 1086, 910, 1083, 888, 1088, 910, 888, 888, 888, 888, - /* 100 */ 888, 910, 888, 888, 910, 1119, 1123, 1105, 1117, 1113, - /* 110 */ 1100, 1098, 1096, 1104, 1127, 910, 888, 888, 910, 888, - /* 120 */ 910, 888, 888, 888, 954, 888, 888, 954, 888, 888, - /* 130 */ 888, 946, 888, 888, 888, 888, 888, 888, 888, 888, - /* 140 */ 888, 910, 888, 888, 888, 888, 888, 888, 910, 888, - /* 150 */ 888, 972, 970, 968, 960, 966, 962, 964, 958, 888, - /* 160 */ 888, 888, 888, 936, 888, 934, 888, 888, 888, 888, - /* 170 */ 888, 910, 888, 910, 888, 888, 888, 888, 888, 888, - /* 180 */ 888, 944, 888, 944, 910, 888, 944, 910, 888, 944, - /* 190 */ 919, 888, 888, 888, 910, 888, 888, 910, 888, 906, - /* 200 */ 994, 1011, 888, 1128, 1118, 888, 1170, 1158, 1157, 1166, - /* 210 */ 1165, 1164, 1156, 1155, 1154, 888, 888, 888, 1150, 1153, - /* 220 */ 1152, 1151, 888, 888, 888, 888, 1160, 1159, 888, 888, - /* 230 */ 888, 888, 888, 888, 888, 888, 888, 888, 1124, 1120, - /* 240 */ 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, - /* 250 */ 888, 1130, 888, 888, 888, 888, 888, 888, 888, 888, - /* 260 */ 888, 1019, 888, 888, 888, 888, 888, 888, 888, 888, - /* 270 */ 888, 888, 888, 888, 1070, 888, 888, 888, 888, 1082, - /* 280 */ 1081, 888, 888, 888, 888, 888, 888, 888, 888, 888, - /* 290 */ 888, 888, 1114, 888, 1106, 888, 888, 1031, 888, 888, - /* 300 */ 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, - /* 310 */ 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, - /* 320 */ 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, - /* 330 */ 888, 888, 1189, 1184, 1185, 1182, 888, 888, 888, 1181, - /* 340 */ 1176, 1177, 888, 888, 888, 1174, 888, 888, 888, 888, - /* 350 */ 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, - /* 360 */ 978, 888, 917, 915, 888, 888, + /* 0 */ 894, 956, 944, 952, 1179, 1179, 1179, 894, 894, 894, + /* 10 */ 894, 894, 894, 894, 894, 894, 894, 894, 894, 894, + /* 20 */ 894, 1086, 914, 1179, 894, 894, 894, 894, 894, 1101, + /* 30 */ 1036, 962, 952, 894, 894, 894, 894, 894, 962, 894, + /* 40 */ 894, 962, 894, 1081, 894, 894, 894, 894, 894, 894, + /* 50 */ 894, 894, 894, 894, 894, 894, 894, 894, 894, 894, + /* 60 */ 894, 894, 894, 894, 894, 894, 894, 894, 894, 894, + /* 70 */ 894, 894, 894, 894, 894, 894, 894, 894, 1088, 894, + /* 80 */ 894, 1120, 1120, 1079, 894, 894, 894, 916, 894, 894, + /* 90 */ 1094, 916, 1091, 894, 1096, 916, 894, 894, 894, 894, + /* 100 */ 894, 916, 894, 894, 916, 1127, 1131, 1113, 1125, 1121, + /* 110 */ 1108, 1106, 1104, 1112, 1135, 916, 894, 894, 916, 894, + /* 120 */ 916, 894, 894, 894, 960, 894, 894, 960, 894, 894, + /* 130 */ 894, 952, 894, 894, 894, 894, 894, 894, 894, 894, + /* 140 */ 894, 916, 894, 894, 894, 894, 894, 894, 916, 894, + /* 150 */ 894, 978, 976, 974, 966, 972, 968, 970, 964, 894, + /* 160 */ 894, 894, 894, 942, 894, 940, 894, 894, 894, 894, + /* 170 */ 894, 916, 894, 916, 894, 894, 894, 894, 894, 894, + /* 180 */ 894, 950, 894, 950, 916, 894, 950, 916, 894, 950, + /* 190 */ 925, 894, 894, 894, 916, 894, 894, 916, 894, 912, + /* 200 */ 1001, 1019, 894, 1136, 1126, 894, 1178, 1166, 1165, 1174, + /* 210 */ 1173, 1172, 1164, 1163, 1162, 894, 894, 894, 1158, 1161, + /* 220 */ 1160, 1159, 894, 894, 894, 894, 1168, 1167, 894, 894, + /* 230 */ 894, 894, 894, 894, 894, 894, 894, 894, 1132, 1128, + /* 240 */ 894, 894, 894, 894, 894, 894, 894, 894, 894, 894, + /* 250 */ 894, 1138, 894, 894, 894, 894, 894, 894, 894, 894, + /* 260 */ 894, 1027, 894, 894, 894, 894, 894, 894, 894, 894, + /* 270 */ 894, 894, 894, 894, 1078, 894, 894, 894, 894, 1090, + /* 280 */ 1089, 894, 894, 894, 894, 894, 894, 894, 894, 894, + /* 290 */ 894, 894, 1122, 894, 1114, 894, 894, 1039, 894, 894, + /* 300 */ 894, 894, 894, 894, 894, 894, 894, 894, 894, 894, + /* 310 */ 894, 894, 894, 894, 894, 894, 894, 894, 894, 894, + /* 320 */ 894, 894, 894, 894, 894, 894, 894, 894, 894, 894, + /* 330 */ 894, 894, 894, 894, 1197, 1192, 1193, 1190, 894, 894, + /* 340 */ 894, 1189, 1184, 1185, 894, 894, 894, 1182, 894, 894, + /* 350 */ 894, 894, 894, 894, 894, 894, 894, 894, 894, 894, + /* 360 */ 894, 894, 984, 894, 923, 921, 894, 894, }; /********** End of lemon-generated parsing tables *****************************/ @@ -622,6 +634,8 @@ static const YYCODETYPE yyFallback[] = { 0, /* PRECISION => nothing */ 0, /* UPDATE => nothing */ 0, /* CACHELAST => nothing */ + 0, /* STREAM => nothing */ + 0, /* MODE => nothing */ 0, /* UNSIGNED => nothing */ 0, /* TAGS => nothing */ 0, /* USING => nothing */ @@ -660,7 +674,6 @@ static const YYCODETYPE yyFallback[] = { 0, /* SET => nothing */ 0, /* KILL => nothing */ 0, /* CONNECTION => nothing */ - 0, /* STREAM => nothing */ 0, /* COLON => nothing */ 1, /* ABORT => ID */ 1, /* AFTER => ID */ @@ -741,6 +754,7 @@ struct yyParser { int yyerrcnt; /* Shifts left before out of the error */ #endif ParseARG_SDECL /* A place to hold %extra_argument */ + ParseCTX_SDECL /* A place to hold %extra_context */ #if YYSTACKDEPTH<=0 int yystksz; /* Current side of the stack */ yyStackEntry *yystack; /* The parser's stack */ @@ -899,87 +913,87 @@ static const char *const yyTokenName[] = { /* 108 */ "PRECISION", /* 109 */ "UPDATE", /* 110 */ "CACHELAST", - /* 111 */ "UNSIGNED", - /* 112 */ "TAGS", - /* 113 */ "USING", - /* 114 */ "NULL", - /* 115 */ "NOW", - /* 116 */ "SELECT", - /* 117 */ "UNION", - /* 118 */ "ALL", - /* 119 */ "DISTINCT", - /* 120 */ "FROM", - /* 121 */ "VARIABLE", - /* 122 */ "INTERVAL", - /* 123 */ "EVERY", - /* 124 */ "SESSION", - /* 125 */ "STATE_WINDOW", - /* 126 */ "FILL", - /* 127 */ "SLIDING", - /* 128 */ "ORDER", - /* 129 */ "BY", - /* 130 */ "ASC", - /* 131 */ "GROUP", - /* 132 */ "HAVING", - /* 133 */ "LIMIT", - /* 134 */ "OFFSET", - /* 135 */ "SLIMIT", - /* 136 */ "SOFFSET", - /* 137 */ "WHERE", - /* 138 */ "RESET", - /* 139 */ "QUERY", - /* 140 */ "SYNCDB", - /* 141 */ "ADD", - /* 142 */ "COLUMN", - /* 143 */ "MODIFY", - /* 144 */ "TAG", - /* 145 */ "CHANGE", - /* 146 */ "SET", - /* 147 */ "KILL", - /* 148 */ "CONNECTION", - /* 149 */ "STREAM", - /* 150 */ "COLON", - /* 151 */ "ABORT", - /* 152 */ "AFTER", - /* 153 */ "ATTACH", - /* 154 */ "BEFORE", - /* 155 */ "BEGIN", - /* 156 */ "CASCADE", - /* 157 */ "CLUSTER", - /* 158 */ "CONFLICT", - /* 159 */ "COPY", - /* 160 */ "DEFERRED", - /* 161 */ "DELIMITERS", - /* 162 */ "DETACH", - /* 163 */ "EACH", - /* 164 */ "END", - /* 165 */ "EXPLAIN", - /* 166 */ "FAIL", - /* 167 */ "FOR", - /* 168 */ "IGNORE", - /* 169 */ "IMMEDIATE", - /* 170 */ "INITIALLY", - /* 171 */ "INSTEAD", - /* 172 */ "KEY", - /* 173 */ "OF", - /* 174 */ "RAISE", - /* 175 */ "REPLACE", - /* 176 */ "RESTRICT", - /* 177 */ "ROW", - /* 178 */ "STATEMENT", - /* 179 */ "TRIGGER", - /* 180 */ "VIEW", - /* 181 */ "SEMI", - /* 182 */ "NONE", - /* 183 */ "PREV", - /* 184 */ "LINEAR", - /* 185 */ "IMPORT", - /* 186 */ "TBNAME", - /* 187 */ "JOIN", - /* 188 */ "INSERT", - /* 189 */ "INTO", - /* 190 */ "VALUES", - /* 191 */ "error", + /* 111 */ "STREAM", + /* 112 */ "MODE", + /* 113 */ "UNSIGNED", + /* 114 */ "TAGS", + /* 115 */ "USING", + /* 116 */ "NULL", + /* 117 */ "NOW", + /* 118 */ "SELECT", + /* 119 */ "UNION", + /* 120 */ "ALL", + /* 121 */ "DISTINCT", + /* 122 */ "FROM", + /* 123 */ "VARIABLE", + /* 124 */ "INTERVAL", + /* 125 */ "EVERY", + /* 126 */ "SESSION", + /* 127 */ "STATE_WINDOW", + /* 128 */ "FILL", + /* 129 */ "SLIDING", + /* 130 */ "ORDER", + /* 131 */ "BY", + /* 132 */ "ASC", + /* 133 */ "GROUP", + /* 134 */ "HAVING", + /* 135 */ "LIMIT", + /* 136 */ "OFFSET", + /* 137 */ "SLIMIT", + /* 138 */ "SOFFSET", + /* 139 */ "WHERE", + /* 140 */ "RESET", + /* 141 */ "QUERY", + /* 142 */ "SYNCDB", + /* 143 */ "ADD", + /* 144 */ "COLUMN", + /* 145 */ "MODIFY", + /* 146 */ "TAG", + /* 147 */ "CHANGE", + /* 148 */ "SET", + /* 149 */ "KILL", + /* 150 */ "CONNECTION", + /* 151 */ "COLON", + /* 152 */ "ABORT", + /* 153 */ "AFTER", + /* 154 */ "ATTACH", + /* 155 */ "BEFORE", + /* 156 */ "BEGIN", + /* 157 */ "CASCADE", + /* 158 */ "CLUSTER", + /* 159 */ "CONFLICT", + /* 160 */ "COPY", + /* 161 */ "DEFERRED", + /* 162 */ "DELIMITERS", + /* 163 */ "DETACH", + /* 164 */ "EACH", + /* 165 */ "END", + /* 166 */ "EXPLAIN", + /* 167 */ "FAIL", + /* 168 */ "FOR", + /* 169 */ "IGNORE", + /* 170 */ "IMMEDIATE", + /* 171 */ "INITIALLY", + /* 172 */ "INSTEAD", + /* 173 */ "KEY", + /* 174 */ "OF", + /* 175 */ "RAISE", + /* 176 */ "REPLACE", + /* 177 */ "RESTRICT", + /* 178 */ "ROW", + /* 179 */ "STATEMENT", + /* 180 */ "TRIGGER", + /* 181 */ "VIEW", + /* 182 */ "SEMI", + /* 183 */ "NONE", + /* 184 */ "PREV", + /* 185 */ "LINEAR", + /* 186 */ "IMPORT", + /* 187 */ "TBNAME", + /* 188 */ "JOIN", + /* 189 */ "INSERT", + /* 190 */ "INTO", + /* 191 */ "VALUES", /* 192 */ "program", /* 193 */ "cmd", /* 194 */ "ids", @@ -1020,47 +1034,48 @@ static const char *const yyTokenName[] = { /* 229 */ "update", /* 230 */ "cachelast", /* 231 */ "vgroups", - /* 232 */ "signed", - /* 233 */ "create_table_args", - /* 234 */ "create_stable_args", - /* 235 */ "create_table_list", - /* 236 */ "create_from_stable", - /* 237 */ "columnlist", - /* 238 */ "tagitemlist1", - /* 239 */ "tagNamelist", - /* 240 */ "select", - /* 241 */ "column", - /* 242 */ "tagitem1", - /* 243 */ "tagitemlist", - /* 244 */ "tagitem", - /* 245 */ "selcollist", - /* 246 */ "from", - /* 247 */ "where_opt", - /* 248 */ "interval_option", - /* 249 */ "sliding_opt", - /* 250 */ "session_option", - /* 251 */ "windowstate_option", - /* 252 */ "fill_opt", - /* 253 */ "groupby_opt", - /* 254 */ "having_opt", - /* 255 */ "orderby_opt", - /* 256 */ "slimit_opt", - /* 257 */ "limit_opt", - /* 258 */ "union", - /* 259 */ "sclp", - /* 260 */ "distinct", - /* 261 */ "expr", - /* 262 */ "as", - /* 263 */ "tablelist", - /* 264 */ "sub", - /* 265 */ "tmvar", - /* 266 */ "intervalKey", - /* 267 */ "sortlist", - /* 268 */ "sortitem", - /* 269 */ "item", - /* 270 */ "sortorder", - /* 271 */ "grouplist", - /* 272 */ "expritem", + /* 232 */ "stream_mode", + /* 233 */ "signed", + /* 234 */ "create_table_args", + /* 235 */ "create_stable_args", + /* 236 */ "create_table_list", + /* 237 */ "create_from_stable", + /* 238 */ "columnlist", + /* 239 */ "tagitemlist1", + /* 240 */ "tagNamelist", + /* 241 */ "select", + /* 242 */ "column", + /* 243 */ "tagitem1", + /* 244 */ "tagitemlist", + /* 245 */ "tagitem", + /* 246 */ "selcollist", + /* 247 */ "from", + /* 248 */ "where_opt", + /* 249 */ "interval_option", + /* 250 */ "sliding_opt", + /* 251 */ "session_option", + /* 252 */ "windowstate_option", + /* 253 */ "fill_opt", + /* 254 */ "groupby_opt", + /* 255 */ "having_opt", + /* 256 */ "orderby_opt", + /* 257 */ "slimit_opt", + /* 258 */ "limit_opt", + /* 259 */ "union", + /* 260 */ "sclp", + /* 261 */ "distinct", + /* 262 */ "expr", + /* 263 */ "as", + /* 264 */ "tablelist", + /* 265 */ "sub", + /* 266 */ "tmvar", + /* 267 */ "intervalKey", + /* 268 */ "sortlist", + /* 269 */ "sortitem", + /* 270 */ "item", + /* 271 */ "sortorder", + /* 272 */ "grouplist", + /* 273 */ "expritem", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1171,205 +1186,207 @@ static const char *const yyRuleName[] = { /* 100 */ "update ::= UPDATE INTEGER", /* 101 */ "cachelast ::= CACHELAST INTEGER", /* 102 */ "vgroups ::= VGROUPS INTEGER", - /* 103 */ "db_optr ::=", - /* 104 */ "db_optr ::= db_optr cache", - /* 105 */ "db_optr ::= db_optr replica", - /* 106 */ "db_optr ::= db_optr quorum", - /* 107 */ "db_optr ::= db_optr days", - /* 108 */ "db_optr ::= db_optr minrows", - /* 109 */ "db_optr ::= db_optr maxrows", - /* 110 */ "db_optr ::= db_optr blocks", - /* 111 */ "db_optr ::= db_optr ctime", - /* 112 */ "db_optr ::= db_optr wal", - /* 113 */ "db_optr ::= db_optr fsync", - /* 114 */ "db_optr ::= db_optr comp", - /* 115 */ "db_optr ::= db_optr prec", - /* 116 */ "db_optr ::= db_optr keep", - /* 117 */ "db_optr ::= db_optr update", - /* 118 */ "db_optr ::= db_optr cachelast", - /* 119 */ "db_optr ::= db_optr vgroups", - /* 120 */ "alter_db_optr ::=", - /* 121 */ "alter_db_optr ::= alter_db_optr replica", - /* 122 */ "alter_db_optr ::= alter_db_optr quorum", - /* 123 */ "alter_db_optr ::= alter_db_optr keep", - /* 124 */ "alter_db_optr ::= alter_db_optr blocks", - /* 125 */ "alter_db_optr ::= alter_db_optr comp", - /* 126 */ "alter_db_optr ::= alter_db_optr update", - /* 127 */ "alter_db_optr ::= alter_db_optr cachelast", - /* 128 */ "typename ::= ids", - /* 129 */ "typename ::= ids LP signed RP", - /* 130 */ "typename ::= ids UNSIGNED", - /* 131 */ "signed ::= INTEGER", - /* 132 */ "signed ::= PLUS INTEGER", - /* 133 */ "signed ::= MINUS INTEGER", - /* 134 */ "cmd ::= CREATE TABLE create_table_args", - /* 135 */ "cmd ::= CREATE TABLE create_stable_args", - /* 136 */ "cmd ::= CREATE STABLE create_stable_args", - /* 137 */ "cmd ::= CREATE TABLE create_table_list", - /* 138 */ "create_table_list ::= create_from_stable", - /* 139 */ "create_table_list ::= create_table_list create_from_stable", - /* 140 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", - /* 141 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", - /* 142 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP", - /* 143 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP", - /* 144 */ "tagNamelist ::= tagNamelist COMMA ids", - /* 145 */ "tagNamelist ::= ids", - /* 146 */ "create_table_args ::= ifnotexists ids cpxName AS select", - /* 147 */ "columnlist ::= columnlist COMMA column", - /* 148 */ "columnlist ::= column", - /* 149 */ "column ::= ids typename", - /* 150 */ "tagitemlist1 ::= tagitemlist1 COMMA tagitem1", - /* 151 */ "tagitemlist1 ::= tagitem1", - /* 152 */ "tagitem1 ::= MINUS INTEGER", - /* 153 */ "tagitem1 ::= MINUS FLOAT", - /* 154 */ "tagitem1 ::= PLUS INTEGER", - /* 155 */ "tagitem1 ::= PLUS FLOAT", - /* 156 */ "tagitem1 ::= INTEGER", - /* 157 */ "tagitem1 ::= FLOAT", - /* 158 */ "tagitem1 ::= STRING", - /* 159 */ "tagitem1 ::= BOOL", - /* 160 */ "tagitem1 ::= NULL", - /* 161 */ "tagitem1 ::= NOW", - /* 162 */ "tagitemlist ::= tagitemlist COMMA tagitem", - /* 163 */ "tagitemlist ::= tagitem", - /* 164 */ "tagitem ::= INTEGER", - /* 165 */ "tagitem ::= FLOAT", - /* 166 */ "tagitem ::= STRING", - /* 167 */ "tagitem ::= BOOL", - /* 168 */ "tagitem ::= NULL", - /* 169 */ "tagitem ::= NOW", - /* 170 */ "tagitem ::= MINUS INTEGER", - /* 171 */ "tagitem ::= MINUS FLOAT", - /* 172 */ "tagitem ::= PLUS INTEGER", - /* 173 */ "tagitem ::= PLUS FLOAT", - /* 174 */ "select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt", - /* 175 */ "select ::= LP select RP", - /* 176 */ "union ::= select", - /* 177 */ "union ::= union UNION ALL select", - /* 178 */ "union ::= union UNION select", - /* 179 */ "cmd ::= union", - /* 180 */ "select ::= SELECT selcollist", - /* 181 */ "sclp ::= selcollist COMMA", - /* 182 */ "sclp ::=", - /* 183 */ "selcollist ::= sclp distinct expr as", - /* 184 */ "selcollist ::= sclp STAR", - /* 185 */ "as ::= AS ids", - /* 186 */ "as ::= ids", - /* 187 */ "as ::=", - /* 188 */ "distinct ::= DISTINCT", - /* 189 */ "distinct ::=", - /* 190 */ "from ::= FROM tablelist", - /* 191 */ "from ::= FROM sub", - /* 192 */ "sub ::= LP union RP", - /* 193 */ "sub ::= LP union RP ids", - /* 194 */ "sub ::= sub COMMA LP union RP ids", - /* 195 */ "tablelist ::= ids cpxName", - /* 196 */ "tablelist ::= ids cpxName ids", - /* 197 */ "tablelist ::= tablelist COMMA ids cpxName", - /* 198 */ "tablelist ::= tablelist COMMA ids cpxName ids", - /* 199 */ "tmvar ::= VARIABLE", - /* 200 */ "interval_option ::= intervalKey LP tmvar RP", - /* 201 */ "interval_option ::= intervalKey LP tmvar COMMA tmvar RP", - /* 202 */ "interval_option ::=", - /* 203 */ "intervalKey ::= INTERVAL", - /* 204 */ "intervalKey ::= EVERY", - /* 205 */ "session_option ::=", - /* 206 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", - /* 207 */ "windowstate_option ::=", - /* 208 */ "windowstate_option ::= STATE_WINDOW LP ids RP", - /* 209 */ "fill_opt ::=", - /* 210 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", - /* 211 */ "fill_opt ::= FILL LP ID RP", - /* 212 */ "sliding_opt ::= SLIDING LP tmvar RP", - /* 213 */ "sliding_opt ::=", - /* 214 */ "orderby_opt ::=", - /* 215 */ "orderby_opt ::= ORDER BY sortlist", - /* 216 */ "sortlist ::= sortlist COMMA item sortorder", - /* 217 */ "sortlist ::= item sortorder", - /* 218 */ "item ::= ids cpxName", - /* 219 */ "sortorder ::= ASC", - /* 220 */ "sortorder ::= DESC", - /* 221 */ "sortorder ::=", - /* 222 */ "groupby_opt ::=", - /* 223 */ "groupby_opt ::= GROUP BY grouplist", - /* 224 */ "grouplist ::= grouplist COMMA item", - /* 225 */ "grouplist ::= item", - /* 226 */ "having_opt ::=", - /* 227 */ "having_opt ::= HAVING expr", - /* 228 */ "limit_opt ::=", - /* 229 */ "limit_opt ::= LIMIT signed", - /* 230 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 231 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 232 */ "slimit_opt ::=", - /* 233 */ "slimit_opt ::= SLIMIT signed", - /* 234 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", - /* 235 */ "slimit_opt ::= SLIMIT signed COMMA signed", - /* 236 */ "where_opt ::=", - /* 237 */ "where_opt ::= WHERE expr", - /* 238 */ "expr ::= LP expr RP", - /* 239 */ "expr ::= ID", - /* 240 */ "expr ::= ID DOT ID", - /* 241 */ "expr ::= ID DOT STAR", - /* 242 */ "expr ::= INTEGER", - /* 243 */ "expr ::= MINUS INTEGER", - /* 244 */ "expr ::= PLUS INTEGER", - /* 245 */ "expr ::= FLOAT", - /* 246 */ "expr ::= MINUS FLOAT", - /* 247 */ "expr ::= PLUS FLOAT", - /* 248 */ "expr ::= STRING", - /* 249 */ "expr ::= NOW", - /* 250 */ "expr ::= VARIABLE", - /* 251 */ "expr ::= PLUS VARIABLE", - /* 252 */ "expr ::= MINUS VARIABLE", - /* 253 */ "expr ::= BOOL", - /* 254 */ "expr ::= NULL", - /* 255 */ "expr ::= ID LP exprlist RP", - /* 256 */ "expr ::= ID LP STAR RP", - /* 257 */ "expr ::= expr IS NULL", - /* 258 */ "expr ::= expr IS NOT NULL", - /* 259 */ "expr ::= expr LT expr", - /* 260 */ "expr ::= expr GT expr", - /* 261 */ "expr ::= expr LE expr", - /* 262 */ "expr ::= expr GE expr", - /* 263 */ "expr ::= expr NE expr", - /* 264 */ "expr ::= expr EQ expr", - /* 265 */ "expr ::= expr BETWEEN expr AND expr", - /* 266 */ "expr ::= expr AND expr", - /* 267 */ "expr ::= expr OR expr", - /* 268 */ "expr ::= expr PLUS expr", - /* 269 */ "expr ::= expr MINUS expr", - /* 270 */ "expr ::= expr STAR expr", - /* 271 */ "expr ::= expr SLASH expr", - /* 272 */ "expr ::= expr REM expr", - /* 273 */ "expr ::= expr LIKE expr", - /* 274 */ "expr ::= expr MATCH expr", - /* 275 */ "expr ::= expr NMATCH expr", - /* 276 */ "expr ::= expr IN LP exprlist RP", - /* 277 */ "exprlist ::= exprlist COMMA expritem", - /* 278 */ "exprlist ::= expritem", - /* 279 */ "expritem ::= expr", - /* 280 */ "expritem ::=", - /* 281 */ "cmd ::= RESET QUERY CACHE", - /* 282 */ "cmd ::= SYNCDB ids REPLICA", - /* 283 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 284 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 285 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", - /* 286 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 287 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 288 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 289 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 290 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", - /* 291 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", - /* 292 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", - /* 293 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", - /* 294 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", - /* 295 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", - /* 296 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", - /* 297 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", - /* 298 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", - /* 299 */ "cmd ::= KILL CONNECTION INTEGER", - /* 300 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 301 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 103 */ "stream_mode ::= STREAM MODE INTEGER", + /* 104 */ "db_optr ::=", + /* 105 */ "db_optr ::= db_optr cache", + /* 106 */ "db_optr ::= db_optr replica", + /* 107 */ "db_optr ::= db_optr quorum", + /* 108 */ "db_optr ::= db_optr days", + /* 109 */ "db_optr ::= db_optr minrows", + /* 110 */ "db_optr ::= db_optr maxrows", + /* 111 */ "db_optr ::= db_optr blocks", + /* 112 */ "db_optr ::= db_optr ctime", + /* 113 */ "db_optr ::= db_optr wal", + /* 114 */ "db_optr ::= db_optr fsync", + /* 115 */ "db_optr ::= db_optr comp", + /* 116 */ "db_optr ::= db_optr prec", + /* 117 */ "db_optr ::= db_optr keep", + /* 118 */ "db_optr ::= db_optr update", + /* 119 */ "db_optr ::= db_optr cachelast", + /* 120 */ "db_optr ::= db_optr vgroups", + /* 121 */ "db_optr ::= db_optr stream_mode", + /* 122 */ "alter_db_optr ::=", + /* 123 */ "alter_db_optr ::= alter_db_optr replica", + /* 124 */ "alter_db_optr ::= alter_db_optr quorum", + /* 125 */ "alter_db_optr ::= alter_db_optr keep", + /* 126 */ "alter_db_optr ::= alter_db_optr blocks", + /* 127 */ "alter_db_optr ::= alter_db_optr comp", + /* 128 */ "alter_db_optr ::= alter_db_optr update", + /* 129 */ "alter_db_optr ::= alter_db_optr cachelast", + /* 130 */ "typename ::= ids", + /* 131 */ "typename ::= ids LP signed RP", + /* 132 */ "typename ::= ids UNSIGNED", + /* 133 */ "signed ::= INTEGER", + /* 134 */ "signed ::= PLUS INTEGER", + /* 135 */ "signed ::= MINUS INTEGER", + /* 136 */ "cmd ::= CREATE TABLE create_table_args", + /* 137 */ "cmd ::= CREATE TABLE create_stable_args", + /* 138 */ "cmd ::= CREATE STABLE create_stable_args", + /* 139 */ "cmd ::= CREATE TABLE create_table_list", + /* 140 */ "create_table_list ::= create_from_stable", + /* 141 */ "create_table_list ::= create_table_list create_from_stable", + /* 142 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", + /* 143 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", + /* 144 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP", + /* 145 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP", + /* 146 */ "tagNamelist ::= tagNamelist COMMA ids", + /* 147 */ "tagNamelist ::= ids", + /* 148 */ "create_table_args ::= ifnotexists ids cpxName AS select", + /* 149 */ "columnlist ::= columnlist COMMA column", + /* 150 */ "columnlist ::= column", + /* 151 */ "column ::= ids typename", + /* 152 */ "tagitemlist1 ::= tagitemlist1 COMMA tagitem1", + /* 153 */ "tagitemlist1 ::= tagitem1", + /* 154 */ "tagitem1 ::= MINUS INTEGER", + /* 155 */ "tagitem1 ::= MINUS FLOAT", + /* 156 */ "tagitem1 ::= PLUS INTEGER", + /* 157 */ "tagitem1 ::= PLUS FLOAT", + /* 158 */ "tagitem1 ::= INTEGER", + /* 159 */ "tagitem1 ::= FLOAT", + /* 160 */ "tagitem1 ::= STRING", + /* 161 */ "tagitem1 ::= BOOL", + /* 162 */ "tagitem1 ::= NULL", + /* 163 */ "tagitem1 ::= NOW", + /* 164 */ "tagitemlist ::= tagitemlist COMMA tagitem", + /* 165 */ "tagitemlist ::= tagitem", + /* 166 */ "tagitem ::= INTEGER", + /* 167 */ "tagitem ::= FLOAT", + /* 168 */ "tagitem ::= STRING", + /* 169 */ "tagitem ::= BOOL", + /* 170 */ "tagitem ::= NULL", + /* 171 */ "tagitem ::= NOW", + /* 172 */ "tagitem ::= MINUS INTEGER", + /* 173 */ "tagitem ::= MINUS FLOAT", + /* 174 */ "tagitem ::= PLUS INTEGER", + /* 175 */ "tagitem ::= PLUS FLOAT", + /* 176 */ "select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt", + /* 177 */ "select ::= LP select RP", + /* 178 */ "union ::= select", + /* 179 */ "union ::= union UNION ALL select", + /* 180 */ "union ::= union UNION select", + /* 181 */ "cmd ::= union", + /* 182 */ "select ::= SELECT selcollist", + /* 183 */ "sclp ::= selcollist COMMA", + /* 184 */ "sclp ::=", + /* 185 */ "selcollist ::= sclp distinct expr as", + /* 186 */ "selcollist ::= sclp STAR", + /* 187 */ "as ::= AS ids", + /* 188 */ "as ::= ids", + /* 189 */ "as ::=", + /* 190 */ "distinct ::= DISTINCT", + /* 191 */ "distinct ::=", + /* 192 */ "from ::= FROM tablelist", + /* 193 */ "from ::= FROM sub", + /* 194 */ "sub ::= LP union RP", + /* 195 */ "sub ::= LP union RP ids", + /* 196 */ "sub ::= sub COMMA LP union RP ids", + /* 197 */ "tablelist ::= ids cpxName", + /* 198 */ "tablelist ::= ids cpxName ids", + /* 199 */ "tablelist ::= tablelist COMMA ids cpxName", + /* 200 */ "tablelist ::= tablelist COMMA ids cpxName ids", + /* 201 */ "tmvar ::= VARIABLE", + /* 202 */ "interval_option ::= intervalKey LP tmvar RP", + /* 203 */ "interval_option ::= intervalKey LP tmvar COMMA tmvar RP", + /* 204 */ "interval_option ::=", + /* 205 */ "intervalKey ::= INTERVAL", + /* 206 */ "intervalKey ::= EVERY", + /* 207 */ "session_option ::=", + /* 208 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", + /* 209 */ "windowstate_option ::=", + /* 210 */ "windowstate_option ::= STATE_WINDOW LP ids RP", + /* 211 */ "fill_opt ::=", + /* 212 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", + /* 213 */ "fill_opt ::= FILL LP ID RP", + /* 214 */ "sliding_opt ::= SLIDING LP tmvar RP", + /* 215 */ "sliding_opt ::=", + /* 216 */ "orderby_opt ::=", + /* 217 */ "orderby_opt ::= ORDER BY sortlist", + /* 218 */ "sortlist ::= sortlist COMMA item sortorder", + /* 219 */ "sortlist ::= item sortorder", + /* 220 */ "item ::= ids cpxName", + /* 221 */ "sortorder ::= ASC", + /* 222 */ "sortorder ::= DESC", + /* 223 */ "sortorder ::=", + /* 224 */ "groupby_opt ::=", + /* 225 */ "groupby_opt ::= GROUP BY grouplist", + /* 226 */ "grouplist ::= grouplist COMMA item", + /* 227 */ "grouplist ::= item", + /* 228 */ "having_opt ::=", + /* 229 */ "having_opt ::= HAVING expr", + /* 230 */ "limit_opt ::=", + /* 231 */ "limit_opt ::= LIMIT signed", + /* 232 */ "limit_opt ::= LIMIT signed OFFSET signed", + /* 233 */ "limit_opt ::= LIMIT signed COMMA signed", + /* 234 */ "slimit_opt ::=", + /* 235 */ "slimit_opt ::= SLIMIT signed", + /* 236 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", + /* 237 */ "slimit_opt ::= SLIMIT signed COMMA signed", + /* 238 */ "where_opt ::=", + /* 239 */ "where_opt ::= WHERE expr", + /* 240 */ "expr ::= LP expr RP", + /* 241 */ "expr ::= ID", + /* 242 */ "expr ::= ID DOT ID", + /* 243 */ "expr ::= ID DOT STAR", + /* 244 */ "expr ::= INTEGER", + /* 245 */ "expr ::= MINUS INTEGER", + /* 246 */ "expr ::= PLUS INTEGER", + /* 247 */ "expr ::= FLOAT", + /* 248 */ "expr ::= MINUS FLOAT", + /* 249 */ "expr ::= PLUS FLOAT", + /* 250 */ "expr ::= STRING", + /* 251 */ "expr ::= NOW", + /* 252 */ "expr ::= VARIABLE", + /* 253 */ "expr ::= PLUS VARIABLE", + /* 254 */ "expr ::= MINUS VARIABLE", + /* 255 */ "expr ::= BOOL", + /* 256 */ "expr ::= NULL", + /* 257 */ "expr ::= ID LP exprlist RP", + /* 258 */ "expr ::= ID LP STAR RP", + /* 259 */ "expr ::= expr IS NULL", + /* 260 */ "expr ::= expr IS NOT NULL", + /* 261 */ "expr ::= expr LT expr", + /* 262 */ "expr ::= expr GT expr", + /* 263 */ "expr ::= expr LE expr", + /* 264 */ "expr ::= expr GE expr", + /* 265 */ "expr ::= expr NE expr", + /* 266 */ "expr ::= expr EQ expr", + /* 267 */ "expr ::= expr BETWEEN expr AND expr", + /* 268 */ "expr ::= expr AND expr", + /* 269 */ "expr ::= expr OR expr", + /* 270 */ "expr ::= expr PLUS expr", + /* 271 */ "expr ::= expr MINUS expr", + /* 272 */ "expr ::= expr STAR expr", + /* 273 */ "expr ::= expr SLASH expr", + /* 274 */ "expr ::= expr REM expr", + /* 275 */ "expr ::= expr LIKE expr", + /* 276 */ "expr ::= expr MATCH expr", + /* 277 */ "expr ::= expr NMATCH expr", + /* 278 */ "expr ::= expr IN LP exprlist RP", + /* 279 */ "exprlist ::= exprlist COMMA expritem", + /* 280 */ "exprlist ::= expritem", + /* 281 */ "expritem ::= expr", + /* 282 */ "expritem ::=", + /* 283 */ "cmd ::= RESET QUERY CACHE", + /* 284 */ "cmd ::= SYNCDB ids REPLICA", + /* 285 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 286 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 287 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", + /* 288 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 289 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 290 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 291 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 292 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", + /* 293 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", + /* 294 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", + /* 295 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", + /* 296 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", + /* 297 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", + /* 298 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", + /* 299 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", + /* 300 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", + /* 301 */ "cmd ::= KILL CONNECTION INTEGER", + /* 302 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 303 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1418,28 +1435,29 @@ static int yyGrowStack(yyParser *p){ /* Initialize a new parser that has already been allocated. */ -void ParseInit(void *yypParser){ - yyParser *pParser = (yyParser*)yypParser; +void ParseInit(void *yypRawParser ParseCTX_PDECL){ + yyParser *yypParser = (yyParser*)yypRawParser; + ParseCTX_STORE #ifdef YYTRACKMAXSTACKDEPTH - pParser->yyhwm = 0; + yypParser->yyhwm = 0; #endif #if YYSTACKDEPTH<=0 - pParser->yytos = NULL; - pParser->yystack = NULL; - pParser->yystksz = 0; - if( yyGrowStack(pParser) ){ - pParser->yystack = &pParser->yystk0; - pParser->yystksz = 1; + yypParser->yytos = NULL; + yypParser->yystack = NULL; + yypParser->yystksz = 0; + if( yyGrowStack(yypParser) ){ + yypParser->yystack = &yypParser->yystk0; + yypParser->yystksz = 1; } #endif #ifndef YYNOERRORRECOVERY - pParser->yyerrcnt = -1; + yypParser->yyerrcnt = -1; #endif - pParser->yytos = pParser->yystack; - pParser->yystack[0].stateno = 0; - pParser->yystack[0].major = 0; + yypParser->yytos = yypParser->yystack; + yypParser->yystack[0].stateno = 0; + yypParser->yystack[0].major = 0; #if YYSTACKDEPTH>0 - pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1]; + yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1]; #endif } @@ -1456,11 +1474,14 @@ void ParseInit(void *yypParser){ ** A pointer to a parser. This pointer is used in subsequent calls ** to Parse and ParseFree. */ -void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){ - yyParser *pParser; - pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); - if( pParser ) ParseInit(pParser); - return pParser; +void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) ParseCTX_PDECL){ + yyParser *yypParser; + yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); + if( yypParser ){ + ParseCTX_STORE + ParseInit(yypParser ParseCTX_PARAM); + } + return (void*)yypParser; } #endif /* Parse_ENGINEALWAYSONSTACK */ @@ -1477,7 +1498,8 @@ static void yy_destructor( YYCODETYPE yymajor, /* Type code for object to destroy */ YYMINORTYPE *yypminor /* The object to be destroyed */ ){ - ParseARG_FETCH; + ParseARG_FETCH + ParseCTX_FETCH switch( yymajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen @@ -1491,60 +1513,60 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ case 200: /* exprlist */ - case 245: /* selcollist */ - case 259: /* sclp */ + case 246: /* selcollist */ + case 260: /* sclp */ { -tSqlExprListDestroy((yypminor->yy165)); +tSqlExprListDestroy((yypminor->yy225)); } break; case 214: /* intitemlist */ case 216: /* keep */ - case 237: /* columnlist */ - case 238: /* tagitemlist1 */ - case 239: /* tagNamelist */ - case 243: /* tagitemlist */ - case 252: /* fill_opt */ - case 253: /* groupby_opt */ - case 255: /* orderby_opt */ - case 267: /* sortlist */ - case 271: /* grouplist */ -{ -taosArrayDestroy((yypminor->yy165)); + case 238: /* columnlist */ + case 239: /* tagitemlist1 */ + case 240: /* tagNamelist */ + case 244: /* tagitemlist */ + case 253: /* fill_opt */ + case 254: /* groupby_opt */ + case 256: /* orderby_opt */ + case 268: /* sortlist */ + case 272: /* grouplist */ +{ +taosArrayDestroy((yypminor->yy225)); } break; - case 235: /* create_table_list */ + case 236: /* create_table_list */ { -destroyCreateTableSql((yypminor->yy326)); +destroyCreateTableSql((yypminor->yy482)); } break; - case 240: /* select */ + case 241: /* select */ { -destroySqlNode((yypminor->yy278)); +destroySqlNode((yypminor->yy185)); } break; - case 246: /* from */ - case 263: /* tablelist */ - case 264: /* sub */ + case 247: /* from */ + case 264: /* tablelist */ + case 265: /* sub */ { -destroyRelationInfo((yypminor->yy10)); +destroyRelationInfo((yypminor->yy160)); } break; - case 247: /* where_opt */ - case 254: /* having_opt */ - case 261: /* expr */ - case 272: /* expritem */ + case 248: /* where_opt */ + case 255: /* having_opt */ + case 262: /* expr */ + case 273: /* expritem */ { -tSqlExprDestroy((yypminor->yy202)); +tSqlExprDestroy((yypminor->yy226)); } break; - case 258: /* union */ + case 259: /* union */ { -destroyAllSqlNode((yypminor->yy503)); +destroyAllSqlNode((yypminor->yy93)); } break; - case 268: /* sortitem */ + case 269: /* sortitem */ { -taosVariantDestroy(&(yypminor->yy425)); +taosVariantDestroy(&(yypminor->yy1)); } break; /********* End destructor definitions *****************************************/ @@ -1656,13 +1678,12 @@ int ParseCoverage(FILE *out){ ** Find the appropriate action for a parser given the terminal ** look-ahead token iLookAhead. */ -static unsigned int yy_find_shift_action( - yyParser *pParser, /* The parser */ - YYCODETYPE iLookAhead /* The look-ahead token */ +static YYACTIONTYPE yy_find_shift_action( + YYCODETYPE iLookAhead, /* The look-ahead token */ + YYACTIONTYPE stateno /* Current state number */ ){ int i; - int stateno = pParser->yytos->stateno; - + if( stateno>YY_MAX_SHIFT ) return stateno; assert( stateno <= YY_SHIFT_COUNT ); #if defined(YYCOVERAGE) @@ -1670,11 +1691,12 @@ static unsigned int yy_find_shift_action( #endif do{ i = yy_shift_ofst[stateno]; - assert( i>=0 && i+YYNTOKEN<=sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) ); + assert( i>=0 ); + /* assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); */ assert( iLookAhead!=YYNOCODE ); assert( iLookAhead < YYNTOKEN ); i += iLookAhead; - if( yy_lookahead[i]!=iLookAhead ){ + if( i>=YY_NLOOKAHEAD || yy_lookahead[i]!=iLookAhead ){ #ifdef YYFALLBACK YYCODETYPE iFallback; /* Fallback token */ if( iLookAhead=YY_ACTTAB_COUNT j0 ){ #ifndef NDEBUG @@ -1724,8 +1747,8 @@ static unsigned int yy_find_shift_action( ** Find the appropriate action for a parser given the non-terminal ** look-ahead token iLookAhead. */ -static int yy_find_reduce_action( - int stateno, /* Current state number */ +static YYACTIONTYPE yy_find_reduce_action( + YYACTIONTYPE stateno, /* Current state number */ YYCODETYPE iLookAhead /* The look-ahead token */ ){ int i; @@ -1754,7 +1777,8 @@ static int yy_find_reduce_action( ** The following routine is called if the stack overflows. */ static void yyStackOverflow(yyParser *yypParser){ - ParseARG_FETCH; + ParseARG_FETCH + ParseCTX_FETCH #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); @@ -1765,7 +1789,8 @@ static void yyStackOverflow(yyParser *yypParser){ ** stack every overflows */ /******** Begin %stack_overflow code ******************************************/ /******** End %stack_overflow code ********************************************/ - ParseARG_STORE; /* Suppress warning about unused %extra_argument var */ + ParseARG_STORE /* Suppress warning about unused %extra_argument var */ + ParseCTX_STORE } /* @@ -1794,8 +1819,8 @@ static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){ */ static void yy_shift( yyParser *yypParser, /* The parser to be shifted */ - int yyNewState, /* The new state to shift in */ - int yyMajor, /* The major token to shift in */ + YYACTIONTYPE yyNewState, /* The new state to shift in */ + YYCODETYPE yyMajor, /* The major token to shift in */ ParseTOKENTYPE yyMinor /* The minor token to shift in */ ){ yyStackEntry *yytos; @@ -1825,8 +1850,8 @@ static void yy_shift( yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; } yytos = yypParser->yytos; - yytos->stateno = (YYACTIONTYPE)yyNewState; - yytos->major = (YYCODETYPE)yyMajor; + yytos->stateno = yyNewState; + yytos->major = yyMajor; yytos->minor.yy0 = yyMinor; yyTraceShift(yypParser, yyNewState, "Shift"); } @@ -1941,205 +1966,207 @@ static const struct { { 229, -2 }, /* (100) update ::= UPDATE INTEGER */ { 230, -2 }, /* (101) cachelast ::= CACHELAST INTEGER */ { 231, -2 }, /* (102) vgroups ::= VGROUPS INTEGER */ - { 202, 0 }, /* (103) db_optr ::= */ - { 202, -2 }, /* (104) db_optr ::= db_optr cache */ - { 202, -2 }, /* (105) db_optr ::= db_optr replica */ - { 202, -2 }, /* (106) db_optr ::= db_optr quorum */ - { 202, -2 }, /* (107) db_optr ::= db_optr days */ - { 202, -2 }, /* (108) db_optr ::= db_optr minrows */ - { 202, -2 }, /* (109) db_optr ::= db_optr maxrows */ - { 202, -2 }, /* (110) db_optr ::= db_optr blocks */ - { 202, -2 }, /* (111) db_optr ::= db_optr ctime */ - { 202, -2 }, /* (112) db_optr ::= db_optr wal */ - { 202, -2 }, /* (113) db_optr ::= db_optr fsync */ - { 202, -2 }, /* (114) db_optr ::= db_optr comp */ - { 202, -2 }, /* (115) db_optr ::= db_optr prec */ - { 202, -2 }, /* (116) db_optr ::= db_optr keep */ - { 202, -2 }, /* (117) db_optr ::= db_optr update */ - { 202, -2 }, /* (118) db_optr ::= db_optr cachelast */ - { 202, -2 }, /* (119) db_optr ::= db_optr vgroups */ - { 198, 0 }, /* (120) alter_db_optr ::= */ - { 198, -2 }, /* (121) alter_db_optr ::= alter_db_optr replica */ - { 198, -2 }, /* (122) alter_db_optr ::= alter_db_optr quorum */ - { 198, -2 }, /* (123) alter_db_optr ::= alter_db_optr keep */ - { 198, -2 }, /* (124) alter_db_optr ::= alter_db_optr blocks */ - { 198, -2 }, /* (125) alter_db_optr ::= alter_db_optr comp */ - { 198, -2 }, /* (126) alter_db_optr ::= alter_db_optr update */ - { 198, -2 }, /* (127) alter_db_optr ::= alter_db_optr cachelast */ - { 203, -1 }, /* (128) typename ::= ids */ - { 203, -4 }, /* (129) typename ::= ids LP signed RP */ - { 203, -2 }, /* (130) typename ::= ids UNSIGNED */ - { 232, -1 }, /* (131) signed ::= INTEGER */ - { 232, -2 }, /* (132) signed ::= PLUS INTEGER */ - { 232, -2 }, /* (133) signed ::= MINUS INTEGER */ - { 193, -3 }, /* (134) cmd ::= CREATE TABLE create_table_args */ - { 193, -3 }, /* (135) cmd ::= CREATE TABLE create_stable_args */ - { 193, -3 }, /* (136) cmd ::= CREATE STABLE create_stable_args */ - { 193, -3 }, /* (137) cmd ::= CREATE TABLE create_table_list */ - { 235, -1 }, /* (138) create_table_list ::= create_from_stable */ - { 235, -2 }, /* (139) create_table_list ::= create_table_list create_from_stable */ - { 233, -6 }, /* (140) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - { 234, -10 }, /* (141) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - { 236, -10 }, /* (142) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */ - { 236, -13 }, /* (143) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ - { 239, -3 }, /* (144) tagNamelist ::= tagNamelist COMMA ids */ - { 239, -1 }, /* (145) tagNamelist ::= ids */ - { 233, -5 }, /* (146) create_table_args ::= ifnotexists ids cpxName AS select */ - { 237, -3 }, /* (147) columnlist ::= columnlist COMMA column */ - { 237, -1 }, /* (148) columnlist ::= column */ - { 241, -2 }, /* (149) column ::= ids typename */ - { 238, -3 }, /* (150) tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ - { 238, -1 }, /* (151) tagitemlist1 ::= tagitem1 */ - { 242, -2 }, /* (152) tagitem1 ::= MINUS INTEGER */ - { 242, -2 }, /* (153) tagitem1 ::= MINUS FLOAT */ - { 242, -2 }, /* (154) tagitem1 ::= PLUS INTEGER */ - { 242, -2 }, /* (155) tagitem1 ::= PLUS FLOAT */ - { 242, -1 }, /* (156) tagitem1 ::= INTEGER */ - { 242, -1 }, /* (157) tagitem1 ::= FLOAT */ - { 242, -1 }, /* (158) tagitem1 ::= STRING */ - { 242, -1 }, /* (159) tagitem1 ::= BOOL */ - { 242, -1 }, /* (160) tagitem1 ::= NULL */ - { 242, -1 }, /* (161) tagitem1 ::= NOW */ - { 243, -3 }, /* (162) tagitemlist ::= tagitemlist COMMA tagitem */ - { 243, -1 }, /* (163) tagitemlist ::= tagitem */ - { 244, -1 }, /* (164) tagitem ::= INTEGER */ - { 244, -1 }, /* (165) tagitem ::= FLOAT */ - { 244, -1 }, /* (166) tagitem ::= STRING */ - { 244, -1 }, /* (167) tagitem ::= BOOL */ - { 244, -1 }, /* (168) tagitem ::= NULL */ - { 244, -1 }, /* (169) tagitem ::= NOW */ - { 244, -2 }, /* (170) tagitem ::= MINUS INTEGER */ - { 244, -2 }, /* (171) tagitem ::= MINUS FLOAT */ - { 244, -2 }, /* (172) tagitem ::= PLUS INTEGER */ - { 244, -2 }, /* (173) tagitem ::= PLUS FLOAT */ - { 240, -14 }, /* (174) select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ - { 240, -3 }, /* (175) select ::= LP select RP */ - { 258, -1 }, /* (176) union ::= select */ - { 258, -4 }, /* (177) union ::= union UNION ALL select */ - { 258, -3 }, /* (178) union ::= union UNION select */ - { 193, -1 }, /* (179) cmd ::= union */ - { 240, -2 }, /* (180) select ::= SELECT selcollist */ - { 259, -2 }, /* (181) sclp ::= selcollist COMMA */ - { 259, 0 }, /* (182) sclp ::= */ - { 245, -4 }, /* (183) selcollist ::= sclp distinct expr as */ - { 245, -2 }, /* (184) selcollist ::= sclp STAR */ - { 262, -2 }, /* (185) as ::= AS ids */ - { 262, -1 }, /* (186) as ::= ids */ - { 262, 0 }, /* (187) as ::= */ - { 260, -1 }, /* (188) distinct ::= DISTINCT */ - { 260, 0 }, /* (189) distinct ::= */ - { 246, -2 }, /* (190) from ::= FROM tablelist */ - { 246, -2 }, /* (191) from ::= FROM sub */ - { 264, -3 }, /* (192) sub ::= LP union RP */ - { 264, -4 }, /* (193) sub ::= LP union RP ids */ - { 264, -6 }, /* (194) sub ::= sub COMMA LP union RP ids */ - { 263, -2 }, /* (195) tablelist ::= ids cpxName */ - { 263, -3 }, /* (196) tablelist ::= ids cpxName ids */ - { 263, -4 }, /* (197) tablelist ::= tablelist COMMA ids cpxName */ - { 263, -5 }, /* (198) tablelist ::= tablelist COMMA ids cpxName ids */ - { 265, -1 }, /* (199) tmvar ::= VARIABLE */ - { 248, -4 }, /* (200) interval_option ::= intervalKey LP tmvar RP */ - { 248, -6 }, /* (201) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ - { 248, 0 }, /* (202) interval_option ::= */ - { 266, -1 }, /* (203) intervalKey ::= INTERVAL */ - { 266, -1 }, /* (204) intervalKey ::= EVERY */ - { 250, 0 }, /* (205) session_option ::= */ - { 250, -7 }, /* (206) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - { 251, 0 }, /* (207) windowstate_option ::= */ - { 251, -4 }, /* (208) windowstate_option ::= STATE_WINDOW LP ids RP */ - { 252, 0 }, /* (209) fill_opt ::= */ - { 252, -6 }, /* (210) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - { 252, -4 }, /* (211) fill_opt ::= FILL LP ID RP */ - { 249, -4 }, /* (212) sliding_opt ::= SLIDING LP tmvar RP */ - { 249, 0 }, /* (213) sliding_opt ::= */ - { 255, 0 }, /* (214) orderby_opt ::= */ - { 255, -3 }, /* (215) orderby_opt ::= ORDER BY sortlist */ - { 267, -4 }, /* (216) sortlist ::= sortlist COMMA item sortorder */ - { 267, -2 }, /* (217) sortlist ::= item sortorder */ - { 269, -2 }, /* (218) item ::= ids cpxName */ - { 270, -1 }, /* (219) sortorder ::= ASC */ - { 270, -1 }, /* (220) sortorder ::= DESC */ - { 270, 0 }, /* (221) sortorder ::= */ - { 253, 0 }, /* (222) groupby_opt ::= */ - { 253, -3 }, /* (223) groupby_opt ::= GROUP BY grouplist */ - { 271, -3 }, /* (224) grouplist ::= grouplist COMMA item */ - { 271, -1 }, /* (225) grouplist ::= item */ - { 254, 0 }, /* (226) having_opt ::= */ - { 254, -2 }, /* (227) having_opt ::= HAVING expr */ - { 257, 0 }, /* (228) limit_opt ::= */ - { 257, -2 }, /* (229) limit_opt ::= LIMIT signed */ - { 257, -4 }, /* (230) limit_opt ::= LIMIT signed OFFSET signed */ - { 257, -4 }, /* (231) limit_opt ::= LIMIT signed COMMA signed */ - { 256, 0 }, /* (232) slimit_opt ::= */ - { 256, -2 }, /* (233) slimit_opt ::= SLIMIT signed */ - { 256, -4 }, /* (234) slimit_opt ::= SLIMIT signed SOFFSET signed */ - { 256, -4 }, /* (235) slimit_opt ::= SLIMIT signed COMMA signed */ - { 247, 0 }, /* (236) where_opt ::= */ - { 247, -2 }, /* (237) where_opt ::= WHERE expr */ - { 261, -3 }, /* (238) expr ::= LP expr RP */ - { 261, -1 }, /* (239) expr ::= ID */ - { 261, -3 }, /* (240) expr ::= ID DOT ID */ - { 261, -3 }, /* (241) expr ::= ID DOT STAR */ - { 261, -1 }, /* (242) expr ::= INTEGER */ - { 261, -2 }, /* (243) expr ::= MINUS INTEGER */ - { 261, -2 }, /* (244) expr ::= PLUS INTEGER */ - { 261, -1 }, /* (245) expr ::= FLOAT */ - { 261, -2 }, /* (246) expr ::= MINUS FLOAT */ - { 261, -2 }, /* (247) expr ::= PLUS FLOAT */ - { 261, -1 }, /* (248) expr ::= STRING */ - { 261, -1 }, /* (249) expr ::= NOW */ - { 261, -1 }, /* (250) expr ::= VARIABLE */ - { 261, -2 }, /* (251) expr ::= PLUS VARIABLE */ - { 261, -2 }, /* (252) expr ::= MINUS VARIABLE */ - { 261, -1 }, /* (253) expr ::= BOOL */ - { 261, -1 }, /* (254) expr ::= NULL */ - { 261, -4 }, /* (255) expr ::= ID LP exprlist RP */ - { 261, -4 }, /* (256) expr ::= ID LP STAR RP */ - { 261, -3 }, /* (257) expr ::= expr IS NULL */ - { 261, -4 }, /* (258) expr ::= expr IS NOT NULL */ - { 261, -3 }, /* (259) expr ::= expr LT expr */ - { 261, -3 }, /* (260) expr ::= expr GT expr */ - { 261, -3 }, /* (261) expr ::= expr LE expr */ - { 261, -3 }, /* (262) expr ::= expr GE expr */ - { 261, -3 }, /* (263) expr ::= expr NE expr */ - { 261, -3 }, /* (264) expr ::= expr EQ expr */ - { 261, -5 }, /* (265) expr ::= expr BETWEEN expr AND expr */ - { 261, -3 }, /* (266) expr ::= expr AND expr */ - { 261, -3 }, /* (267) expr ::= expr OR expr */ - { 261, -3 }, /* (268) expr ::= expr PLUS expr */ - { 261, -3 }, /* (269) expr ::= expr MINUS expr */ - { 261, -3 }, /* (270) expr ::= expr STAR expr */ - { 261, -3 }, /* (271) expr ::= expr SLASH expr */ - { 261, -3 }, /* (272) expr ::= expr REM expr */ - { 261, -3 }, /* (273) expr ::= expr LIKE expr */ - { 261, -3 }, /* (274) expr ::= expr MATCH expr */ - { 261, -3 }, /* (275) expr ::= expr NMATCH expr */ - { 261, -5 }, /* (276) expr ::= expr IN LP exprlist RP */ - { 200, -3 }, /* (277) exprlist ::= exprlist COMMA expritem */ - { 200, -1 }, /* (278) exprlist ::= expritem */ - { 272, -1 }, /* (279) expritem ::= expr */ - { 272, 0 }, /* (280) expritem ::= */ - { 193, -3 }, /* (281) cmd ::= RESET QUERY CACHE */ - { 193, -3 }, /* (282) cmd ::= SYNCDB ids REPLICA */ - { 193, -7 }, /* (283) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - { 193, -7 }, /* (284) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - { 193, -7 }, /* (285) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - { 193, -7 }, /* (286) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - { 193, -7 }, /* (287) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - { 193, -8 }, /* (288) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - { 193, -9 }, /* (289) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - { 193, -7 }, /* (290) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - { 193, -7 }, /* (291) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - { 193, -7 }, /* (292) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - { 193, -7 }, /* (293) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - { 193, -7 }, /* (294) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - { 193, -7 }, /* (295) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - { 193, -8 }, /* (296) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - { 193, -9 }, /* (297) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - { 193, -7 }, /* (298) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - { 193, -3 }, /* (299) cmd ::= KILL CONNECTION INTEGER */ - { 193, -5 }, /* (300) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - { 193, -5 }, /* (301) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + { 232, -3 }, /* (103) stream_mode ::= STREAM MODE INTEGER */ + { 202, 0 }, /* (104) db_optr ::= */ + { 202, -2 }, /* (105) db_optr ::= db_optr cache */ + { 202, -2 }, /* (106) db_optr ::= db_optr replica */ + { 202, -2 }, /* (107) db_optr ::= db_optr quorum */ + { 202, -2 }, /* (108) db_optr ::= db_optr days */ + { 202, -2 }, /* (109) db_optr ::= db_optr minrows */ + { 202, -2 }, /* (110) db_optr ::= db_optr maxrows */ + { 202, -2 }, /* (111) db_optr ::= db_optr blocks */ + { 202, -2 }, /* (112) db_optr ::= db_optr ctime */ + { 202, -2 }, /* (113) db_optr ::= db_optr wal */ + { 202, -2 }, /* (114) db_optr ::= db_optr fsync */ + { 202, -2 }, /* (115) db_optr ::= db_optr comp */ + { 202, -2 }, /* (116) db_optr ::= db_optr prec */ + { 202, -2 }, /* (117) db_optr ::= db_optr keep */ + { 202, -2 }, /* (118) db_optr ::= db_optr update */ + { 202, -2 }, /* (119) db_optr ::= db_optr cachelast */ + { 202, -2 }, /* (120) db_optr ::= db_optr vgroups */ + { 202, -2 }, /* (121) db_optr ::= db_optr stream_mode */ + { 198, 0 }, /* (122) alter_db_optr ::= */ + { 198, -2 }, /* (123) alter_db_optr ::= alter_db_optr replica */ + { 198, -2 }, /* (124) alter_db_optr ::= alter_db_optr quorum */ + { 198, -2 }, /* (125) alter_db_optr ::= alter_db_optr keep */ + { 198, -2 }, /* (126) alter_db_optr ::= alter_db_optr blocks */ + { 198, -2 }, /* (127) alter_db_optr ::= alter_db_optr comp */ + { 198, -2 }, /* (128) alter_db_optr ::= alter_db_optr update */ + { 198, -2 }, /* (129) alter_db_optr ::= alter_db_optr cachelast */ + { 203, -1 }, /* (130) typename ::= ids */ + { 203, -4 }, /* (131) typename ::= ids LP signed RP */ + { 203, -2 }, /* (132) typename ::= ids UNSIGNED */ + { 233, -1 }, /* (133) signed ::= INTEGER */ + { 233, -2 }, /* (134) signed ::= PLUS INTEGER */ + { 233, -2 }, /* (135) signed ::= MINUS INTEGER */ + { 193, -3 }, /* (136) cmd ::= CREATE TABLE create_table_args */ + { 193, -3 }, /* (137) cmd ::= CREATE TABLE create_stable_args */ + { 193, -3 }, /* (138) cmd ::= CREATE STABLE create_stable_args */ + { 193, -3 }, /* (139) cmd ::= CREATE TABLE create_table_list */ + { 236, -1 }, /* (140) create_table_list ::= create_from_stable */ + { 236, -2 }, /* (141) create_table_list ::= create_table_list create_from_stable */ + { 234, -6 }, /* (142) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + { 235, -10 }, /* (143) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + { 237, -10 }, /* (144) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */ + { 237, -13 }, /* (145) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ + { 240, -3 }, /* (146) tagNamelist ::= tagNamelist COMMA ids */ + { 240, -1 }, /* (147) tagNamelist ::= ids */ + { 234, -5 }, /* (148) create_table_args ::= ifnotexists ids cpxName AS select */ + { 238, -3 }, /* (149) columnlist ::= columnlist COMMA column */ + { 238, -1 }, /* (150) columnlist ::= column */ + { 242, -2 }, /* (151) column ::= ids typename */ + { 239, -3 }, /* (152) tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ + { 239, -1 }, /* (153) tagitemlist1 ::= tagitem1 */ + { 243, -2 }, /* (154) tagitem1 ::= MINUS INTEGER */ + { 243, -2 }, /* (155) tagitem1 ::= MINUS FLOAT */ + { 243, -2 }, /* (156) tagitem1 ::= PLUS INTEGER */ + { 243, -2 }, /* (157) tagitem1 ::= PLUS FLOAT */ + { 243, -1 }, /* (158) tagitem1 ::= INTEGER */ + { 243, -1 }, /* (159) tagitem1 ::= FLOAT */ + { 243, -1 }, /* (160) tagitem1 ::= STRING */ + { 243, -1 }, /* (161) tagitem1 ::= BOOL */ + { 243, -1 }, /* (162) tagitem1 ::= NULL */ + { 243, -1 }, /* (163) tagitem1 ::= NOW */ + { 244, -3 }, /* (164) tagitemlist ::= tagitemlist COMMA tagitem */ + { 244, -1 }, /* (165) tagitemlist ::= tagitem */ + { 245, -1 }, /* (166) tagitem ::= INTEGER */ + { 245, -1 }, /* (167) tagitem ::= FLOAT */ + { 245, -1 }, /* (168) tagitem ::= STRING */ + { 245, -1 }, /* (169) tagitem ::= BOOL */ + { 245, -1 }, /* (170) tagitem ::= NULL */ + { 245, -1 }, /* (171) tagitem ::= NOW */ + { 245, -2 }, /* (172) tagitem ::= MINUS INTEGER */ + { 245, -2 }, /* (173) tagitem ::= MINUS FLOAT */ + { 245, -2 }, /* (174) tagitem ::= PLUS INTEGER */ + { 245, -2 }, /* (175) tagitem ::= PLUS FLOAT */ + { 241, -14 }, /* (176) select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ + { 241, -3 }, /* (177) select ::= LP select RP */ + { 259, -1 }, /* (178) union ::= select */ + { 259, -4 }, /* (179) union ::= union UNION ALL select */ + { 259, -3 }, /* (180) union ::= union UNION select */ + { 193, -1 }, /* (181) cmd ::= union */ + { 241, -2 }, /* (182) select ::= SELECT selcollist */ + { 260, -2 }, /* (183) sclp ::= selcollist COMMA */ + { 260, 0 }, /* (184) sclp ::= */ + { 246, -4 }, /* (185) selcollist ::= sclp distinct expr as */ + { 246, -2 }, /* (186) selcollist ::= sclp STAR */ + { 263, -2 }, /* (187) as ::= AS ids */ + { 263, -1 }, /* (188) as ::= ids */ + { 263, 0 }, /* (189) as ::= */ + { 261, -1 }, /* (190) distinct ::= DISTINCT */ + { 261, 0 }, /* (191) distinct ::= */ + { 247, -2 }, /* (192) from ::= FROM tablelist */ + { 247, -2 }, /* (193) from ::= FROM sub */ + { 265, -3 }, /* (194) sub ::= LP union RP */ + { 265, -4 }, /* (195) sub ::= LP union RP ids */ + { 265, -6 }, /* (196) sub ::= sub COMMA LP union RP ids */ + { 264, -2 }, /* (197) tablelist ::= ids cpxName */ + { 264, -3 }, /* (198) tablelist ::= ids cpxName ids */ + { 264, -4 }, /* (199) tablelist ::= tablelist COMMA ids cpxName */ + { 264, -5 }, /* (200) tablelist ::= tablelist COMMA ids cpxName ids */ + { 266, -1 }, /* (201) tmvar ::= VARIABLE */ + { 249, -4 }, /* (202) interval_option ::= intervalKey LP tmvar RP */ + { 249, -6 }, /* (203) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ + { 249, 0 }, /* (204) interval_option ::= */ + { 267, -1 }, /* (205) intervalKey ::= INTERVAL */ + { 267, -1 }, /* (206) intervalKey ::= EVERY */ + { 251, 0 }, /* (207) session_option ::= */ + { 251, -7 }, /* (208) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + { 252, 0 }, /* (209) windowstate_option ::= */ + { 252, -4 }, /* (210) windowstate_option ::= STATE_WINDOW LP ids RP */ + { 253, 0 }, /* (211) fill_opt ::= */ + { 253, -6 }, /* (212) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + { 253, -4 }, /* (213) fill_opt ::= FILL LP ID RP */ + { 250, -4 }, /* (214) sliding_opt ::= SLIDING LP tmvar RP */ + { 250, 0 }, /* (215) sliding_opt ::= */ + { 256, 0 }, /* (216) orderby_opt ::= */ + { 256, -3 }, /* (217) orderby_opt ::= ORDER BY sortlist */ + { 268, -4 }, /* (218) sortlist ::= sortlist COMMA item sortorder */ + { 268, -2 }, /* (219) sortlist ::= item sortorder */ + { 270, -2 }, /* (220) item ::= ids cpxName */ + { 271, -1 }, /* (221) sortorder ::= ASC */ + { 271, -1 }, /* (222) sortorder ::= DESC */ + { 271, 0 }, /* (223) sortorder ::= */ + { 254, 0 }, /* (224) groupby_opt ::= */ + { 254, -3 }, /* (225) groupby_opt ::= GROUP BY grouplist */ + { 272, -3 }, /* (226) grouplist ::= grouplist COMMA item */ + { 272, -1 }, /* (227) grouplist ::= item */ + { 255, 0 }, /* (228) having_opt ::= */ + { 255, -2 }, /* (229) having_opt ::= HAVING expr */ + { 258, 0 }, /* (230) limit_opt ::= */ + { 258, -2 }, /* (231) limit_opt ::= LIMIT signed */ + { 258, -4 }, /* (232) limit_opt ::= LIMIT signed OFFSET signed */ + { 258, -4 }, /* (233) limit_opt ::= LIMIT signed COMMA signed */ + { 257, 0 }, /* (234) slimit_opt ::= */ + { 257, -2 }, /* (235) slimit_opt ::= SLIMIT signed */ + { 257, -4 }, /* (236) slimit_opt ::= SLIMIT signed SOFFSET signed */ + { 257, -4 }, /* (237) slimit_opt ::= SLIMIT signed COMMA signed */ + { 248, 0 }, /* (238) where_opt ::= */ + { 248, -2 }, /* (239) where_opt ::= WHERE expr */ + { 262, -3 }, /* (240) expr ::= LP expr RP */ + { 262, -1 }, /* (241) expr ::= ID */ + { 262, -3 }, /* (242) expr ::= ID DOT ID */ + { 262, -3 }, /* (243) expr ::= ID DOT STAR */ + { 262, -1 }, /* (244) expr ::= INTEGER */ + { 262, -2 }, /* (245) expr ::= MINUS INTEGER */ + { 262, -2 }, /* (246) expr ::= PLUS INTEGER */ + { 262, -1 }, /* (247) expr ::= FLOAT */ + { 262, -2 }, /* (248) expr ::= MINUS FLOAT */ + { 262, -2 }, /* (249) expr ::= PLUS FLOAT */ + { 262, -1 }, /* (250) expr ::= STRING */ + { 262, -1 }, /* (251) expr ::= NOW */ + { 262, -1 }, /* (252) expr ::= VARIABLE */ + { 262, -2 }, /* (253) expr ::= PLUS VARIABLE */ + { 262, -2 }, /* (254) expr ::= MINUS VARIABLE */ + { 262, -1 }, /* (255) expr ::= BOOL */ + { 262, -1 }, /* (256) expr ::= NULL */ + { 262, -4 }, /* (257) expr ::= ID LP exprlist RP */ + { 262, -4 }, /* (258) expr ::= ID LP STAR RP */ + { 262, -3 }, /* (259) expr ::= expr IS NULL */ + { 262, -4 }, /* (260) expr ::= expr IS NOT NULL */ + { 262, -3 }, /* (261) expr ::= expr LT expr */ + { 262, -3 }, /* (262) expr ::= expr GT expr */ + { 262, -3 }, /* (263) expr ::= expr LE expr */ + { 262, -3 }, /* (264) expr ::= expr GE expr */ + { 262, -3 }, /* (265) expr ::= expr NE expr */ + { 262, -3 }, /* (266) expr ::= expr EQ expr */ + { 262, -5 }, /* (267) expr ::= expr BETWEEN expr AND expr */ + { 262, -3 }, /* (268) expr ::= expr AND expr */ + { 262, -3 }, /* (269) expr ::= expr OR expr */ + { 262, -3 }, /* (270) expr ::= expr PLUS expr */ + { 262, -3 }, /* (271) expr ::= expr MINUS expr */ + { 262, -3 }, /* (272) expr ::= expr STAR expr */ + { 262, -3 }, /* (273) expr ::= expr SLASH expr */ + { 262, -3 }, /* (274) expr ::= expr REM expr */ + { 262, -3 }, /* (275) expr ::= expr LIKE expr */ + { 262, -3 }, /* (276) expr ::= expr MATCH expr */ + { 262, -3 }, /* (277) expr ::= expr NMATCH expr */ + { 262, -5 }, /* (278) expr ::= expr IN LP exprlist RP */ + { 200, -3 }, /* (279) exprlist ::= exprlist COMMA expritem */ + { 200, -1 }, /* (280) exprlist ::= expritem */ + { 273, -1 }, /* (281) expritem ::= expr */ + { 273, 0 }, /* (282) expritem ::= */ + { 193, -3 }, /* (283) cmd ::= RESET QUERY CACHE */ + { 193, -3 }, /* (284) cmd ::= SYNCDB ids REPLICA */ + { 193, -7 }, /* (285) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + { 193, -7 }, /* (286) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + { 193, -7 }, /* (287) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + { 193, -7 }, /* (288) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + { 193, -7 }, /* (289) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + { 193, -8 }, /* (290) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + { 193, -9 }, /* (291) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + { 193, -7 }, /* (292) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + { 193, -7 }, /* (293) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + { 193, -7 }, /* (294) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + { 193, -7 }, /* (295) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + { 193, -7 }, /* (296) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + { 193, -7 }, /* (297) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + { 193, -8 }, /* (298) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + { 193, -9 }, /* (299) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + { 193, -7 }, /* (300) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + { 193, -3 }, /* (301) cmd ::= KILL CONNECTION INTEGER */ + { 193, -5 }, /* (302) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + { 193, -5 }, /* (303) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2154,17 +2181,18 @@ static void yy_accept(yyParser*); /* Forward Declaration */ ** only called from one place, optimizing compilers will in-line it, which ** means that the extra parameters have no performance impact. */ -static void yy_reduce( +static YYACTIONTYPE yy_reduce( yyParser *yypParser, /* The parser */ unsigned int yyruleno, /* Number of the rule by which to reduce */ int yyLookahead, /* Lookahead token, or YYNOCODE if none */ ParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */ + ParseCTX_PDECL /* %extra_context */ ){ int yygoto; /* The next state */ - int yyact; /* The next action */ + YYACTIONTYPE yyact; /* The next action */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ - ParseARG_FETCH; + ParseARG_FETCH (void)yyLookahead; (void)yyLookaheadToken; yymsp = yypParser->yytos; @@ -2195,13 +2223,19 @@ static void yy_reduce( #if YYSTACKDEPTH>0 if( yypParser->yytos>=yypParser->yystackEnd ){ yyStackOverflow(yypParser); - return; + /* The call to yyStackOverflow() above pops the stack until it is + ** empty, causing the main parser loop to exit. So the return value + ** is never used and does not matter. */ + return 0; } #else if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ if( yyGrowStack(yypParser) ){ yyStackOverflow(yypParser); - return; + /* The call to yyStackOverflow() above pops the stack until it is + ** empty, causing the main parser loop to exit. So the return value + ** is never used and does not matter. */ + return 0; } yymsp = yypParser->yytos; } @@ -2220,9 +2254,9 @@ static void yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* program ::= cmd */ - case 134: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==134); - case 135: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==135); - case 136: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==136); + case 136: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==136); + case 137: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==137); + case 138: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==138); {} break; case 1: /* cmd ::= SHOW DATABASES */ @@ -2398,16 +2432,16 @@ static void yy_reduce( { setDCLSqlElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; case 47: /* cmd ::= ALTER DATABASE ids alter_db_optr */ -{ SToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy16, &t);} +{ SToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy326, &t);} break; case 48: /* cmd ::= ALTER ACCOUNT ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy211);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy523);} break; case 49: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy211);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy523);} break; case 50: /* cmd ::= COMPACT VNODES IN LP exprlist RP */ -{ setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy165);} +{ setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy225);} break; case 51: /* ids ::= ID */ {yylhsminor.yy0 = yymsp[0].minor.yy0; } @@ -2418,7 +2452,7 @@ static void yy_reduce( break; case 53: /* ifexists ::= */ case 55: /* ifnotexists ::= */ yytestcase(yyruleno==55); - case 189: /* distinct ::= */ yytestcase(yyruleno==189); + case 191: /* distinct ::= */ yytestcase(yyruleno==191); { yymsp[1].minor.yy0.n = 0;} break; case 54: /* ifnotexists ::= IF NOT EXISTS */ @@ -2429,16 +2463,16 @@ static void yy_reduce( { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} break; case 58: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy211);} +{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy523);} break; case 59: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ -{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy16, &yymsp[-2].minor.yy0);} +{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy326, &yymsp[-2].minor.yy0);} break; case 60: /* cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ -{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy106, &yymsp[0].minor.yy0, 1);} +{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy16, &yymsp[0].minor.yy0, 1);} break; case 61: /* cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ -{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy106, &yymsp[0].minor.yy0, 2);} +{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy16, &yymsp[0].minor.yy0, 2);} break; case 62: /* cmd ::= CREATE USER ids PASS ids */ { setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} @@ -2469,38 +2503,38 @@ static void yy_reduce( break; case 83: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { - yylhsminor.yy211.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; - yylhsminor.yy211.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; - yylhsminor.yy211.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; - yylhsminor.yy211.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; - yylhsminor.yy211.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; - yylhsminor.yy211.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy211.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy211.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; - yylhsminor.yy211.stat = yymsp[0].minor.yy0; + yylhsminor.yy523.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; + yylhsminor.yy523.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; + yylhsminor.yy523.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; + yylhsminor.yy523.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; + yylhsminor.yy523.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; + yylhsminor.yy523.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy523.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy523.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; + yylhsminor.yy523.stat = yymsp[0].minor.yy0; } - yymsp[-8].minor.yy211 = yylhsminor.yy211; + yymsp[-8].minor.yy523 = yylhsminor.yy523; break; case 84: /* intitemlist ::= intitemlist COMMA intitem */ - case 162: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==162); -{ yylhsminor.yy165 = tListItemAppend(yymsp[-2].minor.yy165, &yymsp[0].minor.yy425, -1); } - yymsp[-2].minor.yy165 = yylhsminor.yy165; + case 164: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==164); +{ yylhsminor.yy225 = tListItemAppend(yymsp[-2].minor.yy225, &yymsp[0].minor.yy1, -1); } + yymsp[-2].minor.yy225 = yylhsminor.yy225; break; case 85: /* intitemlist ::= intitem */ - case 163: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==163); -{ yylhsminor.yy165 = tListItemAppend(NULL, &yymsp[0].minor.yy425, -1); } - yymsp[0].minor.yy165 = yylhsminor.yy165; + case 165: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==165); +{ yylhsminor.yy225 = tListItemAppend(NULL, &yymsp[0].minor.yy1, -1); } + yymsp[0].minor.yy225 = yylhsminor.yy225; break; case 86: /* intitem ::= INTEGER */ - case 164: /* tagitem ::= INTEGER */ yytestcase(yyruleno==164); - case 165: /* tagitem ::= FLOAT */ yytestcase(yyruleno==165); - case 166: /* tagitem ::= STRING */ yytestcase(yyruleno==166); - case 167: /* tagitem ::= BOOL */ yytestcase(yyruleno==167); -{ toTSDBType(yymsp[0].minor.yy0.type); taosVariantCreate(&yylhsminor.yy425, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } - yymsp[0].minor.yy425 = yylhsminor.yy425; + case 166: /* tagitem ::= INTEGER */ yytestcase(yyruleno==166); + case 167: /* tagitem ::= FLOAT */ yytestcase(yyruleno==167); + case 168: /* tagitem ::= STRING */ yytestcase(yyruleno==168); + case 169: /* tagitem ::= BOOL */ yytestcase(yyruleno==169); +{ toTSDBType(yymsp[0].minor.yy0.type); taosVariantCreate(&yylhsminor.yy1, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } + yymsp[0].minor.yy1 = yylhsminor.yy1; break; case 87: /* keep ::= KEEP intitemlist */ -{ yymsp[-1].minor.yy165 = yymsp[0].minor.yy165; } +{ yymsp[-1].minor.yy225 = yymsp[0].minor.yy225; } break; case 88: /* cache ::= CACHE INTEGER */ case 89: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==89); @@ -2519,675 +2553,682 @@ static void yy_reduce( case 102: /* vgroups ::= VGROUPS INTEGER */ yytestcase(yyruleno==102); { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 103: /* db_optr ::= */ -{setDefaultCreateDbOption(&yymsp[1].minor.yy16);} + case 103: /* stream_mode ::= STREAM MODE INTEGER */ +{ yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; } break; - case 104: /* db_optr ::= db_optr cache */ -{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy16 = yylhsminor.yy16; + case 104: /* db_optr ::= */ +{setDefaultCreateDbOption(&yymsp[1].minor.yy326);} break; - case 105: /* db_optr ::= db_optr replica */ - case 121: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==121); -{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy16 = yylhsminor.yy16; + case 105: /* db_optr ::= db_optr cache */ +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy326 = yylhsminor.yy326; break; - case 106: /* db_optr ::= db_optr quorum */ - case 122: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==122); -{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy16 = yylhsminor.yy16; + case 106: /* db_optr ::= db_optr replica */ + case 123: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==123); +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy326 = yylhsminor.yy326; break; - case 107: /* db_optr ::= db_optr days */ -{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy16 = yylhsminor.yy16; + case 107: /* db_optr ::= db_optr quorum */ + case 124: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==124); +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy326 = yylhsminor.yy326; break; - case 108: /* db_optr ::= db_optr minrows */ -{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy16 = yylhsminor.yy16; + case 108: /* db_optr ::= db_optr days */ +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy326 = yylhsminor.yy326; break; - case 109: /* db_optr ::= db_optr maxrows */ -{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy16 = yylhsminor.yy16; + case 109: /* db_optr ::= db_optr minrows */ +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy326 = yylhsminor.yy326; break; - case 110: /* db_optr ::= db_optr blocks */ - case 124: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==124); -{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy16 = yylhsminor.yy16; + case 110: /* db_optr ::= db_optr maxrows */ +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy326 = yylhsminor.yy326; break; - case 111: /* db_optr ::= db_optr ctime */ -{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy16 = yylhsminor.yy16; + case 111: /* db_optr ::= db_optr blocks */ + case 126: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==126); +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy326 = yylhsminor.yy326; break; - case 112: /* db_optr ::= db_optr wal */ -{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy16 = yylhsminor.yy16; + case 112: /* db_optr ::= db_optr ctime */ +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy326 = yylhsminor.yy326; break; - case 113: /* db_optr ::= db_optr fsync */ -{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy16 = yylhsminor.yy16; + case 113: /* db_optr ::= db_optr wal */ +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy326 = yylhsminor.yy326; break; - case 114: /* db_optr ::= db_optr comp */ - case 125: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==125); -{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy16 = yylhsminor.yy16; + case 114: /* db_optr ::= db_optr fsync */ +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy326 = yylhsminor.yy326; break; - case 115: /* db_optr ::= db_optr prec */ -{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.precision = yymsp[0].minor.yy0; } - yymsp[-1].minor.yy16 = yylhsminor.yy16; + case 115: /* db_optr ::= db_optr comp */ + case 127: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==127); +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy326 = yylhsminor.yy326; break; - case 116: /* db_optr ::= db_optr keep */ - case 123: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==123); -{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.keep = yymsp[0].minor.yy165; } - yymsp[-1].minor.yy16 = yylhsminor.yy16; + case 116: /* db_optr ::= db_optr prec */ +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.precision = yymsp[0].minor.yy0; } + yymsp[-1].minor.yy326 = yylhsminor.yy326; break; - case 117: /* db_optr ::= db_optr update */ - case 126: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==126); -{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy16 = yylhsminor.yy16; + case 117: /* db_optr ::= db_optr keep */ + case 125: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==125); +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.keep = yymsp[0].minor.yy225; } + yymsp[-1].minor.yy326 = yylhsminor.yy326; break; - case 118: /* db_optr ::= db_optr cachelast */ - case 127: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==127); -{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy16 = yylhsminor.yy16; + case 118: /* db_optr ::= db_optr update */ + case 128: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==128); +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy326 = yylhsminor.yy326; break; - case 119: /* db_optr ::= db_optr vgroups */ -{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.numOfVgroups = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy16 = yylhsminor.yy16; + case 119: /* db_optr ::= db_optr cachelast */ + case 129: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==129); +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy326 = yylhsminor.yy326; + break; + case 120: /* db_optr ::= db_optr vgroups */ +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.numOfVgroups = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy326 = yylhsminor.yy326; + break; + case 121: /* db_optr ::= db_optr stream_mode */ +{ yylhsminor.yy326 = yymsp[-1].minor.yy326; yylhsminor.yy326.streamMode = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy326 = yylhsminor.yy326; break; - case 120: /* alter_db_optr ::= */ -{ setDefaultCreateDbOption(&yymsp[1].minor.yy16);} + case 122: /* alter_db_optr ::= */ +{ setDefaultCreateDbOption(&yymsp[1].minor.yy326);} break; - case 128: /* typename ::= ids */ + case 130: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; - tSetColumnType (&yylhsminor.yy106, &yymsp[0].minor.yy0); + tSetColumnType (&yylhsminor.yy16, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy106 = yylhsminor.yy106; + yymsp[0].minor.yy16 = yylhsminor.yy16; break; - case 129: /* typename ::= ids LP signed RP */ + case 131: /* typename ::= ids LP signed RP */ { - if (yymsp[-1].minor.yy207 <= 0) { + if (yymsp[-1].minor.yy61 <= 0) { yymsp[-3].minor.yy0.type = 0; - tSetColumnType(&yylhsminor.yy106, &yymsp[-3].minor.yy0); + tSetColumnType(&yylhsminor.yy16, &yymsp[-3].minor.yy0); } else { - yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy207; // negative value of name length - tSetColumnType(&yylhsminor.yy106, &yymsp[-3].minor.yy0); + yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy61; // negative value of name length + tSetColumnType(&yylhsminor.yy16, &yymsp[-3].minor.yy0); } } - yymsp[-3].minor.yy106 = yylhsminor.yy106; + yymsp[-3].minor.yy16 = yylhsminor.yy16; break; - case 130: /* typename ::= ids UNSIGNED */ + case 132: /* typename ::= ids UNSIGNED */ { yymsp[-1].minor.yy0.type = 0; yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z); - tSetColumnType (&yylhsminor.yy106, &yymsp[-1].minor.yy0); + tSetColumnType (&yylhsminor.yy16, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy106 = yylhsminor.yy106; + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 131: /* signed ::= INTEGER */ -{ yylhsminor.yy207 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[0].minor.yy207 = yylhsminor.yy207; + case 133: /* signed ::= INTEGER */ +{ yylhsminor.yy61 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[0].minor.yy61 = yylhsminor.yy61; break; - case 132: /* signed ::= PLUS INTEGER */ -{ yymsp[-1].minor.yy207 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + case 134: /* signed ::= PLUS INTEGER */ +{ yymsp[-1].minor.yy61 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 133: /* signed ::= MINUS INTEGER */ -{ yymsp[-1].minor.yy207 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} + case 135: /* signed ::= MINUS INTEGER */ +{ yymsp[-1].minor.yy61 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; - case 137: /* cmd ::= CREATE TABLE create_table_list */ -{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy326;} + case 139: /* cmd ::= CREATE TABLE create_table_list */ +{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy482;} break; - case 138: /* create_table_list ::= create_from_stable */ + case 140: /* create_table_list ::= create_from_stable */ { SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); - taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy150); + taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy184); pCreateTable->type = TSDB_SQL_CREATE_TABLE; - yylhsminor.yy326 = pCreateTable; + yylhsminor.yy482 = pCreateTable; } - yymsp[0].minor.yy326 = yylhsminor.yy326; + yymsp[0].minor.yy482 = yylhsminor.yy482; break; - case 139: /* create_table_list ::= create_table_list create_from_stable */ + case 141: /* create_table_list ::= create_table_list create_from_stable */ { - taosArrayPush(yymsp[-1].minor.yy326->childTableInfo, &yymsp[0].minor.yy150); - yylhsminor.yy326 = yymsp[-1].minor.yy326; + taosArrayPush(yymsp[-1].minor.yy482->childTableInfo, &yymsp[0].minor.yy184); + yylhsminor.yy482 = yymsp[-1].minor.yy482; } - yymsp[-1].minor.yy326 = yylhsminor.yy326; + yymsp[-1].minor.yy482 = yylhsminor.yy482; break; - case 140: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + case 142: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { - yylhsminor.yy326 = tSetCreateTableInfo(yymsp[-1].minor.yy165, NULL, NULL, TSDB_SQL_CREATE_TABLE); - setSqlInfo(pInfo, yylhsminor.yy326, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy482 = tSetCreateTableInfo(yymsp[-1].minor.yy225, NULL, NULL, TSDB_SQL_CREATE_TABLE); + setSqlInfo(pInfo, yylhsminor.yy482, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-4].minor.yy0, &yymsp[-5].minor.yy0); } - yymsp[-5].minor.yy326 = yylhsminor.yy326; + yymsp[-5].minor.yy482 = yylhsminor.yy482; break; - case 141: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + case 143: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { - yylhsminor.yy326 = tSetCreateTableInfo(yymsp[-5].minor.yy165, yymsp[-1].minor.yy165, NULL, TSDB_SQL_CREATE_STABLE); - setSqlInfo(pInfo, yylhsminor.yy326, NULL, TSDB_SQL_CREATE_STABLE); + yylhsminor.yy482 = tSetCreateTableInfo(yymsp[-5].minor.yy225, yymsp[-1].minor.yy225, NULL, TSDB_SQL_CREATE_STABLE); + setSqlInfo(pInfo, yylhsminor.yy482, NULL, TSDB_SQL_CREATE_STABLE); yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy326 = yylhsminor.yy326; + yymsp[-9].minor.yy482 = yylhsminor.yy482; break; - case 142: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */ + case 144: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; - yylhsminor.yy150 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy165, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); + yylhsminor.yy184 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy225, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy150 = yylhsminor.yy150; + yymsp[-9].minor.yy184 = yylhsminor.yy184; break; - case 143: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ + case 145: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ { yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n; - yylhsminor.yy150 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy165, yymsp[-1].minor.yy165, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); + yylhsminor.yy184 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy225, yymsp[-1].minor.yy225, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); } - yymsp[-12].minor.yy150 = yylhsminor.yy150; + yymsp[-12].minor.yy184 = yylhsminor.yy184; break; - case 144: /* tagNamelist ::= tagNamelist COMMA ids */ -{taosArrayPush(yymsp[-2].minor.yy165, &yymsp[0].minor.yy0); yylhsminor.yy165 = yymsp[-2].minor.yy165; } - yymsp[-2].minor.yy165 = yylhsminor.yy165; + case 146: /* tagNamelist ::= tagNamelist COMMA ids */ +{taosArrayPush(yymsp[-2].minor.yy225, &yymsp[0].minor.yy0); yylhsminor.yy225 = yymsp[-2].minor.yy225; } + yymsp[-2].minor.yy225 = yylhsminor.yy225; break; - case 145: /* tagNamelist ::= ids */ -{yylhsminor.yy165 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy165, &yymsp[0].minor.yy0);} - yymsp[0].minor.yy165 = yylhsminor.yy165; + case 147: /* tagNamelist ::= ids */ +{yylhsminor.yy225 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy225, &yymsp[0].minor.yy0);} + yymsp[0].minor.yy225 = yylhsminor.yy225; break; - case 146: /* create_table_args ::= ifnotexists ids cpxName AS select */ + case 148: /* create_table_args ::= ifnotexists ids cpxName AS select */ { -// yylhsminor.yy326 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy278, TSQL_CREATE_STREAM); -// setSqlInfo(pInfo, yylhsminor.yy326, NULL, TSDB_SQL_CREATE_TABLE); +// yylhsminor.yy482 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy185, TSQL_CREATE_STREAM); +// setSqlInfo(pInfo, yylhsminor.yy482, NULL, TSDB_SQL_CREATE_TABLE); // // yymsp[-3].minor.yy0.n += yymsp[-2].minor.yy0.n; // setCreatedTableName(pInfo, &yymsp[-3].minor.yy0, &yymsp[-4].minor.yy0); } - yymsp[-4].minor.yy326 = yylhsminor.yy326; + yymsp[-4].minor.yy482 = yylhsminor.yy482; break; - case 147: /* columnlist ::= columnlist COMMA column */ -{taosArrayPush(yymsp[-2].minor.yy165, &yymsp[0].minor.yy106); yylhsminor.yy165 = yymsp[-2].minor.yy165; } - yymsp[-2].minor.yy165 = yylhsminor.yy165; + case 149: /* columnlist ::= columnlist COMMA column */ +{taosArrayPush(yymsp[-2].minor.yy225, &yymsp[0].minor.yy16); yylhsminor.yy225 = yymsp[-2].minor.yy225; } + yymsp[-2].minor.yy225 = yylhsminor.yy225; break; - case 148: /* columnlist ::= column */ -{yylhsminor.yy165 = taosArrayInit(4, sizeof(SField)); taosArrayPush(yylhsminor.yy165, &yymsp[0].minor.yy106);} - yymsp[0].minor.yy165 = yylhsminor.yy165; + case 150: /* columnlist ::= column */ +{yylhsminor.yy225 = taosArrayInit(4, sizeof(SField)); taosArrayPush(yylhsminor.yy225, &yymsp[0].minor.yy16);} + yymsp[0].minor.yy225 = yylhsminor.yy225; break; - case 149: /* column ::= ids typename */ + case 151: /* column ::= ids typename */ { - tSetColumnInfo(&yylhsminor.yy106, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy106); + tSetColumnInfo(&yylhsminor.yy16, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy16); } - yymsp[-1].minor.yy106 = yylhsminor.yy106; + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 150: /* tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ -{ taosArrayPush(yymsp[-2].minor.yy165, &yymsp[0].minor.yy0); yylhsminor.yy165 = yymsp[-2].minor.yy165;} - yymsp[-2].minor.yy165 = yylhsminor.yy165; + case 152: /* tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ +{ taosArrayPush(yymsp[-2].minor.yy225, &yymsp[0].minor.yy0); yylhsminor.yy225 = yymsp[-2].minor.yy225;} + yymsp[-2].minor.yy225 = yylhsminor.yy225; break; - case 151: /* tagitemlist1 ::= tagitem1 */ -{ yylhsminor.yy165 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy165, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy165 = yylhsminor.yy165; + case 153: /* tagitemlist1 ::= tagitem1 */ +{ yylhsminor.yy225 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy225, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy225 = yylhsminor.yy225; break; - case 152: /* tagitem1 ::= MINUS INTEGER */ - case 153: /* tagitem1 ::= MINUS FLOAT */ yytestcase(yyruleno==153); - case 154: /* tagitem1 ::= PLUS INTEGER */ yytestcase(yyruleno==154); - case 155: /* tagitem1 ::= PLUS FLOAT */ yytestcase(yyruleno==155); + case 154: /* tagitem1 ::= MINUS INTEGER */ + case 155: /* tagitem1 ::= MINUS FLOAT */ yytestcase(yyruleno==155); + case 156: /* tagitem1 ::= PLUS INTEGER */ yytestcase(yyruleno==156); + case 157: /* tagitem1 ::= PLUS FLOAT */ yytestcase(yyruleno==157); { yylhsminor.yy0.n = yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n; yylhsminor.yy0.type = yymsp[0].minor.yy0.type; } yymsp[-1].minor.yy0 = yylhsminor.yy0; break; - case 156: /* tagitem1 ::= INTEGER */ - case 157: /* tagitem1 ::= FLOAT */ yytestcase(yyruleno==157); - case 158: /* tagitem1 ::= STRING */ yytestcase(yyruleno==158); - case 159: /* tagitem1 ::= BOOL */ yytestcase(yyruleno==159); - case 160: /* tagitem1 ::= NULL */ yytestcase(yyruleno==160); - case 161: /* tagitem1 ::= NOW */ yytestcase(yyruleno==161); + case 158: /* tagitem1 ::= INTEGER */ + case 159: /* tagitem1 ::= FLOAT */ yytestcase(yyruleno==159); + case 160: /* tagitem1 ::= STRING */ yytestcase(yyruleno==160); + case 161: /* tagitem1 ::= BOOL */ yytestcase(yyruleno==161); + case 162: /* tagitem1 ::= NULL */ yytestcase(yyruleno==162); + case 163: /* tagitem1 ::= NOW */ yytestcase(yyruleno==163); { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 168: /* tagitem ::= NULL */ -{ yymsp[0].minor.yy0.type = 0; taosVariantCreate(&yylhsminor.yy425, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } - yymsp[0].minor.yy425 = yylhsminor.yy425; + case 170: /* tagitem ::= NULL */ +{ yymsp[0].minor.yy0.type = 0; taosVariantCreate(&yylhsminor.yy1, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } + yymsp[0].minor.yy1 = yylhsminor.yy1; break; - case 169: /* tagitem ::= NOW */ -{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; taosVariantCreate(&yylhsminor.yy425, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type);} - yymsp[0].minor.yy425 = yylhsminor.yy425; + case 171: /* tagitem ::= NOW */ +{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; taosVariantCreate(&yylhsminor.yy1, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type);} + yymsp[0].minor.yy1 = yylhsminor.yy1; break; - case 170: /* tagitem ::= MINUS INTEGER */ - case 171: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==171); - case 172: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==172); - case 173: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==173); + case 172: /* tagitem ::= MINUS INTEGER */ + case 173: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==173); + case 174: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==174); + case 175: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==175); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; toTSDBType(yymsp[-1].minor.yy0.type); - taosVariantCreate(&yylhsminor.yy425, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type); + taosVariantCreate(&yylhsminor.yy1, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type); } - yymsp[-1].minor.yy425 = yylhsminor.yy425; + yymsp[-1].minor.yy1 = yylhsminor.yy1; break; - case 174: /* select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ + case 176: /* select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ { - yylhsminor.yy278 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy165, yymsp[-11].minor.yy10, yymsp[-10].minor.yy202, yymsp[-4].minor.yy165, yymsp[-2].minor.yy165, &yymsp[-9].minor.yy532, &yymsp[-7].minor.yy97, &yymsp[-6].minor.yy6, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy165, &yymsp[0].minor.yy367, &yymsp[-1].minor.yy367, yymsp[-3].minor.yy202); + yylhsminor.yy185 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy225, yymsp[-11].minor.yy160, yymsp[-10].minor.yy226, yymsp[-4].minor.yy225, yymsp[-2].minor.yy225, &yymsp[-9].minor.yy52, &yymsp[-7].minor.yy463, &yymsp[-6].minor.yy112, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy225, &yymsp[0].minor.yy495, &yymsp[-1].minor.yy495, yymsp[-3].minor.yy226); } - yymsp[-13].minor.yy278 = yylhsminor.yy278; + yymsp[-13].minor.yy185 = yylhsminor.yy185; break; - case 175: /* select ::= LP select RP */ -{yymsp[-2].minor.yy278 = yymsp[-1].minor.yy278;} + case 177: /* select ::= LP select RP */ +{yymsp[-2].minor.yy185 = yymsp[-1].minor.yy185;} break; - case 176: /* union ::= select */ -{ yylhsminor.yy503 = setSubclause(NULL, yymsp[0].minor.yy278); } - yymsp[0].minor.yy503 = yylhsminor.yy503; + case 178: /* union ::= select */ +{ yylhsminor.yy93 = setSubclause(NULL, yymsp[0].minor.yy185); } + yymsp[0].minor.yy93 = yylhsminor.yy93; break; - case 177: /* union ::= union UNION ALL select */ -{ yylhsminor.yy503 = appendSelectClause(yymsp[-3].minor.yy503, SQL_TYPE_UNIONALL, yymsp[0].minor.yy278); } - yymsp[-3].minor.yy503 = yylhsminor.yy503; + case 179: /* union ::= union UNION ALL select */ +{ yylhsminor.yy93 = appendSelectClause(yymsp[-3].minor.yy93, SQL_TYPE_UNIONALL, yymsp[0].minor.yy185); } + yymsp[-3].minor.yy93 = yylhsminor.yy93; break; - case 178: /* union ::= union UNION select */ -{ yylhsminor.yy503 = appendSelectClause(yymsp[-2].minor.yy503, SQL_TYPE_UNION, yymsp[0].minor.yy278); } - yymsp[-2].minor.yy503 = yylhsminor.yy503; + case 180: /* union ::= union UNION select */ +{ yylhsminor.yy93 = appendSelectClause(yymsp[-2].minor.yy93, SQL_TYPE_UNION, yymsp[0].minor.yy185); } + yymsp[-2].minor.yy93 = yylhsminor.yy93; break; - case 179: /* cmd ::= union */ -{ setSqlInfo(pInfo, yymsp[0].minor.yy503, NULL, TSDB_SQL_SELECT); } + case 181: /* cmd ::= union */ +{ setSqlInfo(pInfo, yymsp[0].minor.yy93, NULL, TSDB_SQL_SELECT); } break; - case 180: /* select ::= SELECT selcollist */ + case 182: /* select ::= SELECT selcollist */ { - yylhsminor.yy278 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy165, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + yylhsminor.yy185 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy225, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } - yymsp[-1].minor.yy278 = yylhsminor.yy278; + yymsp[-1].minor.yy185 = yylhsminor.yy185; break; - case 181: /* sclp ::= selcollist COMMA */ -{yylhsminor.yy165 = yymsp[-1].minor.yy165;} - yymsp[-1].minor.yy165 = yylhsminor.yy165; + case 183: /* sclp ::= selcollist COMMA */ +{yylhsminor.yy225 = yymsp[-1].minor.yy225;} + yymsp[-1].minor.yy225 = yylhsminor.yy225; break; - case 182: /* sclp ::= */ - case 214: /* orderby_opt ::= */ yytestcase(yyruleno==214); -{yymsp[1].minor.yy165 = 0;} + case 184: /* sclp ::= */ + case 216: /* orderby_opt ::= */ yytestcase(yyruleno==216); +{yymsp[1].minor.yy225 = 0;} break; - case 183: /* selcollist ::= sclp distinct expr as */ + case 185: /* selcollist ::= sclp distinct expr as */ { - yylhsminor.yy165 = tSqlExprListAppend(yymsp[-3].minor.yy165, yymsp[-1].minor.yy202, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); + yylhsminor.yy225 = tSqlExprListAppend(yymsp[-3].minor.yy225, yymsp[-1].minor.yy226, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } - yymsp[-3].minor.yy165 = yylhsminor.yy165; + yymsp[-3].minor.yy225 = yylhsminor.yy225; break; - case 184: /* selcollist ::= sclp STAR */ + case 186: /* selcollist ::= sclp STAR */ { tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL); - yylhsminor.yy165 = tSqlExprListAppend(yymsp[-1].minor.yy165, pNode, 0, 0); + yylhsminor.yy225 = tSqlExprListAppend(yymsp[-1].minor.yy225, pNode, 0, 0); } - yymsp[-1].minor.yy165 = yylhsminor.yy165; + yymsp[-1].minor.yy225 = yylhsminor.yy225; break; - case 185: /* as ::= AS ids */ + case 187: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 186: /* as ::= ids */ + case 188: /* as ::= ids */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 187: /* as ::= */ + case 189: /* as ::= */ { yymsp[1].minor.yy0.n = 0; } break; - case 188: /* distinct ::= DISTINCT */ + case 190: /* distinct ::= DISTINCT */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 190: /* from ::= FROM tablelist */ - case 191: /* from ::= FROM sub */ yytestcase(yyruleno==191); -{yymsp[-1].minor.yy10 = yymsp[0].minor.yy10;} + case 192: /* from ::= FROM tablelist */ + case 193: /* from ::= FROM sub */ yytestcase(yyruleno==193); +{yymsp[-1].minor.yy160 = yymsp[0].minor.yy160;} break; - case 192: /* sub ::= LP union RP */ -{yymsp[-2].minor.yy10 = addSubquery(NULL, yymsp[-1].minor.yy503, NULL);} + case 194: /* sub ::= LP union RP */ +{yymsp[-2].minor.yy160 = addSubquery(NULL, yymsp[-1].minor.yy93, NULL);} break; - case 193: /* sub ::= LP union RP ids */ -{yymsp[-3].minor.yy10 = addSubquery(NULL, yymsp[-2].minor.yy503, &yymsp[0].minor.yy0);} + case 195: /* sub ::= LP union RP ids */ +{yymsp[-3].minor.yy160 = addSubquery(NULL, yymsp[-2].minor.yy93, &yymsp[0].minor.yy0);} break; - case 194: /* sub ::= sub COMMA LP union RP ids */ -{yylhsminor.yy10 = addSubquery(yymsp[-5].minor.yy10, yymsp[-2].minor.yy503, &yymsp[0].minor.yy0);} - yymsp[-5].minor.yy10 = yylhsminor.yy10; + case 196: /* sub ::= sub COMMA LP union RP ids */ +{yylhsminor.yy160 = addSubquery(yymsp[-5].minor.yy160, yymsp[-2].minor.yy93, &yymsp[0].minor.yy0);} + yymsp[-5].minor.yy160 = yylhsminor.yy160; break; - case 195: /* tablelist ::= ids cpxName */ + case 197: /* tablelist ::= ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy10 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy160 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); } - yymsp[-1].minor.yy10 = yylhsminor.yy10; + yymsp[-1].minor.yy160 = yylhsminor.yy160; break; - case 196: /* tablelist ::= ids cpxName ids */ + case 198: /* tablelist ::= ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy10 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy160 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy10 = yylhsminor.yy10; + yymsp[-2].minor.yy160 = yylhsminor.yy160; break; - case 197: /* tablelist ::= tablelist COMMA ids cpxName */ + case 199: /* tablelist ::= tablelist COMMA ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy10 = setTableNameList(yymsp[-3].minor.yy10, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy160 = setTableNameList(yymsp[-3].minor.yy160, &yymsp[-1].minor.yy0, NULL); } - yymsp[-3].minor.yy10 = yylhsminor.yy10; + yymsp[-3].minor.yy160 = yylhsminor.yy160; break; - case 198: /* tablelist ::= tablelist COMMA ids cpxName ids */ + case 200: /* tablelist ::= tablelist COMMA ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy10 = setTableNameList(yymsp[-4].minor.yy10, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy160 = setTableNameList(yymsp[-4].minor.yy160, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-4].minor.yy10 = yylhsminor.yy10; + yymsp[-4].minor.yy160 = yylhsminor.yy160; break; - case 199: /* tmvar ::= VARIABLE */ + case 201: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 200: /* interval_option ::= intervalKey LP tmvar RP */ -{yylhsminor.yy532.interval = yymsp[-1].minor.yy0; yylhsminor.yy532.offset.n = 0; yylhsminor.yy532.token = yymsp[-3].minor.yy46;} - yymsp[-3].minor.yy532 = yylhsminor.yy532; + case 202: /* interval_option ::= intervalKey LP tmvar RP */ +{yylhsminor.yy52.interval = yymsp[-1].minor.yy0; yylhsminor.yy52.offset.n = 0; yylhsminor.yy52.token = yymsp[-3].minor.yy460;} + yymsp[-3].minor.yy52 = yylhsminor.yy52; break; - case 201: /* interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ -{yylhsminor.yy532.interval = yymsp[-3].minor.yy0; yylhsminor.yy532.offset = yymsp[-1].minor.yy0; yylhsminor.yy532.token = yymsp[-5].minor.yy46;} - yymsp[-5].minor.yy532 = yylhsminor.yy532; + case 203: /* interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ +{yylhsminor.yy52.interval = yymsp[-3].minor.yy0; yylhsminor.yy52.offset = yymsp[-1].minor.yy0; yylhsminor.yy52.token = yymsp[-5].minor.yy460;} + yymsp[-5].minor.yy52 = yylhsminor.yy52; break; - case 202: /* interval_option ::= */ -{memset(&yymsp[1].minor.yy532, 0, sizeof(yymsp[1].minor.yy532));} + case 204: /* interval_option ::= */ +{memset(&yymsp[1].minor.yy52, 0, sizeof(yymsp[1].minor.yy52));} break; - case 203: /* intervalKey ::= INTERVAL */ -{yymsp[0].minor.yy46 = TK_INTERVAL;} + case 205: /* intervalKey ::= INTERVAL */ +{yymsp[0].minor.yy460 = TK_INTERVAL;} break; - case 204: /* intervalKey ::= EVERY */ -{yymsp[0].minor.yy46 = TK_EVERY; } + case 206: /* intervalKey ::= EVERY */ +{yymsp[0].minor.yy460 = TK_EVERY; } break; - case 205: /* session_option ::= */ -{yymsp[1].minor.yy97.col.n = 0; yymsp[1].minor.yy97.gap.n = 0;} + case 207: /* session_option ::= */ +{yymsp[1].minor.yy463.col.n = 0; yymsp[1].minor.yy463.gap.n = 0;} break; - case 206: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + case 208: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - yymsp[-6].minor.yy97.col = yymsp[-4].minor.yy0; - yymsp[-6].minor.yy97.gap = yymsp[-1].minor.yy0; + yymsp[-6].minor.yy463.col = yymsp[-4].minor.yy0; + yymsp[-6].minor.yy463.gap = yymsp[-1].minor.yy0; } break; - case 207: /* windowstate_option ::= */ -{ yymsp[1].minor.yy6.col.n = 0; yymsp[1].minor.yy6.col.z = NULL;} + case 209: /* windowstate_option ::= */ +{ yymsp[1].minor.yy112.col.n = 0; yymsp[1].minor.yy112.col.z = NULL;} break; - case 208: /* windowstate_option ::= STATE_WINDOW LP ids RP */ -{ yymsp[-3].minor.yy6.col = yymsp[-1].minor.yy0; } + case 210: /* windowstate_option ::= STATE_WINDOW LP ids RP */ +{ yymsp[-3].minor.yy112.col = yymsp[-1].minor.yy0; } break; - case 209: /* fill_opt ::= */ -{ yymsp[1].minor.yy165 = 0; } + case 211: /* fill_opt ::= */ +{ yymsp[1].minor.yy225 = 0; } break; - case 210: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + case 212: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { SVariant A = {0}; toTSDBType(yymsp[-3].minor.yy0.type); taosVariantCreate(&A, yymsp[-3].minor.yy0.z, yymsp[-3].minor.yy0.n, yymsp[-3].minor.yy0.type); - tListItemInsert(yymsp[-1].minor.yy165, &A, -1, 0); - yymsp[-5].minor.yy165 = yymsp[-1].minor.yy165; + tListItemInsert(yymsp[-1].minor.yy225, &A, -1, 0); + yymsp[-5].minor.yy225 = yymsp[-1].minor.yy225; } break; - case 211: /* fill_opt ::= FILL LP ID RP */ + case 213: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); - yymsp[-3].minor.yy165 = tListItemAppendToken(NULL, &yymsp[-1].minor.yy0, -1); + yymsp[-3].minor.yy225 = tListItemAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } break; - case 212: /* sliding_opt ::= SLIDING LP tmvar RP */ + case 214: /* sliding_opt ::= SLIDING LP tmvar RP */ {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } break; - case 213: /* sliding_opt ::= */ + case 215: /* sliding_opt ::= */ {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; - case 215: /* orderby_opt ::= ORDER BY sortlist */ -{yymsp[-2].minor.yy165 = yymsp[0].minor.yy165;} + case 217: /* orderby_opt ::= ORDER BY sortlist */ +{yymsp[-2].minor.yy225 = yymsp[0].minor.yy225;} break; - case 216: /* sortlist ::= sortlist COMMA item sortorder */ + case 218: /* sortlist ::= sortlist COMMA item sortorder */ { - yylhsminor.yy165 = tListItemAppend(yymsp[-3].minor.yy165, &yymsp[-1].minor.yy425, yymsp[0].minor.yy47); + yylhsminor.yy225 = tListItemAppend(yymsp[-3].minor.yy225, &yymsp[-1].minor.yy1, yymsp[0].minor.yy40); } - yymsp[-3].minor.yy165 = yylhsminor.yy165; + yymsp[-3].minor.yy225 = yylhsminor.yy225; break; - case 217: /* sortlist ::= item sortorder */ + case 219: /* sortlist ::= item sortorder */ { - yylhsminor.yy165 = tListItemAppend(NULL, &yymsp[-1].minor.yy425, yymsp[0].minor.yy47); + yylhsminor.yy225 = tListItemAppend(NULL, &yymsp[-1].minor.yy1, yymsp[0].minor.yy40); } - yymsp[-1].minor.yy165 = yylhsminor.yy165; + yymsp[-1].minor.yy225 = yylhsminor.yy225; break; - case 218: /* item ::= ids cpxName */ + case 220: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - taosVariantCreate(&yylhsminor.yy425, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type); + taosVariantCreate(&yylhsminor.yy1, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type); } - yymsp[-1].minor.yy425 = yylhsminor.yy425; + yymsp[-1].minor.yy1 = yylhsminor.yy1; break; - case 219: /* sortorder ::= ASC */ -{ yymsp[0].minor.yy47 = TSDB_ORDER_ASC; } + case 221: /* sortorder ::= ASC */ +{ yymsp[0].minor.yy40 = TSDB_ORDER_ASC; } break; - case 220: /* sortorder ::= DESC */ -{ yymsp[0].minor.yy47 = TSDB_ORDER_DESC;} + case 222: /* sortorder ::= DESC */ +{ yymsp[0].minor.yy40 = TSDB_ORDER_DESC;} break; - case 221: /* sortorder ::= */ -{ yymsp[1].minor.yy47 = TSDB_ORDER_ASC; } + case 223: /* sortorder ::= */ +{ yymsp[1].minor.yy40 = TSDB_ORDER_ASC; } break; - case 222: /* groupby_opt ::= */ -{ yymsp[1].minor.yy165 = 0;} + case 224: /* groupby_opt ::= */ +{ yymsp[1].minor.yy225 = 0;} break; - case 223: /* groupby_opt ::= GROUP BY grouplist */ -{ yymsp[-2].minor.yy165 = yymsp[0].minor.yy165;} + case 225: /* groupby_opt ::= GROUP BY grouplist */ +{ yymsp[-2].minor.yy225 = yymsp[0].minor.yy225;} break; - case 224: /* grouplist ::= grouplist COMMA item */ + case 226: /* grouplist ::= grouplist COMMA item */ { - yylhsminor.yy165 = tListItemAppend(yymsp[-2].minor.yy165, &yymsp[0].minor.yy425, -1); + yylhsminor.yy225 = tListItemAppend(yymsp[-2].minor.yy225, &yymsp[0].minor.yy1, -1); } - yymsp[-2].minor.yy165 = yylhsminor.yy165; + yymsp[-2].minor.yy225 = yylhsminor.yy225; break; - case 225: /* grouplist ::= item */ + case 227: /* grouplist ::= item */ { - yylhsminor.yy165 = tListItemAppend(NULL, &yymsp[0].minor.yy425, -1); + yylhsminor.yy225 = tListItemAppend(NULL, &yymsp[0].minor.yy1, -1); } - yymsp[0].minor.yy165 = yylhsminor.yy165; + yymsp[0].minor.yy225 = yylhsminor.yy225; break; - case 226: /* having_opt ::= */ - case 236: /* where_opt ::= */ yytestcase(yyruleno==236); - case 280: /* expritem ::= */ yytestcase(yyruleno==280); -{yymsp[1].minor.yy202 = 0;} + case 228: /* having_opt ::= */ + case 238: /* where_opt ::= */ yytestcase(yyruleno==238); + case 282: /* expritem ::= */ yytestcase(yyruleno==282); +{yymsp[1].minor.yy226 = 0;} break; - case 227: /* having_opt ::= HAVING expr */ - case 237: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==237); -{yymsp[-1].minor.yy202 = yymsp[0].minor.yy202;} + case 229: /* having_opt ::= HAVING expr */ + case 239: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==239); +{yymsp[-1].minor.yy226 = yymsp[0].minor.yy226;} break; - case 228: /* limit_opt ::= */ - case 232: /* slimit_opt ::= */ yytestcase(yyruleno==232); -{yymsp[1].minor.yy367.limit = -1; yymsp[1].minor.yy367.offset = 0;} + case 230: /* limit_opt ::= */ + case 234: /* slimit_opt ::= */ yytestcase(yyruleno==234); +{yymsp[1].minor.yy495.limit = -1; yymsp[1].minor.yy495.offset = 0;} break; - case 229: /* limit_opt ::= LIMIT signed */ - case 233: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==233); -{yymsp[-1].minor.yy367.limit = yymsp[0].minor.yy207; yymsp[-1].minor.yy367.offset = 0;} + case 231: /* limit_opt ::= LIMIT signed */ + case 235: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==235); +{yymsp[-1].minor.yy495.limit = yymsp[0].minor.yy61; yymsp[-1].minor.yy495.offset = 0;} break; - case 230: /* limit_opt ::= LIMIT signed OFFSET signed */ -{ yymsp[-3].minor.yy367.limit = yymsp[-2].minor.yy207; yymsp[-3].minor.yy367.offset = yymsp[0].minor.yy207;} + case 232: /* limit_opt ::= LIMIT signed OFFSET signed */ +{ yymsp[-3].minor.yy495.limit = yymsp[-2].minor.yy61; yymsp[-3].minor.yy495.offset = yymsp[0].minor.yy61;} break; - case 231: /* limit_opt ::= LIMIT signed COMMA signed */ -{ yymsp[-3].minor.yy367.limit = yymsp[0].minor.yy207; yymsp[-3].minor.yy367.offset = yymsp[-2].minor.yy207;} + case 233: /* limit_opt ::= LIMIT signed COMMA signed */ +{ yymsp[-3].minor.yy495.limit = yymsp[0].minor.yy61; yymsp[-3].minor.yy495.offset = yymsp[-2].minor.yy61;} break; - case 234: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ -{yymsp[-3].minor.yy367.limit = yymsp[-2].minor.yy207; yymsp[-3].minor.yy367.offset = yymsp[0].minor.yy207;} + case 236: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ +{yymsp[-3].minor.yy495.limit = yymsp[-2].minor.yy61; yymsp[-3].minor.yy495.offset = yymsp[0].minor.yy61;} break; - case 235: /* slimit_opt ::= SLIMIT signed COMMA signed */ -{yymsp[-3].minor.yy367.limit = yymsp[0].minor.yy207; yymsp[-3].minor.yy367.offset = yymsp[-2].minor.yy207;} + case 237: /* slimit_opt ::= SLIMIT signed COMMA signed */ +{yymsp[-3].minor.yy495.limit = yymsp[0].minor.yy61; yymsp[-3].minor.yy495.offset = yymsp[-2].minor.yy61;} break; - case 238: /* expr ::= LP expr RP */ -{yylhsminor.yy202 = yymsp[-1].minor.yy202; yylhsminor.yy202->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy202->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 240: /* expr ::= LP expr RP */ +{yylhsminor.yy226 = yymsp[-1].minor.yy226; yylhsminor.yy226->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy226->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 239: /* expr ::= ID */ -{ yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} - yymsp[0].minor.yy202 = yylhsminor.yy202; + case 241: /* expr ::= ID */ +{ yylhsminor.yy226 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} + yymsp[0].minor.yy226 = yylhsminor.yy226; break; - case 240: /* expr ::= ID DOT ID */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 242: /* expr ::= ID DOT ID */ +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy226 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 241: /* expr ::= ID DOT STAR */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 243: /* expr ::= ID DOT STAR */ +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy226 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 242: /* expr ::= INTEGER */ -{ yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy202 = yylhsminor.yy202; + case 244: /* expr ::= INTEGER */ +{ yylhsminor.yy226 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy226 = yylhsminor.yy226; break; - case 243: /* expr ::= MINUS INTEGER */ - case 244: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==244); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy202 = yylhsminor.yy202; + case 245: /* expr ::= MINUS INTEGER */ + case 246: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==246); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy226 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy226 = yylhsminor.yy226; break; - case 245: /* expr ::= FLOAT */ -{ yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} - yymsp[0].minor.yy202 = yylhsminor.yy202; + case 247: /* expr ::= FLOAT */ +{ yylhsminor.yy226 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} + yymsp[0].minor.yy226 = yylhsminor.yy226; break; - case 246: /* expr ::= MINUS FLOAT */ - case 247: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==247); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} - yymsp[-1].minor.yy202 = yylhsminor.yy202; + case 248: /* expr ::= MINUS FLOAT */ + case 249: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==249); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy226 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} + yymsp[-1].minor.yy226 = yylhsminor.yy226; break; - case 248: /* expr ::= STRING */ -{ yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy202 = yylhsminor.yy202; + case 250: /* expr ::= STRING */ +{ yylhsminor.yy226 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy226 = yylhsminor.yy226; break; - case 249: /* expr ::= NOW */ -{ yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy202 = yylhsminor.yy202; + case 251: /* expr ::= NOW */ +{ yylhsminor.yy226 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy226 = yylhsminor.yy226; break; - case 250: /* expr ::= VARIABLE */ -{ yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} - yymsp[0].minor.yy202 = yylhsminor.yy202; + case 252: /* expr ::= VARIABLE */ +{ yylhsminor.yy226 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} + yymsp[0].minor.yy226 = yylhsminor.yy226; break; - case 251: /* expr ::= PLUS VARIABLE */ - case 252: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==252); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} - yymsp[-1].minor.yy202 = yylhsminor.yy202; + case 253: /* expr ::= PLUS VARIABLE */ + case 254: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==254); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy226 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} + yymsp[-1].minor.yy226 = yylhsminor.yy226; break; - case 253: /* expr ::= BOOL */ -{ yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} - yymsp[0].minor.yy202 = yylhsminor.yy202; + case 255: /* expr ::= BOOL */ +{ yylhsminor.yy226 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} + yymsp[0].minor.yy226 = yylhsminor.yy226; break; - case 254: /* expr ::= NULL */ -{ yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} - yymsp[0].minor.yy202 = yylhsminor.yy202; + case 256: /* expr ::= NULL */ +{ yylhsminor.yy226 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} + yymsp[0].minor.yy226 = yylhsminor.yy226; break; - case 255: /* expr ::= ID LP exprlist RP */ -{ tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy202 = tSqlExprCreateFunction(yymsp[-1].minor.yy165, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy202 = yylhsminor.yy202; + case 257: /* expr ::= ID LP exprlist RP */ +{ tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy226 = tSqlExprCreateFunction(yymsp[-1].minor.yy225, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy226 = yylhsminor.yy226; break; - case 256: /* expr ::= ID LP STAR RP */ -{ tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy202 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy202 = yylhsminor.yy202; + case 258: /* expr ::= ID LP STAR RP */ +{ tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy226 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy226 = yylhsminor.yy226; break; - case 257: /* expr ::= expr IS NULL */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, NULL, TK_ISNULL);} - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 259: /* expr ::= expr IS NULL */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, NULL, TK_ISNULL);} + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 258: /* expr ::= expr IS NOT NULL */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-3].minor.yy202, NULL, TK_NOTNULL);} - yymsp[-3].minor.yy202 = yylhsminor.yy202; + case 260: /* expr ::= expr IS NOT NULL */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-3].minor.yy226, NULL, TK_NOTNULL);} + yymsp[-3].minor.yy226 = yylhsminor.yy226; break; - case 259: /* expr ::= expr LT expr */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_LT);} - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 261: /* expr ::= expr LT expr */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_LT);} + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 260: /* expr ::= expr GT expr */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_GT);} - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 262: /* expr ::= expr GT expr */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_GT);} + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 261: /* expr ::= expr LE expr */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_LE);} - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 263: /* expr ::= expr LE expr */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_LE);} + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 262: /* expr ::= expr GE expr */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_GE);} - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 264: /* expr ::= expr GE expr */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_GE);} + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 263: /* expr ::= expr NE expr */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_NE);} - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 265: /* expr ::= expr NE expr */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_NE);} + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 264: /* expr ::= expr EQ expr */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_EQ);} - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 266: /* expr ::= expr EQ expr */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_EQ);} + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 265: /* expr ::= expr BETWEEN expr AND expr */ -{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy202); yylhsminor.yy202 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy202, yymsp[-2].minor.yy202, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy202, TK_LE), TK_AND);} - yymsp[-4].minor.yy202 = yylhsminor.yy202; + case 267: /* expr ::= expr BETWEEN expr AND expr */ +{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy226); yylhsminor.yy226 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy226, yymsp[-2].minor.yy226, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy226, TK_LE), TK_AND);} + yymsp[-4].minor.yy226 = yylhsminor.yy226; break; - case 266: /* expr ::= expr AND expr */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_AND);} - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 268: /* expr ::= expr AND expr */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_AND);} + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 267: /* expr ::= expr OR expr */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_OR); } - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 269: /* expr ::= expr OR expr */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_OR); } + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 268: /* expr ::= expr PLUS expr */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_PLUS); } - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 270: /* expr ::= expr PLUS expr */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_PLUS); } + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 269: /* expr ::= expr MINUS expr */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_MINUS); } - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 271: /* expr ::= expr MINUS expr */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_MINUS); } + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 270: /* expr ::= expr STAR expr */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_STAR); } - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 272: /* expr ::= expr STAR expr */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_STAR); } + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 271: /* expr ::= expr SLASH expr */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_DIVIDE);} - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 273: /* expr ::= expr SLASH expr */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_DIVIDE);} + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 272: /* expr ::= expr REM expr */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_REM); } - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 274: /* expr ::= expr REM expr */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_REM); } + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 273: /* expr ::= expr LIKE expr */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_LIKE); } - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 275: /* expr ::= expr LIKE expr */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_LIKE); } + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 274: /* expr ::= expr MATCH expr */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_MATCH); } - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 276: /* expr ::= expr MATCH expr */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_MATCH); } + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 275: /* expr ::= expr NMATCH expr */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_NMATCH); } - yymsp[-2].minor.yy202 = yylhsminor.yy202; + case 277: /* expr ::= expr NMATCH expr */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-2].minor.yy226, yymsp[0].minor.yy226, TK_NMATCH); } + yymsp[-2].minor.yy226 = yylhsminor.yy226; break; - case 276: /* expr ::= expr IN LP exprlist RP */ -{yylhsminor.yy202 = tSqlExprCreate(yymsp[-4].minor.yy202, (tSqlExpr*)yymsp[-1].minor.yy165, TK_IN); } - yymsp[-4].minor.yy202 = yylhsminor.yy202; + case 278: /* expr ::= expr IN LP exprlist RP */ +{yylhsminor.yy226 = tSqlExprCreate(yymsp[-4].minor.yy226, (tSqlExpr*)yymsp[-1].minor.yy225, TK_IN); } + yymsp[-4].minor.yy226 = yylhsminor.yy226; break; - case 277: /* exprlist ::= exprlist COMMA expritem */ -{yylhsminor.yy165 = tSqlExprListAppend(yymsp[-2].minor.yy165,yymsp[0].minor.yy202,0, 0);} - yymsp[-2].minor.yy165 = yylhsminor.yy165; + case 279: /* exprlist ::= exprlist COMMA expritem */ +{yylhsminor.yy225 = tSqlExprListAppend(yymsp[-2].minor.yy225,yymsp[0].minor.yy226,0, 0);} + yymsp[-2].minor.yy225 = yylhsminor.yy225; break; - case 278: /* exprlist ::= expritem */ -{yylhsminor.yy165 = tSqlExprListAppend(0,yymsp[0].minor.yy202,0, 0);} - yymsp[0].minor.yy165 = yylhsminor.yy165; + case 280: /* exprlist ::= expritem */ +{yylhsminor.yy225 = tSqlExprListAppend(0,yymsp[0].minor.yy226,0, 0);} + yymsp[0].minor.yy225 = yylhsminor.yy225; break; - case 279: /* expritem ::= expr */ -{yylhsminor.yy202 = yymsp[0].minor.yy202;} - yymsp[0].minor.yy202 = yylhsminor.yy202; + case 281: /* expritem ::= expr */ +{yylhsminor.yy226 = yymsp[0].minor.yy226;} + yymsp[0].minor.yy226 = yylhsminor.yy226; break; - case 281: /* cmd ::= RESET QUERY CACHE */ + case 283: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 282: /* cmd ::= SYNCDB ids REPLICA */ + case 284: /* cmd ::= SYNCDB ids REPLICA */ { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} break; - case 283: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 285: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy225, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 284: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 286: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; toTSDBType(yymsp[0].minor.yy0.type); @@ -3196,21 +3237,21 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 285: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + case 287: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy225, NULL, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 286: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 288: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_ADD_TAG, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy225, NULL, TSDB_ALTER_TABLE_ADD_TAG, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 287: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 289: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3221,7 +3262,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 288: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 290: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3235,33 +3276,33 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 289: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 291: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; toTSDBType(yymsp[-2].minor.yy0.type); SArray* A = tListItemAppendToken(NULL, &yymsp[-2].minor.yy0, -1); - A = tListItemAppend(A, &yymsp[0].minor.yy425, -1); + A = tListItemAppend(A, &yymsp[0].minor.yy1, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 290: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + case 292: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy225, NULL, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 291: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + case 293: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy225, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 292: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + case 294: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3272,21 +3313,21 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 293: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + case 295: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy225, NULL, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 294: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + case 296: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_ADD_TAG, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy225, NULL, TSDB_ALTER_TABLE_ADD_TAG, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 295: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + case 297: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3297,7 +3338,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 296: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + case 298: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3311,32 +3352,32 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 297: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + case 299: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; toTSDBType(yymsp[-2].minor.yy0.type); SArray* A = tListItemAppendToken(NULL, &yymsp[-2].minor.yy0, -1); - A = tListItemAppend(A, &yymsp[0].minor.yy425, -1); + A = tListItemAppend(A, &yymsp[0].minor.yy1, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 298: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + case 300: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy225, NULL, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 299: /* cmd ::= KILL CONNECTION INTEGER */ + case 301: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 300: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 302: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);} break; - case 301: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 303: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);} break; default: @@ -3360,6 +3401,7 @@ static void yy_reduce( yymsp->stateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yyTraceShift(yypParser, yyact, "... then shift"); + return yyact; } /* @@ -3369,7 +3411,8 @@ static void yy_reduce( static void yy_parse_failed( yyParser *yypParser /* The parser */ ){ - ParseARG_FETCH; + ParseARG_FETCH + ParseCTX_FETCH #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); @@ -3380,7 +3423,8 @@ static void yy_parse_failed( ** parser fails */ /************ Begin %parse_failure code ***************************************/ /************ End %parse_failure code *****************************************/ - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ + ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ + ParseCTX_STORE } #endif /* YYNOERRORRECOVERY */ @@ -3392,7 +3436,8 @@ static void yy_syntax_error( int yymajor, /* The major type of the error token */ ParseTOKENTYPE yyminor /* The minor type of the error token */ ){ - ParseARG_FETCH; + ParseARG_FETCH + ParseCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ @@ -3418,7 +3463,8 @@ static void yy_syntax_error( assert(len <= outputBufLen); /************ End %syntax_error code ******************************************/ - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ + ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ + ParseCTX_STORE } /* @@ -3427,7 +3473,8 @@ static void yy_syntax_error( static void yy_accept( yyParser *yypParser /* The parser */ ){ - ParseARG_FETCH; + ParseARG_FETCH + ParseCTX_FETCH #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); @@ -3442,7 +3489,8 @@ static void yy_accept( /*********** Begin %parse_accept code *****************************************/ /*********** End %parse_accept code *******************************************/ - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ + ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ + ParseCTX_STORE } /* The main parser program. @@ -3471,45 +3519,47 @@ void Parse( ParseARG_PDECL /* Optional %extra_argument parameter */ ){ YYMINORTYPE yyminorunion; - unsigned int yyact; /* The parser action. */ + YYACTIONTYPE yyact; /* The parser action. */ #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) int yyendofinput; /* True if we are at the end of input */ #endif #ifdef YYERRORSYMBOL int yyerrorhit = 0; /* True if yymajor has invoked an error */ #endif - yyParser *yypParser; /* The parser */ + yyParser *yypParser = (yyParser*)yyp; /* The parser */ + ParseCTX_FETCH + ParseARG_STORE - yypParser = (yyParser*)yyp; assert( yypParser->yytos!=0 ); #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) yyendofinput = (yymajor==0); #endif - ParseARG_STORE; + yyact = yypParser->yytos->stateno; #ifndef NDEBUG if( yyTraceFILE ){ - int stateno = yypParser->yytos->stateno; - if( stateno < YY_MIN_REDUCE ){ + if( yyact < YY_MIN_REDUCE ){ fprintf(yyTraceFILE,"%sInput '%s' in state %d\n", - yyTracePrompt,yyTokenName[yymajor],stateno); + yyTracePrompt,yyTokenName[yymajor],yyact); }else{ fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n", - yyTracePrompt,yyTokenName[yymajor],stateno-YY_MIN_REDUCE); + yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE); } } #endif do{ - yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); + assert( yyact==yypParser->yytos->stateno ); + yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); if( yyact >= YY_MIN_REDUCE ){ - yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,yyminor); + yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor, + yyminor ParseCTX_PARAM); }else if( yyact <= YY_MAX_SHIFTREDUCE ){ - yy_shift(yypParser,yyact,yymajor,yyminor); + yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt--; #endif - yymajor = YYNOCODE; + break; }else if( yyact==YY_ACCEPT_ACTION ){ yypParser->yytos--; yy_accept(yypParser); @@ -3560,10 +3610,9 @@ void Parse( yymajor = YYNOCODE; }else{ while( yypParser->yytos >= yypParser->yystack - && yymx != YYERRORSYMBOL && (yyact = yy_find_reduce_action( yypParser->yytos->stateno, - YYERRORSYMBOL)) >= YY_MIN_REDUCE + YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE ){ yy_pop_parser_stack(yypParser); } @@ -3580,6 +3629,8 @@ void Parse( } yypParser->yyerrcnt = 3; yyerrorhit = 1; + if( yymajor==YYNOCODE ) break; + yyact = yypParser->yytos->stateno; #elif defined(YYNOERRORRECOVERY) /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to ** do any kind of error recovery. Instead, simply invoke the syntax @@ -3590,8 +3641,7 @@ void Parse( */ yy_syntax_error(yypParser,yymajor, yyminor); yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); - yymajor = YYNOCODE; - + break; #else /* YYERRORSYMBOL is not defined */ /* This is what we do if the grammar does not define ERROR: ** @@ -3613,10 +3663,10 @@ void Parse( yypParser->yyerrcnt = -1; #endif } - yymajor = YYNOCODE; + break; #endif } - }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack ); + }while( yypParser->yytos>yypParser->yystack ); #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; @@ -3631,3 +3681,18 @@ void Parse( #endif return; } + +/* +** Return the fallback token corresponding to canonical token iToken, or +** 0 if iToken has no fallback. +*/ +int ParseFallback(int iToken){ +#ifdef YYFALLBACK + if( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ){ + return yyFallback[iToken]; + } +#else + (void)iToken; +#endif + return 0; +} diff --git a/source/libs/parser/src/ttokenizer.c b/source/libs/parser/src/ttokenizer.c index d5d6b11833adc287c53c6ad8a9b880b888f9803b..d54da5aa26f20168623c7a63fa67798161811e95 100644 --- a/source/libs/parser/src/ttokenizer.c +++ b/source/libs/parser/src/ttokenizer.c @@ -230,6 +230,7 @@ static SKeyword keywordTable[] = { {"PORT", TK_PORT}, {"INNER", NEW_TK_INNER}, {"ON", NEW_TK_ON}, + {"MODE", TK_MODE}, }; static const char isIdChar[] = { diff --git a/source/libs/planner/inc/plannerImpl.h b/source/libs/planner/inc/plannerImpl.h index dbfbeb7efcd62573fc6a6e96b4782f5420323a08..d89cc26700e445254e7fbc29ebb5f38e6e0dc46c 100644 --- a/source/libs/planner/inc/plannerImpl.h +++ b/source/libs/planner/inc/plannerImpl.h @@ -20,33 +20,10 @@ extern "C" { #endif -#include "querynodes.h" +#include "plannodes.h" #include "planner.h" -typedef struct SLogicNode { - ENodeType type; - int32_t id; - SNodeList* pTargets; - SNode* pConditions; - SNodeList* pChildren; - struct SLogicNode* pParent; -} SLogicNode; - -typedef struct SScanLogicNode { - SLogicNode node; - SNodeList* pScanCols; - struct STableMeta* pMeta; -} SScanLogicNode; - -typedef struct SFilterLogicNode { - SLogicNode node; -} SFilterLogicNode; - -typedef struct SAggLogicNode { - SLogicNode node; - SNodeList* pGroupKeys; - SNodeList* pAggFuncs; -} SAggLogicNode; +int32_t createLogicPlan(SNode* pNode, SLogicNode** pLogicNode); #ifdef __cplusplus } diff --git a/source/libs/planner/src/plannerImpl.c b/source/libs/planner/src/plannerImpl.c index 9b82b4d58e58409a23ba0a2d0efea432ce681474..40a82f4175de788130bfcc0462c1c77d63efd506 100644 --- a/source/libs/planner/src/plannerImpl.c +++ b/source/libs/planner/src/plannerImpl.c @@ -19,6 +19,7 @@ #define CHECK_ALLOC(p, res) \ do { \ if (NULL == p) { \ + printf("%s : %d\n", __FUNCTION__, __LINE__); \ pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY; \ return res; \ } \ @@ -28,6 +29,7 @@ do { \ int32_t code = exec; \ if (TSDB_CODE_SUCCESS != code) { \ + printf("%s : %d\n", __FUNCTION__, __LINE__); \ pCxt->errCode = code; \ return res; \ } \ @@ -39,36 +41,57 @@ typedef struct SPlanContext { SNodeList* pResource; } SPlanContext; +static SLogicNode* createQueryLogicNode(SPlanContext* pCxt, SNode* pStmt); +static SLogicNode* createLogicNodeByTable(SPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable); + typedef struct SRewriteExprCxt { int32_t errCode; - int32_t planNodeId; - SNodeList* pTargets; + SNodeList* pExprs; } SRewriteExprCxt; static EDealRes doRewriteExpr(SNode** pNode, void* pContext) { - SRewriteExprCxt* pCxt = (SRewriteExprCxt*)pContext; - SNode* pTarget; - int32_t index = 0; - FOREACH(pTarget, pCxt->pTargets) { - if (nodesEqualNode(pTarget, *pNode)) { - SColumnRefNode* pCol = (SColumnRefNode*)nodesMakeNode(QUERY_NODE_COLUMN_REF); - if (NULL == pCol) { - pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY; - return DEAL_RES_ERROR; + switch (nodeType(*pNode)) { + case QUERY_NODE_OPERATOR: + case QUERY_NODE_LOGIC_CONDITION: + case QUERY_NODE_FUNCTION: { + SRewriteExprCxt* pCxt = (SRewriteExprCxt*)pContext; + SNode* pExpr; + int32_t index = 0; + FOREACH(pExpr, pCxt->pExprs) { + if (nodesEqualNode(pExpr, *pNode)) { + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); + if (NULL == pCol) { + pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY; + return DEAL_RES_ERROR; + } + SExprNode* pToBeRewrittenExpr = (SExprNode*)(*pNode); + pCol->node.resType = pToBeRewrittenExpr->resType; + strcpy(pCol->node.aliasName, pToBeRewrittenExpr->aliasName); + strcpy(pCol->colName, ((SExprNode*)pExpr)->aliasName); + nodesDestroyNode(*pNode); + *pNode = (SNode*)pCol; + return DEAL_RES_IGNORE_CHILD; + } + ++index; } - pCol->tupleId = pCxt->planNodeId; - pCol->slotId = index; - nodesDestroyNode(*pNode); - *pNode = (SNode*)pCol; - return DEAL_RES_IGNORE_CHILD; + break; } - ++index; + default: + break; } + return DEAL_RES_CONTINUE; } -static int32_t rewriteExpr(int32_t planNodeId, SNodeList* pTargets, SSelectStmt* pSelect, ESqlClause clause) { - SRewriteExprCxt cxt = { .errCode = TSDB_CODE_SUCCESS, .planNodeId = planNodeId, .pTargets = pTargets }; +static int32_t rewriteExpr(int32_t planNodeId, int32_t rewriteId, SNodeList* pExprs, SSelectStmt* pSelect, ESqlClause clause) { + SNode* pNode; + FOREACH(pNode, pExprs) { + if (QUERY_NODE_COLUMN == nodeType(pNode) || QUERY_NODE_VALUE == nodeType(pNode)) { + continue; + } + sprintf(((SExprNode*)pNode)->aliasName, "#expr_%d_%d", planNodeId, rewriteId); + } + SRewriteExprCxt cxt = { .errCode = TSDB_CODE_SUCCESS, .pExprs = pExprs }; nodesRewriteSelectStmt(pSelect, clause, doRewriteExpr, &cxt); return cxt.errCode; } @@ -102,23 +125,6 @@ error: return pRoot; } -static SNodeList* createScanTargets(int32_t planNodeId, int32_t numOfScanCols) { - SNodeList* pTargets = nodesMakeList(); - if (NULL == pTargets) { - return NULL; - } - for (int32_t i = 0; i < numOfScanCols; ++i) { - SColumnRefNode* pCol = (SColumnRefNode*)nodesMakeNode(QUERY_NODE_COLUMN_REF); - if (NULL == pCol || TSDB_CODE_SUCCESS != nodesListAppend(pTargets, (SNode*)pCol)) { - nodesDestroyList(pTargets); - return NULL; - } - pCol->tupleId = planNodeId; - pCol->slotId = i; - } - return pTargets; -} - static SLogicNode* createScanLogicNode(SPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable) { SScanLogicNode* pScan = (SScanLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN); CHECK_ALLOC(pScan, NULL); @@ -128,24 +134,56 @@ static SLogicNode* createScanLogicNode(SPlanContext* pCxt, SSelectStmt* pSelect, // set columns to scan SNodeList* pCols = NULL; - CHECK_CODE(nodesCollectColumns(pSelect, SQL_CLAUSE_FROM, pScan->pMeta->uid, true, &pCols), (SLogicNode*)pScan); + CHECK_CODE(nodesCollectColumns(pSelect, SQL_CLAUSE_FROM, pRealTable->table.tableAlias, &pCols), (SLogicNode*)pScan); pScan->pScanCols = nodesCloneList(pCols); CHECK_ALLOC(pScan->pScanCols, (SLogicNode*)pScan); - // pScanCols of SScanLogicNode is equivalent to pTargets of other logic nodes - CHECK_CODE(rewriteExpr(pScan->node.id, pScan->pScanCols, pSelect, SQL_CLAUSE_FROM), (SLogicNode*)pScan); - // set output - pScan->node.pTargets = createScanTargets(pScan->node.id, LIST_LENGTH(pScan->pScanCols)); + pScan->node.pTargets = nodesCloneList(pCols); CHECK_ALLOC(pScan->node.pTargets, (SLogicNode*)pScan); return (SLogicNode*)pScan; } -static SLogicNode* createQueryLogicNode(SPlanContext* pCxt, SNode* pStmt); - static SLogicNode* createSubqueryLogicNode(SPlanContext* pCxt, SSelectStmt* pSelect, STempTableNode* pTable) { - return createQueryLogicNode(pCxt, pTable->pSubquery); + SLogicNode* pRoot = createQueryLogicNode(pCxt, pTable->pSubquery); + CHECK_ALLOC(pRoot, NULL); + SNode* pNode; + FOREACH(pNode, pRoot->pTargets) { + strcpy(((SColumnNode*)pNode)->tableAlias, pTable->table.tableAlias); + } + return pRoot; +} + +static SLogicNode* createJoinLogicNode(SPlanContext* pCxt, SSelectStmt* pSelect, SJoinTableNode* pJoinTable) { + SJoinLogicNode* pJoin = (SJoinLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_JOIN); + CHECK_ALLOC(pJoin, NULL); + pJoin->node.id = pCxt->planNodeId++; + + pJoin->joinType = pJoinTable->joinType; + + // set left and right node + pJoin->node.pChildren = nodesMakeList(); + CHECK_ALLOC(pJoin->node.pChildren, (SLogicNode*)pJoin); + SLogicNode* pLeft = createLogicNodeByTable(pCxt, pSelect, pJoinTable->pLeft); + CHECK_ALLOC(pLeft, (SLogicNode*)pJoin); + CHECK_CODE(nodesListAppend(pJoin->node.pChildren, (SNode*)pLeft), (SLogicNode*)pJoin); + SLogicNode* pRight = createLogicNodeByTable(pCxt, pSelect, pJoinTable->pRight); + CHECK_ALLOC(pRight, (SLogicNode*)pJoin); + CHECK_CODE(nodesListAppend(pJoin->node.pChildren, (SNode*)pRight), (SLogicNode*)pJoin); + + // set on conditions + pJoin->pOnConditions = nodesCloneNode(pJoinTable->pOnCond); + CHECK_ALLOC(pJoin->pOnConditions, (SLogicNode*)pJoin); + + // set the output + pJoin->node.pTargets = nodesCloneList(pLeft->pTargets); + CHECK_ALLOC(pJoin->node.pTargets, (SLogicNode*)pJoin); + SNodeList* pTargets = nodesCloneList(pRight->pTargets); + CHECK_ALLOC(pTargets, (SLogicNode*)pJoin); + nodesListAppendList(pJoin->node.pTargets, pTargets); + + return (SLogicNode*)pJoin; } static SLogicNode* createLogicNodeByTable(SPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable) { @@ -155,14 +193,15 @@ static SLogicNode* createLogicNodeByTable(SPlanContext* pCxt, SSelectStmt* pSele case QUERY_NODE_TEMP_TABLE: return createSubqueryLogicNode(pCxt, pSelect, (STempTableNode*)pTable); case QUERY_NODE_JOIN_TABLE: + return createJoinLogicNode(pCxt, pSelect, (SJoinTableNode*)pTable); default: break; } return NULL; } -static SLogicNode* createFilterLogicNode(SPlanContext* pCxt, SSelectStmt* pSelect, SNode* pWhere) { - if (NULL == pWhere) { +static SLogicNode* createWhereFilterLogicNode(SPlanContext* pCxt, SLogicNode* pChild, SSelectStmt* pSelect) { + if (NULL == pSelect->pWhere) { return NULL; } @@ -171,23 +210,51 @@ static SLogicNode* createFilterLogicNode(SPlanContext* pCxt, SSelectStmt* pSelec pFilter->node.id = pCxt->planNodeId++; // set filter conditions - pFilter->node.pConditions = nodesCloneNode(pWhere); + pFilter->node.pConditions = nodesCloneNode(pSelect->pWhere); CHECK_ALLOC(pFilter->node.pConditions, (SLogicNode*)pFilter); - // set the output and rewrite the expression in subsequent clauses with the output - SNodeList* pCols = NULL; - CHECK_CODE(nodesCollectColumns(pSelect, SQL_CLAUSE_WHERE, 0, false, &pCols), (SLogicNode*)pFilter); - pFilter->node.pTargets = nodesCloneList(pCols); + // set the output + pFilter->node.pTargets = nodesCloneList(pChild->pTargets); CHECK_ALLOC(pFilter->node.pTargets, (SLogicNode*)pFilter); - CHECK_CODE(rewriteExpr(pFilter->node.id, pFilter->node.pTargets, pSelect, SQL_CLAUSE_WHERE), (SLogicNode*)pFilter); return (SLogicNode*)pFilter; } -static SLogicNode* createAggLogicNode(SPlanContext* pCxt, SSelectStmt* pSelect, SNodeList* pGroupByList, SNode* pHaving) { +static SNodeList* createColumnByRewriteExps(SPlanContext* pCxt, SNodeList* pExprs) { + SNodeList* pList = nodesMakeList(); + CHECK_ALLOC(pList, NULL); + SNode* pNode; + FOREACH(pNode, pExprs) { + if (QUERY_NODE_VALUE == nodeType(pNode)) { + continue; + } else if (QUERY_NODE_COLUMN == nodeType(pNode)) { + SNode* pCol = nodesCloneNode(pNode); + if (NULL == pCol) { + goto error; + } + if (TSDB_CODE_SUCCESS != nodesListAppend(pList, pCol)) { + goto error; + } + } else { + SExprNode* pExpr = (SExprNode*)pNode; + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); + if (NULL == pCol) { + goto error; + } + pCol->node.resType = pExpr->resType; + strcpy(pCol->colName, pExpr->aliasName); + } + } + return pList; +error: + nodesDestroyList(pList); + return NULL; +} + +static SLogicNode* createAggLogicNode(SPlanContext* pCxt, SSelectStmt* pSelect) { SNodeList* pAggFuncs = NULL; CHECK_CODE(nodesCollectFuncs(pSelect, fmIsAggFunc, &pAggFuncs), NULL); - if (NULL == pAggFuncs && NULL == pGroupByList) { + if (NULL == pAggFuncs && NULL == pSelect->pGroupByList) { return NULL; } @@ -196,32 +263,74 @@ static SLogicNode* createAggLogicNode(SPlanContext* pCxt, SSelectStmt* pSelect, pAgg->node.id = pCxt->planNodeId++; // set grouyp keys, agg funcs and having conditions - pAgg->pGroupKeys = nodesCloneList(pGroupByList); + pAgg->pGroupKeys = nodesCloneList(pSelect->pGroupByList); CHECK_ALLOC(pAgg->pGroupKeys, (SLogicNode*)pAgg); pAgg->pAggFuncs = nodesCloneList(pAggFuncs); CHECK_ALLOC(pAgg->pAggFuncs, (SLogicNode*)pAgg); - pAgg->node.pConditions = nodesCloneNode(pHaving); + + // rewrite the expression in subsequent clauses + CHECK_CODE(rewriteExpr(pAgg->node.id, 1, pAgg->pGroupKeys, pSelect, SQL_CLAUSE_GROUP_BY), (SLogicNode*)pAgg); + CHECK_CODE(rewriteExpr(pAgg->node.id, 1 + LIST_LENGTH(pAgg->pGroupKeys), pAgg->pAggFuncs, pSelect, SQL_CLAUSE_GROUP_BY), (SLogicNode*)pAgg); + + pAgg->node.pConditions = nodesCloneNode(pSelect->pHaving); CHECK_ALLOC(pAgg->node.pConditions, (SLogicNode*)pAgg); - // set the output and rewrite the expression in subsequent clauses with the output - SNodeList* pCols = NULL; - CHECK_CODE(nodesCollectColumns(pSelect, SQL_CLAUSE_HAVING, 0, false, &pCols), (SLogicNode*)pAgg); - pAgg->node.pTargets = nodesCloneList(pCols); + // set the output + pAgg->node.pTargets = createColumnByRewriteExps(pCxt, pAgg->pGroupKeys); CHECK_ALLOC(pAgg->node.pTargets, (SLogicNode*)pAgg); - CHECK_CODE(rewriteExpr(pAgg->node.id, pAgg->node.pTargets, pSelect, SQL_CLAUSE_HAVING), (SLogicNode*)pAgg); - + SNodeList* pTargets = createColumnByRewriteExps(pCxt, pAgg->pAggFuncs); + CHECK_ALLOC(pTargets, (SLogicNode*)pAgg); + nodesListAppendList(pAgg->node.pTargets, pTargets); + return (SLogicNode*)pAgg; } +static SNodeList* createColumnByProjections(SPlanContext* pCxt, SNodeList* pExprs) { + SNodeList* pList = nodesMakeList(); + CHECK_ALLOC(pList, NULL); + SNode* pNode; + FOREACH(pNode, pExprs) { + SExprNode* pExpr = (SExprNode*)pNode; + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); + if (NULL == pCol) { + goto error; + } + pCol->node.resType = pExpr->resType; + strcpy(pCol->colName, pExpr->aliasName); + if (TSDB_CODE_SUCCESS != nodesListAppend(pList, (SNode*)pCol)) { + goto error; + } + } + return pList; +error: + nodesDestroyList(pList); + return NULL; +} + +static SLogicNode* createProjectLogicNode(SPlanContext* pCxt, SSelectStmt* pSelect) { + SProjectLogicNode* pProject = (SProjectLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PROJECT); + CHECK_ALLOC(pProject, NULL); + pProject->node.id = pCxt->planNodeId++; + + pProject->pProjections = nodesCloneList(pSelect->pProjectionList); + + pProject->node.pTargets = createColumnByProjections(pCxt,pSelect->pProjectionList); + CHECK_ALLOC(pProject->node.pTargets, (SLogicNode*)pProject); + + return (SLogicNode*)pProject; +} + static SLogicNode* createSelectLogicNode(SPlanContext* pCxt, SSelectStmt* pSelect) { SLogicNode* pRoot = createLogicNodeByTable(pCxt, pSelect, pSelect->pFromTable); if (TSDB_CODE_SUCCESS == pCxt->errCode) { - pRoot = pushLogicNode(pCxt, pRoot, createFilterLogicNode(pCxt, pSelect, pSelect->pWhere)); + pRoot = pushLogicNode(pCxt, pRoot, createWhereFilterLogicNode(pCxt, pRoot, pSelect)); + } + if (TSDB_CODE_SUCCESS == pCxt->errCode) { + pRoot = pushLogicNode(pCxt, pRoot, createAggLogicNode(pCxt, pSelect)); } if (TSDB_CODE_SUCCESS == pCxt->errCode) { - pRoot = pushLogicNode(pCxt, pRoot, createAggLogicNode(pCxt, pSelect, pSelect->pGroupByList, pSelect->pHaving)); + pRoot = pushLogicNode(pCxt, pRoot, createProjectLogicNode(pCxt, pSelect)); } - // pRoot = pushLogicNode(pCxt, pRoot, createProjectLogicNode(pSelect, pSelect->pProjectionList)); return pRoot; } diff --git a/source/libs/planner/test/CMakeLists.txt b/source/libs/planner/test/CMakeLists.txt index 7fbfcfe7efc31ecae16ffd3d4ad72db2cff58090..cd60b503b990e92973d1b5c99c83eeab3b312801 100644 --- a/source/libs/planner/test/CMakeLists.txt +++ b/source/libs/planner/test/CMakeLists.txt @@ -13,7 +13,7 @@ ADD_EXECUTABLE(plannerTest TARGET_LINK_LIBRARIES( plannerTest - PUBLIC os util common planner parser catalog transport gtest function qcom + PUBLIC os util common nodes planner parser catalog transport gtest function qcom ) TARGET_INCLUDE_DIRECTORIES( diff --git a/source/libs/planner/test/newPlannerTest.cpp b/source/libs/planner/test/newPlannerTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c227bf88bae7cf1b45a4c81d3b7d6061308a6af7 --- /dev/null +++ b/source/libs/planner/test/newPlannerTest.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include + +#include + +#include "plannerImpl.h" +#include "newParser.h" + +using namespace std; +using namespace testing; + +class NewPlannerTest : public Test { +protected: + void setDatabase(const string& acctId, const string& db) { + acctId_ = acctId; + db_ = db; + } + + void bind(const char* sql) { + reset(); + cxt_.acctId = atoi(acctId_.c_str()); + cxt_.db = db_.c_str(); + sqlBuf_ = string(sql); + transform(sqlBuf_.begin(), sqlBuf_.end(), sqlBuf_.begin(), ::tolower); + cxt_.sqlLen = strlen(sql); + cxt_.pSql = sqlBuf_.c_str(); + } + + bool run() { + int32_t code = parser(&cxt_, &query_); + // cout << "parser return " << code << endl; + if (code != TSDB_CODE_SUCCESS) { + cout << "sql:[" << cxt_.pSql << "] parser code:" << tstrerror(code) << ", msg:" << errMagBuf_ << endl; + return false; + } + SLogicNode* pLogicPlan = nullptr; + code = createLogicPlan(query_.pRoot, &pLogicPlan); + if (code != TSDB_CODE_SUCCESS) { + cout << "sql:[" << cxt_.pSql << "] plan code:" << tstrerror(code) << endl; + return false; + } + char* pStr = NULL; + int32_t len = 0; + code = nodesNodeToString((const SNode*)pLogicPlan, &pStr, &len); + if (code != TSDB_CODE_SUCCESS) { + cout << "sql:[" << cxt_.pSql << "] toString code:" << tstrerror(code) << endl; + return false; + } + cout << "logic plan : " << endl; + cout << pStr << endl; + return true; + } + +private: + static const int max_err_len = 1024; + + void reset() { + memset(&cxt_, 0, sizeof(cxt_)); + memset(errMagBuf_, 0, max_err_len); + cxt_.pMsg = errMagBuf_; + cxt_.msgLen = max_err_len; + } + + string acctId_; + string db_; + char errMagBuf_[max_err_len]; + string sqlBuf_; + SParseContext cxt_; + SQuery query_; +}; + +TEST_F(NewPlannerTest, simple) { + setDatabase("root", "test"); + + bind("SELECT * FROM t1"); + ASSERT_TRUE(run()); +} diff --git a/source/libs/tdb/inc/tdb.h b/source/libs/tdb/inc/tdb.h index faf9208f8f8f454cb94ba880fd14a30e17f47d24..cc0d20ef3c22ac8450421472f6585201af47cd1b 100644 --- a/source/libs/tdb/inc/tdb.h +++ b/source/libs/tdb/inc/tdb.h @@ -22,41 +22,44 @@ extern "C" { #endif -// #define TDB_EXTERN -// #define TDB_PUBLIC -// #define TDB_STATIC static +typedef struct STDb TDB; +typedef struct STDbEnv TENV; +typedef struct STDbCurosr TDBC; -// typedef enum { TDB_BTREE_T = 0, TDB_HASH_T = 1, TDB_HEAP_T = 2 } tdb_db_t; +typedef int32_t pgsz_t; +typedef int32_t cachesz_t; -// // Forward declarations -// typedef struct TDB TDB; -// // typedef struct TDB_MPOOL TDB_MPOOL; -// // typedef struct TDB_MPFILE TDB_MPFILE; -// // typedef struct TDB_CURSOR TDB_CURSOR; +typedef int (*TdbKeyCmprFn)(int keyLen1, const void *pKey1, int keyLen2, const void *pKey2); -// typedef struct { -// void* bdata; -// uint32_t size; -// } TDB_KEY, TDB_VALUE; +// TEVN +int tdbEnvCreate(TENV **ppEnv, const char *rootDir); +int tdbEnvOpen(TENV *ppEnv); +int tdbEnvClose(TENV *pEnv); -// // TDB Operations -// int tdbCreateDB(TDB** dbpp, tdb_db_t type); -// int tdbOpenDB(TDB* dbp, const char* fname, const char* dbname, uint32_t flags); -// int tdbCloseDB(TDB* dbp, uint32_t flags); -// int tdbPut(TDB* dbp, const TDB_KEY* key, const TDB_VALUE* value, uint32_t flags); -// int tdbGet(TDB* dbp, const TDB_KEY* key, TDB_VALUE* value, uint32_t flags); +int tdbEnvSetCache(TENV *pEnv, pgsz_t pgSize, cachesz_t cacheSize); +pgsz_t tdbEnvGetPageSize(TENV *pEnv); +cachesz_t tdbEnvGetCacheSize(TENV *pEnv); -// // TDB_MPOOL -// int tdbOpenMPool(TDB_MPOOL** mp); -// int tdbCloseMPool(TDB_MPOOL* mp); +int tdbEnvBeginTxn(TENV *pEnv); +int tdbEnvCommit(TENV *pEnv); -// // TDB_MPFILE -// int tdbOpenMPFile(TDB_MPFILE** mpf, TDB_MPOOL* mp); -// int tdbCloseMPFile(TDB_MPFILE** mpf); +// TDB +int tdbCreate(TDB **ppDb); +int tdbOpen(TDB *pDb, const char *fname, const char *dbname, TENV *pEnv); +int tdbClose(TDB *pDb); +int tdbDrop(TDB *pDb); -// // TDB_CURSOR -// int tdbOpenCursor(TDB* dbp, TDB_CURSOR** tdbcpp); -// int tdbCloseCurosr(TDB_CURSOR* tdbcp); +int tdbSetKeyLen(TDB *pDb, int klen); +int tdbSetValLen(TDB *pDb, int vlen); +int tdbSetDup(TDB *pDb, int dup); +int tdbSetCmprFunc(TDB *pDb, TdbKeyCmprFn fn); +int tdbGetKeyLen(TDB *pDb); +int tdbGetValLen(TDB *pDb); +int tdbGetDup(TDB *pDb); + +int tdbInsert(TDB *pDb, const void *pKey, int nKey, const void *pData, int nData); + +// TDBC #ifdef __cplusplus } diff --git a/source/libs/tdb/src/db/tdb.c b/source/libs/tdb/src/db/tdb.c new file mode 100644 index 0000000000000000000000000000000000000000..cc3b7fa6b9435c0692358ca37f8ff4aa742836d3 --- /dev/null +++ b/source/libs/tdb/src/db/tdb.c @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "tdbInt.h" + +struct STDb { + char dbname[TDB_MAX_DBNAME_LEN]; + SBTree * pBt; // current access method (may extend) + SPgFile * pPgFile; // backend page file this DB is using + TENV * pEnv; // TENV containing the DB + int klen; // key length if know + int vlen; // value length if know + bool dup; // dup mode + TdbKeyCmprFn cFn; // compare function +}; + +struct STDbCurosr { + SBtCursor *pBtCur; +}; + +static int tdbDefaultKeyCmprFn(int keyLen1, const void *pKey1, int keyLen2, const void *pKey2); + +int tdbCreate(TDB **ppDb) { + TDB *pDb; + + // create the handle + pDb = (TDB *)calloc(1, sizeof(*pDb)); + if (pDb == NULL) { + return -1; + } + + pDb->klen = TDB_VARIANT_LEN; + pDb->vlen = TDB_VARIANT_LEN; + pDb->dup = false; + pDb->cFn = tdbDefaultKeyCmprFn; + + *ppDb = pDb; + return 0; +} + +static int tdbDestroy(TDB *pDb) { + if (pDb) { + free(pDb); + } + return 0; +} + +int tdbOpen(TDB *pDb, const char *fname, const char *dbname, TENV *pEnv) { + int ret; + uint8_t fileid[TDB_FILE_ID_LEN]; + SPgFile * pPgFile; + SPgCache *pPgCache; + SBTree * pBt; + bool fileExist; + size_t dbNameLen; + pgno_t dbRootPgno; + char dbfname[128]; // TODO: make this as a macro or malloc on the heap + + ASSERT(pDb != NULL); + ASSERT(fname != NULL); + // TODO: Here we simply put an assert here. In the future, make `pEnv` + // can be set as NULL. + ASSERT(pEnv != NULL); + + // check the DB name + dbNameLen = 0; + if (dbname) { + dbNameLen = strlen(dbname); + if (dbNameLen >= TDB_MAX_DBNAME_LEN) { + return -1; + } + + memcpy(pDb->dbname, dbname, dbNameLen); + } + + pDb->dbname[dbNameLen] = '\0'; + + // get page file from the env, if not opened yet, open it + pPgFile = NULL; + snprintf(dbfname, 128, "%s/%s", tdbEnvGetRootDir(pEnv), fname); + fileExist = (tdbCheckFileAccess(fname, TDB_F_OK) == 0); + if (fileExist) { + tdbGnrtFileID(dbfname, fileid, false); + pPgFile = tdbEnvGetPageFile(pEnv, fileid); + } + + if (pPgFile == NULL) { + ret = pgFileOpen(&pPgFile, dbfname, pEnv); + if (ret != 0) { + // TODO: handle error + return -1; + } + } + + // TODO: get the root page number from the master DB of the page file + // tdbGet(&dbRootPgno); + if (dbRootPgno == 0) { + // DB not exist, create one + ret = pgFileAllocatePage(pPgFile, &dbRootPgno); + if (ret != 0) { + // TODO: handle error + } + // tdbInsert(pPgFile->pMasterDB, dbname, strlen(dbname), &dbRootPgno, sizeof(dbRootPgno)); + } + + ASSERT(dbRootPgno > 1); + + // pDb->pBt->root = dbRootPgno; + + // register + pDb->pPgFile = pPgFile; + tdbEnvRgstDB(pEnv, pDb); + pDb->pEnv = pEnv; + + return 0; +} + +int tdbClose(TDB *pDb) { + if (pDb == NULL) return 0; + return tdbDestroy(pDb); +} + +int tdbDrop(TDB *pDb) { + // TODO + return 0; +} + +int tdbSetKeyLen(TDB *pDb, int klen) { + // TODO: check `klen` + pDb->klen = klen; + return 0; +} + +int tdbSetValLen(TDB *pDb, int vlen) { + // TODO: check `vlen` + pDb->vlen = vlen; + return 0; +} + +int tdbSetDup(TDB *pDb, int dup) { + if (dup) { + pDb->dup = true; + } else { + pDb->dup = false; + } + return 0; +} + +int tdbSetCmprFunc(TDB *pDb, TdbKeyCmprFn fn) { + if (fn == NULL) { + return -1; + } else { + pDb->cFn = fn; + } + return 0; +} + +int tdbGetKeyLen(TDB *pDb) { return pDb->klen; } + +int tdbGetValLen(TDB *pDb) { return pDb->vlen; } + +int tdbGetDup(TDB *pDb) { + if (pDb->dup) { + return 1; + } else { + return 0; + } +} + +int tdbInsert(TDB *pDb, const void *pKey, int nKey, const void *pData, int nData) { + // TODO + return 0; +} + +static int tdbDefaultKeyCmprFn(int keyLen1, const void *pKey1, int keyLen2, const void *pKey2) { + int mlen; + int cret; + + ASSERT(keyLen1 > 0 && keyLen2 > 0 && pKey1 != NULL && pKey2 != NULL); + + mlen = keyLen1 < keyLen2 ? keyLen1 : keyLen2; + cret = memcmp(pKey1, pKey2, mlen); + if (cret == 0) { + if (keyLen1 < keyLen2) { + cret = -1; + } else if (keyLen1 > keyLen2) { + cret = 1; + } else { + cret = 0; + } + } + return cret; +} \ No newline at end of file diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c new file mode 100644 index 0000000000000000000000000000000000000000..86e7980733f39baa393cc45d87cedf755593900e --- /dev/null +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "tdbInt.h" + +struct SBtCursor { + SBTree *pBtree; + pgno_t pgno; + SPage * pPage; // current page traversing +}; + +typedef struct { + pgno_t pgno; + pgsz_t offset; +} SBtIdx; + +// Btree page header definition +typedef struct __attribute__((__packed__)) { + uint8_t flag; // page flag + int32_t vlen; // value length of current page, TDB_VARIANT_LEN for variant length + uint16_t nPayloads; // number of total payloads + pgoff_t freeOff; // free payload offset + pgsz_t fragSize; // total fragment size + pgoff_t offPayload; // payload offset + pgno_t rChildPgno; // right most child page number +} SBtPgHdr; + +typedef int (*BtreeCmprFn)(const void *, const void *); + +#define BTREE_PAGE_HDR(pPage) NULL /* TODO */ +#define BTREE_PAGE_PAYLOAD_AT(pPage, idx) NULL /*TODO*/ +#define BTREE_PAGE_IS_LEAF(pPage) 0 /* TODO */ + +static int btreeCreate(SBTree **ppBt); +static int btreeDestroy(SBTree *pBt); +static int btreeCursorMoveToChild(SBtCursor *pBtCur, pgno_t pgno); + +int btreeOpen(SBTree **ppBt, SPgFile *pPgFile) { + SBTree *pBt; + int ret; + + ret = btreeCreate(&pBt); + if (ret != 0) { + return -1; + } + + *ppBt = pBt; + return 0; +} + +int btreeClose(SBTree *pBt) { + // TODO + return 0; +} + +static int btreeCreate(SBTree **ppBt) { + SBTree *pBt; + + pBt = (SBTree *)calloc(1, sizeof(*pBt)); + if (pBt == NULL) { + return -1; + } + + // TODO + return 0; +} + +static int btreeDestroy(SBTree *pBt) { + if (pBt) { + free(pBt); + } + return 0; +} + +int btreeCursorOpen(SBtCursor *pBtCur, SBTree *pBt) { + // TODO + return 0; +} + +int btreeCursorClose(SBtCursor *pBtCur) { + // TODO + return 0; +} + +int btreeCursorMoveTo(SBtCursor *pBtCur, int kLen, const void *pKey) { + SPage * pPage; + SBtPgHdr * pBtPgHdr; + SPgFile * pPgFile; + pgno_t childPgno; + pgno_t rootPgno; + int nPayloads; + void * pPayload; + BtreeCmprFn cmpFn; + + // 1. Move the cursor to the root page + if (rootPgno == TDB_IVLD_PGNO) { + // No any data in this btree, just return not found (TODO) + return 0; + } else { + // Load the page from the file by the SPgFile handle + pPage = pgFileFetch(pPgFile, rootPgno); + + pBtCur->pPage = pPage; + } + + // 2. Loop to search over the whole tree + for (;;) { + int lidx, ridx, midx, cret; + + pPage = pBtCur->pPage; + pBtPgHdr = BTREE_PAGE_HDR(pPage); + nPayloads = pBtPgHdr->nPayloads; + + // Binary search the page + lidx = 0; + ridx = nPayloads - 1; + midx = (lidx + ridx) >> 1; + for (;;) { + // get the payload ptr at midx + pPayload = BTREE_PAGE_PAYLOAD_AT(pPage, midx); + + // the payload and the key + cret = cmpFn(pKey, pPayload); + + if (cret < 0) { + /* TODO */ + } else if (cret > 0) { + /* TODO */ + } else { + /* TODO */ + } + + if (lidx > ridx) break; + midx = (lidx + ridx) >> 1; + } + if (BTREE_PAGE_IS_LEAF(pPage)) { + /* TODO */ + break; + } else { + /* TODO */ + btreeCursorMoveToChild(pBtCur, childPgno); + } + } + + return 0; +} + +static int btreeCursorMoveToChild(SBtCursor *pBtCur, pgno_t pgno) { + SPgFile *pPgFile; + // TODO + return 0; +} \ No newline at end of file diff --git a/source/libs/tdb/src/db/tdbEnv.c b/source/libs/tdb/src/db/tdbEnv.c new file mode 100644 index 0000000000000000000000000000000000000000..3670c770abd520fdee6cd8c21d82f3c0939150db --- /dev/null +++ b/source/libs/tdb/src/db/tdbEnv.c @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "tdbInt.h" + +struct STDbEnv { + char * rootDir; // root directory of the environment + char * jname; // journal file name + int jfd; // journal file fd + pgsz_t pgSize; // page size + cachesz_t cacheSize; // total cache size + STDbList dbList; // TDB List + SPgFileList pgfList; // SPgFile List + SPgCache * pPgCache; // page cache + struct { +#define TDB_ENV_PGF_HASH_BUCKETS 17 + SPgFileList buckets[TDB_ENV_PGF_HASH_BUCKETS]; + } pgfht; // page file hash table; +}; + +#define TDB_ENV_PGF_HASH(fileid) \ + ({ \ + uint8_t *tmp = (uint8_t *)(fileid); \ + tmp[0] + tmp[1] + tmp[2]; \ + }) + +static int tdbEnvDestroy(TENV *pEnv); + +int tdbEnvCreate(TENV **ppEnv, const char *rootDir) { + TENV * pEnv; + size_t slen; + size_t jlen; + + ASSERT(rootDir != NULL); + + *ppEnv = NULL; + slen = strlen(rootDir); + jlen = slen + strlen(TDB_JOURNAL_NAME) + 1; + pEnv = (TENV *)calloc(1, sizeof(*pEnv) + slen + 1 + jlen + 1); + if (pEnv == NULL) { + return -1; + } + + pEnv->rootDir = (char *)(&pEnv[1]); + pEnv->jname = pEnv->rootDir + slen + 1; + pEnv->jfd = -1; + pEnv->pgSize = TDB_DEFAULT_PGSIZE; + pEnv->cacheSize = TDB_DEFAULT_CACHE_SIZE; + + memcpy(pEnv->rootDir, rootDir, slen); + pEnv->rootDir[slen] = '\0'; + sprintf(pEnv->jname, "%s/%s", rootDir, TDB_JOURNAL_NAME); + + TD_DLIST_INIT(&(pEnv->dbList)); + TD_DLIST_INIT(&(pEnv->pgfList)); + + /* TODO */ + + *ppEnv = pEnv; + return 0; +} + +int tdbEnvOpen(TENV *pEnv) { + SPgCache *pPgCache; + int ret; + + ASSERT(pEnv != NULL); + + /* TODO: here we do not need to create the root directory, more + * work should be done here + */ + mkdir(pEnv->rootDir, 0755); + + ret = pgCacheOpen(&pPgCache, pEnv); + if (ret != 0) { + goto _err; + } + + pEnv->pPgCache = pPgCache; + return 0; + +_err: + return -1; +} + +int tdbEnvClose(TENV *pEnv) { + if (pEnv == NULL) return 0; + pgCacheClose(pEnv->pPgCache); + tdbEnvDestroy(pEnv); + return 0; +} + +int tdbEnvSetCache(TENV *pEnv, pgsz_t pgSize, cachesz_t cacheSize) { + if (!TDB_IS_PGSIZE_VLD(pgSize) || cacheSize / pgSize < 10) { + return -1; + } + + /* TODO */ + + pEnv->pgSize = pgSize; + pEnv->cacheSize = cacheSize; + + return 0; +} + +pgsz_t tdbEnvGetPageSize(TENV *pEnv) { return pEnv->pgSize; } + +cachesz_t tdbEnvGetCacheSize(TENV *pEnv) { return pEnv->cacheSize; } + +SPgFile *tdbEnvGetPageFile(TENV *pEnv, const uint8_t fileid[]) { + SPgFileList *pBucket; + SPgFile * pPgFile; + + pBucket = pEnv->pgfht.buckets + (TDB_ENV_PGF_HASH(fileid) % TDB_ENV_PGF_HASH_BUCKETS); // TODO + for (pPgFile = TD_DLIST_HEAD(pBucket); pPgFile != NULL; pPgFile = TD_DLIST_NODE_NEXT_WITH_FIELD(pPgFile, envHash)) { + if (memcmp(fileid, pPgFile->fileid, TDB_FILE_ID_LEN) == 0) break; + }; + + return pPgFile; +} + +SPgCache *tdbEnvGetPgCache(TENV *pEnv) { return pEnv->pPgCache; } + +static int tdbEnvDestroy(TENV *pEnv) { + // TODO + return 0; +} + +int tdbEnvBeginTxn(TENV *pEnv) { + pEnv->jfd = open(pEnv->jname, O_CREAT | O_RDWR, 0755); + if (pEnv->jfd < 0) { + return -1; + } + + return 0; +} + +int tdbEnvCommit(TENV *pEnv) { + /* TODO */ + close(pEnv->jfd); + pEnv->jfd = -1; + return 0; +} + +const char *tdbEnvGetRootDir(TENV *pEnv) { return pEnv->rootDir; } + +int tdbEnvRgstPageFile(TENV *pEnv, SPgFile *pPgFile) { + SPgFileList *pBucket; + + TD_DLIST_APPEND_WITH_FIELD(&(pEnv->pgfList), pPgFile, envPgfList); + + pBucket = pEnv->pgfht.buckets + (TDB_ENV_PGF_HASH(pPgFile->fileid) % TDB_ENV_PGF_HASH_BUCKETS); // TODO + TD_DLIST_APPEND_WITH_FIELD(pBucket, pPgFile, envHash); + + return 0; +} + +int tdbEnvRgstDB(TENV *pEnv, TDB *pDb) { + // TODO + return 0; +} \ No newline at end of file diff --git a/source/libs/tdb/src/db/tdb_mpool.c b/source/libs/tdb/src/db/tdbPgCache.c similarity index 58% rename from source/libs/tdb/src/db/tdb_mpool.c rename to source/libs/tdb/src/db/tdbPgCache.c index 9b67f405a92781b709cd237335a85120cf8b0b78..1b000aa6d6f85dd983b0d60a3c2565990cfd815e 100644 --- a/source/libs/tdb/src/db/tdb_mpool.c +++ b/source/libs/tdb/src/db/tdbPgCache.c @@ -12,10 +12,225 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +#include "tdbInt.h" + +typedef TD_DLIST(SPage) SPgList; +struct SPgCache { + TENV * pEnv; // TENV containing this page cache + pgsz_t pgsize; + int32_t npage; + SPage **pages; + SPgList freeList; + SPgList lru; + struct { + int32_t nbucket; + SPgList *buckets; + } pght; // page hash table +}; + +static void pgCachePinPage(SPage *pPage); +static void pgCacheUnpinPage(SPage *pPage); + +int pgCacheOpen(SPgCache **ppPgCache, TENV *pEnv) { + SPgCache *pPgCache; + SPage * pPage; + void * pData; + pgsz_t pgSize; + cachesz_t cacheSize; + int32_t npage; + int32_t nbucket; + size_t msize; + + *ppPgCache = NULL; + pgSize = tdbEnvGetPageSize(pEnv); + cacheSize = tdbEnvGetCacheSize(pEnv); + npage = cacheSize / pgSize; + nbucket = npage; + msize = sizeof(*pPgCache) + sizeof(SPage *) * npage + sizeof(SPgList) * nbucket; + + // Allocate the handle + pPgCache = (SPgCache *)calloc(1, msize); + if (pPgCache == NULL) { + return -1; + } + + // Init the handle + pPgCache->pEnv = pEnv; + pPgCache->pgsize = pgSize; + pPgCache->npage = npage; + pPgCache->pages = (SPage **)(&pPgCache[1]); + pPgCache->pght.nbucket = nbucket; + pPgCache->pght.buckets = (SPgList *)(&(pPgCache->pages[npage])); + + TD_DLIST_INIT(&(pPgCache->freeList)); + + for (int32_t i = 0; i < npage; i++) { + pData = malloc(pgSize + sizeof(SPage)); + if (pData == NULL) { + return -1; + // TODO: handle error + } + + pPage = POINTER_SHIFT(pData, pgSize); + + pPage->pgid = TDB_IVLD_PGID; + pPage->frameid = i; + pPage->pData = pData; + + // add current page to the page cache + pPgCache->pages[i] = pPage; + TD_DLIST_APPEND_WITH_FIELD(&(pPgCache->freeList), pPage, freeNode); + } + +#if 0 + for (int32_t i = 0; i < nbucket; i++) { + TD_DLIST_INIT(pPgCache->pght.buckets + i); + } +#endif + + *ppPgCache = pPgCache; + return 0; +} + +int pgCacheClose(SPgCache *pPgCache) { + SPage *pPage; + if (pPgCache) { + for (int32_t i = 0; i < pPgCache->npage; i++) { + pPage = pPgCache->pages[i]; + tfree(pPage->pData); + } + + free(pPgCache); + } + + return 0; +} + +#define PG_CACHE_HASH(fileid, pgno) \ + ({ \ + uint64_t *tmp = (uint64_t *)(fileid); \ + (tmp[0] + tmp[1] + tmp[2] + (pgno)); \ + }) + +SPage *pgCacheFetch(SPgCache *pPgCache, pgid_t pgid) { + SPage * pPage; + SPgFile *pPgFile; + SPgList *pBucket; + + // 1. Search the page hash table SPgCache.pght + pBucket = pPgCache->pght.buckets + (PG_CACHE_HASH(pgid.fileid, pgid.pgno) % pPgCache->pght.nbucket); + pPage = TD_DLIST_HEAD(pBucket); + while (pPage && tdbCmprPgId(&(pPage->pgid), &pgid)) { + pPage = TD_DLIST_NODE_NEXT_WITH_FIELD(pPage, pghtNode); + } -#include "tdb_mpool.h" + if (pPage) { + // Page is found, pin the page and return the page + pgCachePinPage(pPage); + return pPage; + } + + // 2. Check the free list + pPage = TD_DLIST_HEAD(&(pPgCache->freeList)); + if (pPage) { + TD_DLIST_POP_WITH_FIELD(&(pPgCache->freeList), pPage, freeNode); + pgCachePinPage(pPage); + return pPage; + } + + // 3. Try to recycle a page from the LRU list + pPage = TD_DLIST_HEAD(&(pPgCache->lru)); + if (pPage) { + TD_DLIST_POP_WITH_FIELD(&(pPgCache->lru), pPage, lruNode); + // TODO: remove from the hash table + pgCachePinPage(pPage); + return pPage; + } + + // 4. If a memory allocator is set, try to allocate from the allocator (TODO) + + return NULL; +} + +int pgCacheRelease(SPage *pPage) { + // TODO + return 0; +} + +static void pgCachePinPage(SPage *pPage) { + // TODO +} + +static void pgCacheUnpinPage(SPage *pPage) { + // TODO +} + +#if 0 +// Exposed handle +typedef struct TDB_MPOOL TDB_MPOOL; +typedef struct TDB_MPFILE TDB_MPFILE; + +typedef TD_DLIST_NODE(pg_t) pg_free_dlist_node_t, pg_hash_dlist_node_t; +typedef struct pg_t { + SRWLatch rwLatch; + frame_id_t frameid; + pgid_t pgid; + uint8_t dirty; + uint8_t rbit; + int32_t pinRef; + pg_free_dlist_node_t free; + pg_hash_dlist_node_t hash; + void * p; +} pg_t; + +typedef TD_DLIST(pg_t) pg_list_t; +typedef struct { + SRWLatch latch; + TD_DLIST(TDB_MPFILE); +} mpf_bucket_t; +struct TDB_MPOOL { + int64_t cachesize; + pgsz_t pgsize; + int32_t npages; + pg_t * pages; + pg_list_t freeList; + frame_id_t clockHand; + struct { + int32_t nbucket; + pg_list_t *hashtab; + } pgtab; // page table, hash + struct { +#define MPF_HASH_BUCKETS 16 + mpf_bucket_t buckets[MPF_HASH_BUCKETS]; + } mpfht; // MPF hash table. MPFs using this MP will be put in this hash table +}; + +#define MP_PAGE_AT(mp, idx) (mp)->pages[idx] + +typedef TD_DLIST_NODE(TDB_MPFILE) td_mpf_dlist_node_t; +struct TDB_MPFILE { + char * fname; // file name + int fd; // fd + uint8_t fileid[TDB_FILE_ID_LEN]; // file ID + TDB_MPOOL * mp; // underlying memory pool + td_mpf_dlist_node_t node; +}; + +/*=================================================== Exposed apis ==================================================*/ +// TDB_MPOOL +int tdbMPoolOpen(TDB_MPOOL **mpp, uint64_t cachesize, pgsz_t pgsize); +int tdbMPoolClose(TDB_MPOOL *mp); +int tdbMPoolSync(TDB_MPOOL *mp); + +// TDB_MPFILE +int tdbMPoolFileOpen(TDB_MPFILE **mpfp, const char *fname, TDB_MPOOL *mp); +int tdbMPoolFileClose(TDB_MPFILE *mpf); +int tdbMPoolFileNewPage(TDB_MPFILE *mpf, pgno_t *pgno, void *addr); +int tdbMPoolFileFreePage(TDB_MPOOL *mpf, pgno_t *pgno, void *addr); +int tdbMPoolFileGetPage(TDB_MPFILE *mpf, pgno_t pgno, void *addr); +int tdbMPoolFilePutPage(TDB_MPFILE *mpf, pgno_t pgno, void *addr); +int tdbMPoolFileSync(TDB_MPFILE *mpf); -static int tdbGnrtFileID(const char *fname, uint8_t *fileid); static void tdbMPoolRegFile(TDB_MPOOL *mp, TDB_MPFILE *mpf); static void tdbMPoolUnregFile(TDB_MPOOL *mp, TDB_MPFILE *mpf); static TDB_MPFILE *tdbMPoolGetFile(TDB_MPOOL *mp, uint8_t *fileid); @@ -23,7 +238,7 @@ static int tdbMPoolFileReadPage(TDB_MPFILE *mpf, pgno_t pgno, void *p); static int tdbMPoolFileWritePage(TDB_MPFILE *mpf, pgno_t pgno, const void *p); static void tdbMPoolClockEvictPage(TDB_MPOOL *mp, pg_t **pagepp); -int tdbMPoolOpen(TDB_MPOOL **mpp, uint64_t cachesize, pgsize_t pgsize) { +int tdbMPoolOpen(TDB_MPOOL **mpp, uint64_t cachesize, pgsz_t pgsize) { TDB_MPOOL *mp = NULL; size_t tsize; pg_t * pagep; @@ -120,7 +335,7 @@ int tdbMPoolFileOpen(TDB_MPFILE **mpfp, const char *fname, TDB_MPOOL *mp) { goto _err; } - if (tdbGnrtFileID(fname, mpf->fileid) < 0) { + if (tdbGnrtFileID(fname, mpf->fileid, false) < 0) { goto _err; } @@ -230,22 +445,6 @@ int tdbMPoolFilePutPage(TDB_MPFILE *mpf, pgno_t pgno, void *addr) { return 0; } -static int tdbGnrtFileID(const char *fname, uint8_t *fileid) { - struct stat statbuf; - - if (stat(fname, &statbuf) < 0) { - return -1; - } - - memset(fileid, 0, TDB_FILE_ID_LEN); - - ((uint64_t *)fileid)[0] = (uint64_t)statbuf.st_ino; - ((uint64_t *)fileid)[1] = (uint64_t)statbuf.st_dev; - ((uint64_t *)fileid)[2] = rand(); - - return 0; -} - #define MPF_GET_BUCKETID(fileid) \ ({ \ uint64_t *tmp = (uint64_t *)fileid; \ @@ -317,7 +516,7 @@ static void tdbMPoolUnregFile(TDB_MPOOL *mp, TDB_MPFILE *mpf) { } static int tdbMPoolFileReadPage(TDB_MPFILE *mpf, pgno_t pgno, void *p) { - pgsize_t pgsize; + pgsz_t pgsize; TDB_MPOOL *mp; off_t offset; size_t rsize; @@ -334,7 +533,7 @@ static int tdbMPoolFileReadPage(TDB_MPFILE *mpf, pgno_t pgno, void *p) { } static int tdbMPoolFileWritePage(TDB_MPFILE *mpf, pgno_t pgno, const void *p) { - pgsize_t pgsize; + pgsz_t pgsize; TDB_MPOOL *mp; off_t offset; @@ -376,4 +575,6 @@ static void tdbMPoolClockEvictPage(TDB_MPOOL *mp, pg_t **pagepp) { } while (1); *pagepp = pagep; -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/source/libs/tdb/src/db/tdbPgFile.c b/source/libs/tdb/src/db/tdbPgFile.c new file mode 100644 index 0000000000000000000000000000000000000000..ee5b486f7b75d42ec87178da0de7603c21aebaf8 --- /dev/null +++ b/source/libs/tdb/src/db/tdbPgFile.c @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "tdbInt.h" + +typedef struct SPage1 { + char magic[64]; + pgno_t mdbRootPgno; // master DB root page number + pgno_t freePgno; // free list page number + uint32_t nFree; // number of free pages +} SPage1; + +typedef struct SFreePage { + /* TODO */ +} SFreePage; + +TDB_STATIC_ASSERT(sizeof(SPage1) <= TDB_MIN_PGSIZE, "TDB Page1 definition too large"); + +static int pgFileRead(SPgFile *pPgFile, pgno_t pgno, uint8_t *pData); + +int pgFileOpen(SPgFile **ppPgFile, const char *fname, TENV *pEnv) { + SPgFile * pPgFile; + SPgCache *pPgCache; + size_t fnameLen; + pgno_t fsize; + + *ppPgFile = NULL; + + // create the handle + fnameLen = strlen(fname); + pPgFile = (SPgFile *)calloc(1, sizeof(*pPgFile) + fnameLen + 1); + if (pPgFile == NULL) { + return -1; + } + + ASSERT(pEnv != NULL); + + // init the handle + pPgFile->fname = (char *)(&(pPgFile[1])); + memcpy(pPgFile->fname, fname, fnameLen); + pPgFile->fname[fnameLen] = '\0'; + pPgFile->fd = -1; + + pPgFile->fd = open(fname, O_CREAT | O_RDWR, 0755); + if (pPgFile->fd < 0) { + // TODO: handle error + return -1; + } + + tdbGnrtFileID(fname, pPgFile->fileid, false); + tdbGetFileSize(fname, tdbEnvGetPageSize(pEnv), &fsize); + + pPgFile->fsize = fsize; + pPgFile->lsize = fsize; + + if (pPgFile->fsize == 0) { + // A created file + pgno_t pgno; + pgid_t pgid; + + pgFileAllocatePage(pPgFile, &pgno); + + ASSERT(pgno == 1); + + memcpy(pgid.fileid, pPgFile->fileid, TDB_FILE_ID_LEN); + pgid.pgno = pgno; + + pgCacheFetch(pPgCache, pgid); + // Need to allocate the first page as a description page + } else { + // An existing file + } + + /* TODO: other open operations */ + + // add the page file to the environment + tdbEnvRgstPageFile(pEnv, pPgFile); + pPgFile->pEnv = pEnv; + + *ppPgFile = pPgFile; + return 0; +} + +int pgFileClose(SPgFile *pPgFile) { + if (pPgFile) { + if (pPgFile->fd >= 0) { + close(pPgFile->fd); + } + + tfree(pPgFile->fname); + free(pPgFile); + } + + return 0; +} + +SPage *pgFileFetch(SPgFile *pPgFile, pgno_t pgno) { + SPgCache *pPgCache; + SPage * pPage; + pgid_t pgid; + + // 1. Fetch from the page cache + // pgCacheFetch(pPgCache, pgid); + + // 2. If only get a page frame, no content, maybe + // need to load from the file + if (1 /*page not initialized*/) { + if (pgno < pPgFile->fsize) { + // load the page content from the disk + // ?? How about the freed pages ?? + } else { + // zero the page, make the page as a empty + // page with zero records. + } + } + +#if 0 + pPgCache = pPgFile->pPgCache; + pPage = NULL; + memcpy(pgid.fileid, pPgFile->fileid, TDB_FILE_ID_LEN); + pgid.pgno = pgno; + + if (pgno > pPgFile->pgFileSize) { + // TODO + } else { + pPage = pgCacheFetch(pPgCache, pgid); + if (1 /*Page is cached, no need to load from file*/) { + return pPage; + } else { + // TODO: handle error + if (pgFileRead(pPgFile, pgno, (void *)pPage) < 0) { + // todoerr + } + return pPage; + } + } +#endif + + return pPage; +} + +int pgFileRelease(SPage *pPage) { + pgCacheRelease(pPage); + return 0; +} + +int pgFileWrite(SPage *pPage) { + // TODO + return 0; +} + +int pgFileAllocatePage(SPgFile *pPgFile, pgno_t *pPgno) { + pgno_t pgno; + SPage1 * pPage1; + SPgCache *pPgCache; + pgid_t pgid; + SPage * pPage; + + if (pPgFile->lsize == 0) { + pgno = ++(pPgFile->lsize); + } else { + if (0) { + // TODO: allocate from the free list + pPage = pgCacheFetch(pPgCache, pgid); + + if (pPage1->nFree > 0) { + // TODO + } else { + pgno = ++(pPgFile->lsize); + } + } else { + pgno = ++(pPgFile->lsize); + } + } + + *pPgno = pgno; + return 0; +} + +static int pgFileRead(SPgFile *pPgFile, pgno_t pgno, uint8_t *pData) { + pgsz_t pgSize; + ssize_t rsize; + uint8_t *pTData; + size_t szToRead; + +#if 0 + + // pgSize = ; (TODO) + pTData = pData; + szToRead = pgSize; + for (; szToRead > 0;) { + rsize = pread(pPgFile->fd, pTData, szToRead, pgno * pgSize); + if (rsize < 0) { + if (errno == EINTR) { + continue; + } else { + return -1; + } + } else if (rsize == 0) { + return -1; + } + + szToRead -= rsize; + pTData += rsize; + } +#endif + + return 0; +} \ No newline at end of file diff --git a/source/libs/tdb/src/db/tdbUtil.c b/source/libs/tdb/src/db/tdbUtil.c new file mode 100644 index 0000000000000000000000000000000000000000..fa9a3297dad9722a348a5f469aeddcf1ba069632 --- /dev/null +++ b/source/libs/tdb/src/db/tdbUtil.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "tdbInt.h" + +int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique) { + struct stat statbuf; + + if (stat(fname, &statbuf) < 0) { + return -1; + } + + memset(fileid, 0, TDB_FILE_ID_LEN); + + ((uint64_t *)fileid)[0] = (uint64_t)statbuf.st_ino; + ((uint64_t *)fileid)[1] = (uint64_t)statbuf.st_dev; + if (unique) { + ((uint64_t *)fileid)[2] = rand(); + } + + return 0; +} + +int tdbCheckFileAccess(const char *pathname, int mode) { + int flags = 0; + + if (mode & TDB_F_OK) { + flags |= F_OK; + } + + if (mode & TDB_R_OK) { + flags |= R_OK; + } + + if (mode & TDB_W_OK) { + flags |= W_OK; + } + + return access(pathname, flags); +} + +int tdbGetFileSize(const char *fname, pgsz_t pgSize, pgno_t *pSize) { + struct stat st; + int ret; + + ret = stat(fname, &st); + if (ret != 0) { + return -1; + } + + ASSERT(st.st_size % pgSize == 0); + + *pSize = st.st_size / pgSize; + return 0; +} \ No newline at end of file diff --git a/source/libs/tdb/src/inc/tdbBtree.h b/source/libs/tdb/src/inc/tdbBtree.h new file mode 100644 index 0000000000000000000000000000000000000000..94af3331bae7b5485026ffe5bb88c35ec65f8d5a --- /dev/null +++ b/source/libs/tdb/src/inc/tdbBtree.h @@ -0,0 +1,44 @@ +/* + * 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_BTREE_H_ +#define _TD_BTREE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct SBTree SBTree; +typedef struct SBtCursor SBtCursor; + +// SBTree +int btreeOpen(SBTree **ppBt, SPgFile *pPgFile); +int btreeClose(SBTree *pBt); + +// SBtCursor +int btreeCursorOpen(SBtCursor *pBtCur, SBTree *pBt); +int btreeCursorClose(SBtCursor *pBtCur); +int btreeCursorMoveTo(SBtCursor *pBtCur, int kLen, const void *pKey); +int btreeCursorNext(SBtCursor *pBtCur); + +struct SBTree { + pgno_t root; +}; + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_BTREE_H_*/ \ No newline at end of file diff --git a/source/libs/tdb/src/db/tdb_db.c b/source/libs/tdb/src/inc/tdbEnv.h similarity index 61% rename from source/libs/tdb/src/db/tdb_db.c rename to source/libs/tdb/src/inc/tdbEnv.h index 3675844535319d0f35bd62b6f74a6c69c69bba82..6cb5c7a2cda8537ee07a4820e9cb9d5ae6df93a9 100644 --- a/source/libs/tdb/src/db/tdb_db.c +++ b/source/libs/tdb/src/inc/tdbEnv.h @@ -13,14 +13,21 @@ * along with this program. If not, see . */ -#include "tdb_db.h" +#ifndef _TDB_ENV_H_ +#define _TDB_ENV_H_ -int tdbOpen(TDB **dbpp, const char *fname, const char *dbname, uint32_t flags) { - // TODO - return 0; +#ifdef __cplusplus +extern "C" { +#endif + +const char* tdbEnvGetRootDir(TENV* pEnv); +SPgFile* tdbEnvGetPageFile(TENV* pEnv, const uint8_t fileid[]); +SPgCache* tdbEnvGetPgCache(TENV* pEnv); +int tdbEnvRgstPageFile(TENV* pEnv, SPgFile* pPgFile); +int tdbEnvRgstDB(TENV* pEnv, TDB* pDb); + +#ifdef __cplusplus } +#endif -int tdbClose(TDB *dbp, uint32_t flags) { - // TODO - return 0; -} \ No newline at end of file +#endif /*_TDB_ENV_H_*/ \ No newline at end of file diff --git a/source/libs/tdb/src/inc/tdbInt.h b/source/libs/tdb/src/inc/tdbInt.h new file mode 100644 index 0000000000000000000000000000000000000000..ac42e1500293f1c74fec9d6d89c253d772198fc5 --- /dev/null +++ b/source/libs/tdb/src/inc/tdbInt.h @@ -0,0 +1,134 @@ +/* + * 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_TDB_INTERNAL_H_ +#define _TD_TDB_INTERNAL_H_ + +#include "tlist.h" +#include "tlockfree.h" + +#include "tdb.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct SPgFile SPgFile; + +// pgno_t +typedef int32_t pgno_t; +#define TDB_IVLD_PGNO ((pgno_t)0) + +// fileid +#define TDB_FILE_ID_LEN 24 + +// pgid_t +typedef struct { + uint8_t fileid[TDB_FILE_ID_LEN]; + pgno_t pgno; +} pgid_t; + +#define TDB_IVLD_PGID (pgid_t){0, TDB_IVLD_PGNO}; + +static FORCE_INLINE int tdbCmprPgId(const void *p1, const void *p2) { + pgid_t *pgid1 = (pgid_t *)p1; + pgid_t *pgid2 = (pgid_t *)p2; + int rcode; + + rcode = memcmp(pgid1->fileid, pgid2->fileid, TDB_FILE_ID_LEN); + if (rcode) { + return rcode; + } else { + if (pgid1->pgno > pgid2->pgno) { + return 1; + } else if (pgid1->pgno < pgid2->pgno) { + return -1; + } else { + return 0; + } + } +} + +// framd_id_t +typedef int32_t frame_id_t; + +// pgsz_t +#define TDB_MIN_PGSIZE 512 +#define TDB_MAX_PGSIZE 65536 +#define TDB_DEFAULT_PGSIZE 4096 +#define TDB_IS_PGSIZE_VLD(s) (((s) >= TDB_MIN_PGSIZE) && ((s) <= TDB_MAX_PGSIZE)) + +// pgoff_t +typedef pgsz_t pgoff_t; + +// cache +#define TDB_DEFAULT_CACHE_SIZE (256 * 4096) // 1M + +// dbname +#define TDB_MAX_DBNAME_LEN 24 + +// tdb_log +#define tdbError(var) + +typedef TD_DLIST(STDb) STDbList; +typedef TD_DLIST(SPgFile) SPgFileList; +typedef TD_DLIST_NODE(SPgFile) SPgFileListNode; + +#define TERR_A(val, op, flag) \ + do { \ + if (((val) = (op)) != 0) { \ + goto flag; \ + } \ + } while (0) + +#define TERR_B(val, op, flag) \ + do { \ + if (((val) = (op)) == NULL) { \ + goto flag; \ + } \ + } while (0) + +#define TDB_VARIANT_LEN (int)-1 + +// page payload format +// + + [key] + [value] +#define TDB_DECODE_PAYLOAD(pPayload, keyLen, pKey, valLen, pVal) \ + do { \ + if ((keyLen) == TDB_VARIANT_LEN) { \ + /* TODO: decode the keyLen */ \ + } \ + if ((valLen) == TDB_VARIANT_LEN) { \ + /* TODO: decode the valLen */ \ + } \ + /* TODO */ \ + } while (0) + +#define TDB_JOURNAL_NAME "tdb.journal" + +#include "tdbUtil.h" + +#include "tdbBtree.h" + +#include "tdbPgCache.h" + +#include "tdbPgFile.h" + +#include "tdbEnv.h" + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_TDB_INTERNAL_H_*/ diff --git a/source/libs/tdb/src/inc/tdbPgCache.h b/source/libs/tdb/src/inc/tdbPgCache.h new file mode 100644 index 0000000000000000000000000000000000000000..c25ef27c1050dd83495adf4e50215a61810c5825 --- /dev/null +++ b/source/libs/tdb/src/inc/tdbPgCache.h @@ -0,0 +1,48 @@ +/* + * 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_PAGE_CACHE_H_ +#define _TD_PAGE_CACHE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct SPgCache SPgCache; +typedef struct SPage SPage; + +// SPgCache +int pgCacheOpen(SPgCache **ppPgCache, TENV *pEnv); +int pgCacheClose(SPgCache *pPgCache); + +SPage *pgCacheFetch(SPgCache *pPgCache, pgid_t pgid); +int pgCacheRelease(SPage *pPage); + +// SPage +typedef TD_DLIST_NODE(SPage) SPgListNode; +struct SPage { + pgid_t pgid; // page id + frame_id_t frameid; // frame id + uint8_t * pData; // real data + SPgListNode freeNode; // for SPgCache.freeList + SPgListNode pghtNode; // for pght + SPgListNode lruNode; // for LRU +}; + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_PAGE_CACHE_H_*/ \ No newline at end of file diff --git a/source/libs/tdb/src/inc/tdbPgFile.h b/source/libs/tdb/src/inc/tdbPgFile.h new file mode 100644 index 0000000000000000000000000000000000000000..2a7116a0dd232b1933c030e72a4e95166af063ef --- /dev/null +++ b/source/libs/tdb/src/inc/tdbPgFile.h @@ -0,0 +1,59 @@ +/* + * 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_PAGE_FILE_H_ +#define _TD_PAGE_FILE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct __attribute__((__packed__)) { + char hdrInfo[16]; // info string + pgsz_t szPage; // page size of current file + int32_t cno; // commit number counter + pgno_t freePgno; // freelist page number + uint8_t resv[100]; // reserved space +} SPgFileHdr; + +#define TDB_PG_FILE_HDR_SIZE 128 + +TDB_STATIC_ASSERT(sizeof(SPgFileHdr) == TDB_PG_FILE_HDR_SIZE, "Page file header size if not 128"); + +struct SPgFile { + TENV * pEnv; // env containing this page file + char * fname; // backend file name + uint8_t fileid[TDB_FILE_ID_LEN]; // file id + pgno_t lsize; // page file logical size (for count) + pgno_t fsize; // real file size on disk (for rollback) + int fd; + SPgFileListNode envHash; + SPgFileListNode envPgfList; +}; + +int pgFileOpen(SPgFile **ppPgFile, const char *fname, TENV *pEnv); +int pgFileClose(SPgFile *pPgFile); + +SPage *pgFileFetch(SPgFile *pPgFile, pgno_t pgno); +int pgFileRelease(SPage *pPage); + +int pgFileWrite(SPage *pPage); +int pgFileAllocatePage(SPgFile *pPgFile, pgno_t *pPgno); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_PAGE_FILE_H_*/ \ No newline at end of file diff --git a/source/libs/tdb/src/inc/tdb_inc.h b/source/libs/tdb/src/inc/tdbUtil.h similarity index 51% rename from source/libs/tdb/src/inc/tdb_inc.h rename to source/libs/tdb/src/inc/tdbUtil.h index 885191477cfd3e760959a4f81d1dce7f5ba4475e..8108e5aba6e4de3c2929805ee2dabc649bc0e10c 100644 --- a/source/libs/tdb/src/inc/tdb_inc.h +++ b/source/libs/tdb/src/inc/tdbUtil.h @@ -13,46 +13,32 @@ * along with this program. If not, see . */ -#ifndef _TD_TDB_INC_H_ -#define _TD_TDB_INC_H_ - -#include "os.h" -#include "tlist.h" -#include "tlockfree.h" +#ifndef _TDB_UTIL_H_ +#define _TDB_UTIL_H_ #ifdef __cplusplus extern "C" { #endif -// pgno_t -typedef int32_t pgno_t; -#define TDB_IVLD_PGNO ((pgno_t)-1) - -// fileid -#define TDB_FILE_ID_LEN 24 +#if __STDC_VERSION__ >= 201112L +#define TDB_STATIC_ASSERT(op, info) static_assert(op, info) +#else +#define TDB_STATIC_ASSERT(op, info) +#endif -// pgid_t -typedef struct { - uint8_t fileid[TDB_FILE_ID_LEN]; - pgno_t pgno; -} pgid_t; -#define TDB_IVLD_PGID (pgid_t){0, TDB_IVLD_PGNO}; +#define TDB_ROUND8(x) (((x) + 7) & ~7) -// framd_id_t -typedef int32_t frame_id_t; +int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique); -// pgsize_t -typedef int32_t pgsize_t; -#define TDB_MIN_PGSIZE 512 -#define TDB_MAX_PGSIZE 16384 -#define TDB_DEFAULT_PGSIZE 4096 -#define TDB_IS_PGSIZE_VLD(s) (((s) >= TDB_MIN_PGSIZE) && ((s) <= TDB_MAX_PGSIZE)) +#define TDB_F_OK 0x1 +#define TDB_R_OK 0x2 +#define TDB_W_OK 0x4 +int tdbCheckFileAccess(const char *pathname, int mode); -// tdb_log -#define tdbError(var) +int tdbGetFileSize(const char *fname, pgsz_t pgSize, pgno_t *pSize); #ifdef __cplusplus } #endif -#endif /*_TD_TDB_INC_H_*/ +#endif /*_TDB_UTIL_H_*/ \ No newline at end of file diff --git a/source/libs/tdb/src/inc/tdb_mpool.h b/source/libs/tdb/src/inc/tdb_mpool.h deleted file mode 100644 index 37c82f38335b4bda0ce8835f5b47f9178a60c5d1..0000000000000000000000000000000000000000 --- a/source/libs/tdb/src/inc/tdb_mpool.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_TDB_MPOOL_H_ -#define _TD_TDB_MPOOL_H_ - -#include "tdb_inc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// Exposed handle -typedef struct TDB_MPOOL TDB_MPOOL; -typedef struct TDB_MPFILE TDB_MPFILE; - -typedef TD_DLIST_NODE(pg_t) pg_free_dlist_node_t, pg_hash_dlist_node_t; -typedef struct pg_t { - SRWLatch rwLatch; - frame_id_t frameid; - pgid_t pgid; - uint8_t dirty; - uint8_t rbit; - int32_t pinRef; - pg_free_dlist_node_t free; - pg_hash_dlist_node_t hash; - void * p; -} pg_t; - -typedef TD_DLIST(pg_t) pg_list_t; -typedef struct { - SRWLatch latch; - TD_DLIST(TDB_MPFILE); -} mpf_bucket_t; -struct TDB_MPOOL { - int64_t cachesize; - pgsize_t pgsize; - int32_t npages; - pg_t * pages; - pg_list_t freeList; - frame_id_t clockHand; - struct { - int32_t nbucket; - pg_list_t *hashtab; - } pgtab; // page table, hash - struct { -#define MPF_HASH_BUCKETS 16 - mpf_bucket_t buckets[MPF_HASH_BUCKETS]; - } mpfht; // MPF hash table. MPFs using this MP will be put in this hash table -}; - -#define MP_PAGE_AT(mp, idx) (mp)->pages[idx] - -typedef TD_DLIST_NODE(TDB_MPFILE) td_mpf_dlist_node_t; -struct TDB_MPFILE { - char * fname; // file name - int fd; // fd - uint8_t fileid[TDB_FILE_ID_LEN]; // file ID - TDB_MPOOL * mp; // underlying memory pool - td_mpf_dlist_node_t node; -}; - -/*=================================================== Exposed apis ==================================================*/ -// TDB_MPOOL -int tdbMPoolOpen(TDB_MPOOL **mpp, uint64_t cachesize, pgsize_t pgsize); -int tdbMPoolClose(TDB_MPOOL *mp); -int tdbMPoolSync(TDB_MPOOL *mp); - -// TDB_MPFILE -int tdbMPoolFileOpen(TDB_MPFILE **mpfp, const char *fname, TDB_MPOOL *mp); -int tdbMPoolFileClose(TDB_MPFILE *mpf); -int tdbMPoolFileNewPage(TDB_MPFILE *mpf, pgno_t *pgno, void *addr); -int tdbMPoolFileFreePage(TDB_MPOOL *mpf, pgno_t *pgno, void *addr); -int tdbMPoolFileGetPage(TDB_MPFILE *mpf, pgno_t pgno, void *addr); -int tdbMPoolFilePutPage(TDB_MPFILE *mpf, pgno_t pgno, void *addr); -int tdbMPoolFileSync(TDB_MPFILE *mpf); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_TDB_MPOOL_H_*/ \ No newline at end of file diff --git a/source/libs/tdb/test/CMakeLists.txt b/source/libs/tdb/test/CMakeLists.txt index 7fbfaf550691c5e12409a3c8540ab7fbfc080a4f..2d77c1f4e9124bd07d8ecb3e27bf9db9103f33e7 100644 --- a/source/libs/tdb/test/CMakeLists.txt +++ b/source/libs/tdb/test/CMakeLists.txt @@ -1,7 +1,3 @@ -# tdbMPoolTest -add_executable(tdbMPoolTest "tdbMPoolTest.cpp") -target_link_libraries(tdbMPoolTest tdb gtest gtest_main) - # tdbTest add_executable(tdbTest "tdbTest.cpp") target_link_libraries(tdbTest tdb gtest gtest_main) \ No newline at end of file diff --git a/source/libs/tdb/test/tdbMPoolTest.cpp b/source/libs/tdb/test/tdbMPoolTest.cpp deleted file mode 100644 index 17381759fbc9dc7b9f8f5a79810eb22bf016c056..0000000000000000000000000000000000000000 --- a/source/libs/tdb/test/tdbMPoolTest.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "gtest/gtest.h" - -#include - -#include "tdb_mpool.h" - -TEST(tdb_mpool_test, test1) { - TDB_MPOOL * mp; - TDB_MPFILE *mpf; - pgno_t pgno; - void * pgdata; - - // open mp - tdbMPoolOpen(&mp, 16384, 4096); - - // open mpf - tdbMPoolFileOpen(&mpf, "test.db", mp); - -#define TEST1_TOTAL_PAGES 100 - for (int i = 0; i < TEST1_TOTAL_PAGES; i++) { - tdbMPoolFileNewPage(mpf, &pgno, pgdata); - - *(pgno_t *)pgdata = i; - } - - // close mpf - tdbMPoolFileClose(mpf); - - // close mp - tdbMPoolClose(mp); -} diff --git a/source/libs/tdb/test/tdbTest.cpp b/source/libs/tdb/test/tdbTest.cpp index 113bb2560f5ad8a7d71ac253f7514eec39a2a7a8..5ab0b4c0f1d63f252852c8b714ce108c6839aa29 100644 --- a/source/libs/tdb/test/tdbTest.cpp +++ b/source/libs/tdb/test/tdbTest.cpp @@ -2,13 +2,67 @@ #include "tdb.h" -TEST(tdb_api_test, tdb_create_open_close_db_test) { - // int ret; - // TDB *dbp; +TEST(tdb_test, simple_test) { + TENV * pEnv; + TDB * pDb1, *pDb2, *pDb3; + pgsz_t pgSize = 1024; + cachesz_t cacheSize = 10240; - // tdbCreateDB(&dbp, TDB_BTREE_T); + // ENV + GTEST_ASSERT_EQ(tdbEnvCreate(&pEnv, "./testtdb"), 0); - // tdbOpenDB(dbp, 0); + GTEST_ASSERT_EQ(tdbEnvSetCache(pEnv, pgSize, cacheSize), 0); - // tdbCloseDB(dbp, 0); + GTEST_ASSERT_EQ(tdbEnvGetCacheSize(pEnv), cacheSize); + + GTEST_ASSERT_EQ(tdbEnvGetPageSize(pEnv), pgSize); + + GTEST_ASSERT_EQ(tdbEnvOpen(pEnv), 0); + +#if 1 + // DB + GTEST_ASSERT_EQ(tdbCreate(&pDb1), 0); + + // GTEST_ASSERT_EQ(tdbSetKeyLen(pDb1, 8), 0); + + // GTEST_ASSERT_EQ(tdbGetKeyLen(pDb1), 8); + + // GTEST_ASSERT_EQ(tdbSetValLen(pDb1, 3), 0); + + // GTEST_ASSERT_EQ(tdbGetValLen(pDb1), 3); + + // GTEST_ASSERT_EQ(tdbSetDup(pDb1, 1), 0); + + // GTEST_ASSERT_EQ(tdbGetDup(pDb1), 1); + + // GTEST_ASSERT_EQ(tdbSetCmprFunc(pDb1, NULL), 0); + + tdbEnvBeginTxn(pEnv); + + GTEST_ASSERT_EQ(tdbOpen(pDb1, "db.db", "db1", pEnv), 0); + + // char *key = "key1"; + // char *val = "value1"; + // tdbInsert(pDb1, (void *)key, strlen(key), (void *)val, strlen(val)); + + tdbEnvCommit(pEnv); + +#if 0 + // Insert + + // Query + + // Delete + + // Query +#endif + + // GTEST_ASSERT_EQ(tdbOpen(&pDb2, "db.db", "db2", pEnv), 0); + // GTEST_ASSERT_EQ(tdbOpen(&pDb3, "index.db", NULL, pEnv), 0); + // tdbClose(pDb3); + // tdbClose(pDb2); + tdbClose(pDb1); +#endif + + tdbEnvClose(pEnv); } \ No newline at end of file diff --git a/source/util/CMakeLists.txt b/source/util/CMakeLists.txt index 760a66a4fb748c8bfe92b39e9a61ffabb1f56535..7a47639e75f2e18e6ed47a19066c0a69ea336503 100644 --- a/source/util/CMakeLists.txt +++ b/source/util/CMakeLists.txt @@ -10,7 +10,7 @@ target_link_libraries( util PRIVATE os PUBLIC lz4_static - PUBLIC api + PUBLIC api cjson ) if(${BUILD_TEST}) diff --git a/source/util/src/tjson.c b/source/util/src/tjson.c new file mode 100644 index 0000000000000000000000000000000000000000..556e8f8060d4c932bffb17724137f6cff1874db5 --- /dev/null +++ b/source/util/src/tjson.c @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "tjson.h" + +#include "taoserror.h" +#include "cJSON.h" + +SJson* tjsonCreateObject() { + return cJSON_CreateObject(); +} + +void tjsonDelete(SJson* pJson) { + cJSON_Delete((cJSON*)pJson); +} + +int32_t tjsonAddIntegerToObject(SJson* pJson, const char* pName, const uint64_t number) { + char tmp[40] = {0}; + snprintf(tmp, tListLen(tmp), "%"PRId64, number); + return tjsonAddStringToObject(pJson, pName, tmp); +} + +int32_t tjsonAddStringToObject(SJson* pJson, const char* pName, const char* pVal) { + return (NULL == cJSON_AddStringToObject((cJSON*)pJson, pName, pVal) ? TSDB_CODE_FAILED : TSDB_CODE_SUCCESS); +} + +SJson* tjsonAddArrayToObject(SJson* pJson, const char* pName) { + return cJSON_AddArrayToObject((cJSON*)pJson, pName); +} + +int32_t tjsonAddItemToObject(SJson *pJson, const char* pName, SJson* pItem) { + return (cJSON_AddItemToObject((cJSON*)pJson, pName, pItem) ? TSDB_CODE_SUCCESS : TSDB_CODE_FAILED); +} + +int32_t tjsonAddItemToArray(SJson* pJson, SJson* pItem) { + return (cJSON_AddItemToArray((cJSON*)pJson, pItem) ? TSDB_CODE_SUCCESS : TSDB_CODE_FAILED); +} + +int32_t tjsonAddObject(SJson* pJson, const char* pName, FToJson func, const void* pObj) { + if (NULL == pObj) { + return TSDB_CODE_SUCCESS; + } + + SJson* pJobj = tjsonCreateObject(); + if (NULL == pJobj || TSDB_CODE_SUCCESS != func(pObj, pJobj)) { + printf("%s:%d code = %d\n", __FUNCTION__, __LINE__, TSDB_CODE_FAILED); + tjsonDelete(pJobj); + return TSDB_CODE_FAILED; + } + return tjsonAddItemToObject(pJson, pName, pJobj); +} + +int32_t tjsonAddItem(SJson* pJson, FToJson func, const void* pObj) { + SJson* pJobj = tjsonCreateObject(); + if (NULL == pJobj || TSDB_CODE_SUCCESS != func(pObj, pJobj)) { + tjsonDelete(pJobj); + return TSDB_CODE_FAILED; + } + return tjsonAddItemToArray(pJson, pJobj); +} + +char* tjsonToString(const SJson* pJson) { + return cJSON_Print((cJSON*)pJson); +}