diff --git a/examples/c/stream_demo.c b/examples/c/stream_demo.c index f5cb7f1120..1e9058d628 100644 --- a/examples/c/stream_demo.c +++ b/examples/c/stream_demo.c @@ -98,9 +98,10 @@ int32_t create_stream() { /*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/ /*const char* sql = "select sum(k) from tu1 interval(10m)";*/ /*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/ - pRes = taos_query(pConn, - "create stream stream1 trigger at_once into outstb as select _wstartts, sum(k) from st1 partition " - "by tbname interval(10s) "); + pRes = taos_query( + pConn, + "create stream stream1 trigger max_delay 10s into outstb as select _wstartts, sum(k) from st1 partition " + "by tbname session(ts, 10s) "); if (taos_errno(pRes) != 0) { printf("failed to create stream stream1, reason:%s\n", taos_errstr(pRes)); return -1; diff --git a/examples/c/tmq.c b/examples/c/tmq.c index 6fb7e7a1fc..4226587d56 100644 --- a/examples/c/tmq.c +++ b/examples/c/tmq.c @@ -137,8 +137,8 @@ int32_t create_topic() { } taos_free_result(pRes); - pRes = taos_query(pConn, "create topic topic_ctb_column with meta as database abc1"); - /*pRes = taos_query(pConn, "create topic topic_ctb_column as select ts, c1, c2, c3 from st1");*/ + /*pRes = taos_query(pConn, "create topic topic_ctb_column with meta as database abc1");*/ + pRes = taos_query(pConn, "create topic topic_ctb_column as select ts, c1, c2, c3 from st1"); if (taos_errno(pRes) != 0) { printf("failed to create topic topic_ctb_column, reason:%s\n", taos_errstr(pRes)); return -1; @@ -225,7 +225,7 @@ void basic_consume_loop(tmq_t* tmq, tmq_list_t* topics) { } int32_t cnt = 0; while (running) { - TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, 0); + TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, -1); if (tmqmessage) { cnt++; msg_process(tmqmessage); diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 928fe0aa0e..c7ba618b25 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -25,10 +25,11 @@ extern "C" { #endif +// TODO remove it enum { - TMQ_CONF__RESET_OFFSET__LATEST = -1, - TMQ_CONF__RESET_OFFSET__EARLIEAST = -2, TMQ_CONF__RESET_OFFSET__NONE = -3, + TMQ_CONF__RESET_OFFSET__EARLIEAST = -2, + TMQ_CONF__RESET_OFFSET__LATEST = -1, }; enum { @@ -39,6 +40,16 @@ enum { TMQ_MSG_TYPE__END_RSP, }; +enum { + STREAM_INPUT__DATA_SUBMIT = 1, + STREAM_INPUT__DATA_BLOCK, + STREAM_INPUT__DATA_SCAN, + STREAM_INPUT__DATA_RETRIEVE, + STREAM_INPUT__TRIGGER, + STREAM_INPUT__CHECKPOINT, + STREAM_INPUT__DROP, +}; + typedef enum EStreamType { STREAM_NORMAL = 1, STREAM_INVERT, @@ -47,8 +58,8 @@ typedef enum EStreamType { STREAM_GET_ALL, STREAM_DELETE, STREAM_RETRIEVE, - STREAM_PUSH_DATA, - STREAM_PUSH_EMPTY, + STREAM_PULL_DATA, + STREAM_PULL_OVER, } EStreamType; typedef struct { diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index 6653fdd9cd..72e0af657c 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -224,7 +224,7 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize); int32_t blockDataTrimFirstNRows(SSDataBlock* pBlock, size_t n); int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src); -int32_t copyDataBlock(SSDataBlock* dst, const SSDataBlock* src); +int32_t copyDataBlock(SSDataBlock* dst, const SSDataBlock* src); SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData); SSDataBlock* createDataBlock(); int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoData); @@ -232,9 +232,8 @@ int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColIn SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId); SColumnInfoData* bdGetColumnInfoData(SSDataBlock* pBlock, int32_t index); -void blockCompressEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols, - int8_t needCompress); -const char* blockCompressDecode(SSDataBlock* pBlock, int32_t numOfCols, int32_t numOfRows, const char* pData); +void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols, int8_t needCompress); +const char* blockDecode(SSDataBlock* pBlock, int32_t numOfCols, int32_t numOfRows, const char* pData); void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag); // for debug diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 4ba668cbf5..b87d7751ae 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -623,6 +623,7 @@ typedef struct { col_id_t colId; int16_t slotId; }; + bool output; // TODO remove it later int16_t type; int32_t bytes; @@ -2467,22 +2468,37 @@ int32_t tDecodeSMqCMCommitOffsetReq(SDecoder* decoder, SMqCMCommitOffsetReq* pRe // tqOffset enum { - TMQ_OFFSET__SNAPSHOT = 1, - TMQ_OFFSET__LOG, + TMQ_OFFSET__RESET_NONE = -3, + TMQ_OFFSET__RESET_EARLIEAST = -2, + TMQ_OFFSET__RESET_LATEST = -1, + TMQ_OFFSET__LOG = 1, + TMQ_OFFSET__SNAPSHOT_DATA = 2, + TMQ_OFFSET__SNAPSHOT_META = 3, }; typedef struct { int8_t type; union { + // snapshot data struct { int64_t uid; int64_t ts; }; + // log struct { int64_t version; }; }; - char subKey[TSDB_SUBSCRIBE_KEY_LEN]; +} STqOffsetVal; + +int32_t tEncodeSTqOffsetVal(SEncoder* pEncoder, const STqOffsetVal* pOffsetVal); +int32_t tDecodeSTqOffsetVal(SDecoder* pDecoder, STqOffsetVal* pOffsetVal); +int32_t tFormatOffset(char* buf, int32_t maxLen, const STqOffsetVal* pVal); +bool tOffsetEqual(const STqOffsetVal* pLeft, const STqOffsetVal* pRight); + +typedef struct { + STqOffsetVal val; + char subKey[TSDB_SUBSCRIBE_KEY_LEN]; } STqOffset; int32_t tEncodeSTqOffset(SEncoder* pEncoder, const STqOffset* pOffset); @@ -2715,7 +2731,8 @@ typedef struct { uint64_t reqId; int64_t consumerId; int64_t timeout; - int64_t currentOffset; + // int64_t currentOffset; + STqOffsetVal reqOffset; } SMqPollReq; typedef struct { @@ -2784,12 +2801,14 @@ static FORCE_INLINE void tDeleteSMqSubTopicEp(SMqSubTopicEp* pSubTopicEp) { } typedef struct { - SMqRspHead head; - int64_t reqOffset; - int64_t rspOffset; - int16_t resMsgType; - int32_t metaRspLen; - void* metaRsp; + SMqRspHead head; + int64_t reqOffset; + int64_t rspOffset; + STqOffsetVal reqOffsetNew; + STqOffsetVal rspOffsetNew; + int16_t resMsgType; + int32_t metaRspLen; + void* metaRsp; } SMqMetaRsp; static FORCE_INLINE int32_t tEncodeSMqMetaRsp(void** buf, const SMqMetaRsp* pRsp) { @@ -2811,6 +2830,24 @@ static FORCE_INLINE void* tDecodeSMqMetaRsp(const void* buf, SMqMetaRsp* pRsp) { return (void*)buf; } +typedef struct { + SMqRspHead head; + STqOffsetVal reqOffset; + STqOffsetVal rspOffset; + int32_t skipLogNum; + int32_t blockNum; + int8_t withTbName; + int8_t withSchema; + SArray* blockDataLen; + SArray* blockData; + SArray* blockTbName; + SArray* blockSchema; +} SMqDataRsp; + +int32_t tEncodeSMqDataRsp(SEncoder* pEncoder, const SMqDataRsp* pRsp); +int32_t tDecodeSMqDataRsp(SDecoder* pDecoder, SMqDataRsp* pRsp); + +#if 0 typedef struct { SMqRspHead head; int64_t reqOffset; @@ -2819,13 +2856,10 @@ typedef struct { int32_t blockNum; int8_t withTbName; int8_t withSchema; - int8_t withTag; - SArray* blockDataLen; // SArray - SArray* blockData; // SArray - SArray* blockTbName; // SArray - SArray* blockSchema; // SArray - SArray* blockTags; // SArray - SArray* blockTagSchema; // SArray + SArray* blockDataLen; // SArray + SArray* blockData; // SArray + SArray* blockTbName; // SArray + SArray* blockSchema; // SArray } SMqDataBlkRsp; static FORCE_INLINE int32_t tEncodeSMqDataBlkRsp(void** buf, const SMqDataBlkRsp* pRsp) { @@ -2837,7 +2871,6 @@ static FORCE_INLINE int32_t tEncodeSMqDataBlkRsp(void** buf, const SMqDataBlkRsp if (pRsp->blockNum != 0) { tlen += taosEncodeFixedI8(buf, pRsp->withTbName); tlen += taosEncodeFixedI8(buf, pRsp->withSchema); - tlen += taosEncodeFixedI8(buf, pRsp->withTag); for (int32_t i = 0; i < pRsp->blockNum; i++) { int32_t bLen = *(int32_t*)taosArrayGet(pRsp->blockDataLen, i); @@ -2867,7 +2900,6 @@ static FORCE_INLINE void* tDecodeSMqDataBlkRsp(const void* buf, SMqDataBlkRsp* p pRsp->blockDataLen = taosArrayInit(pRsp->blockNum, sizeof(int32_t)); buf = taosDecodeFixedI8(buf, &pRsp->withTbName); buf = taosDecodeFixedI8(buf, &pRsp->withSchema); - buf = taosDecodeFixedI8(buf, &pRsp->withTag); if (pRsp->withTbName) { pRsp->blockTbName = taosArrayInit(pRsp->blockNum, sizeof(void*)); } @@ -2896,6 +2928,7 @@ static FORCE_INLINE void* tDecodeSMqDataBlkRsp(const void* buf, SMqDataBlkRsp* p } return (void*)buf; } +#endif typedef struct { SMqRspHead head; diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 6ace51f58e..f5e068693e 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -16,251 +16,255 @@ #ifndef _TD_COMMON_TOKEN_H_ #define _TD_COMMON_TOKEN_H_ -#define TK_OR 1 -#define TK_AND 2 -#define TK_UNION 3 -#define TK_ALL 4 -#define TK_MINUS 5 -#define TK_EXCEPT 6 -#define TK_INTERSECT 7 -#define TK_NK_BITAND 8 -#define TK_NK_BITOR 9 -#define TK_NK_LSHIFT 10 -#define TK_NK_RSHIFT 11 -#define TK_NK_PLUS 12 -#define TK_NK_MINUS 13 -#define TK_NK_STAR 14 -#define TK_NK_SLASH 15 -#define TK_NK_REM 16 -#define TK_NK_CONCAT 17 -#define TK_CREATE 18 -#define TK_ACCOUNT 19 -#define TK_NK_ID 20 -#define TK_PASS 21 -#define TK_NK_STRING 22 -#define TK_ALTER 23 -#define TK_PPS 24 -#define TK_TSERIES 25 -#define TK_STORAGE 26 -#define TK_STREAMS 27 -#define TK_QTIME 28 -#define TK_DBS 29 -#define TK_USERS 30 -#define TK_CONNS 31 -#define TK_STATE 32 -#define TK_USER 33 -#define TK_ENABLE 34 -#define TK_NK_INTEGER 35 -#define TK_SYSINFO 36 -#define TK_DROP 37 -#define TK_GRANT 38 -#define TK_ON 39 -#define TK_TO 40 -#define TK_REVOKE 41 -#define TK_FROM 42 -#define TK_NK_COMMA 43 -#define TK_READ 44 -#define TK_WRITE 45 -#define TK_NK_DOT 46 -#define TK_DNODE 47 -#define TK_PORT 48 -#define TK_DNODES 49 -#define TK_NK_IPTOKEN 50 -#define TK_LOCAL 51 -#define TK_QNODE 52 -#define TK_BNODE 53 -#define TK_SNODE 54 -#define TK_MNODE 55 -#define TK_DATABASE 56 -#define TK_USE 57 -#define TK_IF 58 -#define TK_NOT 59 -#define TK_EXISTS 60 -#define TK_BUFFER 61 -#define TK_CACHELAST 62 -#define TK_COMP 63 -#define TK_DURATION 64 -#define TK_NK_VARIABLE 65 -#define TK_FSYNC 66 -#define TK_MAXROWS 67 -#define TK_MINROWS 68 -#define TK_KEEP 69 -#define TK_PAGES 70 -#define TK_PAGESIZE 71 -#define TK_PRECISION 72 -#define TK_REPLICA 73 -#define TK_STRICT 74 -#define TK_WAL 75 -#define TK_VGROUPS 76 -#define TK_SINGLE_STABLE 77 -#define TK_RETENTIONS 78 -#define TK_SCHEMALESS 79 -#define TK_NK_COLON 80 -#define TK_TABLE 81 -#define TK_NK_LP 82 -#define TK_NK_RP 83 -#define TK_STABLE 84 -#define TK_ADD 85 -#define TK_COLUMN 86 -#define TK_MODIFY 87 -#define TK_RENAME 88 -#define TK_TAG 89 -#define TK_SET 90 -#define TK_NK_EQ 91 -#define TK_USING 92 -#define TK_TAGS 93 -#define TK_COMMENT 94 -#define TK_BOOL 95 -#define TK_TINYINT 96 -#define TK_SMALLINT 97 -#define TK_INT 98 -#define TK_INTEGER 99 -#define TK_BIGINT 100 -#define TK_FLOAT 101 -#define TK_DOUBLE 102 -#define TK_BINARY 103 -#define TK_TIMESTAMP 104 -#define TK_NCHAR 105 -#define TK_UNSIGNED 106 -#define TK_JSON 107 -#define TK_VARCHAR 108 -#define TK_MEDIUMBLOB 109 -#define TK_BLOB 110 -#define TK_VARBINARY 111 -#define TK_DECIMAL 112 -#define TK_MAX_DELAY 113 -#define TK_WATERMARK 114 -#define TK_ROLLUP 115 -#define TK_TTL 116 -#define TK_SMA 117 -#define TK_FIRST 118 -#define TK_LAST 119 -#define TK_SHOW 120 -#define TK_DATABASES 121 -#define TK_TABLES 122 -#define TK_STABLES 123 -#define TK_MNODES 124 -#define TK_MODULES 125 -#define TK_QNODES 126 -#define TK_FUNCTIONS 127 -#define TK_INDEXES 128 -#define TK_ACCOUNTS 129 -#define TK_APPS 130 -#define TK_CONNECTIONS 131 -#define TK_LICENCE 132 -#define TK_GRANTS 133 -#define TK_QUERIES 134 -#define TK_SCORES 135 -#define TK_TOPICS 136 -#define TK_VARIABLES 137 -#define TK_BNODES 138 -#define TK_SNODES 139 -#define TK_CLUSTER 140 -#define TK_TRANSACTIONS 141 -#define TK_DISTRIBUTED 142 -#define TK_CONSUMERS 143 -#define TK_SUBSCRIPTIONS 144 -#define TK_LIKE 145 -#define TK_INDEX 146 -#define TK_FUNCTION 147 -#define TK_INTERVAL 148 -#define TK_TOPIC 149 -#define TK_AS 150 -#define TK_WITH 151 -#define TK_META 152 -#define TK_CONSUMER 153 -#define TK_GROUP 154 -#define TK_DESC 155 -#define TK_DESCRIBE 156 -#define TK_RESET 157 -#define TK_QUERY 158 -#define TK_CACHE 159 -#define TK_EXPLAIN 160 -#define TK_ANALYZE 161 -#define TK_VERBOSE 162 -#define TK_NK_BOOL 163 -#define TK_RATIO 164 -#define TK_NK_FLOAT 165 -#define TK_COMPACT 166 -#define TK_VNODES 167 -#define TK_IN 168 -#define TK_OUTPUTTYPE 169 -#define TK_AGGREGATE 170 -#define TK_BUFSIZE 171 -#define TK_STREAM 172 -#define TK_INTO 173 -#define TK_TRIGGER 174 -#define TK_AT_ONCE 175 -#define TK_WINDOW_CLOSE 176 -#define TK_KILL 177 -#define TK_CONNECTION 178 -#define TK_TRANSACTION 179 -#define TK_BALANCE 180 -#define TK_VGROUP 181 -#define TK_MERGE 182 -#define TK_REDISTRIBUTE 183 -#define TK_SPLIT 184 -#define TK_SYNCDB 185 -#define TK_DELETE 186 -#define TK_NULL 187 -#define TK_NK_QUESTION 188 -#define TK_NK_ARROW 189 -#define TK_ROWTS 190 -#define TK_TBNAME 191 -#define TK_QSTARTTS 192 -#define TK_QENDTS 193 -#define TK_WSTARTTS 194 -#define TK_WENDTS 195 -#define TK_WDURATION 196 -#define TK_CAST 197 -#define TK_NOW 198 -#define TK_TODAY 199 -#define TK_TIMEZONE 200 -#define TK_COUNT 201 -#define TK_LAST_ROW 202 -#define TK_BETWEEN 203 -#define TK_IS 204 -#define TK_NK_LT 205 -#define TK_NK_GT 206 -#define TK_NK_LE 207 -#define TK_NK_GE 208 -#define TK_NK_NE 209 -#define TK_MATCH 210 -#define TK_NMATCH 211 -#define TK_CONTAINS 212 -#define TK_JOIN 213 -#define TK_INNER 214 -#define TK_SELECT 215 -#define TK_DISTINCT 216 -#define TK_WHERE 217 -#define TK_PARTITION 218 -#define TK_BY 219 -#define TK_SESSION 220 -#define TK_STATE_WINDOW 221 -#define TK_SLIDING 222 -#define TK_FILL 223 -#define TK_VALUE 224 -#define TK_NONE 225 -#define TK_PREV 226 -#define TK_LINEAR 227 -#define TK_NEXT 228 -#define TK_HAVING 229 -#define TK_RANGE 230 -#define TK_EVERY 231 -#define TK_ORDER 232 -#define TK_SLIMIT 233 -#define TK_SOFFSET 234 -#define TK_LIMIT 235 -#define TK_OFFSET 236 -#define TK_ASC 237 -#define TK_NULLS 238 -#define TK_ID 239 -#define TK_NK_BITNOT 240 -#define TK_INSERT 241 -#define TK_VALUES 242 -#define TK_IMPORT 243 -#define TK_NK_SEMI 244 -#define TK_FILE 245 +#define TK_OR 1 +#define TK_AND 2 +#define TK_UNION 3 +#define TK_ALL 4 +#define TK_MINUS 5 +#define TK_EXCEPT 6 +#define TK_INTERSECT 7 +#define TK_NK_BITAND 8 +#define TK_NK_BITOR 9 +#define TK_NK_LSHIFT 10 +#define TK_NK_RSHIFT 11 +#define TK_NK_PLUS 12 +#define TK_NK_MINUS 13 +#define TK_NK_STAR 14 +#define TK_NK_SLASH 15 +#define TK_NK_REM 16 +#define TK_NK_CONCAT 17 +#define TK_CREATE 18 +#define TK_ACCOUNT 19 +#define TK_NK_ID 20 +#define TK_PASS 21 +#define TK_NK_STRING 22 +#define TK_ALTER 23 +#define TK_PPS 24 +#define TK_TSERIES 25 +#define TK_STORAGE 26 +#define TK_STREAMS 27 +#define TK_QTIME 28 +#define TK_DBS 29 +#define TK_USERS 30 +#define TK_CONNS 31 +#define TK_STATE 32 +#define TK_USER 33 +#define TK_ENABLE 34 +#define TK_NK_INTEGER 35 +#define TK_SYSINFO 36 +#define TK_DROP 37 +#define TK_GRANT 38 +#define TK_ON 39 +#define TK_TO 40 +#define TK_REVOKE 41 +#define TK_FROM 42 +#define TK_NK_COMMA 43 +#define TK_READ 44 +#define TK_WRITE 45 +#define TK_NK_DOT 46 +#define TK_DNODE 47 +#define TK_PORT 48 +#define TK_DNODES 49 +#define TK_NK_IPTOKEN 50 +#define TK_LOCAL 51 +#define TK_QNODE 52 +#define TK_BNODE 53 +#define TK_SNODE 54 +#define TK_MNODE 55 +#define TK_DATABASE 56 +#define TK_USE 57 +#define TK_IF 58 +#define TK_NOT 59 +#define TK_EXISTS 60 +#define TK_BUFFER 61 +#define TK_CACHELAST 62 +#define TK_COMP 63 +#define TK_DURATION 64 +#define TK_NK_VARIABLE 65 +#define TK_FSYNC 66 +#define TK_MAXROWS 67 +#define TK_MINROWS 68 +#define TK_KEEP 69 +#define TK_PAGES 70 +#define TK_PAGESIZE 71 +#define TK_PRECISION 72 +#define TK_REPLICA 73 +#define TK_STRICT 74 +#define TK_WAL 75 +#define TK_VGROUPS 76 +#define TK_SINGLE_STABLE 77 +#define TK_RETENTIONS 78 +#define TK_SCHEMALESS 79 +#define TK_NK_COLON 80 +#define TK_TABLE 81 +#define TK_NK_LP 82 +#define TK_NK_RP 83 +#define TK_STABLE 84 +#define TK_ADD 85 +#define TK_COLUMN 86 +#define TK_MODIFY 87 +#define TK_RENAME 88 +#define TK_TAG 89 +#define TK_SET 90 +#define TK_NK_EQ 91 +#define TK_USING 92 +#define TK_TAGS 93 +#define TK_COMMENT 94 +#define TK_BOOL 95 +#define TK_TINYINT 96 +#define TK_SMALLINT 97 +#define TK_INT 98 +#define TK_INTEGER 99 +#define TK_BIGINT 100 +#define TK_FLOAT 101 +#define TK_DOUBLE 102 +#define TK_BINARY 103 +#define TK_TIMESTAMP 104 +#define TK_NCHAR 105 +#define TK_UNSIGNED 106 +#define TK_JSON 107 +#define TK_VARCHAR 108 +#define TK_MEDIUMBLOB 109 +#define TK_BLOB 110 +#define TK_VARBINARY 111 +#define TK_DECIMAL 112 +#define TK_MAX_DELAY 113 +#define TK_WATERMARK 114 +#define TK_ROLLUP 115 +#define TK_TTL 116 +#define TK_SMA 117 +#define TK_FIRST 118 +#define TK_LAST 119 +#define TK_SHOW 120 +#define TK_DATABASES 121 +#define TK_TABLES 122 +#define TK_STABLES 123 +#define TK_MNODES 124 +#define TK_MODULES 125 +#define TK_QNODES 126 +#define TK_FUNCTIONS 127 +#define TK_INDEXES 128 +#define TK_ACCOUNTS 129 +#define TK_APPS 130 +#define TK_CONNECTIONS 131 +#define TK_LICENCE 132 +#define TK_GRANTS 133 +#define TK_QUERIES 134 +#define TK_SCORES 135 +#define TK_TOPICS 136 +#define TK_VARIABLES 137 +#define TK_BNODES 138 +#define TK_SNODES 139 +#define TK_CLUSTER 140 +#define TK_TRANSACTIONS 141 +#define TK_DISTRIBUTED 142 +#define TK_CONSUMERS 143 +#define TK_SUBSCRIPTIONS 144 +#define TK_LIKE 145 +#define TK_INDEX 146 +#define TK_FUNCTION 147 +#define TK_INTERVAL 148 +#define TK_TOPIC 149 +#define TK_AS 150 +#define TK_WITH 151 +#define TK_META 152 +#define TK_CONSUMER 153 +#define TK_GROUP 154 +#define TK_DESC 155 +#define TK_DESCRIBE 156 +#define TK_RESET 157 +#define TK_QUERY 158 +#define TK_CACHE 159 +#define TK_EXPLAIN 160 +#define TK_ANALYZE 161 +#define TK_VERBOSE 162 +#define TK_NK_BOOL 163 +#define TK_RATIO 164 +#define TK_NK_FLOAT 165 +#define TK_COMPACT 166 +#define TK_VNODES 167 +#define TK_IN 168 +#define TK_OUTPUTTYPE 169 +#define TK_AGGREGATE 170 +#define TK_BUFSIZE 171 +#define TK_STREAM 172 +#define TK_INTO 173 +#define TK_TRIGGER 174 +#define TK_AT_ONCE 175 +#define TK_WINDOW_CLOSE 176 +#define TK_KILL 177 +#define TK_CONNECTION 178 +#define TK_TRANSACTION 179 +#define TK_BALANCE 180 +#define TK_VGROUP 181 +#define TK_MERGE 182 +#define TK_REDISTRIBUTE 183 +#define TK_SPLIT 184 +#define TK_SYNCDB 185 +#define TK_DELETE 186 +#define TK_NULL 187 +#define TK_NK_QUESTION 188 +#define TK_NK_ARROW 189 +#define TK_ROWTS 190 +#define TK_TBNAME 191 +#define TK_QSTARTTS 192 +#define TK_QENDTS 193 +#define TK_WSTARTTS 194 +#define TK_WENDTS 195 +#define TK_WDURATION 196 +#define TK_CAST 197 +#define TK_NOW 198 +#define TK_TODAY 199 +#define TK_TIMEZONE 200 +#define TK_CLIENT_VERSION 201 +#define TK_SERVER_VERSION 202 +#define TK_SERVER_STATUS 203 +#define TK_CURRENT_USER 204 +#define TK_COUNT 205 +#define TK_LAST_ROW 206 +#define TK_BETWEEN 207 +#define TK_IS 208 +#define TK_NK_LT 209 +#define TK_NK_GT 210 +#define TK_NK_LE 211 +#define TK_NK_GE 212 +#define TK_NK_NE 213 +#define TK_MATCH 214 +#define TK_NMATCH 215 +#define TK_CONTAINS 216 +#define TK_JOIN 217 +#define TK_INNER 218 +#define TK_SELECT 219 +#define TK_DISTINCT 220 +#define TK_WHERE 221 +#define TK_PARTITION 222 +#define TK_BY 223 +#define TK_SESSION 224 +#define TK_STATE_WINDOW 225 +#define TK_SLIDING 226 +#define TK_FILL 227 +#define TK_VALUE 228 +#define TK_NONE 229 +#define TK_PREV 230 +#define TK_LINEAR 231 +#define TK_NEXT 232 +#define TK_HAVING 233 +#define TK_RANGE 234 +#define TK_EVERY 235 +#define TK_ORDER 236 +#define TK_SLIMIT 237 +#define TK_SOFFSET 238 +#define TK_LIMIT 239 +#define TK_OFFSET 240 +#define TK_ASC 241 +#define TK_NULLS 242 +#define TK_ID 243 +#define TK_NK_BITNOT 244 +#define TK_INSERT 245 +#define TK_VALUES 246 +#define TK_IMPORT 247 +#define TK_NK_SEMI 248 +#define TK_FILE 249 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/libs/executor/executor.h b/include/libs/executor/executor.h index 00acc4741d..6b4772dc2e 100644 --- a/include/libs/executor/executor.h +++ b/include/libs/executor/executor.h @@ -36,15 +36,8 @@ typedef struct SReadHandle { void* vnode; void* mnd; SMsgCb* pMsgCb; -// int8_t initTsdbReader; } SReadHandle; -enum { - STREAM_DATA_TYPE_SUBMIT_BLOCK = 1, - STREAM_DATA_TYPE_SSDATA_BLOCK = 2, - STREAM_DATA_TYPE_FROM_SNAPSHOT = 3, -}; - typedef enum { OPTR_EXEC_MODEL_BATCH = 0x1, OPTR_EXEC_MODEL_STREAM = 0x2, @@ -140,12 +133,6 @@ int32_t qKillTask(qTaskInfo_t tinfo); */ int32_t qAsyncKillTask(qTaskInfo_t tinfo); -/** - * return whether query is completed or not - * @param tinfo - * @return - */ -int32_t qIsTaskCompleted(qTaskInfo_t tinfo); /** * destroy query info structure @@ -176,6 +163,15 @@ int32_t qSerializeTaskStatus(qTaskInfo_t tinfo, char** pOutput, int32_t* len); int32_t qDeserializeTaskStatus(qTaskInfo_t tinfo, const char* pInput, int32_t len); +/** + * return the scan info, in the form of tuple of two items, including table uid and current timestamp + * @param tinfo + * @param uid + * @param ts + * @return + */ +int32_t qGetStreamScanStatus(qTaskInfo_t tinfo, uint64_t* uid, int64_t* ts); + #ifdef __cplusplus } #endif diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index 1ed78750d1..f03422672d 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -105,7 +105,7 @@ typedef enum EFunctionType { // system function FUNCTION_TYPE_DATABASE = 3000, FUNCTION_TYPE_CLIENT_VERSION, - FUNCTION_TYPE_SERVER_SERSION, + FUNCTION_TYPE_SERVER_VERSION, FUNCTION_TYPE_SERVER_STATUS, FUNCTION_TYPE_CURRENT_USER, FUNCTION_TYPE_USER, @@ -125,6 +125,7 @@ typedef enum EFunctionType { FUNCTION_TYPE_BLOCK_DIST_INFO, // block distribution pseudo column function FUNCTION_TYPE_TO_COLUMN, FUNCTION_TYPE_GROUP_KEY, + FUNCTION_TYPE_CACHE_LAST_ROW, // distributed splitting functions FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000, @@ -193,6 +194,7 @@ bool fmIsForbidGroupByFunc(int32_t funcId); bool fmIsIntervalInterpoFunc(int32_t funcId); bool fmIsInterpFunc(int32_t funcId); bool fmIsLastRowFunc(int32_t funcId); +bool fmIsSystemInfoFunc(int32_t funcId); int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc); diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 8031b16d93..659a485959 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -91,6 +91,7 @@ typedef struct SAggLogicNode { SLogicNode node; SNodeList* pGroupKeys; SNodeList* pAggFuncs; + bool hasLastRow; } SAggLogicNode; typedef struct SProjectLogicNode { diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 56d0a3f9b9..9d84f2c32f 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -89,6 +89,7 @@ typedef struct SValueNode { bool isDuration; bool translate; bool notReserved; + bool isNull; int16_t placeholderNo; union { bool b; diff --git a/include/libs/scheduler/scheduler.h b/include/libs/scheduler/scheduler.h index ecb21335b9..be3d16ab0d 100644 --- a/include/libs/scheduler/scheduler.h +++ b/include/libs/scheduler/scheduler.h @@ -69,18 +69,20 @@ typedef struct SSchdFetchParam { int32_t* code; } SSchdFetchParam; -typedef void (*schedulerExecCallback)(SQueryResult* pResult, void* param, int32_t code); -typedef void (*schedulerFetchCallback)(void* pResult, void* param, int32_t code); +typedef void (*schedulerExecFp)(SQueryResult* pResult, void* param, int32_t code); +typedef void (*schedulerFetchFp)(void* pResult, void* param, int32_t code); +typedef bool (*schedulerChkKillFp)(void* param); typedef struct SSchedulerReq { - bool *reqKilled; SRequestConnInfo *pConn; SArray *pNodeList; SQueryPlan *pDag; const char *sql; int64_t startTs; - schedulerExecCallback fp; - void* cbParam; + schedulerExecFp execFp; + void* execParam; + schedulerChkKillFp chkKillFp; + void* chkKillParam; } SSchedulerReq; @@ -110,7 +112,7 @@ int32_t schedulerExecJob(SSchedulerReq *pReq, int64_t *pJob, SQueryResult *pRes) */ int32_t schedulerFetchRows(int64_t job, void **data); -void schedulerAsyncFetchRows(int64_t job, schedulerFetchCallback fp, void* param); +void schedulerAsyncFetchRows(int64_t job, schedulerFetchFp fp, void* param); int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub); diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index db928f194c..67074c789e 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -55,15 +55,6 @@ enum { TASK_OUTPUT_STATUS__BLOCKED, }; -enum { - STREAM_INPUT__DATA_SUBMIT = 1, - STREAM_INPUT__DATA_BLOCK, - STREAM_INPUT__DATA_RETRIEVE, - STREAM_INPUT__TRIGGER, - STREAM_INPUT__CHECKPOINT, - STREAM_INPUT__DROP, -}; - typedef struct { int8_t type; } SStreamQueueItem; @@ -152,10 +143,6 @@ typedef struct { void* executor; } STaskExec; -typedef struct { - int32_t taskId; -} STaskDispatcherInplace; - typedef struct { int32_t taskId; int32_t nodeId; @@ -208,7 +195,6 @@ enum { enum { TASK_DISPATCH__NONE = 1, - TASK_DISPATCH__INPLACE, TASK_DISPATCH__FIXED, TASK_DISPATCH__SHUFFLE, }; @@ -260,7 +246,7 @@ struct SStreamTask { // exec STaskExec exec; - // TODO: merge sink and dispatch + // TODO: unify sink and dispatch // local sink union { @@ -269,9 +255,8 @@ struct SStreamTask { STaskSinkFetch fetchSink; }; - // dispatch + // remote dispatcher union { - STaskDispatcherInplace inplaceDispatcher; STaskDispatcherFixedEp fixedEpDispatcher; STaskDispatcherShuffle shuffleDispatcher; }; @@ -327,9 +312,8 @@ static FORCE_INLINE int32_t streamTaskInput(SStreamTask* pTask, SStreamQueueItem taosWriteQitem(pTask->inputQueue->queue, pItem); } - if (pItem->type != STREAM_INPUT__TRIGGER && pItem->type != STREAM_INPUT__CHECKPOINT && pTask->triggerParam != 0 && - pTask->triggerStatus == TASK_TRIGGER_STATUS__IN_ACTIVE) { - atomic_store_8(&pTask->triggerStatus, TASK_TRIGGER_STATUS__ACTIVE); + if (pItem->type != STREAM_INPUT__TRIGGER && pItem->type != STREAM_INPUT__CHECKPOINT && pTask->triggerParam != 0) { + atomic_val_compare_exchange_8(&pTask->triggerStatus, TASK_TRIGGER_STATUS__IN_ACTIVE, TASK_TRIGGER_STATUS__ACTIVE); } // TODO: back pressure diff --git a/include/libs/sync/syncTools.h b/include/libs/sync/syncTools.h index 5d892352d6..46f279ed85 100644 --- a/include/libs/sync/syncTools.h +++ b/include/libs/sync/syncTools.h @@ -324,6 +324,23 @@ void syncAppendEntriesPrint2(char* s, const SyncAppendEntries* pMsg); void syncAppendEntriesLog(const SyncAppendEntries* pMsg); void syncAppendEntriesLog2(char* s, const SyncAppendEntries* pMsg); +// --------------------------------------------- +typedef struct SyncAppendEntriesBatch { + uint32_t bytes; + int32_t vgId; + uint32_t msgType; + SRaftId srcId; + SRaftId destId; + // private data + SyncTerm term; + SyncIndex prevLogIndex; + SyncTerm prevLogTerm; + SyncIndex commitIndex; + SyncTerm privateTerm; + uint32_t dataLen; + char data[]; +} SyncAppendEntriesBatch; + // --------------------------------------------- typedef struct SyncAppendEntriesReply { uint32_t bytes; diff --git a/packaging/release.sh b/packaging/release.sh index 00a4ad7009..2ac52a0df9 100755 --- a/packaging/release.sh +++ b/packaging/release.sh @@ -111,9 +111,9 @@ else fi csudo="" -if command -v sudo > /dev/null; then - csudo="sudo " -fi +#if command -v sudo > /dev/null; then +# csudo="sudo " +#fi function is_valid_version() { [ -z $1 ] && return 1 || : @@ -182,14 +182,10 @@ cd "${curr_dir}" # 2. cmake executable file compile_dir="${top_dir}/debug" if [ -d ${compile_dir} ]; then - ${csudo}rm -rf ${compile_dir} + rm -rf ${compile_dir} fi -if [ "$osType" != "Darwin" ]; then - ${csudo}mkdir -p ${compile_dir} -else - mkdir -p ${compile_dir} -fi +mkdir -p ${compile_dir} cd ${compile_dir} if [[ "$allocator" == "jemalloc" ]]; then @@ -255,18 +251,18 @@ if [ "$osType" != "Darwin" ]; then echo "====do deb package for the ubuntu system====" output_dir="${top_dir}/debs" if [ -d ${output_dir} ]; then - ${csudo}rm -rf ${output_dir} + rm -rf ${output_dir} fi - ${csudo}mkdir -p ${output_dir} + mkdir -p ${output_dir} cd ${script_dir}/deb ${csudo}./makedeb.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType} if [[ "$pagMode" == "full" ]]; then if [ -d ${top_dir}/tools/taos-tools/packaging/deb ]; then cd ${top_dir}/tools/taos-tools/packaging/deb + taos_tools_ver=$(git describe --tags | sed -e 's/ver-//g' | awk -F '-' '{print $1}') [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" - taos_tools_ver=$(git describe --tags | sed -e 's/ver-//g' | awk -F '-' '{print $1}') ${csudo}./make-taos-tools-deb.sh ${top_dir} \ ${compile_dir} ${output_dir} ${taos_tools_ver} ${cpuType} ${osType} ${verMode} ${verType} fi @@ -280,18 +276,18 @@ if [ "$osType" != "Darwin" ]; then echo "====do rpm package for the centos system====" output_dir="${top_dir}/rpms" if [ -d ${output_dir} ]; then - ${csudo}rm -rf ${output_dir} + rm -rf ${output_dir} fi - ${csudo}mkdir -p ${output_dir} + mkdir -p ${output_dir} cd ${script_dir}/rpm ${csudo}./makerpm.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType} if [[ "$pagMode" == "full" ]]; then if [ -d ${top_dir}/tools/taos-tools/packaging/rpm ]; then cd ${top_dir}/tools/taos-tools/packaging/rpm + taos_tools_ver=$(git describe --tags | sed -e 's/ver-//g' | awk -F '-' '{print $1}' | sed -e 's/-/_/g') [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" - taos_tools_ver=$(git describe --tags | sed -e 's/ver-//g' | awk -F '-' '{print $1}' | sed -e 's/-/_/g') ${csudo}./make-taos-tools-rpm.sh ${top_dir} \ ${compile_dir} ${output_dir} ${taos_tools_ver} ${cpuType} ${osType} ${verMode} ${verType} fi @@ -306,7 +302,7 @@ if [ "$osType" != "Darwin" ]; then ${csudo}./makepkg.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${verNumberComp} ${dbName} ${csudo}./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} - # ${csudo}./makearbi.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} + ${csudo}./makearbi.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} else # only make client for Darwin diff --git a/packaging/rpm/makerpm.sh b/packaging/rpm/makerpm.sh old mode 100644 new mode 100755 diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 3b21258fe1..53292ed46a 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -54,11 +54,10 @@ enum { RES_TYPE__TMQ_META, }; -#define SHOW_VARIABLES_RESULT_COLS 2 +#define SHOW_VARIABLES_RESULT_COLS 2 #define SHOW_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE) #define SHOW_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE) - #define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY) #define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ) #define TD_RES_TMQ_META(res) (*(int8_t*)res == RES_TYPE__TMQ_META) @@ -195,7 +194,7 @@ typedef struct { int32_t vgId; SSchemaWrapper schema; int32_t resIter; - SMqDataBlkRsp rsp; + SMqDataRsp rsp; SReqResultInfo resInfo; } SMqRspObj; @@ -239,18 +238,18 @@ typedef struct SSyncQueryParam { void* doAsyncFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4); void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4); -void doSetOneRowPtr(SReqResultInfo* pResultInfo); -void setResPrecision(SReqResultInfo* pResInfo, int32_t precision); -int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4, - bool freeAfterUse); -void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols); -void doFreeReqResultInfo(SReqResultInfo* pResInfo); -int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, SArray** pReq); -void syncCatalogFn(SMetaData* pResult, void* param, int32_t code); +void doSetOneRowPtr(SReqResultInfo* pResultInfo); +void setResPrecision(SReqResultInfo* pResInfo, int32_t precision); +int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4, + bool freeAfterUse); +void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols); +void doFreeReqResultInfo(SReqResultInfo* pResInfo); +int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, SArray** pReq); +void syncCatalogFn(SMetaData* pResult, void* param, int32_t code); SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen, bool validateOnly); -TAOS_RES *taosQueryImpl(TAOS *taos, const char *sql, bool validateOnly); -void taosAsyncQueryImpl(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param, bool validateOnly); +TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly); +void taosAsyncQueryImpl(TAOS* taos, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly); static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) { SMqRspObj* msg = (SMqRspObj*)res; diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 4cc79096d1..a234311569 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -40,7 +40,7 @@ volatile int32_t tscInitRes = 0; static int32_t registerRequest(SRequestObj *pRequest) { STscObj *pTscObj = acquireTscObj(pRequest->pTscObj->id); if (NULL == pTscObj) { - terrno = TSDB_CODE_TSC_DISCONNECTED; + terrno = TSDB_CODE_TSC_DISCONNECTED; return terrno; } @@ -132,11 +132,11 @@ void closeAllRequests(SHashObj *pRequests) { } } -void destroyAppInst(SAppInstInfo* pAppInfo) { +void destroyAppInst(SAppInstInfo *pAppInfo) { tscDebug("destroy app inst mgr %p", pAppInfo); taosThreadMutexLock(&appInfo.mutex); - + hbRemoveAppHbMrg(&pAppInfo->pAppHbMgr); taosHashRemove(appInfo.pInstMap, pAppInfo->instKey, strlen(pAppInfo->instKey)); @@ -144,10 +144,10 @@ void destroyAppInst(SAppInstInfo* pAppInfo) { taosMemoryFreeClear(pAppInfo->instKey); closeTransporter(pAppInfo); - + taosThreadMutexLock(&pAppInfo->qnodeMutex); taosArrayDestroy(pAppInfo->pQnodeList); - taosThreadMutexUnlock(&pAppInfo->qnodeMutex); + taosThreadMutexUnlock(&pAppInfo->qnodeMutex); taosMemoryFree(pAppInfo); } @@ -160,7 +160,7 @@ void destroyTscObj(void *pObj) { int64_t connNum = atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1); closeAllRequests(pTscObj->pRequests); schedulerStopQueryHb(pTscObj->pAppInfo->pTransporter); - tscDebug("connObj 0x%" PRIx64 " p:%p destroyed, remain inst totalConn:%" PRId64, pTscObj->id, pTscObj, + tscDebug("connObj 0x%" PRIx64 " p:%p destroyed, remain inst totalConn:%" PRId64, pTscObj->id, pTscObj, pTscObj->pAppInfo->numOfConns); if (0 == connNum) { diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 51e43f927b..127fdc979d 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -55,6 +55,18 @@ static char* getClusterKey(const char* user, const char* auth, const char* ip, i return strdup(key); } +bool chkRequestKilled(void* param) { + bool killed = false; + SRequestObj* pRequest = acquireRequest((int64_t)param); + if (NULL == pRequest || pRequest->killed) { + killed = true; + } + + releaseRequest((int64_t)param); + + return killed; +} + static STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __taos_async_fn_t fp, void* param, SAppInstInfo* pAppInfo, int connType); @@ -125,7 +137,7 @@ STscObj* taos_connect_internal(const char* ip, const char* user, const char* pas p->instKey = key; key = NULL; tscDebug("new app inst mgr %p, user:%s, ip:%s, port:%d", p, user, ip, port); - + pInst = &p; } @@ -612,58 +624,6 @@ _return: return code; } -int32_t scheduleAsyncQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) { - tsem_init(&schdRspSem, 0, 0); - - SQueryResult res = {.code = 0, .numOfRows = 0}; - SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter, - .requestId = pRequest->requestId, - .requestObjRefId = pRequest->self}; - SSchedulerReq req = {.pConn = &conn, - .pNodeList = pNodeList, - .pDag = pDag, - .sql = pRequest->sqlstr, - .startTs = pRequest->metric.start, - .fp = schdExecCallback, - .cbParam = &res}; - - int32_t code = schedulerAsyncExecJob(&req, &pRequest->body.queryJob); - - pRequest->body.resInfo.execRes = res.res; - - while (true) { - if (code != TSDB_CODE_SUCCESS) { - if (pRequest->body.queryJob != 0) { - schedulerFreeJob(pRequest->body.queryJob, 0); - } - - pRequest->code = code; - terrno = code; - return pRequest->code; - } else { - tsem_wait(&schdRspSem); - - if (res.code) { - code = res.code; - } else { - break; - } - } - } - - if (TDMT_VND_SUBMIT == pRequest->type || TDMT_VND_CREATE_TABLE == pRequest->type) { - pRequest->body.resInfo.numOfRows = res.numOfRows; - - if (pRequest->body.queryJob != 0) { - schedulerFreeJob(pRequest->body.queryJob, 0); - } - } - - pRequest->code = res.code; - terrno = res.code; - return pRequest->code; -} - int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) { void* pTransporter = pRequest->pTscObj->pAppInfo->pTransporter; @@ -672,13 +632,14 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList .requestId = pRequest->requestId, .requestObjRefId = pRequest->self}; SSchedulerReq req = {.pConn = &conn, - .pNodeList = pNodeList, - .pDag = pDag, - .sql = pRequest->sqlstr, - .startTs = pRequest->metric.start, - .fp = NULL, - .cbParam = NULL, - .reqKilled = &pRequest->killed}; + .pNodeList = pNodeList, + .pDag = pDag, + .sql = pRequest->sqlstr, + .startTs = pRequest->metric.start, + .execFp = NULL, + .execParam = NULL, + .chkKillFp = chkRequestKilled, + .chkKillParam = (void*)pRequest->self}; int32_t code = schedulerExecJob(&req, &pRequest->body.queryJob, &res); pRequest->body.resInfo.execRes = res.res; @@ -878,15 +839,15 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue } break; case QUERY_EXEC_MODE_SCHEDULE: { - SArray* pMnodeList = taosArrayInit(4, sizeof(SQueryNodeLoad)); + SArray* pMnodeList = taosArrayInit(4, sizeof(SQueryNodeLoad)); SQueryPlan* pDag = NULL; code = getPlan(pRequest, pQuery, &pDag, pMnodeList); - if (TSDB_CODE_SUCCESS == code) { + if (TSDB_CODE_SUCCESS == code) { pRequest->body.subplanNum = pDag->numOfSubplans; if (!pRequest->validateOnly) { SArray* pNodeList = NULL; buildSyncExecNodeList(pRequest, &pNodeList, pMnodeList); - + code = scheduleQuery(pRequest, pDag, pNodeList); taosArrayDestroy(pNodeList); } @@ -967,7 +928,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM .pUser = pRequest->pTscObj->user}; SAppInstInfo* pAppInfo = getAppInfo(pRequest); - SQueryPlan* pDag = NULL; + SQueryPlan* pDag = NULL; code = qCreateQueryPlan(&cxt, &pDag, pMnodeList); if (code) { tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code), @@ -987,9 +948,10 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM .pDag = pDag, .sql = pRequest->sqlstr, .startTs = pRequest->metric.start, - .fp = schedulerExecCb, - .cbParam = pRequest, - .reqKilled = &pRequest->killed}; + .execFp = schedulerExecCb, + .execParam = pRequest, + .chkKillFp = chkRequestKilled, + .chkKillParam = (void*)pRequest->self}; code = schedulerAsyncExecJob(&req, &pRequest->body.queryJob); taosArrayDestroy(pNodeList); } else { @@ -1337,7 +1299,7 @@ TAOS* taos_connect_auth(const char* ip, const char* user, const char* auth, cons STscObj* pObj = taos_connect_internal(ip, user, NULL, auth, db, port, CONN_TYPE__QUERY); if (pObj) { - int64_t *rid = taosMemoryCalloc(1, sizeof(int64_t)); + int64_t* rid = taosMemoryCalloc(1, sizeof(int64_t)); *rid = pObj->id; return (TAOS*)rid; } @@ -2028,7 +1990,7 @@ void taosAsyncQueryImpl(TAOS* taos, const char* sql, __taos_async_fn_t fp, void* return; } - int64_t rid = *(int64_t*)taos; + int64_t rid = *(int64_t*)taos; STscObj* pTscObj = acquireTscObj(rid); if (pTscObj == NULL || sql == NULL || NULL == fp) { terrno = TSDB_CODE_INVALID_PARA; @@ -2064,7 +2026,7 @@ void taosAsyncQueryImpl(TAOS* taos, const char* sql, __taos_async_fn_t fp, void* pRequest->body.queryFp = fp; pRequest->body.param = param; doAsyncQuery(pRequest, false); - releaseTscObj(rid); + releaseTscObj(rid); } TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) { @@ -2073,7 +2035,7 @@ TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) { return NULL; } - int64_t rid = *(int64_t*)taos; + int64_t rid = *(int64_t*)taos; STscObj* pTscObj = acquireTscObj(rid); if (pTscObj == NULL || sql == NULL) { terrno = TSDB_CODE_TSC_DISCONNECTED; diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index e568112dfa..d8a9ce581a 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -81,16 +81,16 @@ void taos_cleanup(void) { taosCloseLog(); } -static setConfRet taos_set_config_imp(const char *config){ +static setConfRet taos_set_config_imp(const char *config) { setConfRet ret = {SET_CONF_RET_SUCC, {0}}; // TODO: need re-implementation return ret; } -setConfRet taos_set_config(const char *config){ -// TODO pthread_mutex_lock(&setConfMutex); +setConfRet taos_set_config(const char *config) { + // TODO pthread_mutex_lock(&setConfMutex); setConfRet ret = taos_set_config_imp(config); -// pthread_mutex_unlock(&setConfMutex); + // pthread_mutex_unlock(&setConfMutex); return ret; } @@ -181,8 +181,6 @@ void taos_free_result(TAOS_RES *res) { SMqRspObj *pRsp = (SMqRspObj *)res; if (pRsp->rsp.blockData) taosArrayDestroyP(pRsp->rsp.blockData, taosMemoryFree); if (pRsp->rsp.blockDataLen) taosArrayDestroy(pRsp->rsp.blockDataLen); - if (pRsp->rsp.blockTags) taosArrayDestroy(pRsp->rsp.blockTags); - if (pRsp->rsp.blockTagSchema) taosArrayDestroy(pRsp->rsp.blockTagSchema); if (pRsp->rsp.withTbName) taosArrayDestroyP(pRsp->rsp.blockTbName, taosMemoryFree); if (pRsp->rsp.withSchema) taosArrayDestroyP(pRsp->rsp.blockSchema, (FDelete)tDeleteSSchemaWrapper); pRsp->resInfo.pRspMsg = NULL; @@ -740,6 +738,8 @@ int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt) { .schemalessType = pTscObj->schemalessType, .isSuperUser = (0 == strcmp(pTscObj->user, TSDB_DEFAULT_USER)), .async = true, + .svrVer = pTscObj->sVer, + .nodeOffline = (pTscObj->pAppInfo->onlineDnodes < pTscObj->pAppInfo->totalDnodes) }; return TSDB_CODE_SUCCESS; } diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index ce866d2c20..761eebee42 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -67,11 +67,11 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { dstEpSet.eps[dstEpSet.inUse].fqdn); } else if (connectRsp.dnodeNum > 1 && !isEpsetEqual(&pTscObj->pAppInfo->mgmtEp.epSet, &connectRsp.epSet)) { SEpSet* pOrig = &pTscObj->pAppInfo->mgmtEp.epSet; - SEp* pOrigEp = &pOrig->eps[pOrig->inUse]; - SEp* pNewEp = &connectRsp.epSet.eps[connectRsp.epSet.inUse]; - tscDebug("mnode epset updated from %d/%d=>%s:%d to %d/%d=>%s:%d in connRsp", - pOrig->inUse, pOrig->numOfEps, pOrigEp->fqdn, pOrigEp->port, - connectRsp.epSet.inUse, connectRsp.epSet.numOfEps, pNewEp->fqdn, pNewEp->port); + SEp* pOrigEp = &pOrig->eps[pOrig->inUse]; + SEp* pNewEp = &connectRsp.epSet.eps[connectRsp.epSet.inUse]; + tscDebug("mnode epset updated from %d/%d=>%s:%d to %d/%d=>%s:%d in connRsp", pOrig->inUse, pOrig->numOfEps, + pOrigEp->fqdn, pOrigEp->port, connectRsp.epSet.inUse, connectRsp.epSet.numOfEps, pNewEp->fqdn, + pNewEp->port); updateEpSet_s(&pTscObj->pAppInfo->mgmtEp, &connectRsp.epSet); } @@ -307,13 +307,13 @@ static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) { blockDataEnsureCapacity(pBlock, numOfCfg); for (int32_t i = 0, c = 0; i < numOfCfg; ++i, c = 0) { - SVariablesInfo *pInfo = taosArrayGet(pVars, i); + SVariablesInfo* pInfo = taosArrayGet(pVars, i); char name[TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(name, pInfo->name, TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE); - SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, c++); + SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, c++); colDataAppend(pColInfo, i, name, false); - + char value[TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(value, pInfo->value, TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE); pColInfo = taosArrayGet(pBlock->pDataBlock, c++); @@ -323,14 +323,13 @@ static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) { pBlock->info.rows = numOfCfg; *block = pBlock; - + return TSDB_CODE_SUCCESS; } - static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) { SSDataBlock* pBlock = NULL; - int32_t code = buildShowVariablesBlock(pVars, &pBlock); + int32_t code = buildShowVariablesBlock(pVars, &pBlock); if (code) { return code; } @@ -350,7 +349,7 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) { (*pRsp)->numOfCols = htonl(SHOW_VARIABLES_RESULT_COLS); int32_t len = 0; - blockCompressEncode(pBlock, (*pRsp)->data, &len, SHOW_VARIABLES_RESULT_COLS, false); + blockEncode(pBlock, (*pRsp)->data, &len, SHOW_VARIABLES_RESULT_COLS, false); ASSERT(len == rspSize - sizeof(SRetrieveTableRsp)); blockDataDestroy(pBlock); @@ -362,7 +361,7 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) { if (code != TSDB_CODE_SUCCESS) { setErrno(pRequest, code); } else { - SShowVariablesRsp rsp = {0}; + SShowVariablesRsp rsp = {0}; SRetrieveTableRsp* pRes = NULL; code = tDeserializeSShowVariablesRsp(pMsg->pData, pMsg->len, &rsp); if (TSDB_CODE_SUCCESS == code) { @@ -371,7 +370,7 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) { if (TSDB_CODE_SUCCESS == code) { code = setQueryResultFromRsp(&pRequest->body.resInfo, pRes, false, false); } - + tFreeSShowVariablesRsp(&rsp); } @@ -383,7 +382,6 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) { return code; } - __async_send_cb_fn_t getMsgRspHandle(int32_t msgType) { switch (msgType) { case TDMT_MND_CONNECT: diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 165deaa6c5..c698fe9c17 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -126,8 +126,10 @@ typedef struct { // statistics int64_t pollCnt; // offset - int64_t committedOffset; - int64_t currentOffset; + /*int64_t committedOffset;*/ + /*int64_t currentOffset;*/ + STqOffsetVal committedOffsetNew; + STqOffsetVal currentOffsetNew; // connection info int32_t vgId; int32_t vgStatus; @@ -152,8 +154,8 @@ typedef struct { SMqClientVg* vgHandle; SMqClientTopic* topicHandle; union { - SMqDataBlkRsp dataRsp; - SMqMetaRsp metaRsp; + SMqDataRsp dataRsp; + SMqMetaRsp metaRsp; }; } SMqPollRspWrapper; @@ -179,6 +181,7 @@ typedef struct { tsem_t rspSem; } SMqPollCbParam; +#if 0 typedef struct { tmq_t* tmq; int8_t async; @@ -190,12 +193,13 @@ typedef struct { SArray* offsets; void* userParam; } SMqCommitCbParam; +#endif typedef struct { - tmq_t* tmq; - int8_t automatic; - int8_t async; - int8_t freeOffsets; + tmq_t* tmq; + int8_t automatic; + int8_t async; + /*int8_t freeOffsets;*/ int32_t waitingRspNum; int32_t totalRspNum; int32_t rspErr; @@ -351,6 +355,7 @@ static int32_t tmqMakeTopicVgKey(char* dst, const char* topicName, int32_t vg) { return sprintf(dst, "%s:%d", topicName, vg); } +#if 0 int32_t tmqCommitCb(void* param, const SDataBuf* pMsg, int32_t code) { SMqCommitCbParam* pParam = (SMqCommitCbParam*)param; pParam->rspErr = code; @@ -371,6 +376,7 @@ int32_t tmqCommitCb(void* param, const SDataBuf* pMsg, int32_t code) { } return 0; } +#endif int32_t tmqCommitCb2(void* param, SDataBuf* pBuf, int32_t code) { SMqCommitCbParam2* pParam = (SMqCommitCbParam2*)param; @@ -413,139 +419,148 @@ int32_t tmqCommitCb2(void* param, SDataBuf* pBuf, int32_t code) { return 0; } +static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pTopic, SMqCommitCbParamSet* pParamSet) { + STqOffset* pOffset = taosMemoryCalloc(1, sizeof(STqOffset)); + if (pOffset == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + pOffset->val = pVg->currentOffsetNew; + + int32_t groupLen = strlen(tmq->groupId); + memcpy(pOffset->subKey, tmq->groupId, groupLen); + pOffset->subKey[groupLen] = TMQ_SEPARATOR; + strcpy(pOffset->subKey + groupLen + 1, pTopic->topicName); + + int32_t len; + int32_t code; + tEncodeSize(tEncodeSTqOffset, pOffset, len, code); + if (code < 0) { + ASSERT(0); + return -1; + } + void* buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len); + if (buf == NULL) return -1; + ((SMsgHead*)buf)->vgId = htonl(pVg->vgId); + + void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); + + SEncoder encoder; + tEncoderInit(&encoder, abuf, len); + tEncodeSTqOffset(&encoder, pOffset); + + // build param + SMqCommitCbParam2* pParam = taosMemoryCalloc(1, sizeof(SMqCommitCbParam2)); + pParam->params = pParamSet; + pParam->pOffset = pOffset; + + // build send info + SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); + if (pMsgSendInfo == NULL) { + return -1; + } + pMsgSendInfo->msgInfo = (SDataBuf){ + .pData = buf, + .len = sizeof(SMsgHead) + len, + .handle = NULL, + }; + + tscDebug("consumer %ld commit offset of %s on vg %d, offset is %ld", tmq->consumerId, pOffset->subKey, pVg->vgId, + pOffset->val.version); + + // TODO: put into cb + pVg->committedOffsetNew = pVg->currentOffsetNew; + + pMsgSendInfo->requestId = generateRequestId(); + pMsgSendInfo->requestObjRefId = 0; + pMsgSendInfo->param = pParam; + pMsgSendInfo->fp = tmqCommitCb2; + pMsgSendInfo->msgType = TDMT_VND_MQ_COMMIT_OFFSET; + // send msg + + int64_t transporterId = 0; + asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, pMsgSendInfo); + pParamSet->waitingRspNum++; + pParamSet->totalRspNum++; + return 0; +} + +int32_t tmqCommitMsgImpl(tmq_t* tmq, const TAOS_RES* msg, int8_t async, tmq_commit_cb* userCb, void* userParam) { + char* topic; + int32_t vgId; + ASSERT(msg != NULL); + if (TD_RES_TMQ(msg)) { + SMqRspObj* pRspObj = (SMqRspObj*)msg; + topic = pRspObj->topic; + vgId = pRspObj->vgId; + } else if (TD_RES_TMQ_META(msg)) { + SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)msg; + topic = pMetaRspObj->topic; + vgId = pMetaRspObj->vgId; + } else { + return TSDB_CODE_TMQ_INVALID_MSG; + } + + SMqCommitCbParamSet* pParamSet = taosMemoryCalloc(1, sizeof(SMqCommitCbParamSet)); + if (pParamSet == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + pParamSet->tmq = tmq; + pParamSet->automatic = 0; + pParamSet->async = async; + /*pParamSet->freeOffsets = 1;*/ + pParamSet->userCb = userCb; + pParamSet->userParam = userParam; + tsem_init(&pParamSet->rspSem, 0, 0); + + int32_t code = -1; + + for (int32_t i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) { + SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); + if (strcmp(pTopic->topicName, topic) != 0) continue; + for (int32_t j = 0; j < taosArrayGetSize(pTopic->vgs); j++) { + SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); + if (pVg->vgId != vgId) continue; + + if (pVg->currentOffsetNew.type > 0 && !tOffsetEqual(&pVg->currentOffsetNew, &pVg->committedOffsetNew)) { + if (tmqSendCommitReq(tmq, pVg, pTopic, pParamSet) < 0) { + goto FAIL; + } + goto HANDLE_RSP; + } + } + } + +HANDLE_RSP: + if (pParamSet->totalRspNum == 0) { + tsem_destroy(&pParamSet->rspSem); + taosMemoryFree(pParamSet); + return 0; + } + + if (!async) { + tsem_wait(&pParamSet->rspSem); + code = pParamSet->rspErr; + tsem_destroy(&pParamSet->rspSem); + return code; + } else { + code = 0; + } + +FAIL: + if (code != 0 && async) { + userCb(tmq, code, userParam); + } + return 0; +} + int32_t tmqCommitInner2(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_t async, tmq_commit_cb* userCb, void* userParam) { int32_t code = -1; if (msg != NULL) { - char* topic; - int32_t vgId; - if (TD_RES_TMQ(msg)) { - SMqRspObj* pRspObj = (SMqRspObj*)msg; - topic = pRspObj->topic; - vgId = pRspObj->vgId; - } else if (TD_RES_TMQ_META(msg)) { - SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)msg; - topic = pMetaRspObj->topic; - vgId = pMetaRspObj->vgId; - } else { - return TSDB_CODE_TMQ_INVALID_MSG; - } - - SMqCommitCbParamSet* pParamSet = taosMemoryCalloc(1, sizeof(SMqCommitCbParamSet)); - if (pParamSet == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - pParamSet->tmq = tmq; - pParamSet->automatic = automatic; - pParamSet->async = async; - pParamSet->freeOffsets = 1; - pParamSet->userCb = userCb; - pParamSet->userParam = userParam; - tsem_init(&pParamSet->rspSem, 0, 0); - - for (int32_t i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) { - SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); - if (strcmp(pTopic->topicName, topic) == 0) { - for (int32_t j = 0; j < taosArrayGetSize(pTopic->vgs); j++) { - SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); - if (pVg->vgId == vgId) { - if (pVg->currentOffset < 0 || pVg->committedOffset == pVg->currentOffset) { - tscDebug("consumer %ld skip commit for topic %s vg %d, current offset is %ld, committed offset is %ld", - tmq->consumerId, pTopic->topicName, pVg->vgId, pVg->currentOffset, pVg->committedOffset); - - return 0; - } - - STqOffset* pOffset = taosMemoryCalloc(1, sizeof(STqOffset)); - if (pOffset == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - pOffset->type = TMQ_OFFSET__LOG; - pOffset->version = pVg->currentOffset; - - int32_t groupLen = strlen(tmq->groupId); - memcpy(pOffset->subKey, tmq->groupId, groupLen); - pOffset->subKey[groupLen] = TMQ_SEPARATOR; - strcpy(pOffset->subKey + groupLen + 1, pTopic->topicName); - - int32_t len; - int32_t code; - tEncodeSize(tEncodeSTqOffset, pOffset, len, code); - if (code < 0) { - ASSERT(0); - } - void* buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len); - ((SMsgHead*)buf)->vgId = htonl(pVg->vgId); - - void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); - - SEncoder encoder; - tEncoderInit(&encoder, abuf, len); - tEncodeSTqOffset(&encoder, pOffset); - - // build param - SMqCommitCbParam2* pParam = taosMemoryCalloc(1, sizeof(SMqCommitCbParam2)); - pParam->params = pParamSet; - pParam->pOffset = pOffset; - - // build send info - SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); - if (pMsgSendInfo == NULL) { - // TODO - continue; - } - pMsgSendInfo->msgInfo = (SDataBuf){ - .pData = buf, - .len = sizeof(SMsgHead) + len, - .handle = NULL, - }; - - tscDebug("consumer %ld commit offset of %s on vg %d, offset is %ld", tmq->consumerId, pOffset->subKey, - pVg->vgId, pOffset->version); - - // TODO: put into cb - pVg->committedOffset = pVg->currentOffset; - - pMsgSendInfo->requestId = generateRequestId(); - pMsgSendInfo->requestObjRefId = 0; - pMsgSendInfo->param = pParam; - pMsgSendInfo->fp = tmqCommitCb2; - pMsgSendInfo->msgType = TDMT_VND_MQ_COMMIT_OFFSET; - // send msg - - int64_t transporterId = 0; - asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, pMsgSendInfo); - pParamSet->waitingRspNum++; - pParamSet->totalRspNum++; - } - } - } - } - if (pParamSet->totalRspNum == 0) { - tsem_destroy(&pParamSet->rspSem); - taosMemoryFree(pParamSet); - return 0; - } - - if (!async) { - tsem_wait(&pParamSet->rspSem); - code = pParamSet->rspErr; - tsem_destroy(&pParamSet->rspSem); - } else { - code = 0; - } - - if (code != 0 && async) { - if (automatic) { - tmq->commitCb(tmq, code, tmq->commitCbUserParam); - } else { - userCb(tmq, code, userParam); - } - } - return 0; + return tmqCommitMsgImpl(tmq, msg, async, userCb, userParam); } SMqCommitCbParamSet* pParamSet = taosMemoryCalloc(1, sizeof(SMqCommitCbParamSet)); @@ -556,7 +571,7 @@ int32_t tmqCommitInner2(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_ pParamSet->tmq = tmq; pParamSet->automatic = automatic; pParamSet->async = async; - pParamSet->freeOffsets = 1; + /*pParamSet->freeOffsets = 1;*/ pParamSet->userCb = userCb; pParamSet->userParam = userParam; tsem_init(&pParamSet->rspSem, 0, 0); @@ -572,75 +587,11 @@ int32_t tmqCommitInner2(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_ tscDebug("consumer %ld begin commit for topic %s, vgId %d", tmq->consumerId, pTopic->topicName, pVg->vgId); - /*if (pVg->currentOffset < 0) {*/ - if (pVg->currentOffset < 0 || pVg->committedOffset == pVg->currentOffset) { - tscDebug("consumer %ld skip commit for topic %s vg %d, current offset is %ld, committed offset is %ld", - tmq->consumerId, pTopic->topicName, pVg->vgId, pVg->currentOffset, pVg->committedOffset); - - continue; + if (pVg->currentOffsetNew.type > 0 && !tOffsetEqual(&pVg->currentOffsetNew, &pVg->committedOffsetNew)) { + if (tmqSendCommitReq(tmq, pVg, pTopic, pParamSet) < 0) { + continue; + } } - STqOffset* pOffset = taosMemoryCalloc(1, sizeof(STqOffset)); - if (pOffset == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - pOffset->type = TMQ_OFFSET__LOG; - pOffset->version = pVg->currentOffset; - - int32_t groupLen = strlen(tmq->groupId); - memcpy(pOffset->subKey, tmq->groupId, groupLen); - pOffset->subKey[groupLen] = TMQ_SEPARATOR; - strcpy(pOffset->subKey + groupLen + 1, pTopic->topicName); - - int32_t len; - int32_t code; - tEncodeSize(tEncodeSTqOffset, pOffset, len, code); - if (code < 0) { - ASSERT(0); - } - void* buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len); - ((SMsgHead*)buf)->vgId = htonl(pVg->vgId); - - void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); - - SEncoder encoder; - tEncoderInit(&encoder, abuf, len); - tEncodeSTqOffset(&encoder, pOffset); - - // build param - SMqCommitCbParam2* pParam = taosMemoryCalloc(1, sizeof(SMqCommitCbParam2)); - pParam->params = pParamSet; - pParam->pOffset = pOffset; - - // build send info - SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); - if (pMsgSendInfo == NULL) { - // TODO - continue; - } - pMsgSendInfo->msgInfo = (SDataBuf){ - .pData = buf, - .len = sizeof(SMsgHead) + len, - .handle = NULL, - }; - - tscDebug("consumer %ld commit offset of %s on vg %d, offset is %ld", tmq->consumerId, pOffset->subKey, pVg->vgId, - pOffset->version); - - // TODO: put into cb - pVg->committedOffset = pVg->currentOffset; - - pMsgSendInfo->requestId = generateRequestId(); - pMsgSendInfo->requestObjRefId = 0; - pMsgSendInfo->param = pParam; - pMsgSendInfo->fp = tmqCommitCb2; - pMsgSendInfo->msgType = TDMT_VND_MQ_COMMIT_OFFSET; - // send msg - - int64_t transporterId = 0; - asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, pMsgSendInfo); - pParamSet->waitingRspNum++; - pParamSet->totalRspNum++; } } @@ -1173,8 +1124,11 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { pRspWrapper->topicHandle = pTopic; if (rspType == TMQ_MSG_TYPE__POLL_RSP) { + SDecoder decoder; + tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead)); + tDecodeSMqDataRsp(&decoder, &pRspWrapper->dataRsp); memcpy(&pRspWrapper->dataRsp, pMsg->pData, sizeof(SMqRspHead)); - tDecodeSMqDataBlkRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &pRspWrapper->dataRsp); + /*tDecodeSMqDataBlkRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &pRspWrapper->dataRsp);*/ } else { ASSERT(rspType == TMQ_MSG_TYPE__POLL_META_RSP); memcpy(&pRspWrapper->metaRsp, pMsg->pData, sizeof(SMqRspHead)); @@ -1184,7 +1138,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { taosMemoryFree(pMsg->pData); tscDebug("consumer %ld recv poll: vg %d, req offset %ld, rsp offset %ld, type %d", tmq->consumerId, pVg->vgId, - pRspWrapper->dataRsp.reqOffset, pRspWrapper->dataRsp.rspOffset, rspType); + pRspWrapper->dataRsp.reqOffset.version, pRspWrapper->dataRsp.rspOffset.version, rspType); taosWriteQitem(tmq->mqueue, pRspWrapper); tsem_post(&tmq->rspSem); @@ -1226,9 +1180,11 @@ bool tmqUpdateEp2(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { for (int32_t j = 0; j < vgNumCur; j++) { SMqClientVg* pVgCur = taosArrayGet(pTopicCur->vgs, j); sprintf(vgKey, "%s:%d", pTopicCur->topicName, pVgCur->vgId); - tscDebug("consumer %ld epoch %d vg %d vgKey is %s, offset is %ld", tmq->consumerId, epoch, pVgCur->vgId, vgKey, - pVgCur->currentOffset); - taosHashPut(pHash, vgKey, strlen(vgKey), &pVgCur->currentOffset, sizeof(int64_t)); + char buf[50]; + tFormatOffset(buf, 50, &pVgCur->currentOffsetNew); + tscDebug("consumer %ld epoch %d vg %d vgKey is %s, offset is %s", tmq->consumerId, epoch, pVgCur->vgId, vgKey, + buf); + taosHashPut(pHash, vgKey, strlen(vgKey), &pVgCur->currentOffsetNew, sizeof(STqOffsetVal)); } } } @@ -1247,17 +1203,17 @@ bool tmqUpdateEp2(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { for (int32_t j = 0; j < vgNumGet; j++) { SMqSubVgEp* pVgEp = taosArrayGet(pTopicEp->vgs, j); sprintf(vgKey, "%s:%d", topic.topicName, pVgEp->vgId); - int64_t* pOffset = taosHashGet(pHash, vgKey, strlen(vgKey)); - int64_t offset = tmq->resetOffsetCfg; + STqOffsetVal* pOffset = taosHashGet(pHash, vgKey, strlen(vgKey)); + STqOffsetVal offsetNew = {.type = tmq->resetOffsetCfg}; if (pOffset != NULL) { - offset = *pOffset; + offsetNew = *pOffset; } - tscDebug("consumer %ld(epoch %d) offset of vg %d updated to %ld, vgKey is %s", tmq->consumerId, epoch, - pVgEp->vgId, offset, vgKey); + /*tscDebug("consumer %ld(epoch %d) offset of vg %d updated to %ld, vgKey is %s", tmq->consumerId, epoch,*/ + /*pVgEp->vgId, offset, vgKey);*/ SMqClientVg clientVg = { .pollCnt = 0, - .currentOffset = offset, + .currentOffsetNew = offsetNew, .vgId = pVgEp->vgId, .epSet = pVgEp->epSet, .vgStatus = TMQ_VG_STATUS__IDLE, @@ -1281,7 +1237,7 @@ bool tmqUpdateEp2(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { return set; } -#if 1 +#if 0 bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { /*printf("call update ep %d\n", epoch);*/ bool set = false; @@ -1516,16 +1472,16 @@ int32_t tmq_seek(tmq_t* tmq, const tmq_topic_vgroup_t* offset) { #endif SMqPollReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t timeout, SMqClientTopic* pTopic, SMqClientVg* pVg) { - int64_t reqOffset; - if (pVg->currentOffset >= 0) { - reqOffset = pVg->currentOffset; - } else { - /*if (tmq->resetOffsetCfg == TMQ_CONF__RESET_OFFSET__NONE) {*/ - /*tscError("unable to poll since no committed offset but reset offset is set to none");*/ - /*return NULL;*/ - /*}*/ - reqOffset = tmq->resetOffsetCfg; - } + /*int64_t reqOffset;*/ + /*if (pVg->currentOffset >= 0) {*/ + /*reqOffset = pVg->currentOffset;*/ + /*} else {*/ + /*if (tmq->resetOffsetCfg == TMQ_CONF__RESET_OFFSET__NONE) {*/ + /*tscError("unable to poll since no committed offset but reset offset is set to none");*/ + /*return NULL;*/ + /*}*/ + /*reqOffset = tmq->resetOffsetCfg;*/ + /*}*/ SMqPollReq* pReq = taosMemoryCalloc(1, sizeof(SMqPollReq)); if (pReq == NULL) { @@ -1544,7 +1500,8 @@ SMqPollReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t timeout, SMqClientTopic* pReq->timeout = timeout; pReq->consumerId = tmq->consumerId; pReq->epoch = tmq->epoch; - pReq->currentOffset = reqOffset; + /*pReq->currentOffset = reqOffset;*/ + pReq->reqOffset = pVg->currentOffsetNew; pReq->reqId = generateRequestId(); pReq->useSnapshot = tmq->useSnapshot; @@ -1572,7 +1529,7 @@ SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) { tstrncpy(pRspObj->db, pWrapper->topicHandle->db, TSDB_DB_FNAME_LEN); pRspObj->vgId = pWrapper->vgHandle->vgId; pRspObj->resIter = -1; - memcpy(&pRspObj->rsp, &pWrapper->dataRsp, sizeof(SMqDataBlkRsp)); + memcpy(&pRspObj->rsp, &pWrapper->dataRsp, sizeof(SMqDataRsp)); pRspObj->resInfo.totalRows = 0; pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI; @@ -1645,8 +1602,11 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) { int64_t transporterId = 0; /*printf("send poll\n");*/ - tscDebug("consumer %ld send poll to %s : vg %d, epoch %d, req offset %ld, reqId %lu", tmq->consumerId, - pTopic->topicName, pVg->vgId, tmq->epoch, pVg->currentOffset, pReq->reqId); + + char offsetFormatBuf[50]; + tFormatOffset(offsetFormatBuf, 50, &pVg->currentOffsetNew); + tscDebug("consumer %ld send poll to %s : vg %d, epoch %d, req offset %s, reqId %lu", tmq->consumerId, + pTopic->topicName, pVg->vgId, tmq->epoch, offsetFormatBuf, pReq->reqId); /*printf("send vg %d %ld\n", pVg->vgId, pVg->currentOffset);*/ asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo); pVg->pollCnt++; @@ -1695,7 +1655,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { if (pollRspWrapper->dataRsp.head.epoch == consumerEpoch) { SMqClientVg* pVg = pollRspWrapper->vgHandle; /*printf("vg %d offset %ld up to %ld\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/ - pVg->currentOffset = pollRspWrapper->dataRsp.rspOffset; + pVg->currentOffsetNew = pollRspWrapper->dataRsp.rspOffset; atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); if (pollRspWrapper->dataRsp.blockNum == 0) { taosFreeQitem(pollRspWrapper); @@ -1717,7 +1677,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { if (pollRspWrapper->metaRsp.head.epoch == consumerEpoch) { SMqClientVg* pVg = pollRspWrapper->vgHandle; /*printf("vg %d offset %ld up to %ld\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/ - pVg->currentOffset = pollRspWrapper->metaRsp.rspOffset; + pVg->currentOffsetNew = pollRspWrapper->metaRsp.rspOffsetNew; atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); // build rsp SMqMetaRspObj* pRsp = tmqBuildMetaRspFromWrapper(pollRspWrapper); diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 1ec298ee15..7b142e3053 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1613,7 +1613,8 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) { size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock); int32_t rows = pDataBlock->info.rows; - printf("%s |block type %d |child id %d|group id %zX\n", flag, (int32_t)pDataBlock->info.type, pDataBlock->info.childId, pDataBlock->info.groupId); + printf("%s |block type %d |child id %d|group id %zX\n", flag, (int32_t)pDataBlock->info.type, + pDataBlock->info.childId, pDataBlock->info.groupId); for (int32_t j = 0; j < rows; j++) { printf("%s |", flag); for (int32_t k = 0; k < numOfCols; k++) { @@ -1662,8 +1663,8 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf) int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock); int32_t rows = pDataBlock->info.rows; int32_t len = 0; - len += snprintf(dumpBuf + len, size - len, "\n%s |block type %d |child id %d|\n", flag, - (int32_t)pDataBlock->info.type, pDataBlock->info.childId); + len += snprintf(dumpBuf + len, size - len, "\n%s |block type %d |child id %d|group id %lu|\n", flag, + (int32_t)pDataBlock->info.type, pDataBlock->info.childId, pDataBlock->info.groupId); for (int32_t j = 0; j < rows; j++) { len += snprintf(dumpBuf + len, size - len, "%s |", flag); for (int32_t k = 0; k < colNum; k++) { @@ -1902,8 +1903,7 @@ char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId) { return rname.childTableName; } -void blockCompressEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols, - int8_t needCompress) { +void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols, int8_t needCompress) { // todo extract method int32_t* actualLen = (int32_t*)data; data += sizeof(int32_t); @@ -1913,6 +1913,7 @@ void blockCompressEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen for (int32_t i = 0; i < numOfCols; ++i) { SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i); + *((int16_t*)data) = pColInfoData->info.type; data += sizeof(int16_t); @@ -1960,7 +1961,7 @@ void blockCompressEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen *groupId = pBlock->info.groupId; } -const char* blockCompressDecode(SSDataBlock* pBlock, int32_t numOfCols, int32_t numOfRows, const char* pData) { +const char* blockDecode(SSDataBlock* pBlock, int32_t numOfCols, int32_t numOfRows, const char* pData) { const char* pStart = pData; int32_t dataLen = *(int32_t*)pStart; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 23b33674e4..5baa6984b8 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -621,8 +621,8 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR if (NULL == pReq->pFuncs) return -1; } for (int32_t i = 0; i < numOfFuncs; ++i) { - char *pFunc = NULL; - if (tDecodeCStrAlloc(&decoder, &pFunc) < 0) return -1; + char pFunc[TSDB_FUNC_NAME_LEN] = {0}; + if (tDecodeCStrTo(&decoder, pFunc) < 0) return -1; if (taosArrayPush(pReq->pFuncs, pFunc) == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; @@ -2300,7 +2300,6 @@ int32_t tDeserializeSServerVerRsp(void *buf, int32_t bufLen, SServerVerRsp *pRsp return 0; } - int32_t tSerializeSQnodeListRsp(void *buf, int32_t bufLen, SQnodeListRsp *pRsp) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); @@ -2387,7 +2386,6 @@ int32_t tDeserializeSDnodeListRsp(void *buf, int32_t bufLen, SDnodeListRsp *pRsp void tFreeSDnodeListRsp(SDnodeListRsp *pRsp) { taosArrayDestroy(pRsp->dnodeList); } - int32_t tSerializeSCompactDbReq(void *buf, int32_t bufLen, SCompactDbReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); @@ -2909,20 +2907,19 @@ int32_t tDeserializeSShowVariablesReq(void *buf, int32_t bufLen, SShowVariablesR return 0; } -int32_t tEncodeSVariablesInfo(SEncoder* pEncoder, SVariablesInfo* pInfo) { +int32_t tEncodeSVariablesInfo(SEncoder *pEncoder, SVariablesInfo *pInfo) { if (tEncodeCStr(pEncoder, pInfo->name) < 0) return -1; if (tEncodeCStr(pEncoder, pInfo->value) < 0) return -1; return 0; } -int32_t tDecodeSVariablesInfo(SDecoder* pDecoder, SVariablesInfo* pInfo) { +int32_t tDecodeSVariablesInfo(SDecoder *pDecoder, SVariablesInfo *pInfo) { if (tDecodeCStrTo(pDecoder, pInfo->name) < 0) return -1; if (tDecodeCStrTo(pDecoder, pInfo->value) < 0) return -1; return 0; } - -int32_t tSerializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesRsp* pRsp) { +int32_t tSerializeSShowVariablesRsp(void *buf, int32_t bufLen, SShowVariablesRsp *pRsp) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); @@ -2930,7 +2927,7 @@ int32_t tSerializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesRsp int32_t varNum = taosArrayGetSize(pRsp->variables); if (tEncodeI32(&encoder, varNum) < 0) return -1; for (int32_t i = 0; i < varNum; ++i) { - SVariablesInfo* pInfo = taosArrayGet(pRsp->variables, i); + SVariablesInfo *pInfo = taosArrayGet(pRsp->variables, i); if (tEncodeSVariablesInfo(&encoder, pInfo) < 0) return -1; } tEndEncode(&encoder); @@ -2940,7 +2937,7 @@ int32_t tSerializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesRsp return tlen; } -int32_t tDeserializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesRsp* pRsp) { +int32_t tDeserializeSShowVariablesRsp(void *buf, int32_t bufLen, SShowVariablesRsp *pRsp) { SDecoder decoder = {0}; tDecoderInit(&decoder, buf, bufLen); @@ -2962,11 +2959,11 @@ int32_t tDeserializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesR return 0; } -void tFreeSShowVariablesRsp(SShowVariablesRsp* pRsp) { +void tFreeSShowVariablesRsp(SShowVariablesRsp *pRsp) { if (NULL == pRsp) { return; } - + taosArrayDestroy(pRsp->variables); } @@ -5362,30 +5359,149 @@ void tFreeSMAlterStbRsp(SMAlterStbRsp *pRsp) { } } -int32_t tEncodeSTqOffset(SEncoder *pEncoder, const STqOffset *pOffset) { - if (tEncodeI8(pEncoder, pOffset->type) < 0) return -1; - if (pOffset->type == TMQ_OFFSET__SNAPSHOT) { - if (tEncodeI64(pEncoder, pOffset->uid) < 0) return -1; - if (tEncodeI64(pEncoder, pOffset->ts) < 0) return -1; - } else if (pOffset->type == TMQ_OFFSET__LOG) { - if (tEncodeI64(pEncoder, pOffset->version) < 0) return -1; +int32_t tEncodeSTqOffsetVal(SEncoder *pEncoder, const STqOffsetVal *pOffsetVal) { + if (tEncodeI8(pEncoder, pOffsetVal->type) < 0) return -1; + if (pOffsetVal->type == TMQ_OFFSET__SNAPSHOT_DATA) { + if (tEncodeI64(pEncoder, pOffsetVal->uid) < 0) return -1; + if (tEncodeI64(pEncoder, pOffsetVal->ts) < 0) return -1; + } else if (pOffsetVal->type == TMQ_OFFSET__LOG) { + if (tEncodeI64(pEncoder, pOffsetVal->version) < 0) return -1; + } else if (pOffsetVal->type < 0) { + // do nothing } else { ASSERT(0); } + return 0; +} + +int32_t tDecodeSTqOffsetVal(SDecoder *pDecoder, STqOffsetVal *pOffsetVal) { + if (tDecodeI8(pDecoder, &pOffsetVal->type) < 0) return -1; + if (pOffsetVal->type == TMQ_OFFSET__SNAPSHOT_DATA) { + if (tDecodeI64(pDecoder, &pOffsetVal->uid) < 0) return -1; + if (tDecodeI64(pDecoder, &pOffsetVal->ts) < 0) return -1; + } else if (pOffsetVal->type == TMQ_OFFSET__LOG) { + if (tDecodeI64(pDecoder, &pOffsetVal->version) < 0) return -1; + } else if (pOffsetVal->type < 0) { + // do nothing + } else { + ASSERT(0); + } + return 0; +} + +#if 1 +int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) { + if (pVal->type == TMQ_OFFSET__RESET_NONE) { + snprintf(buf, maxLen, "offset(reset to none)"); + } else if (pVal->type == TMQ_OFFSET__RESET_EARLIEAST) { + snprintf(buf, maxLen, "offset(reset to earlieast)"); + } else if (pVal->type == TMQ_OFFSET__RESET_LATEST) { + snprintf(buf, maxLen, "offset(reset to latest)"); + } else if (pVal->type == TMQ_OFFSET__LOG) { + snprintf(buf, maxLen, "offset(log) ver:%ld", pVal->version); + } else if (pVal->type == TMQ_OFFSET__SNAPSHOT_DATA) { + snprintf(buf, maxLen, "offset(snapshot data) uid:%ld, ts:%ld", pVal->uid, pVal->ts); + } else if (pVal->type == TMQ_OFFSET__SNAPSHOT_META) { + snprintf(buf, maxLen, "offset(snapshot meta) uid:%ld, ts:%ld", pVal->uid, pVal->ts); + } else { + ASSERT(0); + } + return 0; +} +#endif + +bool tOffsetEqual(const STqOffsetVal *pLeft, const STqOffsetVal *pRight) { + if (pLeft->type == pRight->type) { + if (pLeft->type == TMQ_OFFSET__LOG) { + return pLeft->version == pRight->version; + } else if (pLeft->type == TMQ_OFFSET__SNAPSHOT_DATA) { + return pLeft->uid == pRight->uid && pLeft->ts == pRight->ts; + } else if (pLeft->type == TMQ_OFFSET__SNAPSHOT_META) { + ASSERT(0); + // TODO + return pLeft->uid == pRight->uid && pLeft->ts == pRight->ts; + } + } + return false; +} + +int32_t tEncodeSTqOffset(SEncoder *pEncoder, const STqOffset *pOffset) { + if (tEncodeSTqOffsetVal(pEncoder, &pOffset->val) < 0) return -1; if (tEncodeCStr(pEncoder, pOffset->subKey) < 0) return -1; return 0; } int32_t tDecodeSTqOffset(SDecoder *pDecoder, STqOffset *pOffset) { - if (tDecodeI8(pDecoder, &pOffset->type) < 0) return -1; - if (pOffset->type == TMQ_OFFSET__SNAPSHOT) { - if (tDecodeI64(pDecoder, &pOffset->uid) < 0) return -1; - if (tDecodeI64(pDecoder, &pOffset->ts) < 0) return -1; - } else if (pOffset->type == TMQ_OFFSET__LOG) { - if (tDecodeI64(pDecoder, &pOffset->version) < 0) return -1; - } else { - ASSERT(0); - } + if (tDecodeSTqOffsetVal(pDecoder, &pOffset->val) < 0) return -1; if (tDecodeCStrTo(pDecoder, pOffset->subKey) < 0) return -1; return 0; } + +int32_t tEncodeSMqDataRsp(SEncoder *pEncoder, const SMqDataRsp *pRsp) { + if (tEncodeSTqOffsetVal(pEncoder, &pRsp->reqOffset) < 0) return -1; + if (tEncodeSTqOffsetVal(pEncoder, &pRsp->rspOffset) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->skipLogNum) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->blockNum) < 0) return -1; + if (pRsp->blockNum != 0) { + if (tEncodeI8(pEncoder, pRsp->withTbName) < 0) return -1; + if (tEncodeI8(pEncoder, pRsp->withSchema) < 0) return -1; + + for (int32_t i = 0; i < pRsp->blockNum; i++) { + int32_t bLen = *(int32_t *)taosArrayGet(pRsp->blockDataLen, i); + void *data = taosArrayGetP(pRsp->blockData, i); + if (tEncodeBinary(pEncoder, (const uint8_t *)data, bLen) < 0) return -1; + if (pRsp->withSchema) { + SSchemaWrapper *pSW = (SSchemaWrapper *)taosArrayGetP(pRsp->blockSchema, i); + if (tEncodeSSchemaWrapper(pEncoder, pSW) < 0) return -1; + } + if (pRsp->withTbName) { + char *tbName = (char *)taosArrayGetP(pRsp->blockTbName, i); + if (tEncodeCStr(pEncoder, tbName) < 0) return -1; + } + } + } + return 0; +} + +int32_t tDecodeSMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) { + if (tDecodeSTqOffsetVal(pDecoder, &pRsp->reqOffset) < 0) return -1; + if (tDecodeSTqOffsetVal(pDecoder, &pRsp->rspOffset) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->skipLogNum) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->blockNum) < 0) return -1; + if (pRsp->blockNum != 0) { + pRsp->blockData = taosArrayInit(pRsp->blockNum, sizeof(void *)); + pRsp->blockDataLen = taosArrayInit(pRsp->blockNum, sizeof(int32_t)); + if (tDecodeI8(pDecoder, &pRsp->withTbName) < 0) return -1; + if (tDecodeI8(pDecoder, &pRsp->withSchema) < 0) return -1; + if (pRsp->withTbName) { + pRsp->blockTbName = taosArrayInit(pRsp->blockNum, sizeof(void *)); + } + if (pRsp->withSchema) { + pRsp->blockSchema = taosArrayInit(pRsp->blockNum, sizeof(void *)); + } + + for (int32_t i = 0; i < pRsp->blockNum; i++) { + void *data; + uint64_t bLen; + if (tDecodeBinaryAlloc(pDecoder, &data, &bLen) < 0) return -1; + taosArrayPush(pRsp->blockData, &data); + int32_t len = bLen; + taosArrayPush(pRsp->blockDataLen, &len); + + if (pRsp->withSchema) { + SSchemaWrapper *pSW = (SSchemaWrapper *)taosMemoryCalloc(1, sizeof(SSchemaWrapper)); + if (pSW == NULL) return -1; + if (tDecodeSSchemaWrapper(pDecoder, pSW) < 0) return -1; + taosArrayPush(pRsp->blockSchema, &pSW); + } + + if (pRsp->withTbName) { + char *tbName; + if (tDecodeCStrAlloc(pDecoder, &tbName) < 0) return -1; + taosArrayPush(pRsp->blockTbName, &tbName); + } + } + } + return 0; +} + diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c index 980749ca70..234a133243 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c @@ -17,7 +17,6 @@ #include "dmInt.h" #include "systable.h" - extern SConfig *tsCfg; static void dmUpdateDnodeCfg(SDnodeMgmt *pMgmt, SDnodeCfg *pCfg) { @@ -83,7 +82,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) { (*pMgmt->getVnodeLoadsFp)(&vinfo); req.pVloads = vinfo.pVloads; - SMonMloadInfo minfo = {0}; + SMonMloadInfo minfo = {0}; (*pMgmt->getMnodeLoadsFp)(&minfo); req.mload = minfo.load; @@ -186,10 +185,10 @@ int32_t dmProcessServerRunStatus(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) { return 0; } -SSDataBlock* dmBuildVariablesBlock(void) { - SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); +SSDataBlock *dmBuildVariablesBlock(void) { + SSDataBlock *pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); size_t size = 0; - const SSysTableMeta* pMeta = NULL; + const SSysTableMeta *pMeta = NULL; getInfosDbMeta(&pMeta, &size); int32_t index = 0; @@ -215,7 +214,7 @@ SSDataBlock* dmBuildVariablesBlock(void) { return pBlock; } -int32_t dmAppendVariablesToBlock(SSDataBlock* pBlock, int32_t dnodeId) { +int32_t dmAppendVariablesToBlock(SSDataBlock *pBlock, int32_t dnodeId) { int32_t numOfCfg = taosArrayGetSize(tsCfg->array); int32_t numOfRows = 0; blockDataEnsureCapacity(pBlock, numOfCfg); @@ -230,8 +229,8 @@ int32_t dmAppendVariablesToBlock(SSDataBlock* pBlock, int32_t dnodeId) { STR_WITH_MAXSIZE_TO_VARSTR(name, pItem->name, TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE); pColInfo = taosArrayGet(pBlock->pDataBlock, c++); colDataAppend(pColInfo, i, name, false); - - char value[TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE] = {0}; + + char value[TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE] = {0}; int32_t valueLen = 0; cfgDumpItemValue(pItem, &value[VARSTR_HEADER_SIZE], TSDB_CONFIG_VALUE_LEN, &valueLen); varDataSetLen(value, valueLen); @@ -241,9 +240,8 @@ int32_t dmAppendVariablesToBlock(SSDataBlock* pBlock, int32_t dnodeId) { numOfRows++; } - pBlock->info.rows = numOfRows; - + return TSDB_CODE_SUCCESS; } @@ -267,7 +265,7 @@ int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) { return -1; } - SSDataBlock* pBlock = dmBuildVariablesBlock(); + SSDataBlock *pBlock = dmBuildVariablesBlock(); dmAppendVariablesToBlock(pBlock, pMgmt->pData->dnodeId); @@ -283,14 +281,14 @@ int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) { return -1; } - char *pStart = pRsp->data; + char *pStart = pRsp->data; *(int32_t *)pStart = htonl(numOfCols); pStart += sizeof(int32_t); // number of columns for (int32_t i = 0; i < numOfCols; ++i) { SSysTableSchema *pSchema = (SSysTableSchema *)pStart; SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, i); - + pSchema->bytes = htonl(pColInfo->info.bytes); pSchema->colId = htons(pColInfo->info.colId); pSchema->type = pColInfo->info.type; @@ -299,7 +297,7 @@ int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) { } int32_t len = 0; - blockCompressEncode(pBlock, pStart, &len, numOfCols, false); + blockEncode(pBlock, pStart, &len, numOfCols, false); pRsp->numOfRows = htonl(pBlock->info.rows); pRsp->precision = TSDB_TIME_PRECISION_MILLI; // millisecond time precision diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index 5e1ef23f1c..91ef292360 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c @@ -107,13 +107,7 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf const STraceId *trace = &pMsg->info.traceId; dGTrace("vgId:%d, msg:%p get from vnode-sync queue", pVnode->vgId, pMsg); - int32_t code = vnodeProcessSyncReq(pVnode->pImpl, pMsg, NULL); - if (code != 0) { - if (terrno != 0) code = terrno; - dGError("vgId:%d, msg:%p failed to sync since %s", pVnode->vgId, pMsg, terrstr()); - vmSendRsp(pMsg, code); - } - + int32_t code = vnodeProcessSyncReq(pVnode->pImpl, pMsg, NULL); // no response here dGTrace("vgId:%d, msg:%p is freed, code:0x%x", pVnode->vgId, pMsg, code); rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index 939d6f52f3..35d478177a 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -265,7 +265,7 @@ int32_t dmInitClient(SDnode *pDnode) { SDnodeTrans *pTrans = &pDnode->trans; SRpcInit rpcInit = {0}; - rpcInit.label = "DND"; + rpcInit.label = "DND-C"; rpcInit.numOfThreads = 1; rpcInit.cfp = (RpcCfp)dmProcessRpcMsg; rpcInit.sessions = 1024; @@ -299,7 +299,7 @@ int32_t dmInitServer(SDnode *pDnode) { SRpcInit rpcInit = {0}; strncpy(rpcInit.localFqdn, tsLocalFqdn, strlen(tsLocalFqdn)); rpcInit.localPort = tsServerPort; - rpcInit.label = "DND"; + rpcInit.label = "DND-S"; rpcInit.numOfThreads = tsNumOfRpcThreads; rpcInit.cfp = (RpcCfp)dmProcessRpcMsg; rpcInit.sessions = tsMaxShellConns; diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index 164bcc7d60..6014adbe95 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -15,8 +15,8 @@ #define _DEFAULT_SOURCE #include "mndShow.h" -#include "systable.h" #include "mndPrivilege.h" +#include "systable.h" #define SHOW_STEP_SIZE 100 @@ -307,7 +307,7 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) { } int32_t len = 0; - blockCompressEncode(pBlock, pStart, &len, pShow->pMeta->numOfColumns, false); + blockEncode(pBlock, pStart, &len, pShow->pMeta->numOfColumns, false); } pRsp->numOfRows = htonl(rowsRead); diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 5c2d2cd712..cef0bbbc01 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -139,19 +139,19 @@ void tsdbCleanupReadHandle(tsdbReaderT queryHandle); // tq -typedef struct STqReadHandle STqReadHandle; +typedef struct STqReadHandle SStreamReader; -STqReadHandle *tqInitSubmitMsgScanner(SMeta *pMeta); +SStreamReader *tqInitSubmitMsgScanner(SMeta *pMeta); -void tqReadHandleSetColIdList(STqReadHandle *pReadHandle, SArray *pColIdList); -int32_t tqReadHandleSetTbUidList(STqReadHandle *pHandle, const SArray *tbUidList); -int32_t tqReadHandleAddTbUidList(STqReadHandle *pHandle, const SArray *tbUidList); -int32_t tqReadHandleRemoveTbUidList(STqReadHandle *pHandle, const SArray *tbUidList); +void tqReadHandleSetColIdList(SStreamReader *pReadHandle, SArray *pColIdList); +int32_t tqReadHandleSetTbUidList(SStreamReader *pHandle, const SArray *tbUidList); +int32_t tqReadHandleAddTbUidList(SStreamReader *pHandle, const SArray *tbUidList); +int32_t tqReadHandleRemoveTbUidList(SStreamReader *pHandle, const SArray *tbUidList); -int32_t tqReadHandleSetMsg(STqReadHandle *pHandle, SSubmitReq *pMsg, int64_t ver); -bool tqNextDataBlock(STqReadHandle *pHandle); -bool tqNextDataBlockFilterOut(STqReadHandle *pHandle, SHashObj *filterOutUids); -int32_t tqRetrieveDataBlock(SSDataBlock *pBlock, STqReadHandle *pHandle); +int32_t tqReadHandleSetMsg(SStreamReader *pHandle, SSubmitReq *pMsg, int64_t ver); +bool tqNextDataBlock(SStreamReader *pHandle); +bool tqNextDataBlockFilterOut(SStreamReader *pHandle, SHashObj *filterOutUids); +int32_t tqRetrieveDataBlock(SSDataBlock *pBlock, SStreamReader *pHandle); // sma int32_t smaGetTSmaDays(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days); diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h index 23ad70bad3..b455d779c1 100644 --- a/source/dnode/vnode/src/inc/sma.h +++ b/source/dnode/vnode/src/inc/sma.h @@ -46,6 +46,10 @@ struct SSmaEnv { SSmaStat *pStat; }; +typedef struct { + int32_t smaRef; +} SSmaMgmt; + #define SMA_ENV_LOCK(env) ((env)->lock) #define SMA_ENV_TYPE(env) ((env)->type) #define SMA_ENV_STAT(env) ((env)->pStat) @@ -58,11 +62,12 @@ struct STSmaStat { struct SRSmaStat { SSma *pSma; - void *tmrHandle; - tmr_h tmrId; - int32_t tmrSeconds; - int8_t triggerStat; - int8_t runningStat; + int64_t refId; // shared by persistence/fetch tasks + void *tmrHandle; // for persistence task + tmr_h tmrId; // for persistence task + int32_t tmrSeconds; // for persistence task + int8_t triggerStat; // for persistence task + int8_t runningStat; // for persistence task SHashObj *rsmaInfoHash; // key: stbUid, value: SRSmaInfo; }; @@ -73,6 +78,7 @@ struct SSmaStat { }; T_REF_DECLARE() }; + #define SMA_TSMA_STAT(s) (&(s)->tsmaStat) #define SMA_RSMA_STAT(s) (&(s)->rsmaStat) #define RSMA_INFO_HASH(r) ((r)->rsmaInfoHash) @@ -80,6 +86,7 @@ struct SSmaStat { #define RSMA_TMR_HANDLE(r) ((r)->tmrHandle) #define RSMA_TRIGGER_STAT(r) (&(r)->triggerStat) #define RSMA_RUNNING_STAT(r) (&(r)->runningStat) +#define RSMA_REF_ID(r) ((r)->refId) enum { TASK_TRIGGER_STAT_INIT = 0, @@ -192,10 +199,18 @@ typedef struct STFInfo STFInfo; typedef struct STFile STFile; struct STFInfo { + // common fields uint32_t magic; uint32_t ftype; uint32_t fver; int64_t fsize; + + // specific fields + union { + struct { + int64_t applyVer[2]; + } qTaskInfo; + }; }; struct STFile { @@ -230,7 +245,7 @@ int32_t tdUpdateTFileHeader(STFile *pTFile); void tdUpdateTFileMagic(STFile *pTFile, void *pCksm); void tdCloseTFile(STFile *pTFile); -void tdGetVndFileName(int32_t vid, const char *dname, const char *fname, char *outputName); +void tdGetVndFileName(int32_t vgId, const char *dname, const char *fname, char *outputName); #ifdef __cplusplus } diff --git a/source/dnode/vnode/src/inc/tq.h b/source/dnode/vnode/src/inc/tq.h index 59c3e95b9c..38a4f28041 100644 --- a/source/dnode/vnode/src/inc/tq.h +++ b/source/dnode/vnode/src/inc/tq.h @@ -39,6 +39,16 @@ extern "C" { #define tqInfo(...) do { if (tqDebugFlag & DEBUG_INFO) { taosPrintLog("TQ ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0) #define tqDebug(...) do { if (tqDebugFlag & DEBUG_DEBUG) { taosPrintLog("TQ ", DEBUG_DEBUG, tqDebugFlag, __VA_ARGS__); }} while(0) #define tqTrace(...) do { if (tqDebugFlag & DEBUG_TRACE) { taosPrintLog("TQ ", DEBUG_TRACE, tqDebugFlag, __VA_ARGS__); }} while(0) + +#define IS_META_MSG(x) ( \ + x == TDMT_VND_CREATE_STB \ + || x == TDMT_VND_ALTER_STB \ + || x == TDMT_VND_DROP_STB \ + || x == TDMT_VND_CREATE_TABLE \ + || x == TDMT_VND_ALTER_TABLE \ + || x == TDMT_VND_DROP_TABLE \ + || x == TDMT_VND_DROP_TTL_TABLE \ +) // clang-format on typedef struct STqOffsetStore STqOffsetStore; @@ -101,12 +111,13 @@ typedef struct { typedef struct { int8_t subType; - STqReadHandle* pExecReader[5]; + SStreamReader* pExecReader[5]; union { STqExecCol execCol; STqExecTb execTb; STqExecDb execDb; }; + } STqExecHandle; typedef struct { @@ -149,9 +160,9 @@ static STqMgmt tqMgmt = {0}; int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalHead** pHeadWithCkSum); // tqExec -int32_t tqDataExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataBlkRsp* pRsp, int32_t workerId); -int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataBlkRsp* pRsp, int32_t workerId); -int32_t tqSendPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataBlkRsp* pRsp); +int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataRsp* pRsp, int32_t workerId); +int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, int32_t workerId); +int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp); // tqMeta int32_t tqMetaOpen(STQ* pTq); diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index baead763ad..6bd7d4edd1 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -27,6 +27,7 @@ #include "tdatablock.h" #include "tdb.h" #include "tencode.h" +#include "tref.h" #include "tfs.h" #include "tglobal.h" #include "tjson.h" diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index 7f115633b9..120d6612a2 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -18,6 +18,9 @@ typedef struct SSmaStat SSmaStat; #define RSMA_TASK_INFO_HASH_SLOT 8 +#define SMA_MGMT_REF_NUM 1024 + +extern SSmaMgmt smaMgmt; // declaration of static functions @@ -25,6 +28,7 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *p static SSmaEnv *tdNewSmaEnv(const SSma *pSma, int8_t smaType, const char *path); static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SSmaEnv **pEnv); static void *tdFreeTSmaStat(STSmaStat *pStat); +static void tdDestroyRSmaStat(void *pRSmaStat); // implementation @@ -128,6 +132,22 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS if (smaType == TSDB_SMA_TYPE_ROLLUP) { SRSmaStat *pRSmaStat = (SRSmaStat *)(*pSmaStat); pRSmaStat->pSma = (SSma *)pSma; + + // init smaMgmt + smaMgmt.smaRef = taosOpenRef(SMA_MGMT_REF_NUM, tdDestroyRSmaStat); + if (smaMgmt.smaRef < 0) { + smaError("init smaRef failed, num:%d", SMA_MGMT_REF_NUM); + terrno = TSDB_CODE_OUT_OF_MEMORY; + return TSDB_CODE_FAILED; + } + + int64_t refId = taosAddRef(smaMgmt.smaRef, pRSmaStat); + if (refId < 0) { + smaError("taosAddRef smaRef failed, since:%s", tstrerror(terrno)); + return TSDB_CODE_FAILED; + } + pRSmaStat->refId = refId; + // init timer RSMA_TMR_HANDLE(pRSmaStat) = taosTmrInit(10000, 100, 10000, "RSMA"); if (!RSMA_TMR_HANDLE(pRSmaStat)) { @@ -169,9 +189,10 @@ static void *tdFreeTSmaStat(STSmaStat *pStat) { return NULL; } -static void tdDestroyRSmaStat(SRSmaStat *pStat) { - if (pStat) { - smaDebug("vgId:%d destroy rsma stat", SMA_VID(pStat->pSma)); +static void tdDestroyRSmaStat(void *pRSmaStat) { + if (pRSmaStat) { + SRSmaStat *pStat = (SRSmaStat *)pRSmaStat; + smaDebug("vgId:%d %s:%d destroy rsma stat %p", SMA_VID(pStat->pSma), __func__, __LINE__, pRSmaStat); // step 1: set persistence task cancelled atomic_store_8(RSMA_TRIGGER_STAT(pStat), TASK_TRIGGER_STAT_CANCELLED); @@ -183,9 +204,11 @@ static void tdDestroyRSmaStat(SRSmaStat *pStat) { if (atomic_load_8(RSMA_RUNNING_STAT(pStat)) == 1) { while (1) { if (atomic_load_8(RSMA_TRIGGER_STAT(pStat)) == TASK_TRIGGER_STAT_FINISHED) { + smaDebug("rsma, persist task finished already"); break; } else { - smaDebug("not destroyed since rsma stat in %" PRIi8, atomic_load_8(RSMA_TRIGGER_STAT(pStat))); + smaDebug("rsma, persist task not finished yet since rsma stat in %" PRIi8, + atomic_load_8(RSMA_TRIGGER_STAT(pStat))); } ++nLoops; if (nLoops > 1000) { @@ -209,7 +232,10 @@ static void tdDestroyRSmaStat(SRSmaStat *pStat) { nLoops = 0; while (1) { if (T_REF_VAL_GET((SSmaStat *)pStat) == 0) { + smaDebug("rsma, all fetch task finished already"); break; + } else { + smaDebug("rsma, fetch tasks not all finished yet"); } ++nLoops; if (nLoops > 1000) { @@ -225,15 +251,13 @@ static void tdDestroyRSmaStat(SRSmaStat *pStat) { } } -static void *tdFreeRSmaStat(SRSmaStat *pStat) { - tdDestroyRSmaStat(pStat); - taosMemoryFreeClear(pStat); - return NULL; -} - void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) { tdDestroySmaState(pSmaStat, smaType); - taosMemoryFreeClear(pSmaStat); + if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { + taosMemoryFreeClear(pSmaStat); + } + // tref used to free rsma stat + return NULL; } @@ -243,17 +267,21 @@ void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) { * @param pSmaStat * @return int32_t */ + int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) { if (pSmaStat) { if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { tdDestroyTSmaStat(SMA_TSMA_STAT(pSmaStat)); } else if (smaType == TSDB_SMA_TYPE_ROLLUP) { - tdDestroyRSmaStat(SMA_RSMA_STAT(pSmaStat)); + SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pSmaStat); + if (taosRemoveRef(smaMgmt.smaRef, RSMA_REF_ID(pRSmaStat)) < 0) { + smaError("remove refId from smaRef failed, refId:0x%" PRIx64, RSMA_REF_ID(pRSmaStat)); + } } else { ASSERT(0); } } - return TSDB_CODE_SUCCESS; + return 0; } int32_t tdLockSma(SSma *pSma) { diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 4402f37c34..41af641e9e 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -18,9 +18,13 @@ #define RSMA_QTASKINFO_PERSIST_MS 7200000 #define RSMA_QTASKINFO_BUFSIZE 32768 #define RSMA_QTASKINFO_HEAD_LEN (sizeof(int32_t) + sizeof(int8_t) + sizeof(int64_t)) // len + type + suid -typedef enum { TD_QTASK_TMP_FILE = 0, TD_QTASK_CUR_FILE } TD_QTASK_FILE_T; -static const char *tdQTaskInfoFname[] = {"qtaskinfo.t", "qtaskinfo"}; +SSmaMgmt smaMgmt = { + .smaRef = -1, +}; + +typedef enum { TD_QTASK_TMP_F = 0, TD_QTASK_CUR_F } TD_QTASK_FILE_T; +static const char *tdQTaskInfoFname[] = {"qtaskinfo.t", "qtaskinfo"}; typedef struct SRSmaQTaskInfoItem SRSmaQTaskInfoItem; typedef struct SRSmaQTaskInfoIter SRSmaQTaskInfoIter; @@ -46,6 +50,7 @@ static int32_t tdRSmaRestoreTSDataReload(SSma *pSma); struct SRSmaInfoItem { SRSmaInfo *pRsmaInfo; + int64_t refId; void *taskInfo; // qTaskInfo_t tmr_h tmrId; int8_t level; @@ -56,11 +61,14 @@ struct SRSmaInfoItem { struct SRSmaInfo { STSchema *pTSchema; - SSma *pSma; + SRSmaStat *pStat; int64_t suid; SRSmaInfoItem items[TSDB_RETENTION_L2]; }; +#define RSMA_INFO_SMA(r) ((r)->pStat->pSma) +#define RSMA_INFO_STAT(r) ((r)->pStat) + struct SRSmaQTaskInfoItem { int32_t len; int8_t type; @@ -80,6 +88,10 @@ struct SRSmaQTaskInfoIter { int32_t nBufPos; }; +static void tdRSmaQTaskInfoGetFName(int32_t vgId, int8_t ftype, char *outputName) { + tdGetVndFileName(vgId, VNODE_RSMA_DIR, tdQTaskInfoFname[ftype], outputName); +} + static FORCE_INLINE int32_t tdRSmaQTaskInfoContLen(int32_t lenWithHead) { return lenWithHead - RSMA_QTASKINFO_HEAD_LEN; } @@ -99,22 +111,21 @@ static FORCE_INLINE void tdFreeTaskHandle(qTaskInfo_t *taskHandle, int32_t vgId, void *tdFreeRSmaInfo(SRSmaInfo *pInfo) { if (pInfo) { + SSma *pSma = RSMA_INFO_SMA(pInfo); for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { SRSmaInfoItem *pItem = &pInfo->items[i]; if (pItem->taskInfo) { - smaDebug("vgId:%d, stb %" PRIi64 " stop fetch-timer %p level %d", SMA_VID(pInfo->pSma), pInfo->suid, - pItem->tmrId, i + 1); + smaDebug("vgId:%d, stb %" PRIi64 " stop fetch-timer %p level %d", SMA_VID(pSma), pInfo->suid, pItem->tmrId, + i + 1); taosTmrStopA(&pItem->tmrId); - tdFreeTaskHandle(&pItem->taskInfo, SMA_VID(pInfo->pSma), i + 1); + tdFreeTaskHandle(&pItem->taskInfo, SMA_VID(pSma), i + 1); } else { - smaDebug("vgId:%d, stb %" PRIi64 " no need to destroy rsma info level %d since empty taskInfo", - SMA_VID(pInfo->pSma), pInfo->suid, i + 1); + smaDebug("vgId:%d, stb %" PRIi64 " no need to destroy rsma info level %d since empty taskInfo", SMA_VID(pSma), + pInfo->suid, i + 1); } } taosMemoryFree(pInfo->pTSchema); taosMemoryFree(pInfo); - } else { - smaDebug("vgId:%d, stb %" PRIi64 " no need to destroy rsma info since empty", SMA_VID(pInfo->pSma), pInfo->suid); } return NULL; @@ -247,6 +258,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaInfo if (param->qmsg[idx]) { SRSmaInfoItem *pItem = &(pRSmaInfo->items[idx]); + pItem->refId = RSMA_REF_ID(pRSmaInfo->pStat); pItem->pRsmaInfo = pRSmaInfo; pItem->taskInfo = qCreateStreamExecTaskInfo(param->qmsg[idx], pReadHandle); if (!pItem->taskInfo) { @@ -313,7 +325,7 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con return TSDB_CODE_FAILED; } - STqReadHandle *pReadHandle = tqInitSubmitMsgScanner(pMeta); + SStreamReader *pReadHandle = tqInitSubmitMsgScanner(pMeta); if (!pReadHandle) { terrno = TSDB_CODE_OUT_OF_MEMORY; goto _err; @@ -332,7 +344,7 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con goto _err; } pRSmaInfo->pTSchema = pTSchema; - pRSmaInfo->pSma = pSma; + pRSmaInfo->pStat = pStat; pRSmaInfo->suid = suid; if (tdSetRSmaInfoItemParams(pSma, param, pRSmaInfo, &handle, 0) < 0) { @@ -514,7 +526,7 @@ static void tdDestroySDataBlockArray(SArray *pArray) { static int32_t tdFetchAndSubmitRSmaResult(SRSmaInfoItem *pItem, int8_t blkType) { SArray *pResult = NULL; SRSmaInfo *pRSmaInfo = pItem->pRsmaInfo; - SSma *pSma = pRSmaInfo->pSma; + SSma *pSma = RSMA_INFO_SMA(pRSmaInfo); while (1) { SSDataBlock *output = NULL; @@ -577,34 +589,44 @@ _err: */ static void tdRSmaFetchTrigger(void *param, void *tmrId) { SRSmaInfoItem *pItem = param; - SSma *pSma = pItem->pRsmaInfo->pSma; - SRSmaStat *pStat = (SRSmaStat *)SMA_ENV_STAT((SSmaEnv *)pSma->pRSmaEnv); + SSma *pSma = NULL; + SRSmaStat *pStat = (SRSmaStat *)taosAcquireRef(smaMgmt.smaRef, pItem->refId); + if (!pStat) { + smaDebug("rsma fetch task not start since already destroyed"); + return; + } + pSma = RSMA_INFO_SMA(pItem->pRsmaInfo); + + // if rsma trigger stat in cancelled or finished, not start fetch task anymore int8_t rsmaTriggerStat = atomic_load_8(RSMA_TRIGGER_STAT(pStat)); if (rsmaTriggerStat == TASK_TRIGGER_STAT_CANCELLED || rsmaTriggerStat == TASK_TRIGGER_STAT_FINISHED) { - smaDebug("vgId:%d, level %" PRIi8 " not fetch since stat is cancelled for table suid:%" PRIi64, SMA_VID(pSma), - pItem->level, pItem->pRsmaInfo->suid); + taosReleaseRef(smaMgmt.smaRef, pItem->refId); + smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is cancelled", + SMA_VID(pSma), pItem->level, pItem->pRsmaInfo->suid); return; } int8_t fetchTriggerStat = atomic_val_compare_exchange_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE, TASK_TRIGGER_STAT_INACTIVE); if (fetchTriggerStat == TASK_TRIGGER_STAT_ACTIVE) { - smaDebug("vgId:%d, level %" PRIi8 " stat is active for table suid:%" PRIi64, SMA_VID(pSma), pItem->level, - pItem->pRsmaInfo->suid); + smaDebug("vgId:%d, fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is active", SMA_VID(pSma), + pItem->level, pItem->pRsmaInfo->suid); tdRefSmaStat(pSma, (SSmaStat *)pStat); SSDataBlock dataBlock = {.info.type = STREAM_GET_ALL}; - qSetStreamInput(pItem->taskInfo, &dataBlock, STREAM_DATA_TYPE_SSDATA_BLOCK, false); - tdFetchAndSubmitRSmaResult(pItem, STREAM_DATA_TYPE_SSDATA_BLOCK); + qSetStreamInput(pItem->taskInfo, &dataBlock, STREAM_INPUT__DATA_BLOCK, false); + tdFetchAndSubmitRSmaResult(pItem, STREAM_INPUT__DATA_BLOCK); tdUnRefSmaStat(pSma, (SSmaStat *)pStat); } else { - smaDebug("vgId:%d, level %" PRIi8 " stat is inactive for table suid:%" PRIi64, SMA_VID(pSma), pItem->level, - pItem->pRsmaInfo->suid); + smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is inactive", + SMA_VID(pSma), pItem->level, pItem->pRsmaInfo->suid); } +_end: + taosReleaseRef(smaMgmt.smaRef, pItem->refId); } static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfoItem *pItem, tb_uid_t suid, @@ -617,14 +639,13 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType smaDebug("vgId:%d, execute rsma %" PRIi8 " task for qTaskInfo:%p suid:%" PRIu64, SMA_VID(pSma), level, pItem->taskInfo, suid); - if (qSetStreamInput(pItem->taskInfo, pMsg, inputType, true) < 0) { // STREAM_DATA_TYPE_SUBMIT_BLOCK + if (qSetStreamInput(pItem->taskInfo, pMsg, inputType, true) < 0) { // INPUT__DATA_SUBMIT smaError("vgId:%d, rsma % " PRIi8 " qSetStreamInput failed since %s", SMA_VID(pSma), level, tstrerror(terrno)); return TSDB_CODE_FAILED; } - tdFetchAndSubmitRSmaResult(pItem, STREAM_DATA_TYPE_SUBMIT_BLOCK); + tdFetchAndSubmitRSmaResult(pItem, STREAM_INPUT__DATA_SUBMIT); atomic_store_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE); - smaDebug("vgId:%d, process rsma insert", SMA_VID(pSma)); SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); SRSmaStat *pStat = SMA_RSMA_STAT(pEnv->pStat); @@ -660,7 +681,7 @@ static int32_t tdExecuteRSma(SSma *pSma, const void *pMsg, int32_t inputType, tb return TSDB_CODE_SUCCESS; } - if (inputType == STREAM_DATA_TYPE_SUBMIT_BLOCK) { + if (inputType == STREAM_INPUT__DATA_SUBMIT) { tdExecuteRSmaImpl(pSma, pMsg, inputType, &pRSmaInfo->items[0], suid, TSDB_RETENTION_L1); tdExecuteRSmaImpl(pSma, pMsg, inputType, &pRSmaInfo->items[1], suid, TSDB_RETENTION_L2); } @@ -681,7 +702,7 @@ int32_t tdProcessRSmaSubmit(SSma *pSma, void *pMsg, int32_t inputType) { return TSDB_CODE_SUCCESS; } - if (inputType == STREAM_DATA_TYPE_SUBMIT_BLOCK) { + if (inputType == STREAM_INPUT__DATA_SUBMIT) { STbUidStore uidStore = {0}; tdFetchSubmitReqSuids(pMsg, &uidStore); @@ -761,7 +782,7 @@ static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma) { STFile tFile = {0}; char qTaskInfoFName[TSDB_FILENAME_LEN]; - tdRSmaQTaskInfoGetFName(TD_VID(pVnode), TD_QTASK_CUR_FILE, qTaskInfoFName); + tdRSmaQTaskInfoGetFName(TD_VID(pVnode), TD_QTASK_TMP_F, qTaskInfoFName); if (tdInitTFile(&tFile, pVnode->pTfs, qTaskInfoFName) < 0) { goto _err; } @@ -797,9 +818,9 @@ _err: /** * @brief reload ts data from checkpoint - * - * @param pSma - * @return int32_t + * + * @param pSma + * @return int32_t */ static int32_t tdRSmaRestoreTSDataReload(SSma *pSma) { // TODO @@ -861,7 +882,8 @@ static int32_t tdRSmaQTaskInfoItemRestore(SSma *pSma, const SRSmaQTaskInfoItem * pItem->type, terrstr(terrno)); return TSDB_CODE_FAILED; } - smaDebug("vgId:%d, restore rsma task success for table:%" PRIi64 " level %d", SMA_VID(pSma), pItem->suid, pItem->type); + smaDebug("vgId:%d, restore rsma task success for table:%" PRIi64 " level %d", SMA_VID(pSma), pItem->suid, + pItem->type); return TSDB_CODE_SUCCESS; } @@ -1003,10 +1025,6 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) { return TSDB_CODE_SUCCESS; } -static void tdRSmaQTaskInfoGetFName(int32_t vid, int8_t ftype, char *outputName) { - tdGetVndFileName(vid, VNODE_RSMA_DIR, tdQTaskInfoFname[ftype], outputName); -} - static void *tdRSmaPersistExec(void *param) { setThreadName("rsma-task-persist"); SRSmaStat *pRSmaStat = param; @@ -1031,7 +1049,7 @@ static void *tdRSmaPersistExec(void *param) { for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { qTaskInfo_t taskInfo = pRSmaInfo->items[i].taskInfo; if (!taskInfo) { - smaDebug("vgId:%d, table %" PRIi64 " level %d qTaskInfo is NULL", vid, pRSmaInfo->suid, i + 1); + smaDebug("vgId:%d, rsma, table %" PRIi64 " level %d qTaskInfo is NULL", vid, pRSmaInfo->suid, i + 1); continue; } @@ -1039,31 +1057,24 @@ static void *tdRSmaPersistExec(void *param) { int32_t len = 0; int8_t type = (int8_t)(i + 1); if (qSerializeTaskStatus(taskInfo, &pOutput, &len) < 0) { - smaError("vgId:%d, table %" PRIi64 " level %d serialize rsma task failed since %s", vid, pRSmaInfo->suid, i + 1, - terrstr(terrno)); + smaError("vgId:%d, rsma, table %" PRIi64 " level %d serialize qTaskInfo failed since %s", vid, pRSmaInfo->suid, + i + 1, terrstr(terrno)); goto _err; } if (!pOutput || len <= 0) { - smaDebug("vgId:%d, table %" PRIi64 " level %d serialize rsma task success but no output(len %d), not persist", + smaDebug("vgId:%d, rsma, table %" PRIi64 + " level %d serialize qTaskInfo success but no output(len %d), not persist", vid, pRSmaInfo->suid, i + 1, len); taosMemoryFreeClear(pOutput); continue; } - smaDebug("vgId:%d, table %" PRIi64 " level %d serialize rsma task success with len %d, need persist", vid, + smaDebug("vgId:%d, rsma, table %" PRIi64 " level %d serialize qTaskInfo success with len %d, need persist", vid, pRSmaInfo->suid, i + 1, len); -#if 0 - if (qDeserializeTaskStatus(taskInfo, pOutput, len) < 0) { - smaError("vgId:%d, table %" PRIi64 "level %d deserialize rsma task failed since %s", vid, pRSmaInfo->suid, - i + 1, terrstr(terrno)); - } else { - smaDebug("vgId:%d, table %" PRIi64 " level %d deserialize rsma task success", vid, pRSmaInfo->suid, i + 1); - } -#endif if (!isFileCreated) { char qTaskInfoFName[TSDB_FILENAME_LEN]; - tdRSmaQTaskInfoGetFName(vid, TD_QTASK_TMP_FILE, qTaskInfoFName); + tdRSmaQTaskInfoGetFName(vid, TD_QTASK_TMP_F, qTaskInfoFName); tdInitTFile(&tFile, pTfs, qTaskInfoFName); tdCreateTFile(&tFile, pTfs, true, -1); @@ -1079,11 +1090,11 @@ static void *tdRSmaPersistExec(void *param) { ASSERT(headLen <= RSMA_QTASKINFO_HEAD_LEN); tdAppendTFile(&tFile, (void *)&tmpBuf, headLen, &toffset); - smaDebug("vgId:%d, table %" PRIi64 " level %d head part len:%d appended to offset:%" PRIi64, vid, pRSmaInfo->suid, - i + 1, headLen, toffset); + smaDebug("vgId:%d, rsma, table %" PRIi64 " level %d head part(len:%d) appended to offset:%" PRIi64, vid, + pRSmaInfo->suid, i + 1, headLen, toffset); tdAppendTFile(&tFile, pOutput, len, &toffset); - smaDebug("vgId:%d, table %" PRIi64 " level %d body part len:%d appended to offset:%" PRIi64, vid, pRSmaInfo->suid, - i + 1, len, toffset); + smaDebug("vgId:%d, rsma, table %" PRIi64 " level %d body part len:%d appended to offset:%" PRIi64, vid, + pRSmaInfo->suid, i + 1, len, toffset); taosMemoryFree(pOutput); } @@ -1093,26 +1104,26 @@ static void *tdRSmaPersistExec(void *param) { _normal: if (isFileCreated) { if (tdUpdateTFileHeader(&tFile) < 0) { - smaError("vgId:%d, failed to update tfile %s header since %s", vid, TD_TFILE_FULL_NAME(&tFile), + smaError("vgId:%d, rsma, failed to update tfile %s header since %s", vid, TD_TFILE_FULL_NAME(&tFile), tstrerror(terrno)); tdCloseTFile(&tFile); tdRemoveTFile(&tFile); goto _err; } else { - smaDebug("vgId:%d, succeed to update tfile %s header", vid, TD_TFILE_FULL_NAME(&tFile)); + smaDebug("vgId:%d, rsma, succeed to update tfile %s header", vid, TD_TFILE_FULL_NAME(&tFile)); } tdCloseTFile(&tFile); char newFName[TSDB_FILENAME_LEN]; strncpy(newFName, TD_TFILE_FULL_NAME(&tFile), TSDB_FILENAME_LEN); - char *pos = strstr(newFName, tdQTaskInfoFname[TD_QTASK_TMP_FILE]); - strncpy(pos, tdQTaskInfoFname[TD_QTASK_CUR_FILE], TSDB_FILENAME_LEN - POINTER_DISTANCE(pos, newFName)); + char *pos = strstr(newFName, tdQTaskInfoFname[TD_QTASK_TMP_F]); + strncpy(pos, tdQTaskInfoFname[TD_QTASK_TMP_F], TSDB_FILENAME_LEN - POINTER_DISTANCE(pos, newFName)); if (taosRenameFile(TD_TFILE_FULL_NAME(&tFile), newFName) != 0) { - smaError("vgId:%d, failed to rename %s to %s", vid, TD_TFILE_FULL_NAME(&tFile), newFName); + smaError("vgId:%d, rsma, failed to rename %s to %s", vid, TD_TFILE_FULL_NAME(&tFile), newFName); goto _err; } else { - smaDebug("vgId:%d, succeed to rename %s to %s", vid, TD_TFILE_FULL_NAME(&tFile), newFName); + smaDebug("vgId:%d, rsma, succeed to rename %s to %s", vid, TD_TFILE_FULL_NAME(&tFile), newFName); } } goto _end; @@ -1124,16 +1135,17 @@ _end: if (TASK_TRIGGER_STAT_INACTIVE == atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_INACTIVE, TASK_TRIGGER_STAT_ACTIVE)) { - smaDebug("vgId:%d, persist task is active again", vid); + smaDebug("vgId:%d, rsma persist task is active again", vid); } else if (TASK_TRIGGER_STAT_CANCELLED == atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_CANCELLED, TASK_TRIGGER_STAT_FINISHED)) { - smaDebug("vgId:%d, persist task is cancelled", vid); + smaDebug("vgId:%d, rsma persist task is cancelled", vid); } else { - smaWarn("vgId:%d, persist task in abnormal stat %" PRIi8, vid, atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat))); + smaWarn("vgId:%d, rsma persist task in abnormal stat %" PRIi8, vid, atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat))); ASSERT(0); } atomic_store_8(RSMA_RUNNING_STAT(pRSmaStat), 0); + taosReleaseRef(smaMgmt.smaRef, pRSmaStat->refId); taosThreadExit(NULL); return NULL; } @@ -1159,6 +1171,7 @@ static void tdRSmaPersistTask(SRSmaStat *pRSmaStat) { ASSERT(0); } atomic_store_8(RSMA_RUNNING_STAT(pRSmaStat), 0); + taosReleaseRef(smaMgmt.smaRef, pRSmaStat->refId); } taosThreadAttrDestroy(&thAttr); @@ -1171,7 +1184,13 @@ static void tdRSmaPersistTask(SRSmaStat *pRSmaStat) { * @param tmrId */ static void tdRSmaPersistTrigger(void *param, void *tmrId) { - SRSmaStat *pRSmaStat = param; + SRSmaStat *rsmaStat = param; + SRSmaStat *pRSmaStat = (SRSmaStat *)taosAcquireRef(smaMgmt.smaRef, rsmaStat->refId); + + if (!pRSmaStat) { + smaDebug("rsma persistence task not start since already destroyed"); + return; + } int8_t tmrStat = atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_ACTIVE, TASK_TRIGGER_STAT_INACTIVE); @@ -1191,6 +1210,7 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) { } else { atomic_store_8(RSMA_RUNNING_STAT(pRSmaStat), 0); } + return; } break; case TASK_TRIGGER_STAT_CANCELLED: { atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_FINISHED); @@ -1206,4 +1226,5 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) { smaWarn("rsma persistence not start since unknown stat %" PRIi8, tmrStat); } break; } + taosReleaseRef(smaMgmt.smaRef, rsmaStat->refId); } diff --git a/source/dnode/vnode/src/sma/smaUtil.c b/source/dnode/vnode/src/sma/smaUtil.c index 5f78aadddf..17bc2cdaca 100644 --- a/source/dnode/vnode/src/sma/smaUtil.c +++ b/source/dnode/vnode/src/sma/smaUtil.c @@ -141,8 +141,8 @@ int64_t tdAppendTFile(STFile *pTFile, void *buf, int64_t nbyte, int64_t *offset) } #if 1 - smaDebug("append to file %s, offset:%" PRIi64 " + nbyte:%" PRIi64 " =%" PRIi64, TD_TFILE_FULL_NAME(pTFile), toffset, - nbyte, toffset + nbyte); + smaDebug("append to file %s, offset:%" PRIi64 " nbyte:%" PRIi64 " fsize:%" PRIi64, TD_TFILE_FULL_NAME(pTFile), + toffset, nbyte, toffset + nbyte); #endif ASSERT(pTFile->info.fsize == toffset); @@ -179,8 +179,8 @@ void tdCloseTFile(STFile *pTFile) { } } -void tdGetVndFileName(int32_t vid, const char *dname, const char *fname, char *outputName) { - snprintf(outputName, TSDB_FILENAME_LEN, "vnode/vnode%d/%s/%s", vid, dname, fname); +void tdGetVndFileName(int32_t vgId, const char *dname, const char *fname, char *outputName) { + snprintf(outputName, TSDB_FILENAME_LEN, "vnode/vnode%d/%s/%s", vgId, dname, fname); } int32_t tdInitTFile(STFile *pTFile, STfs *pTfs, const char *fname) { diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 766cf7af35..a08515ed5c 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -113,8 +113,23 @@ int32_t tqSendMetaPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, return 0; } -int32_t tqSendPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataBlkRsp* pRsp) { - int32_t tlen = sizeof(SMqRspHead) + tEncodeSMqDataBlkRsp(NULL, pRsp); +int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp) { + ASSERT(taosArrayGetSize(pRsp->blockData) == pRsp->blockNum); + ASSERT(taosArrayGetSize(pRsp->blockDataLen) == pRsp->blockNum); + + if (pRsp->withSchema) { + ASSERT(taosArrayGetSize(pRsp->blockSchema) == pRsp->blockNum); + } else { + ASSERT(taosArrayGetSize(pRsp->blockSchema) == 0); + } + + int32_t len; + int32_t code; + tEncodeSize(tEncodeSMqDataRsp, pRsp, len, code); + if (code < 0) { + return -1; + } + int32_t tlen = sizeof(SMqRspHead) + len; void* buf = rpcMallocCont(tlen); if (buf == NULL) { return -1; @@ -125,18 +140,26 @@ int32_t tqSendPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, con ((SMqRspHead*)buf)->consumerId = pReq->consumerId; void* abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead)); - tEncodeSMqDataBlkRsp(&abuf, pRsp); - SRpcMsg resp = { + SEncoder encoder; + tEncoderInit(&encoder, abuf, len); + tEncodeSMqDataRsp(&encoder, pRsp); + /*tEncodeSMqDataBlkRsp(&abuf, pRsp);*/ + + SRpcMsg rsp = { .info = pMsg->info, .pCont = buf, .contLen = tlen, .code = 0, }; - tmsgSendRsp(&resp); + tmsgSendRsp(&rsp); - tqDebug("vg %d from consumer %ld (epoch %d) send rsp, block num: %d, reqOffset: %ld, rspOffset: %ld", - TD_VID(pTq->pVnode), pReq->consumerId, pReq->epoch, pRsp->blockNum, pRsp->reqOffset, pRsp->rspOffset); + char buf1[50]; + char buf2[50]; + tFormatOffset(buf1, 50, &pRsp->reqOffset); + tFormatOffset(buf2, 50, &pRsp->rspOffset); + tqDebug("vg %d from consumer %ld (epoch %d) send rsp, block num: %d, reqOffset: %s, rspOffset: %s", + TD_VID(pTq->pVnode), pReq->consumerId, pReq->epoch, pRsp->blockNum, buf1, buf2); return 0; } @@ -151,17 +174,17 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen) { } tDecoderClear(&decoder); - if (offset.type == TMQ_OFFSET__SNAPSHOT) { + if (offset.val.type == TMQ_OFFSET__SNAPSHOT_DATA) { tqDebug("receive offset commit msg to %s on vg %d, offset(type:snapshot) uid: %ld, ts: %ld", offset.subKey, - TD_VID(pTq->pVnode), offset.uid, offset.ts); - } else if (offset.type == TMQ_OFFSET__LOG) { + TD_VID(pTq->pVnode), offset.val.uid, offset.val.ts); + } else if (offset.val.type == TMQ_OFFSET__LOG) { tqDebug("receive offset commit msg to %s on vg %d, offset(type:log) version: %ld", offset.subKey, - TD_VID(pTq->pVnode), offset.version); + TD_VID(pTq->pVnode), offset.val.version); } else { ASSERT(0); } STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, offset.subKey); - if (pOffset == NULL || pOffset->version < offset.version) { + if (pOffset == NULL || pOffset->val.version < offset.val.version) { if (tqOffsetWrite(pTq->pOffsetStore, &offset) < 0) { ASSERT(0); return -1; @@ -171,6 +194,238 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen) { return 0; } +static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t subType) { + pRsp->reqOffset = pReq->reqOffset; + + pRsp->blockData = taosArrayInit(0, sizeof(void*)); + pRsp->blockDataLen = taosArrayInit(0, sizeof(int32_t)); + + if (pRsp->blockData == NULL || pRsp->blockDataLen == NULL) { + return -1; + } + + pRsp->withTbName = pReq->withTbName; + if (pRsp->withTbName) { + pRsp->blockTbName = taosArrayInit(0, sizeof(void*)); + if (pRsp->blockTbName == NULL) { + // TODO free + return -1; + } + } + + if (subType == TOPIC_SUB_TYPE__COLUMN) { + pRsp->withSchema = false; + } else { + pRsp->withSchema = true; + pRsp->blockSchema = taosArrayInit(0, sizeof(void*)); + if (pRsp->blockSchema == NULL) { + // TODO free + return -1; + } + } + return 0; +} + +static int32_t tqInitMetaRsp(SMqMetaRsp* pRsp, const SMqPollReq* pReq) { return 0; } + +static FORCE_INLINE void tqOffsetResetToData(STqOffsetVal* pOffsetVal, int64_t uid, int64_t ts) { + pOffsetVal->type = TMQ_OFFSET__SNAPSHOT_DATA; + pOffsetVal->uid = uid; + pOffsetVal->ts = ts; +} + +static FORCE_INLINE void tqOffsetResetToLog(STqOffsetVal* pOffsetVal, int64_t ver) { + pOffsetVal->type = TMQ_OFFSET__LOG; + pOffsetVal->version = ver; +} + +int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { + SMqPollReq* pReq = pMsg->pCont; + int64_t consumerId = pReq->consumerId; + int64_t timeout = pReq->timeout; + int32_t reqEpoch = pReq->epoch; + int32_t code = 0; + STqOffsetVal reqOffset = pReq->reqOffset; + STqOffsetVal fetchOffsetNew; + + // 1.find handle + char buf[50]; + tFormatOffset(buf, 50, &reqOffset); + tqDebug("tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req offset %s", consumerId, pReq->epoch, + TD_VID(pTq->pVnode), buf); + + STqHandle* pHandle = taosHashGet(pTq->handles, pReq->subKey, strlen(pReq->subKey)); + /*ASSERT(pHandle);*/ + if (pHandle == NULL) { + tqError("tmq poll: no consumer handle for consumer %ld in vg %d, subkey %s", consumerId, TD_VID(pTq->pVnode), + pReq->subKey); + return -1; + } + + // check rebalance + if (pHandle->consumerId != consumerId) { + tqError("tmq poll: consumer handle mismatch for consumer %ld in vg %d, subkey %s, handle consumer id %ld", + consumerId, TD_VID(pTq->pVnode), pReq->subKey, pHandle->consumerId); + return -1; + } + + // update epoch if need + int32_t consumerEpoch = atomic_load_32(&pHandle->epoch); + while (consumerEpoch < reqEpoch) { + consumerEpoch = atomic_val_compare_exchange_32(&pHandle->epoch, consumerEpoch, reqEpoch); + } + + // 2.reset offset if needed + if (reqOffset.type > 0) { + fetchOffsetNew = reqOffset; + } else { + STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, pReq->subKey); + if (pOffset != NULL) { + fetchOffsetNew = pOffset->val; + char formatBuf[50]; + tFormatOffset(formatBuf, 50, &fetchOffsetNew); + tqDebug("tmq poll: consumer %ld, offset reset to %s", consumerId, formatBuf); + } else { + if (reqOffset.type == TMQ_OFFSET__RESET_EARLIEAST) { + if (pReq->useSnapshot) { + if (!pHandle->fetchMeta) { + tqOffsetResetToData(&fetchOffsetNew, 0, 0); + } else { + // reset to meta + ASSERT(0); + } + } else { + tqOffsetResetToLog(&fetchOffsetNew, walGetFirstVer(pTq->pVnode->pWal)); + } + } else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) { + tqOffsetResetToLog(&fetchOffsetNew, walGetLastVer(pTq->pVnode->pWal)); + } else if (reqOffset.type == TMQ_OFFSET__RESET_NONE) { + tqError("tmq poll: no offset committed for consumer %ld in vg %d, subkey %s, reset none failed", consumerId, + TD_VID(pTq->pVnode), pReq->subKey); + terrno = TSDB_CODE_TQ_NO_COMMITTED_OFFSET; + return -1; + } + } + } + + // 3.query + SMqDataRsp dataRsp = {0}; + tqInitDataRsp(&dataRsp, pReq, pHandle->execHandle.subType); + + if (fetchOffsetNew.type == TMQ_OFFSET__LOG) { + int64_t fetchVer = fetchOffsetNew.version + 1; + SWalHead* pHeadWithCkSum = taosMemoryMalloc(sizeof(SWalHead) + 2048); + if (pHeadWithCkSum == NULL) { + return -1; + } + + walSetReaderCapacity(pHandle->pWalReader, 2048); + + while (1) { + consumerEpoch = atomic_load_32(&pHandle->epoch); + if (consumerEpoch > reqEpoch) { + tqWarn("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, found new consumer epoch %d, discard req epoch %d", + consumerId, pReq->epoch, TD_VID(pTq->pVnode), fetchVer, consumerEpoch, reqEpoch); + break; + } + + if (tqFetchLog(pTq, pHandle, &fetchVer, &pHeadWithCkSum) < 0) { + // TODO add push mgr + + tqOffsetResetToLog(&dataRsp.rspOffset, fetchVer); + ASSERT(dataRsp.rspOffset.version >= dataRsp.reqOffset.version); + if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { + code = -1; + } + goto OVER; + } + + SWalReadHead* pHead = &pHeadWithCkSum->head; + + tqDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d", consumerId, pReq->epoch, + TD_VID(pTq->pVnode), fetchVer, pHead->msgType); + + if (pHead->msgType == TDMT_VND_SUBMIT) { + SSubmitReq* pCont = (SSubmitReq*)&pHead->body; + + if (tqLogScanExec(pTq, &pHandle->execHandle, pCont, &dataRsp, workerId) < 0) { + /*ASSERT(0);*/ + } + // TODO batch optimization: + // TODO continue scan until meeting batch requirement + if (dataRsp.blockNum > 0 /* threshold */) { + tqOffsetResetToLog(&dataRsp.rspOffset, fetchVer); + ASSERT(dataRsp.rspOffset.version >= dataRsp.reqOffset.version); + + if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { + code = -1; + } + goto OVER; + } else { + fetchVer++; + } + + } else { + ASSERT(pHandle->fetchMeta); + ASSERT(IS_META_MSG(pHead->msgType)); + tqInfo("fetch meta msg, ver: %ld, type: %d", pHead->version, pHead->msgType); + SMqMetaRsp metaRsp = {0}; + metaRsp.reqOffset = pReq->reqOffset.version; + /*tqOffsetResetToLog(&metaR)*/ + metaRsp.rspOffset = fetchVer; + metaRsp.resMsgType = pHead->msgType; + metaRsp.metaRspLen = pHead->bodyLen; + metaRsp.metaRsp = pHead->body; + if (tqSendMetaPollRsp(pTq, pMsg, pReq, &metaRsp) < 0) { + code = -1; + goto OVER; + } + code = 0; + goto OVER; + } + } + + taosMemoryFree(pHeadWithCkSum); + } else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_DATA) { + // 1. set uid and ts + // 2. get data (rebuild reader if needed) + // 3. get new uid and ts + + char formatBuf[50]; + tFormatOffset(formatBuf, 50, &dataRsp.reqOffset); + tqInfo("retrieve using snapshot req offset %s", formatBuf); + if (tqScanSnapshot(pTq, &pHandle->execHandle, &dataRsp, workerId) < 0) { + ASSERT(0); + } + + // 4. send rsp + if (dataRsp.blockNum != 0) { + tqOffsetResetToData(&dataRsp.rspOffset, 0, 0); + if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { + code = -1; + } + } + } else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_META) { + ASSERT(0); + } + +OVER: + // TODO wrap in destroy func + taosArrayDestroy(dataRsp.blockDataLen); + taosArrayDestroyP(dataRsp.blockData, (FDelete)taosMemoryFree); + + if (dataRsp.withSchema) { + taosArrayDestroyP(dataRsp.blockSchema, (FDelete)tDeleteSSchemaWrapper); + } + + if (dataRsp.withTbName) { + taosArrayDestroyP(dataRsp.blockTbName, (FDelete)taosMemoryFree); + } + + return code; +} + +#if 0 int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { SMqPollReq* pReq = pMsg->pCont; int64_t consumerId = pReq->consumerId; @@ -185,10 +440,10 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { } else { STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, pReq->subKey); if (pOffset != NULL) { - ASSERT(pOffset->type == TMQ_OFFSET__LOG); + ASSERT(pOffset->val.type == TMQ_OFFSET__LOG); tqDebug("consumer %ld, restore offset of %s on vg %d, offset(type:log) version: %ld", consumerId, pReq->subKey, - TD_VID(pTq->pVnode), pOffset->version); - fetchOffset = pOffset->version + 1; + TD_VID(pTq->pVnode), pOffset->val.version); + fetchOffset = pOffset->val.version + 1; } else { if (pReq->currentOffset == TMQ_CONF__RESET_OFFSET__EARLIEAST) { fetchOffset = walGetFirstVer(pTq->pWal); @@ -241,12 +496,11 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { if (rsp.withTbName) { rsp.blockTbName = taosArrayInit(0, sizeof(void*)); } + if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { rsp.withSchema = false; - rsp.withTag = false; } else { rsp.withSchema = true; - rsp.withTag = false; rsp.blockSchema = taosArrayInit(0, sizeof(void*)); } @@ -302,10 +556,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { } } else { ASSERT(pHandle->fetchMeta); - ASSERT(pHead->msgType == TDMT_VND_CREATE_STB || pHead->msgType == TDMT_VND_ALTER_STB || - pHead->msgType == TDMT_VND_DROP_STB || pHead->msgType == TDMT_VND_CREATE_TABLE || - pHead->msgType == TDMT_VND_ALTER_TABLE || pHead->msgType == TDMT_VND_DROP_TABLE || - pHead->msgType == TDMT_VND_DROP_TTL_TABLE); + ASSERT(IS_META_MSG(pHead->msgType)); tqInfo("fetch meta msg, ver: %ld, type: %d", pHead->version, pHead->msgType); SMqMetaRsp metaRsp = {0}; metaRsp.reqOffset = pReq->currentOffset; @@ -341,7 +592,7 @@ SEND_RSP: rsp.rspOffset = fetchOffset; - if (tqSendPollRsp(pTq, pMsg, pReq, &rsp) < 0) { + if (tqSendDataRsp(pTq, pMsg, pReq, &rsp) < 0) { code = -1; } OVER: @@ -359,6 +610,7 @@ OVER: return code; } +#endif int32_t tqProcessVgDeleteReq(STQ* pTq, char* msg, int32_t msgLen) { SMqVDeleteReq* pReq = (SMqVDeleteReq*)msg; @@ -403,7 +655,6 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) { .reader = pHandle->execHandle.pExecReader[i], .meta = pTq->pVnode->pMeta, .vnode = pTq->pVnode, -// .initTsdbReader = 1, }; pHandle->execHandle.execCol.task[i] = qCreateStreamExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle); ASSERT(pHandle->execHandle.execCol.task[i]); @@ -474,12 +725,11 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) { if (pTask->execType != TASK_EXEC__NONE) { // expand runners if (pTask->isDataScan) { - STqReadHandle* pStreamReader = tqInitSubmitMsgScanner(pTq->pVnode->pMeta); + SStreamReader* pStreamReader = tqInitSubmitMsgScanner(pTq->pVnode->pMeta); SReadHandle handle = { .reader = pStreamReader, .meta = pTq->pVnode->pMeta, .vnode = pTq->pVnode, -// .initTsdbReader = 1, }; /*pTask->exec.inputHandle = pStreamReader;*/ pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle); diff --git a/source/dnode/vnode/src/tq/tqExec.c b/source/dnode/vnode/src/tq/tqExec.c index afeeeab500..eb09199c70 100644 --- a/source/dnode/vnode/src/tq/tqExec.c +++ b/source/dnode/vnode/src/tq/tqExec.c @@ -15,7 +15,7 @@ #include "tq.h" -static int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataBlkRsp* pRsp) { +static int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp) { int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); void* buf = taosMemoryCalloc(1, dataStrLen); if (buf == NULL) return -1; @@ -29,7 +29,7 @@ static int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataBlkRsp* pRs // TODO enable compress int32_t actualLen = 0; - blockCompressEncode(pBlock, pRetrieve->data, &actualLen, taosArrayGetSize(pBlock->pDataBlock), false); + blockEncode(pBlock, pRetrieve->data, &actualLen, taosArrayGetSize(pBlock->pDataBlock), false); actualLen += sizeof(SRetrieveTableRsp); ASSERT(actualLen <= dataStrLen); taosArrayPush(pRsp->blockDataLen, &actualLen); @@ -37,7 +37,7 @@ static int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataBlkRsp* pRs return 0; } -static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, int32_t workerId, SMqDataBlkRsp* pRsp) { +static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, int32_t workerId, SMqDataRsp* pRsp) { SSchemaWrapper* pSW = tCloneSSchemaWrapper(pExec->pExecReader[workerId]->pSchemaWrapper); if (pSW == NULL) { return -1; @@ -46,10 +46,9 @@ static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, int32_t workerI return 0; } -static int32_t tqAddTbNameToRsp(const STQ* pTq, const STqExecHandle* pExec, SMqDataBlkRsp* pRsp, int32_t workerId) { +static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp, int32_t workerId) { SMetaReader mr = {0}; metaReaderInit(&mr, pTq->pVnode->pMeta, 0); - int64_t uid = pExec->pExecReader[workerId]->msgIter.uid; if (metaGetTableEntryByUid(&mr, uid) < 0) { ASSERT(0); return -1; @@ -60,13 +59,13 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, const STqExecHandle* pExec, SMqD return 0; } -int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataBlkRsp* pRsp, int32_t workerId) { +int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, int32_t workerId) { ASSERT(pExec->subType == TOPIC_SUB_TYPE__COLUMN); qTaskInfo_t task = pExec->execCol.task[workerId]; + // TODO set uid and ts if (qStreamScanSnapshot(task) < 0) { ASSERT(0); } - // set version while (1) { SSDataBlock* pDataBlock = NULL; uint64_t ts = 0; @@ -79,17 +78,24 @@ int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataBlkRsp* pRsp ASSERT(taosArrayGetSize(pDataBlock->pDataBlock) != 0); tqAddBlockDataToRsp(pDataBlock, pRsp); + + if (pRsp->withTbName) { + // TODO + pRsp->withTbName = 0; + /*int64_t uid = 0;*/ + /*tqAddTbNameToRsp(pTq, uid, pRsp, workerId);*/ + } pRsp->blockNum++; } return 0; } -int32_t tqDataExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataBlkRsp* pRsp, int32_t workerId) { +int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataRsp* pRsp, int32_t workerId) { if (pExec->subType == TOPIC_SUB_TYPE__COLUMN) { qTaskInfo_t task = pExec->execCol.task[workerId]; ASSERT(task); - qSetStreamInput(task, pReq, STREAM_DATA_TYPE_SUBMIT_BLOCK, false); + qSetStreamInput(task, pReq, STREAM_INPUT__DATA_SUBMIT, false); while (1) { SSDataBlock* pDataBlock = NULL; uint64_t ts = 0; @@ -102,13 +108,14 @@ int32_t tqDataExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataBlkR tqAddBlockDataToRsp(pDataBlock, pRsp); if (pRsp->withTbName) { - tqAddTbNameToRsp(pTq, pExec, pRsp, workerId); + int64_t uid = pExec->pExecReader[workerId]->msgIter.uid; + tqAddTbNameToRsp(pTq, uid, pRsp, workerId); } pRsp->blockNum++; } } else if (pExec->subType == TOPIC_SUB_TYPE__TABLE) { pRsp->withSchema = 1; - STqReadHandle* pReader = pExec->pExecReader[workerId]; + SStreamReader* pReader = pExec->pExecReader[workerId]; tqReadHandleSetMsg(pReader, pReq, 0); while (tqNextDataBlock(pReader)) { SSDataBlock block = {0}; @@ -118,14 +125,15 @@ int32_t tqDataExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataBlkR } tqAddBlockDataToRsp(&block, pRsp); if (pRsp->withTbName) { - tqAddTbNameToRsp(pTq, pExec, pRsp, workerId); + int64_t uid = pExec->pExecReader[workerId]->msgIter.uid; + tqAddTbNameToRsp(pTq, uid, pRsp, workerId); } tqAddBlockSchemaToRsp(pExec, workerId, pRsp); pRsp->blockNum++; } } else if (pExec->subType == TOPIC_SUB_TYPE__DB) { pRsp->withSchema = 1; - STqReadHandle* pReader = pExec->pExecReader[workerId]; + SStreamReader* pReader = pExec->pExecReader[workerId]; tqReadHandleSetMsg(pReader, pReq, 0); while (tqNextDataBlockFilterOut(pReader, pExec->execDb.pFilterOutTbUid)) { SSDataBlock block = {0}; @@ -135,7 +143,8 @@ int32_t tqDataExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataBlkR } tqAddBlockDataToRsp(&block, pRsp); if (pRsp->withTbName) { - tqAddTbNameToRsp(pTq, pExec, pRsp, workerId); + int64_t uid = pExec->pExecReader[workerId]->msgIter.uid; + tqAddTbNameToRsp(pTq, uid, pRsp, workerId); } tqAddBlockSchemaToRsp(pExec, workerId, pRsp); pRsp->blockNum++; diff --git a/source/dnode/vnode/src/tq/tqOffset.c b/source/dnode/vnode/src/tq/tqOffset.c index e536e87032..16b8872098 100644 --- a/source/dnode/vnode/src/tq/tqOffset.c +++ b/source/dnode/vnode/src/tq/tqOffset.c @@ -92,8 +92,8 @@ STqOffset* tqOffsetRead(STqOffsetStore* pStore, const char* subscribeKey) { } int32_t tqOffsetWrite(STqOffsetStore* pStore, const STqOffset* pOffset) { - ASSERT(pOffset->type == TMQ_OFFSET__LOG); - ASSERT(pOffset->version >= 0); + /*ASSERT(pOffset->val.type == TMQ_OFFSET__LOG);*/ + /*ASSERT(pOffset->val.version >= 0);*/ return taosHashPut(pStore->pHash, pOffset->subKey, strlen(pOffset->subKey), pOffset, sizeof(STqOffset)); } diff --git a/source/dnode/vnode/src/tq/tqPush.c b/source/dnode/vnode/src/tq/tqPush.c index 2ec627bd5c..bd7cda4de3 100644 --- a/source/dnode/vnode/src/tq/tqPush.c +++ b/source/dnode/vnode/src/tq/tqPush.c @@ -15,16 +15,17 @@ #include "tq.h" +#if 0 void tqTmrRspFunc(void* param, void* tmrId) { STqHandle* pHandle = (STqHandle*)param; atomic_store_8(&pHandle->pushHandle.tmrStopped, 1); } -static int32_t tqLoopExecFromQueue(STQ* pTq, STqHandle* pHandle, SStreamDataSubmit** ppSubmit, SMqDataBlkRsp* pRsp) { +static int32_t tqLoopExecFromQueue(STQ* pTq, STqHandle* pHandle, SStreamDataSubmit** ppSubmit, SMqDataRsp* pRsp) { SStreamDataSubmit* pSubmit = *ppSubmit; while (pSubmit != NULL) { ASSERT(pSubmit->ver == pHandle->pushHandle.processedVer + 1); - if (tqDataExec(pTq, &pHandle->execHandle, pSubmit->data, pRsp, 0) < 0) { + if (tqLogScanExec(pTq, &pHandle->execHandle, pSubmit->data, pRsp, 0) < 0) { /*ASSERT(0);*/ } // update processed @@ -43,7 +44,7 @@ static int32_t tqLoopExecFromQueue(STQ* pTq, STqHandle* pHandle, SStreamDataSubm } int32_t tqExecFromInputQ(STQ* pTq, STqHandle* pHandle) { - SMqDataBlkRsp rsp = {0}; + SMqDataRsp rsp = {0}; // 1. guard and set status executing int8_t execStatus = atomic_val_compare_exchange_8(&pHandle->pushHandle.execStatus, TASK_EXEC_STATUS__IDLE, TASK_EXEC_STATUS__EXECUTING); @@ -175,13 +176,13 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_ taosWLockLatch(&pHandle->pushHandle.lock); - SMqDataBlkRsp rsp = {0}; + SMqDataRsp rsp = {0}; rsp.reqOffset = pHandle->pushHandle.reqOffset; rsp.blockData = taosArrayInit(0, sizeof(void*)); rsp.blockDataLen = taosArrayInit(0, sizeof(int32_t)); if (msgType == TDMT_VND_SUBMIT) { - tqDataExec(pTq, &pHandle->execHandle, pReq, &rsp, workerId); + tqLogScanExec(pTq, &pHandle->execHandle, pReq, &rsp, workerId); } else { // TODO ASSERT(0); @@ -233,6 +234,7 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_ return 0; } +#endif int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) { if (msgType == TDMT_VND_SUBMIT) { diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index cbee639911..7d7b9636df 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -44,10 +44,7 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalHead* } else { if (pHandle->fetchMeta) { SWalReadHead* pHead = &((*ppHeadWithCkSum)->head); - if (pHead->msgType == TDMT_VND_CREATE_STB || pHead->msgType == TDMT_VND_ALTER_STB || - pHead->msgType == TDMT_VND_DROP_STB || pHead->msgType == TDMT_VND_CREATE_TABLE || - pHead->msgType == TDMT_VND_ALTER_TABLE || pHead->msgType == TDMT_VND_DROP_TABLE || - pHead->msgType == TDMT_VND_DROP_TTL_TABLE) { + if (IS_META_MSG(pHead->msgType)) { code = walFetchBody(pHandle->pWalReader, ppHeadWithCkSum); if (code < 0) { @@ -76,8 +73,8 @@ END: return code; } -STqReadHandle* tqInitSubmitMsgScanner(SMeta* pMeta) { - STqReadHandle* pReadHandle = taosMemoryMalloc(sizeof(STqReadHandle)); +SStreamReader* tqInitSubmitMsgScanner(SMeta* pMeta) { + SStreamReader* pReadHandle = taosMemoryMalloc(sizeof(SStreamReader)); if (pReadHandle == NULL) { return NULL; } @@ -85,15 +82,15 @@ STqReadHandle* tqInitSubmitMsgScanner(SMeta* pMeta) { pReadHandle->pMsg = NULL; pReadHandle->ver = -1; pReadHandle->pColIdList = NULL; - pReadHandle->cachedSchemaVer = -1; - pReadHandle->cachedSchemaSuid = -1; + pReadHandle->cachedSchemaVer = 0; + pReadHandle->cachedSchemaSuid = 0; pReadHandle->pSchema = NULL; pReadHandle->pSchemaWrapper = NULL; pReadHandle->tbIdHash = NULL; return pReadHandle; } -int32_t tqReadHandleSetMsg(STqReadHandle* pReadHandle, SSubmitReq* pMsg, int64_t ver) { +int32_t tqReadHandleSetMsg(SStreamReader* pReadHandle, SSubmitReq* pMsg, int64_t ver) { pReadHandle->pMsg = pMsg; if (tInitSubmitMsgIter(pMsg, &pReadHandle->msgIter) < 0) return -1; @@ -108,7 +105,7 @@ int32_t tqReadHandleSetMsg(STqReadHandle* pReadHandle, SSubmitReq* pMsg, int64_t return 0; } -bool tqNextDataBlock(STqReadHandle* pHandle) { +bool tqNextDataBlock(SStreamReader* pHandle) { if (pHandle->pMsg == NULL) return false; while (1) { if (tGetSubmitMsgNext(&pHandle->msgIter, &pHandle->pBlock) < 0) { @@ -130,7 +127,7 @@ bool tqNextDataBlock(STqReadHandle* pHandle) { return false; } -bool tqNextDataBlockFilterOut(STqReadHandle* pHandle, SHashObj* filterOutUids) { +bool tqNextDataBlockFilterOut(SStreamReader* pHandle, SHashObj* filterOutUids) { while (1) { if (tGetSubmitMsgNext(&pHandle->msgIter, &pHandle->pBlock) < 0) { return false; @@ -146,7 +143,7 @@ bool tqNextDataBlockFilterOut(STqReadHandle* pHandle, SHashObj* filterOutUids) { return false; } -int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle) { +int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, SStreamReader* pHandle) { // TODO: cache multiple schema int32_t sversion = htonl(pHandle->pBlock->sversion); if (pHandle->cachedSchemaSuid == 0 || pHandle->cachedSchemaVer != sversion || @@ -231,7 +228,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle) { tInitSubmitBlkIter(&pHandle->msgIter, pHandle->pBlock, &pHandle->blkIter); pBlock->info.groupId = 0; - pBlock->info.uid = pHandle->msgIter.uid; // set the uid of table for submit block + pBlock->info.uid = pHandle->msgIter.uid; pBlock->info.rows = pHandle->msgIter.numOfRows; while ((row = tGetSubmitBlkNext(&pHandle->blkIter)) != NULL) { @@ -251,14 +248,14 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle) { } return 0; -FAIL: // todo refactor here - // if (*ppCols) taosArrayDestroy(*ppCols); +FAIL: + tDeleteSSDataBlock(pBlock); return -1; } -void tqReadHandleSetColIdList(STqReadHandle* pReadHandle, SArray* pColIdList) { pReadHandle->pColIdList = pColIdList; } +void tqReadHandleSetColIdList(SStreamReader* pReadHandle, SArray* pColIdList) { pReadHandle->pColIdList = pColIdList; } -int tqReadHandleSetTbUidList(STqReadHandle* pHandle, const SArray* tbUidList) { +int tqReadHandleSetTbUidList(SStreamReader* pHandle, const SArray* tbUidList) { if (pHandle->tbIdHash) { taosHashClear(pHandle->tbIdHash); } @@ -277,7 +274,7 @@ int tqReadHandleSetTbUidList(STqReadHandle* pHandle, const SArray* tbUidList) { return 0; } -int tqReadHandleAddTbUidList(STqReadHandle* pHandle, const SArray* tbUidList) { +int tqReadHandleAddTbUidList(SStreamReader* pHandle, const SArray* tbUidList) { if (pHandle->tbIdHash == NULL) { pHandle->tbIdHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK); if (pHandle->tbIdHash == NULL) { @@ -294,7 +291,7 @@ int tqReadHandleAddTbUidList(STqReadHandle* pHandle, const SArray* tbUidList) { return 0; } -int tqReadHandleRemoveTbUidList(STqReadHandle* pHandle, const SArray* tbUidList) { +int tqReadHandleRemoveTbUidList(SStreamReader* pHandle, const SArray* tbUidList) { ASSERT(pHandle->tbIdHash != NULL); for (int32_t i = 0; i < taosArrayGetSize(tbUidList); i++) { diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index d0a1b5417f..b73eaa4288 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -136,7 +136,7 @@ int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp if (vnodeProcessDropTbReq(pVnode, version, pReq, len, pRsp) < 0) goto _err; break; case TDMT_VND_DROP_TTL_TABLE: - if (vnodeProcessDropTtlTbReq(pVnode, version, pReq, len, pRsp) < 0) goto _err; + //if (vnodeProcessDropTtlTbReq(pVnode, version, pReq, len, pRsp) < 0) goto _err; break; case TDMT_VND_CREATE_SMA: { if (vnodeProcessCreateTSmaReq(pVnode, version, pReq, len, pRsp) < 0) goto _err; @@ -781,7 +781,7 @@ _exit: // TODO: the partial success scenario and the error case // TODO: refactor if ((terrno == TSDB_CODE_SUCCESS) && (pRsp->code == TSDB_CODE_SUCCESS)) { - tdProcessRSmaSubmit(pVnode->pSma, pReq, STREAM_DATA_TYPE_SUBMIT_BLOCK); + tdProcessRSmaSubmit(pVnode->pSma, pReq, STREAM_INPUT__DATA_SUBMIT); } return 0; diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index 67e507858f..f9e811fc32 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -73,7 +73,7 @@ static int32_t vnodeSetStandBy(SVnode *pVnode) { vInfo("vgId:%d, set standby success", TD_VID(pVnode)); return 0; } else { - vError("vgId:%d, failed to set standby since %s", TD_VID(pVnode), terrstr()); + vError("vgId:%d, failed to set standby after leader transfer since %s", TD_VID(pVnode), terrstr()); return -1; } } diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index cb14b916af..377df8f8ac 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -18,7 +18,31 @@ #include "tdatablock.h" #include "tglobal.h" -extern SConfig *tsCfg; +extern SConfig* tsCfg; + +static int32_t buildRetrieveTableRsp(SSDataBlock* pBlock, int32_t numOfCols, SRetrieveTableRsp** pRsp) { + size_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); + *pRsp = taosMemoryCalloc(1, rspSize); + if (NULL == *pRsp) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + (*pRsp)->useconds = 0; + (*pRsp)->completed = 1; + (*pRsp)->precision = 0; + (*pRsp)->compressed = 0; + (*pRsp)->compLen = 0; + (*pRsp)->numOfRows = htonl(pBlock->info.rows); + (*pRsp)->numOfCols = htonl(numOfCols); + + int32_t len = 0; + blockEncode(pBlock, (*pRsp)->data, &len, numOfCols, false); + ASSERT(len == rspSize - sizeof(SRetrieveTableRsp)); + + blockDataDestroy(pBlock); + return TSDB_CODE_SUCCESS; +} + static int32_t getSchemaBytes(const SSchema* pSchema) { switch (pSchema->type) { case TSDB_DATA_TYPE_BINARY: @@ -89,33 +113,13 @@ static int32_t execDescribe(SNode* pStmt, SRetrieveTableRsp** pRsp) { SSDataBlock* pBlock = buildDescResultDataBlock(); setDescResultIntoDataBlock(pBlock, numOfRows, pDesc->pMeta); - size_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); - *pRsp = taosMemoryCalloc(1, rspSize); - if (NULL == *pRsp) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - (*pRsp)->useconds = 0; - (*pRsp)->completed = 1; - (*pRsp)->precision = 0; - (*pRsp)->compressed = 0; - (*pRsp)->compLen = 0; - (*pRsp)->numOfRows = htonl(numOfRows); - (*pRsp)->numOfCols = htonl(DESCRIBE_RESULT_COLS); - - int32_t len = 0; - blockCompressEncode(pBlock, (*pRsp)->data, &len, DESCRIBE_RESULT_COLS, false); - ASSERT(len == rspSize - sizeof(SRetrieveTableRsp)); - - blockDataDestroy(pBlock); - return TSDB_CODE_SUCCESS; + return buildRetrieveTableRsp(pBlock, DESCRIBE_RESULT_COLS, pRsp); } static int32_t execResetQueryCache() { return catalogClearCache(); } - static SSDataBlock* buildCreateDBResultDataBlock() { - SSDataBlock* pBlock = createDataBlock(); + SSDataBlock* pBlock = createDataBlock(); SColumnInfoData infoData = createColumnInfoData(TSDB_DATA_TYPE_VARCHAR, SHOW_CREATE_DB_RESULT_COLS, 1); blockDataAppendColInfo(pBlock, &infoData); @@ -149,14 +153,14 @@ int64_t getValOfDiffPrecision(int8_t unit, int64_t val) { return v; } -char *buildRetension(SArray *pRetension) { +char* buildRetension(SArray* pRetension) { size_t size = taosArrayGetSize(pRetension); if (size == 0) { return NULL; } - char *p1 = taosMemoryCalloc(1, 100); - SRetention *p = taosArrayGet(pRetension, 0); + char* p1 = taosMemoryCalloc(1, 100); + SRetention* p = taosArrayGet(pRetension, 0); int32_t len = 0; @@ -185,8 +189,7 @@ char *buildRetension(SArray *pRetension) { return p1; } - -static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char *dbFName, SDbCfgInfo* pCfg) { +static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbFName, SDbCfgInfo* pCfg) { blockDataEnsureCapacity(pBlock, 1); pBlock->info.rows = 1; @@ -198,7 +201,7 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char *dbFName, S SColumnInfoData* pCol2 = taosArrayGet(pBlock->pDataBlock, 1); char buf2[SHOW_CREATE_DB_RESULT_FIELD2_LEN] = {0}; int32_t len = 0; - char *prec = NULL; + char* prec = NULL; switch (pCfg->precision) { case TSDB_TIME_PRECISION_MILLI: prec = TSDB_TIME_PRECISION_MILLI_STR; @@ -214,15 +217,16 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char *dbFName, S break; } - char *retentions = buildRetension(pCfg->pRetensions); - - len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE DATABASE `%s` BUFFER %d CACHELAST %d COMP %d DURATION %dm " - "FSYNC %d MAXROWS %d MINROWS %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d " - "STRICT %d WAL %d VGROUPS %d SINGLE_STABLE %d", - dbFName, pCfg->buffer, pCfg->cacheLastRow, pCfg->compression, pCfg->daysPerFile, - pCfg->fsyncPeriod, pCfg->maxRows, pCfg->minRows, pCfg->daysToKeep0, pCfg->daysToKeep1, pCfg->daysToKeep2, - pCfg->pages, pCfg->pageSize, prec, pCfg->replications, pCfg->strict, pCfg->walLevel, pCfg->numOfVgroups, - 1 == pCfg->numOfStables); + char* retentions = buildRetension(pCfg->pRetensions); + + len += sprintf(buf2 + VARSTR_HEADER_SIZE, + "CREATE DATABASE `%s` BUFFER %d CACHELAST %d COMP %d DURATION %dm " + "FSYNC %d MAXROWS %d MINROWS %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d " + "STRICT %d WAL %d VGROUPS %d SINGLE_STABLE %d", + dbFName, pCfg->buffer, pCfg->cacheLastRow, pCfg->compression, pCfg->daysPerFile, pCfg->fsyncPeriod, + pCfg->maxRows, pCfg->minRows, pCfg->daysToKeep0, pCfg->daysToKeep1, pCfg->daysToKeep2, pCfg->pages, + pCfg->pageSize, prec, pCfg->replications, pCfg->strict, pCfg->walLevel, pCfg->numOfVgroups, + 1 == pCfg->numOfStables); if (retentions) { len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, " RETENTIONS %s", retentions); @@ -230,35 +234,14 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char *dbFName, S } (varDataLen(buf2)) = len; - + colDataAppend(pCol2, 0, buf2, false); } - static int32_t execShowCreateDatabase(SShowCreateDatabaseStmt* pStmt, SRetrieveTableRsp** pRsp) { SSDataBlock* pBlock = buildCreateDBResultDataBlock(); setCreateDBResultIntoDataBlock(pBlock, pStmt->dbName, pStmt->pCfg); - - size_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); - *pRsp = taosMemoryCalloc(1, rspSize); - if (NULL == *pRsp) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - (*pRsp)->useconds = 0; - (*pRsp)->completed = 1; - (*pRsp)->precision = 0; - (*pRsp)->compressed = 0; - (*pRsp)->compLen = 0; - (*pRsp)->numOfRows = htonl(1); - (*pRsp)->numOfCols = htonl(SHOW_CREATE_DB_RESULT_COLS); - - int32_t len = 0; - blockCompressEncode(pBlock, (*pRsp)->data, &len, SHOW_CREATE_DB_RESULT_COLS, false); - ASSERT(len == rspSize - sizeof(SRetrieveTableRsp)); - - blockDataDestroy(pBlock); - return TSDB_CODE_SUCCESS; + return buildRetrieveTableRsp(pBlock, SHOW_CREATE_DB_RESULT_COLS, pRsp); } static SSDataBlock* buildCreateTbResultDataBlock() { @@ -276,14 +259,14 @@ static SSDataBlock* buildCreateTbResultDataBlock() { void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) { for (int32_t i = 0; i < pCfg->numOfColumns; ++i) { SSchema* pSchema = pCfg->pSchemas + i; - char type[32]; + char type[32]; sprintf(type, "%s", tDataTypes[pSchema->type].name); if (TSDB_DATA_TYPE_VARCHAR == pSchema->type) { sprintf(type + strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE)); } else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) { - sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE)/TSDB_NCHAR_SIZE)); + sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)); } - + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s", ((i > 0) ? ", " : ""), pSchema->name, type); } } @@ -291,19 +274,18 @@ void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) { void appendTagFields(char* buf, int32_t* len, STableCfg* pCfg) { for (int32_t i = 0; i < pCfg->numOfTags; ++i) { SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i; - char type[32]; + char type[32]; sprintf(type, "%s", tDataTypes[pSchema->type].name); if (TSDB_DATA_TYPE_VARCHAR == pSchema->type) { sprintf(type + strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE)); } else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) { - sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE)/TSDB_NCHAR_SIZE)); + sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)); } *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s", ((i > 0) ? ", " : ""), pSchema->name, type); } } - void appendTagNameFields(char* buf, int32_t* len, STableCfg* pCfg) { for (int32_t i = 0; i < pCfg->numOfTags; ++i) { SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i; @@ -311,13 +293,12 @@ void appendTagNameFields(char* buf, int32_t* len, STableCfg* pCfg) { } } - int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) { - SArray *pTagVals = NULL; - STag *pTag = (STag*)pCfg->pTags; - + SArray* pTagVals = NULL; + STag* pTag = (STag*)pCfg->pTags; + if (pCfg->pTags && pTag->flags & TD_TAG_JSON) { - char *pJson = parseTagDatatoJson(pTag); + char* pJson = parseTagDatatoJson(pTag); if (pJson) { *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s", pJson); taosMemoryFree(pJson); @@ -325,8 +306,8 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) { return TSDB_CODE_SUCCESS; } - - int32_t code = tTagToValArray((const STag *)pCfg->pTags, &pTagVals); + + int32_t code = tTagToValArray((const STag*)pCfg->pTags, &pTagVals); if (code) { return code; } @@ -339,20 +320,20 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) { if (i > 0) { *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", "); } - + if (j >= valueNum) { *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "NULL"); continue; } - - STagVal *pTagVal = (STagVal *)taosArrayGet(pTagVals, j); + + STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, j); if (pSchema->colId > pTagVal->cid) { qError("tag value and column mismatch, schemaId:%d, valId:%d", pSchema->colId, pTagVal->cid); taosArrayDestroy(pTagVals); return TSDB_CODE_APP_ERROR; } else if (pSchema->colId == pTagVal->cid) { - char type = pTagVal->type; - int32_t tlen = 0; + char type = pTagVal->type; + int32_t tlen = 0; if (IS_VAR_DATA_TYPE(type)) { dataConverToStr(buf + VARSTR_HEADER_SIZE + *len, type, pTagVal->pData, pTagVal->nData, &tlen); @@ -364,7 +345,6 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) { } else { *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "NULL"); } - /* if (type == TSDB_DATA_TYPE_BINARY) { @@ -372,7 +352,7 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) { if (num) { *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", "); } - + memcpy(buf + VARSTR_HEADER_SIZE + *len, pTagVal->pData, pTagVal->nData); *len += pTagVal->nData; } @@ -397,7 +377,7 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) { taosArrayDestroy(pTagVals); - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; } void appendTableOptions(char* buf, int32_t* len, STableCfg* pCfg) { @@ -426,7 +406,7 @@ void appendTableOptions(char* buf, int32_t* len, STableCfg* pCfg) { *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " ROLLUP("); for (int32_t i = 0; i < funcNum; ++i) { char* pFunc = taosArrayGet(pCfg->pFuncs, i); - *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s%s", ((i > 0) ? ", " : ""), pFunc); + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s%s", ((i > 0) ? ", " : ""), pFunc); } *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ")"); } @@ -436,7 +416,7 @@ void appendTableOptions(char* buf, int32_t* len, STableCfg* pCfg) { } } -static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, char *tbName, STableCfg* pCfg) { +static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, char* tbName, STableCfg* pCfg) { int32_t code = 0; blockDataEnsureCapacity(pBlock, 1); pBlock->info.rows = 1; @@ -454,7 +434,7 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, char *tbName, len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE STABLE `%s` (", tbName); appendColumnFields(buf2, &len, pCfg); len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ") TAGS ("); - appendTagFields(buf2, &len, pCfg); + appendTagFields(buf2, &len, pCfg); len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ")"); appendTableOptions(buf2, &len, pCfg); } else if (TSDB_CHILD_TABLE == pCfg->tableType) { @@ -474,40 +454,19 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, char *tbName, } varDataLen(buf2) = len; - + colDataAppend(pCol2, 0, buf2, false); return TSDB_CODE_SUCCESS; } - static int32_t execShowCreateTable(SShowCreateTableStmt* pStmt, SRetrieveTableRsp** pRsp) { SSDataBlock* pBlock = buildCreateTbResultDataBlock(); - int32_t code = setCreateTBResultIntoDataBlock(pBlock, pStmt->tableName, pStmt->pCfg); + int32_t code = setCreateTBResultIntoDataBlock(pBlock, pStmt->tableName, pStmt->pCfg); if (code) { return code; } - - size_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); - *pRsp = taosMemoryCalloc(1, rspSize); - if (NULL == *pRsp) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - (*pRsp)->useconds = 0; - (*pRsp)->completed = 1; - (*pRsp)->precision = 0; - (*pRsp)->compressed = 0; - (*pRsp)->compLen = 0; - (*pRsp)->numOfRows = htonl(1); - (*pRsp)->numOfCols = htonl(SHOW_CREATE_TB_RESULT_COLS); - - int32_t len = 0; - blockCompressEncode(pBlock, (*pRsp)->data, &len, SHOW_CREATE_TB_RESULT_COLS, false); - ASSERT(len == rspSize - sizeof(SRetrieveTableRsp)); - - blockDataDestroy(pBlock); - return TSDB_CODE_SUCCESS; + return buildRetrieveTableRsp(pBlock, SHOW_CREATE_TB_RESULT_COLS, pRsp); } static int32_t execShowCreateSTable(SShowCreateTableStmt* pStmt, SRetrieveTableRsp** pRsp) { @@ -516,17 +475,17 @@ static int32_t execShowCreateSTable(SShowCreateTableStmt* pStmt, SRetrieveTableR terrno = TSDB_CODE_TSC_NOT_STABLE_ERROR; return terrno; } - + return execShowCreateTable(pStmt, pRsp); } -static int32_t execAlterLocal(SAlterLocalStmt* pStmt) { +static int32_t execAlterLocal(SAlterLocalStmt* pStmt) { if (cfgSetItem(tsCfg, pStmt->config, pStmt->value, CFG_STYPE_ALTER_CMD)) { - return terrno; + return terrno; } if (taosSetCfg(tsCfg, pStmt->config)) { - return terrno; + return terrno; } return TSDB_CODE_SUCCESS; @@ -551,21 +510,20 @@ static SSDataBlock* buildLocalVariablesResultDataBlock() { return pBlock; } - int32_t setLocalVariablesResultIntoDataBlock(SSDataBlock* pBlock) { int32_t numOfCfg = taosArrayGetSize(tsCfg->array); int32_t numOfRows = 0; blockDataEnsureCapacity(pBlock, numOfCfg); for (int32_t i = 0, c = 0; i < numOfCfg; ++i, c = 0) { - SConfigItem *pItem = taosArrayGet(tsCfg->array, i); + SConfigItem* pItem = taosArrayGet(tsCfg->array, i); char name[TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(name, pItem->name, TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE); - SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, c++); + SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, c++); colDataAppend(pColInfo, i, name, false); - - char value[TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE] = {0}; + + char value[TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE] = {0}; int32_t valueLen = 0; cfgDumpItemValue(pItem, &value[VARSTR_HEADER_SIZE], TSDB_CONFIG_VALUE_LEN, &valueLen); varDataSetLen(value, valueLen); @@ -575,42 +533,70 @@ int32_t setLocalVariablesResultIntoDataBlock(SSDataBlock* pBlock) { numOfRows++; } - pBlock->info.rows = numOfRows; - + return TSDB_CODE_SUCCESS; } - static int32_t execShowLocalVariables(SRetrieveTableRsp** pRsp) { SSDataBlock* pBlock = buildLocalVariablesResultDataBlock(); - int32_t code = setLocalVariablesResultIntoDataBlock(pBlock); + int32_t code = setLocalVariablesResultIntoDataBlock(pBlock); if (code) { return code; } + return buildRetrieveTableRsp(pBlock, SHOW_LOCAL_VARIABLES_RESULT_COLS, pRsp); +} - size_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); - *pRsp = taosMemoryCalloc(1, rspSize); - if (NULL == *pRsp) { +static int32_t createSelectResultDataBlock(SNodeList* pProjects, SSDataBlock** pOutput) { + SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); + if (NULL == pBlock) { return TSDB_CODE_OUT_OF_MEMORY; } - (*pRsp)->useconds = 0; - (*pRsp)->completed = 1; - (*pRsp)->precision = 0; - (*pRsp)->compressed = 0; - (*pRsp)->compLen = 0; - (*pRsp)->numOfRows = htonl(pBlock->info.rows); - (*pRsp)->numOfCols = htonl(SHOW_LOCAL_VARIABLES_RESULT_COLS); + pBlock->pDataBlock = taosArrayInit(LIST_LENGTH(pProjects), sizeof(SColumnInfoData)); - int32_t len = 0; - blockCompressEncode(pBlock, (*pRsp)->data, &len, SHOW_LOCAL_VARIABLES_RESULT_COLS, false); - ASSERT(len == rspSize - sizeof(SRetrieveTableRsp)); - - blockDataDestroy(pBlock); + SNode* pProj = NULL; + FOREACH(pProj, pProjects) { + SColumnInfoData infoData = {0}; + infoData.info.type = ((SExprNode*)pProj)->resType.type; + infoData.info.bytes = ((SExprNode*)pProj)->resType.bytes; + taosArrayPush(pBlock->pDataBlock, &infoData); + } + *pOutput = pBlock; return TSDB_CODE_SUCCESS; } +int32_t buildSelectResultDataBlock(SNodeList* pProjects, SSDataBlock* pBlock) { + int32_t numOfCols = LIST_LENGTH(pProjects); + blockDataEnsureCapacity(pBlock, 1); + + int32_t index = 0; + SNode* pProj = NULL; + FOREACH(pProj, pProjects) { + if (((SValueNode*)pProj)->isNull) { + colDataAppend(taosArrayGet(pBlock->pDataBlock, index++), 0, NULL, true); + } else { + colDataAppend(taosArrayGet(pBlock->pDataBlock, index++), 0, nodesGetValueFromNode((SValueNode*)pProj), false); + } + } + + pBlock->info.rows = 1; + + return TSDB_CODE_SUCCESS; +} + +static int32_t execSelectWithoutFrom(SSelectStmt* pSelect, SRetrieveTableRsp** pRsp) { + SSDataBlock* pBlock = NULL; + int32_t code = createSelectResultDataBlock(pSelect->pProjectionList, &pBlock); + if (TSDB_CODE_SUCCESS == code) { + code = buildSelectResultDataBlock(pSelect->pProjectionList, pBlock); + } + if (TSDB_CODE_SUCCESS == code) { + code = buildRetrieveTableRsp(pBlock, LIST_LENGTH(pSelect->pProjectionList), pRsp); + } + return code; +} + int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp) { switch (nodeType(pStmt)) { case QUERY_NODE_DESCRIBE_STMT: @@ -627,6 +613,8 @@ int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp) { return execAlterLocal((SAlterLocalStmt*)pStmt); case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: return execShowLocalVariables(pRsp); + case QUERY_NODE_SELECT_STMT: + return execSelectWithoutFrom((SSelectStmt*)pStmt, pRsp); default: break; } diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index ef4ac0b639..7af36a0842 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -13,11 +13,11 @@ * along with this program. If not, see . */ -#include "tdatablock.h" #include "commandInt.h" #include "plannodes.h" #include "query.h" #include "tcommon.h" +#include "tdatablock.h" int32_t qExplainGenerateResNode(SPhysiNode *pNode, SExplainGroup *group, SExplainResNode **pRes); int32_t qExplainAppendGroupResRows(void *pCtx, int32_t groupId, int32_t level); @@ -216,7 +216,7 @@ int32_t qExplainGenerateResChildren(SPhysiNode *pNode, SExplainGroup *group, SNo SExplainResNode *pResNode = NULL; FOREACH(node, pPhysiChildren) { QRY_ERR_RET(qExplainGenerateResNode((SPhysiNode *)node, group, &pResNode)); - QRY_ERR_RET(nodesListAppend(*pChildren, (SNode*)pResNode)); + QRY_ERR_RET(nodesListAppend(*pChildren, (SNode *)pResNode)); } return TSDB_CODE_SUCCESS; @@ -232,14 +232,14 @@ int32_t qExplainGenerateResNodeExecInfo(SArray **pExecInfo, SExplainGroup *group SExplainRsp *rsp = NULL; for (int32_t i = 0; i < group->nodeNum; ++i) { rsp = taosArrayGet(group->nodeExecInfo, i); -/* - if (group->physiPlanExecIdx >= rsp->numOfPlans) { - qError("physiPlanIdx %d exceed plan num %d", group->physiPlanExecIdx, rsp->numOfPlans); - return TSDB_CODE_QRY_APP_ERROR; - } + /* + if (group->physiPlanExecIdx >= rsp->numOfPlans) { + qError("physiPlanIdx %d exceed plan num %d", group->physiPlanExecIdx, rsp->numOfPlans); + return TSDB_CODE_QRY_APP_ERROR; + } - taosArrayPush(*pExecInfo, rsp->subplanInfo + group->physiPlanExecIdx); -*/ + taosArrayPush(*pExecInfo, rsp->subplanInfo + group->physiPlanExecIdx); + */ taosArrayPush(*pExecInfo, rsp->subplanInfo); } @@ -426,23 +426,23 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i if (EXPLAIN_MODE_ANALYZE == ctx->mode) { EXPLAIN_ROW_NEW(level + 1, "I/O: "); - int32_t nodeNum = taosArrayGetSize(pResNode->pExecInfo); + int32_t nodeNum = taosArrayGetSize(pResNode->pExecInfo); struct STableScanAnalyzeInfo info = {0}; int32_t maxIndex = 0; int32_t totalRows = 0; - for(int32_t i = 0; i < nodeNum; ++i) { + for (int32_t i = 0; i < nodeNum; ++i) { SExplainExecInfo *execInfo = taosArrayGet(pResNode->pExecInfo, i); STableScanAnalyzeInfo *pScanInfo = (STableScanAnalyzeInfo *)execInfo->verboseInfo; - info.totalBlocks += pScanInfo->totalBlocks; - info.loadBlocks += pScanInfo->loadBlocks; - info.totalRows += pScanInfo->totalRows; - info.skipBlocks += pScanInfo->skipBlocks; - info.filterTime += pScanInfo->filterTime; - info.loadBlockStatis += pScanInfo->loadBlockStatis; + info.totalBlocks += pScanInfo->totalBlocks; + info.loadBlocks += pScanInfo->loadBlocks; + info.totalRows += pScanInfo->totalRows; + info.skipBlocks += pScanInfo->skipBlocks; + info.filterTime += pScanInfo->filterTime; + info.loadBlockStatis += pScanInfo->loadBlockStatis; info.totalCheckedRows += pScanInfo->totalCheckedRows; - info.filterOutBlocks += pScanInfo->filterOutBlocks; + info.filterOutBlocks += pScanInfo->filterOutBlocks; if (pScanInfo->totalRows > totalRows) { totalRows = pScanInfo->totalRows; @@ -468,13 +468,14 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); - //Rows out: Avg 4166.7 rows x 24 workers. Max 4187 rows (seg7) with 0.220 ms to first row, 1.738 ms to end, start offset by 1.470 ms. + // Rows out: Avg 4166.7 rows x 24 workers. Max 4187 rows (seg7) with 0.220 ms to first row, 1.738 ms to end, + // start offset by 1.470 ms. SExplainExecInfo *execInfo = taosArrayGet(pResNode->pExecInfo, maxIndex); STableScanAnalyzeInfo *p1 = (STableScanAnalyzeInfo *)execInfo->verboseInfo; EXPLAIN_ROW_NEW(level + 1, " "); - EXPLAIN_ROW_APPEND("max_row_task=%d, total_rows:%" PRId64 ", ep:%s (cost=%.3f..%.3f)", maxIndex, p1->totalRows, "tbd", - execInfo->startupCost, execInfo->totalCost); + EXPLAIN_ROW_APPEND("max_row_task=%d, total_rows:%" PRId64 ", ep:%s (cost=%.3f..%.3f)", maxIndex, p1->totalRows, + "tbd", execInfo->startupCost, execInfo->totalCost); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_END(); @@ -752,7 +753,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i EXPLAIN_ROW_NEW(level + 1, "Sort Key: "); if (pResNode->pExecInfo) { for (int32_t i = 0; i < LIST_LENGTH(pSortNode->pSortKeys); ++i) { - SOrderByExprNode *ptn = (SOrderByExprNode*)nodesListGetNode(pSortNode->pSortKeys, i); + SOrderByExprNode *ptn = (SOrderByExprNode *)nodesListGetNode(pSortNode->pSortKeys, i); EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr)); } } @@ -907,16 +908,16 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); if (pFillNode->pValues) { - SNodeListNode *pValues = (SNodeListNode*)pFillNode->pValues; + SNodeListNode *pValues = (SNodeListNode *)pFillNode->pValues; EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILL_VALUE_FORMAT); - SNode* tNode = NULL; + SNode *tNode = NULL; int32_t i = 0; FOREACH(tNode, pValues->pNodeList) { if (i) { EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); } - SValueNode* tValue = (SValueNode*)tNode; - char *value = nodesGetStrValueFromNode(tValue); + SValueNode *tValue = (SValueNode *)tNode; + char *value = nodesGetStrValueFromNode(tValue); EXPLAIN_ROW_APPEND(EXPLAIN_STRING_TYPE_FORMAT, value); taosMemoryFree(value); ++i; @@ -926,8 +927,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); } - EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIMERANGE_FORMAT, pFillNode->timeRange.skey, - pFillNode->timeRange.ekey); + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIMERANGE_FORMAT, pFillNode->timeRange.skey, pFillNode->timeRange.ekey); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); @@ -1070,13 +1070,13 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i EXPLAIN_ROW_APPEND(EXPLAIN_RIGHT_PARENTHESIS_FORMAT); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); - + if (EXPLAIN_MODE_ANALYZE == ctx->mode) { // sort key EXPLAIN_ROW_NEW(level + 1, "Merge Key: "); if (pResNode->pExecInfo) { for (int32_t i = 0; i < LIST_LENGTH(pMergeNode->pMergeKeys); ++i) { - SOrderByExprNode *ptn = (SOrderByExprNode*)nodesListGetNode(pMergeNode->pMergeKeys, i); + SOrderByExprNode *ptn = (SOrderByExprNode *)nodesListGetNode(pMergeNode->pMergeKeys, i); EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr)); } } @@ -1115,7 +1115,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i EXPLAIN_ROW_NEW(level + 1, EXPLAIN_MERGE_KEYS_FORMAT); for (int32_t i = 0; i < LIST_LENGTH(pMergeNode->pMergeKeys); ++i) { - SOrderByExprNode *ptn = (SOrderByExprNode*)nodesListGetNode(pMergeNode->pMergeKeys, i); + SOrderByExprNode *ptn = (SOrderByExprNode *)nodesListGetNode(pMergeNode->pMergeKeys, i); EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr)); } EXPLAIN_ROW_END(); @@ -1130,7 +1130,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i } } break; - } + } default: qError("not supported physical node type %d", pNode->type); return TSDB_CODE_QRY_APP_ERROR; @@ -1190,12 +1190,12 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) { QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); } - SSDataBlock *pBlock = createDataBlock(); + SSDataBlock *pBlock = createDataBlock(); SColumnInfoData infoData = createColumnInfoData(TSDB_DATA_TYPE_VARCHAR, TSDB_EXPLAIN_RESULT_ROW_SIZE, 1); blockDataAppendColInfo(pBlock, &infoData); blockDataEnsureCapacity(pBlock, rowNum); - SColumnInfoData* pInfoData = taosArrayGet(pBlock->pDataBlock, 0); + SColumnInfoData *pInfoData = taosArrayGet(pBlock->pDataBlock, 0); char buf[1024] = {0}; for (int32_t i = 0; i < rowNum; ++i) { @@ -1219,7 +1219,7 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) { rsp->numOfRows = htonl(rowNum); int32_t len = 0; - blockCompressEncode(pBlock, rsp->data, &len, taosArrayGetSize(pBlock->pDataBlock), 0); + blockEncode(pBlock, rsp->data, &len, taosArrayGetSize(pBlock->pDataBlock), 0); ASSERT(len == rspSize - sizeof(SRetrieveTableRsp)); rsp->compLen = htonl(len); diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index f3e1eb47e8..df961c00fa 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -25,37 +25,36 @@ #define SET_RES_WINDOW_KEY(_k, _ori, _len, _uid) \ do { \ assert(sizeof(_uid) == sizeof(uint64_t)); \ - *(uint64_t *)(_k) = (_uid); \ + *(uint64_t*)(_k) = (_uid); \ memcpy((_k) + sizeof(uint64_t), (_ori), (_len)); \ } while (0) -#define SET_RES_EXT_WINDOW_KEY(_k, _ori, _len, _uid, _buf) \ - do { \ - assert(sizeof(_uid) == sizeof(uint64_t)); \ - *(void **)(_k) = (_buf); \ - *(uint64_t *)((_k) + POINTER_BYTES) = (_uid); \ - memcpy((_k) + POINTER_BYTES + sizeof(uint64_t), (_ori), (_len)); \ +#define SET_RES_EXT_WINDOW_KEY(_k, _ori, _len, _uid, _buf) \ + do { \ + assert(sizeof(_uid) == sizeof(uint64_t)); \ + *(void**)(_k) = (_buf); \ + *(uint64_t*)((_k) + POINTER_BYTES) = (_uid); \ + memcpy((_k) + POINTER_BYTES + sizeof(uint64_t), (_ori), (_len)); \ } while (0) - -#define GET_RES_WINDOW_KEY_LEN(_l) ((_l) + sizeof(uint64_t)) +#define GET_RES_WINDOW_KEY_LEN(_l) ((_l) + sizeof(uint64_t)) #define GET_RES_EXT_WINDOW_KEY_LEN(_l) ((_l) + sizeof(uint64_t) + POINTER_BYTES) -#define GET_TASKID(_t) (((SExecTaskInfo*)(_t))->id.str) +#define GET_TASKID(_t) (((SExecTaskInfo*)(_t))->id.str) typedef struct SGroupResInfo { int32_t index; - SArray* pRows; // SArray + SArray* pRows; // SArray } SGroupResInfo; typedef struct SResultRow { - int32_t pageId; // pageId & rowId is the position of current result in disk-based output buffer - int32_t offset:29; // row index in buffer page - bool startInterp; // the time window start timestamp has done the interpolation already. - bool endInterp; // the time window end timestamp has done the interpolation already. - bool closed; // this result status: closed or opened - uint32_t numOfRows; // number of rows of current time window - STimeWindow win; + int32_t pageId; // pageId & rowId is the position of current result in disk-based output buffer + int32_t offset : 29; // row index in buffer page + bool startInterp; // the time window start timestamp has done the interpolation already. + bool endInterp; // the time window end timestamp has done the interpolation already. + bool closed; // this result status: closed or opened + uint32_t numOfRows; // number of rows of current time window + STimeWindow win; struct SResultRowEntryInfo pEntryInfo[]; // For each result column, there is a resultInfo } SResultRow; @@ -66,57 +65,58 @@ typedef struct SResultRowPosition { typedef struct SResKeyPos { SResultRowPosition pos; - uint64_t groupId; - char key[]; + uint64_t groupId; + char key[]; } SResKeyPos; typedef struct SResultRowInfo { - int32_t size; // number of result set + int32_t size; // number of result set SResultRowPosition cur; - SList* openWindow; + SList* openWindow; } SResultRowInfo; struct SqlFunctionCtx; -size_t getResultRowSize(struct SqlFunctionCtx* pCtx, int32_t numOfOutput); -void initResultRowInfo(SResultRowInfo* pResultRowInfo); -void cleanupResultRowInfo(SResultRowInfo* pResultRowInfo); +size_t getResultRowSize(struct SqlFunctionCtx* pCtx, int32_t numOfOutput); +void initResultRowInfo(SResultRowInfo* pResultRowInfo); +void cleanupResultRowInfo(SResultRowInfo* pResultRowInfo); -void closeAllResultRows(SResultRowInfo* pResultRowInfo); +void closeAllResultRows(SResultRowInfo* pResultRowInfo); -void initResultRow(SResultRow *pResultRow); -void closeResultRow(SResultRow* pResultRow); -bool isResultRowClosed(SResultRow* pResultRow); +void initResultRow(SResultRow* pResultRow); +void closeResultRow(SResultRow* pResultRow); +bool isResultRowClosed(SResultRow* pResultRow); struct SResultRowEntryInfo* getResultEntryInfo(const SResultRow* pRow, int32_t index, const int32_t* offset); -static FORCE_INLINE SResultRow *getResultRowByPos(SDiskbasedBuf* pBuf, SResultRowPosition* pos) { - SFilePage* bufPage = (SFilePage*) getBufPage(pBuf, pos->pageId); +static FORCE_INLINE SResultRow* getResultRowByPos(SDiskbasedBuf* pBuf, SResultRowPosition* pos) { + SFilePage* bufPage = (SFilePage*)getBufPage(pBuf, pos->pageId); SResultRow* pRow = (SResultRow*)((char*)bufPage + pos->offset); return pRow; } -void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SHashObj* pHashmap, int32_t order); -void initMultiResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList); +void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SHashObj* pHashmap, int32_t order); +void initMultiResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList); -void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo); -bool hasDataInGroupInfo(SGroupResInfo* pGroupResInfo); +void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo); +bool hasDataInGroupInfo(SGroupResInfo* pGroupResInfo); int32_t getNumOfTotalRes(SGroupResInfo* pGroupResInfo); SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode); EDealRes doTranslateTagExpr(SNode** pNode, void* pContext); -int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo* pListInfo); -SArray* createSortInfo(SNodeList* pNodeList); -SArray* extractPartitionColInfo(SNodeList* pNodeList); -SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols, int32_t type); +int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo* pListInfo); +SArray* createSortInfo(SNodeList* pNodeList); +SArray* extractPartitionColInfo(SNodeList* pNodeList); +SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols, + int32_t type); SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* numOfExprs); SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowEntryInfoOffset); -void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray* pCols, bool outputEveryColumn); -void initExecTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pQueryWindow); +void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray* pCols, bool outputEveryColumn); +void initExecTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pQueryWindow); SInterval extractIntervalInfo(const STableScanPhysiNode* pTableScanNode); SColumn extractColumnFromColumnNode(SColumnNode* pColNode); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 1cc3f9b874..6b5826bf88 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -253,18 +253,15 @@ typedef struct STableScanInfo { SReadHandle readHandle; SFileBlockLoadRecorder readRecorder; - int64_t numOfRows; SScanInfo scanInfo; int32_t scanTimes; SNode* pFilterNode; // filter info, which is push down by optimizer - SqlFunctionCtx* pCtx; // which belongs to the direct upstream operator operator query context - SResultRowInfo* pResultRowInfo; - int32_t* rowEntryInfoOffset; - SExprInfo* pExpr; + SqlFunctionCtx* pCtx; // which belongs to the direct upstream operator operator query context,todo: remove this by using SExprSup + int32_t* rowEntryInfoOffset; // todo: remove this by using SExprSup + SExprInfo* pExpr;// todo: remove this by using SExprSup + SSDataBlock* pResBlock; SArray* pColMatchInfo; - int32_t numOfOutput; - SExprSupp pseudoSup; SQueryTableDataCond cond; int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan @@ -275,8 +272,13 @@ typedef struct STableScanInfo { int32_t curTWinIdx; int32_t currentGroupId; - uint64_t queryId; - uint64_t taskId; + uint64_t queryId; // todo remove it + uint64_t taskId; // todo remove it + + struct { + uint64_t uid; + int64_t t; + } scanStatus; } STableScanInfo; typedef struct STagScanInfo { @@ -321,31 +323,31 @@ typedef struct SessionWindowSupporter { } SessionWindowSupporter; typedef struct SStreamBlockScanInfo { + uint64_t tableUid; // queried super table uid + SExprInfo* pPseudoExpr; + int32_t numOfPseudoExpr; + int32_t primaryTsIndex; // primary time stamp slot id + SReadHandle readHandle; + SInterval interval; // if the upstream is an interval operator, the interval info is also kept here. + SArray* pColMatchInfo; // + SNode* pCondition; + SArray* pBlockLists; // multiple SSDatablock. SSDataBlock* pRes; // result SSDataBlock SSDataBlock* pUpdateRes; // update SSDataBlock int32_t updateResIndex; int32_t blockType; // current block type int32_t validBlockIndex; // Is current data has returned? - SColumnInfo* pCols; // the output column info uint64_t numOfExec; // execution times void* streamBlockReader;// stream block reader handle - SArray* pColMatchInfo; // - SNode* pCondition; + int32_t tsArrayIndex; SArray* tsArray; uint64_t groupId; SUpdateInfo* pUpdateInfo; - SExprInfo* pPseudoExpr; - int32_t numOfPseudoExpr; - - int32_t primaryTsIndex; // primary time stamp slot id - SReadHandle readHandle; - uint64_t tableUid; // queried super table uid EStreamScanMode scanMode; SOperatorInfo* pSnapshotReadOp; - SInterval interval; // if the upstream is an interval operator, the interval info is also kept here. SArray* childIds; SessionWindowSupporter sessionSup; bool assignBlockUid; // assign block uid to groupId, temporarily used for generating rollup SMA. @@ -416,6 +418,7 @@ typedef struct SIntervalAggOperatorInfo { STimeWindowAggSupp twAggSup; bool invertible; SArray* pPrevValues; // SArray used to keep the previous not null value for interpolation. + bool ignoreCloseWindow; } SIntervalAggOperatorInfo; typedef struct SStreamFinalIntervalOperatorInfo { @@ -437,6 +440,7 @@ typedef struct SStreamFinalIntervalOperatorInfo { SArray* pPullWins; // SPullWindowInfo int32_t pullIndex; SSDataBlock* pPullDataRes; + bool ignoreCloseWindow; } SStreamFinalIntervalOperatorInfo; typedef struct SAggOperatorInfo { @@ -574,6 +578,7 @@ typedef struct SStreamSessionAggOperatorInfo { SArray* pChildren; // cache for children's result; final stream operator SPhysiNode* pPhyNode; // create new child bool isFinal; + bool ignoreCloseWindow; } SStreamSessionAggOperatorInfo; typedef struct STimeSliceOperatorInfo { @@ -617,6 +622,7 @@ typedef struct SStreamStateAggOperatorInfo { void* pDelIterator; SArray* pScanWindow; SArray* pChildren; // cache for children's result; + bool ignoreCloseWindow; } SStreamStateAggOperatorInfo; typedef struct SSortedMergeOperatorInfo { @@ -683,7 +689,7 @@ int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t void initBasicInfo(SOptrBasicInfo* pInfo, SSDataBlock* pBlock); void cleanupBasicInfo(SOptrBasicInfo* pInfo); int32_t initExprSupp(SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfExpr); -void cleanupExprSup(SExprSupp* pSup); +void cleanupExprSupp(SExprSupp* pSup); int32_t initAggInfo(SExprSupp *pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize, const char* pkey); void initResultSizeInfo(SOperatorInfo* pOperator, int32_t numOfRows); @@ -707,7 +713,7 @@ void destroyBasicOperatorInfo(void* param, int32_t numOfOutput); void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle); void setTbNameColData(void* pMeta, const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId); -void cleanupExecSupp(SExprSupp* pSupp); +int32_t doGetScanStatus(SOperatorInfo* pOperator, uint64_t* uid, int64_t* ts); SSDataBlock* loadNextDataBlock(void* param); diff --git a/source/libs/executor/src/dataDispatcher.c b/source/libs/executor/src/dataDispatcher.c index 802f9ea5b5..5ee222efb7 100644 --- a/source/libs/executor/src/dataDispatcher.c +++ b/source/libs/executor/src/dataDispatcher.c @@ -69,14 +69,16 @@ static bool needCompress(const SSDataBlock* pData, int32_t numOfCols) { // data format: // +----------------+--------------+----------+--------------------------------------------+--------------------------------------+-------------+-----------+-------------+-----------+ -// |SDataCacheEntry | total length | group id | col1_schema | col2_schema | col3_schema ...| column#1 length, column#2 length ... | col1 bitmap | col1 data | col2 bitmap | col2 data | .... -// | | (4 bytes) |(8 bytes) |(sizeof(int16_t)+sizeof(int32_t))*numOfCols | sizeof(int32_t) * numOfCols | actual size | | actual size | | +// |SDataCacheEntry | total length | group id | col1_schema | col2_schema | col3_schema ...| column#1 length, column#2 +// length ... | col1 bitmap | col1 data | col2 bitmap | col2 data | .... | | (4 bytes) |(8 bytes) +// |(sizeof(int16_t)+sizeof(int32_t))*numOfCols | sizeof(int32_t) * numOfCols | actual size | | +// actual size | | // +----------------+--------------+----------+--------------------------------------------+--------------------------------------+-------------+-----------+-------------+-----------+ // The length of bitmap is decided by number of rows of this data block, and the length of each column data is // recorded in the first segment, next to the struct header static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pInput, SDataDispatchBuf* pBuf) { int32_t numOfCols = 0; - SNode* pNode; + SNode* pNode; FOREACH(pNode, pHandle->pSchema->pSlots) { SSlotDescNode* pSlotDesc = (SSlotDescNode*)pNode; if (pSlotDesc->output) { @@ -90,12 +92,12 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn pEntry->dataLen = 0; pBuf->useSize = sizeof(SDataCacheEntry); - blockCompressEncode(pInput->pData, pEntry->data, &pEntry->dataLen, numOfCols, pEntry->compressed); + blockEncode(pInput->pData, pEntry->data, &pEntry->dataLen, numOfCols, pEntry->compressed); pBuf->useSize += pEntry->dataLen; - - atomic_add_fetch_64(&pHandle->cachedSize, pEntry->dataLen); - atomic_add_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen); + + atomic_add_fetch_64(&pHandle->cachedSize, pEntry->dataLen); + atomic_add_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen); } static bool allocBuf(SDataDispatchHandle* pDispatcher, const SInputData* pInput, SDataDispatchBuf* pBuf) { @@ -187,8 +189,8 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) { pOutput->numOfCols = pEntry->numOfCols; pOutput->compressed = pEntry->compressed; - atomic_sub_fetch_64(&pDispatcher->cachedSize, pEntry->dataLen); - atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen); + atomic_sub_fetch_64(&pDispatcher->cachedSize, pEntry->dataLen); + atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen); taosMemoryFreeClear(pDispatcher->nextOutput.pData); // todo persistent pOutput->bufStatus = updateStatus(pDispatcher); @@ -198,7 +200,6 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) { pOutput->precision = pDispatcher->pSchema->precision; taosThreadMutexUnlock(&pDispatcher->mutex); - return TSDB_CODE_SUCCESS; } diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index be6ca5145a..2561516f6a 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -13,10 +13,10 @@ * along with this program. If not, see . */ -#include "os.h" -#include "index.h" #include "function.h" #include "functionMgt.h" +#include "index.h" +#include "os.h" #include "tdatablock.h" #include "thash.h" #include "tmsg.h" @@ -25,45 +25,41 @@ #include "executorimpl.h" #include "tcompression.h" -void initResultRowInfo(SResultRowInfo *pResultRowInfo) { - pResultRowInfo->size = 0; +void initResultRowInfo(SResultRowInfo* pResultRowInfo) { + pResultRowInfo->size = 0; pResultRowInfo->cur.pageId = -1; } -void cleanupResultRowInfo(SResultRowInfo *pResultRowInfo) { +void cleanupResultRowInfo(SResultRowInfo* pResultRowInfo) { if (pResultRowInfo == NULL) { return; } - for(int32_t i = 0; i < pResultRowInfo->size; ++i) { -// if (pResultRowInfo->pResult[i]) { -// taosMemoryFreeClear(pResultRowInfo->pResult[i]->key); -// } + for (int32_t i = 0; i < pResultRowInfo->size; ++i) { + // if (pResultRowInfo->pResult[i]) { + // taosMemoryFreeClear(pResultRowInfo->pResult[i]->key); + // } } } -void closeAllResultRows(SResultRowInfo *pResultRowInfo) { -// do nothing +void closeAllResultRows(SResultRowInfo* pResultRowInfo) { + // do nothing } -bool isResultRowClosed(SResultRow* pRow) { - return (pRow->closed == true); -} +bool isResultRowClosed(SResultRow* pRow) { return (pRow->closed == true); } -void closeResultRow(SResultRow* pResultRow) { - pResultRow->closed = true; -} +void closeResultRow(SResultRow* pResultRow) { pResultRow->closed = true; } // TODO refactor: use macro SResultRowEntryInfo* getResultEntryInfo(const SResultRow* pRow, int32_t index, const int32_t* offset) { assert(index >= 0 && offset != NULL); - return (SResultRowEntryInfo*)((char*) pRow->pEntryInfo + offset[index]); + return (SResultRowEntryInfo*)((char*)pRow->pEntryInfo + offset[index]); } size_t getResultRowSize(SqlFunctionCtx* pCtx, int32_t numOfOutput) { int32_t rowSize = (numOfOutput * sizeof(SResultRowEntryInfo)) + sizeof(SResultRow); - for(int32_t i = 0; i < numOfOutput; ++i) { + for (int32_t i = 0; i < numOfOutput; ++i) { rowSize += pCtx[i].resDataInfo.interBufSize; } @@ -74,31 +70,29 @@ void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo) { assert(pGroupResInfo != NULL); taosArrayDestroy(pGroupResInfo->pRows); - pGroupResInfo->pRows = NULL; - pGroupResInfo->index = 0; + pGroupResInfo->pRows = NULL; + pGroupResInfo->index = 0; } static int32_t resultrowComparAsc(const void* p1, const void* p2) { - SResKeyPos* pp1 = *(SResKeyPos**) p1; - SResKeyPos* pp2 = *(SResKeyPos**) p2; + SResKeyPos* pp1 = *(SResKeyPos**)p1; + SResKeyPos* pp2 = *(SResKeyPos**)p2; if (pp1->groupId == pp2->groupId) { - int64_t pts1 = *(int64_t*) pp1->key; - int64_t pts2 = *(int64_t*) pp2->key; + int64_t pts1 = *(int64_t*)pp1->key; + int64_t pts2 = *(int64_t*)pp2->key; if (pts1 == pts2) { return 0; } else { - return pts1 < pts2? -1:1; + return pts1 < pts2 ? -1 : 1; } } else { - return pp1->groupId < pp2->groupId? -1:1; + return pp1->groupId < pp2->groupId ? -1 : 1; } } -static int32_t resultrowComparDesc(const void* p1, const void* p2) { - return resultrowComparAsc(p2, p1); -} +static int32_t resultrowComparDesc(const void* p1, const void* p2) { return resultrowComparAsc(p2, p1); } void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SHashObj* pHashmap, int32_t order) { if (pGroupResInfo->pRows != NULL) { @@ -110,20 +104,20 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SHashObj* pHashmap, int pGroupResInfo->pRows = taosArrayInit(10, POINTER_BYTES); size_t keyLen = 0; - while((pData = taosHashIterate(pHashmap, pData)) != NULL) { + while ((pData = taosHashIterate(pHashmap, pData)) != NULL) { void* key = taosHashGetKey(pData, &keyLen); SResKeyPos* p = taosMemoryMalloc(keyLen + sizeof(SResultRowPosition)); - p->groupId = *(uint64_t*) key; - p->pos = *(SResultRowPosition*) pData; + p->groupId = *(uint64_t*)key; + p->pos = *(SResultRowPosition*)pData; memcpy(p->key, (char*)key + sizeof(uint64_t), keyLen - sizeof(uint64_t)); taosArrayPush(pGroupResInfo->pRows, &p); } if (order == TSDB_ORDER_ASC || order == TSDB_ORDER_DESC) { - __compar_fn_t fn = (order == TSDB_ORDER_ASC)? resultrowComparAsc:resultrowComparDesc; + __compar_fn_t fn = (order == TSDB_ORDER_ASC) ? resultrowComparAsc : resultrowComparDesc; qsort(pGroupResInfo->pRows->pData, taosArrayGetSize(pGroupResInfo->pRows), POINTER_BYTES, fn); } @@ -155,7 +149,7 @@ int32_t getNumOfTotalRes(SGroupResInfo* pGroupResInfo) { return 0; } - return (int32_t) taosArrayGetSize(pGroupResInfo->pRows); + return (int32_t)taosArrayGetSize(pGroupResInfo->pRows); } SArray* createSortInfo(SNodeList* pNodeList) { @@ -194,12 +188,13 @@ SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) { pBlock->info.type = STREAM_INVALID; for (int32_t i = 0; i < numOfCols; ++i) { - SSlotDescNode* pDescNode = (SSlotDescNode*)nodesListGetNode(pNode->pSlots, i); -// if (!pDescNode->output) { // todo disable it temporarily -// continue; -// } + SSlotDescNode* pDescNode = (SSlotDescNode*)nodesListGetNode(pNode->pSlots, i); + /*if (!pDescNode->output) { // todo disable it temporarily*/ + /*continue;*/ + /*}*/ - SColumnInfoData idata = createColumnInfoData(pDescNode->dataType.type, pDescNode->dataType.bytes, pDescNode->slotId); + SColumnInfoData idata = + createColumnInfoData(pDescNode->dataType.type, pDescNode->dataType.bytes, pDescNode->slotId); idata.info.scale = pDescNode->dataType.scale; idata.info.precision = pDescNode->dataType.precision; @@ -211,10 +206,10 @@ SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) { EDealRes doTranslateTagExpr(SNode** pNode, void* pContext) { SMetaReader* mr = (SMetaReader*)pContext; - if(nodeType(*pNode) == QUERY_NODE_COLUMN){ + if (nodeType(*pNode) == QUERY_NODE_COLUMN) { SColumnNode* pSColumnNode = *(SColumnNode**)pNode; - SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE); + SValueNode* res = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); if (NULL == res) { return DEAL_RES_ERROR; } @@ -227,8 +222,8 @@ EDealRes doTranslateTagExpr(SNode** pNode, void* pContext) { const char* p = metaGetTableTagVal(&mr->me, pSColumnNode->node.resType.type, &tagVal); if (p == NULL) { res->node.resType.type = TSDB_DATA_TYPE_NULL; - }else if (pSColumnNode->node.resType.type == TSDB_DATA_TYPE_JSON) { - int32_t len = ((const STag*)p) -> len; + } else if (pSColumnNode->node.resType.type == TSDB_DATA_TYPE_JSON) { + int32_t len = ((const STag*)p)->len; res->datum.p = taosMemoryCalloc(len + 1, 1); memcpy(res->datum.p, p, len); } else if (IS_VAR_DATA_TYPE(pSColumnNode->node.resType.type)) { @@ -240,10 +235,10 @@ EDealRes doTranslateTagExpr(SNode** pNode, void* pContext) { } nodesDestroyNode(*pNode); *pNode = (SNode*)res; - }else if (nodeType(*pNode) == QUERY_NODE_FUNCTION){ - SFunctionNode * pFuncNode = *(SFunctionNode**)pNode; - if(pFuncNode->funcType == FUNCTION_TYPE_TBNAME){ - SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE); + } else if (nodeType(*pNode) == QUERY_NODE_FUNCTION) { + SFunctionNode* pFuncNode = *(SFunctionNode**)pNode; + if (pFuncNode->funcType == FUNCTION_TYPE_TBNAME) { + SValueNode* res = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); if (NULL == res) { return DEAL_RES_ERROR; } @@ -263,12 +258,12 @@ EDealRes doTranslateTagExpr(SNode** pNode, void* pContext) { return DEAL_RES_CONTINUE; } -static bool isTableOk(STableKeyInfo* info, SNode *pTagCond, SMeta *metaHandle){ - SMetaReader mr = {0}; +static bool isTableOk(STableKeyInfo* info, SNode* pTagCond, SMeta* metaHandle) { + SMetaReader mr = {0}; metaReaderInit(&mr, metaHandle, 0); metaGetTableEntryByUid(&mr, info->uid); - SNode *pTagCondTmp = nodesCloneNode(pTagCond); + SNode* pTagCondTmp = nodesCloneNode(pTagCond); nodesRewriteExprPostOrder(&pTagCondTmp, doTranslateTagExpr, &mr); metaReaderClear(&mr); @@ -281,7 +276,7 @@ static bool isTableOk(STableKeyInfo* info, SNode *pTagCond, SMeta *metaHandle){ } ASSERT(nodeType(pNew) == QUERY_NODE_VALUE); - SValueNode *pValue = (SValueNode *)pNew; + SValueNode* pValue = (SValueNode*)pNew; ASSERT(pValue->node.resType.type == TSDB_DATA_TYPE_BOOL); bool result = pValue->datum.b; @@ -292,12 +287,12 @@ static bool isTableOk(STableKeyInfo* info, SNode *pTagCond, SMeta *metaHandle){ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo* pListInfo) { int32_t code = TSDB_CODE_SUCCESS; pListInfo->pTableList = taosArrayInit(8, sizeof(STableKeyInfo)); - if(pListInfo->pTableList == NULL) return TSDB_CODE_OUT_OF_MEMORY; + if (pListInfo->pTableList == NULL) return TSDB_CODE_OUT_OF_MEMORY; uint64_t tableUid = pScanNode->uid; pListInfo->suid = pScanNode->suid; - + SNode* pTagCond = (SNode*)pListInfo->pTagCond; SNode* pTagIndexCond = (SNode*)pListInfo->pTagIndexCond; if (pScanNode->tableType == TSDB_SUPER_TABLE) { @@ -306,7 +301,7 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo .metaEx = metaHandle, .idx = tsdbGetIdx(metaHandle), .ivtIdx = tsdbGetIvtIdx(metaHandle), .suid = tableUid}; SArray* res = taosArrayInit(8, sizeof(uint64_t)); - //code = doFilterTag(pTagIndexCond, &metaArg, res); + // code = doFilterTag(pTagIndexCond, &metaArg, res); code = TSDB_CODE_INDEX_REBUILDING; if (code == TSDB_CODE_INDEX_REBUILDING) { code = tsdbGetAllTableList(metaHandle, tableUid, pListInfo->pTableList); @@ -328,33 +323,33 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo code = tsdbGetAllTableList(metaHandle, tableUid, pListInfo->pTableList); } - if(pTagCond){ + if (pTagCond) { int32_t i = 0; - while(i < taosArrayGetSize(pListInfo->pTableList)) { + while (i < taosArrayGetSize(pListInfo->pTableList)) { STableKeyInfo* info = taosArrayGet(pListInfo->pTableList, i); - bool isOk = isTableOk(info, pTagCond, metaHandle); - if(!isOk){ + bool isOk = isTableOk(info, pTagCond, metaHandle); + if (!isOk) { taosArrayRemove(pListInfo->pTableList, i); continue; } i++; } } - }else { // Create one table group. + } else { // Create one table group. STableKeyInfo info = {.lastKey = 0, .uid = tableUid, .groupId = 0}; taosArrayPush(pListInfo->pTableList, &info); } pListInfo->pGroupList = taosArrayInit(4, POINTER_BYTES); - if(pListInfo->pGroupList == NULL) return TSDB_CODE_OUT_OF_MEMORY; + if (pListInfo->pGroupList == NULL) return TSDB_CODE_OUT_OF_MEMORY; - //put into list as default group, remove it if grouping sorting is required later + // put into list as default group, remove it if grouping sorting is required later taosArrayPush(pListInfo->pGroupList, &pListInfo->pTableList); return code; } SArray* extractPartitionColInfo(SNodeList* pNodeList) { - if(!pNodeList) { + if (!pNodeList) { return NULL; } @@ -383,7 +378,6 @@ SArray* extractPartitionColInfo(SNodeList* pNodeList) { return pList; } - SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols, int32_t type) { size_t numOfCols = LIST_LENGTH(pNodeList); @@ -399,7 +393,7 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod SColMatchInfo c = {0}; c.output = true; - c.colId = pColNode->colId; + c.colId = pColNode->colId; c.srcSlotId = pColNode->slotId; c.matchType = type; c.targetSlotId = pNode->slotId; @@ -675,8 +669,8 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, } for (int32_t i = 1; i < numOfOutput; ++i) { - (*rowEntryInfoOffset)[i] = - (int32_t)((*rowEntryInfoOffset)[i - 1] + sizeof(SResultRowEntryInfo) + pFuncCtx[i - 1].resDataInfo.interBufSize); + (*rowEntryInfoOffset)[i] = (int32_t)((*rowEntryInfoOffset)[i - 1] + sizeof(SResultRowEntryInfo) + + pFuncCtx[i - 1].resDataInfo.interBufSize); } setSelectValueColumnInfo(pFuncCtx, numOfOutput); diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 6de364e63a..31edc46b4d 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -44,12 +44,12 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu // prevent setting a different type of block pInfo->blockType = type; - if (type == STREAM_DATA_TYPE_SUBMIT_BLOCK) { + if (type == STREAM_INPUT__DATA_SUBMIT) { if (tqReadHandleSetMsg(pInfo->streamBlockReader, input, 0) < 0) { qError("submit msg messed up when initing stream block, %s" PRIx64, id); return TSDB_CODE_QRY_APP_ERROR; } - } else if (type == STREAM_DATA_TYPE_SSDATA_BLOCK) { + } else if (type == STREAM_INPUT__DATA_BLOCK) { for (int32_t i = 0; i < numOfBlocks; ++i) { SSDataBlock* pDataBlock = &((SSDataBlock*)input)[i]; @@ -60,9 +60,9 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu taosArrayAddAll(p->pDataBlock, pDataBlock->pDataBlock); taosArrayPush(pInfo->pBlockLists, &p); } - } else if (type == STREAM_DATA_TYPE_FROM_SNAPSHOT) { + } else if (type == STREAM_INPUT__DATA_SCAN) { // do nothing - ASSERT(pInfo->blockType == STREAM_DATA_TYPE_FROM_SNAPSHOT); + ASSERT(pInfo->blockType == STREAM_INPUT__DATA_SCAN); } else { ASSERT(0); } @@ -76,7 +76,7 @@ int32_t qStreamScanSnapshot(qTaskInfo_t tinfo) { return TSDB_CODE_QRY_APP_ERROR; } SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - return doSetStreamBlock(pTaskInfo->pRoot, NULL, 0, STREAM_DATA_TYPE_FROM_SNAPSHOT, 0, NULL); + return doSetStreamBlock(pTaskInfo->pRoot, NULL, 0, STREAM_INPUT__DATA_SCAN, 0, NULL); } int32_t qSetStreamInput(qTaskInfo_t tinfo, const void* input, int32_t type, bool assignUid) { diff --git a/source/libs/executor/src/executorMain.c b/source/libs/executor/src/executorMain.c index e4c0959185..0871575d95 100644 --- a/source/libs/executor/src/executorMain.c +++ b/source/libs/executor/src/executorMain.c @@ -191,16 +191,6 @@ int32_t qAsyncKillTask(qTaskInfo_t qinfo) { return TSDB_CODE_SUCCESS; } -int32_t qIsTaskCompleted(qTaskInfo_t qinfo) { - SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)qinfo; - - if (pTaskInfo == NULL) { - return TSDB_CODE_QRY_INVALID_QHANDLE; - } - - return isTaskKilled(pTaskInfo); -} - void qDestroyTask(qTaskInfo_t qTaskHandle) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)qTaskHandle; qDebug("%s execTask completed, numOfRows:%" PRId64, GET_TASKID(pTaskInfo), pTaskInfo->pRoot->resultInfo.totalRows); @@ -242,3 +232,10 @@ int32_t qDeserializeTaskStatus(qTaskInfo_t tinfo, const char* pInput, int32_t le } +int32_t qGetStreamScanStatus(qTaskInfo_t tinfo, uint64_t* uid, int64_t* ts) { + SExecTaskInfo* pTaskInfo = (SExecTaskInfo*) tinfo; + + return TSDB_CODE_SUCCESS; +} + + diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 535272bc42..4d8fd2085b 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1033,7 +1033,7 @@ static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSData SqlFunctionCtx* pCtx = pTableScanInfo->pCtx; uint32_t status = BLK_DATA_NOT_LOAD; - int32_t numOfOutput = pTableScanInfo->numOfOutput; + int32_t numOfOutput = 0;//pTableScanInfo->numOfOutput; for (int32_t i = 0; i < numOfOutput; ++i) { int32_t functionId = pCtx[i].functionId; int32_t colId = pTableScanInfo->pExpr[i].base.pParam[0].pCol->colId; @@ -2049,7 +2049,7 @@ int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLo if (pColList == NULL) { // data from other sources blockDataCleanup(pRes); // blockDataEnsureCapacity(pRes, numOfRows); - blockCompressDecode(pRes, numOfOutput, numOfRows, pData); + blockDecode(pRes, numOfOutput, numOfRows, pData); } else { // extract data according to pColList ASSERT(numOfOutput == taosArrayGetSize(pColList)); char* pStart = pData; @@ -2073,7 +2073,7 @@ int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLo blockDataAppendColInfo(pBlock, &idata); } - blockCompressDecode(pBlock, numOfCols, numOfRows, pStart); + blockDecode(pBlock, numOfCols, numOfRows, pStart); blockDataEnsureCapacity(pRes, numOfRows); // data from mnode @@ -2822,6 +2822,24 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan } } +int32_t doGetScanStatus(SOperatorInfo* pOperator, uint64_t* uid, int64_t* ts) { + int32_t type = pOperator->operatorType; + if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { + SStreamBlockScanInfo* pScanInfo = pOperator->info; + STableScanInfo* pSnapShotScanInfo = pScanInfo->pSnapshotReadOp->info; + *uid = pSnapShotScanInfo->scanStatus.uid; + *ts = pSnapShotScanInfo->scanStatus.t; + } else { + if (pOperator->pDownstream[0] == NULL) { + return TSDB_CODE_INVALID_PARA; + } else { + doGetScanStatus(pOperator->pDownstream[0], uid, ts); + } + } + + return TSDB_CODE_SUCCESS; +} + // this is a blocking operator static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { if (OPTR_IS_OPENED(pOperator)) { @@ -2935,7 +2953,7 @@ int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* len *length = 0; return TSDB_CODE_SUCCESS; } - + *result = (char*)taosMemoryCalloc(1, totalSize); if (*result == NULL) { return TSDB_CODE_OUT_OF_MEMORY; @@ -3544,7 +3562,7 @@ static void destroyProjectOperatorInfo(void* param, int32_t numOfOutput) { taosArrayDestroy(pInfo->pPseudoColInfo); } -void cleanupExecSupp(SExprSupp* pSupp) { +void cleanupExprSupp(SExprSupp* pSupp) { destroySqlFunctionCtx(pSupp->pCtx, pSupp->numOfExprs); destroyExprInfo(pSupp->pExprInfo, pSupp->numOfExprs); @@ -3557,7 +3575,7 @@ static void destroyIndefinitOperatorInfo(void* param, int32_t numOfOutput) { taosArrayDestroy(pInfo->pPseudoColInfo); cleanupAggSup(&pInfo->aggSup); - cleanupExecSupp(&pInfo->scalarSup); + cleanupExprSupp(&pInfo->scalarSup); } void destroyExchangeOperatorInfo(void* param, int32_t numOfOutput) { @@ -3899,60 +3917,59 @@ int32_t extractTableSchemaVersion(SReadHandle* pHandle, uint64_t uid, SExecTaskI return TSDB_CODE_SUCCESS; } -static int32_t sortTableGroup(STableListInfo* pTableListInfo, int32_t groupNum){ +static int32_t sortTableGroup(STableListInfo* pTableListInfo, int32_t groupNum) { taosArrayClear(pTableListInfo->pGroupList); - SArray *sortSupport = taosArrayInit(groupNum, sizeof(uint64_t)); - if(sortSupport == NULL) return TSDB_CODE_OUT_OF_MEMORY; + SArray* sortSupport = taosArrayInit(groupNum, sizeof(uint64_t)); + if (sortSupport == NULL) return TSDB_CODE_OUT_OF_MEMORY; for (int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); i++) { STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i); - uint64_t* groupId = taosHashGet(pTableListInfo->map, &info->uid, sizeof(uint64_t)); + uint64_t* groupId = taosHashGet(pTableListInfo->map, &info->uid, sizeof(uint64_t)); int32_t index = taosArraySearchIdx(sortSupport, groupId, compareUint64Val, TD_EQ); - if (index == -1){ - void *p = taosArraySearch(sortSupport, groupId, compareUint64Val, TD_GT); - SArray *tGroup = taosArrayInit(8, sizeof(STableKeyInfo)); - if(tGroup == NULL) { + if (index == -1) { + void* p = taosArraySearch(sortSupport, groupId, compareUint64Val, TD_GT); + SArray* tGroup = taosArrayInit(8, sizeof(STableKeyInfo)); + if (tGroup == NULL) { taosArrayDestroy(sortSupport); return TSDB_CODE_OUT_OF_MEMORY; } - if(taosArrayPush(tGroup, info) == NULL){ + if (taosArrayPush(tGroup, info) == NULL) { qError("taos push info array error"); taosArrayDestroy(sortSupport); return TSDB_CODE_QRY_APP_ERROR; } - if(p == NULL){ - if(taosArrayPush(sortSupport, groupId) != NULL){ + if (p == NULL) { + if (taosArrayPush(sortSupport, groupId) != NULL) { qError("taos push support array error"); taosArrayDestroy(sortSupport); return TSDB_CODE_QRY_APP_ERROR; } - if(taosArrayPush(pTableListInfo->pGroupList, &tGroup) != NULL){ + if (taosArrayPush(pTableListInfo->pGroupList, &tGroup) != NULL) { qError("taos push group array error"); taosArrayDestroy(sortSupport); return TSDB_CODE_QRY_APP_ERROR; } - }else{ + } else { int32_t pos = TARRAY_ELEM_IDX(sortSupport, p); - if(taosArrayInsert(sortSupport, pos, groupId) == NULL){ + if (taosArrayInsert(sortSupport, pos, groupId) == NULL) { qError("taos insert support array error"); taosArrayDestroy(sortSupport); return TSDB_CODE_QRY_APP_ERROR; } - if(taosArrayInsert(pTableListInfo->pGroupList, pos, &tGroup) == NULL){ + if (taosArrayInsert(pTableListInfo->pGroupList, pos, &tGroup) == NULL) { qError("taos insert group array error"); taosArrayDestroy(sortSupport); return TSDB_CODE_QRY_APP_ERROR; } } - }else{ + } else { SArray* tGroup = (SArray*)taosArrayGetP(pTableListInfo->pGroupList, index); - if(taosArrayPush(tGroup, info) == NULL){ + if (taosArrayPush(tGroup, info) == NULL) { qError("taos push uid array error"); taosArrayDestroy(sortSupport); return TSDB_CODE_QRY_APP_ERROR; } } - } taosArrayDestroy(sortSupport); return TDB_CODE_SUCCESS; @@ -3970,9 +3987,9 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, int32_t keyLen = 0; void* keyBuf = NULL; - SNode* node; + SNode* node; FOREACH(node, group) { - SExprNode *pExpr = (SExprNode *)node; + SExprNode* pExpr = (SExprNode*)node; keyLen += pExpr->resType.bytes; } @@ -3991,15 +4008,15 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, metaReaderInit(&mr, pHandle->meta, 0); metaGetTableEntryByUid(&mr, info->uid); - SNodeList *groupNew = nodesCloneList(group); + SNodeList* groupNew = nodesCloneList(group); nodesRewriteExprsPostOrder(groupNew, doTranslateTagExpr, &mr); char* isNull = (char*)keyBuf; char* pStart = (char*)keyBuf + nullFlagSize; - SNode* pNode; + SNode* pNode; int32_t index = 0; - FOREACH(pNode, groupNew){ + FOREACH(pNode, groupNew) { SNode* pNew = NULL; int32_t code = scalarCalculateConstants(pNode, &pNew); if (TSDB_CODE_SUCCESS == code) { @@ -4011,15 +4028,15 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, } ASSERT(nodeType(pNew) == QUERY_NODE_VALUE); - SValueNode *pValue = (SValueNode *)pNew; + SValueNode* pValue = (SValueNode*)pNew; if (pValue->node.resType.type == TSDB_DATA_TYPE_NULL) { isNull[index++] = 1; continue; } else { isNull[index++] = 0; - char* data = nodesGetValueFromNode(pValue); - if (pValue->node.resType.type == TSDB_DATA_TYPE_JSON){ + char* data = nodesGetValueFromNode(pValue); + if (pValue->node.resType.type == TSDB_DATA_TYPE_JSON) { int32_t len = getJsonValueLen(data); memcpy(pStart, data, len); pStart += len; @@ -4032,7 +4049,7 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, } } } - int32_t len = (int32_t)(pStart - (char*)keyBuf); + int32_t len = (int32_t)(pStart - (char*)keyBuf); uint64_t groupId = calcGroupId(keyBuf, len); taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &groupId, sizeof(uint64_t)); info->groupId = groupId; @@ -4043,7 +4060,7 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, } taosMemoryFree(keyBuf); - if(pTableListInfo->needSortTableByGroupId){ + if (pTableListInfo->needSortTableByGroupId) { return sortTableGroup(pTableListInfo, groupNum); } @@ -4051,7 +4068,8 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, } SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle, - uint64_t queryId, uint64_t taskId, STableListInfo* pTableListInfo, const char* pUser) { + uint64_t queryId, uint64_t taskId, STableListInfo* pTableListInfo, + const char* pUser) { int32_t type = nodeType(pPhyNode); if (pPhyNode->pChildren == NULL || LIST_LENGTH(pPhyNode->pChildren) == 0) { @@ -4059,7 +4077,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode; int32_t code = createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId); - if(code){ + if (code) { pTaskInfo->code = code; return NULL; } @@ -4077,7 +4095,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo } else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN == type) { STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode; int32_t code = createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId); - if(code){ + if (code) { return NULL; } code = extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo); @@ -4086,7 +4104,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return NULL; } - SOperatorInfo* pOperator = createTableMergeScanOperatorInfo(pTableScanNode, pTableListInfo, pHandle, pTaskInfo, queryId, taskId); + SOperatorInfo* pOperator = + createTableMergeScanOperatorInfo(pTableScanNode, pTableListInfo, pHandle, pTaskInfo, queryId, taskId); STableScanInfo* pScanInfo = pOperator->info; pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder; @@ -4106,7 +4125,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId); } - SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle, pTableScanNode, pTaskInfo, &twSup, queryId, taskId); + SOperatorInfo* pOperator = + createStreamScanOperatorInfo(pHandle, pTableScanNode, pTaskInfo, &twSup, queryId, taskId); return pOperator; } else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) { @@ -4604,8 +4624,8 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead (*pTaskInfo)->sql = sql; (*pTaskInfo)->tableqinfoList.pTagCond = pPlan->pTagCond; (*pTaskInfo)->tableqinfoList.pTagIndexCond = pPlan->pTagIndexCond; - (*pTaskInfo)->pRoot = - createOperatorTree(pPlan->pNode, *pTaskInfo, pHandle, queryId, taskId, &(*pTaskInfo)->tableqinfoList, pPlan->user); + (*pTaskInfo)->pRoot = createOperatorTree(pPlan->pNode, *pTaskInfo, pHandle, queryId, taskId, + &(*pTaskInfo)->tableqinfoList, pPlan->user); if (NULL == (*pTaskInfo)->pRoot) { code = (*pTaskInfo)->code; @@ -4623,8 +4643,8 @@ _complete: static void doDestroyTableList(STableListInfo* pTableqinfoList) { taosArrayDestroy(pTableqinfoList->pTableList); taosHashCleanup(pTableqinfoList->map); - if(pTableqinfoList->needSortTableByGroupId){ - for(int32_t i = 0; i < taosArrayGetSize(pTableqinfoList->pGroupList); i++){ + if (pTableqinfoList->needSortTableByGroupId) { + for (int32_t i = 0; i < taosArrayGetSize(pTableqinfoList->pGroupList); i++) { SArray* tmp = taosArrayGetP(pTableqinfoList->pGroupList, i); taosArrayDestroy(tmp); } diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 4e4aaba7f4..0a14993c21 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -37,7 +37,7 @@ static void destroyGroupOperatorInfo(void* param, int32_t numOfOutput) { taosMemoryFreeClear(pInfo->keyBuf); taosArrayDestroy(pInfo->pGroupCols); taosArrayDestroy(pInfo->pGroupColVals); - cleanupExecSupp(&pInfo->scalarSup); + cleanupExprSupp(&pInfo->scalarSup); } static int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char** keyBuf, const SArray* pGroupColList) { @@ -701,7 +701,7 @@ static void destroyPartitionOperatorInfo(void* param, int32_t numOfOutput) { taosHashCleanup(pInfo->pGroupSet); taosMemoryFree(pInfo->columnOffset); - cleanupExecSupp(&pInfo->scalarSup); + cleanupExprSupp(&pInfo->scalarSup); } SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartitionPhysiNode* pPartNode, SExecTaskInfo* pTaskInfo) { diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 146b6ca76b..eae20fbb04 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -13,6 +13,7 @@ * along with this program. If not, see . */ +#include #include #include "filter.h" #include "function.h" @@ -413,6 +414,11 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { pTableScanInfo->readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0; pOperator->cost.totalCost = pTableScanInfo->readRecorder.elapsedTime; + + // todo refactor + pTableScanInfo->scanStatus.uid = pBlock->info.uid; + pTableScanInfo->scanStatus.t = pBlock->info.window.ekey; + return pBlock; } return NULL; @@ -459,7 +465,7 @@ static SSDataBlock* doTableScanGroup(SOperatorInfo* pOperator) { int32_t total = pTableScanInfo->scanInfo.numOfAsc + pTableScanInfo->scanInfo.numOfDesc; if (pTableScanInfo->scanTimes < total) { if (pTableScanInfo->cond.order == TSDB_ORDER_ASC) { - prepareForDescendingScan(pTableScanInfo, pTableScanInfo->pCtx, pTableScanInfo->numOfOutput); + prepareForDescendingScan(pTableScanInfo, pTableScanInfo->pCtx, 0); tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0); pTableScanInfo->curTWinIdx = 0; } @@ -962,7 +968,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) { size_t total = taosArrayGetSize(pInfo->pBlockLists); // TODO: refactor - if (pInfo->blockType == STREAM_DATA_TYPE_SSDATA_BLOCK) { + if (pInfo->blockType == STREAM_INPUT__DATA_BLOCK) { if (pInfo->validBlockIndex >= total) { /*doClearBufferedBlocks(pInfo);*/ pOperator->status = OP_EXEC_DONE; @@ -973,7 +979,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) { SSDataBlock* pBlock = taosArrayGetP(pInfo->pBlockLists, current); blockDataUpdateTsWindow(pBlock, 0); if (pBlock->info.type == STREAM_RETRIEVE) { - pInfo->blockType = STREAM_DATA_TYPE_SUBMIT_BLOCK; + pInfo->blockType = STREAM_INPUT__DATA_SUBMIT; pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RETRIEVE; copyDataBlock(pInfo->pPullDataRes, pBlock); pInfo->pullDataResIndex = 0; @@ -981,7 +987,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) { updateInfoAddCloseWindowSBF(pInfo->pUpdateInfo); } return pBlock; - } else if (pInfo->blockType == STREAM_DATA_TYPE_SUBMIT_BLOCK) { + } else if (pInfo->blockType == STREAM_INPUT__DATA_SUBMIT) { if (pInfo->scanMode == STREAM_SCAN_FROM_RES) { blockDataDestroy(pInfo->pUpdateRes); pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE; @@ -996,7 +1002,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) { SSDataBlock* pSDB = doDataScan(pInfo, pInfo->pPullDataRes, 0, &pInfo->pullDataResIndex); if (pSDB != NULL) { getUpdateDataBlock(pInfo, true, pSDB, NULL); - pSDB->info.type = STREAM_PUSH_DATA; + pSDB->info.type = STREAM_PULL_DATA; return pSDB; } pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER; @@ -1133,7 +1139,9 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) { return (pBlockInfo->rows == 0) ? NULL : pInfo->pRes; - } else if (pInfo->blockType == STREAM_DATA_TYPE_FROM_SNAPSHOT) { + } else if (pInfo->blockType == STREAM_INPUT__DATA_SCAN) { + // check reader last status + // if not match, reset status SSDataBlock* pResult = doTableScan(pInfo->pSnapshotReadOp); return pResult && pResult->info.rows > 0 ? pResult : NULL; @@ -1213,7 +1221,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->tableUid = pScanPhyNode->uid; // set the extract column id to streamHandle - tqReadHandleSetColIdList((STqReadHandle*)pHandle->reader, pColIds); + tqReadHandleSetColIdList((SStreamReader*)pHandle->reader, pColIds); SArray* tableIdList = extractTableIdList(&pTaskInfo->tableqinfoList); int32_t code = tqReadHandleSetTbUidList(pHandle->reader, tableIdList); if (code != 0) { diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 963e714972..95b16589ee 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -34,7 +34,7 @@ typedef struct SWinRes { typedef struct SPullWindowInfo { STimeWindow window; - uint64_t groupId; + uint64_t groupId; } SPullWindowInfo; static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator); @@ -695,11 +695,11 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num } void printDataBlock(SSDataBlock* pBlock, const char* flag) { - if (pBlock == NULL){ + if (pBlock == NULL) { qDebug("======printDataBlock Block is Null"); return; } - char *pBuf = NULL; + char* pBuf = NULL; qDebug("%s", dumpBlockData(pBlock, flag, &pBuf)); taosMemoryFree(pBuf); } @@ -813,6 +813,13 @@ static void removeResults(SArray* pWins, SArray* pUpdated) { } } +bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup) { + ASSERT(pSup->maxTs == INT64_MIN || pSup->maxTs > 0); + return pSup->maxTs != INT64_MIN && ts < pSup->maxTs - pSup->waterMark; +} + +bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup) { return isOverdue(pWin->ekey, pSup); } + static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pBlock, int32_t scanFlag, SArray* pUpdated) { SIntervalAggOperatorInfo* pInfo = (SIntervalAggOperatorInfo*)pOperatorInfo->info; @@ -830,15 +837,15 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul STimeWindow win = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, pInfo->interval.precision, &pInfo->win); + int32_t ret = TSDB_CODE_SUCCESS; + if (!pInfo->ignoreCloseWindow || !isCloseWindow(&win, &pInfo->twAggSup)) { + ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx, + numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); + if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { + longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + } - int32_t ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, - pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); - if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { - longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); - } - - if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) { - if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) { + if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM && pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) { saveResultRow(pResult, tableGroupId, pUpdated); } } @@ -864,9 +871,11 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul doWindowBorderInterpolation(pInfo, pBlock, pResult, &win, startPos, forwardRows, pSup); } - updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, true); - doApplyFunctions(pTaskInfo, pSup->pCtx, &win, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, tsCols, - pBlock->info.rows, numOfOutput, pInfo->order); + if (!pInfo->ignoreCloseWindow || !isCloseWindow(&win, &pInfo->twAggSup)) { + updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, true); + doApplyFunctions(pTaskInfo, pSup->pCtx, &win, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, tsCols, + pBlock->info.rows, numOfOutput, pInfo->order); + } doCloseWindow(pResultRowInfo, pInfo, pResult); @@ -877,6 +886,12 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul if (startPos < 0) { break; } + if (pInfo->ignoreCloseWindow && isCloseWindow(&nextWin, &pInfo->twAggSup)) { + ekey = ascScan ? nextWin.ekey : nextWin.skey; + forwardRows = + getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->order); + continue; + } // null data, failed to allocate more memory buffer int32_t code = setTimeWindowOutputBuf(pResultRowInfo, &nextWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, @@ -885,10 +900,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } - if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) { - if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) { - saveResultRow(pResult, tableGroupId, pUpdated); - } + if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM && pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) { + saveResultRow(pResult, tableGroupId, pUpdated); } ekey = ascScan ? nextWin.ekey : nextWin.skey; @@ -970,9 +983,8 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) { getTableScanInfo(pOperator, &pInfo->order, &scanFlag); if (pInfo->scalarSupp.pExprInfo != NULL) { - SExprSupp* pExprSup =& pInfo->scalarSupp; - projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, - pExprSup->numOfExprs, NULL); + SExprSupp* pExprSup = &pInfo->scalarSupp; + projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL); } // the pDataBlock are always the same one, no need to call this again @@ -1255,10 +1267,10 @@ static void doClearWindows(SAggSupporter* pAggSup, SExprSupp* pSup1, SInterval* TSKEY* tsCols = (TSKEY*)pTsCol->pData; uint64_t* pGpDatas = NULL; if (pBlock->info.type == STREAM_RETRIEVE) { - SColumnInfoData* pGpCol = taosArrayGet(pBlock->pDataBlock, 2); - pGpDatas = (uint64_t*)pGpCol->pData; + SColumnInfoData* pGpCol = taosArrayGet(pBlock->pDataBlock, 2); + pGpDatas = (uint64_t*)pGpCol->pData; } - int32_t step = 0; + int32_t step = 0; for (int32_t i = 0; i < pBlock->info.rows; i += step) { SResultRowInfo dumyInfo; dumyInfo.cur.pageId = -1; @@ -1292,13 +1304,8 @@ static int32_t getAllIntervalWindow(SHashObj* pHashMap, SArray* resWins) { return TSDB_CODE_SUCCESS; } -bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup) { - ASSERT(pSup->maxTs == INT64_MIN || pSup->maxTs > 0); - return pSup->maxTs != INT64_MIN && pWin->ekey < pSup->maxTs - pSup->waterMark; -} - -static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup, - SInterval* pInterval, SHashObj* pPullDataMap, SArray* closeWins) { +static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup, SInterval* pInterval, + SHashObj* pPullDataMap, SArray* closeWins) { void* pIte = NULL; size_t keyLen = 0; while ((pIte = taosHashIterate(pHashMap, pIte)) != NULL) { @@ -1309,15 +1316,18 @@ static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup, SResultRowInfo dumyInfo; dumyInfo.cur.pageId = -1; STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, ts, pInterval, pInterval->precision, NULL); - SWinRes winRe = {.ts = win.skey, .groupId = groupId,}; + SWinRes winRe = { + .ts = win.skey, + .groupId = groupId, + }; void* chIds = taosHashGet(pPullDataMap, &winRe, sizeof(SWinRes)); if (isCloseWindow(&win, pSup)) { if (chIds && pPullDataMap) { - SArray* chAy = *(SArray**) chIds; + SArray* chAy = *(SArray**)chIds; int32_t size = taosArrayGetSize(chAy); - qInfo("======window %ld wait child size:%d", win.skey ,size); + qInfo("======window %ld wait child size:%d", win.skey, size); for (int32_t i = 0; i < size; i++) { - qInfo("======window %ld wait chid id:%d", win.skey ,*(int32_t*)taosArrayGet(chAy, i)); + qInfo("======window %ld wait chid id:%d", win.skey, *(int32_t*)taosArrayGet(chAy, i)); } continue; } else if (pPullDataMap) { @@ -1341,7 +1351,7 @@ static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup, static void closeChildIntervalWindow(SArray* pChildren, TSKEY maxTs) { int32_t size = taosArrayGetSize(pChildren); for (int32_t i = 0; i < size; i++) { - SOperatorInfo* pChildOp = taosArrayGetP(pChildren, i); + SOperatorInfo* pChildOp = taosArrayGetP(pChildren, i); SStreamFinalIntervalOperatorInfo* pChInfo = pChildOp->info; ASSERT(pChInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE); pChInfo->twAggSup.maxTs = TMAX(pChInfo->twAggSup.maxTs, maxTs); @@ -1411,7 +1421,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); pOperator->status = OP_RES_TO_RETURN; - + printDataBlock(pInfo->binfo.pRes, "single interval"); return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes; } @@ -1431,7 +1441,7 @@ void destroyStreamFinalIntervalOperatorInfo(void* param, int32_t numOfOutput) { SStreamFinalIntervalOperatorInfo* pInfo = (SStreamFinalIntervalOperatorInfo*)param; cleanupBasicInfo(&pInfo->binfo); cleanupAggSup(&pInfo->aggSup); - //it should be empty. + // it should be empty. taosHashCleanup(pInfo->pPullDataMap); taosArrayDestroy(pInfo->pPullWins); blockDataDestroy(pInfo->pPullDataRes); @@ -1509,23 +1519,25 @@ void increaseTs(SqlFunctionCtx* pCtx) { SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId, - STimeWindowAggSupp* pTwAggSupp, SIntervalPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, bool isStream) { + STimeWindowAggSupp* pTwAggSupp, SIntervalPhysiNode* pPhyNode, + SExecTaskInfo* pTaskInfo, bool isStream) { SIntervalAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SIntervalAggOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { goto _error; } - pInfo->win = pTaskInfo->window; - pInfo->order = TSDB_ORDER_ASC; - pInfo->interval = *pInterval; + pInfo->win = pTaskInfo->window; + pInfo->order = TSDB_ORDER_ASC; + pInfo->interval = *pInterval; pInfo->execModel = pTaskInfo->execModel; - pInfo->twAggSup = *pTwAggSupp; + pInfo->twAggSup = *pTwAggSupp; + pInfo->ignoreCloseWindow = false; if (pPhyNode->window.pExprs != NULL) { int32_t numOfScalar = 0; SExprInfo* pScalarExprInfo = createExprInfo(pPhyNode->window.pExprs, NULL, &numOfScalar); - int32_t code = initExprSupp(&pInfo->scalarSupp, pScalarExprInfo, numOfScalar); + int32_t code = initExprSupp(&pInfo->scalarSupp, pScalarExprInfo, numOfScalar); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -2236,10 +2248,10 @@ bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup) { return p1 == NULL; } -int32_t getNexWindowPos(SInterval* pInterval, SDataBlockInfo* pBlockInfo, TSKEY* tsCols, - int32_t startPos, TSKEY eKey, STimeWindow* pNextWin) { - int32_t forwardRows = getNumOfRowsInTimeWindow(pBlockInfo, tsCols, startPos, - eKey, binarySearchForKey, NULL, TSDB_ORDER_ASC); +int32_t getNexWindowPos(SInterval* pInterval, SDataBlockInfo* pBlockInfo, TSKEY* tsCols, int32_t startPos, TSKEY eKey, + STimeWindow* pNextWin) { + int32_t forwardRows = + getNumOfRowsInTimeWindow(pBlockInfo, tsCols, startPos, eKey, binarySearchForKey, NULL, TSDB_ORDER_ASC); int32_t prevEndPos = forwardRows - 1 + startPos; return getNextQualifiedWindow(pInterval, pNextWin, pBlockInfo, tsCols, prevEndPos, TSDB_ORDER_ASC); } @@ -2276,9 +2288,20 @@ static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBloc STimeWindow nextWin = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, pInfo->interval.precision, NULL); while (1) { - if (IS_FINAL_OP(pInfo) && isCloseWindow(&nextWin, &pInfo->twAggSup) && pInfo->pChildren) { - bool ignore = true; - SWinRes winRes = {.ts = nextWin.skey, .groupId = tableGroupId,}; + bool isClosed = isCloseWindow(&nextWin, &pInfo->twAggSup); + if (pInfo->ignoreCloseWindow && isClosed) { + startPos = getNexWindowPos(&pInfo->interval, &pSDataBlock->info, tsCols, startPos, nextWin.ekey, &nextWin); + if (startPos < 0) { + break; + } + continue; + } + if (IS_FINAL_OP(pInfo) && isClosed && pInfo->pChildren) { + bool ignore = true; + SWinRes winRes = { + .ts = nextWin.skey, + .groupId = tableGroupId, + }; void* chIds = taosHashGet(pInfo->pPullDataMap, &winRes, sizeof(SWinRes)); if (isDeletedWindow(&nextWin, tableGroupId, &pInfo->aggSup) && !chIds) { SPullWindowInfo pull = {.window = nextWin, .groupId = tableGroupId}; @@ -2289,18 +2312,18 @@ static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBloc int32_t index = -1; SArray* chArray = NULL; if (chIds) { - chArray = *(void**) chIds; + chArray = *(void**)chIds; int32_t chId = getChildIndex(pSDataBlock); index = taosArraySearchIdx(chArray, &chId, compareInt32Val, TD_EQ); } - if (index != -1 && pSDataBlock->info.type == STREAM_PUSH_DATA) { + if (index != -1 && pSDataBlock->info.type == STREAM_PULL_DATA) { taosArrayRemove(chArray, index); if (taosArrayGetSize(chArray) == 0) { // pull data is over taosHashRemove(pInfo->pPullDataMap, &winRes, sizeof(SWinRes)); } } - if ( index == -1 || pSDataBlock->info.type == STREAM_PUSH_DATA) { + if (index == -1 || pSDataBlock->info.type == STREAM_PULL_DATA) { ignore = false; } } @@ -2385,17 +2408,17 @@ static void doBuildPullDataBlock(SArray* array, int32_t* pIndex, SSDataBlock* pB if (size - (*pIndex) == 0) { return; } - blockDataEnsureCapacity(pBlock, size - (*pIndex) ); + blockDataEnsureCapacity(pBlock, size - (*pIndex)); ASSERT(3 <= taosArrayGetSize(pBlock->pDataBlock)); for (; (*pIndex) < size; (*pIndex)++) { - SPullWindowInfo* pWin = taosArrayGet(array, (*pIndex) ); - SColumnInfoData* pStartTs = (SColumnInfoData*) taosArrayGet(pBlock->pDataBlock, 0); + SPullWindowInfo* pWin = taosArrayGet(array, (*pIndex)); + SColumnInfoData* pStartTs = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, 0); colDataAppend(pStartTs, pBlock->info.rows, (const char*)&pWin->window.skey, false); - SColumnInfoData* pEndTs = (SColumnInfoData*) taosArrayGet(pBlock->pDataBlock, 1); + SColumnInfoData* pEndTs = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, 1); colDataAppend(pEndTs, pBlock->info.rows, (const char*)&pWin->window.ekey, false); - SColumnInfoData* pGroupId = (SColumnInfoData*) taosArrayGet(pBlock->pDataBlock, 2); + SColumnInfoData* pGroupId = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, 2); colDataAppend(pGroupId, pBlock->info.rows, (const char*)&pWin->groupId, false); pBlock->info.rows++; } @@ -2406,17 +2429,17 @@ static void doBuildPullDataBlock(SArray* array, int32_t* pIndex, SSDataBlock* pB blockDataUpdateTsWindow(pBlock, 0); } -void processPushEmpty(SSDataBlock* pBlock, SHashObj* pMap) { +void processPullOver(SSDataBlock* pBlock, SHashObj* pMap) { SColumnInfoData* pStartCol = taosArrayGet(pBlock->pDataBlock, 0); - TSKEY* tsData = (TSKEY*)pStartCol->pData; + TSKEY* tsData = (TSKEY*)pStartCol->pData; SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, 2); - uint64_t* groupIdData = (uint64_t*)pGroupCol->pData; - int32_t chId = getChildIndex(pBlock); + uint64_t* groupIdData = (uint64_t*)pGroupCol->pData; + int32_t chId = getChildIndex(pBlock); for (int32_t i = 0; i < pBlock->info.rows; i++) { SWinRes winRes = {.ts = tsData[i], .groupId = groupIdData[i]}; - void* chIds = taosHashGet(pMap, &winRes, sizeof(SWinRes)); + void* chIds = taosHashGet(pMap, &winRes, sizeof(SWinRes)); if (chIds) { - SArray* chArray = *(SArray**) chIds; + SArray* chArray = *(SArray**)chIds; int32_t index = taosArraySearchIdx(chArray, &chId, compareInt32Val, TD_EQ); if (index != -1) { taosArrayRemove(chArray, index); @@ -2484,17 +2507,18 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { printDataBlock(pBlock, IS_FINAL_OP(pInfo) ? "interval Final recv" : "interval Semi recv"); maxTs = TMAX(maxTs, pBlock->info.window.ekey); - if (pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_PUSH_DATA || pBlock->info.type == STREAM_INVALID) { + if (pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_PULL_DATA || + pBlock->info.type == STREAM_INVALID) { pInfo->binfo.pRes->info.type = pBlock->info.type; } else if (pBlock->info.type == STREAM_CLEAR) { SArray* pUpWins = taosArrayInit(8, sizeof(STimeWindow)); doClearWindows(&pInfo->aggSup, pSup, &pInfo->interval, pInfo->primaryTsIndex, pOperator->exprSupp.numOfExprs, pBlock, pUpWins); if (IS_FINAL_OP(pInfo)) { - int32_t childIndex = getChildIndex(pBlock); - SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex); + int32_t childIndex = getChildIndex(pBlock); + SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex); SStreamFinalIntervalOperatorInfo* pChildInfo = pChildOp->info; - SExprSupp* pChildSup = &pChildOp->exprSupp; + SExprSupp* pChildSup = &pChildOp->exprSupp; doClearWindows(&pChildInfo->aggSup, pChildSup, &pChildInfo->interval, pChildInfo->primaryTsIndex, pChildSup->numOfExprs, pBlock, NULL); @@ -2513,16 +2537,15 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { continue; } else if (pBlock->info.type == STREAM_RETRIEVE && !IS_FINAL_OP(pInfo)) { SArray* pUpWins = taosArrayInit(8, sizeof(STimeWindow)); - doClearWindows(&pInfo->aggSup, pSup, &pInfo->interval, 0, pOperator->exprSupp.numOfExprs, - pBlock, pUpWins); + doClearWindows(&pInfo->aggSup, pSup, &pInfo->interval, 0, pOperator->exprSupp.numOfExprs, pBlock, pUpWins); removeResults(pUpWins, pUpdated); taosArrayDestroy(pUpWins); if (taosArrayGetSize(pUpdated) > 0) { break; } continue; - } else if (pBlock->info.type == STREAM_PUSH_EMPTY && IS_FINAL_OP(pInfo)) { - processPushEmpty(pBlock, pInfo->pPullDataMap); + } else if (pBlock->info.type == STREAM_PULL_OVER && IS_FINAL_OP(pInfo)) { + processPullOver(pBlock, pInfo->pPullDataMap); continue; } @@ -2552,8 +2575,8 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs); if (IS_FINAL_OP(pInfo)) { - closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, - &pInfo->interval, pInfo->pPullDataMap, pUpdated); + closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, pInfo->pPullDataMap, + pUpdated); closeChildIntervalWindow(pInfo->pChildren, pInfo->twAggSup.maxTs); } @@ -2684,6 +2707,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); pInfo->pPullDataMap = taosHashInit(64, hashFn, false, HASH_NO_LOCK); pInfo->pPullDataRes = createPullDataBlock(); + pInfo->ignoreCloseWindow = false; pOperator->operatorType = pPhyNode->type; pOperator->blocking = true; @@ -2830,6 +2854,7 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh pInfo->pChildren = NULL; pInfo->isFinal = false; pInfo->pPhyNode = pPhyNode; + pInfo->ignoreCloseWindow = false; pOperator->name = "StreamSessionWindowAggOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION; @@ -3007,6 +3032,9 @@ static int32_t doOneWindowAggImpl(int32_t tsColId, SOptrBasicInfo* pBinfo, SStre updateTimeWindowInfo(pTimeWindowData, &pCurWin->win, false); doApplyFunctions(pTaskInfo, pSup->pCtx, &pCurWin->win, pTimeWindowData, startIndex, winRows, tsCols, pSDataBlock->info.rows, numOutput, TSDB_ORDER_ASC); + SFilePage* bufPage = getBufPage(pAggSup->pResultBuf, pCurWin->pos.pageId); + setBufPageDirty(bufPage, true); + releaseBufPage(pAggSup->pResultBuf, bufPage); return TSDB_CODE_SUCCESS; } @@ -3063,7 +3091,13 @@ void compactTimeWindow(SStreamSessionAggOperatorInfo* pInfo, int32_t startIndex, pWinInfo->isOutput = false; } taosArrayRemove(pInfo->streamAggSup.pCurWins, i); + SFilePage* tmpPage = getBufPage(pInfo->streamAggSup.pResultBuf, pWinInfo->pos.pageId); + releaseBufPage(pInfo->streamAggSup.pResultBuf, tmpPage); } + SFilePage* bufPage = getBufPage(pInfo->streamAggSup.pResultBuf, pCurWin->pos.pageId); + ASSERT(num > 0); + setBufPageDirty(bufPage, true); + releaseBufPage(pInfo->streamAggSup.pResultBuf, bufPage); } static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBlock, SHashObj* pStUpdated, @@ -3083,22 +3117,23 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData SResultRow* pResult = NULL; int32_t winRows = 0; - if (pSDataBlock->pDataBlock != NULL) { - SColumnInfoData* pStartTsCol = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); - startTsCols = (int64_t*)pStartTsCol->pData; - SColumnInfoData* pEndTsCol = NULL; - if (hasEndTs) { - pEndTsCol = taosArrayGet(pSDataBlock->pDataBlock, pInfo->endTsIndex); - } else { - pEndTsCol = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); - } - endTsCols = (int64_t*)pEndTsCol->pData; + ASSERT(pSDataBlock->pDataBlock); + SColumnInfoData* pStartTsCol = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); + startTsCols = (int64_t*)pStartTsCol->pData; + SColumnInfoData* pEndTsCol = NULL; + if (hasEndTs) { + pEndTsCol = taosArrayGet(pSDataBlock->pDataBlock, pInfo->endTsIndex); } else { - return; + pEndTsCol = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); } + endTsCols = (int64_t*)pEndTsCol->pData; SStreamAggSupporter* pAggSup = &pInfo->streamAggSup; for (int32_t i = 0; i < pSDataBlock->info.rows;) { + if (pInfo->ignoreCloseWindow && isOverdue(endTsCols[i], &pInfo->twAggSup)) { + i++; + continue; + } int32_t winIndex = 0; SResultWindowInfo* pCurWin = getSessionTimeWindow(pAggSup, startTsCols[i], endTsCols[i], groupId, gap, &winIndex); winRows = @@ -3205,17 +3240,24 @@ static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWin index = 0; } for (int32_t k = index; k < chWinSize; k++) { - SResultWindowInfo* pcw = taosArrayGet(pChWins, k); - if (pParentWin->win.skey <= pcw->win.skey && pcw->win.ekey <= pParentWin->win.ekey) { + SResultWindowInfo* pChWin = taosArrayGet(pChWins, k); + if (pParentWin->win.skey <= pChWin->win.skey && pChWin->win.ekey <= pParentWin->win.ekey) { SResultRow* pChResult = NULL; - setWindowOutputBuf(pcw, &pChResult, pChild->exprSupp.pCtx, groupId, numOfOutput, + setWindowOutputBuf(pChWin, &pChResult, pChild->exprSupp.pCtx, groupId, numOfOutput, pChild->exprSupp.rowEntryInfoOffset, &pChInfo->streamAggSup, pTaskInfo); compactFunctions(pSup->pCtx, pChild->exprSupp.pCtx, numOfOutput, pTaskInfo); + SFilePage* bufPage = getBufPage(pInfo->streamAggSup.pResultBuf, pChWin->pos.pageId); + setBufPageDirty(bufPage, true); + releaseBufPage(pInfo->streamAggSup.pResultBuf, bufPage); continue; } break; } } + SFilePage* bufPage = getBufPage(pInfo->streamAggSup.pResultBuf, pParentWin->pos.pageId); + ASSERT(size > 0); + setBufPageDirty(bufPage, true); + releaseBufPage(pInfo->streamAggSup.pResultBuf, bufPage); } } @@ -3234,7 +3276,7 @@ int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArra for (int32_t i = 0; i < size; i++) { void* pWin = taosArrayGet(pWins, i); SResultWindowInfo* pSeWin = fn(pWin); - if (pSeWin->win.ekey < pTwSup->maxTs - pTwSup->waterMark) { + if (isCloseWindow(&pSeWin->win, pTwSup)) { if (!pSeWin->isClosed) { pSeWin->isClosed = true; if (pTwSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) { @@ -3277,14 +3319,14 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { } else if (pOperator->status == OP_RES_TO_RETURN) { doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator); if (pInfo->pDelRes->info.rows > 0) { - printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo)? "Final Session" : "Single Session"); + printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "Final Session" : "Single Session"); return pInfo->pDelRes; } doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf); if (pBInfo->pRes->info.rows == 0 || !hasDataInGroupInfo(&pInfo->groupResInfo)) { doSetOperatorCompleted(pOperator); } - printDataBlock(pBInfo->pRes, IS_FINAL_OP(pInfo)? "Final Session" : "Single Session"); + printDataBlock(pBInfo->pRes, IS_FINAL_OP(pInfo) ? "Final Session" : "Single Session"); return pBInfo->pRes->info.rows == 0 ? NULL : pBInfo->pRes; } @@ -3352,11 +3394,11 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity); doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator); if (pInfo->pDelRes->info.rows > 0) { - printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo)? "Final Session" : "Single Session"); + printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "Final Session" : "Single Session"); return pInfo->pDelRes; } doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf); - printDataBlock(pBInfo->pRes, IS_FINAL_OP(pInfo)? "Final Session" : "Single Session"); + printDataBlock(pBInfo->pRes, IS_FINAL_OP(pInfo) ? "Final Session" : "Single Session"); return pBInfo->pRes->info.rows == 0 ? NULL : pBInfo->pRes; } @@ -3745,6 +3787,10 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl SStreamAggSupporter* pAggSup = &pInfo->streamAggSup; SColumnInfoData* pKeyColInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->stateCol.slotId); for (int32_t i = 0; i < pSDataBlock->info.rows; i += winRows) { + if (pInfo->ignoreCloseWindow && isOverdue(tsCols[i], &pInfo->twAggSup)) { + i++; + continue; + } char* pKeyData = colDataGetData(pKeyColInfo, i); int32_t winIndex = 0; bool allEqual = true; @@ -3895,6 +3941,7 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys pInfo->pDelRes->info.type = STREAM_DELETE; blockDataEnsureCapacity(pInfo->pDelRes, 64); pInfo->pChildren = NULL; + pInfo->ignoreCloseWindow = false; pOperator->name = "StreamStateAggOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE; @@ -4150,16 +4197,16 @@ _error: // merge interval operator typedef struct SMergeIntervalAggOperatorInfo { SIntervalAggOperatorInfo intervalAggOperatorInfo; - SList* groupIntervals; - SListIter groupIntervalsIter; - bool hasGroupId; - uint64_t groupId; - SSDataBlock* prefetchedBlock; - bool inputBlocksFinished; + SList* groupIntervals; + SListIter groupIntervalsIter; + bool hasGroupId; + uint64_t groupId; + SSDataBlock* prefetchedBlock; + bool inputBlocksFinished; } SMergeIntervalAggOperatorInfo; typedef struct SGroupTimeWindow { - uint64_t groupId; + uint64_t groupId; STimeWindow window; } SGroupTimeWindow; @@ -4169,7 +4216,8 @@ void destroyMergeIntervalOperatorInfo(void* param, int32_t numOfOutput) { destroyIntervalOperatorInfo(&miaInfo->intervalAggOperatorInfo, numOfOutput); } -static int32_t finalizeWindowResult(SOperatorInfo* pOperatorInfo, uint64_t tableGroupId, STimeWindow* win, SSDataBlock* pResultBlock) { +static int32_t finalizeWindowResult(SOperatorInfo* pOperatorInfo, uint64_t tableGroupId, STimeWindow* win, + SSDataBlock* pResultBlock) { SMergeIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info; SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; @@ -4202,7 +4250,7 @@ static int32_t outputPrevIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t t SListNode* listNode = NULL; while ((listNode = tdListNext(&iter)) != NULL) { SGroupTimeWindow* prevGrpWin = (SGroupTimeWindow*)listNode->data; - if (prevGrpWin->groupId != tableGroupId ) { + if (prevGrpWin->groupId != tableGroupId) { continue; } STimeWindow* prevWin = &prevGrpWin->window; @@ -4445,4 +4493,4 @@ _error: taosMemoryFreeClear(pOperator); pTaskInfo->code = code; return NULL; -} \ No newline at end of file +} diff --git a/source/libs/function/inc/functionMgtInt.h b/source/libs/function/inc/functionMgtInt.h index 44e1e6f7b1..e1aca7ce00 100644 --- a/source/libs/function/inc/functionMgtInt.h +++ b/source/libs/function/inc/functionMgtInt.h @@ -46,6 +46,7 @@ extern "C" { #define FUNC_MGT_FORBID_STREAM_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(17) #define FUNC_MGT_FORBID_WINDOW_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(18) #define FUNC_MGT_FORBID_GROUP_BY_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(19) +#define FUNC_MGT_SYSTEM_INFO_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(20) #define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index fbebb12cc3..23d7185508 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -39,6 +39,20 @@ static int32_t invaildFuncParaValueErrMsg(char* pErrBuf, int32_t len, const char return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_PARA_VALUE, "Invalid parameter value : %s", pFuncName); } +void static addDbPrecisonParam(SNodeList** pList, uint8_t precision) { + SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); + pVal->literal = NULL; + pVal->isDuration = false; + pVal->translate = true; + pVal->node.resType.type = TSDB_DATA_TYPE_TINYINT; + pVal->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_TINYINT].bytes; + pVal->node.resType.precision = precision; + pVal->datum.i = (int64_t)precision; + pVal->typeData = (int64_t)precision; + + nodesListMakeAppend(pList, (SNode*)pVal); +} + // There is only one parameter of numeric type, and the return type is parameter type static int32_t translateInOutNum(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { if (1 != LIST_LENGTH(pFunc->pParameterList)) { @@ -220,8 +234,20 @@ static int32_t translateWduration(SFunctionNode* pFunc, char* pErrBuf, int32_t l return TSDB_CODE_SUCCESS; } +static int32_t translateNowToday(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + // pseudo column do not need to check parameters + + //add database precision as param + uint8_t dbPrec = pFunc->node.resType.precision; + addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + + pFunc->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_TIMESTAMP}; + return TSDB_CODE_SUCCESS; +} + static int32_t translateTimePseudoColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { // pseudo column do not need to check parameters + pFunc->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_TIMESTAMP}; return TSDB_CODE_SUCCESS; } @@ -1446,6 +1472,10 @@ static int32_t translateToUnixtimestamp(SFunctionNode* pFunc, char* pErrBuf, int return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } + //add database precision as param + uint8_t dbPrec = pFunc->node.resType.precision; + addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT}; return TSDB_CODE_SUCCESS; } @@ -1462,6 +1492,10 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_ return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } + //add database precision as param + uint8_t dbPrec = pFunc->node.resType.precision; + addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP}; return TSDB_CODE_SUCCESS; @@ -1486,6 +1520,10 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le } } + //add database precision as param + uint8_t dbPrec = pFunc->node.resType.precision; + addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT}; return TSDB_CODE_SUCCESS; } @@ -1539,6 +1577,36 @@ static int32_t translateGroupKey(SFunctionNode* pFunc, char* pErrBuf, int32_t le return TSDB_CODE_SUCCESS; } +static int32_t translateDatabaseFunc(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + pFunc->node.resType = (SDataType){.bytes = TSDB_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateClientVersionFunc(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + pFunc->node.resType = (SDataType){.bytes = TSDB_VERSION_LEN, .type = TSDB_DATA_TYPE_VARCHAR}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateServerVersionFunc(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + pFunc->node.resType = (SDataType){.bytes = TSDB_VERSION_LEN, .type = TSDB_DATA_TYPE_VARCHAR}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateServerStatusFunc(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes, .type = TSDB_DATA_TYPE_INT}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateCurrentUserFunc(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + pFunc->node.resType = (SDataType){.bytes = TSDB_USER_LEN, .type = TSDB_DATA_TYPE_VARCHAR}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateUserFunc(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + pFunc->node.resType = (SDataType){.bytes = TSDB_USER_LEN, .type = TSDB_DATA_TYPE_VARCHAR}; + return TSDB_CODE_SUCCESS; +} + // clang-format off const SBuiltinFuncDefinition funcMgtBuiltins[] = { { @@ -1640,7 +1708,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "leastsquares", .type = FUNCTION_TYPE_LEASTSQUARES, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateLeastSQR, .getEnvFunc = getLeastSQRFuncEnv, .initFunc = leastSQRFunctionSetup, @@ -1882,6 +1950,19 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "last_row", .type = FUNCTION_TYPE_LAST_ROW, .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .translateFunc = translateFirstLast, + .getEnvFunc = getFirstLastFuncEnv, + .initFunc = functionSetup, + .processFunc = lastFunction, + .finalizeFunc = firstLastFinalize, + .pPartialFunc = "_last_partial", + .pMergeFunc = "_last_merge", + .combineFunc = lastCombine, + }, + { + .name = "_cache_last_row", + .type = FUNCTION_TYPE_CACHE_LAST_ROW, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, .translateFunc = translateLastRow, .getEnvFunc = getMinmaxFuncEnv, .initFunc = minmaxFunctionSetup, @@ -1904,7 +1985,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_first_partial", .type = FUNCTION_TYPE_FIRST_PARTIAL, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, .translateFunc = translateFirstLastPartial, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, @@ -1915,7 +1996,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_first_merge", .type = FUNCTION_TYPE_FIRST_MERGE, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, .translateFunc = translateFirstLastMerge, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, @@ -1939,7 +2020,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_last_partial", .type = FUNCTION_TYPE_LAST_PARTIAL, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, .translateFunc = translateFirstLastPartial, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, @@ -1950,7 +2031,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_last_merge", .type = FUNCTION_TYPE_LAST_MERGE, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, .translateFunc = translateFirstLastMerge, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, @@ -2410,7 +2491,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "now", .type = FUNCTION_TYPE_NOW, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC, - .translateFunc = translateTimePseudoColumn, + .translateFunc = translateNowToday, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = nowFunction, @@ -2420,7 +2501,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "today", .type = FUNCTION_TYPE_TODAY, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC, - .translateFunc = translateTimePseudoColumn, + .translateFunc = translateNowToday, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = todayFunction, @@ -2546,6 +2627,42 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .pPartialFunc = "_group_key", .pMergeFunc = "_group_key" }, + { + .name = "database", + .type = FUNCTION_TYPE_DATABASE, + .classification = FUNC_MGT_SYSTEM_INFO_FUNC | FUNC_MGT_SCALAR_FUNC, + .translateFunc = translateDatabaseFunc, + }, + { + .name = "client_version", + .type = FUNCTION_TYPE_CLIENT_VERSION, + .classification = FUNC_MGT_SYSTEM_INFO_FUNC | FUNC_MGT_SCALAR_FUNC, + .translateFunc = translateClientVersionFunc, + }, + { + .name = "server_version", + .type = FUNCTION_TYPE_SERVER_VERSION, + .classification = FUNC_MGT_SYSTEM_INFO_FUNC | FUNC_MGT_SCALAR_FUNC, + .translateFunc = translateServerVersionFunc, + }, + { + .name = "server_status", + .type = FUNCTION_TYPE_SERVER_STATUS, + .classification = FUNC_MGT_SYSTEM_INFO_FUNC | FUNC_MGT_SCALAR_FUNC, + .translateFunc = translateServerStatusFunc, + }, + { + .name = "current_user", + .type = FUNCTION_TYPE_CURRENT_USER, + .classification = FUNC_MGT_SYSTEM_INFO_FUNC | FUNC_MGT_SCALAR_FUNC, + .translateFunc = translateCurrentUserFunc, + }, + { + .name = "user", + .type = FUNCTION_TYPE_USER, + .classification = FUNC_MGT_SYSTEM_INFO_FUNC | FUNC_MGT_SCALAR_FUNC, + .translateFunc = translateUserFunc, + }, }; // clang-format on diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 06f24f39e7..a75d5a2ecb 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -2409,11 +2409,11 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) return TSDB_CODE_SUCCESS; } -int32_t getFirstLastInfoSize(int32_t resBytes) { return sizeof(SFirstLastRes) + resBytes + sizeof(int64_t); } +int32_t getFirstLastInfoSize(int32_t resBytes) { return sizeof(SFirstLastRes) + resBytes + sizeof(int64_t) + sizeof(STuplePos); } bool getFirstLastFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { SColumnNode* pNode = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0); - pEnv->calcMemSize = sizeof(SFirstLastRes) + pNode->node.resType.bytes + sizeof(int64_t); + pEnv->calcMemSize = getFirstLastInfoSize(pNode->node.resType.bytes); return true; } @@ -2491,9 +2491,17 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { } memcpy(pInfo->buf, data, bytes); *(TSKEY*)(pInfo->buf + bytes) = cts; + //handle selectivity + if (pCtx->subsidiaries.num > 0) { + STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY)); + if (!pInfo->hasResult) { + saveTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); + } else { + copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); + } + } pInfo->hasResult = true; - // DO_UPDATE_TAG_COLUMNS(pCtx, ts); - + //DO_UPDATE_TAG_COLUMNS(pCtx, ts); pResInfo->numOfRes = 1; break; } @@ -2525,8 +2533,17 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { } memcpy(pInfo->buf, data, bytes); *(TSKEY*)(pInfo->buf + bytes) = cts; + //handle selectivity + if (pCtx->subsidiaries.num > 0) { + STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY)); + if (!pInfo->hasResult) { + saveTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); + } else { + copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); + } + } pInfo->hasResult = true; - // DO_UPDATE_TAG_COLUMNS(pCtx, ts); + //DO_UPDATE_TAG_COLUMNS(pCtx, ts); pResInfo->numOfRes = 1; break; } @@ -2580,8 +2597,17 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { } memcpy(pInfo->buf, data, bytes); *(TSKEY*)(pInfo->buf + bytes) = cts; - // DO_UPDATE_TAG_COLUMNS(pCtx, ts); + //handle selectivity + if (pCtx->subsidiaries.num > 0) { + STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY)); + if (!pInfo->hasResult) { + saveTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); + } else { + copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); + } + } pInfo->hasResult = true; + //DO_UPDATE_TAG_COLUMNS(pCtx, ts); pResInfo->numOfRes = 1; } break; @@ -2603,9 +2629,18 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { } memcpy(pInfo->buf, data, bytes); *(TSKEY*)(pInfo->buf + bytes) = cts; + //handle selectivity + if (pCtx->subsidiaries.num > 0) { + STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY)); + if (!pInfo->hasResult) { + saveTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); + } else { + copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); + } + } pInfo->hasResult = true; pResInfo->numOfRes = 1; - // DO_UPDATE_TAG_COLUMNS(pCtx, ts); + //DO_UPDATE_TAG_COLUMNS(pCtx, ts); } break; } @@ -2615,7 +2650,10 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { return TSDB_CODE_SUCCESS; } -static void firstLastTransferInfo(SFirstLastRes* pInput, SFirstLastRes* pOutput, bool isFirst) { +static void firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, SFirstLastRes* pOutput, bool isFirst) { + SInputColumnInfoData* pColInfo = &pCtx->input; + int32_t start = pColInfo->startRowIndex; + pOutput->bytes = pInput->bytes; TSKEY* tsIn = (TSKEY*)(pInput->buf + pInput->bytes); TSKEY* tsOut = (TSKEY*)(pOutput->buf + pInput->bytes); @@ -2632,7 +2670,17 @@ static void firstLastTransferInfo(SFirstLastRes* pInput, SFirstLastRes* pOutput, } *tsOut = *tsIn; memcpy(pOutput->buf, pInput->buf, pOutput->bytes); + //handle selectivity + STuplePos* pTuplePos = (STuplePos*)(pOutput->buf + pOutput->bytes + sizeof(TSKEY)); + if (pCtx->subsidiaries.num > 0) { + if (!pOutput->hasResult) { + saveTupleData(pCtx, start, pCtx->pSrcBlock, pTuplePos); + } else { + copyTupleData(pCtx, start, pCtx->pSrcBlock, pTuplePos); + } + } pOutput->hasResult = true; + return; } @@ -2647,7 +2695,7 @@ static int32_t firstLastFunctionMergeImpl(SqlFunctionCtx* pCtx, bool isFirstQuer char* data = colDataGetData(pCol, start); SFirstLastRes* pInputInfo = (SFirstLastRes*)varDataVal(data); - firstLastTransferInfo(pInputInfo, pInfo, isFirstQuery); + firstLastTransferInfo(pCtx, pInputInfo, pInfo, isFirstQuery); int32_t numOfElems = pInputInfo->hasResult ? 1 : 0; @@ -2669,6 +2717,9 @@ int32_t firstLastFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SFirstLastRes* pRes = GET_ROWCELL_INTERBUF(pResInfo); colDataAppend(pCol, pBlock->info.rows, pRes->buf, pResInfo->isNullRes); + //handle selectivity + STuplePos* pTuplePos = (STuplePos*)(pRes->buf + pRes->bytes + sizeof(TSKEY)); + setSelectivityValue(pCtx, pBlock, pTuplePos, pBlock->info.rows); return pResInfo->numOfRes; } @@ -2687,6 +2738,9 @@ int32_t firstLastPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); colDataAppend(pCol, pBlock->info.rows, res, false); + //handle selectivity + STuplePos* pTuplePos = (STuplePos*)(pRes->buf + pRes->bytes + sizeof(TSKEY)); + setSelectivityValue(pCtx, pBlock, pTuplePos, pBlock->info.rows); taosMemoryFree(res); return 1; @@ -3043,7 +3097,9 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData pItem->uid = uid; // save the data of this tuple - saveTupleData(pCtx, rowIndex, pSrcBlock, &pItem->tuplePos); + if (pCtx->subsidiaries.num > 0) { + saveTupleData(pCtx, rowIndex, pSrcBlock, &pItem->tuplePos); + } // allocate the buffer and keep the data of this row into the new allocated buffer pEntryInfo->numOfRes++; @@ -3062,7 +3118,10 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData pItem->uid = uid; // save the data of this tuple by over writing the old data - copyTupleData(pCtx, rowIndex, pSrcBlock, &pItem->tuplePos); + if (pCtx->subsidiaries.num > 0) { + copyTupleData(pCtx, rowIndex, pSrcBlock, &pItem->tuplePos); + } + taosheapadjust((void*)pItems, sizeof(STopBotResItem), 0, pEntryInfo->numOfRes - 1, (const void*)&type, topBotResComparFn, NULL, !isTopQuery); } @@ -4224,7 +4283,7 @@ int32_t stateDurationFunction(SqlFunctionCtx* pCtx) { SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput; // TODO: process timeUnit for different db precisions - int32_t timeUnit = 1000; + int32_t timeUnit = 1; if (pCtx->numOfParams == 5) { // TODO: param number incorrect timeUnit = pCtx->param[3].param.i; } @@ -5466,7 +5525,7 @@ int32_t groupKeyFunction(SqlFunctionCtx* pCtx) { int32_t startIndex = pInput->startRowIndex; - //escape rest of data blocks to avoid first entry be overwritten. + //escape rest of data blocks to avoid first entry to be overwritten. if (pInfo->hasResult) { goto _group_key_over; } diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index 5fcf5e239c..52edf83232 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -179,6 +179,8 @@ bool fmIsForbidWindowFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId bool fmIsForbidGroupByFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_FORBID_GROUP_BY_FUNC); } +bool fmIsSystemInfoFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_SYSTEM_INFO_FUNC); } + bool fmIsInterpFunc(int32_t funcId) { if (funcId < 0 || funcId >= funcMgtBuiltinsNum) { return false; diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index a27d0e9164..cb43bfef0e 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -685,6 +685,12 @@ literal_func(A) ::= NOW(B). noarg_func(A) ::= NOW(B). { A = B; } noarg_func(A) ::= TODAY(B). { A = B; } noarg_func(A) ::= TIMEZONE(B). { A = B; } +noarg_func(A) ::= DATABASE(B). { A = B; } +noarg_func(A) ::= CLIENT_VERSION(B). { A = B; } +noarg_func(A) ::= SERVER_VERSION(B). { A = B; } +noarg_func(A) ::= SERVER_STATUS(B). { A = B; } +noarg_func(A) ::= CURRENT_USER(B). { A = B; } +noarg_func(A) ::= USER(B). { A = B; } %type star_func { SToken } %destructor star_func { } diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 7cd8398f86..044ec90a7f 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -67,6 +67,13 @@ typedef struct SInsertParseContext { SParseMetaCache* pMetaCache; } SInsertParseContext; +typedef struct SInsertParseSyntaxCxt { + SParseContext* pComCxt; + char* pSql; + SMsgBuf msg; + SParseMetaCache* pMetaCache; +} SInsertParseSyntaxCxt; + typedef int32_t (*_row_append_fn_t)(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param); static uint8_t TRUE_VALUE = (uint8_t)TSDB_TRUE; @@ -1098,11 +1105,24 @@ static int32_t storeTableMeta(SInsertParseContext* pCxt, SHashObj* pHash, SName* return taosHashPut(pHash, pName, len, &pBackup, POINTER_BYTES); } +static int32_t skipUsingClause(SInsertParseSyntaxCxt* pCxt); + +// pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...) +static int32_t ignoreAutoCreateTableClause(SInsertParseContext* pCxt) { + SToken sToken; + NEXT_TOKEN(pCxt->pSql, sToken); + SInsertParseSyntaxCxt cxt = {.pComCxt = pCxt->pComCxt, .pSql = pCxt->pSql, .msg = pCxt->msg, .pMetaCache = NULL}; + int32_t code = skipUsingClause(&cxt); + pCxt->pSql = cxt.pSql; + return code; +} + // pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...) static int32_t parseUsingClause(SInsertParseContext* pCxt, SName* name, char* tbFName) { int32_t len = strlen(tbFName); STableMeta** pMeta = taosHashGet(pCxt->pSubTableHashObj, tbFName, len); if (NULL != pMeta) { + CHECK_CODE(ignoreAutoCreateTableClause(pCxt)); return cloneTableMeta(*pMeta, &pCxt->pTableMeta); } @@ -1522,13 +1542,6 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery, SParseMetaCache return code; } -typedef struct SInsertParseSyntaxCxt { - SParseContext* pComCxt; - char* pSql; - SMsgBuf msg; - SParseMetaCache* pMetaCache; -} SInsertParseSyntaxCxt; - static int32_t skipParentheses(SInsertParseSyntaxCxt* pCxt) { SToken sToken; int32_t expectRightParenthesis = 1; diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 6726bb7dfd..7f5d742dc7 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -29,213 +29,217 @@ typedef struct SKeyword { // clang-format off // keywords in sql string static SKeyword keywordTable[] = { - {"ACCOUNT", TK_ACCOUNT}, - {"ACCOUNTS", TK_ACCOUNTS}, - {"ADD", TK_ADD}, - {"AGGREGATE", TK_AGGREGATE}, - {"ALL", TK_ALL}, - {"ALTER", TK_ALTER}, - {"ANALYZE", TK_ANALYZE}, - {"AND", TK_AND}, - {"APPS", TK_APPS}, - {"AS", TK_AS}, - {"ASC", TK_ASC}, - {"AT_ONCE", TK_AT_ONCE}, - {"BALANCE", TK_BALANCE}, - {"BETWEEN", TK_BETWEEN}, - {"BINARY", TK_BINARY}, - {"BIGINT", TK_BIGINT}, - {"BNODE", TK_BNODE}, - {"BNODES", TK_BNODES}, - {"BOOL", TK_BOOL}, - {"BUFFER", TK_BUFFER}, - {"BUFSIZE", TK_BUFSIZE}, - {"BY", TK_BY}, - {"CACHE", TK_CACHE}, - {"CACHELAST", TK_CACHELAST}, - {"CAST", TK_CAST}, - {"CLUSTER", TK_CLUSTER}, - {"COLUMN", TK_COLUMN}, - {"COMMENT", TK_COMMENT}, - {"COMP", TK_COMP}, - {"COMPACT", TK_COMPACT}, - {"CONNS", TK_CONNS}, - {"CONNECTION", TK_CONNECTION}, - {"CONNECTIONS", TK_CONNECTIONS}, - {"CONSUMER", TK_CONSUMER}, - {"CONSUMERS", TK_CONSUMERS}, - {"COUNT", TK_COUNT}, - {"CREATE", TK_CREATE}, - {"CONTAINS", TK_CONTAINS}, - {"DATABASE", TK_DATABASE}, - {"DATABASES", TK_DATABASES}, - {"DBS", TK_DBS}, - {"DELETE", TK_DELETE}, - {"DESC", TK_DESC}, - {"DESCRIBE", TK_DESCRIBE}, - {"DISTINCT", TK_DISTINCT}, - {"DISTRIBUTED", TK_DISTRIBUTED}, - {"DNODE", TK_DNODE}, - {"DNODES", TK_DNODES}, - {"DOUBLE", TK_DOUBLE}, - {"DROP", TK_DROP}, - {"DURATION", TK_DURATION}, - {"ENABLE", TK_ENABLE}, - {"EXISTS", TK_EXISTS}, - {"EXPLAIN", TK_EXPLAIN}, - {"EVERY", TK_EVERY}, - {"FILL", TK_FILL}, - {"FIRST", TK_FIRST}, - {"FLOAT", TK_FLOAT}, - {"FROM", TK_FROM}, - {"FSYNC", TK_FSYNC}, - {"FUNCTION", TK_FUNCTION}, - {"FUNCTIONS", TK_FUNCTIONS}, - {"GRANT", TK_GRANT}, - {"GRANTS", TK_GRANTS}, - {"GROUP", TK_GROUP}, - {"HAVING", TK_HAVING}, - {"IF", TK_IF}, - {"IMPORT", TK_IMPORT}, - {"IN", TK_IN}, - {"INDEX", TK_INDEX}, - {"INDEXES", TK_INDEXES}, - {"INNER", TK_INNER}, - {"INT", TK_INT}, - {"INSERT", TK_INSERT}, - {"INTEGER", TK_INTEGER}, - {"INTERVAL", TK_INTERVAL}, - {"INTO", TK_INTO}, - {"IS", TK_IS}, - {"JOIN", TK_JOIN}, - {"JSON", TK_JSON}, - {"KEEP", TK_KEEP}, - {"KILL", TK_KILL}, - {"LAST", TK_LAST}, - {"LAST_ROW", TK_LAST_ROW}, - {"LICENCE", TK_LICENCE}, - {"LIKE", TK_LIKE}, - {"LIMIT", TK_LIMIT}, - {"LINEAR", TK_LINEAR}, - {"LOCAL", TK_LOCAL}, - {"MATCH", TK_MATCH}, - {"MAXROWS", TK_MAXROWS}, - {"MAX_DELAY", TK_MAX_DELAY}, - {"MERGE", TK_MERGE}, - {"META", TK_META}, - {"MINROWS", TK_MINROWS}, - {"MINUS", TK_MINUS}, - {"MNODE", TK_MNODE}, - {"MNODES", TK_MNODES}, - {"MODIFY", TK_MODIFY}, - {"MODULES", TK_MODULES}, - {"NCHAR", TK_NCHAR}, - {"NEXT", TK_NEXT}, - {"NMATCH", TK_NMATCH}, - {"NONE", TK_NONE}, - {"NOT", TK_NOT}, - {"NOW", TK_NOW}, - {"NULL", TK_NULL}, - {"NULLS", TK_NULLS}, - {"OFFSET", TK_OFFSET}, - {"ON", TK_ON}, - {"OR", TK_OR}, - {"ORDER", TK_ORDER}, - {"OUTPUTTYPE", TK_OUTPUTTYPE}, - {"PARTITION", TK_PARTITION}, - {"PASS", TK_PASS}, - {"PAGES", TK_PAGES}, - {"PAGESIZE", TK_PAGESIZE}, - {"PORT", TK_PORT}, - {"PPS", TK_PPS}, - {"PRECISION", TK_PRECISION}, - // {"PRIVILEGE", TK_PRIVILEGE}, - {"PREV", TK_PREV}, - {"QNODE", TK_QNODE}, - {"QNODES", TK_QNODES}, - {"QTIME", TK_QTIME}, - {"QUERIES", TK_QUERIES}, - {"QUERY", TK_QUERY}, - {"RANGE", TK_RANGE}, - {"RATIO", TK_RATIO}, - {"READ", TK_READ}, - {"REDISTRIBUTE", TK_REDISTRIBUTE}, - {"RENAME", TK_RENAME}, - {"REPLICA", TK_REPLICA}, - {"RESET", TK_RESET}, - {"RETENTIONS", TK_RETENTIONS}, - {"REVOKE", TK_REVOKE}, - {"ROLLUP", TK_ROLLUP}, - {"SCHEMALESS", TK_SCHEMALESS}, - {"SCORES", TK_SCORES}, - {"SELECT", TK_SELECT}, - {"SESSION", TK_SESSION}, - {"SET", TK_SET}, - {"SHOW", TK_SHOW}, - {"SINGLE_STABLE", TK_SINGLE_STABLE}, - {"SLIDING", TK_SLIDING}, - {"SLIMIT", TK_SLIMIT}, - {"SMA", TK_SMA}, - {"SMALLINT", TK_SMALLINT}, - {"SNODE", TK_SNODE}, - {"SNODES", TK_SNODES}, - {"SOFFSET", TK_SOFFSET}, - {"SPLIT", TK_SPLIT}, - {"STABLE", TK_STABLE}, - {"STABLES", TK_STABLES}, - {"STATE", TK_STATE}, - {"STATE_WINDOW", TK_STATE_WINDOW}, - {"STORAGE", TK_STORAGE}, - {"STREAM", TK_STREAM}, - {"STREAMS", TK_STREAMS}, - {"STRICT", TK_STRICT}, - {"SUBSCRIPTIONS", TK_SUBSCRIPTIONS}, - {"SYNCDB", TK_SYNCDB}, - {"SYSINFO", TK_SYSINFO}, - {"TABLE", TK_TABLE}, - {"TABLES", TK_TABLES}, - {"TAG", TK_TAG}, - {"TAGS", TK_TAGS}, - {"TBNAME", TK_TBNAME}, - {"TIMESTAMP", TK_TIMESTAMP}, - {"TIMEZONE", TK_TIMEZONE}, - {"TINYINT", TK_TINYINT}, - {"TO", TK_TO}, - {"TODAY", TK_TODAY}, - {"TOPIC", TK_TOPIC}, - {"TOPICS", TK_TOPICS}, - {"TRANSACTION", TK_TRANSACTION}, - {"TRANSACTIONS", TK_TRANSACTIONS}, - {"TRIGGER", TK_TRIGGER}, - {"TSERIES", TK_TSERIES}, - {"TTL", TK_TTL}, - {"UNION", TK_UNION}, - {"UNSIGNED", TK_UNSIGNED}, - {"USE", TK_USE}, - {"USER", TK_USER}, - {"USERS", TK_USERS}, - {"USING", TK_USING}, - {"VALUE", TK_VALUE}, - {"VALUES", TK_VALUES}, - {"VARCHAR", TK_VARCHAR}, - {"VARIABLES", TK_VARIABLES}, - {"VERBOSE", TK_VERBOSE}, - {"VGROUP", TK_VGROUP}, - {"VGROUPS", TK_VGROUPS}, - {"VNODES", TK_VNODES}, - {"WAL", TK_WAL}, - {"WATERMARK", TK_WATERMARK}, - {"WHERE", TK_WHERE}, - {"WINDOW_CLOSE", TK_WINDOW_CLOSE}, - {"WITH", TK_WITH}, - {"WRITE", TK_WRITE}, - {"_C0", TK_ROWTS}, - {"_QENDTS", TK_QENDTS}, - {"_QSTARTTS", TK_QSTARTTS}, - {"_ROWTS", TK_ROWTS}, - {"_WDURATION", TK_WDURATION}, - {"_WENDTS", TK_WENDTS}, - {"_WSTARTTS", TK_WSTARTTS}, + {"ACCOUNT", TK_ACCOUNT}, + {"ACCOUNTS", TK_ACCOUNTS}, + {"ADD", TK_ADD}, + {"AGGREGATE", TK_AGGREGATE}, + {"ALL", TK_ALL}, + {"ALTER", TK_ALTER}, + {"ANALYZE", TK_ANALYZE}, + {"AND", TK_AND}, + {"APPS", TK_APPS}, + {"AS", TK_AS}, + {"ASC", TK_ASC}, + {"AT_ONCE", TK_AT_ONCE}, + {"BALANCE", TK_BALANCE}, + {"BETWEEN", TK_BETWEEN}, + {"BINARY", TK_BINARY}, + {"BIGINT", TK_BIGINT}, + {"BNODE", TK_BNODE}, + {"BNODES", TK_BNODES}, + {"BOOL", TK_BOOL}, + {"BUFFER", TK_BUFFER}, + {"BUFSIZE", TK_BUFSIZE}, + {"BY", TK_BY}, + {"CACHE", TK_CACHE}, + {"CACHELAST", TK_CACHELAST}, + {"CAST", TK_CAST}, + {"CLIENT_VERSION", TK_CLIENT_VERSION}, + {"CLUSTER", TK_CLUSTER}, + {"COLUMN", TK_COLUMN}, + {"COMMENT", TK_COMMENT}, + {"COMP", TK_COMP}, + {"COMPACT", TK_COMPACT}, + {"CONNS", TK_CONNS}, + {"CONNECTION", TK_CONNECTION}, + {"CONNECTIONS", TK_CONNECTIONS}, + {"CONSUMER", TK_CONSUMER}, + {"CONSUMERS", TK_CONSUMERS}, + {"CONTAINS", TK_CONTAINS}, + {"COUNT", TK_COUNT}, + {"CREATE", TK_CREATE}, + {"CURRENT_USER", TK_CURRENT_USER}, + {"DATABASE", TK_DATABASE}, + {"DATABASES", TK_DATABASES}, + {"DBS", TK_DBS}, + {"DELETE", TK_DELETE}, + {"DESC", TK_DESC}, + {"DESCRIBE", TK_DESCRIBE}, + {"DISTINCT", TK_DISTINCT}, + {"DISTRIBUTED", TK_DISTRIBUTED}, + {"DNODE", TK_DNODE}, + {"DNODES", TK_DNODES}, + {"DOUBLE", TK_DOUBLE}, + {"DROP", TK_DROP}, + {"DURATION", TK_DURATION}, + {"ENABLE", TK_ENABLE}, + {"EXISTS", TK_EXISTS}, + {"EXPLAIN", TK_EXPLAIN}, + {"EVERY", TK_EVERY}, + {"FILL", TK_FILL}, + {"FIRST", TK_FIRST}, + {"FLOAT", TK_FLOAT}, + {"FROM", TK_FROM}, + {"FSYNC", TK_FSYNC}, + {"FUNCTION", TK_FUNCTION}, + {"FUNCTIONS", TK_FUNCTIONS}, + {"GRANT", TK_GRANT}, + {"GRANTS", TK_GRANTS}, + {"GROUP", TK_GROUP}, + {"HAVING", TK_HAVING}, + {"IF", TK_IF}, + {"IMPORT", TK_IMPORT}, + {"IN", TK_IN}, + {"INDEX", TK_INDEX}, + {"INDEXES", TK_INDEXES}, + {"INNER", TK_INNER}, + {"INT", TK_INT}, + {"INSERT", TK_INSERT}, + {"INTEGER", TK_INTEGER}, + {"INTERVAL", TK_INTERVAL}, + {"INTO", TK_INTO}, + {"IS", TK_IS}, + {"JOIN", TK_JOIN}, + {"JSON", TK_JSON}, + {"KEEP", TK_KEEP}, + {"KILL", TK_KILL}, + {"LAST", TK_LAST}, + {"LAST_ROW", TK_LAST_ROW}, + {"LICENCE", TK_LICENCE}, + {"LIKE", TK_LIKE}, + {"LIMIT", TK_LIMIT}, + {"LINEAR", TK_LINEAR}, + {"LOCAL", TK_LOCAL}, + {"MATCH", TK_MATCH}, + {"MAXROWS", TK_MAXROWS}, + {"MAX_DELAY", TK_MAX_DELAY}, + {"MERGE", TK_MERGE}, + {"META", TK_META}, + {"MINROWS", TK_MINROWS}, + {"MINUS", TK_MINUS}, + {"MNODE", TK_MNODE}, + {"MNODES", TK_MNODES}, + {"MODIFY", TK_MODIFY}, + {"MODULES", TK_MODULES}, + {"NCHAR", TK_NCHAR}, + {"NEXT", TK_NEXT}, + {"NMATCH", TK_NMATCH}, + {"NONE", TK_NONE}, + {"NOT", TK_NOT}, + {"NOW", TK_NOW}, + {"NULL", TK_NULL}, + {"NULLS", TK_NULLS}, + {"OFFSET", TK_OFFSET}, + {"ON", TK_ON}, + {"OR", TK_OR}, + {"ORDER", TK_ORDER}, + {"OUTPUTTYPE", TK_OUTPUTTYPE}, + {"PARTITION", TK_PARTITION}, + {"PASS", TK_PASS}, + {"PAGES", TK_PAGES}, + {"PAGESIZE", TK_PAGESIZE}, + {"PORT", TK_PORT}, + {"PPS", TK_PPS}, + {"PRECISION", TK_PRECISION}, + // {"PRIVILEGE", TK_PRIVILEGE}, + {"PREV", TK_PREV}, + {"QNODE", TK_QNODE}, + {"QNODES", TK_QNODES}, + {"QTIME", TK_QTIME}, + {"QUERIES", TK_QUERIES}, + {"QUERY", TK_QUERY}, + {"RANGE", TK_RANGE}, + {"RATIO", TK_RATIO}, + {"READ", TK_READ}, + {"REDISTRIBUTE", TK_REDISTRIBUTE}, + {"RENAME", TK_RENAME}, + {"REPLICA", TK_REPLICA}, + {"RESET", TK_RESET}, + {"RETENTIONS", TK_RETENTIONS}, + {"REVOKE", TK_REVOKE}, + {"ROLLUP", TK_ROLLUP}, + {"SCHEMALESS", TK_SCHEMALESS}, + {"SCORES", TK_SCORES}, + {"SELECT", TK_SELECT}, + {"SERVER_STATUS", TK_SERVER_STATUS}, + {"SERVER_VERSION", TK_SERVER_VERSION}, + {"SESSION", TK_SESSION}, + {"SET", TK_SET}, + {"SHOW", TK_SHOW}, + {"SINGLE_STABLE", TK_SINGLE_STABLE}, + {"SLIDING", TK_SLIDING}, + {"SLIMIT", TK_SLIMIT}, + {"SMA", TK_SMA}, + {"SMALLINT", TK_SMALLINT}, + {"SNODE", TK_SNODE}, + {"SNODES", TK_SNODES}, + {"SOFFSET", TK_SOFFSET}, + {"SPLIT", TK_SPLIT}, + {"STABLE", TK_STABLE}, + {"STABLES", TK_STABLES}, + {"STATE", TK_STATE}, + {"STATE_WINDOW", TK_STATE_WINDOW}, + {"STORAGE", TK_STORAGE}, + {"STREAM", TK_STREAM}, + {"STREAMS", TK_STREAMS}, + {"STRICT", TK_STRICT}, + {"SUBSCRIPTIONS", TK_SUBSCRIPTIONS}, + {"SYNCDB", TK_SYNCDB}, + {"SYSINFO", TK_SYSINFO}, + {"TABLE", TK_TABLE}, + {"TABLES", TK_TABLES}, + {"TAG", TK_TAG}, + {"TAGS", TK_TAGS}, + {"TBNAME", TK_TBNAME}, + {"TIMESTAMP", TK_TIMESTAMP}, + {"TIMEZONE", TK_TIMEZONE}, + {"TINYINT", TK_TINYINT}, + {"TO", TK_TO}, + {"TODAY", TK_TODAY}, + {"TOPIC", TK_TOPIC}, + {"TOPICS", TK_TOPICS}, + {"TRANSACTION", TK_TRANSACTION}, + {"TRANSACTIONS", TK_TRANSACTIONS}, + {"TRIGGER", TK_TRIGGER}, + {"TSERIES", TK_TSERIES}, + {"TTL", TK_TTL}, + {"UNION", TK_UNION}, + {"UNSIGNED", TK_UNSIGNED}, + {"USE", TK_USE}, + {"USER", TK_USER}, + {"USERS", TK_USERS}, + {"USING", TK_USING}, + {"VALUE", TK_VALUE}, + {"VALUES", TK_VALUES}, + {"VARCHAR", TK_VARCHAR}, + {"VARIABLES", TK_VARIABLES}, + {"VERBOSE", TK_VERBOSE}, + {"VGROUP", TK_VGROUP}, + {"VGROUPS", TK_VGROUPS}, + {"VNODES", TK_VNODES}, + {"WAL", TK_WAL}, + {"WATERMARK", TK_WATERMARK}, + {"WHERE", TK_WHERE}, + {"WINDOW_CLOSE", TK_WINDOW_CLOSE}, + {"WITH", TK_WITH}, + {"WRITE", TK_WRITE}, + {"_C0", TK_ROWTS}, + {"_QENDTS", TK_QENDTS}, + {"_QSTARTTS", TK_QSTARTTS}, + {"_ROWTS", TK_ROWTS}, + {"_WDURATION", TK_WDURATION}, + {"_WENDTS", TK_WENDTS}, + {"_WSTARTTS", TK_WSTARTTS}, // {"ID", TK_ID}, // {"STRING", TK_STRING}, // {"EQ", TK_EQ}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index e19825573b..97a0212ea2 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -35,8 +35,7 @@ typedef struct STranslateContext { SArray* pNsLevel; // element is SArray*, the element of this subarray is STableNode* int32_t currLevel; ESqlClause currClause; - SSelectStmt* pCurrSelectStmt; - SSetOperator* pCurrSetOperator; + SNode* pCurrStmt; SCmdMsgInfo* pCmdMsg; SHashObj* pDbs; SHashObj* pTables; @@ -397,6 +396,34 @@ static void destroyTranslateContext(STranslateContext* pCxt) { taosHashCleanup(pCxt->pTables); } +static bool isSelectStmt(SNode* pCurrStmt) { + return NULL != pCurrStmt && QUERY_NODE_SELECT_STMT == nodeType(pCurrStmt); +} + +static bool isSetOperator(SNode* pCurrStmt) { + return NULL != pCurrStmt && QUERY_NODE_SET_OPERATOR == nodeType(pCurrStmt); +} + +static SNodeList* getProjectListFromCurrStmt(SNode* pCurrStmt) { + if (isSelectStmt(pCurrStmt)) { + return ((SSelectStmt*)pCurrStmt)->pProjectionList; + } + if (isSetOperator(pCurrStmt)) { + return ((SSetOperator*)pCurrStmt)->pProjectionList; + } + return NULL; +} + +static uint8_t getPrecisionFromCurrStmt(SNode* pCurrStmt, uint8_t defaultVal) { + if (isSelectStmt(pCurrStmt)) { + return ((SSelectStmt*)pCurrStmt)->precision; + } + if (isSetOperator(pCurrStmt)) { + return ((SSetOperator*)pCurrStmt)->precision; + } + return defaultVal; +} + static bool isAliasColumn(const SNode* pNode) { return (QUERY_NODE_COLUMN == nodeType(pNode) && ('\0' == ((SColumnNode*)pNode)->tableAlias[0])); } @@ -426,7 +453,8 @@ static bool isVectorFunc(const SNode* pNode) { } static bool isDistinctOrderBy(STranslateContext* pCxt) { - return (SQL_CLAUSE_ORDER_BY == pCxt->currClause && pCxt->pCurrSelectStmt->isDistinct); + return (SQL_CLAUSE_ORDER_BY == pCxt->currClause && isSelectStmt(pCxt->pCurrStmt) && + ((SSelectStmt*)pCxt->pCurrStmt)->isDistinct); } static bool belongTable(const char* currentDb, const SColumnNode* pCol, const STableNode* pTable) { @@ -646,7 +674,7 @@ static EDealRes translateColumnWithoutPrefix(STranslateContext* pCxt, SColumnNod } if (!found) { if (isInternalPk) { - if (NULL != pCxt->pCurrSelectStmt && NULL != pCxt->pCurrSelectStmt->pWindow) { + if (isSelectStmt(pCxt->pCurrStmt) && NULL != ((SSelectStmt*)pCxt->pCurrStmt)->pWindow) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_NOT_ALLOWED_WIN_QUERY); } return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_INTERNAL_PK); @@ -657,18 +685,8 @@ static EDealRes translateColumnWithoutPrefix(STranslateContext* pCxt, SColumnNod return DEAL_RES_CONTINUE; } -static SNodeList* getProjectListFromCxt(STranslateContext* pCxt) { - if (NULL != pCxt->pCurrSelectStmt) { - return pCxt->pCurrSelectStmt->pProjectionList; - } else if (NULL != pCxt->pCurrSetOperator) { - return pCxt->pCurrSetOperator->pProjectionList; - } else { - return NULL; - } -} - static EDealRes translateColumnUseAlias(STranslateContext* pCxt, SColumnNode** pCol, bool* pFound) { - SNodeList* pProjectionList = getProjectListFromCxt(pCxt); + SNodeList* pProjectionList = getProjectListFromCurrStmt(pCxt->pCurrStmt); SNode* pNode; FOREACH(pNode, pProjectionList) { SExprNode* pExpr = (SExprNode*)pNode; @@ -690,7 +708,7 @@ static EDealRes translateColumnUseAlias(STranslateContext* pCxt, SColumnNode** p } static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) { - if (NULL != pCxt->pCurrSelectStmt && NULL == pCxt->pCurrSelectStmt->pFromTable) { + if (isSelectStmt(pCxt->pCurrStmt) && NULL == ((SSelectStmt*)pCxt->pCurrStmt)->pFromTable) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_COLUMN, (*pCol)->colName); } @@ -708,7 +726,7 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) { res = translateColumnUseAlias(pCxt, pCol, &found); } if (DEAL_RES_ERROR != res && !found) { - if (NULL != pCxt->pCurrSetOperator) { + if (isSetOperator(pCxt->pCurrStmt)) { res = generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_COLUMN, (*pCol)->colName); } else { res = translateColumnWithoutPrefix(pCxt, pCol); @@ -760,9 +778,9 @@ static int32_t parseBoolFromValueNode(STranslateContext* pCxt, SValueNode* pVal) } static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SDataType targetDt) { - uint8_t precision = (NULL != pCxt->pCurrSelectStmt ? pCxt->pCurrSelectStmt->precision : targetDt.precision); + uint8_t precision = getPrecisionFromCurrStmt(pCxt->pCurrStmt, targetDt.precision); pVal->node.resType.precision = precision; - if (pVal->placeholderNo > 0) { + if (pVal->placeholderNo > 0 || pVal->isNull) { return DEAL_RES_CONTINUE; } if (pVal->isDuration) { @@ -1102,6 +1120,8 @@ static bool hasInvalidFuncNesting(SNodeList* pParameterList) { } static int32_t getFuncInfo(STranslateContext* pCxt, SFunctionNode* pFunc) { + // the time precision of the function execution environment + pFunc->node.resType.precision = getPrecisionFromCurrStmt(pCxt->pCurrStmt, TSDB_TIME_PRECISION_MILLI); int32_t code = fmGetFuncInfo(pFunc, pCxt->msgBuf.buf, pCxt->msgBuf.len); if (TSDB_CODE_FUNC_NOT_BUILTIN_FUNTION == code) { code = getUdfInfo(pCxt, pFunc); @@ -1119,7 +1139,7 @@ static int32_t translateAggFunc(STranslateContext* pCxt, SFunctionNode* pFunc) { if (hasInvalidFuncNesting(pFunc->pParameterList)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_AGG_FUNC_NESTING); } - if (NULL != pCxt->pCurrSelectStmt && pCxt->pCurrSelectStmt->hasIndefiniteRowsFunc) { + if (isSelectStmt(pCxt->pCurrStmt) && ((SSelectStmt*)pCxt->pCurrStmt)->hasIndefiniteRowsFunc) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC); } @@ -1134,7 +1154,8 @@ static int32_t translateScanPseudoColumnFunc(STranslateContext* pCxt, SFunctionN return TSDB_CODE_SUCCESS; } if (0 == LIST_LENGTH(pFunc->pParameterList)) { - if (QUERY_NODE_REAL_TABLE != nodeType(pCxt->pCurrSelectStmt->pFromTable)) { + if (!isSelectStmt(pCxt->pCurrStmt) || + QUERY_NODE_REAL_TABLE != nodeType(((SSelectStmt*)pCxt->pCurrStmt)->pFromTable)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TBNAME); } } else { @@ -1152,8 +1173,8 @@ static int32_t translateIndefiniteRowsFunc(STranslateContext* pCxt, SFunctionNod if (!fmIsIndefiniteRowsFunc(pFunc->funcId)) { return TSDB_CODE_SUCCESS; } - if (SQL_CLAUSE_SELECT != pCxt->currClause || pCxt->pCurrSelectStmt->hasIndefiniteRowsFunc || - pCxt->pCurrSelectStmt->hasAggFuncs) { + if (!isSelectStmt(pCxt->pCurrStmt) || SQL_CLAUSE_SELECT != pCxt->currClause || + ((SSelectStmt*)pCxt->pCurrStmt)->hasIndefiniteRowsFunc || ((SSelectStmt*)pCxt->pCurrStmt)->hasAggFuncs) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC); } if (hasInvalidFuncNesting(pFunc->pParameterList)) { @@ -1162,13 +1183,20 @@ static int32_t translateIndefiniteRowsFunc(STranslateContext* pCxt, SFunctionNod return TSDB_CODE_SUCCESS; } +static bool hasFillClause(SNode* pCurrStmt) { + if (!isSelectStmt(pCurrStmt)) { + return false; + } + SSelectStmt* pSelect = (SSelectStmt*)pCurrStmt; + return NULL != pSelect->pWindow && QUERY_NODE_INTERVAL_WINDOW == nodeType(pSelect->pWindow) && + NULL != ((SIntervalWindowNode*)pSelect->pWindow)->pFill; +} + static int32_t translateForbidFillFunc(STranslateContext* pCxt, SFunctionNode* pFunc) { if (!fmIsForbidFillFunc(pFunc->funcId)) { return TSDB_CODE_SUCCESS; } - if (NULL != pCxt->pCurrSelectStmt->pWindow && - QUERY_NODE_INTERVAL_WINDOW == nodeType(pCxt->pCurrSelectStmt->pWindow) && - NULL != ((SIntervalWindowNode*)pCxt->pCurrSelectStmt->pWindow)->pFill) { + if (hasFillClause(pCxt->pCurrStmt)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC, pFunc->functionName); } return TSDB_CODE_SUCCESS; @@ -1178,7 +1206,7 @@ static int32_t translateWindowPseudoColumnFunc(STranslateContext* pCxt, SFunctio if (!fmIsWindowPseudoColumnFunc(pFunc->funcId)) { return TSDB_CODE_SUCCESS; } - if (NULL == pCxt->pCurrSelectStmt->pWindow) { + if (!isSelectStmt(pCxt->pCurrStmt) || NULL == ((SSelectStmt*)pCxt->pCurrStmt)->pWindow) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_WINDOW_PC); } return TSDB_CODE_SUCCESS; @@ -1188,7 +1216,7 @@ static int32_t translateForbidWindowFunc(STranslateContext* pCxt, SFunctionNode* if (!fmIsForbidWindowFunc(pFunc->funcId)) { return TSDB_CODE_SUCCESS; } - if (NULL != pCxt->pCurrSelectStmt->pWindow) { + if (isSelectStmt(pCxt->pCurrStmt) && NULL != ((SSelectStmt*)pCxt->pCurrStmt)->pWindow) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC, pFunc->functionName); } return TSDB_CODE_SUCCESS; @@ -1208,14 +1236,15 @@ static int32_t translateForbidGroupByFunc(STranslateContext* pCxt, SFunctionNode if (!fmIsForbidGroupByFunc(pFunc->funcId)) { return TSDB_CODE_SUCCESS; } - if (NULL != pCxt->pCurrSelectStmt->pGroupByList) { + if (isSelectStmt(pCxt->pCurrStmt) && NULL != ((SSelectStmt*)pCxt->pCurrStmt)->pGroupByList) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GROUP_BY_NOT_ALLOWED_FUNC, pFunc->functionName); } return TSDB_CODE_SUCCESS; } -static void setFuncClassification(SSelectStmt* pSelect, SFunctionNode* pFunc) { - if (NULL != pSelect) { +static void setFuncClassification(SNode* pCurrStmt, SFunctionNode* pFunc) { + if (NULL != pCurrStmt && QUERY_NODE_SELECT_STMT == nodeType(pCurrStmt)) { + SSelectStmt* pSelect = (SSelectStmt*)pCurrStmt; pSelect->hasAggFuncs = pSelect->hasAggFuncs ? true : fmIsAggFunc(pFunc->funcId); pSelect->hasRepeatScanFuncs = pSelect->hasRepeatScanFuncs ? true : fmIsRepeatScanFunc(pFunc->funcId); pSelect->hasIndefiniteRowsFunc = pSelect->hasIndefiniteRowsFunc ? true : fmIsIndefiniteRowsFunc(pFunc->funcId); @@ -1226,41 +1255,138 @@ static void setFuncClassification(SSelectStmt* pSelect, SFunctionNode* pFunc) { } } -static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc) { +static int32_t rewriteSystemInfoFuncImpl(STranslateContext* pCxt, char* pLiteral, SNode** pNode) { + SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); + if (NULL == pVal) { + return TSDB_CODE_OUT_OF_MEMORY; + } + strcpy(pVal->node.aliasName, ((SExprNode*)*pNode)->aliasName); + pVal->node.resType = ((SExprNode*)*pNode)->resType; + if (NULL == pLiteral) { + pVal->isNull = true; + } else { + pVal->literal = pLiteral; + } + if (DEAL_RES_ERROR != translateValue(pCxt, pVal)) { + *pNode = (SNode*)pVal; + } else { + nodesDestroyNode((SNode*)pVal); + } + return pCxt->errCode; +} + +static int32_t rewriteDatabaseFunc(STranslateContext* pCxt, SNode** pNode) { + char* pCurrDb = NULL; + if (NULL != pCxt->pParseCxt->db) { + pCurrDb = taosMemoryStrDup((void*)pCxt->pParseCxt->db); + if (NULL == pCurrDb) { + return TSDB_CODE_OUT_OF_MEMORY; + } + } + return rewriteSystemInfoFuncImpl(pCxt, pCurrDb, pNode); +} + +static int32_t rewriteClentVersionFunc(STranslateContext* pCxt, SNode** pNode) { + char* pVer = taosMemoryStrDup((void*)version); + if (NULL == pVer) { + return TSDB_CODE_OUT_OF_MEMORY; + } + return rewriteSystemInfoFuncImpl(pCxt, pVer, pNode); +} + +static int32_t rewriteServerVersionFunc(STranslateContext* pCxt, SNode** pNode) { + char* pVer = taosMemoryStrDup((void*)pCxt->pParseCxt->svrVer); + if (NULL == pVer) { + return TSDB_CODE_OUT_OF_MEMORY; + } + return rewriteSystemInfoFuncImpl(pCxt, pVer, pNode); +} + +static int32_t rewriteServerStatusFunc(STranslateContext* pCxt, SNode** pNode) { + if (pCxt->pParseCxt->nodeOffline) { + return TSDB_CODE_RPC_NETWORK_UNAVAIL; + } + char* pStatus = taosMemoryStrDup((void*)"1"); + return rewriteSystemInfoFuncImpl(pCxt, pStatus, pNode); +} + +static int32_t rewriteUserFunc(STranslateContext* pCxt, SNode** pNode) { + char userConn[TSDB_USER_LEN + 1 + TSDB_FQDN_LEN] = {0}; // format 'user@host' + int32_t len = snprintf(userConn, sizeof(userConn), "%s@", pCxt->pParseCxt->pUser); + taosGetFqdn(userConn + len); + char* pUserConn = taosMemoryStrDup((void*)userConn); + if (NULL == pUserConn) { + return TSDB_CODE_OUT_OF_MEMORY; + } + return rewriteSystemInfoFuncImpl(pCxt, pUserConn, pNode); +} + +static int32_t rewriteSystemInfoFunc(STranslateContext* pCxt, SNode** pNode) { + switch (((SFunctionNode*)*pNode)->funcType) { + case FUNCTION_TYPE_DATABASE: + return rewriteDatabaseFunc(pCxt, pNode); + case FUNCTION_TYPE_CLIENT_VERSION: + return rewriteClentVersionFunc(pCxt, pNode); + case FUNCTION_TYPE_SERVER_VERSION: + return rewriteServerVersionFunc(pCxt, pNode); + case FUNCTION_TYPE_SERVER_STATUS: + return rewriteServerStatusFunc(pCxt, pNode); + case FUNCTION_TYPE_CURRENT_USER: + case FUNCTION_TYPE_USER: + return rewriteUserFunc(pCxt, pNode); + default: + break; + } + return TSDB_CODE_PAR_INTERNAL_ERROR; +} + +static int32_t translateNoramlFunction(STranslateContext* pCxt, SFunctionNode* pFunc) { + int32_t code = translateAggFunc(pCxt, pFunc); + if (TSDB_CODE_SUCCESS == code) { + code = translateScanPseudoColumnFunc(pCxt, pFunc); + } + if (TSDB_CODE_SUCCESS == code) { + code = translateIndefiniteRowsFunc(pCxt, pFunc); + } + if (TSDB_CODE_SUCCESS == code) { + code = translateForbidFillFunc(pCxt, pFunc); + } + if (TSDB_CODE_SUCCESS == code) { + code = translateWindowPseudoColumnFunc(pCxt, pFunc); + } + if (TSDB_CODE_SUCCESS == code) { + code = translateForbidWindowFunc(pCxt, pFunc); + } + if (TSDB_CODE_SUCCESS == code) { + code = translateForbidStreamFunc(pCxt, pFunc); + } + if (TSDB_CODE_SUCCESS == code) { + code = translateForbidGroupByFunc(pCxt, pFunc); + } + if (TSDB_CODE_SUCCESS == code) { + setFuncClassification(pCxt->pCurrStmt, pFunc); + } + return code; +} + +static int32_t translateFunctionImpl(STranslateContext* pCxt, SFunctionNode** pFunc) { + if (fmIsSystemInfoFunc((*pFunc)->funcId)) { + return rewriteSystemInfoFunc(pCxt, (SNode**)pFunc); + } + return translateNoramlFunction(pCxt, *pFunc); +} + +static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode** pFunc) { SNode* pParam = NULL; - FOREACH(pParam, pFunc->pParameterList) { + FOREACH(pParam, (*pFunc)->pParameterList) { if (isMultiResFunc(pParam)) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)pParam)->aliasName); } } - pCxt->errCode = getFuncInfo(pCxt, pFunc); + pCxt->errCode = getFuncInfo(pCxt, *pFunc); if (TSDB_CODE_SUCCESS == pCxt->errCode) { - pCxt->errCode = translateAggFunc(pCxt, pFunc); - } - if (TSDB_CODE_SUCCESS == pCxt->errCode) { - pCxt->errCode = translateScanPseudoColumnFunc(pCxt, pFunc); - } - if (TSDB_CODE_SUCCESS == pCxt->errCode) { - pCxt->errCode = translateIndefiniteRowsFunc(pCxt, pFunc); - } - if (TSDB_CODE_SUCCESS == pCxt->errCode) { - pCxt->errCode = translateForbidFillFunc(pCxt, pFunc); - } - if (TSDB_CODE_SUCCESS == pCxt->errCode) { - pCxt->errCode = translateWindowPseudoColumnFunc(pCxt, pFunc); - } - if (TSDB_CODE_SUCCESS == pCxt->errCode) { - pCxt->errCode = translateForbidWindowFunc(pCxt, pFunc); - } - if (TSDB_CODE_SUCCESS == pCxt->errCode) { - pCxt->errCode = translateForbidStreamFunc(pCxt, pFunc); - } - if (TSDB_CODE_SUCCESS == pCxt->errCode) { - pCxt->errCode = translateForbidGroupByFunc(pCxt, pFunc); - } - if (TSDB_CODE_SUCCESS == pCxt->errCode) { - setFuncClassification(pCxt->pCurrSelectStmt, pFunc); + pCxt->errCode = translateFunctionImpl(pCxt, pFunc); } return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR; } @@ -1285,7 +1411,7 @@ static EDealRes doTranslateExpr(SNode** pNode, void* pContext) { case QUERY_NODE_OPERATOR: return translateOperator(pCxt, (SOperatorNode**)pNode); case QUERY_NODE_FUNCTION: - return translateFunction(pCxt, (SFunctionNode*)*pNode); + return translateFunction(pCxt, (SFunctionNode**)pNode); case QUERY_NODE_LOGIC_CONDITION: return translateLogicCond(pCxt, (SLogicConditionNode*)*pNode); case QUERY_NODE_TEMP_TABLE: @@ -1308,9 +1434,9 @@ static int32_t translateExprList(STranslateContext* pCxt, SNodeList* pList) { static SNodeList* getGroupByList(STranslateContext* pCxt) { if (isDistinctOrderBy(pCxt)) { - return pCxt->pCurrSelectStmt->pProjectionList; + return ((SSelectStmt*)pCxt->pCurrStmt)->pProjectionList; } - return pCxt->pCurrSelectStmt->pGroupByList; + return ((SSelectStmt*)pCxt->pCurrStmt)->pGroupByList; } static SNode* getGroupByNode(SNode* pNode) { @@ -1348,7 +1474,7 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode } if (TSDB_CODE_SUCCESS == pCxt->errCode) { *pNode = (SNode*)pFunc; - pCxt->pCurrSelectStmt->hasSelectValFunc = true; + ((SSelectStmt*)pCxt->pCurrStmt)->hasSelectValFunc = true; } else { nodesDestroyNode((SNode*)pFunc); } @@ -1378,7 +1504,7 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) { } } SNode* pPartKey = NULL; - FOREACH(pPartKey, pCxt->pTranslateCxt->pCurrSelectStmt->pPartitionByList) { + FOREACH(pPartKey, ((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pPartitionByList) { if (nodesEqualNode(pPartKey, *pNode)) { return DEAL_RES_IGNORE_CHILD; } @@ -1463,7 +1589,7 @@ static EDealRes doCheckAggColCoexist(SNode* pNode, void* pContext) { return DEAL_RES_IGNORE_CHILD; } SNode* pPartKey = NULL; - FOREACH(pPartKey, pCxt->pTranslateCxt->pCurrSelectStmt->pPartitionByList) { + FOREACH(pPartKey, ((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pPartitionByList) { if (nodesEqualNode(pPartKey, pNode)) { return DEAL_RES_IGNORE_CHILD; } @@ -1627,7 +1753,8 @@ static uint8_t getStmtPrecision(SNode* pStmt) { static bool stmtIsSingleTable(SNode* pStmt) { if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { - return ((STableNode*)((SSelectStmt*)pStmt)->pFromTable)->singleTable; + SSelectStmt* pSelect = (SSelectStmt*)pStmt; + return NULL == pSelect->pFromTable || ((STableNode*)pSelect->pFromTable)->singleTable; } return false; } @@ -1655,8 +1782,8 @@ static int32_t setTableIndex(STranslateContext* pCxt, SName* pName, SRealTableNo if (pCxt->createStream || QUERY_SMA_OPTIMIZE_DISABLE == tsQuerySmaOptimize) { return TSDB_CODE_SUCCESS; } - if (NULL != pCxt->pCurrSelectStmt && NULL != pCxt->pCurrSelectStmt->pWindow && - QUERY_NODE_INTERVAL_WINDOW == nodeType(pCxt->pCurrSelectStmt->pWindow)) { + if (isSelectStmt(pCxt->pCurrStmt) && NULL != ((SSelectStmt*)pCxt->pCurrStmt)->pWindow && + QUERY_NODE_INTERVAL_WINDOW == nodeType(((SSelectStmt*)pCxt->pCurrStmt)->pWindow)) { return getTableIndex(pCxt, pName, &pRealTable->pSmaIndexes); } return TSDB_CODE_SUCCESS; @@ -2369,7 +2496,7 @@ static EDealRes rewriteSeletcValueFunc(STranslateContext* pCxt, SNode** pNode) { nodesDestroyNode(*pNode); *pNode = (SNode*)pFirst; pCxt->errCode = fmGetFuncInfo(pFirst, pCxt->msgBuf.buf, pCxt->msgBuf.len); - pCxt->pCurrSelectStmt->hasAggFuncs = true; + ((SSelectStmt*)pCxt->pCurrStmt)->hasAggFuncs = true; return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR; } @@ -2408,13 +2535,13 @@ static int32_t replaceOrderByAlias(STranslateContext* pCxt, SNodeList* pProjecti } static int32_t translateSelectWithoutFrom(STranslateContext* pCxt, SSelectStmt* pSelect) { - pCxt->pCurrSelectStmt = pSelect; + pCxt->pCurrStmt = (SNode*)pSelect; pCxt->currClause = SQL_CLAUSE_SELECT; return translateExprList(pCxt, pSelect->pProjectionList); } static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect) { - pCxt->pCurrSelectStmt = pSelect; + pCxt->pCurrStmt = (SNode*)pSelect; int32_t code = translateFrom(pCxt, pSelect->pFromTable); if (TSDB_CODE_SUCCESS == code) { pSelect->precision = ((STableNode*)pSelect->pFromTable)->precision; @@ -2538,8 +2665,7 @@ static int32_t translateSetOperOrderBy(STranslateContext* pCxt, SSetOperator* pS if (TSDB_CODE_SUCCESS == code) { if (other) { pCxt->currClause = SQL_CLAUSE_ORDER_BY; - pCxt->pCurrSelectStmt = NULL; - pCxt->pCurrSetOperator = pSetOperator; + pCxt->pCurrStmt = (SNode*)pSetOperator; code = translateExprList(pCxt, pSetOperator->pOrderByList); } } @@ -4419,12 +4545,12 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) { ++(pCxt->currLevel); - ESqlClause currClause = pCxt->currClause; - SSelectStmt* pCurrStmt = pCxt->pCurrSelectStmt; - int32_t code = translateQuery(pCxt, pNode); + ESqlClause currClause = pCxt->currClause; + SNode* pCurrStmt = pCxt->pCurrStmt; + int32_t code = translateQuery(pCxt, pNode); --(pCxt->currLevel); pCxt->currClause = currClause; - pCxt->pCurrSelectStmt = pCurrStmt; + pCxt->pCurrStmt = pCurrStmt; return code; } @@ -5876,6 +6002,11 @@ static int32_t setRefreshMate(STranslateContext* pCxt, SQuery* pQuery) { static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) { switch (nodeType(pQuery->pRoot)) { case QUERY_NODE_SELECT_STMT: + if (NULL == ((SSelectStmt*)pQuery->pRoot)->pFromTable) { + pQuery->execMode = QUERY_EXEC_MODE_LOCAL; + pQuery->haveResultSet = true; + break; + } case QUERY_NODE_SET_OPERATOR: case QUERY_NODE_EXPLAIN_STMT: pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE; diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 225d163f53..5eb9c72267 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -104,26 +104,26 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 370 +#define YYNOCODE 374 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - ENullOrder yy77; - SAlterOption yy85; - int32_t yy100; - SToken yy109; - EOrder yy178; - int64_t yy209; - int8_t yy323; - SNodeList* yy404; - bool yy437; - EOperatorType yy440; - SNode* yy452; - SDataType yy504; - EJoinType yy532; - EFillMode yy614; + SNodeList* yy24; + SDataType yy48; + bool yy97; + SAlterOption yy189; + int32_t yy244; + EFillMode yy250; + EJoinType yy596; + EOrder yy598; + int8_t yy619; + SNode* yy652; + ENullOrder yy653; + SToken yy657; + EOperatorType yy700; + int64_t yy701; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -140,16 +140,16 @@ typedef union { #define ParseCTX_STORE #define YYFALLBACK 1 #define YYNSTATE 653 -#define YYNRULE 477 -#define YYNTOKEN 246 +#define YYNRULE 483 +#define YYNTOKEN 250 #define YY_MAX_SHIFT 652 -#define YY_MIN_SHIFTREDUCE 947 -#define YY_MAX_SHIFTREDUCE 1423 -#define YY_ERROR_ACTION 1424 -#define YY_ACCEPT_ACTION 1425 -#define YY_NO_ACTION 1426 -#define YY_MIN_REDUCE 1427 -#define YY_MAX_REDUCE 1903 +#define YY_MIN_SHIFTREDUCE 953 +#define YY_MAX_SHIFTREDUCE 1435 +#define YY_ERROR_ACTION 1436 +#define YY_ACCEPT_ACTION 1437 +#define YY_NO_ACTION 1438 +#define YY_MIN_REDUCE 1439 +#define YY_MAX_REDUCE 1921 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -216,623 +216,679 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2208) +#define YY_ACTTAB_COUNT (2489) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 422, 1661, 423, 1462, 430, 1730, 423, 1462, 317, 1881, - /* 10 */ 141, 1425, 39, 37, 1518, 373, 1727, 69, 1552, 1550, - /* 20 */ 326, 1428, 1230, 1880, 379, 1730, 1367, 1878, 334, 1727, - /* 30 */ 115, 140, 1254, 1439, 1743, 1228, 1727, 338, 566, 1556, - /* 40 */ 1606, 1608, 101, 1723, 1729, 100, 99, 98, 97, 96, - /* 50 */ 95, 94, 93, 92, 570, 1881, 1723, 1729, 61, 14, - /* 60 */ 1309, 296, 1761, 1723, 1729, 1236, 1254, 570, 1761, 156, - /* 70 */ 550, 566, 343, 1878, 570, 1713, 519, 549, 39, 37, - /* 80 */ 1360, 427, 1, 504, 1255, 1230, 326, 1252, 1230, 33, - /* 90 */ 32, 439, 530, 40, 38, 36, 35, 34, 1228, 1743, - /* 100 */ 43, 1228, 151, 1774, 649, 520, 87, 1744, 552, 1746, - /* 110 */ 1747, 548, 1881, 570, 518, 1600, 1814, 69, 1301, 1302, - /* 120 */ 298, 1810, 60, 1881, 1255, 14, 156, 1761, 1236, 1881, - /* 130 */ 1878, 1236, 1881, 567, 567, 547, 60, 156, 526, 1557, - /* 140 */ 1713, 1878, 549, 157, 111, 161, 158, 1878, 2, 101, - /* 150 */ 1878, 460, 100, 99, 98, 97, 96, 95, 94, 93, - /* 160 */ 92, 1561, 1561, 1231, 1394, 1229, 119, 649, 1774, 604, - /* 170 */ 649, 287, 1744, 552, 1746, 1747, 548, 546, 570, 543, - /* 180 */ 1786, 1323, 1129, 1130, 1301, 1302, 1450, 1234, 1235, 534, - /* 190 */ 1283, 1284, 1286, 1287, 1288, 1289, 1290, 545, 568, 1298, - /* 200 */ 1299, 1300, 1303, 1285, 1328, 166, 117, 295, 1829, 1252, - /* 210 */ 40, 38, 36, 35, 34, 159, 405, 1427, 1236, 417, - /* 220 */ 528, 153, 1822, 1823, 567, 1827, 1231, 1713, 1229, 1231, - /* 230 */ 67, 1229, 1826, 66, 1384, 377, 390, 1285, 418, 27, - /* 240 */ 392, 110, 109, 108, 107, 106, 105, 104, 103, 102, - /* 250 */ 1234, 1235, 1561, 1234, 1235, 159, 1283, 1284, 1286, 1287, - /* 260 */ 1288, 1289, 1290, 545, 568, 1298, 1299, 1300, 1303, 159, - /* 270 */ 383, 512, 1382, 1383, 1385, 1386, 33, 32, 39, 37, - /* 280 */ 40, 38, 36, 35, 34, 1254, 326, 608, 1230, 1533, - /* 290 */ 1087, 593, 592, 591, 1091, 590, 1093, 1094, 589, 1096, - /* 300 */ 586, 1228, 1102, 583, 1104, 1105, 580, 577, 11, 10, - /* 310 */ 416, 22, 566, 411, 410, 409, 408, 407, 404, 403, - /* 320 */ 402, 401, 400, 396, 395, 394, 393, 387, 386, 385, - /* 330 */ 384, 1236, 381, 380, 39, 37, 1743, 1253, 310, 30, - /* 340 */ 240, 997, 326, 996, 1230, 33, 32, 209, 8, 40, - /* 350 */ 38, 36, 35, 34, 474, 473, 458, 1228, 1731, 472, - /* 360 */ 980, 1256, 116, 469, 1761, 567, 468, 467, 466, 1727, - /* 370 */ 649, 998, 550, 60, 42, 73, 111, 1713, 596, 549, - /* 380 */ 535, 14, 497, 465, 1301, 1302, 311, 1236, 309, 308, - /* 390 */ 1335, 462, 412, 1561, 530, 464, 1723, 1729, 515, 479, - /* 400 */ 984, 985, 1881, 1449, 2, 1774, 1440, 570, 87, 1744, - /* 410 */ 552, 1746, 1747, 548, 489, 570, 1879, 463, 1814, 567, - /* 420 */ 1878, 567, 298, 1810, 84, 553, 649, 1492, 201, 1231, - /* 430 */ 378, 1229, 382, 329, 1881, 607, 1658, 120, 170, 169, - /* 440 */ 1301, 1302, 482, 1448, 1713, 1553, 476, 1561, 156, 1561, - /* 450 */ 490, 200, 1878, 1234, 1235, 1546, 1283, 1284, 1286, 1287, - /* 460 */ 1288, 1289, 1290, 545, 568, 1298, 1299, 1300, 1303, 330, - /* 470 */ 521, 516, 39, 37, 1304, 421, 55, 138, 425, 54, - /* 480 */ 326, 159, 1230, 567, 1713, 1231, 1563, 1229, 474, 473, - /* 490 */ 1881, 231, 1420, 472, 397, 1228, 116, 469, 526, 1519, - /* 500 */ 468, 467, 466, 526, 156, 58, 159, 159, 1878, 1234, - /* 510 */ 1235, 1561, 1283, 1284, 1286, 1287, 1288, 1289, 1290, 545, - /* 520 */ 568, 1298, 1299, 1300, 1303, 1236, 119, 39, 37, 1607, - /* 530 */ 1608, 119, 567, 364, 1257, 326, 1447, 1230, 984, 985, - /* 540 */ 33, 32, 9, 398, 40, 38, 36, 35, 34, 202, - /* 550 */ 1228, 33, 32, 366, 362, 40, 38, 36, 35, 34, - /* 560 */ 1561, 567, 429, 1743, 649, 425, 117, 336, 997, 1446, - /* 570 */ 996, 117, 438, 1657, 1419, 138, 305, 1713, 1301, 1302, - /* 580 */ 1236, 154, 1822, 1823, 1563, 1827, 155, 1822, 1823, 1561, - /* 590 */ 1827, 1761, 602, 39, 37, 235, 567, 9, 998, 550, - /* 600 */ 1445, 326, 1444, 1230, 1713, 464, 549, 1558, 71, 304, - /* 610 */ 1713, 129, 128, 599, 598, 597, 1228, 567, 506, 649, - /* 620 */ 471, 470, 1479, 1231, 1561, 1229, 1374, 463, 1690, 36, - /* 630 */ 35, 34, 1774, 1301, 1302, 288, 1744, 552, 1746, 1747, - /* 640 */ 548, 1713, 570, 1713, 475, 1561, 1236, 1234, 1235, 1049, - /* 650 */ 1283, 1284, 1286, 1287, 1288, 1289, 1290, 545, 568, 1298, - /* 660 */ 1299, 1300, 1303, 2, 212, 567, 567, 33, 32, 1254, - /* 670 */ 567, 40, 38, 36, 35, 34, 498, 502, 1231, 1051, - /* 680 */ 1229, 564, 33, 32, 1651, 649, 40, 38, 36, 35, - /* 690 */ 34, 620, 618, 1561, 1561, 168, 1834, 1355, 1561, 1301, - /* 700 */ 1302, 1538, 1234, 1235, 1548, 1283, 1284, 1286, 1287, 1288, - /* 710 */ 1289, 1290, 545, 568, 1298, 1299, 1300, 1303, 299, 60, - /* 720 */ 567, 33, 32, 652, 339, 40, 38, 36, 35, 34, - /* 730 */ 1544, 565, 138, 299, 532, 205, 1613, 262, 567, 1539, - /* 740 */ 488, 1563, 1268, 331, 1231, 1443, 1229, 1613, 1561, 256, - /* 750 */ 1321, 149, 1611, 486, 337, 484, 642, 638, 634, 630, - /* 760 */ 260, 244, 1743, 1611, 1537, 1321, 1561, 1442, 1234, 1235, - /* 770 */ 1441, 1283, 1284, 1286, 1287, 1288, 1289, 1290, 545, 568, - /* 780 */ 1298, 1299, 1300, 1303, 138, 85, 1713, 139, 254, 553, - /* 790 */ 1761, 1438, 273, 1564, 1359, 602, 1268, 439, 550, 372, - /* 800 */ 1659, 371, 567, 1713, 1322, 549, 271, 57, 1713, 1829, - /* 810 */ 56, 1713, 544, 340, 129, 128, 599, 598, 597, 1322, - /* 820 */ 1437, 563, 604, 1212, 1213, 1656, 171, 1327, 305, 1613, - /* 830 */ 1561, 1774, 1713, 1825, 88, 1744, 552, 1746, 1747, 548, - /* 840 */ 1285, 570, 1327, 1489, 1814, 1612, 1436, 1435, 319, 1810, - /* 850 */ 1894, 60, 159, 211, 78, 1701, 7, 595, 1434, 1849, - /* 860 */ 1433, 1713, 29, 324, 1316, 1317, 1318, 1319, 1320, 1324, - /* 870 */ 1325, 1326, 245, 246, 1204, 1554, 204, 29, 324, 1316, - /* 880 */ 1317, 1318, 1319, 1320, 1324, 1325, 1326, 1713, 1713, 86, - /* 890 */ 33, 32, 513, 1432, 40, 38, 36, 35, 34, 1713, - /* 900 */ 1743, 1713, 352, 1431, 626, 625, 624, 341, 1829, 623, - /* 910 */ 622, 621, 121, 616, 615, 614, 613, 612, 611, 610, - /* 920 */ 609, 131, 605, 619, 64, 63, 376, 1430, 1761, 165, - /* 930 */ 208, 542, 1824, 304, 1713, 370, 529, 333, 332, 600, - /* 940 */ 537, 1713, 1604, 549, 1713, 601, 294, 1244, 1604, 360, - /* 950 */ 1239, 358, 354, 350, 162, 345, 267, 457, 72, 1591, - /* 960 */ 1237, 1743, 193, 367, 195, 191, 223, 194, 1713, 1774, - /* 970 */ 1536, 1474, 88, 1744, 552, 1746, 1747, 548, 197, 570, - /* 980 */ 199, 196, 1814, 198, 159, 1472, 319, 1810, 152, 1761, - /* 990 */ 1236, 52, 501, 477, 11, 10, 1238, 529, 491, 50, - /* 1000 */ 232, 1762, 1713, 83, 549, 26, 1358, 480, 505, 1842, - /* 1010 */ 1733, 33, 32, 80, 28, 40, 38, 36, 35, 34, - /* 1020 */ 33, 32, 1743, 342, 40, 38, 36, 35, 34, 571, - /* 1030 */ 1774, 1355, 137, 88, 1744, 552, 1746, 1747, 548, 1381, - /* 1040 */ 570, 1422, 1423, 1814, 1463, 1601, 1735, 319, 1810, 152, - /* 1050 */ 1761, 1845, 216, 41, 527, 234, 237, 239, 550, 1313, - /* 1060 */ 41, 5, 41, 1713, 602, 549, 242, 344, 3, 1252, - /* 1070 */ 1843, 123, 347, 351, 126, 127, 50, 1743, 306, 1049, - /* 1080 */ 1242, 575, 126, 129, 128, 599, 598, 597, 1245, 1468, - /* 1090 */ 1240, 1774, 218, 1329, 88, 1744, 552, 1746, 1747, 548, - /* 1100 */ 1291, 570, 1180, 127, 1814, 1761, 247, 112, 319, 1810, - /* 1110 */ 1894, 559, 1248, 550, 253, 1080, 266, 307, 1713, 1872, - /* 1120 */ 549, 1108, 1112, 568, 1298, 1299, 1241, 1196, 126, 263, - /* 1130 */ 1743, 1021, 399, 538, 1653, 167, 406, 644, 1258, 1743, - /* 1140 */ 414, 413, 415, 1119, 419, 1261, 1774, 1117, 431, 88, - /* 1150 */ 1744, 552, 1746, 1747, 548, 420, 570, 1743, 1761, 1814, - /* 1160 */ 428, 1022, 174, 319, 1810, 1894, 550, 1761, 130, 1260, - /* 1170 */ 433, 1713, 176, 549, 1833, 550, 432, 1262, 434, 179, - /* 1180 */ 1713, 181, 549, 1259, 437, 1761, 459, 183, 530, 436, - /* 1190 */ 68, 440, 186, 550, 461, 91, 1551, 530, 1713, 1774, - /* 1200 */ 549, 190, 280, 1744, 552, 1746, 1747, 548, 1774, 570, - /* 1210 */ 1547, 280, 1744, 552, 1746, 1747, 548, 192, 570, 132, - /* 1220 */ 133, 1549, 1743, 1545, 134, 135, 1774, 297, 1881, 89, - /* 1230 */ 1744, 552, 1746, 1747, 548, 1695, 570, 1881, 1743, 1814, - /* 1240 */ 264, 203, 158, 1813, 1810, 492, 1878, 1743, 493, 496, - /* 1250 */ 1761, 156, 1257, 206, 499, 1878, 503, 316, 550, 210, - /* 1260 */ 514, 1846, 509, 1713, 556, 549, 1761, 1856, 214, 511, - /* 1270 */ 217, 318, 6, 517, 550, 1761, 523, 510, 1836, 1713, - /* 1280 */ 224, 549, 508, 550, 507, 1855, 1355, 118, 1713, 226, - /* 1290 */ 549, 1774, 222, 227, 89, 1744, 552, 1746, 1747, 548, - /* 1300 */ 1743, 570, 146, 225, 1814, 1256, 1830, 1774, 541, 1810, - /* 1310 */ 142, 1744, 552, 1746, 1747, 548, 1774, 570, 44, 89, - /* 1320 */ 1744, 552, 1746, 1747, 548, 539, 570, 1877, 1761, 1814, - /* 1330 */ 188, 536, 320, 18, 1811, 124, 550, 233, 236, 228, - /* 1340 */ 1795, 1713, 125, 549, 144, 554, 555, 1897, 533, 456, - /* 1350 */ 452, 448, 444, 187, 1743, 531, 1895, 1694, 1663, 557, - /* 1360 */ 540, 328, 560, 1743, 561, 249, 251, 238, 562, 1774, - /* 1370 */ 265, 77, 283, 1744, 552, 1746, 1747, 548, 70, 570, - /* 1380 */ 1562, 185, 1761, 79, 573, 268, 1534, 645, 259, 1605, - /* 1390 */ 550, 1761, 646, 648, 51, 1713, 145, 549, 289, 550, - /* 1400 */ 272, 291, 290, 270, 1713, 1707, 549, 1706, 62, 1705, - /* 1410 */ 346, 522, 348, 1743, 1702, 349, 1223, 1224, 323, 163, - /* 1420 */ 353, 1700, 355, 1774, 1743, 356, 142, 1744, 552, 1746, - /* 1430 */ 1747, 548, 1774, 570, 357, 288, 1744, 552, 1746, 1747, - /* 1440 */ 548, 1761, 570, 184, 177, 1699, 182, 359, 1698, 547, - /* 1450 */ 435, 361, 1761, 1697, 1713, 363, 549, 1696, 365, 1680, - /* 1460 */ 550, 164, 368, 369, 1199, 1713, 1198, 549, 1674, 175, - /* 1470 */ 1673, 374, 1896, 375, 1672, 1671, 1743, 1168, 1646, 325, - /* 1480 */ 1645, 1644, 1774, 65, 1643, 287, 1744, 552, 1746, 1747, - /* 1490 */ 548, 1642, 570, 1774, 1787, 1641, 288, 1744, 552, 1746, - /* 1500 */ 1747, 548, 1640, 570, 1761, 1639, 388, 389, 1638, 391, - /* 1510 */ 1637, 1636, 550, 1635, 1634, 1633, 1632, 1713, 1631, 549, - /* 1520 */ 1630, 1629, 1628, 1627, 1626, 1625, 1624, 122, 1623, 1743, - /* 1530 */ 1622, 327, 1621, 1620, 1619, 1618, 1617, 1616, 1743, 1170, - /* 1540 */ 1615, 1614, 1491, 1459, 150, 1774, 172, 1743, 288, 1744, - /* 1550 */ 552, 1746, 1747, 548, 1458, 570, 1688, 1761, 113, 987, - /* 1560 */ 986, 1682, 1670, 1669, 180, 550, 1761, 1655, 1540, 173, - /* 1570 */ 1713, 1490, 549, 424, 550, 1761, 1488, 426, 114, 1713, - /* 1580 */ 1486, 549, 1484, 550, 1482, 441, 178, 443, 1713, 1471, - /* 1590 */ 549, 442, 445, 1470, 447, 449, 1455, 1542, 1774, 1743, - /* 1600 */ 446, 274, 1744, 552, 1746, 1747, 548, 1774, 570, 451, - /* 1610 */ 275, 1744, 552, 1746, 1747, 548, 1774, 570, 453, 276, - /* 1620 */ 1744, 552, 1746, 1747, 548, 1015, 570, 1761, 450, 49, - /* 1630 */ 455, 1122, 454, 1123, 1541, 550, 1048, 1047, 1046, 1045, - /* 1640 */ 1713, 1743, 549, 617, 1480, 1042, 1041, 1040, 189, 619, - /* 1650 */ 312, 1475, 313, 1473, 478, 314, 481, 1454, 483, 1453, - /* 1660 */ 485, 1743, 1452, 487, 1687, 90, 1206, 1681, 1774, 1761, - /* 1670 */ 494, 282, 1744, 552, 1746, 1747, 548, 550, 570, 1668, - /* 1680 */ 1666, 136, 1713, 1743, 549, 1667, 1665, 1664, 15, 1761, - /* 1690 */ 4, 1408, 41, 47, 10, 23, 213, 550, 1396, 207, - /* 1700 */ 143, 53, 1713, 215, 549, 1380, 219, 221, 24, 220, - /* 1710 */ 1774, 1761, 1373, 284, 1744, 552, 1746, 1747, 548, 550, - /* 1720 */ 570, 500, 495, 315, 1713, 74, 549, 1733, 16, 1352, - /* 1730 */ 1774, 25, 46, 277, 1744, 552, 1746, 1747, 548, 1743, - /* 1740 */ 570, 1351, 230, 147, 17, 1407, 1413, 321, 1743, 1412, - /* 1750 */ 1411, 1402, 1774, 322, 19, 285, 1744, 552, 1746, 1747, - /* 1760 */ 548, 1314, 570, 148, 1276, 1293, 31, 1761, 160, 1662, - /* 1770 */ 1654, 250, 1732, 1292, 241, 550, 1761, 45, 1378, 551, - /* 1780 */ 1713, 12, 549, 558, 550, 13, 20, 21, 243, 1713, - /* 1790 */ 248, 549, 80, 255, 1246, 75, 572, 574, 1743, 1295, - /* 1800 */ 252, 76, 1777, 569, 1101, 48, 335, 1743, 1774, 578, - /* 1810 */ 1109, 278, 1744, 552, 1746, 1747, 548, 1774, 570, 576, - /* 1820 */ 286, 1744, 552, 1746, 1747, 548, 1761, 570, 1106, 1103, - /* 1830 */ 579, 581, 582, 584, 550, 1761, 587, 1097, 585, 1713, - /* 1840 */ 1095, 549, 588, 550, 1100, 1099, 1086, 1098, 1713, 594, - /* 1850 */ 549, 1118, 257, 1114, 1013, 81, 603, 1743, 82, 59, - /* 1860 */ 1037, 606, 258, 1035, 1055, 1034, 1743, 1774, 1033, 1032, - /* 1870 */ 279, 1744, 552, 1746, 1747, 548, 1774, 570, 1031, 292, - /* 1880 */ 1744, 552, 1746, 1747, 548, 1761, 570, 1030, 1029, 1028, - /* 1890 */ 1050, 1052, 1025, 550, 1761, 1024, 1023, 1020, 1713, 1019, - /* 1900 */ 549, 1018, 550, 1487, 627, 628, 629, 1713, 1485, 549, - /* 1910 */ 631, 633, 1483, 635, 1481, 632, 637, 636, 1743, 639, - /* 1920 */ 640, 641, 1469, 643, 977, 1451, 1774, 1743, 261, 293, - /* 1930 */ 1744, 552, 1746, 1747, 548, 1774, 570, 647, 1755, 1744, - /* 1940 */ 552, 1746, 1747, 548, 650, 570, 1761, 1426, 1232, 269, - /* 1950 */ 651, 1426, 1426, 1426, 550, 1761, 1426, 1426, 1426, 1713, - /* 1960 */ 1426, 549, 1426, 550, 1426, 1426, 1426, 1426, 1713, 1426, - /* 1970 */ 549, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, - /* 1980 */ 1743, 1426, 1426, 1426, 1426, 1426, 1426, 1774, 1426, 1743, - /* 1990 */ 1754, 1744, 552, 1746, 1747, 548, 1774, 570, 1743, 1753, - /* 2000 */ 1744, 552, 1746, 1747, 548, 1426, 570, 1743, 1761, 1426, - /* 2010 */ 526, 1426, 1426, 1426, 1426, 1426, 550, 1761, 1426, 1426, - /* 2020 */ 1426, 1713, 1426, 549, 1426, 550, 1761, 1426, 1426, 1426, - /* 2030 */ 1713, 1426, 549, 1426, 550, 1761, 1426, 1426, 119, 1713, - /* 2040 */ 1426, 549, 1426, 550, 1426, 1426, 1426, 1426, 1713, 1774, - /* 2050 */ 549, 1426, 302, 1744, 552, 1746, 1747, 548, 1774, 570, - /* 2060 */ 530, 301, 1744, 552, 1746, 1747, 548, 1774, 570, 1426, - /* 2070 */ 303, 1744, 552, 1746, 1747, 548, 1774, 570, 117, 300, - /* 2080 */ 1744, 552, 1746, 1747, 548, 1743, 570, 1426, 1426, 1426, - /* 2090 */ 1426, 1426, 1426, 229, 1822, 525, 1426, 524, 1426, 526, - /* 2100 */ 1881, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, - /* 2110 */ 1426, 1426, 1426, 1761, 158, 1426, 1426, 1426, 1878, 1426, - /* 2120 */ 1426, 550, 1426, 1426, 1426, 1426, 1713, 119, 549, 1426, - /* 2130 */ 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, - /* 2140 */ 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 530, - /* 2150 */ 1426, 1426, 1426, 1426, 1774, 1426, 1426, 281, 1744, 552, - /* 2160 */ 1746, 1747, 548, 1426, 570, 1426, 1426, 117, 1426, 1426, - /* 2170 */ 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, - /* 2180 */ 1426, 1426, 229, 1822, 525, 1426, 524, 1426, 1426, 1881, - /* 2190 */ 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, - /* 2200 */ 1426, 1426, 1426, 156, 1426, 1426, 1426, 1878, + /* 0 */ 567, 422, 1437, 423, 1474, 1742, 1673, 430, 317, 423, + /* 10 */ 1474, 111, 39, 37, 1504, 140, 1739, 1451, 460, 69, + /* 20 */ 326, 1440, 1236, 1742, 488, 151, 334, 526, 1573, 1564, + /* 30 */ 1261, 566, 115, 1311, 1739, 1234, 1847, 486, 1612, 484, + /* 40 */ 1739, 1568, 101, 1735, 1741, 100, 99, 98, 97, 96, + /* 50 */ 95, 94, 93, 92, 570, 119, 1306, 1625, 1755, 14, + /* 60 */ 1844, 1735, 1741, 343, 331, 1242, 373, 1735, 1741, 39, + /* 70 */ 37, 1372, 570, 1623, 566, 474, 473, 326, 570, 1236, + /* 80 */ 472, 1847, 1, 116, 469, 553, 1773, 468, 467, 466, + /* 90 */ 1311, 1625, 1234, 329, 529, 117, 1670, 567, 337, 1725, + /* 100 */ 1462, 549, 504, 1899, 649, 1843, 1899, 1623, 111, 528, + /* 110 */ 153, 1840, 1841, 1306, 1845, 465, 14, 156, 1313, 1314, + /* 120 */ 156, 1896, 1242, 1439, 1896, 1573, 1480, 1786, 1135, 1136, + /* 130 */ 88, 1756, 552, 1758, 1759, 548, 42, 570, 78, 2, + /* 140 */ 1832, 1725, 1899, 209, 319, 1828, 152, 110, 109, 108, + /* 150 */ 107, 106, 105, 104, 103, 102, 156, 439, 232, 1566, + /* 160 */ 1896, 649, 1501, 1237, 141, 1235, 505, 1860, 1530, 60, + /* 170 */ 520, 73, 474, 473, 644, 1313, 1314, 472, 1743, 338, + /* 180 */ 116, 469, 1618, 1620, 468, 467, 466, 1240, 1241, 1739, + /* 190 */ 1289, 1290, 1292, 1293, 1294, 1295, 1296, 545, 568, 1304, + /* 200 */ 1305, 1307, 1308, 1309, 1310, 1312, 1315, 33, 32, 245, + /* 210 */ 246, 40, 38, 36, 35, 34, 1735, 1741, 421, 159, + /* 220 */ 1237, 425, 1235, 626, 625, 624, 341, 570, 623, 622, + /* 230 */ 621, 121, 616, 615, 614, 613, 612, 611, 610, 609, + /* 240 */ 131, 605, 1262, 986, 1240, 1241, 61, 1289, 1290, 1292, + /* 250 */ 1293, 1294, 1295, 1296, 545, 568, 1304, 1305, 1307, 1308, + /* 260 */ 1309, 1310, 1312, 1315, 39, 37, 566, 1236, 60, 490, + /* 270 */ 304, 1396, 326, 159, 1236, 40, 38, 36, 35, 34, + /* 280 */ 1234, 1261, 1406, 990, 991, 1311, 84, 1234, 1093, 593, + /* 290 */ 592, 591, 1097, 590, 1099, 1100, 589, 1102, 586, 120, + /* 300 */ 1108, 583, 1110, 1111, 580, 577, 159, 1565, 1306, 1899, + /* 310 */ 1242, 14, 512, 1394, 1395, 1397, 1398, 1242, 602, 1551, + /* 320 */ 379, 39, 37, 156, 60, 1755, 604, 1896, 43, 326, + /* 330 */ 1003, 1236, 1002, 1260, 2, 330, 60, 129, 128, 599, + /* 340 */ 598, 597, 1311, 138, 1234, 458, 336, 1259, 372, 649, + /* 350 */ 371, 526, 1575, 1773, 138, 1899, 649, 296, 1549, 339, + /* 360 */ 1004, 550, 244, 1575, 1899, 1306, 1725, 138, 549, 1898, + /* 370 */ 1313, 1314, 231, 1896, 1242, 1899, 1575, 439, 157, 119, + /* 380 */ 33, 32, 1896, 530, 40, 38, 36, 35, 34, 1897, + /* 390 */ 1379, 8, 567, 1896, 1786, 1663, 1260, 87, 1756, 552, + /* 400 */ 1758, 1759, 548, 161, 570, 159, 168, 1832, 1237, 364, + /* 410 */ 1235, 298, 1828, 649, 1773, 1237, 604, 1235, 515, 117, + /* 420 */ 1573, 83, 519, 1899, 1218, 1219, 1242, 1313, 1314, 366, + /* 430 */ 362, 80, 1240, 1241, 154, 1840, 1841, 158, 1845, 1240, + /* 440 */ 1241, 1896, 1289, 1290, 1292, 1293, 1294, 1295, 1296, 545, + /* 450 */ 568, 1304, 1305, 1307, 1308, 1309, 1310, 1312, 1315, 101, + /* 460 */ 518, 159, 100, 99, 98, 97, 96, 95, 94, 93, + /* 470 */ 92, 427, 1237, 159, 1235, 33, 32, 1258, 26, 40, + /* 480 */ 38, 36, 35, 34, 33, 32, 412, 1321, 40, 38, + /* 490 */ 36, 35, 34, 1260, 521, 516, 1240, 1241, 596, 1289, + /* 500 */ 1290, 1292, 1293, 1294, 1295, 1296, 545, 568, 1304, 1305, + /* 510 */ 1307, 1308, 1309, 1310, 1312, 1315, 39, 37, 1316, 567, + /* 520 */ 202, 30, 240, 567, 326, 607, 1236, 1432, 159, 1461, + /* 530 */ 377, 1460, 170, 169, 378, 1745, 1003, 1311, 1002, 1234, + /* 540 */ 497, 1459, 28, 36, 35, 34, 7, 1573, 33, 32, + /* 550 */ 1386, 1573, 40, 38, 36, 35, 34, 33, 32, 1755, + /* 560 */ 1306, 40, 38, 36, 35, 34, 1004, 1291, 1458, 1242, + /* 570 */ 1725, 1747, 1725, 39, 37, 1755, 1619, 1620, 479, 71, + /* 580 */ 304, 326, 1725, 1236, 33, 32, 9, 1773, 40, 38, + /* 590 */ 36, 35, 34, 489, 1311, 550, 1234, 138, 69, 567, + /* 600 */ 1725, 567, 549, 1773, 11, 10, 1576, 201, 649, 1725, + /* 610 */ 382, 529, 397, 1431, 166, 1457, 1725, 1306, 549, 22, + /* 620 */ 1569, 482, 1313, 1314, 1550, 476, 1242, 1573, 1786, 1573, + /* 630 */ 200, 89, 1756, 552, 1758, 1759, 548, 429, 570, 67, + /* 640 */ 425, 1832, 66, 9, 1786, 1831, 1828, 88, 1756, 552, + /* 650 */ 1758, 1759, 548, 1055, 570, 55, 1725, 1832, 54, 526, + /* 660 */ 1562, 319, 1828, 152, 1291, 649, 1335, 1237, 1558, 1235, + /* 670 */ 33, 32, 1456, 1455, 40, 38, 36, 35, 34, 1313, + /* 680 */ 1314, 1548, 600, 1057, 1861, 1616, 1347, 119, 1454, 1340, + /* 690 */ 1453, 1240, 1241, 1450, 1289, 1290, 1292, 1293, 1294, 1295, + /* 700 */ 1296, 545, 568, 1304, 1305, 1307, 1308, 1309, 1310, 1312, + /* 710 */ 1315, 471, 470, 1725, 1725, 33, 32, 1371, 602, 40, + /* 720 */ 38, 36, 35, 34, 1237, 1367, 1235, 117, 27, 1725, + /* 730 */ 1449, 1725, 1448, 1447, 1725, 310, 1446, 129, 128, 599, + /* 740 */ 598, 597, 155, 1840, 1841, 1274, 1845, 1669, 1240, 1241, + /* 750 */ 305, 1289, 1290, 1292, 1293, 1294, 1295, 1296, 545, 568, + /* 760 */ 1304, 1305, 1307, 1308, 1309, 1310, 1312, 1315, 39, 37, + /* 770 */ 295, 1725, 1258, 1725, 1725, 602, 326, 1725, 1236, 405, + /* 780 */ 464, 1847, 417, 311, 1445, 309, 308, 1668, 462, 1311, + /* 790 */ 305, 1234, 464, 1263, 129, 128, 599, 598, 597, 390, + /* 800 */ 58, 418, 463, 392, 567, 1842, 620, 618, 553, 567, + /* 810 */ 1260, 567, 1306, 567, 463, 398, 567, 1444, 567, 1671, + /* 820 */ 438, 1242, 1570, 1713, 1702, 1725, 1443, 498, 1755, 502, + /* 830 */ 534, 567, 1573, 383, 1625, 990, 991, 1573, 2, 1573, + /* 840 */ 267, 1573, 564, 1603, 1573, 537, 1573, 33, 32, 1560, + /* 850 */ 1624, 40, 38, 36, 35, 34, 1773, 137, 1725, 1573, + /* 860 */ 649, 608, 601, 1545, 550, 1616, 1556, 1725, 1442, 1725, + /* 870 */ 352, 549, 1491, 416, 1313, 1314, 411, 410, 409, 408, + /* 880 */ 407, 404, 403, 402, 401, 400, 396, 395, 394, 393, + /* 890 */ 387, 386, 385, 384, 475, 381, 380, 1786, 299, 1245, + /* 900 */ 88, 1756, 552, 1758, 1759, 548, 567, 570, 208, 1725, + /* 910 */ 1832, 1852, 1367, 1486, 319, 1828, 1912, 565, 188, 1237, + /* 920 */ 205, 1235, 1274, 212, 544, 1867, 193, 619, 195, 191, + /* 930 */ 1333, 194, 144, 1370, 1573, 477, 72, 456, 452, 448, + /* 940 */ 444, 187, 197, 1240, 1241, 196, 1289, 1290, 1292, 1293, + /* 950 */ 1294, 1295, 1296, 545, 568, 1304, 1305, 1307, 1308, 1309, + /* 960 */ 1310, 1312, 1315, 139, 567, 567, 70, 367, 273, 185, + /* 970 */ 52, 501, 595, 50, 199, 256, 340, 198, 1484, 542, + /* 980 */ 216, 1291, 271, 57, 1334, 1452, 56, 1531, 11, 10, + /* 990 */ 513, 235, 1573, 1573, 1434, 1435, 41, 41, 457, 41, + /* 1000 */ 480, 242, 171, 123, 126, 127, 491, 1339, 223, 1244, + /* 1010 */ 1027, 33, 32, 1393, 1774, 40, 38, 36, 35, 34, + /* 1020 */ 218, 342, 1475, 50, 575, 535, 126, 60, 127, 1248, + /* 1030 */ 526, 184, 177, 532, 182, 1613, 1341, 1297, 435, 1186, + /* 1040 */ 1028, 247, 538, 559, 253, 1086, 29, 324, 1328, 1329, + /* 1050 */ 1330, 1331, 1332, 1336, 1337, 1338, 112, 175, 119, 126, + /* 1060 */ 527, 1863, 299, 266, 1114, 86, 1118, 234, 1125, 5, + /* 1070 */ 3, 237, 239, 344, 1258, 347, 351, 306, 1055, 307, + /* 1080 */ 530, 263, 1202, 399, 167, 1665, 406, 414, 413, 419, + /* 1090 */ 1264, 415, 420, 428, 1333, 1267, 1123, 431, 117, 130, + /* 1100 */ 64, 63, 376, 432, 1266, 165, 174, 1325, 1755, 176, + /* 1110 */ 433, 370, 1268, 229, 1840, 525, 434, 524, 179, 436, + /* 1120 */ 1899, 1265, 294, 181, 183, 360, 68, 358, 354, 350, + /* 1130 */ 162, 345, 437, 186, 158, 440, 1773, 459, 1896, 1247, + /* 1140 */ 1707, 461, 91, 1563, 550, 297, 190, 1559, 1334, 1725, + /* 1150 */ 192, 549, 132, 264, 133, 203, 1561, 492, 1557, 134, + /* 1160 */ 135, 1755, 206, 493, 159, 499, 530, 503, 210, 1263, + /* 1170 */ 514, 1339, 1874, 316, 1864, 556, 496, 1786, 1873, 6, + /* 1180 */ 87, 1756, 552, 1758, 1759, 548, 1854, 570, 509, 1773, + /* 1190 */ 1832, 214, 511, 523, 298, 1828, 217, 550, 510, 508, + /* 1200 */ 146, 318, 1725, 1755, 549, 517, 1899, 224, 222, 225, + /* 1210 */ 29, 324, 1328, 1329, 1330, 1331, 1332, 1336, 1337, 1338, + /* 1220 */ 156, 507, 227, 1367, 1896, 118, 1262, 44, 539, 536, + /* 1230 */ 1786, 1773, 1848, 88, 1756, 552, 1758, 1759, 548, 550, + /* 1240 */ 570, 226, 228, 1832, 1725, 18, 549, 319, 1828, 1912, + /* 1250 */ 333, 332, 320, 1813, 560, 561, 1915, 1895, 1890, 249, + /* 1260 */ 1250, 533, 233, 236, 124, 540, 554, 555, 238, 125, + /* 1270 */ 1706, 1311, 1786, 1243, 251, 88, 1756, 552, 1758, 1759, + /* 1280 */ 548, 1755, 570, 265, 1675, 1832, 562, 557, 328, 319, + /* 1290 */ 1828, 1912, 79, 77, 1306, 1617, 1574, 573, 1546, 268, + /* 1300 */ 1851, 645, 646, 1242, 259, 648, 145, 289, 1755, 1773, + /* 1310 */ 51, 291, 290, 270, 272, 1719, 1718, 550, 62, 1717, + /* 1320 */ 1714, 346, 1725, 348, 549, 349, 1229, 1230, 163, 353, + /* 1330 */ 1712, 355, 356, 357, 1711, 359, 1773, 1710, 361, 530, + /* 1340 */ 1709, 1708, 571, 363, 550, 365, 1692, 368, 164, 1725, + /* 1350 */ 1786, 549, 1205, 280, 1756, 552, 1758, 1759, 548, 369, + /* 1360 */ 570, 1204, 1686, 1685, 374, 375, 530, 1684, 1683, 1174, + /* 1370 */ 1658, 1657, 1656, 65, 1655, 1654, 1755, 1786, 1653, 1899, + /* 1380 */ 280, 1756, 552, 1758, 1759, 548, 1652, 570, 1651, 388, + /* 1390 */ 389, 1650, 391, 158, 1649, 1648, 1647, 1896, 1646, 1645, + /* 1400 */ 1644, 1251, 1643, 1246, 1773, 1176, 1899, 1642, 1641, 1640, + /* 1410 */ 1639, 1638, 550, 1637, 1636, 122, 1635, 1725, 1755, 549, + /* 1420 */ 156, 1634, 1633, 1632, 1896, 1254, 1631, 1630, 1629, 1628, + /* 1430 */ 1627, 1626, 1503, 1471, 172, 424, 568, 1304, 1305, 1307, + /* 1440 */ 1308, 1309, 1310, 1755, 150, 1786, 1773, 1021, 89, 1756, + /* 1450 */ 552, 1758, 1759, 548, 547, 570, 113, 993, 1832, 1725, + /* 1460 */ 992, 549, 541, 1828, 426, 1470, 1700, 1694, 1682, 1681, + /* 1470 */ 1667, 1773, 180, 1552, 173, 114, 178, 1502, 1500, 550, + /* 1480 */ 526, 443, 442, 441, 1725, 1498, 549, 1786, 445, 447, + /* 1490 */ 287, 1756, 552, 1758, 1759, 548, 546, 570, 543, 1804, + /* 1500 */ 1755, 446, 1496, 450, 1494, 454, 449, 1483, 119, 453, + /* 1510 */ 1482, 451, 1786, 189, 455, 142, 1756, 552, 1758, 1759, + /* 1520 */ 548, 1467, 570, 1554, 1129, 1128, 1553, 1054, 1773, 49, + /* 1530 */ 530, 1053, 1052, 1051, 617, 1048, 550, 619, 1492, 312, + /* 1540 */ 1047, 1725, 1487, 549, 1046, 1485, 313, 314, 117, 481, + /* 1550 */ 478, 1466, 1465, 483, 485, 1464, 487, 1755, 1699, 90, + /* 1560 */ 531, 1913, 53, 229, 1840, 525, 1212, 524, 1693, 1786, + /* 1570 */ 1899, 494, 89, 1756, 552, 1758, 1759, 548, 1755, 570, + /* 1580 */ 1680, 1678, 1832, 1679, 156, 1773, 207, 1829, 1896, 136, + /* 1590 */ 495, 315, 1677, 550, 1676, 1408, 500, 4, 1725, 41, + /* 1600 */ 549, 45, 15, 215, 23, 47, 1773, 220, 25, 213, + /* 1610 */ 46, 1392, 506, 1385, 550, 143, 16, 219, 24, 1725, + /* 1620 */ 221, 549, 1745, 74, 230, 147, 1786, 1364, 17, 288, + /* 1630 */ 1756, 552, 1758, 1759, 548, 1755, 570, 1420, 13, 1419, + /* 1640 */ 1363, 321, 1425, 1414, 1424, 1423, 322, 1786, 10, 1326, + /* 1650 */ 283, 1756, 552, 1758, 1759, 548, 19, 570, 1755, 1282, + /* 1660 */ 1299, 148, 160, 1773, 31, 551, 1674, 1298, 12, 20, + /* 1670 */ 21, 550, 241, 1390, 1666, 243, 1725, 248, 549, 75, + /* 1680 */ 558, 250, 76, 252, 1744, 255, 1773, 1789, 80, 522, + /* 1690 */ 1301, 1252, 572, 574, 550, 1115, 569, 335, 578, 1725, + /* 1700 */ 1755, 549, 48, 576, 1786, 1112, 579, 142, 1756, 552, + /* 1710 */ 1758, 1759, 548, 323, 570, 1109, 1755, 581, 582, 584, + /* 1720 */ 587, 1092, 594, 1103, 1101, 585, 588, 1786, 1773, 1107, + /* 1730 */ 288, 1756, 552, 1758, 1759, 548, 547, 570, 81, 1106, + /* 1740 */ 1105, 1725, 82, 549, 1773, 1124, 59, 257, 1120, 1019, + /* 1750 */ 603, 1104, 550, 1914, 1043, 606, 258, 1725, 1061, 549, + /* 1760 */ 1041, 1036, 1040, 1039, 1038, 1037, 1755, 1035, 1034, 1786, + /* 1770 */ 1058, 325, 287, 1756, 552, 1758, 1759, 548, 1056, 570, + /* 1780 */ 1031, 1805, 1030, 1029, 1026, 1786, 1025, 1024, 288, 1756, + /* 1790 */ 552, 1758, 1759, 548, 1773, 570, 652, 1499, 627, 629, + /* 1800 */ 628, 1497, 550, 631, 632, 633, 1495, 1725, 635, 549, + /* 1810 */ 262, 636, 1493, 637, 639, 641, 640, 1481, 643, 983, + /* 1820 */ 1463, 327, 261, 1755, 149, 647, 1438, 1238, 650, 642, + /* 1830 */ 638, 634, 630, 260, 1438, 1786, 269, 1438, 288, 1756, + /* 1840 */ 552, 1758, 1759, 548, 651, 570, 1438, 1438, 1438, 1438, + /* 1850 */ 1438, 1773, 1438, 1438, 1438, 1438, 1438, 1438, 85, 550, + /* 1860 */ 1438, 254, 1438, 1438, 1725, 1438, 549, 1438, 1438, 1438, + /* 1870 */ 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, + /* 1880 */ 1438, 1438, 1438, 1438, 1755, 1438, 1438, 1438, 1438, 1438, + /* 1890 */ 1438, 1438, 1786, 1438, 563, 274, 1756, 552, 1758, 1759, + /* 1900 */ 548, 1755, 570, 1438, 1438, 1438, 1438, 1438, 1438, 1438, + /* 1910 */ 1438, 1438, 1773, 1438, 1438, 1438, 1438, 1438, 1438, 1438, + /* 1920 */ 550, 1438, 1438, 1438, 1438, 1725, 211, 549, 1438, 1773, + /* 1930 */ 1438, 1438, 1438, 1438, 1438, 1438, 1438, 550, 1438, 1438, + /* 1940 */ 1438, 1438, 1725, 1755, 549, 1438, 1438, 1210, 1438, 204, + /* 1950 */ 1438, 1438, 1438, 1786, 1755, 1438, 275, 1756, 552, 1758, + /* 1960 */ 1759, 548, 1438, 570, 1438, 1755, 1438, 1438, 1438, 1438, + /* 1970 */ 1786, 1773, 1438, 276, 1756, 552, 1758, 1759, 548, 550, + /* 1980 */ 570, 1438, 1773, 1438, 1725, 1438, 549, 1438, 1438, 1438, + /* 1990 */ 550, 1438, 1438, 1773, 1438, 1725, 1438, 549, 1438, 1438, + /* 2000 */ 1438, 550, 1438, 1438, 1438, 1438, 1725, 1755, 549, 1438, + /* 2010 */ 1438, 1438, 1786, 1438, 1438, 282, 1756, 552, 1758, 1759, + /* 2020 */ 548, 1438, 570, 1786, 1438, 1755, 284, 1756, 552, 1758, + /* 2030 */ 1759, 548, 1438, 570, 1786, 1773, 1438, 277, 1756, 552, + /* 2040 */ 1758, 1759, 548, 550, 570, 1438, 1438, 1438, 1725, 1755, + /* 2050 */ 549, 1438, 1438, 1773, 1438, 1438, 1438, 1438, 1438, 1438, + /* 2060 */ 1438, 550, 1438, 1438, 1438, 1438, 1725, 1438, 549, 1438, + /* 2070 */ 1438, 1438, 1438, 1438, 1438, 1438, 1786, 1773, 1438, 285, + /* 2080 */ 1756, 552, 1758, 1759, 548, 550, 570, 1438, 1438, 1438, + /* 2090 */ 1725, 1438, 549, 1438, 1786, 1438, 1438, 278, 1756, 552, + /* 2100 */ 1758, 1759, 548, 1438, 570, 1755, 1438, 1438, 1438, 1438, + /* 2110 */ 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1786, 1438, + /* 2120 */ 1438, 286, 1756, 552, 1758, 1759, 548, 1438, 570, 1438, + /* 2130 */ 1438, 1438, 1438, 1773, 1438, 1438, 1438, 1438, 1438, 1438, + /* 2140 */ 1438, 550, 1438, 1438, 1438, 1438, 1725, 1438, 549, 1438, + /* 2150 */ 1438, 1438, 1438, 1438, 1438, 1755, 1438, 1438, 1438, 1438, + /* 2160 */ 1438, 1438, 1438, 1438, 1438, 1438, 1755, 1438, 1438, 1438, + /* 2170 */ 1438, 1438, 1438, 1438, 1786, 1438, 1438, 279, 1756, 552, + /* 2180 */ 1758, 1759, 548, 1773, 570, 1438, 1438, 1438, 1438, 1438, + /* 2190 */ 1438, 550, 1438, 1438, 1773, 1438, 1725, 1438, 549, 1438, + /* 2200 */ 1438, 1438, 550, 1438, 1438, 1438, 1438, 1725, 1755, 549, + /* 2210 */ 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1755, + /* 2220 */ 1438, 1438, 1438, 1438, 1786, 1438, 1438, 292, 1756, 552, + /* 2230 */ 1758, 1759, 548, 1755, 570, 1786, 1773, 1438, 293, 1756, + /* 2240 */ 552, 1758, 1759, 548, 550, 570, 1438, 1773, 1438, 1725, + /* 2250 */ 1438, 549, 1438, 1438, 1438, 550, 1438, 1438, 1438, 1438, + /* 2260 */ 1725, 1773, 549, 1438, 1438, 1438, 1438, 1438, 1438, 550, + /* 2270 */ 1438, 1438, 1438, 1438, 1725, 1438, 549, 1786, 1438, 1438, + /* 2280 */ 1767, 1756, 552, 1758, 1759, 548, 1438, 570, 1786, 1755, + /* 2290 */ 1438, 1766, 1756, 552, 1758, 1759, 548, 1438, 570, 1438, + /* 2300 */ 1438, 1438, 1786, 1755, 1438, 1765, 1756, 552, 1758, 1759, + /* 2310 */ 548, 1438, 570, 1438, 1438, 1438, 1438, 1773, 1438, 1438, + /* 2320 */ 1438, 1438, 1438, 1438, 1438, 550, 1438, 1438, 1438, 1438, + /* 2330 */ 1725, 1773, 549, 1438, 1438, 1438, 1438, 1438, 1438, 550, + /* 2340 */ 1438, 1438, 1438, 1438, 1725, 1438, 549, 1438, 1438, 1438, + /* 2350 */ 1438, 1438, 1438, 1755, 1438, 1438, 1438, 1438, 1786, 1438, + /* 2360 */ 1438, 302, 1756, 552, 1758, 1759, 548, 1438, 570, 1438, + /* 2370 */ 1438, 1438, 1786, 1438, 1438, 301, 1756, 552, 1758, 1759, + /* 2380 */ 548, 1773, 570, 1438, 1438, 1438, 1438, 1438, 1438, 550, + /* 2390 */ 1438, 1438, 1438, 1438, 1725, 1755, 549, 1438, 1438, 1438, + /* 2400 */ 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1755, + /* 2410 */ 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, 1438, + /* 2420 */ 1438, 1438, 1786, 1773, 1438, 303, 1756, 552, 1758, 1759, + /* 2430 */ 548, 550, 570, 1438, 1438, 1438, 1725, 1773, 549, 1438, + /* 2440 */ 1438, 1438, 1438, 1438, 1438, 550, 1438, 1438, 1438, 1438, + /* 2450 */ 1725, 1438, 549, 1438, 1438, 1438, 1438, 1438, 1438, 1438, + /* 2460 */ 1438, 1438, 1438, 1438, 1786, 1438, 1438, 300, 1756, 552, + /* 2470 */ 1758, 1759, 548, 1438, 570, 1438, 1438, 1438, 1786, 1438, + /* 2480 */ 1438, 281, 1756, 552, 1758, 1759, 548, 1438, 570, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 253, 0, 255, 256, 253, 279, 255, 256, 282, 347, - /* 10 */ 262, 246, 12, 13, 266, 307, 290, 261, 279, 278, - /* 20 */ 20, 0, 22, 361, 257, 279, 14, 365, 282, 290, - /* 30 */ 274, 248, 20, 250, 249, 35, 290, 288, 20, 283, - /* 40 */ 291, 292, 21, 317, 318, 24, 25, 26, 27, 28, - /* 50 */ 29, 30, 31, 32, 328, 347, 317, 318, 4, 59, - /* 60 */ 14, 294, 277, 317, 318, 65, 20, 328, 277, 361, - /* 70 */ 285, 20, 307, 365, 328, 290, 285, 292, 12, 13, - /* 80 */ 14, 14, 82, 307, 20, 22, 20, 20, 22, 8, - /* 90 */ 9, 58, 307, 12, 13, 14, 15, 16, 35, 249, - /* 100 */ 82, 35, 276, 318, 104, 20, 321, 322, 323, 324, - /* 110 */ 325, 326, 347, 328, 323, 289, 331, 261, 118, 119, - /* 120 */ 335, 336, 82, 347, 20, 59, 361, 277, 65, 347, - /* 130 */ 365, 65, 347, 257, 257, 285, 82, 361, 257, 283, - /* 140 */ 290, 365, 292, 361, 268, 268, 361, 365, 82, 21, - /* 150 */ 365, 275, 24, 25, 26, 27, 28, 29, 30, 31, - /* 160 */ 32, 285, 285, 163, 83, 165, 285, 104, 318, 58, - /* 170 */ 104, 321, 322, 323, 324, 325, 326, 327, 328, 329, - /* 180 */ 330, 145, 118, 119, 118, 119, 249, 187, 188, 43, + /* 0 */ 261, 257, 250, 259, 260, 283, 0, 257, 286, 259, + /* 10 */ 260, 272, 12, 13, 0, 252, 294, 254, 279, 265, + /* 20 */ 20, 0, 22, 283, 21, 280, 286, 261, 289, 283, + /* 30 */ 20, 20, 278, 33, 294, 35, 323, 34, 293, 36, + /* 40 */ 294, 287, 21, 321, 322, 24, 25, 26, 27, 28, + /* 50 */ 29, 30, 31, 32, 332, 289, 56, 281, 253, 59, + /* 60 */ 347, 321, 322, 311, 288, 65, 311, 321, 322, 12, + /* 70 */ 13, 14, 332, 297, 20, 61, 62, 20, 332, 22, + /* 80 */ 66, 323, 82, 69, 70, 296, 281, 73, 74, 75, + /* 90 */ 33, 281, 35, 304, 289, 329, 307, 261, 288, 294, + /* 100 */ 253, 296, 311, 351, 104, 347, 351, 297, 272, 343, + /* 110 */ 344, 345, 346, 56, 348, 279, 59, 365, 118, 119, + /* 120 */ 365, 369, 65, 0, 369, 289, 0, 322, 118, 119, + /* 130 */ 325, 326, 327, 328, 329, 330, 82, 332, 263, 82, + /* 140 */ 335, 294, 351, 56, 339, 340, 341, 24, 25, 26, + /* 150 */ 27, 28, 29, 30, 31, 32, 365, 58, 353, 284, + /* 160 */ 369, 104, 0, 163, 266, 165, 361, 362, 270, 82, + /* 170 */ 20, 84, 61, 62, 48, 118, 119, 66, 283, 292, + /* 180 */ 69, 70, 295, 296, 73, 74, 75, 187, 188, 294, /* 190 */ 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, - /* 200 */ 200, 201, 202, 191, 168, 56, 325, 18, 319, 20, - /* 210 */ 12, 13, 14, 15, 16, 215, 27, 0, 65, 30, - /* 220 */ 339, 340, 341, 342, 257, 344, 163, 290, 165, 163, - /* 230 */ 81, 165, 343, 84, 187, 268, 47, 191, 49, 203, - /* 240 */ 51, 24, 25, 26, 27, 28, 29, 30, 31, 32, - /* 250 */ 187, 188, 285, 187, 188, 215, 190, 191, 192, 193, - /* 260 */ 194, 195, 196, 197, 198, 199, 200, 201, 202, 215, - /* 270 */ 81, 224, 225, 226, 227, 228, 8, 9, 12, 13, - /* 280 */ 12, 13, 14, 15, 16, 20, 20, 265, 22, 267, - /* 290 */ 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, - /* 300 */ 105, 35, 107, 108, 109, 110, 111, 112, 1, 2, - /* 310 */ 121, 43, 20, 124, 125, 126, 127, 128, 129, 130, - /* 320 */ 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, - /* 330 */ 141, 65, 143, 144, 12, 13, 249, 20, 37, 332, - /* 340 */ 333, 20, 20, 22, 22, 8, 9, 56, 82, 12, - /* 350 */ 13, 14, 15, 16, 61, 62, 35, 35, 279, 66, - /* 360 */ 4, 20, 69, 70, 277, 257, 73, 74, 75, 290, - /* 370 */ 104, 50, 285, 82, 82, 84, 268, 290, 93, 292, - /* 380 */ 234, 59, 311, 275, 118, 119, 85, 65, 87, 88, - /* 390 */ 83, 90, 76, 285, 307, 94, 317, 318, 148, 4, - /* 400 */ 44, 45, 347, 249, 82, 318, 250, 328, 321, 322, - /* 410 */ 323, 324, 325, 326, 19, 328, 361, 116, 331, 257, - /* 420 */ 365, 257, 335, 336, 259, 292, 104, 0, 33, 163, - /* 430 */ 268, 165, 268, 300, 347, 65, 303, 272, 122, 123, - /* 440 */ 118, 119, 47, 249, 290, 280, 51, 285, 361, 285, - /* 450 */ 307, 56, 365, 187, 188, 278, 190, 191, 192, 193, - /* 460 */ 194, 195, 196, 197, 198, 199, 200, 201, 202, 269, - /* 470 */ 220, 221, 12, 13, 14, 254, 81, 277, 257, 84, - /* 480 */ 20, 215, 22, 257, 290, 163, 286, 165, 61, 62, - /* 490 */ 347, 150, 155, 66, 268, 35, 69, 70, 257, 266, - /* 500 */ 73, 74, 75, 257, 361, 3, 215, 215, 365, 187, - /* 510 */ 188, 285, 190, 191, 192, 193, 194, 195, 196, 197, - /* 520 */ 198, 199, 200, 201, 202, 65, 285, 12, 13, 291, - /* 530 */ 292, 285, 257, 158, 20, 20, 249, 22, 44, 45, - /* 540 */ 8, 9, 82, 268, 12, 13, 14, 15, 16, 114, - /* 550 */ 35, 8, 9, 178, 179, 12, 13, 14, 15, 16, - /* 560 */ 285, 257, 254, 249, 104, 257, 325, 269, 20, 249, - /* 570 */ 22, 325, 268, 302, 237, 277, 305, 290, 118, 119, - /* 580 */ 65, 340, 341, 342, 286, 344, 340, 341, 342, 285, - /* 590 */ 344, 277, 94, 12, 13, 368, 257, 82, 50, 285, - /* 600 */ 249, 20, 249, 22, 290, 94, 292, 268, 173, 174, - /* 610 */ 290, 113, 114, 115, 116, 117, 35, 257, 304, 104, - /* 620 */ 263, 264, 0, 163, 285, 165, 83, 116, 268, 14, - /* 630 */ 15, 16, 318, 118, 119, 321, 322, 323, 324, 325, - /* 640 */ 326, 290, 328, 290, 22, 285, 65, 187, 188, 35, - /* 650 */ 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, - /* 660 */ 200, 201, 202, 82, 150, 257, 257, 8, 9, 20, - /* 670 */ 257, 12, 13, 14, 15, 16, 268, 268, 163, 65, - /* 680 */ 165, 268, 8, 9, 285, 104, 12, 13, 14, 15, - /* 690 */ 16, 263, 264, 285, 285, 296, 213, 214, 285, 118, - /* 700 */ 119, 0, 187, 188, 278, 190, 191, 192, 193, 194, - /* 710 */ 195, 196, 197, 198, 199, 200, 201, 202, 59, 82, - /* 720 */ 257, 8, 9, 19, 269, 12, 13, 14, 15, 16, - /* 730 */ 278, 268, 277, 59, 232, 278, 277, 33, 257, 0, - /* 740 */ 21, 286, 83, 284, 163, 249, 165, 277, 285, 268, - /* 750 */ 91, 47, 293, 34, 284, 36, 52, 53, 54, 55, - /* 760 */ 56, 113, 249, 293, 0, 91, 285, 249, 187, 188, - /* 770 */ 249, 190, 191, 192, 193, 194, 195, 196, 197, 198, - /* 780 */ 199, 200, 201, 202, 277, 81, 290, 18, 84, 292, - /* 790 */ 277, 249, 23, 286, 4, 94, 83, 58, 285, 162, - /* 800 */ 303, 164, 257, 290, 145, 292, 37, 38, 290, 319, - /* 810 */ 41, 290, 278, 268, 113, 114, 115, 116, 117, 145, - /* 820 */ 249, 117, 58, 175, 176, 302, 57, 168, 305, 277, - /* 830 */ 285, 318, 290, 343, 321, 322, 323, 324, 325, 326, - /* 840 */ 191, 328, 168, 0, 331, 293, 249, 249, 335, 336, - /* 850 */ 337, 82, 215, 149, 259, 0, 39, 278, 249, 346, - /* 860 */ 249, 290, 203, 204, 205, 206, 207, 208, 209, 210, - /* 870 */ 211, 212, 113, 114, 170, 280, 172, 203, 204, 205, - /* 880 */ 206, 207, 208, 209, 210, 211, 212, 290, 290, 120, - /* 890 */ 8, 9, 359, 249, 12, 13, 14, 15, 16, 290, - /* 900 */ 249, 290, 47, 249, 61, 62, 63, 64, 319, 66, - /* 910 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - /* 920 */ 77, 78, 79, 43, 155, 156, 157, 249, 277, 160, - /* 930 */ 56, 59, 343, 174, 290, 166, 285, 12, 13, 287, - /* 940 */ 43, 290, 290, 292, 290, 287, 177, 22, 290, 180, - /* 950 */ 35, 182, 183, 184, 185, 186, 270, 258, 84, 273, - /* 960 */ 35, 249, 86, 83, 86, 89, 354, 89, 290, 318, - /* 970 */ 0, 0, 321, 322, 323, 324, 325, 326, 86, 328, - /* 980 */ 86, 89, 331, 89, 215, 0, 335, 336, 337, 277, - /* 990 */ 65, 150, 151, 22, 1, 2, 35, 285, 314, 43, - /* 1000 */ 349, 277, 290, 82, 292, 2, 216, 22, 357, 358, - /* 1010 */ 46, 8, 9, 92, 2, 12, 13, 14, 15, 16, - /* 1020 */ 8, 9, 249, 258, 12, 13, 14, 15, 16, 104, - /* 1030 */ 318, 214, 150, 321, 322, 323, 324, 325, 326, 83, - /* 1040 */ 328, 118, 119, 331, 256, 289, 82, 335, 336, 337, - /* 1050 */ 277, 320, 43, 43, 345, 362, 362, 362, 285, 187, - /* 1060 */ 43, 217, 43, 290, 94, 292, 43, 316, 348, 20, - /* 1070 */ 358, 43, 257, 47, 43, 43, 43, 249, 315, 35, - /* 1080 */ 165, 43, 43, 113, 114, 115, 116, 117, 163, 0, - /* 1090 */ 165, 318, 83, 83, 321, 322, 323, 324, 325, 326, - /* 1100 */ 83, 328, 83, 43, 331, 277, 83, 43, 335, 336, - /* 1110 */ 337, 83, 187, 285, 83, 83, 83, 263, 290, 346, - /* 1120 */ 292, 83, 83, 198, 199, 200, 165, 161, 43, 309, - /* 1130 */ 249, 35, 257, 236, 257, 42, 297, 48, 20, 249, - /* 1140 */ 145, 295, 295, 83, 257, 20, 318, 83, 313, 321, - /* 1150 */ 322, 323, 324, 325, 326, 251, 328, 249, 277, 331, - /* 1160 */ 251, 65, 261, 335, 336, 337, 285, 277, 83, 20, - /* 1170 */ 306, 290, 261, 292, 346, 285, 292, 20, 308, 261, - /* 1180 */ 290, 261, 292, 20, 298, 277, 251, 261, 307, 306, - /* 1190 */ 261, 257, 261, 285, 277, 257, 277, 307, 290, 318, - /* 1200 */ 292, 277, 321, 322, 323, 324, 325, 326, 318, 328, - /* 1210 */ 277, 321, 322, 323, 324, 325, 326, 277, 328, 277, - /* 1220 */ 277, 277, 249, 277, 277, 277, 318, 251, 347, 321, - /* 1230 */ 322, 323, 324, 325, 326, 290, 328, 347, 249, 331, - /* 1240 */ 313, 259, 361, 335, 336, 171, 365, 249, 312, 292, - /* 1250 */ 277, 361, 20, 259, 257, 365, 257, 306, 285, 259, - /* 1260 */ 223, 320, 290, 290, 222, 292, 277, 353, 301, 290, - /* 1270 */ 301, 290, 229, 290, 285, 277, 154, 231, 356, 290, - /* 1280 */ 352, 292, 230, 285, 218, 353, 214, 285, 290, 350, - /* 1290 */ 292, 318, 355, 316, 321, 322, 323, 324, 325, 326, - /* 1300 */ 249, 328, 353, 351, 331, 20, 319, 318, 335, 336, - /* 1310 */ 321, 322, 323, 324, 325, 326, 318, 328, 42, 321, - /* 1320 */ 322, 323, 324, 325, 326, 235, 328, 364, 277, 331, - /* 1330 */ 33, 233, 238, 82, 336, 301, 285, 363, 363, 338, - /* 1340 */ 334, 290, 301, 292, 47, 290, 290, 369, 364, 52, - /* 1350 */ 53, 54, 55, 56, 249, 366, 367, 290, 290, 290, - /* 1360 */ 364, 290, 147, 249, 299, 285, 259, 363, 298, 318, - /* 1370 */ 273, 259, 321, 322, 323, 324, 325, 326, 81, 328, - /* 1380 */ 285, 84, 277, 82, 281, 257, 267, 36, 259, 290, - /* 1390 */ 285, 277, 252, 251, 310, 290, 305, 292, 271, 285, - /* 1400 */ 247, 271, 271, 260, 290, 0, 292, 0, 42, 0, - /* 1410 */ 73, 360, 35, 249, 0, 181, 35, 35, 304, 35, - /* 1420 */ 181, 0, 35, 318, 249, 35, 321, 322, 323, 324, - /* 1430 */ 325, 326, 318, 328, 181, 321, 322, 323, 324, 325, - /* 1440 */ 326, 277, 328, 146, 147, 0, 149, 181, 0, 285, - /* 1450 */ 153, 35, 277, 0, 290, 22, 292, 0, 35, 0, - /* 1460 */ 285, 82, 168, 167, 165, 290, 163, 292, 0, 172, - /* 1470 */ 0, 159, 367, 158, 0, 0, 249, 46, 0, 304, - /* 1480 */ 0, 0, 318, 142, 0, 321, 322, 323, 324, 325, - /* 1490 */ 326, 0, 328, 318, 330, 0, 321, 322, 323, 324, - /* 1500 */ 325, 326, 0, 328, 277, 0, 137, 35, 0, 137, - /* 1510 */ 0, 0, 285, 0, 0, 0, 0, 290, 0, 292, - /* 1520 */ 0, 0, 0, 0, 0, 0, 0, 42, 0, 249, - /* 1530 */ 0, 304, 0, 0, 0, 0, 0, 0, 249, 22, - /* 1540 */ 0, 0, 0, 0, 43, 318, 42, 249, 321, 322, - /* 1550 */ 323, 324, 325, 326, 0, 328, 0, 277, 39, 14, - /* 1560 */ 14, 0, 0, 0, 154, 285, 277, 0, 0, 40, - /* 1570 */ 290, 0, 292, 46, 285, 277, 0, 46, 39, 290, - /* 1580 */ 0, 292, 0, 285, 0, 35, 39, 39, 290, 0, - /* 1590 */ 292, 47, 35, 0, 39, 35, 0, 0, 318, 249, - /* 1600 */ 47, 321, 322, 323, 324, 325, 326, 318, 328, 39, - /* 1610 */ 321, 322, 323, 324, 325, 326, 318, 328, 35, 321, - /* 1620 */ 322, 323, 324, 325, 326, 60, 328, 277, 47, 91, - /* 1630 */ 39, 22, 47, 35, 0, 285, 35, 35, 35, 35, - /* 1640 */ 290, 249, 292, 43, 0, 35, 35, 35, 89, 43, - /* 1650 */ 22, 0, 22, 0, 49, 22, 35, 0, 35, 0, - /* 1660 */ 35, 249, 0, 22, 0, 20, 35, 0, 318, 277, - /* 1670 */ 22, 321, 322, 323, 324, 325, 326, 285, 328, 0, - /* 1680 */ 0, 169, 290, 249, 292, 0, 0, 0, 219, 277, - /* 1690 */ 43, 35, 43, 43, 2, 82, 82, 285, 83, 147, - /* 1700 */ 82, 150, 290, 83, 292, 83, 82, 46, 82, 43, - /* 1710 */ 318, 277, 83, 321, 322, 323, 324, 325, 326, 285, - /* 1720 */ 328, 152, 150, 150, 290, 82, 292, 46, 219, 83, - /* 1730 */ 318, 43, 43, 321, 322, 323, 324, 325, 326, 249, - /* 1740 */ 328, 83, 46, 46, 43, 35, 83, 35, 249, 35, - /* 1750 */ 35, 83, 318, 35, 43, 321, 322, 323, 324, 325, - /* 1760 */ 326, 187, 328, 46, 22, 83, 82, 277, 46, 0, - /* 1770 */ 0, 39, 46, 83, 83, 285, 277, 213, 83, 189, - /* 1780 */ 290, 82, 292, 148, 285, 219, 82, 82, 82, 290, - /* 1790 */ 82, 292, 92, 46, 22, 82, 93, 35, 249, 83, - /* 1800 */ 146, 82, 82, 82, 106, 82, 35, 249, 318, 35, - /* 1810 */ 83, 321, 322, 323, 324, 325, 326, 318, 328, 82, - /* 1820 */ 321, 322, 323, 324, 325, 326, 277, 328, 83, 83, - /* 1830 */ 82, 35, 82, 35, 285, 277, 35, 83, 82, 290, - /* 1840 */ 83, 292, 82, 285, 106, 106, 22, 106, 290, 94, - /* 1850 */ 292, 35, 43, 22, 60, 82, 59, 249, 82, 82, - /* 1860 */ 35, 80, 43, 35, 65, 35, 249, 318, 35, 35, - /* 1870 */ 321, 322, 323, 324, 325, 326, 318, 328, 35, 321, - /* 1880 */ 322, 323, 324, 325, 326, 277, 328, 22, 35, 35, - /* 1890 */ 35, 65, 35, 285, 277, 35, 35, 35, 290, 35, - /* 1900 */ 292, 35, 285, 0, 35, 47, 39, 290, 0, 292, - /* 1910 */ 35, 39, 0, 35, 0, 47, 39, 47, 249, 35, - /* 1920 */ 47, 39, 0, 35, 35, 0, 318, 249, 22, 321, - /* 1930 */ 322, 323, 324, 325, 326, 318, 328, 21, 321, 322, - /* 1940 */ 323, 324, 325, 326, 21, 328, 277, 370, 22, 22, - /* 1950 */ 20, 370, 370, 370, 285, 277, 370, 370, 370, 290, - /* 1960 */ 370, 292, 370, 285, 370, 370, 370, 370, 290, 370, - /* 1970 */ 292, 370, 370, 370, 370, 370, 370, 370, 370, 370, - /* 1980 */ 249, 370, 370, 370, 370, 370, 370, 318, 370, 249, - /* 1990 */ 321, 322, 323, 324, 325, 326, 318, 328, 249, 321, - /* 2000 */ 322, 323, 324, 325, 326, 370, 328, 249, 277, 370, - /* 2010 */ 257, 370, 370, 370, 370, 370, 285, 277, 370, 370, - /* 2020 */ 370, 290, 370, 292, 370, 285, 277, 370, 370, 370, - /* 2030 */ 290, 370, 292, 370, 285, 277, 370, 370, 285, 290, - /* 2040 */ 370, 292, 370, 285, 370, 370, 370, 370, 290, 318, - /* 2050 */ 292, 370, 321, 322, 323, 324, 325, 326, 318, 328, - /* 2060 */ 307, 321, 322, 323, 324, 325, 326, 318, 328, 370, - /* 2070 */ 321, 322, 323, 324, 325, 326, 318, 328, 325, 321, - /* 2080 */ 322, 323, 324, 325, 326, 249, 328, 370, 370, 370, - /* 2090 */ 370, 370, 370, 340, 341, 342, 370, 344, 370, 257, - /* 2100 */ 347, 370, 370, 370, 370, 370, 370, 370, 370, 370, - /* 2110 */ 370, 370, 370, 277, 361, 370, 370, 370, 365, 370, - /* 2120 */ 370, 285, 370, 370, 370, 370, 290, 285, 292, 370, - /* 2130 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - /* 2140 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 307, - /* 2150 */ 370, 370, 370, 370, 318, 370, 370, 321, 322, 323, - /* 2160 */ 324, 325, 326, 370, 328, 370, 370, 325, 370, 370, - /* 2170 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - /* 2180 */ 370, 370, 340, 341, 342, 370, 344, 370, 370, 347, - /* 2190 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - /* 2200 */ 370, 370, 370, 361, 370, 370, 370, 365, + /* 200 */ 200, 201, 202, 203, 204, 205, 206, 8, 9, 113, + /* 210 */ 114, 12, 13, 14, 15, 16, 321, 322, 258, 219, + /* 220 */ 163, 261, 165, 61, 62, 63, 64, 332, 66, 67, + /* 230 */ 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, + /* 240 */ 78, 79, 20, 4, 187, 188, 4, 190, 191, 192, + /* 250 */ 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, + /* 260 */ 203, 204, 205, 206, 12, 13, 20, 22, 82, 311, + /* 270 */ 174, 187, 20, 219, 22, 12, 13, 14, 15, 16, + /* 280 */ 35, 20, 83, 44, 45, 33, 263, 35, 95, 96, + /* 290 */ 97, 98, 99, 100, 101, 102, 103, 104, 105, 276, + /* 300 */ 107, 108, 109, 110, 111, 112, 219, 284, 56, 351, + /* 310 */ 65, 59, 228, 229, 230, 231, 232, 65, 94, 0, + /* 320 */ 261, 12, 13, 365, 82, 253, 58, 369, 82, 20, + /* 330 */ 20, 22, 22, 20, 82, 273, 82, 113, 114, 115, + /* 340 */ 116, 117, 33, 281, 35, 35, 273, 20, 162, 104, + /* 350 */ 164, 261, 290, 281, 281, 351, 104, 298, 0, 273, + /* 360 */ 50, 289, 113, 290, 351, 56, 294, 281, 296, 365, + /* 370 */ 118, 119, 150, 369, 65, 351, 290, 58, 365, 289, + /* 380 */ 8, 9, 369, 311, 12, 13, 14, 15, 16, 365, + /* 390 */ 14, 82, 261, 369, 322, 289, 20, 325, 326, 327, + /* 400 */ 328, 329, 330, 272, 332, 219, 300, 335, 163, 158, + /* 410 */ 165, 339, 340, 104, 281, 163, 58, 165, 148, 329, + /* 420 */ 289, 82, 289, 351, 175, 176, 65, 118, 119, 178, + /* 430 */ 179, 92, 187, 188, 344, 345, 346, 365, 348, 187, + /* 440 */ 188, 369, 190, 191, 192, 193, 194, 195, 196, 197, + /* 450 */ 198, 199, 200, 201, 202, 203, 204, 205, 206, 21, + /* 460 */ 327, 219, 24, 25, 26, 27, 28, 29, 30, 31, + /* 470 */ 32, 14, 163, 219, 165, 8, 9, 20, 2, 12, + /* 480 */ 13, 14, 15, 16, 8, 9, 76, 14, 12, 13, + /* 490 */ 14, 15, 16, 20, 224, 225, 187, 188, 93, 190, + /* 500 */ 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, + /* 510 */ 201, 202, 203, 204, 205, 206, 12, 13, 14, 261, + /* 520 */ 114, 336, 337, 261, 20, 65, 22, 155, 219, 253, + /* 530 */ 272, 253, 122, 123, 272, 46, 20, 33, 22, 35, + /* 540 */ 315, 253, 2, 14, 15, 16, 39, 289, 8, 9, + /* 550 */ 83, 289, 12, 13, 14, 15, 16, 8, 9, 253, + /* 560 */ 56, 12, 13, 14, 15, 16, 50, 191, 253, 65, + /* 570 */ 294, 82, 294, 12, 13, 253, 295, 296, 4, 173, + /* 580 */ 174, 20, 294, 22, 8, 9, 82, 281, 12, 13, + /* 590 */ 14, 15, 16, 19, 33, 289, 35, 281, 265, 261, + /* 600 */ 294, 261, 296, 281, 1, 2, 290, 33, 104, 294, + /* 610 */ 272, 289, 272, 241, 56, 253, 294, 56, 296, 43, + /* 620 */ 287, 47, 118, 119, 0, 51, 65, 289, 322, 289, + /* 630 */ 56, 325, 326, 327, 328, 329, 330, 258, 332, 81, + /* 640 */ 261, 335, 84, 82, 322, 339, 340, 325, 326, 327, + /* 650 */ 328, 329, 330, 35, 332, 81, 294, 335, 84, 261, + /* 660 */ 282, 339, 340, 341, 191, 104, 145, 163, 282, 165, + /* 670 */ 8, 9, 253, 253, 12, 13, 14, 15, 16, 118, + /* 680 */ 119, 0, 291, 65, 362, 294, 83, 289, 253, 168, + /* 690 */ 253, 187, 188, 253, 190, 191, 192, 193, 194, 195, + /* 700 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + /* 710 */ 206, 267, 268, 294, 294, 8, 9, 4, 94, 12, + /* 720 */ 13, 14, 15, 16, 163, 218, 165, 329, 207, 294, + /* 730 */ 253, 294, 253, 253, 294, 37, 253, 113, 114, 115, + /* 740 */ 116, 117, 344, 345, 346, 83, 348, 306, 187, 188, + /* 750 */ 309, 190, 191, 192, 193, 194, 195, 196, 197, 198, + /* 760 */ 199, 200, 201, 202, 203, 204, 205, 206, 12, 13, + /* 770 */ 18, 294, 20, 294, 294, 94, 20, 294, 22, 27, + /* 780 */ 94, 323, 30, 85, 253, 87, 88, 306, 90, 33, + /* 790 */ 309, 35, 94, 20, 113, 114, 115, 116, 117, 47, + /* 800 */ 3, 49, 116, 51, 261, 347, 267, 268, 296, 261, + /* 810 */ 20, 261, 56, 261, 116, 272, 261, 253, 261, 307, + /* 820 */ 272, 65, 272, 0, 272, 294, 253, 272, 253, 272, + /* 830 */ 43, 261, 289, 81, 281, 44, 45, 289, 82, 289, + /* 840 */ 274, 289, 272, 277, 289, 43, 289, 8, 9, 282, + /* 850 */ 297, 12, 13, 14, 15, 16, 281, 150, 294, 289, + /* 860 */ 104, 269, 291, 271, 289, 294, 282, 294, 253, 294, + /* 870 */ 47, 296, 0, 121, 118, 119, 124, 125, 126, 127, + /* 880 */ 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, + /* 890 */ 138, 139, 140, 141, 22, 143, 144, 322, 59, 35, + /* 900 */ 325, 326, 327, 328, 329, 330, 261, 332, 56, 294, + /* 910 */ 335, 217, 218, 0, 339, 340, 341, 272, 33, 163, + /* 920 */ 282, 165, 83, 150, 282, 350, 86, 43, 86, 89, + /* 930 */ 91, 89, 47, 220, 289, 22, 84, 52, 53, 54, + /* 940 */ 55, 56, 86, 187, 188, 89, 190, 191, 192, 193, + /* 950 */ 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, + /* 960 */ 204, 205, 206, 18, 261, 261, 81, 83, 23, 84, + /* 970 */ 150, 151, 282, 43, 86, 272, 272, 89, 0, 59, + /* 980 */ 43, 191, 37, 38, 145, 254, 41, 270, 1, 2, + /* 990 */ 363, 372, 289, 289, 118, 119, 43, 43, 262, 43, + /* 1000 */ 22, 43, 57, 43, 43, 43, 318, 168, 358, 35, + /* 1010 */ 35, 8, 9, 83, 281, 12, 13, 14, 15, 16, + /* 1020 */ 83, 262, 260, 43, 43, 238, 43, 82, 43, 165, + /* 1030 */ 261, 146, 147, 236, 149, 293, 83, 83, 153, 83, + /* 1040 */ 65, 83, 240, 83, 83, 83, 207, 208, 209, 210, + /* 1050 */ 211, 212, 213, 214, 215, 216, 43, 172, 289, 43, + /* 1060 */ 349, 324, 59, 83, 83, 120, 83, 366, 83, 221, + /* 1070 */ 352, 366, 366, 320, 20, 261, 47, 319, 35, 267, + /* 1080 */ 311, 313, 161, 261, 42, 261, 301, 145, 299, 261, + /* 1090 */ 20, 299, 255, 255, 91, 20, 83, 317, 329, 83, + /* 1100 */ 155, 156, 157, 296, 20, 160, 265, 187, 253, 265, + /* 1110 */ 310, 166, 20, 344, 345, 346, 312, 348, 265, 310, + /* 1120 */ 351, 20, 177, 265, 265, 180, 265, 182, 183, 184, + /* 1130 */ 185, 186, 302, 265, 365, 261, 281, 255, 369, 165, + /* 1140 */ 294, 281, 261, 281, 289, 255, 281, 281, 145, 294, + /* 1150 */ 281, 296, 281, 317, 281, 263, 281, 171, 281, 281, + /* 1160 */ 281, 253, 263, 316, 219, 261, 311, 261, 263, 20, + /* 1170 */ 227, 168, 357, 310, 324, 226, 296, 322, 357, 233, + /* 1180 */ 325, 326, 327, 328, 329, 330, 360, 332, 294, 281, + /* 1190 */ 335, 305, 294, 154, 339, 340, 305, 289, 235, 234, + /* 1200 */ 357, 294, 294, 253, 296, 294, 351, 356, 359, 355, + /* 1210 */ 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, + /* 1220 */ 365, 222, 320, 218, 369, 289, 20, 42, 239, 237, + /* 1230 */ 322, 281, 323, 325, 326, 327, 328, 329, 330, 289, + /* 1240 */ 332, 354, 342, 335, 294, 82, 296, 339, 340, 341, + /* 1250 */ 12, 13, 242, 338, 147, 303, 373, 368, 350, 289, + /* 1260 */ 22, 368, 367, 367, 305, 368, 294, 294, 367, 305, + /* 1270 */ 294, 33, 322, 35, 263, 325, 326, 327, 328, 329, + /* 1280 */ 330, 253, 332, 277, 294, 335, 302, 294, 294, 339, + /* 1290 */ 340, 341, 82, 263, 56, 294, 289, 285, 271, 261, + /* 1300 */ 350, 36, 256, 65, 263, 255, 309, 275, 253, 281, + /* 1310 */ 314, 275, 275, 264, 251, 0, 0, 289, 42, 0, + /* 1320 */ 0, 73, 294, 35, 296, 181, 35, 35, 35, 181, + /* 1330 */ 0, 35, 35, 181, 0, 181, 281, 0, 35, 311, + /* 1340 */ 0, 0, 104, 22, 289, 35, 0, 168, 82, 294, + /* 1350 */ 322, 296, 165, 325, 326, 327, 328, 329, 330, 167, + /* 1360 */ 332, 163, 0, 0, 159, 158, 311, 0, 0, 46, + /* 1370 */ 0, 0, 0, 142, 0, 0, 253, 322, 0, 351, + /* 1380 */ 325, 326, 327, 328, 329, 330, 0, 332, 0, 137, + /* 1390 */ 35, 0, 137, 365, 0, 0, 0, 369, 0, 0, + /* 1400 */ 0, 163, 0, 165, 281, 22, 351, 0, 0, 0, + /* 1410 */ 0, 0, 289, 0, 0, 42, 0, 294, 253, 296, + /* 1420 */ 365, 0, 0, 0, 369, 187, 0, 0, 0, 0, + /* 1430 */ 0, 0, 0, 0, 42, 46, 198, 199, 200, 201, + /* 1440 */ 202, 203, 204, 253, 43, 322, 281, 60, 325, 326, + /* 1450 */ 327, 328, 329, 330, 289, 332, 39, 14, 335, 294, + /* 1460 */ 14, 296, 339, 340, 46, 0, 0, 0, 0, 0, + /* 1470 */ 0, 281, 154, 0, 40, 39, 39, 0, 0, 289, + /* 1480 */ 261, 39, 47, 35, 294, 0, 296, 322, 35, 39, + /* 1490 */ 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + /* 1500 */ 253, 47, 0, 47, 0, 47, 35, 0, 289, 35, + /* 1510 */ 0, 39, 322, 89, 39, 325, 326, 327, 328, 329, + /* 1520 */ 330, 0, 332, 0, 35, 22, 0, 35, 281, 91, + /* 1530 */ 311, 35, 35, 35, 43, 35, 289, 43, 0, 22, + /* 1540 */ 35, 294, 0, 296, 35, 0, 22, 22, 329, 35, + /* 1550 */ 49, 0, 0, 35, 35, 0, 22, 253, 0, 20, + /* 1560 */ 370, 371, 150, 344, 345, 346, 35, 348, 0, 322, + /* 1570 */ 351, 22, 325, 326, 327, 328, 329, 330, 253, 332, + /* 1580 */ 0, 0, 335, 0, 365, 281, 147, 340, 369, 169, + /* 1590 */ 150, 150, 0, 289, 0, 83, 152, 43, 294, 43, + /* 1600 */ 296, 217, 223, 83, 82, 43, 281, 43, 43, 82, + /* 1610 */ 43, 83, 308, 83, 289, 82, 223, 82, 82, 294, + /* 1620 */ 46, 296, 46, 82, 46, 46, 322, 83, 43, 325, + /* 1630 */ 326, 327, 328, 329, 330, 253, 332, 35, 223, 35, + /* 1640 */ 83, 35, 83, 83, 35, 35, 35, 322, 2, 187, + /* 1650 */ 325, 326, 327, 328, 329, 330, 43, 332, 253, 22, + /* 1660 */ 83, 46, 46, 281, 82, 189, 0, 83, 82, 82, + /* 1670 */ 82, 289, 83, 83, 0, 82, 294, 82, 296, 82, + /* 1680 */ 148, 39, 82, 146, 46, 46, 281, 82, 92, 364, + /* 1690 */ 83, 22, 93, 35, 289, 83, 82, 35, 35, 294, + /* 1700 */ 253, 296, 82, 82, 322, 83, 82, 325, 326, 327, + /* 1710 */ 328, 329, 330, 308, 332, 83, 253, 35, 82, 35, + /* 1720 */ 35, 22, 94, 83, 83, 82, 82, 322, 281, 106, + /* 1730 */ 325, 326, 327, 328, 329, 330, 289, 332, 82, 106, + /* 1740 */ 106, 294, 82, 296, 281, 35, 82, 43, 22, 60, + /* 1750 */ 59, 106, 289, 371, 35, 80, 43, 294, 65, 296, + /* 1760 */ 35, 22, 35, 35, 35, 35, 253, 35, 35, 322, + /* 1770 */ 65, 308, 325, 326, 327, 328, 329, 330, 35, 332, + /* 1780 */ 35, 334, 35, 35, 35, 322, 35, 35, 325, 326, + /* 1790 */ 327, 328, 329, 330, 281, 332, 19, 0, 35, 39, + /* 1800 */ 47, 0, 289, 35, 47, 39, 0, 294, 35, 296, + /* 1810 */ 33, 47, 0, 39, 35, 39, 47, 0, 35, 35, + /* 1820 */ 0, 308, 22, 253, 47, 21, 374, 22, 21, 52, + /* 1830 */ 53, 54, 55, 56, 374, 322, 22, 374, 325, 326, + /* 1840 */ 327, 328, 329, 330, 20, 332, 374, 374, 374, 374, + /* 1850 */ 374, 281, 374, 374, 374, 374, 374, 374, 81, 289, + /* 1860 */ 374, 84, 374, 374, 294, 374, 296, 374, 374, 374, + /* 1870 */ 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, + /* 1880 */ 374, 374, 374, 374, 253, 374, 374, 374, 374, 374, + /* 1890 */ 374, 374, 322, 374, 117, 325, 326, 327, 328, 329, + /* 1900 */ 330, 253, 332, 374, 374, 374, 374, 374, 374, 374, + /* 1910 */ 374, 374, 281, 374, 374, 374, 374, 374, 374, 374, + /* 1920 */ 289, 374, 374, 374, 374, 294, 149, 296, 374, 281, + /* 1930 */ 374, 374, 374, 374, 374, 374, 374, 289, 374, 374, + /* 1940 */ 374, 374, 294, 253, 296, 374, 374, 170, 374, 172, + /* 1950 */ 374, 374, 374, 322, 253, 374, 325, 326, 327, 328, + /* 1960 */ 329, 330, 374, 332, 374, 253, 374, 374, 374, 374, + /* 1970 */ 322, 281, 374, 325, 326, 327, 328, 329, 330, 289, + /* 1980 */ 332, 374, 281, 374, 294, 374, 296, 374, 374, 374, + /* 1990 */ 289, 374, 374, 281, 374, 294, 374, 296, 374, 374, + /* 2000 */ 374, 289, 374, 374, 374, 374, 294, 253, 296, 374, + /* 2010 */ 374, 374, 322, 374, 374, 325, 326, 327, 328, 329, + /* 2020 */ 330, 374, 332, 322, 374, 253, 325, 326, 327, 328, + /* 2030 */ 329, 330, 374, 332, 322, 281, 374, 325, 326, 327, + /* 2040 */ 328, 329, 330, 289, 332, 374, 374, 374, 294, 253, + /* 2050 */ 296, 374, 374, 281, 374, 374, 374, 374, 374, 374, + /* 2060 */ 374, 289, 374, 374, 374, 374, 294, 374, 296, 374, + /* 2070 */ 374, 374, 374, 374, 374, 374, 322, 281, 374, 325, + /* 2080 */ 326, 327, 328, 329, 330, 289, 332, 374, 374, 374, + /* 2090 */ 294, 374, 296, 374, 322, 374, 374, 325, 326, 327, + /* 2100 */ 328, 329, 330, 374, 332, 253, 374, 374, 374, 374, + /* 2110 */ 374, 374, 374, 374, 374, 374, 374, 374, 322, 374, + /* 2120 */ 374, 325, 326, 327, 328, 329, 330, 374, 332, 374, + /* 2130 */ 374, 374, 374, 281, 374, 374, 374, 374, 374, 374, + /* 2140 */ 374, 289, 374, 374, 374, 374, 294, 374, 296, 374, + /* 2150 */ 374, 374, 374, 374, 374, 253, 374, 374, 374, 374, + /* 2160 */ 374, 374, 374, 374, 374, 374, 253, 374, 374, 374, + /* 2170 */ 374, 374, 374, 374, 322, 374, 374, 325, 326, 327, + /* 2180 */ 328, 329, 330, 281, 332, 374, 374, 374, 374, 374, + /* 2190 */ 374, 289, 374, 374, 281, 374, 294, 374, 296, 374, + /* 2200 */ 374, 374, 289, 374, 374, 374, 374, 294, 253, 296, + /* 2210 */ 374, 374, 374, 374, 374, 374, 374, 374, 374, 253, + /* 2220 */ 374, 374, 374, 374, 322, 374, 374, 325, 326, 327, + /* 2230 */ 328, 329, 330, 253, 332, 322, 281, 374, 325, 326, + /* 2240 */ 327, 328, 329, 330, 289, 332, 374, 281, 374, 294, + /* 2250 */ 374, 296, 374, 374, 374, 289, 374, 374, 374, 374, + /* 2260 */ 294, 281, 296, 374, 374, 374, 374, 374, 374, 289, + /* 2270 */ 374, 374, 374, 374, 294, 374, 296, 322, 374, 374, + /* 2280 */ 325, 326, 327, 328, 329, 330, 374, 332, 322, 253, + /* 2290 */ 374, 325, 326, 327, 328, 329, 330, 374, 332, 374, + /* 2300 */ 374, 374, 322, 253, 374, 325, 326, 327, 328, 329, + /* 2310 */ 330, 374, 332, 374, 374, 374, 374, 281, 374, 374, + /* 2320 */ 374, 374, 374, 374, 374, 289, 374, 374, 374, 374, + /* 2330 */ 294, 281, 296, 374, 374, 374, 374, 374, 374, 289, + /* 2340 */ 374, 374, 374, 374, 294, 374, 296, 374, 374, 374, + /* 2350 */ 374, 374, 374, 253, 374, 374, 374, 374, 322, 374, + /* 2360 */ 374, 325, 326, 327, 328, 329, 330, 374, 332, 374, + /* 2370 */ 374, 374, 322, 374, 374, 325, 326, 327, 328, 329, + /* 2380 */ 330, 281, 332, 374, 374, 374, 374, 374, 374, 289, + /* 2390 */ 374, 374, 374, 374, 294, 253, 296, 374, 374, 374, + /* 2400 */ 374, 374, 374, 374, 374, 374, 374, 374, 374, 253, + /* 2410 */ 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, + /* 2420 */ 374, 374, 322, 281, 374, 325, 326, 327, 328, 329, + /* 2430 */ 330, 289, 332, 374, 374, 374, 294, 281, 296, 374, + /* 2440 */ 374, 374, 374, 374, 374, 289, 374, 374, 374, 374, + /* 2450 */ 294, 374, 296, 374, 374, 374, 374, 374, 374, 374, + /* 2460 */ 374, 374, 374, 374, 322, 374, 374, 325, 326, 327, + /* 2470 */ 328, 329, 330, 374, 332, 374, 374, 374, 322, 374, + /* 2480 */ 374, 325, 326, 327, 328, 329, 330, 374, 332, }; #define YY_SHIFT_COUNT (652) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1930) +#define YY_SHIFT_MAX (1824) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 769, 0, 0, 66, 322, 322, 322, 322, 266, 266, - /* 10 */ 322, 322, 460, 515, 581, 515, 515, 515, 515, 515, - /* 20 */ 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, - /* 30 */ 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, - /* 40 */ 515, 515, 292, 292, 18, 18, 18, 925, 925, 925, - /* 50 */ 925, 637, 291, 40, 51, 51, 356, 356, 54, 64, - /* 60 */ 40, 40, 51, 51, 51, 51, 51, 51, 51, 51, - /* 70 */ 33, 51, 51, 51, 85, 104, 265, 51, 51, 265, - /* 80 */ 51, 265, 265, 265, 51, 111, 189, 659, 674, 674, - /* 90 */ 128, 293, 63, 63, 63, 63, 63, 63, 63, 63, - /* 100 */ 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, - /* 110 */ 63, 301, 64, 67, 67, 739, 614, 341, 341, 341, - /* 120 */ 764, 614, 317, 104, 1, 1, 265, 265, 153, 153, - /* 130 */ 285, 370, 195, 195, 195, 195, 195, 195, 195, 704, - /* 140 */ 21, 427, 337, 47, 321, 435, 250, 12, 46, 548, - /* 150 */ 494, 511, 514, 483, 817, 483, 502, 502, 502, 790, - /* 160 */ 649, 844, 1049, 1026, 1044, 966, 1049, 1049, 1093, 995, - /* 170 */ 995, 1049, 1118, 1118, 1125, 33, 104, 33, 1149, 1157, - /* 180 */ 33, 1149, 33, 1163, 33, 33, 1049, 33, 1118, 265, - /* 190 */ 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, - /* 200 */ 1049, 1118, 153, 1125, 111, 1074, 104, 111, 1049, 1049, - /* 210 */ 1149, 111, 1232, 153, 1037, 1042, 153, 1037, 1042, 153, - /* 220 */ 153, 265, 1043, 1122, 1037, 1046, 1052, 1066, 844, 1072, - /* 230 */ 317, 1285, 1276, 1090, 1098, 1094, 1090, 1098, 1090, 1098, - /* 240 */ 1251, 1042, 153, 153, 153, 153, 153, 1042, 153, 1215, - /* 250 */ 317, 1163, 111, 285, 111, 317, 1301, 153, 370, 1049, - /* 260 */ 111, 1351, 1118, 2208, 2208, 2208, 2208, 2208, 2208, 2208, - /* 270 */ 843, 1297, 217, 395, 81, 268, 543, 1003, 1012, 882, - /* 280 */ 713, 532, 532, 532, 532, 532, 532, 532, 532, 701, - /* 290 */ 970, 498, 198, 198, 375, 149, 316, 719, 307, 36, - /* 300 */ 615, 615, 615, 615, 648, 759, 855, 880, 876, 878, - /* 310 */ 892, 894, 622, 971, 985, 874, 841, 956, 1009, 993, - /* 320 */ 923, 146, 897, 1010, 872, 1017, 964, 1019, 1023, 1028, - /* 330 */ 1031, 1032, 915, 961, 1033, 1038, 1039, 1060, 1064, 1085, - /* 340 */ 921, 1096, 1089, 1405, 1407, 1366, 1409, 1337, 1414, 1377, - /* 350 */ 1234, 1381, 1382, 1384, 1239, 1421, 1387, 1390, 1253, 1445, - /* 360 */ 1266, 1448, 1416, 1453, 1433, 1457, 1423, 1459, 1379, 1294, - /* 370 */ 1296, 1299, 1303, 1468, 1470, 1312, 1315, 1474, 1475, 1431, - /* 380 */ 1478, 1480, 1481, 1341, 1484, 1491, 1495, 1502, 1505, 1369, - /* 390 */ 1472, 1508, 1372, 1510, 1511, 1513, 1514, 1515, 1516, 1518, - /* 400 */ 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1485, 1528, 1530, - /* 410 */ 1532, 1533, 1534, 1535, 1517, 1536, 1537, 1540, 1541, 1542, - /* 420 */ 1543, 1504, 1519, 1501, 1545, 1527, 1546, 1531, 1554, 1529, - /* 430 */ 1539, 1556, 1561, 1562, 1547, 1410, 1563, 1567, 1568, 1565, - /* 440 */ 1571, 1576, 1550, 1544, 1548, 1580, 1557, 1553, 1555, 1582, - /* 450 */ 1560, 1581, 1570, 1584, 1583, 1585, 1591, 1589, 1593, 1596, - /* 460 */ 1597, 1538, 1559, 1598, 1609, 1634, 1601, 1602, 1603, 1604, - /* 470 */ 1600, 1606, 1610, 1611, 1612, 1644, 1628, 1651, 1630, 1605, - /* 480 */ 1653, 1633, 1621, 1657, 1623, 1659, 1625, 1662, 1641, 1645, - /* 490 */ 1664, 1551, 1631, 1667, 1512, 1648, 1572, 1552, 1679, 1680, - /* 500 */ 1573, 1569, 1685, 1686, 1687, 1647, 1649, 1469, 1613, 1615, - /* 510 */ 1614, 1620, 1650, 1622, 1618, 1624, 1626, 1629, 1666, 1661, - /* 520 */ 1681, 1643, 1688, 1509, 1646, 1658, 1696, 1564, 1689, 1697, - /* 530 */ 1663, 1701, 1566, 1668, 1656, 1710, 1712, 1714, 1715, 1718, - /* 540 */ 1668, 1692, 1574, 1711, 1682, 1684, 1690, 1717, 1699, 1704, - /* 550 */ 1722, 1742, 1590, 1705, 1691, 1695, 1706, 1769, 1708, 1635, - /* 560 */ 1713, 1770, 1732, 1654, 1719, 1700, 1726, 1747, 1720, 1716, - /* 570 */ 1721, 1772, 1723, 1703, 1727, 1762, 1771, 1737, 1745, 1774, - /* 580 */ 1748, 1746, 1796, 1750, 1754, 1798, 1756, 1757, 1801, 1760, - /* 590 */ 1698, 1738, 1739, 1741, 1824, 1755, 1773, 1776, 1816, 1777, - /* 600 */ 1809, 1809, 1831, 1794, 1797, 1825, 1799, 1781, 1819, 1828, - /* 610 */ 1830, 1833, 1834, 1843, 1865, 1853, 1854, 1826, 1600, 1855, - /* 620 */ 1606, 1857, 1860, 1861, 1862, 1864, 1866, 1903, 1869, 1858, - /* 630 */ 1867, 1908, 1875, 1868, 1872, 1912, 1878, 1870, 1877, 1914, - /* 640 */ 1884, 1873, 1882, 1922, 1888, 1889, 1925, 1906, 1916, 1926, - /* 650 */ 1927, 1923, 1930, + /* 0 */ 945, 0, 0, 57, 252, 252, 252, 252, 309, 309, + /* 10 */ 252, 252, 504, 561, 756, 561, 561, 561, 561, 561, + /* 20 */ 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, + /* 30 */ 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, + /* 40 */ 561, 561, 54, 54, 246, 246, 246, 1238, 1238, 1238, + /* 50 */ 1238, 186, 87, 254, 11, 11, 239, 239, 242, 10, + /* 60 */ 254, 254, 11, 11, 11, 11, 11, 11, 11, 11, + /* 70 */ 99, 11, 11, 11, 150, 261, 313, 11, 11, 313, + /* 80 */ 11, 313, 313, 313, 11, 268, 752, 839, 1003, 1003, + /* 90 */ 438, 111, 245, 245, 245, 245, 245, 245, 245, 245, + /* 100 */ 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + /* 110 */ 245, 698, 10, 457, 457, 319, 618, 222, 222, 222, + /* 120 */ 358, 618, 327, 261, 6, 6, 313, 313, 361, 361, + /* 130 */ 405, 460, 193, 193, 193, 193, 193, 193, 193, 1777, + /* 140 */ 21, 14, 372, 84, 310, 406, 270, 376, 473, 516, + /* 150 */ 791, 686, 773, 694, 507, 694, 797, 797, 797, 713, + /* 160 */ 790, 848, 1054, 1029, 1043, 921, 1054, 1054, 1042, 942, + /* 170 */ 942, 1054, 1070, 1070, 1075, 99, 261, 99, 1084, 1092, + /* 180 */ 99, 1084, 99, 1101, 99, 99, 1054, 99, 1070, 313, + /* 190 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, + /* 200 */ 1054, 1070, 361, 1075, 268, 986, 261, 268, 1054, 1054, + /* 210 */ 1084, 268, 1149, 361, 943, 949, 361, 943, 949, 361, + /* 220 */ 361, 313, 946, 1039, 943, 963, 965, 999, 848, 1005, + /* 230 */ 327, 1206, 1185, 989, 992, 1010, 989, 992, 989, 992, + /* 240 */ 1163, 949, 361, 361, 361, 361, 361, 949, 361, 1107, + /* 250 */ 327, 1101, 268, 405, 268, 327, 1210, 361, 460, 1054, + /* 260 */ 268, 1265, 1070, 2489, 2489, 2489, 2489, 2489, 2489, 2489, + /* 270 */ 162, 885, 123, 574, 199, 576, 467, 476, 540, 707, + /* 280 */ 662, 549, 549, 549, 549, 549, 549, 549, 549, 624, + /* 290 */ 681, 224, 263, 263, 251, 558, 410, 3, 603, 521, + /* 300 */ 529, 529, 529, 529, 249, 96, 823, 884, 840, 842, + /* 310 */ 856, 888, 872, 913, 978, 852, 820, 930, 937, 987, + /* 320 */ 876, 787, 802, 953, 920, 954, 489, 956, 958, 960, + /* 330 */ 961, 962, 864, 974, 980, 981, 983, 985, 1013, 1016, + /* 340 */ 339, 975, 126, 1315, 1316, 1276, 1319, 1248, 1320, 1288, + /* 350 */ 1144, 1291, 1292, 1293, 1148, 1330, 1296, 1297, 1152, 1334, + /* 360 */ 1154, 1337, 1303, 1340, 1321, 1341, 1310, 1346, 1266, 1179, + /* 370 */ 1192, 1187, 1198, 1362, 1363, 1205, 1207, 1367, 1368, 1323, + /* 380 */ 1370, 1371, 1372, 1231, 1374, 1375, 1378, 1386, 1388, 1252, + /* 390 */ 1355, 1391, 1255, 1394, 1395, 1396, 1398, 1399, 1400, 1402, + /* 400 */ 1407, 1408, 1409, 1410, 1411, 1413, 1414, 1373, 1416, 1421, + /* 410 */ 1422, 1423, 1426, 1427, 1383, 1428, 1429, 1430, 1431, 1432, + /* 420 */ 1433, 1392, 1417, 1401, 1443, 1389, 1446, 1418, 1465, 1434, + /* 430 */ 1436, 1466, 1467, 1468, 1437, 1318, 1469, 1470, 1473, 1387, + /* 440 */ 1477, 1478, 1448, 1435, 1442, 1485, 1453, 1454, 1450, 1502, + /* 450 */ 1471, 1456, 1472, 1504, 1474, 1458, 1475, 1507, 1510, 1521, + /* 460 */ 1523, 1438, 1424, 1489, 1503, 1526, 1492, 1496, 1497, 1498, + /* 470 */ 1491, 1494, 1500, 1505, 1509, 1538, 1517, 1542, 1524, 1501, + /* 480 */ 1545, 1525, 1514, 1551, 1518, 1552, 1519, 1555, 1534, 1539, + /* 490 */ 1558, 1412, 1531, 1568, 1420, 1549, 1440, 1439, 1580, 1581, + /* 500 */ 1441, 1444, 1583, 1592, 1594, 1554, 1556, 1379, 1522, 1512, + /* 510 */ 1527, 1520, 1562, 1528, 1533, 1535, 1536, 1530, 1564, 1574, + /* 520 */ 1576, 1541, 1565, 1393, 1544, 1557, 1578, 1384, 1567, 1579, + /* 530 */ 1559, 1585, 1415, 1560, 1602, 1604, 1606, 1609, 1610, 1611, + /* 540 */ 1560, 1646, 1462, 1613, 1577, 1582, 1584, 1615, 1586, 1587, + /* 550 */ 1616, 1637, 1476, 1588, 1589, 1590, 1593, 1666, 1595, 1532, + /* 560 */ 1597, 1674, 1642, 1537, 1600, 1596, 1638, 1639, 1605, 1607, + /* 570 */ 1614, 1669, 1620, 1599, 1612, 1658, 1662, 1621, 1622, 1663, + /* 580 */ 1624, 1632, 1682, 1636, 1640, 1684, 1643, 1641, 1685, 1644, + /* 590 */ 1623, 1633, 1634, 1645, 1699, 1628, 1656, 1660, 1710, 1664, + /* 600 */ 1704, 1704, 1726, 1689, 1691, 1719, 1693, 1675, 1713, 1725, + /* 610 */ 1727, 1728, 1729, 1730, 1739, 1732, 1733, 1705, 1491, 1743, + /* 620 */ 1494, 1745, 1747, 1748, 1749, 1751, 1752, 1797, 1763, 1753, + /* 630 */ 1760, 1801, 1768, 1757, 1766, 1806, 1773, 1764, 1774, 1812, + /* 640 */ 1779, 1769, 1776, 1817, 1783, 1784, 1820, 1800, 1804, 1805, + /* 650 */ 1814, 1807, 1824, }; #define YY_REDUCE_COUNT (269) -#define YY_REDUCE_MIN (-338) -#define YY_REDUCE_MAX (1842) +#define YY_REDUCE_MIN (-287) +#define YY_REDUCE_MAX (2156) static const short yy_reduce_ofst[] = { - /* 0 */ -235, -215, 87, 651, 712, 513, 773, 828, 881, 890, - /* 10 */ 908, 973, -150, 989, 998, 314, 1051, 1105, 1114, 1164, - /* 20 */ 1175, 1227, 1280, 1289, 1298, 1350, 1392, 1412, 1434, 1490, - /* 30 */ 1499, 1549, 1558, 1608, 1617, 1669, 1678, 1731, 1740, 1749, - /* 40 */ 1758, 1836, 1753, 1842, -119, 241, 246, -274, -254, -261, - /* 50 */ 79, -292, -224, 143, -124, 108, -253, -249, -338, -251, - /* 60 */ -218, 55, -123, -33, 162, 164, 226, 275, 304, 339, - /* 70 */ -244, 360, 408, 409, -209, 133, 200, 413, 463, 459, - /* 80 */ 481, 298, 470, 455, 545, 165, -233, 7, 7, 7, - /* 90 */ -217, -252, -63, 154, 194, 287, 320, 351, 353, 496, - /* 100 */ 518, 521, 542, 571, 597, 598, 609, 611, 644, 654, - /* 110 */ 678, -174, 238, 221, 308, -144, 357, -111, 490, 589, - /* 120 */ 595, 428, 399, 497, 271, 523, 507, 552, 652, 658, - /* 130 */ 686, 22, -259, 177, 426, 452, 457, 534, 579, 71, - /* 140 */ 156, 233, 227, 533, 699, 684, 612, 724, 724, 765, - /* 150 */ 788, 756, 731, 709, 709, 709, 693, 694, 695, 720, - /* 160 */ 724, 751, 815, 763, 854, 820, 875, 877, 839, 846, - /* 170 */ 847, 887, 904, 909, 835, 901, 884, 911, 864, 870, - /* 180 */ 918, 883, 920, 886, 926, 929, 934, 931, 935, 917, - /* 190 */ 919, 924, 933, 940, 942, 943, 944, 946, 947, 948, - /* 200 */ 938, 976, 945, 927, 982, 936, 957, 994, 997, 999, - /* 210 */ 951, 1000, 941, 972, 914, 967, 979, 932, 969, 981, - /* 220 */ 983, 724, 922, 937, 949, 928, 952, 939, 977, 709, - /* 230 */ 1002, 987, 1001, 963, 974, 978, 984, 975, 996, 1004, - /* 240 */ 1006, 1034, 1055, 1056, 1067, 1068, 1069, 1041, 1071, 1065, - /* 250 */ 1080, 1070, 1107, 1097, 1112, 1095, 1103, 1099, 1119, 1128, - /* 260 */ 1129, 1140, 1142, 1084, 1091, 1127, 1130, 1131, 1143, 1153, + /* 0 */ -248, 72, 855, -195, 322, 575, 908, 950, 1028, 1055, + /* 10 */ 306, 1123, 1165, 1190, 1247, 1304, 1325, 1382, 1405, 1447, + /* 20 */ 1463, 1513, 1570, 1631, 1648, 1690, 1701, 1712, 1754, 1772, + /* 30 */ 1796, 1852, 1902, 1913, 1955, 1966, 1980, 2036, 2050, 2100, + /* 40 */ 2142, 2156, 769, 1219, -234, 90, 398, -278, -260, -254, + /* 50 */ -105, -245, -209, -42, -261, -164, -256, -250, 4, -113, + /* 60 */ 13, 24, 131, 258, 262, 338, 340, 543, 548, 550, + /* 70 */ -246, 552, 555, 557, 133, -211, 62, 570, 645, -224, + /* 80 */ 703, 73, -190, 86, 704, 23, 59, 185, 185, 185, + /* 90 */ -237, -102, -153, 276, 278, 288, 315, 362, 419, 420, + /* 100 */ 435, 437, 440, 477, 479, 480, 483, 531, 564, 573, + /* 110 */ 615, -255, 281, -40, 379, 333, 444, -287, -242, 458, + /* 120 */ -125, 539, 106, 512, 441, 481, 316, 553, 391, 571, + /* 130 */ 566, 592, 378, 386, 567, 584, 638, 642, 690, 225, + /* 140 */ 731, 717, 619, 627, 736, 688, 650, 733, 733, 759, + /* 150 */ 762, 742, 737, 711, 711, 711, 701, 705, 706, 718, + /* 160 */ 733, 753, 814, 758, 812, 768, 822, 824, 785, 789, + /* 170 */ 792, 828, 837, 838, 780, 841, 807, 844, 800, 804, + /* 180 */ 853, 809, 858, 830, 859, 861, 874, 868, 882, 860, + /* 190 */ 862, 865, 866, 869, 871, 873, 875, 877, 878, 879, + /* 200 */ 881, 890, 846, 836, 892, 847, 880, 899, 904, 906, + /* 210 */ 863, 905, 850, 894, 815, 886, 898, 821, 891, 907, + /* 220 */ 911, 733, 826, 849, 843, 851, 854, 887, 902, 711, + /* 230 */ 936, 909, 900, 889, 895, 883, 893, 896, 897, 901, + /* 240 */ 915, 959, 972, 973, 976, 990, 993, 964, 994, 952, + /* 250 */ 970, 984, 1011, 1006, 1030, 1007, 1012, 1001, 1027, 1038, + /* 260 */ 1041, 1046, 1050, 996, 997, 1032, 1036, 1037, 1049, 1063, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 10 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 20 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 30 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 40 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 50 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 60 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 70 */ 1496, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 80 */ 1424, 1424, 1424, 1424, 1424, 1494, 1647, 1424, 1816, 1424, - /* 90 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 100 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 110 */ 1424, 1424, 1424, 1424, 1424, 1496, 1424, 1828, 1828, 1828, - /* 120 */ 1494, 1424, 1424, 1424, 1691, 1691, 1424, 1424, 1424, 1424, - /* 130 */ 1590, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1683, - /* 140 */ 1424, 1424, 1898, 1424, 1424, 1689, 1852, 1424, 1424, 1424, - /* 150 */ 1424, 1543, 1844, 1820, 1834, 1821, 1883, 1883, 1883, 1837, - /* 160 */ 1424, 1848, 1424, 1424, 1424, 1675, 1424, 1424, 1652, 1649, - /* 170 */ 1649, 1424, 1424, 1424, 1424, 1496, 1424, 1496, 1424, 1424, - /* 180 */ 1496, 1424, 1496, 1424, 1496, 1496, 1424, 1496, 1424, 1424, - /* 190 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 200 */ 1424, 1424, 1424, 1424, 1494, 1685, 1424, 1494, 1424, 1424, - /* 210 */ 1424, 1494, 1424, 1424, 1859, 1857, 1424, 1859, 1857, 1424, - /* 220 */ 1424, 1424, 1871, 1867, 1859, 1875, 1873, 1850, 1848, 1834, - /* 230 */ 1424, 1424, 1818, 1889, 1885, 1901, 1889, 1885, 1889, 1885, - /* 240 */ 1424, 1857, 1424, 1424, 1424, 1424, 1424, 1857, 1424, 1424, - /* 250 */ 1424, 1424, 1494, 1424, 1494, 1424, 1559, 1424, 1424, 1424, - /* 260 */ 1494, 1456, 1424, 1677, 1691, 1593, 1593, 1593, 1497, 1429, - /* 270 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 280 */ 1424, 1760, 1870, 1869, 1792, 1791, 1790, 1788, 1759, 1424, - /* 290 */ 1424, 1555, 1758, 1757, 1424, 1424, 1424, 1424, 1424, 1424, - /* 300 */ 1751, 1752, 1750, 1749, 1424, 1424, 1424, 1424, 1424, 1424, - /* 310 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1817, - /* 320 */ 1424, 1886, 1890, 1424, 1424, 1424, 1734, 1424, 1424, 1424, - /* 330 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 340 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 350 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 360 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 370 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 380 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 390 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 400 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 410 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 420 */ 1424, 1424, 1424, 1461, 1424, 1424, 1424, 1424, 1424, 1424, - /* 430 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 440 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 450 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 460 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 470 */ 1524, 1523, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 480 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 490 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 500 */ 1424, 1424, 1424, 1424, 1424, 1841, 1851, 1424, 1424, 1424, - /* 510 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 520 */ 1734, 1424, 1868, 1424, 1827, 1823, 1424, 1424, 1819, 1424, - /* 530 */ 1424, 1884, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 540 */ 1424, 1812, 1424, 1785, 1424, 1424, 1424, 1424, 1424, 1424, - /* 550 */ 1424, 1424, 1745, 1424, 1424, 1424, 1424, 1695, 1424, 1424, - /* 560 */ 1424, 1424, 1424, 1424, 1424, 1424, 1733, 1424, 1776, 1424, - /* 570 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1587, 1424, 1424, - /* 580 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 590 */ 1572, 1570, 1569, 1568, 1424, 1565, 1424, 1424, 1424, 1424, - /* 600 */ 1596, 1595, 1424, 1424, 1424, 1424, 1424, 1424, 1516, 1424, - /* 610 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1507, 1424, - /* 620 */ 1506, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 630 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 640 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, - /* 650 */ 1424, 1424, 1424, + /* 0 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 10 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 20 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 30 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 40 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 50 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 60 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 70 */ 1508, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 80 */ 1436, 1436, 1436, 1436, 1436, 1506, 1659, 1436, 1834, 1436, + /* 90 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 100 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 110 */ 1436, 1436, 1436, 1436, 1436, 1508, 1436, 1846, 1846, 1846, + /* 120 */ 1506, 1436, 1436, 1436, 1703, 1703, 1436, 1436, 1436, 1436, + /* 130 */ 1602, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1695, + /* 140 */ 1436, 1436, 1916, 1436, 1436, 1701, 1870, 1436, 1436, 1436, + /* 150 */ 1436, 1555, 1862, 1838, 1852, 1839, 1901, 1901, 1901, 1855, + /* 160 */ 1436, 1866, 1436, 1436, 1436, 1687, 1436, 1436, 1664, 1661, + /* 170 */ 1661, 1436, 1436, 1436, 1436, 1508, 1436, 1508, 1436, 1436, + /* 180 */ 1508, 1436, 1508, 1436, 1508, 1508, 1436, 1508, 1436, 1436, + /* 190 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 200 */ 1436, 1436, 1436, 1436, 1506, 1697, 1436, 1506, 1436, 1436, + /* 210 */ 1436, 1506, 1436, 1436, 1877, 1875, 1436, 1877, 1875, 1436, + /* 220 */ 1436, 1436, 1889, 1885, 1877, 1893, 1891, 1868, 1866, 1852, + /* 230 */ 1436, 1436, 1836, 1907, 1903, 1919, 1907, 1903, 1907, 1903, + /* 240 */ 1436, 1875, 1436, 1436, 1436, 1436, 1436, 1875, 1436, 1436, + /* 250 */ 1436, 1436, 1506, 1436, 1506, 1436, 1571, 1436, 1436, 1436, + /* 260 */ 1506, 1468, 1436, 1689, 1703, 1605, 1605, 1605, 1509, 1441, + /* 270 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 280 */ 1436, 1772, 1888, 1887, 1810, 1809, 1808, 1806, 1771, 1436, + /* 290 */ 1436, 1567, 1770, 1769, 1436, 1436, 1436, 1436, 1436, 1436, + /* 300 */ 1763, 1764, 1762, 1761, 1436, 1436, 1436, 1436, 1436, 1436, + /* 310 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1835, + /* 320 */ 1436, 1904, 1908, 1436, 1436, 1436, 1746, 1436, 1436, 1436, + /* 330 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 340 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 350 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 360 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 370 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 380 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 390 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 400 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 410 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 420 */ 1436, 1436, 1436, 1473, 1436, 1436, 1436, 1436, 1436, 1436, + /* 430 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 440 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 450 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 460 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 470 */ 1536, 1535, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 480 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 490 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 500 */ 1436, 1436, 1436, 1436, 1436, 1859, 1869, 1436, 1436, 1436, + /* 510 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 520 */ 1746, 1436, 1886, 1436, 1845, 1841, 1436, 1436, 1837, 1436, + /* 530 */ 1436, 1902, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 540 */ 1436, 1830, 1436, 1803, 1436, 1436, 1436, 1436, 1436, 1436, + /* 550 */ 1436, 1436, 1757, 1436, 1436, 1436, 1436, 1707, 1436, 1436, + /* 560 */ 1436, 1436, 1436, 1436, 1436, 1436, 1745, 1436, 1788, 1436, + /* 570 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1599, 1436, 1436, + /* 580 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 590 */ 1584, 1582, 1581, 1580, 1436, 1577, 1436, 1436, 1436, 1436, + /* 600 */ 1608, 1607, 1436, 1436, 1436, 1436, 1436, 1436, 1528, 1436, + /* 610 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1519, 1436, + /* 620 */ 1518, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 630 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 640 */ 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, + /* 650 */ 1436, 1436, 1436, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1053,6 +1109,10 @@ static const YYCODETYPE yyFallback[] = { 0, /* NOW => nothing */ 0, /* TODAY => nothing */ 0, /* TIMEZONE => nothing */ + 0, /* CLIENT_VERSION => nothing */ + 0, /* SERVER_VERSION => nothing */ + 0, /* SERVER_STATUS => nothing */ + 0, /* CURRENT_USER => nothing */ 0, /* COUNT => nothing */ 0, /* LAST_ROW => nothing */ 0, /* BETWEEN => nothing */ @@ -1092,12 +1152,12 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ID => nothing */ - 239, /* NK_BITNOT => ID */ - 239, /* INSERT => ID */ - 239, /* VALUES => ID */ - 239, /* IMPORT => ID */ - 239, /* NK_SEMI => ID */ - 239, /* FILE => ID */ + 243, /* NK_BITNOT => ID */ + 243, /* INSERT => ID */ + 243, /* VALUES => ID */ + 243, /* IMPORT => ID */ + 243, /* NK_SEMI => ID */ + 243, /* FILE => ID */ }; #endif /* YYFALLBACK */ @@ -1386,175 +1446,179 @@ static const char *const yyTokenName[] = { /* 198 */ "NOW", /* 199 */ "TODAY", /* 200 */ "TIMEZONE", - /* 201 */ "COUNT", - /* 202 */ "LAST_ROW", - /* 203 */ "BETWEEN", - /* 204 */ "IS", - /* 205 */ "NK_LT", - /* 206 */ "NK_GT", - /* 207 */ "NK_LE", - /* 208 */ "NK_GE", - /* 209 */ "NK_NE", - /* 210 */ "MATCH", - /* 211 */ "NMATCH", - /* 212 */ "CONTAINS", - /* 213 */ "JOIN", - /* 214 */ "INNER", - /* 215 */ "SELECT", - /* 216 */ "DISTINCT", - /* 217 */ "WHERE", - /* 218 */ "PARTITION", - /* 219 */ "BY", - /* 220 */ "SESSION", - /* 221 */ "STATE_WINDOW", - /* 222 */ "SLIDING", - /* 223 */ "FILL", - /* 224 */ "VALUE", - /* 225 */ "NONE", - /* 226 */ "PREV", - /* 227 */ "LINEAR", - /* 228 */ "NEXT", - /* 229 */ "HAVING", - /* 230 */ "RANGE", - /* 231 */ "EVERY", - /* 232 */ "ORDER", - /* 233 */ "SLIMIT", - /* 234 */ "SOFFSET", - /* 235 */ "LIMIT", - /* 236 */ "OFFSET", - /* 237 */ "ASC", - /* 238 */ "NULLS", - /* 239 */ "ID", - /* 240 */ "NK_BITNOT", - /* 241 */ "INSERT", - /* 242 */ "VALUES", - /* 243 */ "IMPORT", - /* 244 */ "NK_SEMI", - /* 245 */ "FILE", - /* 246 */ "cmd", - /* 247 */ "account_options", - /* 248 */ "alter_account_options", - /* 249 */ "literal", - /* 250 */ "alter_account_option", - /* 251 */ "user_name", - /* 252 */ "sysinfo_opt", - /* 253 */ "privileges", - /* 254 */ "priv_level", - /* 255 */ "priv_type_list", - /* 256 */ "priv_type", - /* 257 */ "db_name", - /* 258 */ "dnode_endpoint", - /* 259 */ "not_exists_opt", - /* 260 */ "db_options", - /* 261 */ "exists_opt", - /* 262 */ "alter_db_options", - /* 263 */ "integer_list", - /* 264 */ "variable_list", - /* 265 */ "retention_list", - /* 266 */ "alter_db_option", - /* 267 */ "retention", - /* 268 */ "full_table_name", - /* 269 */ "column_def_list", - /* 270 */ "tags_def_opt", - /* 271 */ "table_options", - /* 272 */ "multi_create_clause", - /* 273 */ "tags_def", - /* 274 */ "multi_drop_clause", - /* 275 */ "alter_table_clause", - /* 276 */ "alter_table_options", - /* 277 */ "column_name", - /* 278 */ "type_name", - /* 279 */ "signed_literal", - /* 280 */ "create_subtable_clause", - /* 281 */ "specific_tags_opt", - /* 282 */ "literal_list", - /* 283 */ "drop_table_clause", - /* 284 */ "col_name_list", - /* 285 */ "table_name", - /* 286 */ "column_def", - /* 287 */ "duration_list", - /* 288 */ "rollup_func_list", - /* 289 */ "alter_table_option", - /* 290 */ "duration_literal", - /* 291 */ "rollup_func_name", - /* 292 */ "function_name", - /* 293 */ "col_name", - /* 294 */ "db_name_cond_opt", - /* 295 */ "like_pattern_opt", - /* 296 */ "table_name_cond", - /* 297 */ "from_db_opt", - /* 298 */ "index_name", - /* 299 */ "index_options", - /* 300 */ "func_list", - /* 301 */ "sliding_opt", - /* 302 */ "sma_stream_opt", - /* 303 */ "func", - /* 304 */ "expression_list", - /* 305 */ "stream_options", - /* 306 */ "topic_name", - /* 307 */ "query_expression", - /* 308 */ "cgroup_name", - /* 309 */ "analyze_opt", - /* 310 */ "explain_options", - /* 311 */ "agg_func_opt", - /* 312 */ "bufsize_opt", - /* 313 */ "stream_name", - /* 314 */ "into_opt", - /* 315 */ "dnode_list", - /* 316 */ "where_clause_opt", - /* 317 */ "signed", - /* 318 */ "literal_func", - /* 319 */ "table_alias", - /* 320 */ "column_alias", - /* 321 */ "expression", - /* 322 */ "pseudo_column", - /* 323 */ "column_reference", - /* 324 */ "function_expression", - /* 325 */ "subquery", - /* 326 */ "star_func", - /* 327 */ "star_func_para_list", - /* 328 */ "noarg_func", - /* 329 */ "other_para_list", - /* 330 */ "star_func_para", - /* 331 */ "predicate", - /* 332 */ "compare_op", - /* 333 */ "in_op", - /* 334 */ "in_predicate_value", - /* 335 */ "boolean_value_expression", - /* 336 */ "boolean_primary", - /* 337 */ "common_expression", - /* 338 */ "from_clause_opt", - /* 339 */ "table_reference_list", - /* 340 */ "table_reference", - /* 341 */ "table_primary", - /* 342 */ "joined_table", - /* 343 */ "alias_opt", - /* 344 */ "parenthesized_joined_table", - /* 345 */ "join_type", - /* 346 */ "search_condition", - /* 347 */ "query_specification", - /* 348 */ "set_quantifier_opt", - /* 349 */ "select_list", - /* 350 */ "partition_by_clause_opt", - /* 351 */ "range_opt", - /* 352 */ "every_opt", - /* 353 */ "fill_opt", - /* 354 */ "twindow_clause_opt", - /* 355 */ "group_by_clause_opt", - /* 356 */ "having_clause_opt", - /* 357 */ "select_sublist", - /* 358 */ "select_item", - /* 359 */ "fill_mode", - /* 360 */ "group_by_list", - /* 361 */ "query_expression_body", - /* 362 */ "order_by_clause_opt", - /* 363 */ "slimit_clause_opt", - /* 364 */ "limit_clause_opt", - /* 365 */ "query_primary", - /* 366 */ "sort_specification_list", - /* 367 */ "sort_specification", - /* 368 */ "ordering_specification_opt", - /* 369 */ "null_ordering_opt", + /* 201 */ "CLIENT_VERSION", + /* 202 */ "SERVER_VERSION", + /* 203 */ "SERVER_STATUS", + /* 204 */ "CURRENT_USER", + /* 205 */ "COUNT", + /* 206 */ "LAST_ROW", + /* 207 */ "BETWEEN", + /* 208 */ "IS", + /* 209 */ "NK_LT", + /* 210 */ "NK_GT", + /* 211 */ "NK_LE", + /* 212 */ "NK_GE", + /* 213 */ "NK_NE", + /* 214 */ "MATCH", + /* 215 */ "NMATCH", + /* 216 */ "CONTAINS", + /* 217 */ "JOIN", + /* 218 */ "INNER", + /* 219 */ "SELECT", + /* 220 */ "DISTINCT", + /* 221 */ "WHERE", + /* 222 */ "PARTITION", + /* 223 */ "BY", + /* 224 */ "SESSION", + /* 225 */ "STATE_WINDOW", + /* 226 */ "SLIDING", + /* 227 */ "FILL", + /* 228 */ "VALUE", + /* 229 */ "NONE", + /* 230 */ "PREV", + /* 231 */ "LINEAR", + /* 232 */ "NEXT", + /* 233 */ "HAVING", + /* 234 */ "RANGE", + /* 235 */ "EVERY", + /* 236 */ "ORDER", + /* 237 */ "SLIMIT", + /* 238 */ "SOFFSET", + /* 239 */ "LIMIT", + /* 240 */ "OFFSET", + /* 241 */ "ASC", + /* 242 */ "NULLS", + /* 243 */ "ID", + /* 244 */ "NK_BITNOT", + /* 245 */ "INSERT", + /* 246 */ "VALUES", + /* 247 */ "IMPORT", + /* 248 */ "NK_SEMI", + /* 249 */ "FILE", + /* 250 */ "cmd", + /* 251 */ "account_options", + /* 252 */ "alter_account_options", + /* 253 */ "literal", + /* 254 */ "alter_account_option", + /* 255 */ "user_name", + /* 256 */ "sysinfo_opt", + /* 257 */ "privileges", + /* 258 */ "priv_level", + /* 259 */ "priv_type_list", + /* 260 */ "priv_type", + /* 261 */ "db_name", + /* 262 */ "dnode_endpoint", + /* 263 */ "not_exists_opt", + /* 264 */ "db_options", + /* 265 */ "exists_opt", + /* 266 */ "alter_db_options", + /* 267 */ "integer_list", + /* 268 */ "variable_list", + /* 269 */ "retention_list", + /* 270 */ "alter_db_option", + /* 271 */ "retention", + /* 272 */ "full_table_name", + /* 273 */ "column_def_list", + /* 274 */ "tags_def_opt", + /* 275 */ "table_options", + /* 276 */ "multi_create_clause", + /* 277 */ "tags_def", + /* 278 */ "multi_drop_clause", + /* 279 */ "alter_table_clause", + /* 280 */ "alter_table_options", + /* 281 */ "column_name", + /* 282 */ "type_name", + /* 283 */ "signed_literal", + /* 284 */ "create_subtable_clause", + /* 285 */ "specific_tags_opt", + /* 286 */ "literal_list", + /* 287 */ "drop_table_clause", + /* 288 */ "col_name_list", + /* 289 */ "table_name", + /* 290 */ "column_def", + /* 291 */ "duration_list", + /* 292 */ "rollup_func_list", + /* 293 */ "alter_table_option", + /* 294 */ "duration_literal", + /* 295 */ "rollup_func_name", + /* 296 */ "function_name", + /* 297 */ "col_name", + /* 298 */ "db_name_cond_opt", + /* 299 */ "like_pattern_opt", + /* 300 */ "table_name_cond", + /* 301 */ "from_db_opt", + /* 302 */ "index_name", + /* 303 */ "index_options", + /* 304 */ "func_list", + /* 305 */ "sliding_opt", + /* 306 */ "sma_stream_opt", + /* 307 */ "func", + /* 308 */ "expression_list", + /* 309 */ "stream_options", + /* 310 */ "topic_name", + /* 311 */ "query_expression", + /* 312 */ "cgroup_name", + /* 313 */ "analyze_opt", + /* 314 */ "explain_options", + /* 315 */ "agg_func_opt", + /* 316 */ "bufsize_opt", + /* 317 */ "stream_name", + /* 318 */ "into_opt", + /* 319 */ "dnode_list", + /* 320 */ "where_clause_opt", + /* 321 */ "signed", + /* 322 */ "literal_func", + /* 323 */ "table_alias", + /* 324 */ "column_alias", + /* 325 */ "expression", + /* 326 */ "pseudo_column", + /* 327 */ "column_reference", + /* 328 */ "function_expression", + /* 329 */ "subquery", + /* 330 */ "star_func", + /* 331 */ "star_func_para_list", + /* 332 */ "noarg_func", + /* 333 */ "other_para_list", + /* 334 */ "star_func_para", + /* 335 */ "predicate", + /* 336 */ "compare_op", + /* 337 */ "in_op", + /* 338 */ "in_predicate_value", + /* 339 */ "boolean_value_expression", + /* 340 */ "boolean_primary", + /* 341 */ "common_expression", + /* 342 */ "from_clause_opt", + /* 343 */ "table_reference_list", + /* 344 */ "table_reference", + /* 345 */ "table_primary", + /* 346 */ "joined_table", + /* 347 */ "alias_opt", + /* 348 */ "parenthesized_joined_table", + /* 349 */ "join_type", + /* 350 */ "search_condition", + /* 351 */ "query_specification", + /* 352 */ "set_quantifier_opt", + /* 353 */ "select_list", + /* 354 */ "partition_by_clause_opt", + /* 355 */ "range_opt", + /* 356 */ "every_opt", + /* 357 */ "fill_opt", + /* 358 */ "twindow_clause_opt", + /* 359 */ "group_by_clause_opt", + /* 360 */ "having_clause_opt", + /* 361 */ "select_sublist", + /* 362 */ "select_item", + /* 363 */ "fill_mode", + /* 364 */ "group_by_list", + /* 365 */ "query_expression_body", + /* 366 */ "order_by_clause_opt", + /* 367 */ "slimit_clause_opt", + /* 368 */ "limit_clause_opt", + /* 369 */ "query_primary", + /* 370 */ "sort_specification_list", + /* 371 */ "sort_specification", + /* 372 */ "ordering_specification_opt", + /* 373 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1915,130 +1979,136 @@ static const char *const yyRuleName[] = { /* 350 */ "noarg_func ::= NOW", /* 351 */ "noarg_func ::= TODAY", /* 352 */ "noarg_func ::= TIMEZONE", - /* 353 */ "star_func ::= COUNT", - /* 354 */ "star_func ::= FIRST", - /* 355 */ "star_func ::= LAST", - /* 356 */ "star_func ::= LAST_ROW", - /* 357 */ "star_func_para_list ::= NK_STAR", - /* 358 */ "star_func_para_list ::= other_para_list", - /* 359 */ "other_para_list ::= star_func_para", - /* 360 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 361 */ "star_func_para ::= expression", - /* 362 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 363 */ "predicate ::= expression compare_op expression", - /* 364 */ "predicate ::= expression BETWEEN expression AND expression", - /* 365 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 366 */ "predicate ::= expression IS NULL", - /* 367 */ "predicate ::= expression IS NOT NULL", - /* 368 */ "predicate ::= expression in_op in_predicate_value", - /* 369 */ "compare_op ::= NK_LT", - /* 370 */ "compare_op ::= NK_GT", - /* 371 */ "compare_op ::= NK_LE", - /* 372 */ "compare_op ::= NK_GE", - /* 373 */ "compare_op ::= NK_NE", - /* 374 */ "compare_op ::= NK_EQ", - /* 375 */ "compare_op ::= LIKE", - /* 376 */ "compare_op ::= NOT LIKE", - /* 377 */ "compare_op ::= MATCH", - /* 378 */ "compare_op ::= NMATCH", - /* 379 */ "compare_op ::= CONTAINS", - /* 380 */ "in_op ::= IN", - /* 381 */ "in_op ::= NOT IN", - /* 382 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 383 */ "boolean_value_expression ::= boolean_primary", - /* 384 */ "boolean_value_expression ::= NOT boolean_primary", - /* 385 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 386 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 387 */ "boolean_primary ::= predicate", - /* 388 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 389 */ "common_expression ::= expression", - /* 390 */ "common_expression ::= boolean_value_expression", - /* 391 */ "from_clause_opt ::=", - /* 392 */ "from_clause_opt ::= FROM table_reference_list", - /* 393 */ "table_reference_list ::= table_reference", - /* 394 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 395 */ "table_reference ::= table_primary", - /* 396 */ "table_reference ::= joined_table", - /* 397 */ "table_primary ::= table_name alias_opt", - /* 398 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 399 */ "table_primary ::= subquery alias_opt", - /* 400 */ "table_primary ::= parenthesized_joined_table", - /* 401 */ "alias_opt ::=", - /* 402 */ "alias_opt ::= table_alias", - /* 403 */ "alias_opt ::= AS table_alias", - /* 404 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 405 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 406 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 407 */ "join_type ::=", - /* 408 */ "join_type ::= INNER", - /* 409 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 410 */ "set_quantifier_opt ::=", - /* 411 */ "set_quantifier_opt ::= DISTINCT", - /* 412 */ "set_quantifier_opt ::= ALL", - /* 413 */ "select_list ::= NK_STAR", - /* 414 */ "select_list ::= select_sublist", - /* 415 */ "select_sublist ::= select_item", - /* 416 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 417 */ "select_item ::= common_expression", - /* 418 */ "select_item ::= common_expression column_alias", - /* 419 */ "select_item ::= common_expression AS column_alias", - /* 420 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 421 */ "where_clause_opt ::=", - /* 422 */ "where_clause_opt ::= WHERE search_condition", - /* 423 */ "partition_by_clause_opt ::=", - /* 424 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 425 */ "twindow_clause_opt ::=", - /* 426 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 427 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 428 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 429 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 430 */ "sliding_opt ::=", - /* 431 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 432 */ "fill_opt ::=", - /* 433 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 434 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 435 */ "fill_mode ::= NONE", - /* 436 */ "fill_mode ::= PREV", - /* 437 */ "fill_mode ::= NULL", - /* 438 */ "fill_mode ::= LINEAR", - /* 439 */ "fill_mode ::= NEXT", - /* 440 */ "group_by_clause_opt ::=", - /* 441 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 442 */ "group_by_list ::= expression", - /* 443 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 444 */ "having_clause_opt ::=", - /* 445 */ "having_clause_opt ::= HAVING search_condition", - /* 446 */ "range_opt ::=", - /* 447 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", - /* 448 */ "every_opt ::=", - /* 449 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 450 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 451 */ "query_expression_body ::= query_primary", - /* 452 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 453 */ "query_expression_body ::= query_expression_body UNION query_expression_body", - /* 454 */ "query_primary ::= query_specification", - /* 455 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", - /* 456 */ "order_by_clause_opt ::=", - /* 457 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 458 */ "slimit_clause_opt ::=", - /* 459 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 460 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 461 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 462 */ "limit_clause_opt ::=", - /* 463 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 464 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 465 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 466 */ "subquery ::= NK_LP query_expression NK_RP", - /* 467 */ "search_condition ::= common_expression", - /* 468 */ "sort_specification_list ::= sort_specification", - /* 469 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 470 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 471 */ "ordering_specification_opt ::=", - /* 472 */ "ordering_specification_opt ::= ASC", - /* 473 */ "ordering_specification_opt ::= DESC", - /* 474 */ "null_ordering_opt ::=", - /* 475 */ "null_ordering_opt ::= NULLS FIRST", - /* 476 */ "null_ordering_opt ::= NULLS LAST", + /* 353 */ "noarg_func ::= DATABASE", + /* 354 */ "noarg_func ::= CLIENT_VERSION", + /* 355 */ "noarg_func ::= SERVER_VERSION", + /* 356 */ "noarg_func ::= SERVER_STATUS", + /* 357 */ "noarg_func ::= CURRENT_USER", + /* 358 */ "noarg_func ::= USER", + /* 359 */ "star_func ::= COUNT", + /* 360 */ "star_func ::= FIRST", + /* 361 */ "star_func ::= LAST", + /* 362 */ "star_func ::= LAST_ROW", + /* 363 */ "star_func_para_list ::= NK_STAR", + /* 364 */ "star_func_para_list ::= other_para_list", + /* 365 */ "other_para_list ::= star_func_para", + /* 366 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 367 */ "star_func_para ::= expression", + /* 368 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 369 */ "predicate ::= expression compare_op expression", + /* 370 */ "predicate ::= expression BETWEEN expression AND expression", + /* 371 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 372 */ "predicate ::= expression IS NULL", + /* 373 */ "predicate ::= expression IS NOT NULL", + /* 374 */ "predicate ::= expression in_op in_predicate_value", + /* 375 */ "compare_op ::= NK_LT", + /* 376 */ "compare_op ::= NK_GT", + /* 377 */ "compare_op ::= NK_LE", + /* 378 */ "compare_op ::= NK_GE", + /* 379 */ "compare_op ::= NK_NE", + /* 380 */ "compare_op ::= NK_EQ", + /* 381 */ "compare_op ::= LIKE", + /* 382 */ "compare_op ::= NOT LIKE", + /* 383 */ "compare_op ::= MATCH", + /* 384 */ "compare_op ::= NMATCH", + /* 385 */ "compare_op ::= CONTAINS", + /* 386 */ "in_op ::= IN", + /* 387 */ "in_op ::= NOT IN", + /* 388 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 389 */ "boolean_value_expression ::= boolean_primary", + /* 390 */ "boolean_value_expression ::= NOT boolean_primary", + /* 391 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 392 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 393 */ "boolean_primary ::= predicate", + /* 394 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 395 */ "common_expression ::= expression", + /* 396 */ "common_expression ::= boolean_value_expression", + /* 397 */ "from_clause_opt ::=", + /* 398 */ "from_clause_opt ::= FROM table_reference_list", + /* 399 */ "table_reference_list ::= table_reference", + /* 400 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 401 */ "table_reference ::= table_primary", + /* 402 */ "table_reference ::= joined_table", + /* 403 */ "table_primary ::= table_name alias_opt", + /* 404 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 405 */ "table_primary ::= subquery alias_opt", + /* 406 */ "table_primary ::= parenthesized_joined_table", + /* 407 */ "alias_opt ::=", + /* 408 */ "alias_opt ::= table_alias", + /* 409 */ "alias_opt ::= AS table_alias", + /* 410 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 411 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 412 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 413 */ "join_type ::=", + /* 414 */ "join_type ::= INNER", + /* 415 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 416 */ "set_quantifier_opt ::=", + /* 417 */ "set_quantifier_opt ::= DISTINCT", + /* 418 */ "set_quantifier_opt ::= ALL", + /* 419 */ "select_list ::= NK_STAR", + /* 420 */ "select_list ::= select_sublist", + /* 421 */ "select_sublist ::= select_item", + /* 422 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 423 */ "select_item ::= common_expression", + /* 424 */ "select_item ::= common_expression column_alias", + /* 425 */ "select_item ::= common_expression AS column_alias", + /* 426 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 427 */ "where_clause_opt ::=", + /* 428 */ "where_clause_opt ::= WHERE search_condition", + /* 429 */ "partition_by_clause_opt ::=", + /* 430 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 431 */ "twindow_clause_opt ::=", + /* 432 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 433 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 434 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 435 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 436 */ "sliding_opt ::=", + /* 437 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 438 */ "fill_opt ::=", + /* 439 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 440 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 441 */ "fill_mode ::= NONE", + /* 442 */ "fill_mode ::= PREV", + /* 443 */ "fill_mode ::= NULL", + /* 444 */ "fill_mode ::= LINEAR", + /* 445 */ "fill_mode ::= NEXT", + /* 446 */ "group_by_clause_opt ::=", + /* 447 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 448 */ "group_by_list ::= expression", + /* 449 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 450 */ "having_clause_opt ::=", + /* 451 */ "having_clause_opt ::= HAVING search_condition", + /* 452 */ "range_opt ::=", + /* 453 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", + /* 454 */ "every_opt ::=", + /* 455 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 456 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 457 */ "query_expression_body ::= query_primary", + /* 458 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 459 */ "query_expression_body ::= query_expression_body UNION query_expression_body", + /* 460 */ "query_primary ::= query_specification", + /* 461 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", + /* 462 */ "order_by_clause_opt ::=", + /* 463 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 464 */ "slimit_clause_opt ::=", + /* 465 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 466 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 467 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 468 */ "limit_clause_opt ::=", + /* 469 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 470 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 471 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 472 */ "subquery ::= NK_LP query_expression NK_RP", + /* 473 */ "search_condition ::= common_expression", + /* 474 */ "sort_specification_list ::= sort_specification", + /* 475 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 476 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 477 */ "ordering_specification_opt ::=", + /* 478 */ "ordering_specification_opt ::= ASC", + /* 479 */ "ordering_specification_opt ::= DESC", + /* 480 */ "null_ordering_opt ::=", + /* 481 */ "null_ordering_opt ::= NULLS FIRST", + /* 482 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2165,182 +2235,182 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 246: /* cmd */ - case 249: /* literal */ - case 260: /* db_options */ - case 262: /* alter_db_options */ - case 267: /* retention */ - case 268: /* full_table_name */ - case 271: /* table_options */ - case 275: /* alter_table_clause */ - case 276: /* alter_table_options */ - case 279: /* signed_literal */ - case 280: /* create_subtable_clause */ - case 283: /* drop_table_clause */ - case 286: /* column_def */ - case 290: /* duration_literal */ - case 291: /* rollup_func_name */ - case 293: /* col_name */ - case 294: /* db_name_cond_opt */ - case 295: /* like_pattern_opt */ - case 296: /* table_name_cond */ - case 297: /* from_db_opt */ - case 299: /* index_options */ - case 301: /* sliding_opt */ - case 302: /* sma_stream_opt */ - case 303: /* func */ - case 305: /* stream_options */ - case 307: /* query_expression */ - case 310: /* explain_options */ - case 314: /* into_opt */ - case 316: /* where_clause_opt */ - case 317: /* signed */ - case 318: /* literal_func */ - case 321: /* expression */ - case 322: /* pseudo_column */ - case 323: /* column_reference */ - case 324: /* function_expression */ - case 325: /* subquery */ - case 330: /* star_func_para */ - case 331: /* predicate */ - case 334: /* in_predicate_value */ - case 335: /* boolean_value_expression */ - case 336: /* boolean_primary */ - case 337: /* common_expression */ - case 338: /* from_clause_opt */ - case 339: /* table_reference_list */ - case 340: /* table_reference */ - case 341: /* table_primary */ - case 342: /* joined_table */ - case 344: /* parenthesized_joined_table */ - case 346: /* search_condition */ - case 347: /* query_specification */ - case 351: /* range_opt */ - case 352: /* every_opt */ - case 353: /* fill_opt */ - case 354: /* twindow_clause_opt */ - case 356: /* having_clause_opt */ - case 358: /* select_item */ - case 361: /* query_expression_body */ - case 363: /* slimit_clause_opt */ - case 364: /* limit_clause_opt */ - case 365: /* query_primary */ - case 367: /* sort_specification */ + case 250: /* cmd */ + case 253: /* literal */ + case 264: /* db_options */ + case 266: /* alter_db_options */ + case 271: /* retention */ + case 272: /* full_table_name */ + case 275: /* table_options */ + case 279: /* alter_table_clause */ + case 280: /* alter_table_options */ + case 283: /* signed_literal */ + case 284: /* create_subtable_clause */ + case 287: /* drop_table_clause */ + case 290: /* column_def */ + case 294: /* duration_literal */ + case 295: /* rollup_func_name */ + case 297: /* col_name */ + case 298: /* db_name_cond_opt */ + case 299: /* like_pattern_opt */ + case 300: /* table_name_cond */ + case 301: /* from_db_opt */ + case 303: /* index_options */ + case 305: /* sliding_opt */ + case 306: /* sma_stream_opt */ + case 307: /* func */ + case 309: /* stream_options */ + case 311: /* query_expression */ + case 314: /* explain_options */ + case 318: /* into_opt */ + case 320: /* where_clause_opt */ + case 321: /* signed */ + case 322: /* literal_func */ + case 325: /* expression */ + case 326: /* pseudo_column */ + case 327: /* column_reference */ + case 328: /* function_expression */ + case 329: /* subquery */ + case 334: /* star_func_para */ + case 335: /* predicate */ + case 338: /* in_predicate_value */ + case 339: /* boolean_value_expression */ + case 340: /* boolean_primary */ + case 341: /* common_expression */ + case 342: /* from_clause_opt */ + case 343: /* table_reference_list */ + case 344: /* table_reference */ + case 345: /* table_primary */ + case 346: /* joined_table */ + case 348: /* parenthesized_joined_table */ + case 350: /* search_condition */ + case 351: /* query_specification */ + case 355: /* range_opt */ + case 356: /* every_opt */ + case 357: /* fill_opt */ + case 358: /* twindow_clause_opt */ + case 360: /* having_clause_opt */ + case 362: /* select_item */ + case 365: /* query_expression_body */ + case 367: /* slimit_clause_opt */ + case 368: /* limit_clause_opt */ + case 369: /* query_primary */ + case 371: /* sort_specification */ { - nodesDestroyNode((yypminor->yy452)); + nodesDestroyNode((yypminor->yy652)); } break; - case 247: /* account_options */ - case 248: /* alter_account_options */ - case 250: /* alter_account_option */ - case 312: /* bufsize_opt */ + case 251: /* account_options */ + case 252: /* alter_account_options */ + case 254: /* alter_account_option */ + case 316: /* bufsize_opt */ { } break; - case 251: /* user_name */ - case 254: /* priv_level */ - case 257: /* db_name */ - case 258: /* dnode_endpoint */ - case 277: /* column_name */ - case 285: /* table_name */ - case 292: /* function_name */ - case 298: /* index_name */ - case 306: /* topic_name */ - case 308: /* cgroup_name */ - case 313: /* stream_name */ - case 319: /* table_alias */ - case 320: /* column_alias */ - case 326: /* star_func */ - case 328: /* noarg_func */ - case 343: /* alias_opt */ + case 255: /* user_name */ + case 258: /* priv_level */ + case 261: /* db_name */ + case 262: /* dnode_endpoint */ + case 281: /* column_name */ + case 289: /* table_name */ + case 296: /* function_name */ + case 302: /* index_name */ + case 310: /* topic_name */ + case 312: /* cgroup_name */ + case 317: /* stream_name */ + case 323: /* table_alias */ + case 324: /* column_alias */ + case 330: /* star_func */ + case 332: /* noarg_func */ + case 347: /* alias_opt */ { } break; - case 252: /* sysinfo_opt */ + case 256: /* sysinfo_opt */ { } break; - case 253: /* privileges */ - case 255: /* priv_type_list */ - case 256: /* priv_type */ + case 257: /* privileges */ + case 259: /* priv_type_list */ + case 260: /* priv_type */ { } break; - case 259: /* not_exists_opt */ - case 261: /* exists_opt */ - case 309: /* analyze_opt */ - case 311: /* agg_func_opt */ - case 348: /* set_quantifier_opt */ + case 263: /* not_exists_opt */ + case 265: /* exists_opt */ + case 313: /* analyze_opt */ + case 315: /* agg_func_opt */ + case 352: /* set_quantifier_opt */ { } break; - case 263: /* integer_list */ - case 264: /* variable_list */ - case 265: /* retention_list */ - case 269: /* column_def_list */ - case 270: /* tags_def_opt */ - case 272: /* multi_create_clause */ - case 273: /* tags_def */ - case 274: /* multi_drop_clause */ - case 281: /* specific_tags_opt */ - case 282: /* literal_list */ - case 284: /* col_name_list */ - case 287: /* duration_list */ - case 288: /* rollup_func_list */ - case 300: /* func_list */ - case 304: /* expression_list */ - case 315: /* dnode_list */ - case 327: /* star_func_para_list */ - case 329: /* other_para_list */ - case 349: /* select_list */ - case 350: /* partition_by_clause_opt */ - case 355: /* group_by_clause_opt */ - case 357: /* select_sublist */ - case 360: /* group_by_list */ - case 362: /* order_by_clause_opt */ - case 366: /* sort_specification_list */ + case 267: /* integer_list */ + case 268: /* variable_list */ + case 269: /* retention_list */ + case 273: /* column_def_list */ + case 274: /* tags_def_opt */ + case 276: /* multi_create_clause */ + case 277: /* tags_def */ + case 278: /* multi_drop_clause */ + case 285: /* specific_tags_opt */ + case 286: /* literal_list */ + case 288: /* col_name_list */ + case 291: /* duration_list */ + case 292: /* rollup_func_list */ + case 304: /* func_list */ + case 308: /* expression_list */ + case 319: /* dnode_list */ + case 331: /* star_func_para_list */ + case 333: /* other_para_list */ + case 353: /* select_list */ + case 354: /* partition_by_clause_opt */ + case 359: /* group_by_clause_opt */ + case 361: /* select_sublist */ + case 364: /* group_by_list */ + case 366: /* order_by_clause_opt */ + case 370: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy404)); + nodesDestroyList((yypminor->yy24)); } break; - case 266: /* alter_db_option */ - case 289: /* alter_table_option */ + case 270: /* alter_db_option */ + case 293: /* alter_table_option */ { } break; - case 278: /* type_name */ + case 282: /* type_name */ { } break; - case 332: /* compare_op */ - case 333: /* in_op */ + case 336: /* compare_op */ + case 337: /* in_op */ { } break; - case 345: /* join_type */ + case 349: /* join_type */ { } break; - case 359: /* fill_mode */ + case 363: /* fill_mode */ { } break; - case 368: /* ordering_specification_opt */ + case 372: /* ordering_specification_opt */ { } break; - case 369: /* null_ordering_opt */ + case 373: /* null_ordering_opt */ { } @@ -2639,483 +2709,489 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { - { 246, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 246, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 247, 0 }, /* (2) account_options ::= */ - { 247, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 247, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 247, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 247, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 247, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 247, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 247, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 247, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 247, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 248, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 248, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 250, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 250, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 250, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 250, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 250, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 250, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 250, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 250, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 250, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 250, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 246, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ - { 246, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 246, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - { 246, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - { 246, -3 }, /* (28) cmd ::= DROP USER user_name */ - { 252, 0 }, /* (29) sysinfo_opt ::= */ - { 252, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ - { 246, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 246, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 253, -1 }, /* (33) privileges ::= ALL */ - { 253, -1 }, /* (34) privileges ::= priv_type_list */ - { 255, -1 }, /* (35) priv_type_list ::= priv_type */ - { 255, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 256, -1 }, /* (37) priv_type ::= READ */ - { 256, -1 }, /* (38) priv_type ::= WRITE */ - { 254, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 254, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ - { 246, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ - { 246, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - { 246, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ - { 246, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ - { 246, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 246, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 246, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ - { 246, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 258, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ - { 258, -1 }, /* (50) dnode_endpoint ::= NK_ID */ - { 258, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ - { 246, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ - { 246, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 246, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 246, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 246, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 246, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 246, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 246, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 246, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 246, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 246, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 246, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ - { 246, -2 }, /* (64) cmd ::= USE db_name */ - { 246, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 259, -3 }, /* (66) not_exists_opt ::= IF NOT EXISTS */ - { 259, 0 }, /* (67) not_exists_opt ::= */ - { 261, -2 }, /* (68) exists_opt ::= IF EXISTS */ - { 261, 0 }, /* (69) exists_opt ::= */ - { 260, 0 }, /* (70) db_options ::= */ - { 260, -3 }, /* (71) db_options ::= db_options BUFFER NK_INTEGER */ - { 260, -3 }, /* (72) db_options ::= db_options CACHELAST NK_INTEGER */ - { 260, -3 }, /* (73) db_options ::= db_options COMP NK_INTEGER */ - { 260, -3 }, /* (74) db_options ::= db_options DURATION NK_INTEGER */ - { 260, -3 }, /* (75) db_options ::= db_options DURATION NK_VARIABLE */ - { 260, -3 }, /* (76) db_options ::= db_options FSYNC NK_INTEGER */ - { 260, -3 }, /* (77) db_options ::= db_options MAXROWS NK_INTEGER */ - { 260, -3 }, /* (78) db_options ::= db_options MINROWS NK_INTEGER */ - { 260, -3 }, /* (79) db_options ::= db_options KEEP integer_list */ - { 260, -3 }, /* (80) db_options ::= db_options KEEP variable_list */ - { 260, -3 }, /* (81) db_options ::= db_options PAGES NK_INTEGER */ - { 260, -3 }, /* (82) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 260, -3 }, /* (83) db_options ::= db_options PRECISION NK_STRING */ - { 260, -3 }, /* (84) db_options ::= db_options REPLICA NK_INTEGER */ - { 260, -3 }, /* (85) db_options ::= db_options STRICT NK_INTEGER */ - { 260, -3 }, /* (86) db_options ::= db_options WAL NK_INTEGER */ - { 260, -3 }, /* (87) db_options ::= db_options VGROUPS NK_INTEGER */ - { 260, -3 }, /* (88) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 260, -3 }, /* (89) db_options ::= db_options RETENTIONS retention_list */ - { 260, -3 }, /* (90) db_options ::= db_options SCHEMALESS NK_INTEGER */ - { 262, -1 }, /* (91) alter_db_options ::= alter_db_option */ - { 262, -2 }, /* (92) alter_db_options ::= alter_db_options alter_db_option */ - { 266, -2 }, /* (93) alter_db_option ::= BUFFER NK_INTEGER */ - { 266, -2 }, /* (94) alter_db_option ::= CACHELAST NK_INTEGER */ - { 266, -2 }, /* (95) alter_db_option ::= FSYNC NK_INTEGER */ - { 266, -2 }, /* (96) alter_db_option ::= KEEP integer_list */ - { 266, -2 }, /* (97) alter_db_option ::= KEEP variable_list */ - { 266, -2 }, /* (98) alter_db_option ::= PAGES NK_INTEGER */ - { 266, -2 }, /* (99) alter_db_option ::= REPLICA NK_INTEGER */ - { 266, -2 }, /* (100) alter_db_option ::= STRICT NK_INTEGER */ - { 266, -2 }, /* (101) alter_db_option ::= WAL NK_INTEGER */ - { 263, -1 }, /* (102) integer_list ::= NK_INTEGER */ - { 263, -3 }, /* (103) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 264, -1 }, /* (104) variable_list ::= NK_VARIABLE */ - { 264, -3 }, /* (105) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 265, -1 }, /* (106) retention_list ::= retention */ - { 265, -3 }, /* (107) retention_list ::= retention_list NK_COMMA retention */ - { 267, -3 }, /* (108) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 246, -9 }, /* (109) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 246, -3 }, /* (110) cmd ::= CREATE TABLE multi_create_clause */ - { 246, -9 }, /* (111) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 246, -3 }, /* (112) cmd ::= DROP TABLE multi_drop_clause */ - { 246, -4 }, /* (113) cmd ::= DROP STABLE exists_opt full_table_name */ - { 246, -3 }, /* (114) cmd ::= ALTER TABLE alter_table_clause */ - { 246, -3 }, /* (115) cmd ::= ALTER STABLE alter_table_clause */ - { 275, -2 }, /* (116) alter_table_clause ::= full_table_name alter_table_options */ - { 275, -5 }, /* (117) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 275, -4 }, /* (118) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 275, -5 }, /* (119) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 275, -5 }, /* (120) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 275, -5 }, /* (121) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 275, -4 }, /* (122) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 275, -5 }, /* (123) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 275, -5 }, /* (124) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 275, -6 }, /* (125) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 272, -1 }, /* (126) multi_create_clause ::= create_subtable_clause */ - { 272, -2 }, /* (127) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 280, -10 }, /* (128) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ - { 274, -1 }, /* (129) multi_drop_clause ::= drop_table_clause */ - { 274, -2 }, /* (130) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 283, -2 }, /* (131) drop_table_clause ::= exists_opt full_table_name */ - { 281, 0 }, /* (132) specific_tags_opt ::= */ - { 281, -3 }, /* (133) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 268, -1 }, /* (134) full_table_name ::= table_name */ - { 268, -3 }, /* (135) full_table_name ::= db_name NK_DOT table_name */ - { 269, -1 }, /* (136) column_def_list ::= column_def */ - { 269, -3 }, /* (137) column_def_list ::= column_def_list NK_COMMA column_def */ - { 286, -2 }, /* (138) column_def ::= column_name type_name */ - { 286, -4 }, /* (139) column_def ::= column_name type_name COMMENT NK_STRING */ - { 278, -1 }, /* (140) type_name ::= BOOL */ - { 278, -1 }, /* (141) type_name ::= TINYINT */ - { 278, -1 }, /* (142) type_name ::= SMALLINT */ - { 278, -1 }, /* (143) type_name ::= INT */ - { 278, -1 }, /* (144) type_name ::= INTEGER */ - { 278, -1 }, /* (145) type_name ::= BIGINT */ - { 278, -1 }, /* (146) type_name ::= FLOAT */ - { 278, -1 }, /* (147) type_name ::= DOUBLE */ - { 278, -4 }, /* (148) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 278, -1 }, /* (149) type_name ::= TIMESTAMP */ - { 278, -4 }, /* (150) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 278, -2 }, /* (151) type_name ::= TINYINT UNSIGNED */ - { 278, -2 }, /* (152) type_name ::= SMALLINT UNSIGNED */ - { 278, -2 }, /* (153) type_name ::= INT UNSIGNED */ - { 278, -2 }, /* (154) type_name ::= BIGINT UNSIGNED */ - { 278, -1 }, /* (155) type_name ::= JSON */ - { 278, -4 }, /* (156) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 278, -1 }, /* (157) type_name ::= MEDIUMBLOB */ - { 278, -1 }, /* (158) type_name ::= BLOB */ - { 278, -4 }, /* (159) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 278, -1 }, /* (160) type_name ::= DECIMAL */ - { 278, -4 }, /* (161) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 278, -6 }, /* (162) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 270, 0 }, /* (163) tags_def_opt ::= */ - { 270, -1 }, /* (164) tags_def_opt ::= tags_def */ - { 273, -4 }, /* (165) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 271, 0 }, /* (166) table_options ::= */ - { 271, -3 }, /* (167) table_options ::= table_options COMMENT NK_STRING */ - { 271, -3 }, /* (168) table_options ::= table_options MAX_DELAY duration_list */ - { 271, -3 }, /* (169) table_options ::= table_options WATERMARK duration_list */ - { 271, -5 }, /* (170) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - { 271, -3 }, /* (171) table_options ::= table_options TTL NK_INTEGER */ - { 271, -5 }, /* (172) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 276, -1 }, /* (173) alter_table_options ::= alter_table_option */ - { 276, -2 }, /* (174) alter_table_options ::= alter_table_options alter_table_option */ - { 289, -2 }, /* (175) alter_table_option ::= COMMENT NK_STRING */ - { 289, -2 }, /* (176) alter_table_option ::= TTL NK_INTEGER */ - { 287, -1 }, /* (177) duration_list ::= duration_literal */ - { 287, -3 }, /* (178) duration_list ::= duration_list NK_COMMA duration_literal */ - { 288, -1 }, /* (179) rollup_func_list ::= rollup_func_name */ - { 288, -3 }, /* (180) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - { 291, -1 }, /* (181) rollup_func_name ::= function_name */ - { 291, -1 }, /* (182) rollup_func_name ::= FIRST */ - { 291, -1 }, /* (183) rollup_func_name ::= LAST */ - { 284, -1 }, /* (184) col_name_list ::= col_name */ - { 284, -3 }, /* (185) col_name_list ::= col_name_list NK_COMMA col_name */ - { 293, -1 }, /* (186) col_name ::= column_name */ - { 246, -2 }, /* (187) cmd ::= SHOW DNODES */ - { 246, -2 }, /* (188) cmd ::= SHOW USERS */ - { 246, -2 }, /* (189) cmd ::= SHOW DATABASES */ - { 246, -4 }, /* (190) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 246, -4 }, /* (191) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 246, -3 }, /* (192) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 246, -2 }, /* (193) cmd ::= SHOW MNODES */ - { 246, -2 }, /* (194) cmd ::= SHOW MODULES */ - { 246, -2 }, /* (195) cmd ::= SHOW QNODES */ - { 246, -2 }, /* (196) cmd ::= SHOW FUNCTIONS */ - { 246, -5 }, /* (197) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 246, -2 }, /* (198) cmd ::= SHOW STREAMS */ - { 246, -2 }, /* (199) cmd ::= SHOW ACCOUNTS */ - { 246, -2 }, /* (200) cmd ::= SHOW APPS */ - { 246, -2 }, /* (201) cmd ::= SHOW CONNECTIONS */ - { 246, -2 }, /* (202) cmd ::= SHOW LICENCE */ - { 246, -2 }, /* (203) cmd ::= SHOW GRANTS */ - { 246, -4 }, /* (204) cmd ::= SHOW CREATE DATABASE db_name */ - { 246, -4 }, /* (205) cmd ::= SHOW CREATE TABLE full_table_name */ - { 246, -4 }, /* (206) cmd ::= SHOW CREATE STABLE full_table_name */ - { 246, -2 }, /* (207) cmd ::= SHOW QUERIES */ - { 246, -2 }, /* (208) cmd ::= SHOW SCORES */ - { 246, -2 }, /* (209) cmd ::= SHOW TOPICS */ - { 246, -2 }, /* (210) cmd ::= SHOW VARIABLES */ - { 246, -3 }, /* (211) cmd ::= SHOW LOCAL VARIABLES */ - { 246, -4 }, /* (212) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ - { 246, -2 }, /* (213) cmd ::= SHOW BNODES */ - { 246, -2 }, /* (214) cmd ::= SHOW SNODES */ - { 246, -2 }, /* (215) cmd ::= SHOW CLUSTER */ - { 246, -2 }, /* (216) cmd ::= SHOW TRANSACTIONS */ - { 246, -4 }, /* (217) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - { 246, -2 }, /* (218) cmd ::= SHOW CONSUMERS */ - { 246, -2 }, /* (219) cmd ::= SHOW SUBSCRIPTIONS */ - { 294, 0 }, /* (220) db_name_cond_opt ::= */ - { 294, -2 }, /* (221) db_name_cond_opt ::= db_name NK_DOT */ - { 295, 0 }, /* (222) like_pattern_opt ::= */ - { 295, -2 }, /* (223) like_pattern_opt ::= LIKE NK_STRING */ - { 296, -1 }, /* (224) table_name_cond ::= table_name */ - { 297, 0 }, /* (225) from_db_opt ::= */ - { 297, -2 }, /* (226) from_db_opt ::= FROM db_name */ - { 246, -8 }, /* (227) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - { 246, -4 }, /* (228) cmd ::= DROP INDEX exists_opt index_name */ - { 299, -10 }, /* (229) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - { 299, -12 }, /* (230) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ - { 300, -1 }, /* (231) func_list ::= func */ - { 300, -3 }, /* (232) func_list ::= func_list NK_COMMA func */ - { 303, -4 }, /* (233) func ::= function_name NK_LP expression_list NK_RP */ - { 302, 0 }, /* (234) sma_stream_opt ::= */ - { 302, -3 }, /* (235) sma_stream_opt ::= stream_options WATERMARK duration_literal */ - { 302, -3 }, /* (236) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ - { 246, -6 }, /* (237) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 246, -7 }, /* (238) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 246, -9 }, /* (239) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ - { 246, -7 }, /* (240) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 246, -9 }, /* (241) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ - { 246, -4 }, /* (242) cmd ::= DROP TOPIC exists_opt topic_name */ - { 246, -7 }, /* (243) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 246, -2 }, /* (244) cmd ::= DESC full_table_name */ - { 246, -2 }, /* (245) cmd ::= DESCRIBE full_table_name */ - { 246, -3 }, /* (246) cmd ::= RESET QUERY CACHE */ - { 246, -4 }, /* (247) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - { 309, 0 }, /* (248) analyze_opt ::= */ - { 309, -1 }, /* (249) analyze_opt ::= ANALYZE */ - { 310, 0 }, /* (250) explain_options ::= */ - { 310, -3 }, /* (251) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 310, -3 }, /* (252) explain_options ::= explain_options RATIO NK_FLOAT */ - { 246, -6 }, /* (253) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ - { 246, -10 }, /* (254) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 246, -4 }, /* (255) cmd ::= DROP FUNCTION exists_opt function_name */ - { 311, 0 }, /* (256) agg_func_opt ::= */ - { 311, -1 }, /* (257) agg_func_opt ::= AGGREGATE */ - { 312, 0 }, /* (258) bufsize_opt ::= */ - { 312, -2 }, /* (259) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 246, -8 }, /* (260) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ - { 246, -4 }, /* (261) cmd ::= DROP STREAM exists_opt stream_name */ - { 314, 0 }, /* (262) into_opt ::= */ - { 314, -2 }, /* (263) into_opt ::= INTO full_table_name */ - { 305, 0 }, /* (264) stream_options ::= */ - { 305, -3 }, /* (265) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 305, -3 }, /* (266) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 305, -4 }, /* (267) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 305, -3 }, /* (268) stream_options ::= stream_options WATERMARK duration_literal */ - { 246, -3 }, /* (269) cmd ::= KILL CONNECTION NK_INTEGER */ - { 246, -3 }, /* (270) cmd ::= KILL QUERY NK_STRING */ - { 246, -3 }, /* (271) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 246, -2 }, /* (272) cmd ::= BALANCE VGROUP */ - { 246, -4 }, /* (273) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 246, -4 }, /* (274) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 246, -3 }, /* (275) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 315, -2 }, /* (276) dnode_list ::= DNODE NK_INTEGER */ - { 315, -3 }, /* (277) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 246, -3 }, /* (278) cmd ::= SYNCDB db_name REPLICA */ - { 246, -4 }, /* (279) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 246, -1 }, /* (280) cmd ::= query_expression */ - { 249, -1 }, /* (281) literal ::= NK_INTEGER */ - { 249, -1 }, /* (282) literal ::= NK_FLOAT */ - { 249, -1 }, /* (283) literal ::= NK_STRING */ - { 249, -1 }, /* (284) literal ::= NK_BOOL */ - { 249, -2 }, /* (285) literal ::= TIMESTAMP NK_STRING */ - { 249, -1 }, /* (286) literal ::= duration_literal */ - { 249, -1 }, /* (287) literal ::= NULL */ - { 249, -1 }, /* (288) literal ::= NK_QUESTION */ - { 290, -1 }, /* (289) duration_literal ::= NK_VARIABLE */ - { 317, -1 }, /* (290) signed ::= NK_INTEGER */ - { 317, -2 }, /* (291) signed ::= NK_PLUS NK_INTEGER */ - { 317, -2 }, /* (292) signed ::= NK_MINUS NK_INTEGER */ - { 317, -1 }, /* (293) signed ::= NK_FLOAT */ - { 317, -2 }, /* (294) signed ::= NK_PLUS NK_FLOAT */ - { 317, -2 }, /* (295) signed ::= NK_MINUS NK_FLOAT */ - { 279, -1 }, /* (296) signed_literal ::= signed */ - { 279, -1 }, /* (297) signed_literal ::= NK_STRING */ - { 279, -1 }, /* (298) signed_literal ::= NK_BOOL */ - { 279, -2 }, /* (299) signed_literal ::= TIMESTAMP NK_STRING */ - { 279, -1 }, /* (300) signed_literal ::= duration_literal */ - { 279, -1 }, /* (301) signed_literal ::= NULL */ - { 279, -1 }, /* (302) signed_literal ::= literal_func */ - { 282, -1 }, /* (303) literal_list ::= signed_literal */ - { 282, -3 }, /* (304) literal_list ::= literal_list NK_COMMA signed_literal */ - { 257, -1 }, /* (305) db_name ::= NK_ID */ - { 285, -1 }, /* (306) table_name ::= NK_ID */ - { 277, -1 }, /* (307) column_name ::= NK_ID */ - { 292, -1 }, /* (308) function_name ::= NK_ID */ - { 319, -1 }, /* (309) table_alias ::= NK_ID */ - { 320, -1 }, /* (310) column_alias ::= NK_ID */ - { 251, -1 }, /* (311) user_name ::= NK_ID */ - { 298, -1 }, /* (312) index_name ::= NK_ID */ - { 306, -1 }, /* (313) topic_name ::= NK_ID */ - { 313, -1 }, /* (314) stream_name ::= NK_ID */ - { 308, -1 }, /* (315) cgroup_name ::= NK_ID */ - { 321, -1 }, /* (316) expression ::= literal */ - { 321, -1 }, /* (317) expression ::= pseudo_column */ - { 321, -1 }, /* (318) expression ::= column_reference */ - { 321, -1 }, /* (319) expression ::= function_expression */ - { 321, -1 }, /* (320) expression ::= subquery */ - { 321, -3 }, /* (321) expression ::= NK_LP expression NK_RP */ - { 321, -2 }, /* (322) expression ::= NK_PLUS expression */ - { 321, -2 }, /* (323) expression ::= NK_MINUS expression */ - { 321, -3 }, /* (324) expression ::= expression NK_PLUS expression */ - { 321, -3 }, /* (325) expression ::= expression NK_MINUS expression */ - { 321, -3 }, /* (326) expression ::= expression NK_STAR expression */ - { 321, -3 }, /* (327) expression ::= expression NK_SLASH expression */ - { 321, -3 }, /* (328) expression ::= expression NK_REM expression */ - { 321, -3 }, /* (329) expression ::= column_reference NK_ARROW NK_STRING */ - { 321, -3 }, /* (330) expression ::= expression NK_BITAND expression */ - { 321, -3 }, /* (331) expression ::= expression NK_BITOR expression */ - { 304, -1 }, /* (332) expression_list ::= expression */ - { 304, -3 }, /* (333) expression_list ::= expression_list NK_COMMA expression */ - { 323, -1 }, /* (334) column_reference ::= column_name */ - { 323, -3 }, /* (335) column_reference ::= table_name NK_DOT column_name */ - { 322, -1 }, /* (336) pseudo_column ::= ROWTS */ - { 322, -1 }, /* (337) pseudo_column ::= TBNAME */ - { 322, -3 }, /* (338) pseudo_column ::= table_name NK_DOT TBNAME */ - { 322, -1 }, /* (339) pseudo_column ::= QSTARTTS */ - { 322, -1 }, /* (340) pseudo_column ::= QENDTS */ - { 322, -1 }, /* (341) pseudo_column ::= WSTARTTS */ - { 322, -1 }, /* (342) pseudo_column ::= WENDTS */ - { 322, -1 }, /* (343) pseudo_column ::= WDURATION */ - { 324, -4 }, /* (344) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 324, -4 }, /* (345) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 324, -6 }, /* (346) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ - { 324, -1 }, /* (347) function_expression ::= literal_func */ - { 318, -3 }, /* (348) literal_func ::= noarg_func NK_LP NK_RP */ - { 318, -1 }, /* (349) literal_func ::= NOW */ - { 328, -1 }, /* (350) noarg_func ::= NOW */ - { 328, -1 }, /* (351) noarg_func ::= TODAY */ - { 328, -1 }, /* (352) noarg_func ::= TIMEZONE */ - { 326, -1 }, /* (353) star_func ::= COUNT */ - { 326, -1 }, /* (354) star_func ::= FIRST */ - { 326, -1 }, /* (355) star_func ::= LAST */ - { 326, -1 }, /* (356) star_func ::= LAST_ROW */ - { 327, -1 }, /* (357) star_func_para_list ::= NK_STAR */ - { 327, -1 }, /* (358) star_func_para_list ::= other_para_list */ - { 329, -1 }, /* (359) other_para_list ::= star_func_para */ - { 329, -3 }, /* (360) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 330, -1 }, /* (361) star_func_para ::= expression */ - { 330, -3 }, /* (362) star_func_para ::= table_name NK_DOT NK_STAR */ - { 331, -3 }, /* (363) predicate ::= expression compare_op expression */ - { 331, -5 }, /* (364) predicate ::= expression BETWEEN expression AND expression */ - { 331, -6 }, /* (365) predicate ::= expression NOT BETWEEN expression AND expression */ - { 331, -3 }, /* (366) predicate ::= expression IS NULL */ - { 331, -4 }, /* (367) predicate ::= expression IS NOT NULL */ - { 331, -3 }, /* (368) predicate ::= expression in_op in_predicate_value */ - { 332, -1 }, /* (369) compare_op ::= NK_LT */ - { 332, -1 }, /* (370) compare_op ::= NK_GT */ - { 332, -1 }, /* (371) compare_op ::= NK_LE */ - { 332, -1 }, /* (372) compare_op ::= NK_GE */ - { 332, -1 }, /* (373) compare_op ::= NK_NE */ - { 332, -1 }, /* (374) compare_op ::= NK_EQ */ - { 332, -1 }, /* (375) compare_op ::= LIKE */ - { 332, -2 }, /* (376) compare_op ::= NOT LIKE */ - { 332, -1 }, /* (377) compare_op ::= MATCH */ - { 332, -1 }, /* (378) compare_op ::= NMATCH */ - { 332, -1 }, /* (379) compare_op ::= CONTAINS */ - { 333, -1 }, /* (380) in_op ::= IN */ - { 333, -2 }, /* (381) in_op ::= NOT IN */ - { 334, -3 }, /* (382) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 335, -1 }, /* (383) boolean_value_expression ::= boolean_primary */ - { 335, -2 }, /* (384) boolean_value_expression ::= NOT boolean_primary */ - { 335, -3 }, /* (385) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 335, -3 }, /* (386) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 336, -1 }, /* (387) boolean_primary ::= predicate */ - { 336, -3 }, /* (388) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 337, -1 }, /* (389) common_expression ::= expression */ - { 337, -1 }, /* (390) common_expression ::= boolean_value_expression */ - { 338, 0 }, /* (391) from_clause_opt ::= */ - { 338, -2 }, /* (392) from_clause_opt ::= FROM table_reference_list */ - { 339, -1 }, /* (393) table_reference_list ::= table_reference */ - { 339, -3 }, /* (394) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 340, -1 }, /* (395) table_reference ::= table_primary */ - { 340, -1 }, /* (396) table_reference ::= joined_table */ - { 341, -2 }, /* (397) table_primary ::= table_name alias_opt */ - { 341, -4 }, /* (398) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 341, -2 }, /* (399) table_primary ::= subquery alias_opt */ - { 341, -1 }, /* (400) table_primary ::= parenthesized_joined_table */ - { 343, 0 }, /* (401) alias_opt ::= */ - { 343, -1 }, /* (402) alias_opt ::= table_alias */ - { 343, -2 }, /* (403) alias_opt ::= AS table_alias */ - { 344, -3 }, /* (404) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 344, -3 }, /* (405) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 342, -6 }, /* (406) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 345, 0 }, /* (407) join_type ::= */ - { 345, -1 }, /* (408) join_type ::= INNER */ - { 347, -12 }, /* (409) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 348, 0 }, /* (410) set_quantifier_opt ::= */ - { 348, -1 }, /* (411) set_quantifier_opt ::= DISTINCT */ - { 348, -1 }, /* (412) set_quantifier_opt ::= ALL */ - { 349, -1 }, /* (413) select_list ::= NK_STAR */ - { 349, -1 }, /* (414) select_list ::= select_sublist */ - { 357, -1 }, /* (415) select_sublist ::= select_item */ - { 357, -3 }, /* (416) select_sublist ::= select_sublist NK_COMMA select_item */ - { 358, -1 }, /* (417) select_item ::= common_expression */ - { 358, -2 }, /* (418) select_item ::= common_expression column_alias */ - { 358, -3 }, /* (419) select_item ::= common_expression AS column_alias */ - { 358, -3 }, /* (420) select_item ::= table_name NK_DOT NK_STAR */ - { 316, 0 }, /* (421) where_clause_opt ::= */ - { 316, -2 }, /* (422) where_clause_opt ::= WHERE search_condition */ - { 350, 0 }, /* (423) partition_by_clause_opt ::= */ - { 350, -3 }, /* (424) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 354, 0 }, /* (425) twindow_clause_opt ::= */ - { 354, -6 }, /* (426) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 354, -4 }, /* (427) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - { 354, -6 }, /* (428) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 354, -8 }, /* (429) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 301, 0 }, /* (430) sliding_opt ::= */ - { 301, -4 }, /* (431) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 353, 0 }, /* (432) fill_opt ::= */ - { 353, -4 }, /* (433) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 353, -6 }, /* (434) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 359, -1 }, /* (435) fill_mode ::= NONE */ - { 359, -1 }, /* (436) fill_mode ::= PREV */ - { 359, -1 }, /* (437) fill_mode ::= NULL */ - { 359, -1 }, /* (438) fill_mode ::= LINEAR */ - { 359, -1 }, /* (439) fill_mode ::= NEXT */ - { 355, 0 }, /* (440) group_by_clause_opt ::= */ - { 355, -3 }, /* (441) group_by_clause_opt ::= GROUP BY group_by_list */ - { 360, -1 }, /* (442) group_by_list ::= expression */ - { 360, -3 }, /* (443) group_by_list ::= group_by_list NK_COMMA expression */ - { 356, 0 }, /* (444) having_clause_opt ::= */ - { 356, -2 }, /* (445) having_clause_opt ::= HAVING search_condition */ - { 351, 0 }, /* (446) range_opt ::= */ - { 351, -6 }, /* (447) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ - { 352, 0 }, /* (448) every_opt ::= */ - { 352, -4 }, /* (449) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 307, -4 }, /* (450) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 361, -1 }, /* (451) query_expression_body ::= query_primary */ - { 361, -4 }, /* (452) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 361, -3 }, /* (453) query_expression_body ::= query_expression_body UNION query_expression_body */ - { 365, -1 }, /* (454) query_primary ::= query_specification */ - { 365, -6 }, /* (455) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ - { 362, 0 }, /* (456) order_by_clause_opt ::= */ - { 362, -3 }, /* (457) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 363, 0 }, /* (458) slimit_clause_opt ::= */ - { 363, -2 }, /* (459) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 363, -4 }, /* (460) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 363, -4 }, /* (461) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 364, 0 }, /* (462) limit_clause_opt ::= */ - { 364, -2 }, /* (463) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 364, -4 }, /* (464) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 364, -4 }, /* (465) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 325, -3 }, /* (466) subquery ::= NK_LP query_expression NK_RP */ - { 346, -1 }, /* (467) search_condition ::= common_expression */ - { 366, -1 }, /* (468) sort_specification_list ::= sort_specification */ - { 366, -3 }, /* (469) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 367, -3 }, /* (470) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 368, 0 }, /* (471) ordering_specification_opt ::= */ - { 368, -1 }, /* (472) ordering_specification_opt ::= ASC */ - { 368, -1 }, /* (473) ordering_specification_opt ::= DESC */ - { 369, 0 }, /* (474) null_ordering_opt ::= */ - { 369, -2 }, /* (475) null_ordering_opt ::= NULLS FIRST */ - { 369, -2 }, /* (476) null_ordering_opt ::= NULLS LAST */ + { 250, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 250, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 251, 0 }, /* (2) account_options ::= */ + { 251, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 251, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 251, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 251, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 251, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 251, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 251, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 251, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 251, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 252, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 252, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 254, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 254, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 254, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 254, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 254, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 254, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 254, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 254, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 254, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 254, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 250, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ + { 250, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 250, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + { 250, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + { 250, -3 }, /* (28) cmd ::= DROP USER user_name */ + { 256, 0 }, /* (29) sysinfo_opt ::= */ + { 256, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ + { 250, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 250, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 257, -1 }, /* (33) privileges ::= ALL */ + { 257, -1 }, /* (34) privileges ::= priv_type_list */ + { 259, -1 }, /* (35) priv_type_list ::= priv_type */ + { 259, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 260, -1 }, /* (37) priv_type ::= READ */ + { 260, -1 }, /* (38) priv_type ::= WRITE */ + { 258, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 258, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ + { 250, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ + { 250, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + { 250, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ + { 250, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ + { 250, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 250, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 250, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ + { 250, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 262, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ + { 262, -1 }, /* (50) dnode_endpoint ::= NK_ID */ + { 262, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ + { 250, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ + { 250, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 250, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 250, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 250, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 250, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 250, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 250, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 250, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 250, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 250, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 250, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ + { 250, -2 }, /* (64) cmd ::= USE db_name */ + { 250, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 263, -3 }, /* (66) not_exists_opt ::= IF NOT EXISTS */ + { 263, 0 }, /* (67) not_exists_opt ::= */ + { 265, -2 }, /* (68) exists_opt ::= IF EXISTS */ + { 265, 0 }, /* (69) exists_opt ::= */ + { 264, 0 }, /* (70) db_options ::= */ + { 264, -3 }, /* (71) db_options ::= db_options BUFFER NK_INTEGER */ + { 264, -3 }, /* (72) db_options ::= db_options CACHELAST NK_INTEGER */ + { 264, -3 }, /* (73) db_options ::= db_options COMP NK_INTEGER */ + { 264, -3 }, /* (74) db_options ::= db_options DURATION NK_INTEGER */ + { 264, -3 }, /* (75) db_options ::= db_options DURATION NK_VARIABLE */ + { 264, -3 }, /* (76) db_options ::= db_options FSYNC NK_INTEGER */ + { 264, -3 }, /* (77) db_options ::= db_options MAXROWS NK_INTEGER */ + { 264, -3 }, /* (78) db_options ::= db_options MINROWS NK_INTEGER */ + { 264, -3 }, /* (79) db_options ::= db_options KEEP integer_list */ + { 264, -3 }, /* (80) db_options ::= db_options KEEP variable_list */ + { 264, -3 }, /* (81) db_options ::= db_options PAGES NK_INTEGER */ + { 264, -3 }, /* (82) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 264, -3 }, /* (83) db_options ::= db_options PRECISION NK_STRING */ + { 264, -3 }, /* (84) db_options ::= db_options REPLICA NK_INTEGER */ + { 264, -3 }, /* (85) db_options ::= db_options STRICT NK_INTEGER */ + { 264, -3 }, /* (86) db_options ::= db_options WAL NK_INTEGER */ + { 264, -3 }, /* (87) db_options ::= db_options VGROUPS NK_INTEGER */ + { 264, -3 }, /* (88) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 264, -3 }, /* (89) db_options ::= db_options RETENTIONS retention_list */ + { 264, -3 }, /* (90) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 266, -1 }, /* (91) alter_db_options ::= alter_db_option */ + { 266, -2 }, /* (92) alter_db_options ::= alter_db_options alter_db_option */ + { 270, -2 }, /* (93) alter_db_option ::= BUFFER NK_INTEGER */ + { 270, -2 }, /* (94) alter_db_option ::= CACHELAST NK_INTEGER */ + { 270, -2 }, /* (95) alter_db_option ::= FSYNC NK_INTEGER */ + { 270, -2 }, /* (96) alter_db_option ::= KEEP integer_list */ + { 270, -2 }, /* (97) alter_db_option ::= KEEP variable_list */ + { 270, -2 }, /* (98) alter_db_option ::= PAGES NK_INTEGER */ + { 270, -2 }, /* (99) alter_db_option ::= REPLICA NK_INTEGER */ + { 270, -2 }, /* (100) alter_db_option ::= STRICT NK_INTEGER */ + { 270, -2 }, /* (101) alter_db_option ::= WAL NK_INTEGER */ + { 267, -1 }, /* (102) integer_list ::= NK_INTEGER */ + { 267, -3 }, /* (103) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 268, -1 }, /* (104) variable_list ::= NK_VARIABLE */ + { 268, -3 }, /* (105) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 269, -1 }, /* (106) retention_list ::= retention */ + { 269, -3 }, /* (107) retention_list ::= retention_list NK_COMMA retention */ + { 271, -3 }, /* (108) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 250, -9 }, /* (109) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 250, -3 }, /* (110) cmd ::= CREATE TABLE multi_create_clause */ + { 250, -9 }, /* (111) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 250, -3 }, /* (112) cmd ::= DROP TABLE multi_drop_clause */ + { 250, -4 }, /* (113) cmd ::= DROP STABLE exists_opt full_table_name */ + { 250, -3 }, /* (114) cmd ::= ALTER TABLE alter_table_clause */ + { 250, -3 }, /* (115) cmd ::= ALTER STABLE alter_table_clause */ + { 279, -2 }, /* (116) alter_table_clause ::= full_table_name alter_table_options */ + { 279, -5 }, /* (117) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 279, -4 }, /* (118) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 279, -5 }, /* (119) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 279, -5 }, /* (120) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 279, -5 }, /* (121) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 279, -4 }, /* (122) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 279, -5 }, /* (123) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 279, -5 }, /* (124) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 279, -6 }, /* (125) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 276, -1 }, /* (126) multi_create_clause ::= create_subtable_clause */ + { 276, -2 }, /* (127) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 284, -10 }, /* (128) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ + { 278, -1 }, /* (129) multi_drop_clause ::= drop_table_clause */ + { 278, -2 }, /* (130) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 287, -2 }, /* (131) drop_table_clause ::= exists_opt full_table_name */ + { 285, 0 }, /* (132) specific_tags_opt ::= */ + { 285, -3 }, /* (133) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 272, -1 }, /* (134) full_table_name ::= table_name */ + { 272, -3 }, /* (135) full_table_name ::= db_name NK_DOT table_name */ + { 273, -1 }, /* (136) column_def_list ::= column_def */ + { 273, -3 }, /* (137) column_def_list ::= column_def_list NK_COMMA column_def */ + { 290, -2 }, /* (138) column_def ::= column_name type_name */ + { 290, -4 }, /* (139) column_def ::= column_name type_name COMMENT NK_STRING */ + { 282, -1 }, /* (140) type_name ::= BOOL */ + { 282, -1 }, /* (141) type_name ::= TINYINT */ + { 282, -1 }, /* (142) type_name ::= SMALLINT */ + { 282, -1 }, /* (143) type_name ::= INT */ + { 282, -1 }, /* (144) type_name ::= INTEGER */ + { 282, -1 }, /* (145) type_name ::= BIGINT */ + { 282, -1 }, /* (146) type_name ::= FLOAT */ + { 282, -1 }, /* (147) type_name ::= DOUBLE */ + { 282, -4 }, /* (148) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 282, -1 }, /* (149) type_name ::= TIMESTAMP */ + { 282, -4 }, /* (150) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 282, -2 }, /* (151) type_name ::= TINYINT UNSIGNED */ + { 282, -2 }, /* (152) type_name ::= SMALLINT UNSIGNED */ + { 282, -2 }, /* (153) type_name ::= INT UNSIGNED */ + { 282, -2 }, /* (154) type_name ::= BIGINT UNSIGNED */ + { 282, -1 }, /* (155) type_name ::= JSON */ + { 282, -4 }, /* (156) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 282, -1 }, /* (157) type_name ::= MEDIUMBLOB */ + { 282, -1 }, /* (158) type_name ::= BLOB */ + { 282, -4 }, /* (159) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 282, -1 }, /* (160) type_name ::= DECIMAL */ + { 282, -4 }, /* (161) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 282, -6 }, /* (162) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 274, 0 }, /* (163) tags_def_opt ::= */ + { 274, -1 }, /* (164) tags_def_opt ::= tags_def */ + { 277, -4 }, /* (165) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 275, 0 }, /* (166) table_options ::= */ + { 275, -3 }, /* (167) table_options ::= table_options COMMENT NK_STRING */ + { 275, -3 }, /* (168) table_options ::= table_options MAX_DELAY duration_list */ + { 275, -3 }, /* (169) table_options ::= table_options WATERMARK duration_list */ + { 275, -5 }, /* (170) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + { 275, -3 }, /* (171) table_options ::= table_options TTL NK_INTEGER */ + { 275, -5 }, /* (172) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 280, -1 }, /* (173) alter_table_options ::= alter_table_option */ + { 280, -2 }, /* (174) alter_table_options ::= alter_table_options alter_table_option */ + { 293, -2 }, /* (175) alter_table_option ::= COMMENT NK_STRING */ + { 293, -2 }, /* (176) alter_table_option ::= TTL NK_INTEGER */ + { 291, -1 }, /* (177) duration_list ::= duration_literal */ + { 291, -3 }, /* (178) duration_list ::= duration_list NK_COMMA duration_literal */ + { 292, -1 }, /* (179) rollup_func_list ::= rollup_func_name */ + { 292, -3 }, /* (180) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + { 295, -1 }, /* (181) rollup_func_name ::= function_name */ + { 295, -1 }, /* (182) rollup_func_name ::= FIRST */ + { 295, -1 }, /* (183) rollup_func_name ::= LAST */ + { 288, -1 }, /* (184) col_name_list ::= col_name */ + { 288, -3 }, /* (185) col_name_list ::= col_name_list NK_COMMA col_name */ + { 297, -1 }, /* (186) col_name ::= column_name */ + { 250, -2 }, /* (187) cmd ::= SHOW DNODES */ + { 250, -2 }, /* (188) cmd ::= SHOW USERS */ + { 250, -2 }, /* (189) cmd ::= SHOW DATABASES */ + { 250, -4 }, /* (190) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 250, -4 }, /* (191) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 250, -3 }, /* (192) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 250, -2 }, /* (193) cmd ::= SHOW MNODES */ + { 250, -2 }, /* (194) cmd ::= SHOW MODULES */ + { 250, -2 }, /* (195) cmd ::= SHOW QNODES */ + { 250, -2 }, /* (196) cmd ::= SHOW FUNCTIONS */ + { 250, -5 }, /* (197) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 250, -2 }, /* (198) cmd ::= SHOW STREAMS */ + { 250, -2 }, /* (199) cmd ::= SHOW ACCOUNTS */ + { 250, -2 }, /* (200) cmd ::= SHOW APPS */ + { 250, -2 }, /* (201) cmd ::= SHOW CONNECTIONS */ + { 250, -2 }, /* (202) cmd ::= SHOW LICENCE */ + { 250, -2 }, /* (203) cmd ::= SHOW GRANTS */ + { 250, -4 }, /* (204) cmd ::= SHOW CREATE DATABASE db_name */ + { 250, -4 }, /* (205) cmd ::= SHOW CREATE TABLE full_table_name */ + { 250, -4 }, /* (206) cmd ::= SHOW CREATE STABLE full_table_name */ + { 250, -2 }, /* (207) cmd ::= SHOW QUERIES */ + { 250, -2 }, /* (208) cmd ::= SHOW SCORES */ + { 250, -2 }, /* (209) cmd ::= SHOW TOPICS */ + { 250, -2 }, /* (210) cmd ::= SHOW VARIABLES */ + { 250, -3 }, /* (211) cmd ::= SHOW LOCAL VARIABLES */ + { 250, -4 }, /* (212) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + { 250, -2 }, /* (213) cmd ::= SHOW BNODES */ + { 250, -2 }, /* (214) cmd ::= SHOW SNODES */ + { 250, -2 }, /* (215) cmd ::= SHOW CLUSTER */ + { 250, -2 }, /* (216) cmd ::= SHOW TRANSACTIONS */ + { 250, -4 }, /* (217) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 250, -2 }, /* (218) cmd ::= SHOW CONSUMERS */ + { 250, -2 }, /* (219) cmd ::= SHOW SUBSCRIPTIONS */ + { 298, 0 }, /* (220) db_name_cond_opt ::= */ + { 298, -2 }, /* (221) db_name_cond_opt ::= db_name NK_DOT */ + { 299, 0 }, /* (222) like_pattern_opt ::= */ + { 299, -2 }, /* (223) like_pattern_opt ::= LIKE NK_STRING */ + { 300, -1 }, /* (224) table_name_cond ::= table_name */ + { 301, 0 }, /* (225) from_db_opt ::= */ + { 301, -2 }, /* (226) from_db_opt ::= FROM db_name */ + { 250, -8 }, /* (227) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + { 250, -4 }, /* (228) cmd ::= DROP INDEX exists_opt index_name */ + { 303, -10 }, /* (229) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + { 303, -12 }, /* (230) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ + { 304, -1 }, /* (231) func_list ::= func */ + { 304, -3 }, /* (232) func_list ::= func_list NK_COMMA func */ + { 307, -4 }, /* (233) func ::= function_name NK_LP expression_list NK_RP */ + { 306, 0 }, /* (234) sma_stream_opt ::= */ + { 306, -3 }, /* (235) sma_stream_opt ::= stream_options WATERMARK duration_literal */ + { 306, -3 }, /* (236) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ + { 250, -6 }, /* (237) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 250, -7 }, /* (238) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 250, -9 }, /* (239) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 250, -7 }, /* (240) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 250, -9 }, /* (241) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 250, -4 }, /* (242) cmd ::= DROP TOPIC exists_opt topic_name */ + { 250, -7 }, /* (243) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 250, -2 }, /* (244) cmd ::= DESC full_table_name */ + { 250, -2 }, /* (245) cmd ::= DESCRIBE full_table_name */ + { 250, -3 }, /* (246) cmd ::= RESET QUERY CACHE */ + { 250, -4 }, /* (247) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + { 313, 0 }, /* (248) analyze_opt ::= */ + { 313, -1 }, /* (249) analyze_opt ::= ANALYZE */ + { 314, 0 }, /* (250) explain_options ::= */ + { 314, -3 }, /* (251) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 314, -3 }, /* (252) explain_options ::= explain_options RATIO NK_FLOAT */ + { 250, -6 }, /* (253) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ + { 250, -10 }, /* (254) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 250, -4 }, /* (255) cmd ::= DROP FUNCTION exists_opt function_name */ + { 315, 0 }, /* (256) agg_func_opt ::= */ + { 315, -1 }, /* (257) agg_func_opt ::= AGGREGATE */ + { 316, 0 }, /* (258) bufsize_opt ::= */ + { 316, -2 }, /* (259) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 250, -8 }, /* (260) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ + { 250, -4 }, /* (261) cmd ::= DROP STREAM exists_opt stream_name */ + { 318, 0 }, /* (262) into_opt ::= */ + { 318, -2 }, /* (263) into_opt ::= INTO full_table_name */ + { 309, 0 }, /* (264) stream_options ::= */ + { 309, -3 }, /* (265) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 309, -3 }, /* (266) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 309, -4 }, /* (267) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 309, -3 }, /* (268) stream_options ::= stream_options WATERMARK duration_literal */ + { 250, -3 }, /* (269) cmd ::= KILL CONNECTION NK_INTEGER */ + { 250, -3 }, /* (270) cmd ::= KILL QUERY NK_STRING */ + { 250, -3 }, /* (271) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 250, -2 }, /* (272) cmd ::= BALANCE VGROUP */ + { 250, -4 }, /* (273) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 250, -4 }, /* (274) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 250, -3 }, /* (275) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 319, -2 }, /* (276) dnode_list ::= DNODE NK_INTEGER */ + { 319, -3 }, /* (277) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 250, -3 }, /* (278) cmd ::= SYNCDB db_name REPLICA */ + { 250, -4 }, /* (279) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 250, -1 }, /* (280) cmd ::= query_expression */ + { 253, -1 }, /* (281) literal ::= NK_INTEGER */ + { 253, -1 }, /* (282) literal ::= NK_FLOAT */ + { 253, -1 }, /* (283) literal ::= NK_STRING */ + { 253, -1 }, /* (284) literal ::= NK_BOOL */ + { 253, -2 }, /* (285) literal ::= TIMESTAMP NK_STRING */ + { 253, -1 }, /* (286) literal ::= duration_literal */ + { 253, -1 }, /* (287) literal ::= NULL */ + { 253, -1 }, /* (288) literal ::= NK_QUESTION */ + { 294, -1 }, /* (289) duration_literal ::= NK_VARIABLE */ + { 321, -1 }, /* (290) signed ::= NK_INTEGER */ + { 321, -2 }, /* (291) signed ::= NK_PLUS NK_INTEGER */ + { 321, -2 }, /* (292) signed ::= NK_MINUS NK_INTEGER */ + { 321, -1 }, /* (293) signed ::= NK_FLOAT */ + { 321, -2 }, /* (294) signed ::= NK_PLUS NK_FLOAT */ + { 321, -2 }, /* (295) signed ::= NK_MINUS NK_FLOAT */ + { 283, -1 }, /* (296) signed_literal ::= signed */ + { 283, -1 }, /* (297) signed_literal ::= NK_STRING */ + { 283, -1 }, /* (298) signed_literal ::= NK_BOOL */ + { 283, -2 }, /* (299) signed_literal ::= TIMESTAMP NK_STRING */ + { 283, -1 }, /* (300) signed_literal ::= duration_literal */ + { 283, -1 }, /* (301) signed_literal ::= NULL */ + { 283, -1 }, /* (302) signed_literal ::= literal_func */ + { 286, -1 }, /* (303) literal_list ::= signed_literal */ + { 286, -3 }, /* (304) literal_list ::= literal_list NK_COMMA signed_literal */ + { 261, -1 }, /* (305) db_name ::= NK_ID */ + { 289, -1 }, /* (306) table_name ::= NK_ID */ + { 281, -1 }, /* (307) column_name ::= NK_ID */ + { 296, -1 }, /* (308) function_name ::= NK_ID */ + { 323, -1 }, /* (309) table_alias ::= NK_ID */ + { 324, -1 }, /* (310) column_alias ::= NK_ID */ + { 255, -1 }, /* (311) user_name ::= NK_ID */ + { 302, -1 }, /* (312) index_name ::= NK_ID */ + { 310, -1 }, /* (313) topic_name ::= NK_ID */ + { 317, -1 }, /* (314) stream_name ::= NK_ID */ + { 312, -1 }, /* (315) cgroup_name ::= NK_ID */ + { 325, -1 }, /* (316) expression ::= literal */ + { 325, -1 }, /* (317) expression ::= pseudo_column */ + { 325, -1 }, /* (318) expression ::= column_reference */ + { 325, -1 }, /* (319) expression ::= function_expression */ + { 325, -1 }, /* (320) expression ::= subquery */ + { 325, -3 }, /* (321) expression ::= NK_LP expression NK_RP */ + { 325, -2 }, /* (322) expression ::= NK_PLUS expression */ + { 325, -2 }, /* (323) expression ::= NK_MINUS expression */ + { 325, -3 }, /* (324) expression ::= expression NK_PLUS expression */ + { 325, -3 }, /* (325) expression ::= expression NK_MINUS expression */ + { 325, -3 }, /* (326) expression ::= expression NK_STAR expression */ + { 325, -3 }, /* (327) expression ::= expression NK_SLASH expression */ + { 325, -3 }, /* (328) expression ::= expression NK_REM expression */ + { 325, -3 }, /* (329) expression ::= column_reference NK_ARROW NK_STRING */ + { 325, -3 }, /* (330) expression ::= expression NK_BITAND expression */ + { 325, -3 }, /* (331) expression ::= expression NK_BITOR expression */ + { 308, -1 }, /* (332) expression_list ::= expression */ + { 308, -3 }, /* (333) expression_list ::= expression_list NK_COMMA expression */ + { 327, -1 }, /* (334) column_reference ::= column_name */ + { 327, -3 }, /* (335) column_reference ::= table_name NK_DOT column_name */ + { 326, -1 }, /* (336) pseudo_column ::= ROWTS */ + { 326, -1 }, /* (337) pseudo_column ::= TBNAME */ + { 326, -3 }, /* (338) pseudo_column ::= table_name NK_DOT TBNAME */ + { 326, -1 }, /* (339) pseudo_column ::= QSTARTTS */ + { 326, -1 }, /* (340) pseudo_column ::= QENDTS */ + { 326, -1 }, /* (341) pseudo_column ::= WSTARTTS */ + { 326, -1 }, /* (342) pseudo_column ::= WENDTS */ + { 326, -1 }, /* (343) pseudo_column ::= WDURATION */ + { 328, -4 }, /* (344) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 328, -4 }, /* (345) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 328, -6 }, /* (346) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ + { 328, -1 }, /* (347) function_expression ::= literal_func */ + { 322, -3 }, /* (348) literal_func ::= noarg_func NK_LP NK_RP */ + { 322, -1 }, /* (349) literal_func ::= NOW */ + { 332, -1 }, /* (350) noarg_func ::= NOW */ + { 332, -1 }, /* (351) noarg_func ::= TODAY */ + { 332, -1 }, /* (352) noarg_func ::= TIMEZONE */ + { 332, -1 }, /* (353) noarg_func ::= DATABASE */ + { 332, -1 }, /* (354) noarg_func ::= CLIENT_VERSION */ + { 332, -1 }, /* (355) noarg_func ::= SERVER_VERSION */ + { 332, -1 }, /* (356) noarg_func ::= SERVER_STATUS */ + { 332, -1 }, /* (357) noarg_func ::= CURRENT_USER */ + { 332, -1 }, /* (358) noarg_func ::= USER */ + { 330, -1 }, /* (359) star_func ::= COUNT */ + { 330, -1 }, /* (360) star_func ::= FIRST */ + { 330, -1 }, /* (361) star_func ::= LAST */ + { 330, -1 }, /* (362) star_func ::= LAST_ROW */ + { 331, -1 }, /* (363) star_func_para_list ::= NK_STAR */ + { 331, -1 }, /* (364) star_func_para_list ::= other_para_list */ + { 333, -1 }, /* (365) other_para_list ::= star_func_para */ + { 333, -3 }, /* (366) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 334, -1 }, /* (367) star_func_para ::= expression */ + { 334, -3 }, /* (368) star_func_para ::= table_name NK_DOT NK_STAR */ + { 335, -3 }, /* (369) predicate ::= expression compare_op expression */ + { 335, -5 }, /* (370) predicate ::= expression BETWEEN expression AND expression */ + { 335, -6 }, /* (371) predicate ::= expression NOT BETWEEN expression AND expression */ + { 335, -3 }, /* (372) predicate ::= expression IS NULL */ + { 335, -4 }, /* (373) predicate ::= expression IS NOT NULL */ + { 335, -3 }, /* (374) predicate ::= expression in_op in_predicate_value */ + { 336, -1 }, /* (375) compare_op ::= NK_LT */ + { 336, -1 }, /* (376) compare_op ::= NK_GT */ + { 336, -1 }, /* (377) compare_op ::= NK_LE */ + { 336, -1 }, /* (378) compare_op ::= NK_GE */ + { 336, -1 }, /* (379) compare_op ::= NK_NE */ + { 336, -1 }, /* (380) compare_op ::= NK_EQ */ + { 336, -1 }, /* (381) compare_op ::= LIKE */ + { 336, -2 }, /* (382) compare_op ::= NOT LIKE */ + { 336, -1 }, /* (383) compare_op ::= MATCH */ + { 336, -1 }, /* (384) compare_op ::= NMATCH */ + { 336, -1 }, /* (385) compare_op ::= CONTAINS */ + { 337, -1 }, /* (386) in_op ::= IN */ + { 337, -2 }, /* (387) in_op ::= NOT IN */ + { 338, -3 }, /* (388) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 339, -1 }, /* (389) boolean_value_expression ::= boolean_primary */ + { 339, -2 }, /* (390) boolean_value_expression ::= NOT boolean_primary */ + { 339, -3 }, /* (391) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 339, -3 }, /* (392) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 340, -1 }, /* (393) boolean_primary ::= predicate */ + { 340, -3 }, /* (394) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 341, -1 }, /* (395) common_expression ::= expression */ + { 341, -1 }, /* (396) common_expression ::= boolean_value_expression */ + { 342, 0 }, /* (397) from_clause_opt ::= */ + { 342, -2 }, /* (398) from_clause_opt ::= FROM table_reference_list */ + { 343, -1 }, /* (399) table_reference_list ::= table_reference */ + { 343, -3 }, /* (400) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 344, -1 }, /* (401) table_reference ::= table_primary */ + { 344, -1 }, /* (402) table_reference ::= joined_table */ + { 345, -2 }, /* (403) table_primary ::= table_name alias_opt */ + { 345, -4 }, /* (404) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 345, -2 }, /* (405) table_primary ::= subquery alias_opt */ + { 345, -1 }, /* (406) table_primary ::= parenthesized_joined_table */ + { 347, 0 }, /* (407) alias_opt ::= */ + { 347, -1 }, /* (408) alias_opt ::= table_alias */ + { 347, -2 }, /* (409) alias_opt ::= AS table_alias */ + { 348, -3 }, /* (410) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 348, -3 }, /* (411) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 346, -6 }, /* (412) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 349, 0 }, /* (413) join_type ::= */ + { 349, -1 }, /* (414) join_type ::= INNER */ + { 351, -12 }, /* (415) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 352, 0 }, /* (416) set_quantifier_opt ::= */ + { 352, -1 }, /* (417) set_quantifier_opt ::= DISTINCT */ + { 352, -1 }, /* (418) set_quantifier_opt ::= ALL */ + { 353, -1 }, /* (419) select_list ::= NK_STAR */ + { 353, -1 }, /* (420) select_list ::= select_sublist */ + { 361, -1 }, /* (421) select_sublist ::= select_item */ + { 361, -3 }, /* (422) select_sublist ::= select_sublist NK_COMMA select_item */ + { 362, -1 }, /* (423) select_item ::= common_expression */ + { 362, -2 }, /* (424) select_item ::= common_expression column_alias */ + { 362, -3 }, /* (425) select_item ::= common_expression AS column_alias */ + { 362, -3 }, /* (426) select_item ::= table_name NK_DOT NK_STAR */ + { 320, 0 }, /* (427) where_clause_opt ::= */ + { 320, -2 }, /* (428) where_clause_opt ::= WHERE search_condition */ + { 354, 0 }, /* (429) partition_by_clause_opt ::= */ + { 354, -3 }, /* (430) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 358, 0 }, /* (431) twindow_clause_opt ::= */ + { 358, -6 }, /* (432) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 358, -4 }, /* (433) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + { 358, -6 }, /* (434) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 358, -8 }, /* (435) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 305, 0 }, /* (436) sliding_opt ::= */ + { 305, -4 }, /* (437) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 357, 0 }, /* (438) fill_opt ::= */ + { 357, -4 }, /* (439) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 357, -6 }, /* (440) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 363, -1 }, /* (441) fill_mode ::= NONE */ + { 363, -1 }, /* (442) fill_mode ::= PREV */ + { 363, -1 }, /* (443) fill_mode ::= NULL */ + { 363, -1 }, /* (444) fill_mode ::= LINEAR */ + { 363, -1 }, /* (445) fill_mode ::= NEXT */ + { 359, 0 }, /* (446) group_by_clause_opt ::= */ + { 359, -3 }, /* (447) group_by_clause_opt ::= GROUP BY group_by_list */ + { 364, -1 }, /* (448) group_by_list ::= expression */ + { 364, -3 }, /* (449) group_by_list ::= group_by_list NK_COMMA expression */ + { 360, 0 }, /* (450) having_clause_opt ::= */ + { 360, -2 }, /* (451) having_clause_opt ::= HAVING search_condition */ + { 355, 0 }, /* (452) range_opt ::= */ + { 355, -6 }, /* (453) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ + { 356, 0 }, /* (454) every_opt ::= */ + { 356, -4 }, /* (455) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 311, -4 }, /* (456) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 365, -1 }, /* (457) query_expression_body ::= query_primary */ + { 365, -4 }, /* (458) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 365, -3 }, /* (459) query_expression_body ::= query_expression_body UNION query_expression_body */ + { 369, -1 }, /* (460) query_primary ::= query_specification */ + { 369, -6 }, /* (461) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ + { 366, 0 }, /* (462) order_by_clause_opt ::= */ + { 366, -3 }, /* (463) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 367, 0 }, /* (464) slimit_clause_opt ::= */ + { 367, -2 }, /* (465) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 367, -4 }, /* (466) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 367, -4 }, /* (467) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 368, 0 }, /* (468) limit_clause_opt ::= */ + { 368, -2 }, /* (469) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 368, -4 }, /* (470) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 368, -4 }, /* (471) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 329, -3 }, /* (472) subquery ::= NK_LP query_expression NK_RP */ + { 350, -1 }, /* (473) search_condition ::= common_expression */ + { 370, -1 }, /* (474) sort_specification_list ::= sort_specification */ + { 370, -3 }, /* (475) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 371, -3 }, /* (476) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 372, 0 }, /* (477) ordering_specification_opt ::= */ + { 372, -1 }, /* (478) ordering_specification_opt ::= ASC */ + { 372, -1 }, /* (479) ordering_specification_opt ::= DESC */ + { 373, 0 }, /* (480) null_ordering_opt ::= */ + { 373, -2 }, /* (481) null_ordering_opt ::= NULLS FIRST */ + { 373, -2 }, /* (482) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3204,11 +3280,11 @@ static YYACTIONTYPE yy_reduce( YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,247,&yymsp[0].minor); + yy_destructor(yypParser,251,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,248,&yymsp[0].minor); + yy_destructor(yypParser,252,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3222,20 +3298,20 @@ static YYACTIONTYPE yy_reduce( case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9); case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); -{ yy_destructor(yypParser,247,&yymsp[-2].minor); +{ yy_destructor(yypParser,251,&yymsp[-2].minor); { } - yy_destructor(yypParser,249,&yymsp[0].minor); + yy_destructor(yypParser,253,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,250,&yymsp[0].minor); +{ yy_destructor(yypParser,254,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,248,&yymsp[-1].minor); +{ yy_destructor(yypParser,252,&yymsp[-1].minor); { } - yy_destructor(yypParser,250,&yymsp[0].minor); + yy_destructor(yypParser,254,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3249,72 +3325,72 @@ static YYACTIONTYPE yy_reduce( case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); { } - yy_destructor(yypParser,249,&yymsp[0].minor); + yy_destructor(yypParser,253,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy109, &yymsp[-1].minor.yy0, yymsp[0].minor.yy323); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy657, &yymsp[-1].minor.yy0, yymsp[0].minor.yy619); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy109, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy657, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy109, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy657, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy109, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy657, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 28: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy109); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy657); } break; case 29: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy323 = 1; } +{ yymsp[1].minor.yy619 = 1; } break; case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy323 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy619 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } break; case 31: /* cmd ::= GRANT privileges ON priv_level TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy209, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy701, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy657); } break; case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy209, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy701, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy657); } break; case 33: /* privileges ::= ALL */ -{ yymsp[0].minor.yy209 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy701 = PRIVILEGE_TYPE_ALL; } break; case 34: /* privileges ::= priv_type_list */ case 35: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==35); -{ yylhsminor.yy209 = yymsp[0].minor.yy209; } - yymsp[0].minor.yy209 = yylhsminor.yy209; +{ yylhsminor.yy701 = yymsp[0].minor.yy701; } + yymsp[0].minor.yy701 = yylhsminor.yy701; break; case 36: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy209 = yymsp[-2].minor.yy209 | yymsp[0].minor.yy209; } - yymsp[-2].minor.yy209 = yylhsminor.yy209; +{ yylhsminor.yy701 = yymsp[-2].minor.yy701 | yymsp[0].minor.yy701; } + yymsp[-2].minor.yy701 = yylhsminor.yy701; break; case 37: /* priv_type ::= READ */ -{ yymsp[0].minor.yy209 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy701 = PRIVILEGE_TYPE_READ; } break; case 38: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy209 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy701 = PRIVILEGE_TYPE_WRITE; } break; case 39: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy109 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy109 = yylhsminor.yy109; +{ yylhsminor.yy657 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy657 = yylhsminor.yy657; break; case 40: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy109 = yymsp[-2].minor.yy109; } - yymsp[-2].minor.yy109 = yylhsminor.yy109; +{ yylhsminor.yy657 = yymsp[-2].minor.yy657; } + yymsp[-2].minor.yy657 = yylhsminor.yy657; break; case 41: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy109, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy657, NULL); } break; case 42: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy0); } break; case 43: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 44: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy109); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy657); } break; case 45: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3345,12 +3421,18 @@ static YYACTIONTYPE yy_reduce( case 350: /* noarg_func ::= NOW */ yytestcase(yyruleno==350); case 351: /* noarg_func ::= TODAY */ yytestcase(yyruleno==351); case 352: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==352); - case 353: /* star_func ::= COUNT */ yytestcase(yyruleno==353); - case 354: /* star_func ::= FIRST */ yytestcase(yyruleno==354); - case 355: /* star_func ::= LAST */ yytestcase(yyruleno==355); - case 356: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==356); -{ yylhsminor.yy109 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy109 = yylhsminor.yy109; + case 353: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==353); + case 354: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==354); + case 355: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==355); + case 356: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==356); + case 357: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==357); + case 358: /* noarg_func ::= USER */ yytestcase(yyruleno==358); + case 359: /* star_func ::= COUNT */ yytestcase(yyruleno==359); + case 360: /* star_func ::= FIRST */ yytestcase(yyruleno==360); + case 361: /* star_func ::= LAST */ yytestcase(yyruleno==361); + case 362: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==362); +{ yylhsminor.yy657 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy657 = yylhsminor.yy657; break; case 52: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3383,156 +3465,156 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 62: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy437, &yymsp[-1].minor.yy109, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy97, &yymsp[-1].minor.yy657, yymsp[0].minor.yy652); } break; case 63: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy437, &yymsp[0].minor.yy109); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy657); } break; case 64: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy109); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy657); } break; case 65: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy109, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy657, yymsp[0].minor.yy652); } break; case 66: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy437 = true; } +{ yymsp[-2].minor.yy97 = true; } break; case 67: /* not_exists_opt ::= */ case 69: /* exists_opt ::= */ yytestcase(yyruleno==69); case 248: /* analyze_opt ::= */ yytestcase(yyruleno==248); case 256: /* agg_func_opt ::= */ yytestcase(yyruleno==256); - case 410: /* set_quantifier_opt ::= */ yytestcase(yyruleno==410); -{ yymsp[1].minor.yy437 = false; } + case 416: /* set_quantifier_opt ::= */ yytestcase(yyruleno==416); +{ yymsp[1].minor.yy97 = false; } break; case 68: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy437 = true; } +{ yymsp[-1].minor.yy97 = true; } break; case 70: /* db_options ::= */ -{ yymsp[1].minor.yy452 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy652 = createDefaultDatabaseOptions(pCxt); } break; case 71: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 72: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 73: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 74: /* db_options ::= db_options DURATION NK_INTEGER */ case 75: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==75); -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 76: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 77: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 78: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 79: /* db_options ::= db_options KEEP integer_list */ case 80: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==80); -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_KEEP, yymsp[0].minor.yy404); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_KEEP, yymsp[0].minor.yy24); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 81: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 82: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 83: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 84: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 85: /* db_options ::= db_options STRICT NK_INTEGER */ -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 86: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 87: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 88: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 89: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_RETENTIONS, yymsp[0].minor.yy404); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_RETENTIONS, yymsp[0].minor.yy24); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 90: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 91: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy452 = createAlterDatabaseOptions(pCxt); yylhsminor.yy452 = setAlterDatabaseOption(pCxt, yylhsminor.yy452, &yymsp[0].minor.yy85); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createAlterDatabaseOptions(pCxt); yylhsminor.yy652 = setAlterDatabaseOption(pCxt, yylhsminor.yy652, &yymsp[0].minor.yy189); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 92: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy452 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy452, &yymsp[0].minor.yy85); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy652, &yymsp[0].minor.yy189); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; case 93: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy85.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy189.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } break; case 94: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy85.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy189.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } break; case 95: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy85.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy189.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } break; case 96: /* alter_db_option ::= KEEP integer_list */ case 97: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==97); -{ yymsp[-1].minor.yy85.type = DB_OPTION_KEEP; yymsp[-1].minor.yy85.pList = yymsp[0].minor.yy404; } +{ yymsp[-1].minor.yy189.type = DB_OPTION_KEEP; yymsp[-1].minor.yy189.pList = yymsp[0].minor.yy24; } break; case 98: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy85.type = DB_OPTION_PAGES; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy189.type = DB_OPTION_PAGES; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } break; case 99: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy85.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy189.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } break; case 100: /* alter_db_option ::= STRICT NK_INTEGER */ -{ yymsp[-1].minor.yy85.type = DB_OPTION_STRICT; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy189.type = DB_OPTION_STRICT; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } break; case 101: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy85.type = DB_OPTION_WAL; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy189.type = DB_OPTION_WAL; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } break; case 102: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy404 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy24 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; case 103: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ case 277: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==277); -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 104: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy404 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy24 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; case 105: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 106: /* retention_list ::= retention */ case 126: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==126); @@ -3542,11 +3624,11 @@ static YYACTIONTYPE yy_reduce( case 184: /* col_name_list ::= col_name */ yytestcase(yyruleno==184); case 231: /* func_list ::= func */ yytestcase(yyruleno==231); case 303: /* literal_list ::= signed_literal */ yytestcase(yyruleno==303); - case 359: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==359); - case 415: /* select_sublist ::= select_item */ yytestcase(yyruleno==415); - case 468: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==468); -{ yylhsminor.yy404 = createNodeList(pCxt, yymsp[0].minor.yy452); } - yymsp[0].minor.yy404 = yylhsminor.yy404; + case 365: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==365); + case 421: /* select_sublist ::= select_item */ yytestcase(yyruleno==421); + case 474: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==474); +{ yylhsminor.yy24 = createNodeList(pCxt, yymsp[0].minor.yy652); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; case 107: /* retention_list ::= retention_list NK_COMMA retention */ case 137: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==137); @@ -3554,252 +3636,252 @@ static YYACTIONTYPE yy_reduce( case 185: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==185); case 232: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==232); case 304: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==304); - case 360: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==360); - case 416: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==416); - case 469: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==469); -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, yymsp[0].minor.yy452); } - yymsp[-2].minor.yy404 = yylhsminor.yy404; + case 366: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==366); + case 422: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==422); + case 475: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==475); +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, yymsp[0].minor.yy652); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 108: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy452 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 109: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 111: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==111); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy437, yymsp[-5].minor.yy452, yymsp[-3].minor.yy404, yymsp[-1].minor.yy404, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy97, yymsp[-5].minor.yy652, yymsp[-3].minor.yy24, yymsp[-1].minor.yy24, yymsp[0].minor.yy652); } break; case 110: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy404); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy24); } break; case 112: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy404); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy24); } break; case 113: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy437, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy97, yymsp[0].minor.yy652); } break; case 114: /* cmd ::= ALTER TABLE alter_table_clause */ case 115: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==115); case 280: /* cmd ::= query_expression */ yytestcase(yyruleno==280); -{ pCxt->pRootNode = yymsp[0].minor.yy452; } +{ pCxt->pRootNode = yymsp[0].minor.yy652; } break; case 116: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy452 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; case 117: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy452 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy109, yymsp[0].minor.yy504); } - yymsp[-4].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy657, yymsp[0].minor.yy48); } + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; case 118: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy452 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy452, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy109); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy652, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy657); } + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; case 119: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy452 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy109, yymsp[0].minor.yy504); } - yymsp[-4].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy657, yymsp[0].minor.yy48); } + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; case 120: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy452 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy109, &yymsp[0].minor.yy109); } - yymsp[-4].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy657, &yymsp[0].minor.yy657); } + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; case 121: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy452 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy109, yymsp[0].minor.yy504); } - yymsp[-4].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy657, yymsp[0].minor.yy48); } + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; case 122: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy452 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy452, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy109); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy652, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy657); } + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; case 123: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy452 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy109, yymsp[0].minor.yy504); } - yymsp[-4].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy657, yymsp[0].minor.yy48); } + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; case 124: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy452 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy109, &yymsp[0].minor.yy109); } - yymsp[-4].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy657, &yymsp[0].minor.yy657); } + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; case 125: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy452 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy452, &yymsp[-2].minor.yy109, yymsp[0].minor.yy452); } - yymsp[-5].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy652, &yymsp[-2].minor.yy657, yymsp[0].minor.yy652); } + yymsp[-5].minor.yy652 = yylhsminor.yy652; break; case 127: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 130: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==130); -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-1].minor.yy404, yymsp[0].minor.yy452); } - yymsp[-1].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-1].minor.yy24, yymsp[0].minor.yy652); } + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; case 128: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ -{ yylhsminor.yy452 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy437, yymsp[-8].minor.yy452, yymsp[-6].minor.yy452, yymsp[-5].minor.yy404, yymsp[-2].minor.yy404, yymsp[0].minor.yy452); } - yymsp[-9].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy97, yymsp[-8].minor.yy652, yymsp[-6].minor.yy652, yymsp[-5].minor.yy24, yymsp[-2].minor.yy24, yymsp[0].minor.yy652); } + yymsp[-9].minor.yy652 = yylhsminor.yy652; break; case 131: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy452 = createDropTableClause(pCxt, yymsp[-1].minor.yy437, yymsp[0].minor.yy452); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createDropTableClause(pCxt, yymsp[-1].minor.yy97, yymsp[0].minor.yy652); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; case 132: /* specific_tags_opt ::= */ case 163: /* tags_def_opt ::= */ yytestcase(yyruleno==163); - case 423: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==423); - case 440: /* group_by_clause_opt ::= */ yytestcase(yyruleno==440); - case 456: /* order_by_clause_opt ::= */ yytestcase(yyruleno==456); -{ yymsp[1].minor.yy404 = NULL; } + case 429: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==429); + case 446: /* group_by_clause_opt ::= */ yytestcase(yyruleno==446); + case 462: /* order_by_clause_opt ::= */ yytestcase(yyruleno==462); +{ yymsp[1].minor.yy24 = NULL; } break; case 133: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy404 = yymsp[-1].minor.yy404; } +{ yymsp[-2].minor.yy24 = yymsp[-1].minor.yy24; } break; case 134: /* full_table_name ::= table_name */ -{ yylhsminor.yy452 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy109, NULL); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy657, NULL); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 135: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy452 = createRealTableNode(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109, NULL); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRealTableNode(pCxt, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy657, NULL); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 138: /* column_def ::= column_name type_name */ -{ yylhsminor.yy452 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy109, yymsp[0].minor.yy504, NULL); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy657, yymsp[0].minor.yy48, NULL); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; case 139: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy452 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy109, yymsp[-2].minor.yy504, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy657, yymsp[-2].minor.yy48, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; case 140: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 141: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 142: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 143: /* type_name ::= INT */ case 144: /* type_name ::= INTEGER */ yytestcase(yyruleno==144); -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_INT); } break; case 145: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 146: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 147: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 148: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy48 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 149: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 150: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy48 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 151: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy504 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy48 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 152: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy504 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy48 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 153: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy504 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy48 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 154: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy504 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy48 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 155: /* type_name ::= JSON */ -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 156: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy48 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 157: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 158: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 159: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy48 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 160: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy48 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 161: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy504 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy48 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 162: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy504 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy48 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 164: /* tags_def_opt ::= tags_def */ - case 358: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==358); - case 414: /* select_list ::= select_sublist */ yytestcase(yyruleno==414); -{ yylhsminor.yy404 = yymsp[0].minor.yy404; } - yymsp[0].minor.yy404 = yylhsminor.yy404; + case 364: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==364); + case 420: /* select_list ::= select_sublist */ yytestcase(yyruleno==420); +{ yylhsminor.yy24 = yymsp[0].minor.yy24; } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; case 165: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy404 = yymsp[-1].minor.yy404; } +{ yymsp[-3].minor.yy24 = yymsp[-1].minor.yy24; } break; case 166: /* table_options ::= */ -{ yymsp[1].minor.yy452 = createDefaultTableOptions(pCxt); } +{ yymsp[1].minor.yy652 = createDefaultTableOptions(pCxt); } break; case 167: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-2].minor.yy452, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-2].minor.yy652, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 168: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-2].minor.yy452, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy404); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-2].minor.yy652, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy24); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 169: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-2].minor.yy452, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy404); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-2].minor.yy652, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy24); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 170: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-4].minor.yy452, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy404); } - yymsp[-4].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-4].minor.yy652, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy24); } + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; case 171: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-2].minor.yy452, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-2].minor.yy652, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 172: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-4].minor.yy452, TABLE_OPTION_SMA, yymsp[-1].minor.yy404); } - yymsp[-4].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-4].minor.yy652, TABLE_OPTION_SMA, yymsp[-1].minor.yy24); } + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; case 173: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy452 = createAlterTableOptions(pCxt); yylhsminor.yy452 = setTableOption(pCxt, yylhsminor.yy452, yymsp[0].minor.yy85.type, &yymsp[0].minor.yy85.val); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createAlterTableOptions(pCxt); yylhsminor.yy652 = setTableOption(pCxt, yylhsminor.yy652, yymsp[0].minor.yy189.type, &yymsp[0].minor.yy189.val); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 174: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-1].minor.yy452, yymsp[0].minor.yy85.type, &yymsp[0].minor.yy85.val); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-1].minor.yy652, yymsp[0].minor.yy189.type, &yymsp[0].minor.yy189.val); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; case 175: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy85.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy189.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } break; case 176: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy85.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy189.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy189.val = yymsp[0].minor.yy0; } break; case 177: /* duration_list ::= duration_literal */ case 332: /* expression_list ::= expression */ yytestcase(yyruleno==332); -{ yylhsminor.yy404 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy452)); } - yymsp[0].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy24 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy652)); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; case 178: /* duration_list ::= duration_list NK_COMMA duration_literal */ case 333: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==333); -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, releaseRawExprNode(pCxt, yymsp[0].minor.yy452)); } - yymsp[-2].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, releaseRawExprNode(pCxt, yymsp[0].minor.yy652)); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 181: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy452 = createFunctionNode(pCxt, &yymsp[0].minor.yy109, NULL); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createFunctionNode(pCxt, &yymsp[0].minor.yy657, NULL); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 182: /* rollup_func_name ::= FIRST */ case 183: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==183); -{ yylhsminor.yy452 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 186: /* col_name ::= column_name */ -{ yylhsminor.yy452 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy109); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy657); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 187: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } @@ -3811,13 +3893,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } break; case 190: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy452, yymsp[0].minor.yy452, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy652, yymsp[0].minor.yy652, OP_TYPE_LIKE); } break; case 191: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy452, yymsp[0].minor.yy452, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy652, yymsp[0].minor.yy652, OP_TYPE_LIKE); } break; case 192: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy452, NULL, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy652, NULL, OP_TYPE_LIKE); } break; case 193: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } @@ -3832,7 +3914,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; case 197: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy452, yymsp[-1].minor.yy452, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy652, yymsp[-1].minor.yy652, OP_TYPE_EQUAL); } break; case 198: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } @@ -3851,13 +3933,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT); } break; case 204: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy109); } +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy657); } break; case 205: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy652); } break; case 206: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy652); } break; case 207: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } @@ -3890,7 +3972,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; case 217: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy652); } break; case 218: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } @@ -3900,150 +3982,150 @@ static YYACTIONTYPE yy_reduce( break; case 220: /* db_name_cond_opt ::= */ case 225: /* from_db_opt ::= */ yytestcase(yyruleno==225); -{ yymsp[1].minor.yy452 = createDefaultDatabaseCondValue(pCxt); } +{ yymsp[1].minor.yy652 = createDefaultDatabaseCondValue(pCxt); } break; case 221: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy109); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy657); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; case 222: /* like_pattern_opt ::= */ case 262: /* into_opt ::= */ yytestcase(yyruleno==262); - case 391: /* from_clause_opt ::= */ yytestcase(yyruleno==391); - case 421: /* where_clause_opt ::= */ yytestcase(yyruleno==421); - case 425: /* twindow_clause_opt ::= */ yytestcase(yyruleno==425); - case 430: /* sliding_opt ::= */ yytestcase(yyruleno==430); - case 432: /* fill_opt ::= */ yytestcase(yyruleno==432); - case 444: /* having_clause_opt ::= */ yytestcase(yyruleno==444); - case 446: /* range_opt ::= */ yytestcase(yyruleno==446); - case 448: /* every_opt ::= */ yytestcase(yyruleno==448); - case 458: /* slimit_clause_opt ::= */ yytestcase(yyruleno==458); - case 462: /* limit_clause_opt ::= */ yytestcase(yyruleno==462); -{ yymsp[1].minor.yy452 = NULL; } + case 397: /* from_clause_opt ::= */ yytestcase(yyruleno==397); + case 427: /* where_clause_opt ::= */ yytestcase(yyruleno==427); + case 431: /* twindow_clause_opt ::= */ yytestcase(yyruleno==431); + case 436: /* sliding_opt ::= */ yytestcase(yyruleno==436); + case 438: /* fill_opt ::= */ yytestcase(yyruleno==438); + case 450: /* having_clause_opt ::= */ yytestcase(yyruleno==450); + case 452: /* range_opt ::= */ yytestcase(yyruleno==452); + case 454: /* every_opt ::= */ yytestcase(yyruleno==454); + case 464: /* slimit_clause_opt ::= */ yytestcase(yyruleno==464); + case 468: /* limit_clause_opt ::= */ yytestcase(yyruleno==468); +{ yymsp[1].minor.yy652 = NULL; } break; case 223: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; case 224: /* table_name_cond ::= table_name */ -{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy109); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy657); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 226: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy109); } +{ yymsp[-1].minor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy657); } break; case 227: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy437, &yymsp[-3].minor.yy109, &yymsp[-1].minor.yy109, NULL, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy97, &yymsp[-3].minor.yy657, &yymsp[-1].minor.yy657, NULL, yymsp[0].minor.yy652); } break; case 228: /* cmd ::= DROP INDEX exists_opt index_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy437, &yymsp[0].minor.yy109); } +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy657); } break; case 229: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy452 = createIndexOption(pCxt, yymsp[-7].minor.yy404, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), NULL, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } +{ yymsp[-9].minor.yy652 = createIndexOption(pCxt, yymsp[-7].minor.yy24, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), NULL, yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } break; case 230: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-11].minor.yy452 = createIndexOption(pCxt, yymsp[-9].minor.yy404, releaseRawExprNode(pCxt, yymsp[-5].minor.yy452), releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } +{ yymsp[-11].minor.yy652 = createIndexOption(pCxt, yymsp[-9].minor.yy24, releaseRawExprNode(pCxt, yymsp[-5].minor.yy652), releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } break; case 233: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy452 = createFunctionNode(pCxt, &yymsp[-3].minor.yy109, yymsp[-1].minor.yy404); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createFunctionNode(pCxt, &yymsp[-3].minor.yy657, yymsp[-1].minor.yy24); } + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; case 234: /* sma_stream_opt ::= */ case 264: /* stream_options ::= */ yytestcase(yyruleno==264); -{ yymsp[1].minor.yy452 = createStreamOptions(pCxt); } +{ yymsp[1].minor.yy652 = createStreamOptions(pCxt); } break; case 235: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ case 268: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==268); -{ ((SStreamOptions*)yymsp[-2].minor.yy452)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy452); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SStreamOptions*)yymsp[-2].minor.yy652)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy652); yylhsminor.yy652 = yymsp[-2].minor.yy652; } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 236: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy452)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy452); yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SStreamOptions*)yymsp[-2].minor.yy652)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy652); yylhsminor.yy652 = yymsp[-2].minor.yy652; } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 237: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy437, &yymsp[-2].minor.yy109, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy97, &yymsp[-2].minor.yy657, yymsp[0].minor.yy652); } break; case 238: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy437, &yymsp[-3].minor.yy109, &yymsp[0].minor.yy109, false); } +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy97, &yymsp[-3].minor.yy657, &yymsp[0].minor.yy657, false); } break; case 239: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy437, &yymsp[-5].minor.yy109, &yymsp[0].minor.yy109, true); } +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy97, &yymsp[-5].minor.yy657, &yymsp[0].minor.yy657, true); } break; case 240: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy437, &yymsp[-3].minor.yy109, yymsp[0].minor.yy452, false); } +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy97, &yymsp[-3].minor.yy657, yymsp[0].minor.yy652, false); } break; case 241: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy437, &yymsp[-5].minor.yy109, yymsp[0].minor.yy452, true); } +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy97, &yymsp[-5].minor.yy657, yymsp[0].minor.yy652, true); } break; case 242: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy437, &yymsp[0].minor.yy109); } +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy657); } break; case 243: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy437, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109); } +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy97, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy657); } break; case 244: /* cmd ::= DESC full_table_name */ case 245: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==245); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy652); } break; case 246: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; case 247: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy437, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy97, yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } break; case 249: /* analyze_opt ::= ANALYZE */ case 257: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==257); - case 411: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==411); -{ yymsp[0].minor.yy437 = true; } + case 417: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==417); +{ yymsp[0].minor.yy97 = true; } break; case 250: /* explain_options ::= */ -{ yymsp[1].minor.yy452 = createDefaultExplainOptions(pCxt); } +{ yymsp[1].minor.yy652 = createDefaultExplainOptions(pCxt); } break; case 251: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy452 = setExplainVerbose(pCxt, yymsp[-2].minor.yy452, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setExplainVerbose(pCxt, yymsp[-2].minor.yy652, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 252: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy452 = setExplainRatio(pCxt, yymsp[-2].minor.yy452, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = setExplainRatio(pCxt, yymsp[-2].minor.yy652, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 253: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ -{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy404); } +{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy24); } break; case 254: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy437, yymsp[-8].minor.yy437, &yymsp[-5].minor.yy109, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy504, yymsp[0].minor.yy100); } +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy97, yymsp[-8].minor.yy97, &yymsp[-5].minor.yy657, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy48, yymsp[0].minor.yy244); } break; case 255: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy437, &yymsp[0].minor.yy109); } +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy657); } break; case 258: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy100 = 0; } +{ yymsp[1].minor.yy244 = 0; } break; case 259: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy100 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy244 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; case 260: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy437, &yymsp[-4].minor.yy109, yymsp[-2].minor.yy452, yymsp[-3].minor.yy452, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy97, &yymsp[-4].minor.yy657, yymsp[-2].minor.yy652, yymsp[-3].minor.yy652, yymsp[0].minor.yy652); } break; case 261: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy437, &yymsp[0].minor.yy109); } +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy657); } break; case 263: /* into_opt ::= INTO full_table_name */ - case 392: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==392); - case 422: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==422); - case 445: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==445); -{ yymsp[-1].minor.yy452 = yymsp[0].minor.yy452; } + case 398: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==398); + case 428: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==428); + case 451: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==451); +{ yymsp[-1].minor.yy652 = yymsp[0].minor.yy652; } break; case 265: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy452)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SStreamOptions*)yymsp[-2].minor.yy652)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy652 = yymsp[-2].minor.yy652; } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 266: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy452)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy452 = yymsp[-2].minor.yy452; } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ ((SStreamOptions*)yymsp[-2].minor.yy652)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy652 = yymsp[-2].minor.yy652; } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 267: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-3].minor.yy452)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy452)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy452); yylhsminor.yy452 = yymsp[-3].minor.yy452; } - yymsp[-3].minor.yy452 = yylhsminor.yy452; +{ ((SStreamOptions*)yymsp[-3].minor.yy652)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy652)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy652); yylhsminor.yy652 = yymsp[-3].minor.yy652; } + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; case 269: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } @@ -4061,39 +4143,39 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; case 274: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy404); } +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy24); } break; case 275: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; case 276: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy404 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +{ yymsp[-1].minor.yy24 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; case 278: /* cmd ::= SYNCDB db_name REPLICA */ -{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy109); } +{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy657); } break; case 279: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } break; case 281: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 282: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 283: /* literal ::= NK_STRING */ -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 284: /* literal ::= NK_BOOL */ -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 285: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; case 286: /* literal ::= duration_literal */ case 296: /* signed_literal ::= signed */ yytestcase(yyruleno==296); @@ -4103,173 +4185,173 @@ static YYACTIONTYPE yy_reduce( case 319: /* expression ::= function_expression */ yytestcase(yyruleno==319); case 320: /* expression ::= subquery */ yytestcase(yyruleno==320); case 347: /* function_expression ::= literal_func */ yytestcase(yyruleno==347); - case 383: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==383); - case 387: /* boolean_primary ::= predicate */ yytestcase(yyruleno==387); - case 389: /* common_expression ::= expression */ yytestcase(yyruleno==389); - case 390: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==390); - case 393: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==393); - case 395: /* table_reference ::= table_primary */ yytestcase(yyruleno==395); - case 396: /* table_reference ::= joined_table */ yytestcase(yyruleno==396); - case 400: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==400); - case 451: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==451); - case 454: /* query_primary ::= query_specification */ yytestcase(yyruleno==454); -{ yylhsminor.yy452 = yymsp[0].minor.yy452; } - yymsp[0].minor.yy452 = yylhsminor.yy452; + case 389: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==389); + case 393: /* boolean_primary ::= predicate */ yytestcase(yyruleno==393); + case 395: /* common_expression ::= expression */ yytestcase(yyruleno==395); + case 396: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==396); + case 399: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==399); + case 401: /* table_reference ::= table_primary */ yytestcase(yyruleno==401); + case 402: /* table_reference ::= joined_table */ yytestcase(yyruleno==402); + case 406: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==406); + case 457: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==457); + case 460: /* query_primary ::= query_specification */ yytestcase(yyruleno==460); +{ yylhsminor.yy652 = yymsp[0].minor.yy652; } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 287: /* literal ::= NULL */ -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 288: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 289: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 290: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 291: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 292: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; case 293: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 294: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; case 295: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; case 297: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 298: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 299: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; case 300: /* signed_literal ::= duration_literal */ case 302: /* signed_literal ::= literal_func */ yytestcase(yyruleno==302); - case 361: /* star_func_para ::= expression */ yytestcase(yyruleno==361); - case 417: /* select_item ::= common_expression */ yytestcase(yyruleno==417); - case 467: /* search_condition ::= common_expression */ yytestcase(yyruleno==467); -{ yylhsminor.yy452 = releaseRawExprNode(pCxt, yymsp[0].minor.yy452); } - yymsp[0].minor.yy452 = yylhsminor.yy452; + case 367: /* star_func_para ::= expression */ yytestcase(yyruleno==367); + case 423: /* select_item ::= common_expression */ yytestcase(yyruleno==423); + case 473: /* search_condition ::= common_expression */ yytestcase(yyruleno==473); +{ yylhsminor.yy652 = releaseRawExprNode(pCxt, yymsp[0].minor.yy652); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 301: /* signed_literal ::= NULL */ -{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 321: /* expression ::= NK_LP expression NK_RP */ - case 388: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==388); -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy452)); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + case 394: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==394); +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy652)); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 322: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy452)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy652)); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; case 323: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy452), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy652), NULL)); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; case 324: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 325: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 326: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 327: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 328: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 329: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 330: /* expression ::= expression NK_BITAND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 331: /* expression ::= expression NK_BITOR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 334: /* column_reference ::= column_name */ -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy109, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy109)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy657, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy657)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 335: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109, createColumnNode(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109)); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy657, createColumnNode(pCxt, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy657)); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 336: /* pseudo_column ::= ROWTS */ case 337: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==337); @@ -4279,319 +4361,319 @@ static YYACTIONTYPE yy_reduce( case 342: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==342); case 343: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==343); case 349: /* literal_func ::= NOW */ yytestcase(yyruleno==349); -{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 338: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy109)))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy657)))); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 344: /* function_expression ::= function_name NK_LP expression_list NK_RP */ case 345: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==345); -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy109, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy109, yymsp[-1].minor.yy404)); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy657, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy657, yymsp[-1].minor.yy24)); } + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; case 346: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), yymsp[-1].minor.yy504)); } - yymsp[-5].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), yymsp[-1].minor.yy48)); } + yymsp[-5].minor.yy652 = yylhsminor.yy652; break; case 348: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy109, NULL)); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy657, NULL)); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 357: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy404 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy404 = yylhsminor.yy404; + case 363: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy24 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 362: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 420: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==420); -{ yylhsminor.yy452 = createColumnNode(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + case 368: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 426: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==426); +{ yylhsminor.yy652 = createColumnNode(pCxt, &yymsp[-2].minor.yy657, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 363: /* predicate ::= expression compare_op expression */ - case 368: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==368); + case 369: /* predicate ::= expression compare_op expression */ + case 374: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==374); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy440, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy700, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 364: /* predicate ::= expression BETWEEN expression AND expression */ + case 370: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy452), releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy652), releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-4].minor.yy452 = yylhsminor.yy452; + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; - case 365: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 371: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy452), releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy652), releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-5].minor.yy452 = yylhsminor.yy452; + yymsp[-5].minor.yy652 = yylhsminor.yy652; break; - case 366: /* predicate ::= expression IS NULL */ + case 372: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), NULL)); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 367: /* predicate ::= expression IS NOT NULL */ + case 373: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), NULL)); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; - case 369: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy440 = OP_TYPE_LOWER_THAN; } + case 375: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy700 = OP_TYPE_LOWER_THAN; } break; - case 370: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy440 = OP_TYPE_GREATER_THAN; } + case 376: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy700 = OP_TYPE_GREATER_THAN; } break; - case 371: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy440 = OP_TYPE_LOWER_EQUAL; } + case 377: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy700 = OP_TYPE_LOWER_EQUAL; } break; - case 372: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy440 = OP_TYPE_GREATER_EQUAL; } + case 378: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy700 = OP_TYPE_GREATER_EQUAL; } break; - case 373: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy440 = OP_TYPE_NOT_EQUAL; } + case 379: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy700 = OP_TYPE_NOT_EQUAL; } break; - case 374: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy440 = OP_TYPE_EQUAL; } + case 380: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy700 = OP_TYPE_EQUAL; } break; - case 375: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy440 = OP_TYPE_LIKE; } + case 381: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy700 = OP_TYPE_LIKE; } break; - case 376: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy440 = OP_TYPE_NOT_LIKE; } + case 382: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy700 = OP_TYPE_NOT_LIKE; } break; - case 377: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy440 = OP_TYPE_MATCH; } + case 383: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy700 = OP_TYPE_MATCH; } break; - case 378: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy440 = OP_TYPE_NMATCH; } + case 384: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy700 = OP_TYPE_NMATCH; } break; - case 379: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy440 = OP_TYPE_JSON_CONTAINS; } + case 385: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy700 = OP_TYPE_JSON_CONTAINS; } break; - case 380: /* in_op ::= IN */ -{ yymsp[0].minor.yy440 = OP_TYPE_IN; } + case 386: /* in_op ::= IN */ +{ yymsp[0].minor.yy700 = OP_TYPE_IN; } break; - case 381: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy440 = OP_TYPE_NOT_IN; } + case 387: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy700 = OP_TYPE_NOT_IN; } break; - case 382: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy404)); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + case 388: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy24)); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 384: /* boolean_value_expression ::= NOT boolean_primary */ + case 390: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy452), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy652), NULL)); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 385: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 391: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 386: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 392: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); - yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 394: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy452 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy452, yymsp[0].minor.yy452, NULL); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + case 400: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy652 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy652, yymsp[0].minor.yy652, NULL); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 397: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy452 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy109, &yymsp[0].minor.yy109); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; + case 403: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy652 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy657, &yymsp[0].minor.yy657); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 398: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy452 = createRealTableNode(pCxt, &yymsp[-3].minor.yy109, &yymsp[-1].minor.yy109, &yymsp[0].minor.yy109); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; + case 404: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy652 = createRealTableNode(pCxt, &yymsp[-3].minor.yy657, &yymsp[-1].minor.yy657, &yymsp[0].minor.yy657); } + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; - case 399: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy452 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy452), &yymsp[0].minor.yy109); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; + case 405: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy652 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy652), &yymsp[0].minor.yy657); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 401: /* alias_opt ::= */ -{ yymsp[1].minor.yy109 = nil_token; } + case 407: /* alias_opt ::= */ +{ yymsp[1].minor.yy657 = nil_token; } break; - case 402: /* alias_opt ::= table_alias */ -{ yylhsminor.yy109 = yymsp[0].minor.yy109; } - yymsp[0].minor.yy109 = yylhsminor.yy109; + case 408: /* alias_opt ::= table_alias */ +{ yylhsminor.yy657 = yymsp[0].minor.yy657; } + yymsp[0].minor.yy657 = yylhsminor.yy657; break; - case 403: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy109 = yymsp[0].minor.yy109; } + case 409: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy657 = yymsp[0].minor.yy657; } break; - case 404: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 405: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==405); -{ yymsp[-2].minor.yy452 = yymsp[-1].minor.yy452; } + case 410: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 411: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==411); +{ yymsp[-2].minor.yy652 = yymsp[-1].minor.yy652; } break; - case 406: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy452 = createJoinTableNode(pCxt, yymsp[-4].minor.yy532, yymsp[-5].minor.yy452, yymsp[-2].minor.yy452, yymsp[0].minor.yy452); } - yymsp[-5].minor.yy452 = yylhsminor.yy452; + case 412: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy652 = createJoinTableNode(pCxt, yymsp[-4].minor.yy596, yymsp[-5].minor.yy652, yymsp[-2].minor.yy652, yymsp[0].minor.yy652); } + yymsp[-5].minor.yy652 = yylhsminor.yy652; break; - case 407: /* join_type ::= */ -{ yymsp[1].minor.yy532 = JOIN_TYPE_INNER; } + case 413: /* join_type ::= */ +{ yymsp[1].minor.yy596 = JOIN_TYPE_INNER; } break; - case 408: /* join_type ::= INNER */ -{ yymsp[0].minor.yy532 = JOIN_TYPE_INNER; } + case 414: /* join_type ::= INNER */ +{ yymsp[0].minor.yy596 = JOIN_TYPE_INNER; } break; - case 409: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 415: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-11].minor.yy452 = createSelectStmt(pCxt, yymsp[-10].minor.yy437, yymsp[-9].minor.yy404, yymsp[-8].minor.yy452); - yymsp[-11].minor.yy452 = addWhereClause(pCxt, yymsp[-11].minor.yy452, yymsp[-7].minor.yy452); - yymsp[-11].minor.yy452 = addPartitionByClause(pCxt, yymsp[-11].minor.yy452, yymsp[-6].minor.yy404); - yymsp[-11].minor.yy452 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy452, yymsp[-2].minor.yy452); - yymsp[-11].minor.yy452 = addGroupByClause(pCxt, yymsp[-11].minor.yy452, yymsp[-1].minor.yy404); - yymsp[-11].minor.yy452 = addHavingClause(pCxt, yymsp[-11].minor.yy452, yymsp[0].minor.yy452); - yymsp[-11].minor.yy452 = addRangeClause(pCxt, yymsp[-11].minor.yy452, yymsp[-5].minor.yy452); - yymsp[-11].minor.yy452 = addEveryClause(pCxt, yymsp[-11].minor.yy452, yymsp[-4].minor.yy452); - yymsp[-11].minor.yy452 = addFillClause(pCxt, yymsp[-11].minor.yy452, yymsp[-3].minor.yy452); + yymsp[-11].minor.yy652 = createSelectStmt(pCxt, yymsp[-10].minor.yy97, yymsp[-9].minor.yy24, yymsp[-8].minor.yy652); + yymsp[-11].minor.yy652 = addWhereClause(pCxt, yymsp[-11].minor.yy652, yymsp[-7].minor.yy652); + yymsp[-11].minor.yy652 = addPartitionByClause(pCxt, yymsp[-11].minor.yy652, yymsp[-6].minor.yy24); + yymsp[-11].minor.yy652 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy652, yymsp[-2].minor.yy652); + yymsp[-11].minor.yy652 = addGroupByClause(pCxt, yymsp[-11].minor.yy652, yymsp[-1].minor.yy24); + yymsp[-11].minor.yy652 = addHavingClause(pCxt, yymsp[-11].minor.yy652, yymsp[0].minor.yy652); + yymsp[-11].minor.yy652 = addRangeClause(pCxt, yymsp[-11].minor.yy652, yymsp[-5].minor.yy652); + yymsp[-11].minor.yy652 = addEveryClause(pCxt, yymsp[-11].minor.yy652, yymsp[-4].minor.yy652); + yymsp[-11].minor.yy652 = addFillClause(pCxt, yymsp[-11].minor.yy652, yymsp[-3].minor.yy652); } break; - case 412: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy437 = false; } + case 418: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy97 = false; } break; - case 413: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy404 = NULL; } + case 419: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy24 = NULL; } break; - case 418: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy452 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy452), &yymsp[0].minor.yy109); } - yymsp[-1].minor.yy452 = yylhsminor.yy452; + case 424: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy652 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy652), &yymsp[0].minor.yy657); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 419: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy452 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), &yymsp[0].minor.yy109); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + case 425: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy652 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), &yymsp[0].minor.yy657); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 424: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 441: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==441); - case 457: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==457); -{ yymsp[-2].minor.yy404 = yymsp[0].minor.yy404; } + case 430: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 447: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==447); + case 463: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==463); +{ yymsp[-2].minor.yy24 = yymsp[0].minor.yy24; } break; - case 426: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy452 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), releaseRawExprNode(pCxt, yymsp[-1].minor.yy452)); } + case 432: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy652 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), releaseRawExprNode(pCxt, yymsp[-1].minor.yy652)); } break; - case 427: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ -{ yymsp[-3].minor.yy452 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy452)); } + case 433: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ +{ yymsp[-3].minor.yy652 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy652)); } break; - case 428: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy452 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), NULL, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } + case 434: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy652 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), NULL, yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } break; - case 429: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy452 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy452), releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } + case 435: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy652 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy652), releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } break; - case 431: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - case 449: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==449); -{ yymsp[-3].minor.yy452 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy452); } + case 437: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + case 455: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==455); +{ yymsp[-3].minor.yy652 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy652); } break; - case 433: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy452 = createFillNode(pCxt, yymsp[-1].minor.yy614, NULL); } + case 439: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy652 = createFillNode(pCxt, yymsp[-1].minor.yy250, NULL); } break; - case 434: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy452 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy404)); } + case 440: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy652 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy24)); } break; - case 435: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy614 = FILL_MODE_NONE; } + case 441: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy250 = FILL_MODE_NONE; } break; - case 436: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy614 = FILL_MODE_PREV; } + case 442: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy250 = FILL_MODE_PREV; } break; - case 437: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy614 = FILL_MODE_NULL; } + case 443: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy250 = FILL_MODE_NULL; } break; - case 438: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy614 = FILL_MODE_LINEAR; } + case 444: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy250 = FILL_MODE_LINEAR; } break; - case 439: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy614 = FILL_MODE_NEXT; } + case 445: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy250 = FILL_MODE_NEXT; } break; - case 442: /* group_by_list ::= expression */ -{ yylhsminor.yy404 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[0].minor.yy404 = yylhsminor.yy404; + case 448: /* group_by_list ::= expression */ +{ yylhsminor.yy24 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 443: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-2].minor.yy404 = yylhsminor.yy404; + case 449: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 447: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ -{ yymsp[-5].minor.yy452 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), releaseRawExprNode(pCxt, yymsp[-1].minor.yy452)); } + case 453: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ +{ yymsp[-5].minor.yy652 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), releaseRawExprNode(pCxt, yymsp[-1].minor.yy652)); } break; - case 450: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 456: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy452 = addOrderByClause(pCxt, yymsp[-3].minor.yy452, yymsp[-2].minor.yy404); - yylhsminor.yy452 = addSlimitClause(pCxt, yylhsminor.yy452, yymsp[-1].minor.yy452); - yylhsminor.yy452 = addLimitClause(pCxt, yylhsminor.yy452, yymsp[0].minor.yy452); + yylhsminor.yy652 = addOrderByClause(pCxt, yymsp[-3].minor.yy652, yymsp[-2].minor.yy24); + yylhsminor.yy652 = addSlimitClause(pCxt, yylhsminor.yy652, yymsp[-1].minor.yy652); + yylhsminor.yy652 = addLimitClause(pCxt, yylhsminor.yy652, yymsp[0].minor.yy652); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; - case 452: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy452 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy452, yymsp[0].minor.yy452); } - yymsp[-3].minor.yy452 = yylhsminor.yy452; + case 458: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy652 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy652, yymsp[0].minor.yy652); } + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; - case 453: /* query_expression_body ::= query_expression_body UNION query_expression_body */ -{ yylhsminor.yy452 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy452, yymsp[0].minor.yy452); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + case 459: /* query_expression_body ::= query_expression_body UNION query_expression_body */ +{ yylhsminor.yy652 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy652, yymsp[0].minor.yy652); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 455: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ -{ yymsp[-5].minor.yy452 = yymsp[-4].minor.yy452; } - yy_destructor(yypParser,362,&yymsp[-3].minor); - yy_destructor(yypParser,363,&yymsp[-2].minor); - yy_destructor(yypParser,364,&yymsp[-1].minor); + case 461: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ +{ yymsp[-5].minor.yy652 = yymsp[-4].minor.yy652; } + yy_destructor(yypParser,366,&yymsp[-3].minor); + yy_destructor(yypParser,367,&yymsp[-2].minor); + yy_destructor(yypParser,368,&yymsp[-1].minor); break; - case 459: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 463: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==463); -{ yymsp[-1].minor.yy452 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 465: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 469: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==469); +{ yymsp[-1].minor.yy652 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 460: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 464: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==464); -{ yymsp[-3].minor.yy452 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 466: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 470: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==470); +{ yymsp[-3].minor.yy652 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 461: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 465: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==465); -{ yymsp[-3].minor.yy452 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 467: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 471: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==471); +{ yymsp[-3].minor.yy652 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 466: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy452); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + case 472: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy652); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 470: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy452 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), yymsp[-1].minor.yy178, yymsp[0].minor.yy77); } - yymsp[-2].minor.yy452 = yylhsminor.yy452; + case 476: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy652 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), yymsp[-1].minor.yy598, yymsp[0].minor.yy653); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 471: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy178 = ORDER_ASC; } + case 477: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy598 = ORDER_ASC; } break; - case 472: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy178 = ORDER_ASC; } + case 478: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy598 = ORDER_ASC; } break; - case 473: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy178 = ORDER_DESC; } + case 479: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy598 = ORDER_DESC; } break; - case 474: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy77 = NULL_ORDER_DEFAULT; } + case 480: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy653 = NULL_ORDER_DEFAULT; } break; - case 475: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy77 = NULL_ORDER_FIRST; } + case 481: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy653 = NULL_ORDER_FIRST; } break; - case 476: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy77 = NULL_ORDER_LAST; } + case 482: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy653 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parInsertTest.cpp b/source/libs/parser/test/parInsertTest.cpp index 3ebf9a417b..22a1be2579 100644 --- a/source/libs/parser/test/parInsertTest.cpp +++ b/source/libs/parser/test/parInsertTest.cpp @@ -265,6 +265,11 @@ TEST_F(InsertTest, autoCreateTableTest) { "insert into st1s1 using st1 (tag1, tag2) tags(1, 'wxy') values (now, 1, \"beijing\")" "(now+1s, 2, \"shanghai\")(now+2s, 3, \"guangzhou\")"); ASSERT_EQ(runAsync(), TSDB_CODE_SUCCESS); + + bind( + "insert into st1s1 using st1 tags(1, 'wxy', now) values (now, 1, \"beijing\")" + "st1s1 using st1 tags(1, 'wxy', now) values (now+1s, 2, \"shanghai\")"); + ASSERT_EQ(run(), TSDB_CODE_SUCCESS); } TEST_F(InsertTest, toleranceTest) { diff --git a/source/libs/parser/test/parSelectTest.cpp b/source/libs/parser/test/parSelectTest.cpp index 82e07b71af..4ca2dec299 100644 --- a/source/libs/parser/test/parSelectTest.cpp +++ b/source/libs/parser/test/parSelectTest.cpp @@ -423,6 +423,18 @@ TEST_F(ParserSelectTest, withoutFrom) { useDb("root", "test"); run("SELECT 1"); + + run("SELECT DATABASE()"); + + run("SELECT CLIENT_VERSION()"); + + run("SELECT SERVER_VERSION()"); + + run("SELECT SERVER_STATUS()"); + + run("SELECT CURRENT_USER()"); + + run("SELECT USER()"); } } // namespace ParserTest diff --git a/source/libs/parser/test/parTestUtil.cpp b/source/libs/parser/test/parTestUtil.cpp index 663f456cb8..2b312642cd 100644 --- a/source/libs/parser/test/parTestUtil.cpp +++ b/source/libs/parser/test/parTestUtil.cpp @@ -203,6 +203,7 @@ class ParserTestBaseImpl { pCxt->pMsg = stmtEnv_.msgBuf_.data(); pCxt->msgLen = stmtEnv_.msgBuf_.max_size(); pCxt->async = async; + pCxt->svrVer = "3.0.0.0"; } void doParse(SParseContext* pCxt, SQuery** pQuery) { diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index ef8b109b62..d170482c48 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -154,16 +154,12 @@ static int32_t createSelectRootLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p return createRootLogicNode(pCxt, pSelect, pSelect->precision, (FCreateLogicNode)func, pRoot); } -static EScanType getScanType(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNodeList* pScanPseudoCols, - SNodeList* pScanCols, int8_t tableType) { +static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols, SNodeList* pScanCols, + int8_t tableType) { if (pCxt->pPlanCxt->topicQuery || pCxt->pPlanCxt->streamQuery) { return SCAN_TYPE_STREAM; } - if (pSelect->hasLastRowFunc) { - return SCAN_TYPE_LAST_ROW; - } - if (NULL == pScanCols) { // select count(*) from t return NULL == pScanPseudoCols @@ -279,7 +275,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect code = rewriteExprsForSelect(pScan->pScanPseudoCols, pSelect, SQL_CLAUSE_FROM); } - pScan->scanType = getScanType(pCxt, pSelect, pScan->pScanPseudoCols, pScan->pScanCols, pScan->tableType); + pScan->scanType = getScanType(pCxt, pScan->pScanPseudoCols, pScan->pScanCols, pScan->tableType); if (TSDB_CODE_SUCCESS == code) { code = addPrimaryKeyCol(pScan->tableId, &pScan->pScanCols); @@ -474,6 +470,8 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, return TSDB_CODE_OUT_OF_MEMORY; } + pAgg->hasLastRow = pSelect->hasLastRowFunc; + int32_t code = TSDB_CODE_SUCCESS; // set grouyp keys, agg funcs and having conditions diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 42f7f744c5..b1e5b542e3 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -276,7 +276,8 @@ static int32_t pushDownCondOptAppendCond(SNode** pCond, SNode** pAdditionalCond) } int32_t code = TSDB_CODE_SUCCESS; - if (QUERY_NODE_LOGIC_CONDITION == nodeType(*pCond)) { + if (QUERY_NODE_LOGIC_CONDITION == nodeType(*pCond) && + LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)*pCond)->condType) { code = nodesListAppend(((SLogicConditionNode*)*pCond)->pParameterList, *pAdditionalCond); if (TSDB_CODE_SUCCESS == code) { *pAdditionalCond = NULL; @@ -1083,6 +1084,11 @@ static int32_t partTagsOptRebuildTbanme(SNodeList* pPartKeys) { return code; } +// todo refact: just to mask compilation warnings +static void partTagsSetAlias(char* pAlias, int32_t len, const char* pTableAlias, const char* pColName) { + snprintf(pAlias, len, "%s.%s", pTableAlias, pColName); +} + static SNode* partTagsCreateWrapperFunc(const char* pFuncName, SNode* pNode) { SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pFunc) { @@ -1092,7 +1098,7 @@ static SNode* partTagsCreateWrapperFunc(const char* pFuncName, SNode* pNode) { strcpy(pFunc->functionName, pFuncName); if (QUERY_NODE_COLUMN == nodeType(pNode)) { SColumnNode* pCol = (SColumnNode*)pNode; - sprintf(pFunc->node.aliasName, "%s.%s", pCol->tableAlias, pCol->colName); + partTagsSetAlias(pFunc->node.aliasName, sizeof(pFunc->node.aliasName), pCol->tableAlias, pCol->colName); } else { strcpy(pFunc->node.aliasName, ((SExprNode*)pNode)->aliasName); } @@ -1464,9 +1470,9 @@ static SNode* rewriteUniqueOptCreateFirstFunc(SFunctionNode* pSelectValue, SNode strcpy(pFunc->functionName, "first"); if (NULL != pSelectValue) { - sprintf(pFunc->node.aliasName, "%s", pSelectValue->node.aliasName); + strcpy(pFunc->node.aliasName, pSelectValue->node.aliasName); } else { - sprintf(pFunc->node.aliasName, "%s.%p", pFunc->functionName, pFunc); + snprintf(pFunc->node.aliasName, sizeof(pFunc->node.aliasName), "%s.%p", pFunc->functionName, pFunc); } int32_t code = nodesListMakeStrictAppend(&pFunc->pParameterList, nodesCloneNode(pCol)); if (TSDB_CODE_SUCCESS == code) { @@ -1616,6 +1622,46 @@ static int32_t rewriteUniqueOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLog return rewriteUniqueOptimizeImpl(pCxt, pLogicSubplan, pIndef); } +static bool lastRowScanOptMayBeOptimized(SLogicNode* pNode) { + if (QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode) || !(((SAggLogicNode*)pNode)->hasLastRow) || + NULL != ((SAggLogicNode*)pNode)->pGroupKeys || 1 != LIST_LENGTH(pNode->pChildren) || + QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(nodesListGetNode(pNode->pChildren, 0)) || + NULL != ((SScanLogicNode*)nodesListGetNode(pNode->pChildren, 0))->node.pConditions) { + return false; + } + + SNode* pFunc = NULL; + FOREACH(pFunc, ((SAggLogicNode*)pNode)->pAggFuncs) { + if (FUNCTION_TYPE_LAST_ROW != ((SFunctionNode*)pFunc)->funcType) { + return false; + } + } + + return true; +} + +static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { + SAggLogicNode* pAgg = (SAggLogicNode*)optFindPossibleNode(pLogicSubplan->pNode, lastRowScanOptMayBeOptimized); + + if (NULL == pAgg) { + return TSDB_CODE_SUCCESS; + } + + SNode* pNode = NULL; + FOREACH(pNode, pAgg->pAggFuncs) { + SFunctionNode* pFunc = (SFunctionNode*)pNode; + int32_t len = snprintf(pFunc->functionName, sizeof(pFunc->functionName), "_cache_last_row"); + pFunc->functionName[len] = '\0'; + fmGetFuncInfo(pFunc, NULL, 0); + } + pAgg->hasLastRow = false; + + ((SScanLogicNode*)nodesListGetNode(pAgg->node.pChildren, 0))->scanType = SCAN_TYPE_LAST_ROW; + + pCxt->optimized = true; + return TSDB_CODE_SUCCESS; +} + // merge projects static bool mergeProjectsMayBeOptimized(SLogicNode* pNode) { if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren)) { @@ -1704,7 +1750,8 @@ static const SOptimizeRule optimizeRuleSet[] = { {.pName = "EliminateProject", .optimizeFunc = eliminateProjOptimize}, {.pName = "EliminateSetOperator", .optimizeFunc = eliminateSetOpOptimize}, {.pName = "RewriteTail", .optimizeFunc = rewriteTailOptimize}, - {.pName = "RewriteUnique", .optimizeFunc = rewriteUniqueOptimize} + {.pName = "RewriteUnique", .optimizeFunc = rewriteUniqueOptimize}, + {.pName = "LastRowScan", .optimizeFunc = lastRowScanOptimize} }; // clang-format on diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index cbb12fee0e..1fc06f1a7d 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1344,7 +1344,7 @@ static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SMergeLogicNode* pM } } - if (TSDB_CODE_SUCCESS == code) { + if (TSDB_CODE_SUCCESS == code && NULL != pMergeLogicNode->pMergeKeys) { code = setListSlotId(pCxt, pMerge->node.pOutputDataBlockDesc->dataBlockId, -1, pMergeLogicNode->pMergeKeys, &pMerge->pMergeKeys); } diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 9d23df5bda..60c04c2c30 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -197,6 +197,8 @@ static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) { return stbSplIsMultiTbScan(streamQuery, (SScanLogicNode*)pNode); case QUERY_NODE_LOGIC_PLAN_JOIN: return !(((SJoinLogicNode*)pNode)->isSingleTableJoin); + case QUERY_NODE_LOGIC_PLAN_PARTITION: + return stbSplHasMultiTbScan(streamQuery, pNode); case QUERY_NODE_LOGIC_PLAN_AGG: return !stbSplHasGatherExecFunc(((SAggLogicNode*)pNode)->pAggFuncs) && stbSplHasMultiTbScan(streamQuery, pNode); case QUERY_NODE_LOGIC_PLAN_WINDOW: @@ -431,7 +433,7 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo SNodeList* pMergeKeys = NULL; code = stbSplCreateMergeKeysByPrimaryKey(((SWindowLogicNode*)pInfo->pSplitNode)->pTspk, &pMergeKeys); if (TSDB_CODE_SUCCESS == code) { - code = stbSplCreateMergeNode(pCxt, NULL, pInfo->pSplitNode, pMergeKeys, pPartWindow, false); + code = stbSplCreateMergeNode(pCxt, NULL, pInfo->pSplitNode, pMergeKeys, pPartWindow, true); } if (TSDB_CODE_SUCCESS != code) { nodesDestroyList(pMergeKeys); @@ -887,6 +889,16 @@ static int32_t stbSplSplitJoinNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) return code; } +static int32_t stbSplSplitPartitionNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) { + int32_t code = stbSplCreateMergeNode(pCxt, pInfo->pSubplan, pInfo->pSplitNode, NULL, pInfo->pSplitNode, true); + if (TSDB_CODE_SUCCESS == code) { + code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, + (SNode*)splCreateScanSubplan(pCxt, pInfo->pSplitNode, SPLIT_FLAG_STABLE_SPLIT)); + } + ++(pCxt->groupId); + return code; +} + static int32_t stableSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { if (pCxt->pPlanCxt->rSmaQuery) { return TSDB_CODE_SUCCESS; @@ -905,6 +917,9 @@ static int32_t stableSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { case QUERY_NODE_LOGIC_PLAN_JOIN: code = stbSplSplitJoinNode(pCxt, &info); break; + case QUERY_NODE_LOGIC_PLAN_PARTITION: + code = stbSplSplitPartitionNode(pCxt, &info); + break; case QUERY_NODE_LOGIC_PLAN_AGG: code = stbSplSplitAggNode(pCxt, &info); break; diff --git a/source/libs/planner/src/planner.c b/source/libs/planner/src/planner.c index b1268358fb..f3174ce70a 100644 --- a/source/libs/planner/src/planner.c +++ b/source/libs/planner/src/planner.c @@ -102,7 +102,6 @@ static void clearSubplanExecutionNode(SPhysiNode* pNode) { void qClearSubplanExecutionNode(SSubplan* pSubplan) { clearSubplanExecutionNode(pSubplan->pNode); } - int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen) { if (SUBPLAN_TYPE_MODIFY == pSubplan->subplanType && NULL == pSubplan->pNode) { SDataInserterNode* insert = (SDataInserterNode*)pSubplan->pDataSink; diff --git a/source/libs/planner/test/planBasicTest.cpp b/source/libs/planner/test/planBasicTest.cpp index ff725c444e..b886fca2af 100644 --- a/source/libs/planner/test/planBasicTest.cpp +++ b/source/libs/planner/test/planBasicTest.cpp @@ -99,6 +99,8 @@ TEST_F(PlanBasicTest, lastRowFunc) { run("SELECT LAST_ROW(c1, c2) FROM t1"); run("SELECT LAST_ROW(c1) FROM st1"); + + run("SELECT LAST_ROW(c1), SUM(c3) FROM t1"); } TEST_F(PlanBasicTest, sampleFunc) { diff --git a/source/libs/planner/test/planTestUtil.cpp b/source/libs/planner/test/planTestUtil.cpp index d54859c296..d19e277a7d 100644 --- a/source/libs/planner/test/planTestUtil.cpp +++ b/source/libs/planner/test/planTestUtil.cpp @@ -310,6 +310,7 @@ class PlannerTestBaseImpl { cxt.sqlLen = stmtEnv_.sql_.length(); cxt.pMsg = stmtEnv_.msgBuf_.data(); cxt.msgLen = stmtEnv_.msgBuf_.max_size(); + cxt.svrVer = "3.0.0.0"; DO_WITH_THROW(qParseSql, &cxt, pQuery); if (prepare) { diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 80bebafef2..76c0e48740 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1116,7 +1116,8 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam * int32_t toUnixtimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { int32_t type = GET_PARAM_TYPE(pInput); - int32_t timePrec = GET_PARAM_PRECISON(pInput); + int64_t timePrec; + GET_TYPED_DATA(timePrec, int64_t, GET_PARAM_TYPE(&pInput[1]), pInput[1].columnData->pData); for (int32_t i = 0; i < pInput[0].numOfRows; ++i) { if (colDataIsNull_s(pInput[0].columnData, i)) { @@ -1192,10 +1193,10 @@ int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { int32_t type = GET_PARAM_TYPE(&pInput[0]); - int32_t timePrec = GET_PARAM_PRECISON(&pInput[0]); - int64_t timeUnit, timeVal = 0; + int64_t timeUnit, timePrec, timeVal = 0; GET_TYPED_DATA(timeUnit, int64_t, GET_PARAM_TYPE(&pInput[1]), pInput[1].columnData->pData); + GET_TYPED_DATA(timePrec, int64_t, GET_PARAM_TYPE(&pInput[2]), pInput[2].columnData->pData); int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); @@ -1380,10 +1381,12 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara } int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - int32_t timePrec = GET_PARAM_PRECISON(&pInput[0]); - int64_t timeUnit = -1, timeVal[2] = {0}; - if (inputNum == 3) { + int64_t timeUnit = -1, timePrec, timeVal[2] = {0}; + if (inputNum == 4) { GET_TYPED_DATA(timeUnit, int64_t, GET_PARAM_TYPE(&pInput[2]), pInput[2].columnData->pData); + GET_TYPED_DATA(timePrec, int64_t, GET_PARAM_TYPE(&pInput[3]), pInput[3].columnData->pData); + } else { + GET_TYPED_DATA(timePrec, int64_t, GET_PARAM_TYPE(&pInput[2]), pInput[2].columnData->pData); } int32_t numOfRows = 0; @@ -1512,7 +1515,10 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p } int32_t nowFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - int64_t ts = taosGetTimestamp(TSDB_TIME_PRECISION_MILLI); + int64_t timePrec; + GET_TYPED_DATA(timePrec, int64_t, GET_PARAM_TYPE(&pInput[0]), pInput[0].columnData->pData); + + int64_t ts = taosGetTimestamp(timePrec); for (int32_t i = 0; i < pInput->numOfRows; ++i) { colDataAppendInt64(pOutput->columnData, i, &ts); } @@ -1521,7 +1527,10 @@ int32_t nowFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu } int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - int64_t ts = taosGetTimestampToday(TSDB_TIME_PRECISION_MILLI); + int64_t timePrec; + GET_TYPED_DATA(timePrec, int64_t, GET_PARAM_TYPE(&pInput[0]), pInput[0].columnData->pData); + + int64_t ts = taosGetTimestampToday(timePrec); for (int32_t i = 0; i < pInput->numOfRows; ++i) { colDataAppendInt64(pOutput->columnData, i, &ts); } diff --git a/source/libs/scheduler/inc/schedulerInt.h b/source/libs/scheduler/inc/schedulerInt.h index 8595e41640..94a1108710 100644 --- a/source/libs/scheduler/inc/schedulerInt.h +++ b/source/libs/scheduler/inc/schedulerInt.h @@ -99,8 +99,8 @@ typedef struct SSchStat { typedef struct SSchResInfo { SQueryResult* queryRes; void** fetchRes; - schedulerExecCallback execFp; - schedulerFetchCallback fetchFp; + schedulerExecFp execFp; + schedulerFetchFp fetchFp; void* userParam; } SSchResInfo; @@ -204,37 +204,38 @@ typedef struct { } SSchOpStatus; typedef struct SSchJob { - int64_t refId; - uint64_t queryId; - SSchJobAttr attr; - int32_t levelNum; - int32_t taskNum; - SRequestConnInfo conn; - SArray *nodeList; // qnode/vnode list, SArray - SArray *levels; // starting from 0. SArray - SQueryPlan *pDag; + int64_t refId; + uint64_t queryId; + SSchJobAttr attr; + int32_t levelNum; + int32_t taskNum; + SRequestConnInfo conn; + SArray *nodeList; // qnode/vnode list, SArray + SArray *levels; // starting from 0. SArray + SQueryPlan *pDag; - SArray *dataSrcTasks; // SArray - int32_t levelIdx; - SEpSet dataSrcEps; - SHashObj *taskList; - SHashObj *execTasks; // executing and executed tasks, key:taskid, value:SQueryTask* - SHashObj *flowCtrl; // key is ep, element is SSchFlowControl + SArray *dataSrcTasks; // SArray + int32_t levelIdx; + SEpSet dataSrcEps; + SHashObj *taskList; + SHashObj *execTasks; // executing and executed tasks, key:taskid, value:SQueryTask* + SHashObj *flowCtrl; // key is ep, element is SSchFlowControl - SExplainCtx *explainCtx; - int8_t status; - SQueryNodeAddr resNode; - tsem_t rspSem; - SSchOpStatus opStatus; - bool *reqKilled; - SSchTask *fetchTask; - int32_t errCode; - SRWLatch resLock; - SQueryExecRes execRes; - void *resData; //TODO free it or not - int32_t resNumOfRows; - SSchResInfo userRes; - const char *sql; + SExplainCtx *explainCtx; + int8_t status; + SQueryNodeAddr resNode; + tsem_t rspSem; + SSchOpStatus opStatus; + schedulerChkKillFp chkKillFp; + void* chkKillParam; + SSchTask *fetchTask; + int32_t errCode; + SRWLatch resLock; + SQueryExecRes execRes; + void *resData; //TODO free it or not + int32_t resNumOfRows; + SSchResInfo userRes; + const char *sql; SQueryProfileSummary summary; } SSchJob; diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index b2a96cbb23..425ea242fd 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -55,9 +55,10 @@ int32_t schInitJob(SSchedulerReq *pReq, SSchJob **pSchJob) { pJob->conn = *pReq->pConn; pJob->sql = pReq->sql; pJob->pDag = pReq->pDag; - pJob->reqKilled = pReq->reqKilled; - pJob->userRes.execFp = pReq->fp; - pJob->userRes.userParam = pReq->cbParam; + pJob->chkKillFp = pReq->chkKillFp; + pJob->chkKillParam = pReq->chkKillParam; + pJob->userRes.execFp = pReq->execFp; + pJob->userRes.userParam = pReq->execParam; if (pReq->pNodeList == NULL || taosArrayGetSize(pReq->pNodeList) <= 0) { qDebug("QID:0x%" PRIx64 " input exec nodeList is empty", pReq->pDag->queryId); @@ -182,7 +183,7 @@ FORCE_INLINE bool schJobNeedToStop(SSchJob *pJob, int8_t *pStatus) { *pStatus = status; } - if (*pJob->reqKilled) { + if ((*pJob->chkKillFp)(pJob->chkKillParam)) { schUpdateJobStatus(pJob, JOB_TASK_STATUS_DROPPING); schUpdateJobErrCode(pJob, TSDB_CODE_TSC_QUERY_KILLED); @@ -1611,7 +1612,7 @@ _return: schEndOperation(pJob); if (!sync) { - pReq->fp(NULL, pReq->cbParam, code); + pReq->execFp(NULL, pReq->execParam, code); } schFreeJobImpl(pJob); @@ -1658,7 +1659,7 @@ int32_t schExecJobImpl(SSchedulerReq *pReq, SSchJob *pJob, bool sync) { SCH_ERR_JRET(schBeginOperation(pJob, SCH_OP_EXEC, sync)); if (EXPLAIN_MODE_STATIC == pReq->pDag->explainInfo.mode) { - code = schLaunchStaticExplainJob(pReq, pJob, true); + code = schLaunchStaticExplainJob(pReq, pJob, sync); } else { code = schLaunchJob(pJob); if (sync) { @@ -1678,7 +1679,7 @@ int32_t schExecJobImpl(SSchedulerReq *pReq, SSchJob *pJob, bool sync) { _return: if (!sync) { - pReq->fp(NULL, pReq->cbParam, code); + pReq->execFp(NULL, pReq->execParam, code); } SCH_RET(code); diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 15a687531c..74ddc89b40 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -113,10 +113,6 @@ _return: schReleaseJob(pJob->refId); } - if (code != TSDB_CODE_SUCCESS) { - pReq->fp(NULL, pReq->cbParam, code); - } - return code; } @@ -144,7 +140,7 @@ int32_t schedulerFetchRows(int64_t job, void **pData) { SCH_RET(code); } -void schedulerAsyncFetchRows(int64_t job, schedulerFetchCallback fp, void* param) { +void schedulerAsyncFetchRows(int64_t job, schedulerFetchFp fp, void* param) { qDebug("scheduler async fetch rows start"); int32_t code = 0; diff --git a/source/libs/scheduler/test/schedulerTests.cpp b/source/libs/scheduler/test/schedulerTests.cpp index 22b08e9037..098699744d 100644 --- a/source/libs/scheduler/test/schedulerTests.cpp +++ b/source/libs/scheduler/test/schedulerTests.cpp @@ -511,8 +511,8 @@ void* schtRunJobThread(void *aa) { req.pNodeList = qnodeList; req.pDag = &dag; req.sql = "select * from tb"; - req.fp = schtQueryCb; - req.cbParam = &queryDone; + req.execFp = schtQueryCb; + req.execParam = &queryDone; code = schedulerAsyncExecJob(&req, &queryJobRefId); assert(code == 0); @@ -663,8 +663,8 @@ TEST(queryTest, normalCase) { req.pNodeList = qnodeList; req.pDag = &dag; req.sql = "select * from tb"; - req.fp = schtQueryCb; - req.cbParam = &queryDone; + req.execFp = schtQueryCb; + req.execParam = &queryDone; code = schedulerAsyncExecJob(&req, &job); ASSERT_EQ(code, 0); @@ -767,8 +767,8 @@ TEST(queryTest, readyFirstCase) { req.pNodeList = qnodeList; req.pDag = &dag; req.sql = "select * from tb"; - req.fp = schtQueryCb; - req.cbParam = &queryDone; + req.execFp = schtQueryCb; + req.execParam = &queryDone; code = schedulerAsyncExecJob(&req, &job); ASSERT_EQ(code, 0); @@ -874,8 +874,8 @@ TEST(queryTest, flowCtrlCase) { req.pNodeList = qnodeList; req.pDag = &dag; req.sql = "select * from tb"; - req.fp = schtQueryCb; - req.cbParam = &queryDone; + req.execFp = schtQueryCb; + req.execParam = &queryDone; code = schedulerAsyncExecJob(&req, &job); ASSERT_EQ(code, 0); @@ -987,8 +987,8 @@ TEST(insertTest, normalCase) { req.pNodeList = qnodeList; req.pDag = &dag; req.sql = "insert into tb values(now,1)"; - req.fp = schtQueryCb; - req.cbParam = NULL; + req.execFp = schtQueryCb; + req.execParam = NULL; code = schedulerExecJob(&req, &insertJobRefId, &res); ASSERT_EQ(code, 0); diff --git a/source/libs/stream/src/streamData.c b/source/libs/stream/src/streamData.c index 3efe3e6c9c..e9b311db9a 100644 --- a/source/libs/stream/src/streamData.c +++ b/source/libs/stream/src/streamData.c @@ -30,7 +30,7 @@ int32_t streamDispatchReqToData(const SStreamDispatchReq* pReq, SStreamDataBlock /*int32_t len = *(int32_t*)taosArrayGet(pReq->dataLen, i);*/ SRetrieveTableRsp* pRetrieve = taosArrayGetP(pReq->data, i); SSDataBlock* pDataBlock = taosArrayGet(pArray, i); - blockCompressDecode(pDataBlock, htonl(pRetrieve->numOfCols), htonl(pRetrieve->numOfRows), pRetrieve->data); + blockDecode(pDataBlock, htonl(pRetrieve->numOfCols), htonl(pRetrieve->numOfRows), pRetrieve->data); // TODO: refactor pDataBlock->info.window.skey = be64toh(pRetrieve->skey); pDataBlock->info.window.ekey = be64toh(pRetrieve->ekey); @@ -50,7 +50,7 @@ int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock taosArraySetSize(pArray, 1); SRetrieveTableRsp* pRetrieve = pReq->pRetrieve; SSDataBlock* pDataBlock = taosArrayGet(pArray, 0); - blockCompressDecode(pDataBlock, htonl(pRetrieve->numOfCols), htonl(pRetrieve->numOfRows), pRetrieve->data); + blockDecode(pDataBlock, htonl(pRetrieve->numOfCols), htonl(pRetrieve->numOfRows), pRetrieve->data); // TODO: refactor pDataBlock->info.window.skey = be64toh(pRetrieve->skey); pDataBlock->info.window.ekey = be64toh(pRetrieve->ekey); diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index a5e9b8edd9..8034840fce 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -108,7 +108,7 @@ int32_t streamBroadcastToChildren(SStreamTask* pTask, const SSDataBlock* pBlock) pRetrieve->ekey = htobe64(pBlock->info.window.ekey); int32_t actualLen = 0; - blockCompressEncode(pBlock, pRetrieve->data, &actualLen, numOfCols, false); + blockEncode(pBlock, pRetrieve->data, &actualLen, numOfCols, false); SStreamRetrieveReq req = { .streamId = pTask->streamId, @@ -181,7 +181,7 @@ static int32_t streamAddBlockToDispatchMsg(const SSDataBlock* pBlock, SStreamDis pRetrieve->numOfCols = htonl(numOfCols); int32_t actualLen = 0; - blockCompressEncode(pBlock, pRetrieve->data, &actualLen, numOfCols, false); + blockEncode(pBlock, pRetrieve->data, &actualLen, numOfCols, false); actualLen += sizeof(SRetrieveTableRsp); ASSERT(actualLen <= dataStrLen); taosArrayPush(pReq->dataLen, &actualLen); diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index c75e6c004a..b3be35fba3 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -17,21 +17,20 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes) { void* exec = pTask->exec.executor; - bool hasData = false; // set input SStreamQueueItem* pItem = (SStreamQueueItem*)data; if (pItem->type == STREAM_INPUT__TRIGGER) { SStreamTrigger* pTrigger = (SStreamTrigger*)data; - qSetMultiStreamInput(exec, pTrigger->pBlock, 1, STREAM_DATA_TYPE_SSDATA_BLOCK, false); + qSetMultiStreamInput(exec, pTrigger->pBlock, 1, STREAM_INPUT__DATA_BLOCK, false); } else if (pItem->type == STREAM_INPUT__DATA_SUBMIT) { ASSERT(pTask->isDataScan); SStreamDataSubmit* pSubmit = (SStreamDataSubmit*)data; - qSetStreamInput(exec, pSubmit->data, STREAM_DATA_TYPE_SUBMIT_BLOCK, false); + qSetStreamInput(exec, pSubmit->data, STREAM_INPUT__DATA_SUBMIT, false); } else if (pItem->type == STREAM_INPUT__DATA_BLOCK || pItem->type == STREAM_INPUT__DATA_RETRIEVE) { SStreamDataBlock* pBlock = (SStreamDataBlock*)data; SArray* blocks = pBlock->blocks; - qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_DATA_TYPE_SSDATA_BLOCK, false); + qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_INPUT__DATA_BLOCK, false); } else if (pItem->type == STREAM_INPUT__DROP) { // TODO exec drop return 0; @@ -46,19 +45,16 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes) } if (output == NULL) { if (pItem->type == STREAM_INPUT__DATA_RETRIEVE) { - //SSDataBlock block = {0}; - //block.info.type = STREAM_PUSH_EMPTY; - //block.info.childId = pTask->selfChildId; + SSDataBlock block = {0}; SStreamDataBlock* pRetrieveBlock = (SStreamDataBlock*)data; ASSERT(taosArrayGetSize(pRetrieveBlock->blocks) == 1); - SSDataBlock* pBlock = createOneDataBlock(taosArrayGet(pRetrieveBlock->blocks, 0), true); - pBlock->info.type = STREAM_PUSH_EMPTY; - pBlock->info.childId = pTask->selfChildId; - taosArrayPush(pRes, pBlock); + assignOneDataBlock(&block, taosArrayGet(pRetrieveBlock->blocks, 0)); + block.info.type = STREAM_PULL_OVER; + block.info.childId = pTask->selfChildId; + taosArrayPush(pRes, &block); } break; } - hasData = true; if (output->info.type == STREAM_RETRIEVE) { if (streamBroadcastToChildren(pTask, output) < 0) { @@ -72,9 +68,6 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes) assignOneDataBlock(&block, output); block.info.childId = pTask->selfChildId; taosArrayPush(pRes, &block); - /*SSDataBlock* outputCopy = createOneDataBlock(output, true);*/ - /*outputCopy->info.childId = pTask->selfChildId;*/ - /*taosArrayPush(pRes, outputCopy);*/ } return 0; } @@ -163,4 +156,3 @@ FAIL: atomic_store_8(&pTask->execStatus, TASK_EXEC_STATUS__IDLE); return -1; } - diff --git a/source/libs/stream/src/streamTask.c b/source/libs/stream/src/streamTask.c index 1daa9bd50e..97aa182dc9 100644 --- a/source/libs/stream/src/streamTask.c +++ b/source/libs/stream/src/streamTask.c @@ -86,9 +86,7 @@ int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) { ASSERT(pTask->sinkType == TASK_SINK__NONE); } - if (pTask->dispatchType == TASK_DISPATCH__INPLACE) { - if (tEncodeI32(pEncoder, pTask->inplaceDispatcher.taskId) < 0) return -1; - } else if (pTask->dispatchType == TASK_DISPATCH__FIXED) { + if (pTask->dispatchType == TASK_DISPATCH__FIXED) { if (tEncodeI32(pEncoder, pTask->fixedEpDispatcher.taskId) < 0) return -1; if (tEncodeI32(pEncoder, pTask->fixedEpDispatcher.nodeId) < 0) return -1; if (tEncodeSEpSet(pEncoder, &pTask->fixedEpDispatcher.epSet) < 0) return -1; @@ -147,9 +145,7 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) { ASSERT(pTask->sinkType == TASK_SINK__NONE); } - if (pTask->dispatchType == TASK_DISPATCH__INPLACE) { - if (tDecodeI32(pDecoder, &pTask->inplaceDispatcher.taskId) < 0) return -1; - } else if (pTask->dispatchType == TASK_DISPATCH__FIXED) { + if (pTask->dispatchType == TASK_DISPATCH__FIXED) { if (tDecodeI32(pDecoder, &pTask->fixedEpDispatcher.taskId) < 0) return -1; if (tDecodeI32(pDecoder, &pTask->fixedEpDispatcher.nodeId) < 0) return -1; if (tDecodeSEpSet(pDecoder, &pTask->fixedEpDispatcher.epSet) < 0) return -1; diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h index d351dc50f4..d58ae83dd3 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -221,7 +221,6 @@ void syncNodeVoteForSelf(SSyncNode* pSyncNode); // snapshot -------------- bool syncNodeHasSnapshot(SSyncNode* pSyncNode); -bool syncNodeIsIndexInSnapshot(SSyncNode* pSyncNode, SyncIndex index); SyncIndex syncNodeGetLastIndex(SSyncNode* pSyncNode); SyncTerm syncNodeGetLastTerm(SSyncNode* pSyncNode); diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index ba3dd66550..a10b81d165 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -860,7 +860,9 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs } code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pAppendEntry); - ASSERT(code == 0); + if (code != 0) { + return -1; + } // pre commit code = syncNodePreCommit(ths, pAppendEntry); @@ -971,7 +973,9 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs ASSERT(pAppendEntry != NULL); code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pAppendEntry); - ASSERT(code == 0); + if (code != 0) { + return -1; + } // pre commit code = syncNodePreCommit(ths, pAppendEntry); diff --git a/source/libs/sync/src/syncElection.c b/source/libs/sync/src/syncElection.c index 738b17b9cb..816430b5b5 100644 --- a/source/libs/sync/src/syncElection.c +++ b/source/libs/sync/src/syncElection.c @@ -75,7 +75,11 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) { if (pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER) { syncNodeFollower2Candidate(pSyncNode); } - ASSERT(pSyncNode->state == TAOS_SYNC_STATE_CANDIDATE); + + if (pSyncNode->state != TAOS_SYNC_STATE_CANDIDATE) { + syncNodeErrorLog(pSyncNode, "not candidate, can not elect"); + return -1; + } // start election raftStoreNextTerm(pSyncNode->pRaftStore); diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index f6768bf494..d32153e5ed 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -1923,6 +1923,8 @@ void syncNodeVoteForSelf(SSyncNode* pSyncNode) { } // snapshot -------------- + +// return if has a snapshot bool syncNodeHasSnapshot(SSyncNode* pSyncNode) { bool ret = false; SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0, .lastConfigIndex = -1}; @@ -1935,21 +1937,10 @@ bool syncNodeHasSnapshot(SSyncNode* pSyncNode) { return ret; } -#if 0 -bool syncNodeIsIndexInSnapshot(SSyncNode* pSyncNode, SyncIndex index) { - ASSERT(syncNodeHasSnapshot(pSyncNode)); - ASSERT(pSyncNode->pFsm->FpGetSnapshotInfo != NULL); - ASSERT(index >= SYNC_INDEX_BEGIN); - - SSnapshot snapshot; - pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); - bool b = (index <= snapshot.lastApplyIndex); - return b; -} -#endif - +// return max(logLastIndex, snapshotLastIndex) +// if no snapshot and log, return -1 SyncIndex syncNodeGetLastIndex(SSyncNode* pSyncNode) { - SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0}; + SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0, .lastConfigIndex = -1}; if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); } @@ -1959,6 +1950,8 @@ SyncIndex syncNodeGetLastIndex(SSyncNode* pSyncNode) { return lastIndex; } +// return the last term of snapshot and log +// if error, return SYNC_TERM_INVALID (by syncLogLastTerm) SyncTerm syncNodeGetLastTerm(SSyncNode* pSyncNode) { SyncTerm lastTerm = 0; if (syncNodeHasSnapshot(pSyncNode)) { @@ -1990,11 +1983,14 @@ int32_t syncNodeGetLastIndexTerm(SSyncNode* pSyncNode, SyncIndex* pLastIndex, Sy return 0; } +// return append-entries first try index SyncIndex syncNodeSyncStartIndex(SSyncNode* pSyncNode) { SyncIndex syncStartIndex = syncNodeGetLastIndex(pSyncNode) + 1; return syncStartIndex; } +// if index > 0, return index - 1 +// else, return -1 SyncIndex syncNodeGetPreIndex(SSyncNode* pSyncNode, SyncIndex index) { SyncIndex preIndex = index - 1; if (preIndex < SYNC_INDEX_INVALID) { @@ -2004,21 +2000,10 @@ SyncIndex syncNodeGetPreIndex(SSyncNode* pSyncNode, SyncIndex index) { return preIndex; } -/* -SyncIndex syncNodeGetPreIndex(SSyncNode* pSyncNode, SyncIndex index) { - ASSERT(index >= SYNC_INDEX_BEGIN); - - SyncIndex syncStartIndex = syncNodeSyncStartIndex(pSyncNode); - if (index > syncStartIndex) { - syncNodeLog3("syncNodeGetPreIndex", pSyncNode); - ASSERT(0); - } - - SyncIndex preIndex = index - 1; - return preIndex; -} -*/ - +// if index < 0, return SYNC_TERM_INVALID +// if index == 0, return 0 +// if index > 0, return preTerm +// if error, return SYNC_TERM_INVALID SyncTerm syncNodeGetPreTerm(SSyncNode* pSyncNode, SyncIndex index) { if (index < SYNC_INDEX_BEGIN) { return SYNC_TERM_INVALID; @@ -2056,112 +2041,6 @@ SyncTerm syncNodeGetPreTerm(SSyncNode* pSyncNode, SyncIndex index) { return SYNC_TERM_INVALID; } -#if 0 -SyncTerm syncNodeGetPreTerm(SSyncNode* pSyncNode, SyncIndex index) { - ASSERT(index >= SYNC_INDEX_BEGIN); - - SyncIndex syncStartIndex = syncNodeSyncStartIndex(pSyncNode); - if (index > syncStartIndex) { - syncNodeLog3("syncNodeGetPreTerm", pSyncNode); - ASSERT(0); - } - - if (index == SYNC_INDEX_BEGIN) { - return 0; - } - - SyncTerm preTerm = 0; - SyncIndex preIndex = index - 1; - SSyncRaftEntry* pPreEntry = NULL; - int32_t code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, preIndex, &pPreEntry); - if (code == 0) { - ASSERT(pPreEntry != NULL); - preTerm = pPreEntry->term; - taosMemoryFree(pPreEntry); - return preTerm; - } else { - if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST) { - SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0, .lastConfigIndex = -1}; - if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { - pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); - if (snapshot.lastApplyIndex == preIndex) { - return snapshot.lastApplyTerm; - } - } - } - } - - ASSERT(0); - return -1; -} -#endif - -#if 0 -SyncTerm syncNodeGetPreTerm(SSyncNode* pSyncNode, SyncIndex index) { - ASSERT(index >= SYNC_INDEX_BEGIN); - - SyncIndex syncStartIndex = syncNodeSyncStartIndex(pSyncNode); - if (index > syncStartIndex) { - syncNodeLog3("syncNodeGetPreTerm", pSyncNode); - ASSERT(0); - } - - if (index == SYNC_INDEX_BEGIN) { - return 0; - } - - SyncTerm preTerm = 0; - if (syncNodeHasSnapshot(pSyncNode)) { - // has snapshot - SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0, .lastConfigIndex = -1}; - if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { - pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); - } - - if (index > snapshot.lastApplyIndex + 1) { - // should be log preTerm - SSyncRaftEntry* pPreEntry = NULL; - int32_t code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, index - 1, &pPreEntry); - ASSERT(code == 0); - ASSERT(pPreEntry != NULL); - - preTerm = pPreEntry->term; - taosMemoryFree(pPreEntry); - - } else if (index == snapshot.lastApplyIndex + 1) { - preTerm = snapshot.lastApplyTerm; - - } else { - // maybe snapshot change - sError("sync get pre term, bad scene. index:%ld", index); - logStoreLog2("sync get pre term, bad scene", pSyncNode->pLogStore); - - SSyncRaftEntry* pPreEntry = NULL; - int32_t code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, index - 1, &pPreEntry); - ASSERT(code == 0); - ASSERT(pPreEntry != NULL); - - preTerm = pPreEntry->term; - taosMemoryFree(pPreEntry); - } - - } else { - // no snapshot - ASSERT(index > SYNC_INDEX_BEGIN); - - SSyncRaftEntry* pPreEntry = NULL; - int32_t code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, index - 1, &pPreEntry); - ASSERT(code == 0); - ASSERT(pPreEntry != NULL); - - preTerm = pPreEntry->term; - taosMemoryFree(pPreEntry); - } - - return preTerm; -} -#endif - // get pre index and term of "index" int32_t syncNodeGetPreIndexTerm(SSyncNode* pSyncNode, SyncIndex index, SyncIndex* pPreIndex, SyncTerm* pPreTerm) { *pPreIndex = syncNodeGetPreIndex(pSyncNode, index); @@ -2351,8 +2230,8 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths) { ASSERT(pEntry != NULL); if (ths->state == TAOS_SYNC_STATE_LEADER) { - // ths->pLogStore->appendEntry(ths->pLogStore, pEntry); - ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pEntry); + int32_t code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pEntry); + ASSERT(code == 0); syncNodeReplicate(ths); } @@ -2406,6 +2285,7 @@ int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg) { // int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg, SyncIndex* pRetIndex) { int32_t ret = 0; + int32_t code = 0; syncClientRequestLog2("==syncNodeOnClientRequestCb==", pMsg); SyncIndex index = ths->pLogStore->syncLogWriteIndex(ths->pLogStore); @@ -2414,18 +2294,24 @@ int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg, SyncI ASSERT(pEntry != NULL); if (ths->state == TAOS_SYNC_STATE_LEADER) { - // ths->pLogStore->appendEntry(ths->pLogStore, pEntry); - ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pEntry); + // append entry + code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pEntry); + if (code != 0) { + // del resp mgr, call FpCommitCb + ASSERT(0); + return -1; + } - // start replicate right now! - syncNodeReplicate(ths); + // if mulit replica, start replicate right now + if (ths->replicaNum > 1) { + syncNodeReplicate(ths); + } // pre commit SRpcMsg rpcMsg; syncEntry2OriginalRpc(pEntry, &rpcMsg); if (ths->pFsm != NULL) { - // if (ths->pFsm->FpPreCommitCb != NULL && pEntry->originalRpcType != TDMT_SYNC_NOOP) { if (ths->pFsm->FpPreCommitCb != NULL && syncUtilUserPreCommit(pEntry->originalRpcType)) { SFsmCbMeta cbMeta = {0}; cbMeta.index = pEntry->index; @@ -2439,8 +2325,10 @@ int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg, SyncI } rpcFreeCont(rpcMsg.pCont); - // only myself, maybe commit - syncMaybeAdvanceCommitIndex(ths); + // if only myself, maybe commit right now + if (ths->replicaNum == 1) { + syncMaybeAdvanceCommitIndex(ths); + } } else { // pre commit @@ -2448,7 +2336,6 @@ int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg, SyncI syncEntry2OriginalRpc(pEntry, &rpcMsg); if (ths->pFsm != NULL) { - // if (ths->pFsm->FpPreCommitCb != NULL && pEntry->originalRpcType != TDMT_SYNC_NOOP) { if (ths->pFsm->FpPreCommitCb != NULL && syncUtilUserPreCommit(pEntry->originalRpcType)) { SFsmCbMeta cbMeta = {0}; cbMeta.index = pEntry->index; diff --git a/source/libs/sync/src/syncRaftCfg.c b/source/libs/sync/src/syncRaftCfg.c index 9d16bed6c1..43890c196c 100644 --- a/source/libs/sync/src/syncRaftCfg.c +++ b/source/libs/sync/src/syncRaftCfg.c @@ -101,7 +101,7 @@ cJSON *syncCfg2Json(SSyncCfg *pSyncCfg) { char *syncCfg2Str(SSyncCfg *pSyncCfg) { cJSON *pJson = syncCfg2Json(pSyncCfg); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -109,7 +109,7 @@ char *syncCfg2Str(SSyncCfg *pSyncCfg) { char *syncCfg2SimpleStr(SSyncCfg *pSyncCfg) { if (pSyncCfg != NULL) { int32_t len = 512; - char * s = taosMemoryMalloc(len); + char *s = taosMemoryMalloc(len); memset(s, 0, len); snprintf(s, len, "{replica-num:%d, my-index:%d, ", pSyncCfg->replicaNum, pSyncCfg->myIndex); @@ -205,7 +205,7 @@ cJSON *raftCfg2Json(SRaftCfg *pRaftCfg) { char *raftCfg2Str(SRaftCfg *pRaftCfg) { cJSON *pJson = raftCfg2Json(pRaftCfg); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -214,7 +214,16 @@ int32_t raftCfgCreateFile(SSyncCfg *pCfg, SRaftCfgMeta meta, const char *path) { ASSERT(pCfg != NULL); TdFilePtr pFile = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE); - ASSERT(pFile != NULL); + if (pFile == NULL) { + int32_t err = terrno; + const char *errStr = tstrerror(err); + int32_t sysErr = errno; + const char *sysErrStr = strerror(errno); + sError("create raft cfg file error, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", err, err, errStr, sysErr, sysErrStr); + ASSERT(0); + + return -1; + } SRaftCfg raftCfg; raftCfg.cfg = *pCfg; @@ -271,7 +280,7 @@ int32_t raftCfgFromJson(const cJSON *pRoot, SRaftCfg *pRaftCfg) { (pRaftCfg->configIndexArr)[i] = atoll(pIndex->valuestring); } - cJSON * pJsonSyncCfg = cJSON_GetObjectItem(pJson, "SSyncCfg"); + cJSON *pJsonSyncCfg = cJSON_GetObjectItem(pJson, "SSyncCfg"); int32_t code = syncCfgFromJson(pJsonSyncCfg, &(pRaftCfg->cfg)); ASSERT(code == 0); diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index d84c576714..a026892629 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -17,24 +17,27 @@ #include "syncRaftCfg.h" #include "syncRaftStore.h" -// refactor, log[0 .. n] ==> log[m .. n] -static int32_t raftLogRestoreFromSnapshot(struct SSyncLogStore* pLogStore, SyncIndex snapshotIndex); -// static int32_t raftLogSetBeginIndex(struct SSyncLogStore* pLogStore, SyncIndex beginIndex); +//------------------------------- +// log[m .. n] + +// public function +static int32_t raftLogRestoreFromSnapshot(struct SSyncLogStore* pLogStore, SyncIndex snapshotIndex); static SyncIndex raftLogBeginIndex(struct SSyncLogStore* pLogStore); static SyncIndex raftLogEndIndex(struct SSyncLogStore* pLogStore); static SyncIndex raftLogWriteIndex(struct SSyncLogStore* pLogStore); static bool raftLogIsEmpty(struct SSyncLogStore* pLogStore); static int32_t raftLogEntryCount(struct SSyncLogStore* pLogStore); - static SyncIndex raftLogLastIndex(struct SSyncLogStore* pLogStore); static SyncTerm raftLogLastTerm(struct SSyncLogStore* pLogStore); static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry); static int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncRaftEntry** ppEntry); static int32_t raftLogTruncate(struct SSyncLogStore* pLogStore, SyncIndex fromIndex); +// private function static int32_t raftLogGetLastEntry(SSyncLogStore* pLogStore, SSyncRaftEntry** ppLastEntry); //------------------------------- +// log[0 .. n] static SSyncRaftEntry* logStoreGetLastEntry(SSyncLogStore* pLogStore); static SyncIndex logStoreLastIndex(SSyncLogStore* pLogStore); static SyncTerm logStoreLastTerm(SSyncLogStore* pLogStore); @@ -44,28 +47,86 @@ static int32_t logStoreTruncate(SSyncLogStore* pLogStore, SyncIndex from static int32_t logStoreUpdateCommitIndex(SSyncLogStore* pLogStore, SyncIndex index); static SyncIndex logStoreGetCommitIndex(SSyncLogStore* pLogStore); -// refactor, log[0 .. n] ==> log[m .. n] -/* -static int32_t raftLogSetBeginIndex(struct SSyncLogStore* pLogStore, SyncIndex beginIndex) { - // if beginIndex == 0, donot need call this funciton - ASSERT(beginIndex > 0); +//------------------------------- +SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) { + SSyncLogStore* pLogStore = taosMemoryMalloc(sizeof(SSyncLogStore)); + ASSERT(pLogStore != NULL); + + pLogStore->data = taosMemoryMalloc(sizeof(SSyncLogStoreData)); + ASSERT(pLogStore->data != NULL); SSyncLogStoreData* pData = pLogStore->data; - SWal* pWal = pData->pWal; - sTrace("vgId:%d, reset wal begin index:%ld", pData->pSyncNode->vgId, beginIndex); + pData->pSyncNode = pSyncNode; + pData->pWal = pSyncNode->pWal; + ASSERT(pData->pWal != NULL); - pData->beginIndex = beginIndex; - walRestoreFromSnapshot(pWal, beginIndex - 1); - return 0; + taosThreadMutexInit(&(pData->mutex), NULL); + pData->pWalHandle = walOpenReadHandle(pData->pWal); + ASSERT(pData->pWalHandle != NULL); + + pLogStore->appendEntry = logStoreAppendEntry; + pLogStore->getEntry = logStoreGetEntry; + pLogStore->truncate = logStoreTruncate; + pLogStore->getLastIndex = logStoreLastIndex; + pLogStore->getLastTerm = logStoreLastTerm; + pLogStore->updateCommitIndex = logStoreUpdateCommitIndex; + pLogStore->getCommitIndex = logStoreGetCommitIndex; + + pLogStore->syncLogRestoreFromSnapshot = raftLogRestoreFromSnapshot; + pLogStore->syncLogBeginIndex = raftLogBeginIndex; + pLogStore->syncLogEndIndex = raftLogEndIndex; + pLogStore->syncLogIsEmpty = raftLogIsEmpty; + pLogStore->syncLogEntryCount = raftLogEntryCount; + pLogStore->syncLogLastIndex = raftLogLastIndex; + pLogStore->syncLogLastTerm = raftLogLastTerm; + pLogStore->syncLogAppendEntry = raftLogAppendEntry; + pLogStore->syncLogGetEntry = raftLogGetEntry; + pLogStore->syncLogTruncate = raftLogTruncate; + pLogStore->syncLogWriteIndex = raftLogWriteIndex; + + return pLogStore; } -*/ +void logStoreDestory(SSyncLogStore* pLogStore) { + if (pLogStore != NULL) { + SSyncLogStoreData* pData = pLogStore->data; + + taosThreadMutexLock(&(pData->mutex)); + if (pData->pWalHandle != NULL) { + walCloseReadHandle(pData->pWalHandle); + pData->pWalHandle = NULL; + } + taosThreadMutexUnlock(&(pData->mutex)); + taosThreadMutexDestroy(&(pData->mutex)); + + taosMemoryFree(pLogStore->data); + taosMemoryFree(pLogStore); + } +} + +//------------------------------- +// log[m .. n] static int32_t raftLogRestoreFromSnapshot(struct SSyncLogStore* pLogStore, SyncIndex snapshotIndex) { ASSERT(snapshotIndex >= 0); SSyncLogStoreData* pData = pLogStore->data; SWal* pWal = pData->pWal; - walRestoreFromSnapshot(pWal, snapshotIndex); + int32_t code = walRestoreFromSnapshot(pWal, snapshotIndex); + if (code != 0) { + int32_t err = terrno; + const char* errStr = tstrerror(err); + int32_t sysErr = errno; + const char* sysErrStr = strerror(errno); + + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), + "wal restore from snapshot error, index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", snapshotIndex, err, + err, errStr, sysErr, sysErrStr); + syncNodeErrorLog(pData->pSyncNode, logBuf); + + return -1; + } + return 0; } @@ -91,18 +152,6 @@ static int32_t raftLogEntryCount(struct SSyncLogStore* pLogStore) { return count > 0 ? count : 0; } -#if 0 -static bool raftLogInRange(struct SSyncLogStore* pLogStore, SyncIndex index) { - SyncIndex beginIndex = raftLogBeginIndex(pLogStore); - SyncIndex endIndex = raftLogEndIndex(pLogStore); - if (index >= beginIndex && index <= endIndex) { - return true; - } else { - return false; - } -} -#endif - static SyncIndex raftLogLastIndex(struct SSyncLogStore* pLogStore) { SyncIndex lastIndex; SSyncLogStoreData* pData = pLogStore->data; @@ -119,6 +168,9 @@ static SyncIndex raftLogWriteIndex(struct SSyncLogStore* pLogStore) { return lastVer + 1; } +// if success, return last term +// if not log, return 0 +// if error, return SYNC_TERM_INVALID static SyncTerm raftLogLastTerm(struct SSyncLogStore* pLogStore) { SSyncLogStoreData* pData = pLogStore->data; SWal* pWal = pData->pWal; @@ -127,34 +179,18 @@ static SyncTerm raftLogLastTerm(struct SSyncLogStore* pLogStore) { } else { SSyncRaftEntry* pLastEntry; int32_t code = raftLogGetLastEntry(pLogStore, &pLastEntry); - ASSERT(code == 0); - ASSERT(pLastEntry != NULL); - - SyncTerm lastTerm = pLastEntry->term; - taosMemoryFree(pLastEntry); - return lastTerm; - } - - return 0; -} - -/* -static SyncTerm raftLogLastTerm(struct SSyncLogStore* pLogStore) { - SyncTerm lastTerm = 0; - if (raftLogEntryCount(pLogStore) == 0) { - lastTerm = 0; - } else { - SSyncRaftEntry* pLastEntry; - int32_t code = raftLogGetLastEntry(pLogStore, &pLastEntry); - ASSERT(code == 0); - if (pLastEntry != NULL) { - lastTerm = pLastEntry->term; + if (code == 0 && pLastEntry != NULL) { + SyncTerm lastTerm = pLastEntry->term; taosMemoryFree(pLastEntry); + return lastTerm; + } else { + return SYNC_TERM_INVALID; } } - return lastTerm; + + // can not be here! + return SYNC_TERM_INVALID; } -*/ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) { SSyncLogStoreData* pData = pLogStore->data; @@ -187,63 +223,21 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr ASSERT(0); } - walFsync(pWal, true); + // walFsync(pWal, true); - char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "write index:%ld, type:%s,%d, type2:%s,%d", pEntry->index, - TMSG_INFO(pEntry->msgType), pEntry->msgType, TMSG_INFO(pEntry->originalRpcType), pEntry->originalRpcType); - syncNodeEventLog(pData->pSyncNode, eventLog); + do { + char eventLog[128]; + snprintf(eventLog, sizeof(eventLog), "write index:%ld, type:%s,%d, type2:%s,%d", pEntry->index, + TMSG_INFO(pEntry->msgType), pEntry->msgType, TMSG_INFO(pEntry->originalRpcType), pEntry->originalRpcType); + syncNodeEventLog(pData->pSyncNode, eventLog); + } while (0); return code; } -#if 0 -static int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncRaftEntry** ppEntry) { - SSyncLogStoreData* pData = pLogStore->data; - SWal* pWal = pData->pWal; - int32_t code; - - *ppEntry = NULL; - if (raftLogInRange(pLogStore, index)) { - SWalReadHandle* pWalHandle = walOpenReadHandle(pWal); - ASSERT(pWalHandle != NULL); - - code = walReadWithHandle(pWalHandle, index); - if (code != 0) { - int32_t err = terrno; - const char* errStr = tstrerror(err); - int32_t linuxErr = errno; - const char* linuxErrMsg = strerror(errno); - sError("raftLogGetEntry error, err:%d %X, msg:%s, linuxErr:%d, linuxErrMsg:%s", err, err, errStr, linuxErr, - linuxErrMsg); - ASSERT(0); - walCloseReadHandle(pWalHandle); - return code; - } - - *ppEntry = syncEntryBuild(pWalHandle->pHead->head.bodyLen); - ASSERT(*ppEntry != NULL); - (*ppEntry)->msgType = TDMT_SYNC_CLIENT_REQUEST; - (*ppEntry)->originalRpcType = pWalHandle->pHead->head.msgType; - (*ppEntry)->seqNum = pWalHandle->pHead->head.syncMeta.seqNum; - (*ppEntry)->isWeak = pWalHandle->pHead->head.syncMeta.isWeek; - (*ppEntry)->term = pWalHandle->pHead->head.syncMeta.term; - (*ppEntry)->index = index; - ASSERT((*ppEntry)->dataLen == pWalHandle->pHead->head.bodyLen); - memcpy((*ppEntry)->data, pWalHandle->pHead->head.body, pWalHandle->pHead->head.bodyLen); - - // need to hold, do not new every time!! - walCloseReadHandle(pWalHandle); - - } else { - // index not in range - code = 0; - } - - return code; -} -#endif - +// entry found, return 0 +// entry not found, return -1, terrno = TSDB_CODE_WAL_LOG_NOT_EXIST +// other error, return -1 static int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncRaftEntry** ppEntry) { SSyncLogStoreData* pData = pLogStore->data; SWal* pWal = pData->pWal; @@ -254,6 +248,7 @@ static int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, // SWalReadHandle* pWalHandle = walOpenReadHandle(pWal); SWalReadHandle* pWalHandle = pData->pWalHandle; if (pWalHandle == NULL) { + terrno = TSDB_CODE_SYN_INTERNAL_ERROR; return -1; } @@ -325,6 +320,9 @@ static int32_t raftLogTruncate(struct SSyncLogStore* pLogStore, SyncIndex fromIn return code; } +// entry found, return 0 +// entry not found, return -1, terrno = TSDB_CODE_WAL_LOG_NOT_EXIST +// other error, return -1 static int32_t raftLogGetLastEntry(SSyncLogStore* pLogStore, SSyncRaftEntry** ppLastEntry) { SSyncLogStoreData* pData = pLogStore->data; SWal* pWal = pData->pWal; @@ -336,98 +334,16 @@ static int32_t raftLogGetLastEntry(SSyncLogStore* pLogStore, SSyncRaftEntry** pp return -1; } else { SyncIndex lastIndex = raftLogLastIndex(pLogStore); - int32_t code = raftLogGetEntry(pLogStore, lastIndex, ppLastEntry); + ASSERT(lastIndex >= SYNC_INDEX_BEGIN); + int32_t code = raftLogGetEntry(pLogStore, lastIndex, ppLastEntry); return code; } return -1; } -/* -static int32_t raftLogGetLastEntry(SSyncLogStore* pLogStore, SSyncRaftEntry** ppLastEntry) { - *ppLastEntry = NULL; - if (raftLogEntryCount(pLogStore) == 0) { - return 0; - } - SyncIndex lastIndex = raftLogLastIndex(pLogStore); - int32_t code = raftLogGetEntry(pLogStore, lastIndex, ppLastEntry); - return code; -} -*/ - -//------------------------------- -SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) { - SSyncLogStore* pLogStore = taosMemoryMalloc(sizeof(SSyncLogStore)); - ASSERT(pLogStore != NULL); - - pLogStore->data = taosMemoryMalloc(sizeof(SSyncLogStoreData)); - ASSERT(pLogStore->data != NULL); - - SSyncLogStoreData* pData = pLogStore->data; - pData->pSyncNode = pSyncNode; - pData->pWal = pSyncNode->pWal; - ASSERT(pData->pWal != NULL); - - taosThreadMutexInit(&(pData->mutex), NULL); - pData->pWalHandle = walOpenReadHandle(pData->pWal); - ASSERT(pData->pWalHandle != NULL); - - /* - SyncIndex firstVer = walGetFirstVer(pData->pWal); - SyncIndex lastVer = walGetLastVer(pData->pWal); - if (firstVer >= 0) { - pData->beginIndex = firstVer; - } else if (firstVer == -1) { - pData->beginIndex = lastVer + 1; - } else { - ASSERT(0); - } - */ - - pLogStore->appendEntry = logStoreAppendEntry; - pLogStore->getEntry = logStoreGetEntry; - pLogStore->truncate = logStoreTruncate; - pLogStore->getLastIndex = logStoreLastIndex; - pLogStore->getLastTerm = logStoreLastTerm; - pLogStore->updateCommitIndex = logStoreUpdateCommitIndex; - pLogStore->getCommitIndex = logStoreGetCommitIndex; - - // pLogStore->syncLogSetBeginIndex = raftLogSetBeginIndex; - pLogStore->syncLogRestoreFromSnapshot = raftLogRestoreFromSnapshot; - pLogStore->syncLogBeginIndex = raftLogBeginIndex; - pLogStore->syncLogEndIndex = raftLogEndIndex; - pLogStore->syncLogIsEmpty = raftLogIsEmpty; - pLogStore->syncLogEntryCount = raftLogEntryCount; - pLogStore->syncLogLastIndex = raftLogLastIndex; - pLogStore->syncLogLastTerm = raftLogLastTerm; - pLogStore->syncLogAppendEntry = raftLogAppendEntry; - pLogStore->syncLogGetEntry = raftLogGetEntry; - pLogStore->syncLogTruncate = raftLogTruncate; - pLogStore->syncLogWriteIndex = raftLogWriteIndex; - - // pLogStore->syncLogInRange = raftLogInRange; - - return pLogStore; -} - -void logStoreDestory(SSyncLogStore* pLogStore) { - if (pLogStore != NULL) { - SSyncLogStoreData* pData = pLogStore->data; - - taosThreadMutexLock(&(pData->mutex)); - if (pData->pWalHandle != NULL) { - walCloseReadHandle(pData->pWalHandle); - pData->pWalHandle = NULL; - } - taosThreadMutexUnlock(&(pData->mutex)); - taosThreadMutexDestroy(&(pData->mutex)); - - taosMemoryFree(pLogStore->data); - taosMemoryFree(pLogStore); - } -} - //------------------------------- +// log[0 .. n] int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) { SSyncLogStoreData* pData = pLogStore->data; SWal* pWal = pData->pWal; @@ -455,7 +371,7 @@ int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) { ASSERT(0); } - walFsync(pWal, true); + // walFsync(pWal, true); char eventLog[128]; snprintf(eventLog, sizeof(eventLog), "old write index:%ld, type:%s,%d, type2:%s,%d", pEntry->index, @@ -593,55 +509,6 @@ SSyncRaftEntry* logStoreGetLastEntry(SSyncLogStore* pLogStore) { return pEntry; } -/* -cJSON* logStore2Json(SSyncLogStore* pLogStore) { - char u64buf[128] = {0}; - SSyncLogStoreData* pData = (SSyncLogStoreData*)pLogStore->data; - cJSON* pRoot = cJSON_CreateObject(); - - if (pData != NULL && pData->pWal != NULL) { - snprintf(u64buf, sizeof(u64buf), "%p", pData->pSyncNode); - cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pData->pWal); - cJSON_AddStringToObject(pRoot, "pWal", u64buf); - - snprintf(u64buf, sizeof(u64buf), "%ld", pData->beginIndex); - cJSON_AddStringToObject(pRoot, "beginIndex", u64buf); - - SyncIndex endIndex = raftLogEndIndex(pLogStore); - snprintf(u64buf, sizeof(u64buf), "%ld", endIndex); - cJSON_AddStringToObject(pRoot, "endIndex", u64buf); - - int32_t count = raftLogEntryCount(pLogStore); - cJSON_AddNumberToObject(pRoot, "entryCount", count); - - snprintf(u64buf, sizeof(u64buf), "%ld", raftLogWriteIndex(pLogStore)); - cJSON_AddStringToObject(pRoot, "WriteIndex", u64buf); - - snprintf(u64buf, sizeof(u64buf), "%d", raftLogIsEmpty(pLogStore)); - cJSON_AddStringToObject(pRoot, "IsEmpty", u64buf); - - snprintf(u64buf, sizeof(u64buf), "%ld", raftLogLastIndex(pLogStore)); - cJSON_AddStringToObject(pRoot, "LastIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", raftLogLastTerm(pLogStore)); - cJSON_AddStringToObject(pRoot, "LastTerm", u64buf); - - cJSON* pEntries = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "pEntries", pEntries); - - for (SyncIndex i = pData->beginIndex; i <= endIndex; ++i) { - SSyncRaftEntry* pEntry = logStoreGetEntry(pLogStore, i); - cJSON_AddItemToArray(pEntries, syncEntry2Json(pEntry)); - syncEntryDestory(pEntry); - } - } - - cJSON* pJson = cJSON_CreateObject(); - cJSON_AddItemToObject(pJson, "SSyncLogStore", pRoot); - return pJson; -} -*/ - cJSON* logStore2Json(SSyncLogStore* pLogStore) { char u64buf[128] = {0}; SSyncLogStoreData* pData = (SSyncLogStoreData*)pLogStore->data; diff --git a/source/libs/sync/src/syncRequestVote.c b/source/libs/sync/src/syncRequestVote.c index 95dec6cb83..d272e0175f 100644 --- a/source/libs/sync/src/syncRequestVote.c +++ b/source/libs/sync/src/syncRequestVote.c @@ -156,6 +156,10 @@ static bool syncNodeOnRequestVoteLogOK(SSyncNode* pSyncNode, SyncRequestVote* pM SyncTerm myLastTerm = syncNodeGetLastTerm(pSyncNode); SyncIndex myLastIndex = syncNodeGetLastIndex(pSyncNode); + if (myLastTerm == SYNC_TERM_INVALID) { + return false; + } + if (pMsg->lastLogTerm > myLastTerm) { return true; } diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 0e77876b97..70f3801e61 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -508,32 +508,51 @@ void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { } while (0); } -static void snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pMsg) { +static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pMsg) { ASSERT(pMsg->seq == SYNC_SNAPSHOT_SEQ_END); + int32_t code = 0; if (pReceiver->pWriter != NULL) { - int32_t code = 0; + // write data if (pMsg->dataLen > 0) { code = pReceiver->pSyncNode->pFsm->FpSnapshotDoWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, pMsg->data, pMsg->dataLen); - ASSERT(code == 0); + if (code != 0) { + syncNodeErrorLog(pReceiver->pSyncNode, "snapshot write error"); + return -1; + } } + // reset wal + code = + pReceiver->pSyncNode->pLogStore->syncLogRestoreFromSnapshot(pReceiver->pSyncNode->pLogStore, pMsg->lastIndex); + if (code != 0) { + syncNodeErrorLog(pReceiver->pSyncNode, "wal restore from snapshot error"); + return -1; + } + + // update commit index + if (pReceiver->snapshot.lastApplyIndex > pReceiver->pSyncNode->commitIndex) { + pReceiver->pSyncNode->commitIndex = pReceiver->snapshot.lastApplyIndex; + } + + // stop writer code = pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, true); - ASSERT(code == 0); + if (code != 0) { + syncNodeErrorLog(pReceiver->pSyncNode, "snapshot stop writer true error"); + ASSERT(0); + return -1; + } pReceiver->pWriter = NULL; + + // update progress + pReceiver->ack = SYNC_SNAPSHOT_SEQ_END; + + } else { + syncNodeErrorLog(pReceiver->pSyncNode, "snapshot stop writer true error"); + return -1; } - pReceiver->ack = SYNC_SNAPSHOT_SEQ_END; - - // update commit index - if (pReceiver->snapshot.lastApplyIndex > pReceiver->pSyncNode->commitIndex) { - pReceiver->pSyncNode->commitIndex = pReceiver->snapshot.lastApplyIndex; - } - - // reset wal - pReceiver->pSyncNode->pLogStore->syncLogRestoreFromSnapshot(pReceiver->pSyncNode->pLogStore, pMsg->lastIndex); - // event log do { SSnapshot snapshot; @@ -542,6 +561,8 @@ static void snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnapsho syncNodeEventLog(pReceiver->pSyncNode, eventLog); taosMemoryFree(eventLog); } while (0); + + return 0; } static void snapshotReceiverGotData(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pMsg) { @@ -642,6 +663,7 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { // get receiver SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver; bool needRsp = false; + int32_t code = 0; // state, term, seq/ack if (pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER) { @@ -653,8 +675,10 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_END) { // end, finish FSM - snapshotReceiverFinish(pReceiver, pMsg); - snapshotReceiverStop(pReceiver); + code = snapshotReceiverFinish(pReceiver, pMsg); + if (code == 0) { + snapshotReceiverStop(pReceiver); + } needRsp = true; // maybe update lastconfig @@ -772,6 +796,7 @@ int32_t syncNodeOnSnapshotRspCb(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) { snapshotReSend(pSender); } else { + // error log do { char logBuf[96]; snprintf(logBuf, sizeof(logBuf), "snapshot sender recv error ack:%d, my seq:%d", pMsg->ack, pSender->seq); diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index bb554793d9..b06d541b75 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -296,7 +296,6 @@ void transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pMsg, STra void transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pMsg, STransMsg* pRsp); void transSendResponse(const STransMsg* msg); void transRegisterMsg(const STransMsg* msg); -int transGetConnInfo(void* thandle, STransHandleInfo* pInfo); void transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn); void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, void* fp, void* shandle); diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index a26725c41c..936cfe870d 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -83,6 +83,7 @@ void rpcClose(void* arg) { SRpcInfo* pRpc = (SRpcInfo*)arg; (*taosCloseHandle[pRpc->connType])(pRpc->tcphandle); taosMemoryFree(pRpc); + tInfo("finish to close rpc"); return; } @@ -140,7 +141,9 @@ void rpcSendRecv(void* shandle, SEpSet* pEpSet, SRpcMsg* pMsg, SRpcMsg* pRsp) { } void rpcSendResponse(const SRpcMsg* pMsg) { transSendResponse(pMsg); } -int32_t rpcGetConnInfo(void* thandle, SRpcConnInfo* pInfo) { return transGetConnInfo((void*)thandle, pInfo); } + +int32_t rpcGetConnInfo(void* thandle, SRpcConnInfo* pInfo) { return 0; } + void rpcRefHandle(void* handle, int8_t type) { assert(type == TAOS_CONN_SERVER || type == TAOS_CONN_CLIENT); diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 77cc5dbaf7..4ec54beebf 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -317,8 +317,9 @@ void cliHandleResp(SCliConn* conn) { if (CONN_NO_PERSIST_BY_APP(conn)) { pMsg = transQueuePop(&conn->cliMsgs); - pCtx = pMsg->ctx; - transMsg.info.ahandle = pCtx->ahandle; + + pCtx = pMsg ? pMsg->ctx : NULL; + transMsg.info.ahandle = pCtx ? pCtx->ahandle : NULL; tDebug("%s conn %p get ahandle %p, persist: 0", CONN_GET_INST_LABEL(conn), conn, transMsg.info.ahandle); } else { uint64_t ahandle = (uint64_t)pHead->ahandle; @@ -464,8 +465,7 @@ void* destroyConnPool(void* pool) { SConnList* connList = taosHashIterate((SHashObj*)pool, NULL); while (connList != NULL) { while (!QUEUE_IS_EMPTY(&connList->conn)) { - queue* h = QUEUE_HEAD(&connList->conn); - // QUEUE_REMOVE(h); + queue* h = QUEUE_HEAD(&connList->conn); SCliConn* c = QUEUE_DATA(h, SCliConn, conn); cliDestroyConn(c, true); } @@ -502,6 +502,7 @@ static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port) { static void allocConnRef(SCliConn* conn, bool update) { if (update) { transRemoveExHandle(conn->refId); + conn->refId = -1; } SExHandle* exh = taosMemoryCalloc(1, sizeof(SExHandle)); exh->handle = conn; @@ -601,8 +602,10 @@ static void cliDestroyConn(SCliConn* conn, bool clear) { QUEUE_REMOVE(&conn->conn); QUEUE_INIT(&conn->conn); transRemoveExHandle(conn->refId); + conn->refId = -1; + if (clear) { - if (uv_is_active((uv_handle_t*)conn->stream)) { + if (!uv_is_closing((uv_handle_t*)conn->stream)) { uv_close((uv_handle_t*)conn->stream, cliDestroy); } else { cliDestroy((uv_handle_t*)conn->stream); @@ -610,8 +613,14 @@ static void cliDestroyConn(SCliConn* conn, bool clear) { } } static void cliDestroy(uv_handle_t* handle) { + if (uv_handle_get_type(handle) != UV_TCP || handle->data == NULL) { + return; + } + SCliConn* conn = handle->data; + transRemoveExHandle(conn->refId); taosMemoryFree(conn->ip); + conn->stream->data = NULL; taosMemoryFree(conn->stream); transCtxCleanup(&conn->ctx); transQueueDestroy(&conn->cliMsgs); @@ -969,7 +978,7 @@ void cliSendQuit(SCliThrd* thrd) { } void cliWalkCb(uv_handle_t* handle, void* arg) { if (!uv_is_closing(handle)) { - uv_close(handle, NULL); + uv_close(handle, cliDestroy); } } diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index aacae590a0..5516c1cf36 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -139,7 +139,6 @@ static void uvHandleResp(SSvrMsg* msg, SWorkThrd* thrd); static void uvHandleRegister(SSvrMsg* msg, SWorkThrd* thrd); static void (*transAsyncHandle[])(SSvrMsg* msg, SWorkThrd* thrd) = {uvHandleResp, uvHandleQuit, uvHandleRelease, uvHandleRegister, NULL}; - static void uvDestroyConn(uv_handle_t* handle); // server and worker thread @@ -332,7 +331,6 @@ void uvOnTimeoutCb(uv_timer_t* handle) { void uvOnSendCb(uv_write_t* req, int status) { SSvrConn* conn = req->data; - // transClearBuffer(&conn->readBuf); if (status == 0) { tTrace("conn %p data already was written on stream", conn); if (!transQueueEmpty(&conn->srvMsgs)) { @@ -362,6 +360,7 @@ void uvOnSendCb(uv_write_t* req, int status) { } } } + transUnrefSrvHandle(conn); } else { tError("conn %p failed to write data, %s", conn, uv_err_name(status)); conn->broken = true; @@ -424,11 +423,15 @@ static void uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) { } static void uvStartSendRespInternal(SSvrMsg* smsg) { + SSvrConn* pConn = smsg->pConn; + if (pConn->broken) { + return; + } + uv_buf_t wb; uvPrepareSendData(smsg, &wb); - SSvrConn* pConn = smsg->pConn; - // uv_timer_stop(&pConn->pTimer); + transRefSrvHandle(pConn); uv_write(&pConn->pWriter, (uv_stream_t*)pConn->pTcp, &wb, 1, uvOnSendCb); } static void uvStartSendResp(SSvrMsg* smsg) { @@ -769,12 +772,9 @@ static void destroyConn(SSvrConn* conn, bool clear) { transDestroyBuffer(&conn->readBuf); if (clear) { - if (uv_is_active((uv_handle_t*)conn->pTcp)) { + if (!uv_is_closing((uv_handle_t*)conn->pTcp)) { tTrace("conn %p to be destroyed", conn); - // uv_shutdown_t* req = taosMemoryMalloc(sizeof(uv_shutdown_t)); uv_close((uv_handle_t*)conn->pTcp, uvDestroyConn); - // uv_close(conn->pTcp) - // uv_shutdown(req, (uv_stream_t*)conn->pTcp, uvShutDownCb); } else { uvDestroyConn((uv_handle_t*)conn->pTcp); } diff --git a/source/os/src/osSocket.c b/source/os/src/osSocket.c index b0e07ff010..f0dd5b974d 100644 --- a/source/os/src/osSocket.c +++ b/source/os/src/osSocket.c @@ -925,10 +925,24 @@ uint32_t taosGetIpv4FromFqdn(const char *fqdn) { } int32_t taosGetFqdn(char *fqdn) { +#ifdef WINDOWS + // Initialize Winsock + WSADATA wsaData; + int iResult; + iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); + if (iResult != 0) { + // printf("WSAStartup failed: %d\n", iResult); + return 1; + } +#endif char hostname[1024]; hostname[1023] = '\0'; if (gethostname(hostname, 1023) == -1) { - // printf("failed to get hostname, reason:%s", strerror(errno)); +#ifdef WINDOWS + printf("failed to get hostname, reason:%s", strerror(WSAGetLastError())); +#else + printf("failed to get hostname, reason:%s", strerror(errno)); +#endif assert(0); return -1; } diff --git a/tests/pytest/a.sh b/tests/pytest/a.sh new file mode 100755 index 0000000000..cf6157980d --- /dev/null +++ b/tests/pytest/a.sh @@ -0,0 +1,13 @@ +#!/bin/bash +for i in {1..100} +do + echo $i + python3 ./test.py -f query/nestedQuery/nestedQuery_datacheck.py >>log 2>&1 + if [ $? -eq 0 ] + then + echo success + else + echo failed + break + fi +done diff --git a/tests/script/sh/exec.bat b/tests/script/sh/exec.bat index 0f3d0dcf49..e4c998c25b 100644 --- a/tests/script/sh/exec.bat +++ b/tests/script/sh/exec.bat @@ -6,6 +6,7 @@ if %1 == -n set NODE_NAME=%2 if %1 == -s set EXEC_OPTON=%2 if %3 == -n set NODE_NAME=%4 if %3 == -s set EXEC_OPTON=%4 +if "%5" == "-x" set EXEC_SIGNAL=%6 rem echo NODE_NAME: %NODE_NAME% rem echo NODE: %EXEC_OPTON% @@ -39,7 +40,7 @@ rem echo TAOS_LOG: %TAOS_LOG% if %EXEC_OPTON% == start ( rm -rf %TAOS_LOG% echo start %TAOSD% -c %CFG_DIR% - start %TAOSD% -c %CFG_DIR% + mintty -h never %TAOSD% -c %CFG_DIR% set /a check_num=0 :check_online sleep 1 @@ -58,13 +59,25 @@ if %EXEC_OPTON% == stop ( rem echo wmic process where "name='taosd.exe' and CommandLine like '%%%NODE_NAME%%%'" list INSTANCE rem wmic process where "name='taosd.exe' and CommandLine like '%%%NODE_NAME%%%'" call terminate > NUL 2>&1 - for /f "tokens=1 skip=1" %%A in ( - 'wmic process where "name='taosd.exe' and CommandLine like '%%%NODE_NAME%%%'" get processId ' - ) do ( - rem echo taskkill /IM %%A - taskkill /IM %%A > NUL 2>&1 + for /f "tokens=2" %%A in ('wmic process where "name='taosd.exe' and CommandLine like '%%%NODE_NAME%%%'" get processId ^| xargs echo') do ( + for /f "tokens=1" %%B in ('ps ^| grep %%A') do ( + if "%EXEC_SIGNAL%" == "SIGKILL" ( + kill -9 %%B + ) else ( + kill -INT %%B + call :check_offline + ) + ) goto :finish ) ) +:finish +goto :eof -:finish \ No newline at end of file +:check_offline +sleep 1 +for /f "tokens=2" %%C in ('wmic process where "name='taosd.exe' and CommandLine like '%%%NODE_NAME%%%'" get processId ^| xargs echo') do ( + echo check taosd offline + goto :check_offline +) +goto :eof \ No newline at end of file diff --git a/tests/script/test-all.bat b/tests/script/test-all.bat index 1c698449c6..f771f8fcb6 100644 --- a/tests/script/test-all.bat +++ b/tests/script/test-all.bat @@ -62,7 +62,5 @@ goto :eof :CheckSkipCase set skipCase=false -if "%*" == "./test.sh -f tsim/query/scalarFunction.sim" ( set skipCase=true ) -if "%*" == "./test.sh -f tsim/stream/distributeInterval0.sim" ( set skipCase=true ) -if "%*" == "./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim" ( set skipCase=true ) +@REM if "%*" == "./test.sh -f tsim/query/scalarFunction.sim" ( set skipCase=true ) :goto eof \ No newline at end of file diff --git a/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim b/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim index 78bca45f31..20eac3836c 100644 --- a/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim +++ b/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim @@ -124,7 +124,7 @@ if $data(5)[3] != 3 then return -1 endi -#sql reset query cache +sql reset query cache print =============== step4: select data sql show d1.tables diff --git a/tests/script/tsim/tmq/basic2Of2ConsOverlap.sim b/tests/script/tsim/tmq/basic2Of2ConsOverlap.sim index 480cf520d9..d796d00f03 100644 --- a/tests/script/tsim/tmq/basic2Of2ConsOverlap.sim +++ b/tests/script/tsim/tmq/basic2Of2ConsOverlap.sim @@ -134,6 +134,8 @@ endi $totalMsgCons = $totalMsgOfOneTopic + $totalMsgOfStb $sumOfMsgCnt = $data[0][2] + $data[1][2] if $sumOfMsgCnt != $totalMsgCons then + print total: $totalMsgCons + print sum: $sumOfMsgCnt return -1 endi diff --git a/tests/system-test/2-query/json_tag.py b/tests/system-test/2-query/json_tag.py index 9b96b6ebd0..53dfc57458 100644 --- a/tests/system-test/2-query/json_tag.py +++ b/tests/system-test/2-query/json_tag.py @@ -199,7 +199,7 @@ class TDTestCase: tdSql.checkData(0, 0, "true") # test select json tag->'key', value is null tdSql.query("select jtag->'tag1' from jsons1_4") - tdSql.checkData(0, 0, "null") + tdSql.checkData(0, 0, None) # test select json tag->'key', value is double tdSql.query("select jtag->'tag1' from jsons1_5") tdSql.checkData(0, 0, "1.232000000") @@ -562,7 +562,7 @@ class TDTestCase: tdSql.checkRows(3) tdSql.query("select round(dataint) from jsons1 where jtag->'tag1'>1") tdSql.checkRows(3) - + #math function tdSql.query("select sin(dataint) from jsons1 where jtag->'tag1'>1;") tdSql.checkRows(3) @@ -606,7 +606,7 @@ class TDTestCase: tdSql.checkRows(1) tdSql.query("select twa(dataint) from jsons1 where jtag->'tag1'>1;") tdSql.checkRows(1) - + # function not ready # tdSql.query("select tail(dataint,1) from jsons1 where jtag->'tag1'>1;") # tdSql.checkRows(3) @@ -616,7 +616,7 @@ class TDTestCase: # tdSql.checkRows(3) # tdSql.query("select irate(dataint) from jsons1 where jtag->'tag1'>1;") # tdSql.checkRows(1) - + #str function tdSql.query("select upper(dataStr) from jsons1 where jtag->'tag1'>1;") tdSql.checkRows(3) @@ -658,7 +658,7 @@ class TDTestCase: tdSql.checkRows(3) tdSql.query("select ELAPSED(ts,1h) from jsons1 where jtag->'tag1'>1;") tdSql.checkRows(1) - + # # #test TD-12077 tdSql.execute("insert into jsons1_16 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":-2.111}') values(1591062628000, 2, NULL, '你就会', 'dws')") diff --git a/tests/system-test/2-query/stateduration.py b/tests/system-test/2-query/stateduration.py index fa71009ef2..23169553dc 100644 --- a/tests/system-test/2-query/stateduration.py +++ b/tests/system-test/2-query/stateduration.py @@ -38,15 +38,15 @@ class TDTestCase: tdSql.query(f"select stateduration(col{i},'{j}',5) from test") tdSql.checkRows(10) if j in ['LT' ,'lt','Lt','lT']: - tdSql.checkEqual(tdSql.queryResult,[(0,), (0,), (0,), (0,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,)]) + tdSql.checkEqual(tdSql.queryResult,[(0,), (1,), (2,), (3,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,)]) elif j in ['GT','gt', 'Gt','gT']: - tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (-1,), (0,), (0,), (0,), (0,), (0,)]) + tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (-1,), (0,), (1,), (2,), (3,), (4,)]) elif j in ['LE','le','Le','lE']: - tdSql.checkEqual(tdSql.queryResult,[(0,), (0,), (0,), (0,), (0,), (-1,), (-1,), (-1,), (-1,), (-1,)]) + tdSql.checkEqual(tdSql.queryResult,[(0,), (1,), (2,), (3,), (4,), (-1,), (-1,), (-1,), (-1,), (-1,)]) elif j in [ 'GE','ge','Ge','gE']: - tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (0,), (0,), (0,), (0,), (0,), (0,)]) + tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (0,), (1,), (2,), (3,), (4,), (5,)]) elif j in ['NE','ne','Ne','nE']: - tdSql.checkEqual(tdSql.queryResult,[(0,), (0,), (0,), (0,), (-1,), (0,), (0,), (0,), (0,), (0,)]) + tdSql.checkEqual(tdSql.queryResult,[(0,), (1,), (2,), (3,), (-1,), (0,), (1,), (2,), (3,), (4,)]) elif j in ['EQ','eq','Eq','eQ']: tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (0,), (-1,), (-1,), (-1,), (-1,), (-1,)]) for i in float_list: @@ -54,11 +54,11 @@ class TDTestCase: tdSql.query(f"select stateduration(col{i},'{j}',5) from test") tdSql.checkRows(10) if j in ['LT','lt','Lt','lT','LE','le','Le','lE']: - tdSql.checkEqual(tdSql.queryResult,[(0,), (0,), (0,), (0,), (0,), (-1,), (-1,), (-1,), (-1,), (-1,)]) + tdSql.checkEqual(tdSql.queryResult,[(0,), (1,), (2,), (3,), (4,), (-1,), (-1,), (-1,), (-1,), (-1,)]) elif j in ['GE','ge','Ge','gE','GT','gt','Gt','gT']: - tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (-1,), (0,), (0,), (0,), (0,), (0,)]) + tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (-1,), (0,), (1,), (2,), (3,), (4,)]) elif j in ['NE','ne','Ne','nE']: - tdSql.checkEqual(tdSql.queryResult,[(0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,)]) + tdSql.checkEqual(tdSql.queryResult,[(0,), (1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,)]) elif j in ['EQ','eq','Eq','eQ']: tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,)]) @@ -66,34 +66,34 @@ class TDTestCase: for i in error_column_list: for j in self.param_list: tdSql.error(f"select stateduration({i},{j},5) from test") - + error_param_list = ['a',1] for i in error_param_list: tdSql.error(f"select stateduration(col1,{i},5) from test") - + # timestamp = 1s, time_unit =1s tdSql.execute('''create table test1(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)''') for i in range(self.row_num): tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" % (self.ts + i*1000, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) - + for i in integer_list: for j in self.param_list: tdSql.query(f"select stateduration(col{i},'{j}',5) from test1") tdSql.checkRows(10) # print(tdSql.queryResult) if j in ['LT' ,'lt','Lt','lT']: - tdSql.checkEqual(tdSql.queryResult,[(0,), (1,), (2,), (3,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,)]) + tdSql.checkEqual(tdSql.queryResult,[(0,), (1000,), (2000,), (3000,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,)]) elif j in ['GT','gt', 'Gt','gT']: - tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (-1,), (0,), (1,), (2,), (3,), (4,)]) + tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (-1,), (0,), (1000,), (2000,), (3000,), (4000,)]) elif j in ['LE','le','Le','lE']: - tdSql.checkEqual(tdSql.queryResult,[(0,), (1,), (2,), (3,), (4,), (-1,), (-1,), (-1,), (-1,), (-1,)]) + tdSql.checkEqual(tdSql.queryResult,[(0,), (1000,), (2000,), (3000,), (4000,), (-1,), (-1,), (-1,), (-1,), (-1,)]) elif j in [ 'GE','ge','Ge','gE']: - tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (0,), (1,), (2,), (3,), (4,), (5,)]) + tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (0,), (1000,), (2000,), (3000,), (4000,), (5000,)]) elif j in ['NE','ne','Ne','nE']: - tdSql.checkEqual(tdSql.queryResult,[(0,), (1,), (2,), (3,), (-1,), (0,), (1,), (2,), (3,), (4,)]) - elif j in ['EQ','eq','Eq','eQ']: + tdSql.checkEqual(tdSql.queryResult,[(0,), (1000,), (2000,), (3000,), (-1,), (0,), (1000,), (2000,), (3000,), (4000,)]) + elif j in ['EQ','eq','Eq','eQ']: tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (0,), (-1,), (-1,), (-1,), (-1,), (-1,)]) for i in float_list: for j in self.param_list: @@ -101,22 +101,22 @@ class TDTestCase: tdSql.checkRows(10) print(tdSql.queryResult) if j in ['LT','lt','Lt','lT','LE','le','Le','lE']: - tdSql.checkEqual(tdSql.queryResult,[(0,), (1,), (2,), (3,), (4,), (-1,), (-1,), (-1,), (-1,), (-1,)]) + tdSql.checkEqual(tdSql.queryResult,[(0,), (1000,), (2000,), (3000,), (4000,), (-1,), (-1,), (-1,), (-1,), (-1,)]) elif j in ['GE','ge','Ge','gE','GT','gt','Gt','gT']: - tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (-1,), (0,), (1,), (2,), (3,), (4,)]) + tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (-1,), (0,), (1000,), (2000,), (3000,), (4000,)]) elif j in ['NE','ne','Ne','nE']: - tdSql.checkEqual(tdSql.queryResult,[(0,), (1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,)]) + tdSql.checkEqual(tdSql.queryResult,[(0,), (1000,), (2000,), (3000,), (4000,), (5000,), (6000,), (7000,), (8000,), (9000,)]) elif j in ['EQ','eq','Eq','eQ']: tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,)]) # timestamp = 1m, time_unit =1m - tdSql.execute('''create table test2(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + tdSql.execute('''create table test2(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)''') for i in range(self.row_num): - tdSql.execute("insert into test2 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + tdSql.execute("insert into test2 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" % (self.ts + i*1000*60, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) - + for i in integer_list: for j in self.param_list: tdSql.query(f"select stateduration(col{i},'{j}',5,1m) from test2") @@ -132,7 +132,7 @@ class TDTestCase: tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (0,), (1,), (2,), (3,), (4,), (5,)]) elif j in ['NE','ne','Ne','nE']: tdSql.checkEqual(tdSql.queryResult,[(0,), (1,), (2,), (3,), (-1,), (0,), (1,), (2,), (3,), (4,)]) - elif j in ['EQ','eq','Eq','eQ']: + elif j in ['EQ','eq','Eq','eQ']: tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (0,), (-1,), (-1,), (-1,), (-1,), (-1,)]) for i in float_list: for j in self.param_list: @@ -147,14 +147,14 @@ class TDTestCase: tdSql.checkEqual(tdSql.queryResult,[(0,), (1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,)]) elif j in ['EQ','eq','Eq','eQ']: tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,)]) - + # timestamp = 1h, time_unit =1h - tdSql.execute('''create table test3(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + tdSql.execute('''create table test3(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)''') for i in range(self.row_num): - tdSql.execute("insert into test3 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + tdSql.execute("insert into test3 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" % (self.ts + i*1000*60*60, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) - + for i in integer_list: for j in self.param_list: tdSql.query(f"select stateduration(col{i},'{j}',5,1h) from test3") @@ -170,7 +170,7 @@ class TDTestCase: tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (0,), (1,), (2,), (3,), (4,), (5,)]) elif j in ['NE','ne','Ne','nE']: tdSql.checkEqual(tdSql.queryResult,[(0,), (1,), (2,), (3,), (-1,), (0,), (1,), (2,), (3,), (4,)]) - elif j in ['EQ','eq','Eq','eQ']: + elif j in ['EQ','eq','Eq','eQ']: tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (0,), (-1,), (-1,), (-1,), (-1,), (-1,)]) for i in float_list: for j in self.param_list: @@ -202,7 +202,7 @@ class TDTestCase: tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (0,), (60,), (120,), (180,), (240,), (300,)]) elif j in ['NE','ne','Ne','nE']: tdSql.checkEqual(tdSql.queryResult,[(0,), (60,), (120,), (180,), (-1,), (0,), (60,), (120,), (180,), (240,)]) - elif j in ['EQ','eq','Eq','eQ']: + elif j in ['EQ','eq','Eq','eQ']: tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (0,), (-1,), (-1,), (-1,), (-1,), (-1,)]) for i in float_list: for j in self.param_list: @@ -219,13 +219,13 @@ class TDTestCase: tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,)]) # for stb - tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(t0 int)''') tdSql.execute('create table stb_1 using stb tags(1)') for i in range(self.row_num): - tdSql.execute("insert into stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + tdSql.execute("insert into stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" % (self.ts + i*1000*60*60, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) - + for i in integer_list: for j in self.param_list: tdSql.query(f"select stateduration(col{i},'{j}',5,1h) from stb") @@ -241,7 +241,7 @@ class TDTestCase: tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (0,), (1,), (2,), (3,), (4,), (5,)]) elif j in ['NE','ne','Ne','nE']: tdSql.checkEqual(tdSql.queryResult,[(0,), (1,), (2,), (3,), (-1,), (0,), (1,), (2,), (3,), (4,)]) - elif j in ['EQ','eq','Eq','eQ']: + elif j in ['EQ','eq','Eq','eQ']: tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (0,), (-1,), (-1,), (-1,), (-1,), (-1,)]) for i in float_list: for j in self.param_list: @@ -256,10 +256,10 @@ class TDTestCase: tdSql.checkEqual(tdSql.queryResult,[(0,), (1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,)]) elif j in ['EQ','eq','Eq','eQ']: tdSql.checkEqual(tdSql.queryResult,[(-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,), (-1,)]) - + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode2mnode.py b/tests/system-test/6-cluster/5dnode2mnode.py index e08e738be6..509e535f01 100644 --- a/tests/system-test/6-cluster/5dnode2mnode.py +++ b/tests/system-test/6-cluster/5dnode2mnode.py @@ -9,28 +9,22 @@ from util.sql import * from util.cases import * from util.dnodes import TDDnodes from util.dnodes import TDDnode +from util.cluster import * + import time import socket import subprocess +sys.path.append("./6-cluster") -class MyDnodes(TDDnodes): - def __init__(self ,dnodes_lists): - super(MyDnodes,self).__init__() - self.dnodes = dnodes_lists # dnode must be TDDnode instance - self.simDeployed = False - +from clusterCommonCreate import * +from clusterCommonCheck import * + class TDTestCase: - noConn = True - def init(self,conn ,logSql): tdLog.debug(f"start to excute {__file__}") - self.TDDnodes = None - self.depoly_cluster(5) - self.master_dnode = self.TDDnodes.dnodes[0] - self.host=self.master_dnode.cfgDict["fqdn"] - conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir) - tdSql.init(conn1.cursor()) - + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -41,90 +35,12 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files or "taosd.exe" in files): + if ("taosd" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] break return buildPath - - - def depoly_cluster(self ,dnodes_nums): - - testCluster = False - valgrind = 0 - hostname = socket.gethostname() - dnodes = [] - start_port = 6030 - start_port_sec = 6130 - - for num in range(1, dnodes_nums+1): - dnode = TDDnode(num) - dnode.addExtraCfg("firstEp", f"{hostname}:{start_port}") - dnode.addExtraCfg("fqdn", f"{hostname}") - dnode.addExtraCfg("serverPort", f"{start_port + (num-1)*100}") - dnode.addExtraCfg("monitorFqdn", hostname) - dnode.addExtraCfg("monitorPort", 7043) - dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}") - - dnodes.append(dnode) - - self.TDDnodes = MyDnodes(dnodes) - self.TDDnodes.init("") - self.TDDnodes.setTestCluster(testCluster) - self.TDDnodes.setValgrind(valgrind) - self.TDDnodes.stopAll() - for dnode in self.TDDnodes.dnodes: - self.TDDnodes.deploy(dnode.index,{}) - - for dnode in self.TDDnodes.dnodes: - self.TDDnodes.starttaosd(dnode.index) - - # create cluster - for dnode in self.TDDnodes.dnodes[1:]: - # print(dnode.cfgDict) - dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] - dnode_first_host = dnode.cfgDict["firstEp"].split(":")[0] - dnode_first_port = dnode.cfgDict["firstEp"].split(":")[-1] - cmd = f"{self.getBuildPath()}/build/bin/taos -h {dnode_first_host} -P {dnode_first_port} -s \"create dnode \\\"{dnode_id}\\\"\"" - print(cmd) - os.system(cmd) - - time.sleep(2) - tdLog.info(" create cluster done! ") - - def five_dnode_one_mnode(self): - tdSql.query("show dnodes;") - tdSql.checkData(0,1,'%s:6030'%self.host) - tdSql.checkData(4,1,'%s:6430'%self.host) - tdSql.checkData(0,4,'ready') - tdSql.checkData(4,4,'ready') - tdSql.query("show mnodes;") - tdSql.checkData(0,1,'%s:6030'%self.host) - tdSql.checkData(0,2,'leader') - tdSql.checkData(0,3,'ready') - - - tdSql.error("create mnode on dnode 1;") - tdSql.error("drop mnode on dnode 1;") - - tdSql.execute("drop database if exists db") - tdSql.execute("create database if not exists db replica 1 duration 300") - tdSql.execute("use db") - tdSql.execute( - '''create table stb1 - (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) - tags (t1 int) - ''' - ) - tdSql.execute( - ''' - create table t1 - (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) - ''' - ) - for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') def five_dnode_two_mnode(self): tdSql.query("show dnodes;") @@ -187,6 +103,34 @@ class TDTestCase: tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") print(tdSql.queryResult) + clusterComCheck.checkDnodes(5) + # restart all taosd + tdDnodes=cluster.dnodes + + # stop follower + tdLog.info("stop follower") + tdDnodes[1].stoptaosd() + if cluster.checkConnectStatus(0) : + print("cluster also work") + + # start follower + tdLog.info("start follower") + tdDnodes[1].starttaosd() + if clusterComCheck.checkMnodeStatus(2) : + print("both mnodes are ready") + + # stop leader + tdLog.info("stop leader") + tdDnodes[0].stoptaosd() + try: + cluster.checkConnectStatus(2) + tdLog.exit(" The election still succeeds when leader of both mnodes are killed ") + except Exception: + pass + tdLog.info("start leader") + tdDnodes[0].starttaosd() + if clusterComCheck.checkMnodeStatus(2) : + print("both mnodes are ready") # # fisrt drop follower of mnode # BUG @@ -229,8 +173,6 @@ class TDTestCase: def run(self): - print(self.master_dnode.cfgDict) - self.five_dnode_one_mnode() self.five_dnode_two_mnode() diff --git a/tests/system-test/6-cluster/5dnode3mnodeStop.py b/tests/system-test/6-cluster/5dnode3mnodeStop.py index 1b55176e1d..f932e5537e 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeStop.py +++ b/tests/system-test/6-cluster/5dnode3mnodeStop.py @@ -88,7 +88,7 @@ class TDTestCase: tdLog.info("Confirm the status of the dnode again") tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") - print(tdSql.queryResult) + # print(tdSql.queryResult) clusterComCheck.checkDnodes(dnodenumbers) # restart all taosd tdDnodes=cluster.dnodes @@ -108,18 +108,6 @@ class TDTestCase: tdDnodes[0].starttaosd() clusterComCheck.checkMnodeStatus(3) - tdLog.info("Take turns stopping all dnodes ") - # seperate vnode and mnode in different dnodes. - # create database and stable - stopcount =0 - while stopcount <= 2: - tdLog.info("first restart loop") - for i in range(dnodenumbers): - tdDnodes[i].stoptaosd() - tdDnodes[i].starttaosd() - stopcount+=1 - clusterComCheck.checkDnodes(dnodenumbers) - clusterComCheck.checkMnodeStatus(3) def run(self): # print(self.master_dnode.cfgDict) diff --git a/tests/system-test/6-cluster/5dnode3mnodeStopLoop.py b/tests/system-test/6-cluster/5dnode3mnodeStopLoop.py new file mode 100644 index 0000000000..e0c91e5ac4 --- /dev/null +++ b/tests/system-test/6-cluster/5dnode3mnodeStopLoop.py @@ -0,0 +1,118 @@ +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * +from test import tdDnodes +sys.path.append("./6-cluster") + +from clusterCommonCreate import * +from clusterCommonCheck import * +import time +import socket +import subprocess +from multiprocessing import Process + + +class TDTestCase: + + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def fiveDnodeThreeMnode(self,dnodenumbers,mnodeNums,restartNumber): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'db', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'replica': 1, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 1, + 'rowsPerTbl': 10000, + 'batchNum': 10, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 10, + 'showMsg': 1, + 'showRow': 1} + dnodenumbers=int(dnodenumbers) + mnodeNums=int(mnodeNums) + dbNumbers = int(dnodenumbers * restartNumber) + + tdLog.info("first check dnode and mnode") + tdSql.query("show dnodes;") + tdSql.checkData(0,1,'%s:6030'%self.host) + tdSql.checkData(4,1,'%s:6430'%self.host) + clusterComCheck.checkDnodes(dnodenumbers) + clusterComCheck.checkMnodeStatus(1) + + # fisr add three mnodes; + tdLog.info("fisr add three mnodes and check mnode status") + tdSql.execute("create mnode on dnode 2") + clusterComCheck.checkMnodeStatus(2) + tdSql.execute("create mnode on dnode 3") + clusterComCheck.checkMnodeStatus(3) + + # add some error operations and + tdLog.info("Confirm the status of the dnode again") + tdSql.error("create mnode on dnode 2") + tdSql.query("show dnodes;") + # print(tdSql.queryResult) + clusterComCheck.checkDnodes(dnodenumbers) + # restart all taosd + tdDnodes=cluster.dnodes + + tdLog.info("Take turns stopping all dnodes ") + # seperate vnode and mnode in different dnodes. + # create database and stable + stopcount =0 + while stopcount <= 2: + tdLog.info(" restart loop: %d"%stopcount ) + for i in range(dnodenumbers): + tdDnodes[i].stoptaosd() + tdDnodes[i].starttaosd() + stopcount+=1 + clusterComCheck.checkDnodes(dnodenumbers) + clusterComCheck.checkMnodeStatus(3) + + def run(self): + # print(self.master_dnode.cfgDict) + self.fiveDnodeThreeMnode(5,3,1) + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index b0b8aa7108..f6dfe95f45 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -23,7 +23,7 @@ python3 ./test.py -f 1-insert/alter_stable.py python3 ./test.py -f 1-insert/alter_table.py python3 ./test.py -f 1-insert/insertWithMoreVgroup.py python3 ./test.py -f 1-insert/table_comment.py -python3 ./test.py -f 1-insert/table_param_ttl.py +#python3 ./test.py -f 1-insert/table_param_ttl.py python3 ./test.py -f 2-query/between.py python3 ./test.py -f 2-query/distinct.py python3 ./test.py -f 2-query/varchar.py @@ -116,17 +116,18 @@ python3 ./test.py -f 2-query/function_null.py python3 ./test.py -f 2-query/queryQnode.py python3 ./test.py -f 6-cluster/5dnode1mnode.py -python3 ./test.py -f 6-cluster/5dnode2mnode.py +python3 ./test.py -f 6-cluster/5dnode2mnode.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -N 5 -M 3 +python3 ./test.py -f 6-cluster/5dnode3mnodeStopLoop.py -N 5 -M 3 # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py -N 5 -M 3 # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py -N 5 -M 3 -python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 5 -M 3 +# python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 5 -M 3 # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateStb.py -N 5 -M 3 # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py -N 5 -M 3 # python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py -N 5 -M 3 # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py # python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py -N 5 -python3 test.py -f 6-cluster/5dnode3mnodeStopConnect.py -N 5 -M 3 +# python3 test.py -f 6-cluster/5dnode3mnodeStopConnect.py -N 5 -M 3 python3 ./test.py -f 7-tmq/basic5.py diff --git a/tools/taos-tools b/tools/taos-tools index 28a49b447f..7105027650 160000 --- a/tools/taos-tools +++ b/tools/taos-tools @@ -1 +1 @@ -Subproject commit 28a49b447f71c4f014ebbac858b7215b897d57fd +Subproject commit 7105027650b51e701cfa1dac11b8fb42d447dd01 diff --git a/tools/taosadapter b/tools/taosadapter index c1dc11f3ca..c885e967e4 160000 --- a/tools/taosadapter +++ b/tools/taosadapter @@ -1 +1 @@ -Subproject commit c1dc11f3cae64adf31dbd9a954ef8372d1e8f671 +Subproject commit c885e967e490105999b84d009a15168728dfafaf