diff --git a/docs/en/12-taos-sql/06-select.md b/docs/en/12-taos-sql/06-select.md index a2e6bca46c..074fbfbc8d 100755 --- a/docs/en/12-taos-sql/06-select.md +++ b/docs/en/12-taos-sql/06-select.md @@ -24,7 +24,7 @@ SELECT [hints] [DISTINCT] [TAGS] select_list hints: /*+ [hint([hint_param_list])] [hint([hint_param_list])] */ hint: - BATCH_SCAN | NO_BATCH_SCAN | SORT_FOR_GROUP | PARA_TABLES_SORT + BATCH_SCAN | NO_BATCH_SCAN | SORT_FOR_GROUP | PARA_TABLES_SORT | PARTITION_FIRST | SMALLDATA_TS_SORT select_list: select_expr [, select_expr] ... @@ -94,6 +94,7 @@ The list of currently supported Hints is as follows: | SORT_FOR_GROUP| None | Use sort for partition, conflict with PARTITION_FIRST | With normal column in partition by list | | PARTITION_FIRST| None | Use Partition before aggregate, conflict with SORT_FOR_GROUP | With normal column in partition by list | | PARA_TABLES_SORT| None | When sorting the supertable rows by timestamp, No temporary disk space is used. When there are numerous tables, each with long rows, the corresponding algorithm associated with this prompt may consume a substantial amount of memory, potentially leading to an Out Of Memory (OOM) situation. | Sorting the supertable rows by timestamp | +| SMALLDATA_TS_SORT| None | When sorting the supertable rows by timestamp, if the length of query columns >= 256, and there are relatively few rows, this hint can improve performance. | Sorting the supertable rows by timestamp | For example: @@ -102,6 +103,7 @@ SELECT /*+ BATCH_SCAN() */ a.ts FROM stable1 a, stable2 b where a.tag0 = b.tag0 SELECT /*+ SORT_FOR_GROUP() */ count(*), c1 FROM stable1 PARTITION BY c1; SELECT /*+ PARTITION_FIRST() */ count(*), c1 FROM stable1 PARTITION BY c1; SELECT /*+ PARA_TABLES_SORT() */ * from stable1 order by ts; +SELECT /*+ SMALLDATA_TS_SORT() */ * from stable1 order by ts; ``` ## Lists diff --git a/docs/zh/07-develop/06-stream.md b/docs/zh/07-develop/06-stream.md index 4a5ebb96e8..a6c8b02772 100644 --- a/docs/zh/07-develop/06-stream.md +++ b/docs/zh/07-develop/06-stream.md @@ -8,7 +8,7 @@ title: 流式计算 TDengine 3.0 的流式计算引擎提供了实时处理写入的数据流的能力,使用 SQL 定义实时流变换,当数据被写入流的源表后,数据会被以定义的方式自动处理,并根据定义的触发模式向目的表推送结果。它提供了替代复杂流处理系统的轻量级解决方案,并能够在高吞吐的数据写入的情况下,提供毫秒级的计算结果延迟。 -流式计算可以包含数据过滤,标量函数计算(含UDF),以及窗口聚合(支持滑动窗口、会话窗口与状态窗口),可以以超级表、子表、普通表为源表,写入到目的超级表。在创建流时,目的超级表将被自动创建,随后新插入的数据会被流定义的方式处理并写入其中,通过 partition by 子句,可以以表名或标签划分 partition,不同的 partition 将写入到目的超级表的不同子表。 +流式计算可以包含数据过滤,标量函数计算(含UDF),以及窗口聚合(支持滑动窗口、会话窗口、状态窗口、事件窗口与计数窗口),可以以超级表、子表、普通表为源表,写入到目的超级表。在创建流时,目的超级表将被自动创建,随后新插入的数据会被流定义的方式处理并写入其中,通过 partition by 子句,可以以表名或标签划分 partition,不同的 partition 将写入到目的超级表的不同子表。 TDengine 的流式计算能够支持分布在多个 vnode 中的超级表聚合;还能够处理乱序数据的写入:它提供了 watermark 机制以度量容忍数据乱序的程度,并提供了 ignore expired 配置项以决定乱序数据的处理策略——丢弃或者重新计算。 diff --git a/docs/zh/12-taos-sql/06-select.md b/docs/zh/12-taos-sql/06-select.md index eec947ea23..573e854864 100755 --- a/docs/zh/12-taos-sql/06-select.md +++ b/docs/zh/12-taos-sql/06-select.md @@ -24,7 +24,7 @@ SELECT [hints] [DISTINCT] [TAGS] select_list hints: /*+ [hint([hint_param_list])] [hint([hint_param_list])] */ hint: - BATCH_SCAN | NO_BATCH_SCAN | SORT_FOR_GROUP | PARA_TABLES_SORT + BATCH_SCAN | NO_BATCH_SCAN | SORT_FOR_GROUP | PARTITION_FIRST | PARA_TABLES_SORT | SMALLDATA_TS_SORT select_list: select_expr [, select_expr] ... @@ -94,6 +94,8 @@ Hints 是用户控制单个语句查询优化的一种手段,当 Hint 不适 | SORT_FOR_GROUP| 无 | 采用sort方式进行分组, 与PARTITION_FIRST冲突 | partition by 列表有普通列时 | | PARTITION_FIRST| 无 | 在聚合之前使用PARTITION计算分组, 与SORT_FOR_GROUP冲突 | partition by 列表有普通列时 | | PARA_TABLES_SORT| 无 | 超级表的数据按时间戳排序时, 不使用临时磁盘空间, 只使用内存。当子表数量多, 行长比较大时候, 会使用大量内存, 可能发生OOM | 超级表的数据按时间戳排序时 | +| SMALLDATA_TS_SORT| 无 | 超级表的数据按时间戳排序时, 查询列长度大于等于256, 但是行数不多, 使用这个提示, 可以提高性能 | 超级表的数据按时间戳排序时 | + 举例: ```sql @@ -101,6 +103,7 @@ SELECT /*+ BATCH_SCAN() */ a.ts FROM stable1 a, stable2 b where a.tag0 = b.tag0 SELECT /*+ SORT_FOR_GROUP() */ count(*), c1 FROM stable1 PARTITION BY c1; SELECT /*+ PARTITION_FIRST() */ count(*), c1 FROM stable1 PARTITION BY c1; SELECT /*+ PARA_TABLES_SORT() */ * from stable1 order by ts; +SELECT /*+ SMALLDATA_TS_SORT() */ * from stable1 order by ts; ``` ## 列表 diff --git a/docs/zh/12-taos-sql/12-distinguished.md b/docs/zh/12-taos-sql/12-distinguished.md index 8ae3f900f4..f73919a970 100755 --- a/docs/zh/12-taos-sql/12-distinguished.md +++ b/docs/zh/12-taos-sql/12-distinguished.md @@ -49,6 +49,7 @@ window_clause: { | STATE_WINDOW(col) | INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [FILL(fill_mod_and_val)] | EVENT_WINDOW START WITH start_trigger_condition END WITH end_trigger_condition + | COUNT_WINDOW(count_val[, sliding_val]) } ``` @@ -180,6 +181,19 @@ select _wstart, _wend, count(*) from t event_window start with c1 > 0 end with c ![TDengine Database 事件窗口示意图](./event_window.webp) +### 计数窗口 + +计数窗口按固定的数据行数来划分窗口。默认将数据按时间戳排序,再按照count_val的值,将数据划分为多个窗口,然后做聚合计算。count_val表示每个count window包含的最大数据行数,总数据行数不能整除count_val时,最后一个窗口的行数会小于count_val。sliding_val是常量,表示窗口滑动的数量,类似于 interval的SLIDING。 + +以下面的 SQL 语句为例,计数窗口切分如图所示: +```sql +select _wstart, _wend, count(*) from t count_window(4); +``` + +![count_window](https://github.com/taosdata/TDengine/assets/38781207/ff86278e-cbff-477f-a866-6e5cc150b712) + + + ### 时间戳伪列 窗口聚合查询结果中,如果 SQL 语句中没有指定输出查询结果中的时间戳列,那么最终结果中不会自动包含窗口的时间列信息。如果需要在结果中输出聚合结果所对应的时间窗口信息,需要在 SELECT 子句中使用时间戳相关的伪列: 时间窗口起始时间 (\_WSTART), 时间窗口结束时间 (\_WEND), 时间窗口持续时间 (\_WDURATION), 以及查询整体窗口相关的伪列: 查询窗口起始时间(\_QSTART) 和查询窗口结束时间(\_QEND)。需要注意的是时间窗口起始时间和结束时间均是闭区间,时间窗口持续时间是数据当前时间分辨率下的数值。例如,如果当前数据库的时间分辨率是毫秒,那么结果中 500 就表示当前时间窗口的持续时间是 500毫秒 (500 ms)。 diff --git a/docs/zh/12-taos-sql/14-stream.md b/docs/zh/12-taos-sql/14-stream.md index 8868b728f8..2ed3c9afae 100644 --- a/docs/zh/12-taos-sql/14-stream.md +++ b/docs/zh/12-taos-sql/14-stream.md @@ -30,7 +30,7 @@ subquery: SELECT select_list [window_clause] ``` -支持会话窗口、状态窗口与滑动窗口,其中,会话窗口与状态窗口搭配超级表时必须与partition by tbname一起使用 +支持会话窗口、状态窗口、滑动窗口、事件窗口和计数窗口,其中,状态窗口、事件窗口和计数窗口搭配超级表时必须与partition by tbname一起使用 stb_name 是保存计算结果的超级表的表名,如果该超级表不存在,会自动创建;如果已存在,则检查列的schema信息。详见 写入已存在的超级表 @@ -60,7 +60,11 @@ COUNT_WINDOW 是计数窗口,按固定的数据行数来划分窗口。 count_va 窗口的定义与时序数据特色查询中的定义完全相同,详见 [TDengine 特色查询](../distinguished) -例如,如下语句创建流式计算,同时自动创建名为 avg_vol 的超级表,此流计算以一分钟为时间窗口、30 秒为前向增量统计这些电表的平均电压,并将来自 meters 表的数据的计算结果写入 avg_vol 表,不同 partition 的数据会分别创建子表并写入不同子表。 +例如,如下语句创建流式计算。第一个流计算,自动创建名为 avg_vol 的超级表,以一分钟为时间窗口、30 秒为前向增量统计这些电表的平均电压,并将来自 meters 表的数据的计算结果写入 avg_vol 表,不同 partition 的数据会分别创建子表并写入不同子表。 + +第二个流计算,自动创建名为 streamt0 的超级表,将数据按时间戳的顺序,以 voltage < 0 作为窗口的开始条件,voltage > 9作为窗口的结束条件,划分窗口做聚合运算,并将来自 meters 表的数据的计算结果写入 streamt0 表,不同 partition 的数据会分别创建子表并写入不同子表。 + +第三个流计算,自动创建名为 streamt1 的超级表,将数据按时间戳的顺序,以10条数据为一组,划分窗口做聚合运算,并将来自 meters 表的数据的计算结果写入 streamt1 表,不同 partition 的数据会分别创建子表并写入不同子表。 ```sql CREATE STREAM avg_vol_s INTO avg_vol AS diff --git a/include/common/tmsg.h b/include/common/tmsg.h index db2c51fb01..16a72fbd2c 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -2820,8 +2820,10 @@ typedef struct { char* tagName; int8_t isNull; int8_t tagType; + int8_t tagFree; uint32_t nTagVal; uint8_t* pTagVal; + SArray* pTagArray; // TSDB_ALTER_TABLE_UPDATE_OPTIONS int8_t updateTTL; int32_t newTTL; @@ -3919,11 +3921,11 @@ int32_t tSerializeSMqAskEpReq(void* buf, int32_t bufLen, SMqAskEpReq* pReq); int32_t tDeserializeSMqAskEpReq(void* buf, int32_t bufLen, SMqAskEpReq* pReq); int32_t tSerializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq); int32_t tDeserializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq); -int32_t tDeatroySMqHbReq(SMqHbReq* pReq); +void tDestroySMqHbReq(SMqHbReq* pReq); int32_t tSerializeSMqHbRsp(void* buf, int32_t bufLen, SMqHbRsp* pRsp); int32_t tDeserializeSMqHbRsp(void* buf, int32_t bufLen, SMqHbRsp* pRsp); -int32_t tDeatroySMqHbRsp(SMqHbRsp* pRsp); +void tDestroySMqHbRsp(SMqHbRsp* pRsp); int32_t tSerializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq); int32_t tDeserializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq); diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 8f89857d33..45e79ddcf6 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -250,137 +250,139 @@ #define TK_SPLIT 231 #define TK_DELETE 232 #define TK_INSERT 233 -#define TK_NULL 234 -#define TK_NK_QUESTION 235 -#define TK_NK_ALIAS 236 -#define TK_NK_ARROW 237 -#define TK_ROWTS 238 -#define TK_QSTART 239 -#define TK_QEND 240 -#define TK_QDURATION 241 -#define TK_WSTART 242 -#define TK_WEND 243 -#define TK_WDURATION 244 -#define TK_IROWTS 245 -#define TK_ISFILLED 246 -#define TK_CAST 247 -#define TK_NOW 248 -#define TK_TODAY 249 -#define TK_TIMEZONE 250 -#define TK_CLIENT_VERSION 251 -#define TK_SERVER_VERSION 252 -#define TK_SERVER_STATUS 253 -#define TK_CURRENT_USER 254 -#define TK_CASE 255 -#define TK_WHEN 256 -#define TK_THEN 257 -#define TK_ELSE 258 -#define TK_BETWEEN 259 -#define TK_IS 260 -#define TK_NK_LT 261 -#define TK_NK_GT 262 -#define TK_NK_LE 263 -#define TK_NK_GE 264 -#define TK_NK_NE 265 -#define TK_MATCH 266 -#define TK_NMATCH 267 -#define TK_CONTAINS 268 -#define TK_IN 269 -#define TK_JOIN 270 -#define TK_INNER 271 -#define TK_SELECT 272 -#define TK_NK_HINT 273 -#define TK_DISTINCT 274 -#define TK_WHERE 275 -#define TK_PARTITION 276 -#define TK_BY 277 -#define TK_SESSION 278 -#define TK_STATE_WINDOW 279 -#define TK_EVENT_WINDOW 280 -#define TK_COUNT_WINDOW 281 -#define TK_SLIDING 282 -#define TK_FILL 283 -#define TK_VALUE 284 -#define TK_VALUE_F 285 -#define TK_NONE 286 -#define TK_PREV 287 -#define TK_NULL_F 288 -#define TK_LINEAR 289 -#define TK_NEXT 290 -#define TK_HAVING 291 -#define TK_RANGE 292 -#define TK_EVERY 293 -#define TK_ORDER 294 -#define TK_SLIMIT 295 -#define TK_SOFFSET 296 -#define TK_LIMIT 297 -#define TK_OFFSET 298 -#define TK_ASC 299 -#define TK_NULLS 300 -#define TK_ABORT 301 -#define TK_AFTER 302 -#define TK_ATTACH 303 -#define TK_BEFORE 304 -#define TK_BEGIN 305 -#define TK_BITAND 306 -#define TK_BITNOT 307 -#define TK_BITOR 308 -#define TK_BLOCKS 309 -#define TK_CHANGE 310 -#define TK_COMMA 311 -#define TK_CONCAT 312 -#define TK_CONFLICT 313 -#define TK_COPY 314 -#define TK_DEFERRED 315 -#define TK_DELIMITERS 316 -#define TK_DETACH 317 -#define TK_DIVIDE 318 -#define TK_DOT 319 -#define TK_EACH 320 -#define TK_FAIL 321 -#define TK_FILE 322 -#define TK_FOR 323 -#define TK_GLOB 324 -#define TK_ID 325 -#define TK_IMMEDIATE 326 -#define TK_IMPORT 327 -#define TK_INITIALLY 328 -#define TK_INSTEAD 329 -#define TK_ISNULL 330 -#define TK_KEY 331 -#define TK_MODULES 332 -#define TK_NK_BITNOT 333 -#define TK_NK_SEMI 334 -#define TK_NOTNULL 335 -#define TK_OF 336 -#define TK_PLUS 337 -#define TK_PRIVILEGE 338 -#define TK_RAISE 339 -#define TK_RESTRICT 340 -#define TK_ROW 341 -#define TK_SEMI 342 -#define TK_STAR 343 -#define TK_STATEMENT 344 -#define TK_STRICT 345 -#define TK_STRING 346 -#define TK_TIMES 347 -#define TK_VALUES 348 -#define TK_VARIABLE 349 -#define TK_WAL 350 +#define TK_NK_BIN 234 +#define TK_NK_HEX 235 +#define TK_NULL 236 +#define TK_NK_QUESTION 237 +#define TK_NK_ALIAS 238 +#define TK_NK_ARROW 239 +#define TK_ROWTS 240 +#define TK_QSTART 241 +#define TK_QEND 242 +#define TK_QDURATION 243 +#define TK_WSTART 244 +#define TK_WEND 245 +#define TK_WDURATION 246 +#define TK_IROWTS 247 +#define TK_ISFILLED 248 +#define TK_CAST 249 +#define TK_NOW 250 +#define TK_TODAY 251 +#define TK_TIMEZONE 252 +#define TK_CLIENT_VERSION 253 +#define TK_SERVER_VERSION 254 +#define TK_SERVER_STATUS 255 +#define TK_CURRENT_USER 256 +#define TK_CASE 257 +#define TK_WHEN 258 +#define TK_THEN 259 +#define TK_ELSE 260 +#define TK_BETWEEN 261 +#define TK_IS 262 +#define TK_NK_LT 263 +#define TK_NK_GT 264 +#define TK_NK_LE 265 +#define TK_NK_GE 266 +#define TK_NK_NE 267 +#define TK_MATCH 268 +#define TK_NMATCH 269 +#define TK_CONTAINS 270 +#define TK_IN 271 +#define TK_JOIN 272 +#define TK_INNER 273 +#define TK_SELECT 274 +#define TK_NK_HINT 275 +#define TK_DISTINCT 276 +#define TK_WHERE 277 +#define TK_PARTITION 278 +#define TK_BY 279 +#define TK_SESSION 280 +#define TK_STATE_WINDOW 281 +#define TK_EVENT_WINDOW 282 +#define TK_COUNT_WINDOW 283 +#define TK_SLIDING 284 +#define TK_FILL 285 +#define TK_VALUE 286 +#define TK_VALUE_F 287 +#define TK_NONE 288 +#define TK_PREV 289 +#define TK_NULL_F 290 +#define TK_LINEAR 291 +#define TK_NEXT 292 +#define TK_HAVING 293 +#define TK_RANGE 294 +#define TK_EVERY 295 +#define TK_ORDER 296 +#define TK_SLIMIT 297 +#define TK_SOFFSET 298 +#define TK_LIMIT 299 +#define TK_OFFSET 300 +#define TK_ASC 301 +#define TK_NULLS 302 +#define TK_ABORT 303 +#define TK_AFTER 304 +#define TK_ATTACH 305 +#define TK_BEFORE 306 +#define TK_BEGIN 307 +#define TK_BITAND 308 +#define TK_BITNOT 309 +#define TK_BITOR 310 +#define TK_BLOCKS 311 +#define TK_CHANGE 312 +#define TK_COMMA 313 +#define TK_CONCAT 314 +#define TK_CONFLICT 315 +#define TK_COPY 316 +#define TK_DEFERRED 317 +#define TK_DELIMITERS 318 +#define TK_DETACH 319 +#define TK_DIVIDE 320 +#define TK_DOT 321 +#define TK_EACH 322 +#define TK_FAIL 323 +#define TK_FILE 324 +#define TK_FOR 325 +#define TK_GLOB 326 +#define TK_ID 327 +#define TK_IMMEDIATE 328 +#define TK_IMPORT 329 +#define TK_INITIALLY 330 +#define TK_INSTEAD 331 +#define TK_ISNULL 332 +#define TK_KEY 333 +#define TK_MODULES 334 +#define TK_NK_BITNOT 335 +#define TK_NK_SEMI 336 +#define TK_NOTNULL 337 +#define TK_OF 338 +#define TK_PLUS 339 +#define TK_PRIVILEGE 340 +#define TK_RAISE 341 +#define TK_RESTRICT 342 +#define TK_ROW 343 +#define TK_SEMI 344 +#define TK_STAR 345 +#define TK_STATEMENT 346 +#define TK_STRICT 347 +#define TK_STRING 348 +#define TK_TIMES 349 +#define TK_VALUES 350 +#define TK_VARIABLE 351 +#define TK_WAL 352 #define TK_NK_SPACE 600 #define TK_NK_COMMENT 601 #define TK_NK_ILLEGAL 602 -#define TK_NK_HEX 603 // hex number 0x123 +// #define TK_NK_HEX 603 // hex number 0x123 #define TK_NK_OCT 604 // oct number -#define TK_NK_BIN 605 // bin format data 0b111 +// #define TK_NK_BIN 605 // bin format data 0b111 #define TK_BATCH_SCAN 606 #define TK_NO_BATCH_SCAN 607 #define TK_SORT_FOR_GROUP 608 #define TK_PARTITION_FIRST 609 #define TK_PARA_TABLES_SORT 610 - +#define TK_SMALLDATA_TS_SORT 611 #define TK_NK_NIL 65535 diff --git a/include/common/tvariant.h b/include/common/tvariant.h index 66b7302f4e..6f88eba027 100644 --- a/include/common/tvariant.h +++ b/include/common/tvariant.h @@ -44,6 +44,11 @@ int32_t toDoubleEx(const char *z, int32_t n, uint32_t type, double *value); int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value); int32_t toUInteger(const char *z, int32_t n, int32_t base, uint64_t *value); +/** + * non floating point integers +*/ +int32_t toIntegerPure(const char *z, int32_t n, int32_t base, int64_t *value); + void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32_t type); void taosVariantDestroy(SVariant *pV); diff --git a/include/libs/executor/storageapi.h b/include/libs/executor/storageapi.h index 37b34ef26f..04bc839d51 100644 --- a/include/libs/executor/storageapi.h +++ b/include/libs/executor/storageapi.h @@ -224,10 +224,10 @@ typedef struct SStoreTqReader { bool (*tqReaderCurrentBlockConsumed)(); struct SWalReader* (*tqReaderGetWalReader)(); // todo remove it - int32_t (*tqReaderRetrieveTaosXBlock)(); // todo remove it +// int32_t (*tqReaderRetrieveTaosXBlock)(); // todo remove it int32_t (*tqReaderSetSubmitMsg)(); // todo remove it - bool (*tqReaderNextBlockFilterOut)(); +// bool (*tqReaderNextBlockFilterOut)(); } SStoreTqReader; typedef struct SStoreSnapshotFn { diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 0bc3ce04ef..cbf38102de 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -122,6 +122,7 @@ typedef struct SScanLogicNode { bool isCountByTag; // true if selectstmt hasCountFunc & part by tag/tbname SArray* pFuncTypes; // for last, last_row bool paraTablesSort; // for table merge scan + bool smallDataTsSort; // disable row id sort for table merge scan } SScanLogicNode; typedef struct SJoinLogicNode { @@ -445,6 +446,7 @@ typedef struct STableScanPhysiNode { bool filesetDelimited; bool needCountEmptyTable; bool paraTablesSort; + bool smallDataTsSort; } STableScanPhysiNode; typedef STableScanPhysiNode STableSeqScanPhysiNode; diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 7ceb7e0278..97ac4ff3b9 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -128,7 +128,8 @@ typedef enum EHintOption { HINT_BATCH_SCAN, HINT_SORT_FOR_GROUP, HINT_PARTITION_FIRST, - HINT_PARA_TABLES_SORT + HINT_PARA_TABLES_SORT, + HINT_SMALLDATA_TS_SORT, } EHintOption; typedef struct SHintNode { diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index e7b0b25653..460b8962ea 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -62,6 +62,7 @@ typedef struct SRpcHandleInfo { SRpcConnInfo conn; int8_t forbiddenIp; + int8_t notFreeAhandle; } SRpcHandleInfo; diff --git a/include/os/osFile.h b/include/os/osFile.h index eb0862a719..9c9027e931 100644 --- a/include/os/osFile.h +++ b/include/os/osFile.h @@ -119,6 +119,13 @@ int32_t taosSetFileHandlesLimit(); int32_t taosLinkFile(char *src, char *dst); +FILE* taosOpenCFile(const char* filename, const char* mode); +int taosSeekCFile(FILE* file, int64_t offset, int whence); +size_t taosReadFromCFile(void *buffer, size_t size, size_t count, FILE *stream ); +size_t taosWriteToCFile(const void* ptr, size_t size, size_t nitems, FILE* stream); +int taosCloseCFile(FILE *); +int taosSetAutoDelFile(char* path); + bool lastErrorIsFileNotExist(); #ifdef __cplusplus diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 6650d4c8b3..6c3603b4e0 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -298,8 +298,7 @@ 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); +int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4); int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows, bool convertUcs4); void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 94da1e1998..e87e676f08 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -302,7 +302,7 @@ int32_t execLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { int8_t biMode = atomic_load_8(&pRequest->pTscObj->biMode); int32_t code = qExecCommand(&pRequest->pTscObj->id, pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp, biMode); if (TSDB_CODE_SUCCESS == code && NULL != pRsp) { - code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false, true); + code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false); } return code; @@ -341,7 +341,7 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { int32_t code = qExecCommand(&pRequest->pTscObj->id, pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp, atomic_load_8(&pRequest->pTscObj->biMode)); if (TSDB_CODE_SUCCESS == code && NULL != pRsp) { - code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false, true); + code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false); } SReqResultInfo* pResultInfo = &pRequest->body.resInfo; @@ -1721,7 +1721,7 @@ void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4) } pRequest->code = - setQueryResultFromRsp(&pRequest->body.resInfo, (const SRetrieveTableRsp*)pResInfo->pData, convertUcs4, true); + setQueryResultFromRsp(&pRequest->body.resInfo, (const SRetrieveTableRsp*)pResInfo->pData, convertUcs4); if (pRequest->code != TSDB_CODE_SUCCESS) { pResultInfo->numOfRows = 0; return NULL; @@ -2180,15 +2180,13 @@ void resetConnectDB(STscObj* pTscObj) { taosThreadMutexUnlock(&pTscObj->mutex); } -int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4, - bool freeAfterUse) { +int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4) { if (pResultInfo == NULL || pRsp == NULL) { tscError("setQueryResultFromRsp paras is null"); return TSDB_CODE_TSC_INTERNAL_ERROR; } - if (freeAfterUse) taosMemoryFreeClear(pResultInfo->pRspMsg); - + taosMemoryFreeClear(pResultInfo->pRspMsg); pResultInfo->pRspMsg = (const char*)pRsp; pResultInfo->pData = (void*)pRsp->data; pResultInfo->numOfRows = htobe64(pRsp->numOfRows); @@ -2618,7 +2616,7 @@ static void fetchCallback(void* pResult, void* param, int32_t code) { } pRequest->code = - setQueryResultFromRsp(pResultInfo, (const SRetrieveTableRsp*)pResultInfo->pData, pResultInfo->convertUcs4, true); + setQueryResultFromRsp(pResultInfo, (const SRetrieveTableRsp*)pResultInfo->pData, pResultInfo->convertUcs4); if (pRequest->code != TSDB_CODE_SUCCESS) { pResultInfo->numOfRows = 0; pRequest->code = code; diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 47adb40eaa..a49d2091ac 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -350,7 +350,6 @@ void taos_free_result(TAOS_RES *res) { taosArrayDestroy(pRsp->rsp.createTableLen); taosArrayDestroyP(pRsp->rsp.createTableReq, taosMemoryFree); - pRsp->resInfo.pRspMsg = NULL; doFreeReqResultInfo(&pRsp->resInfo); taosMemoryFree(pRsp); } else if (TD_RES_TMQ(res)) { @@ -359,7 +358,6 @@ void taos_free_result(TAOS_RES *res) { taosArrayDestroy(pRsp->rsp.blockDataLen); taosArrayDestroyP(pRsp->rsp.blockTbName, taosMemoryFree); taosArrayDestroyP(pRsp->rsp.blockSchema, (FDelete)tDeleteSchemaWrapper); - pRsp->resInfo.pRspMsg = NULL; doFreeReqResultInfo(&pRsp->resInfo); taosMemoryFree(pRsp); } else if (TD_RES_TMQ_META(res)) { diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 324b99022b..360a346fb7 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -538,7 +538,7 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) { code = buildShowVariablesRsp(rsp.variables, &pRes); } if (TSDB_CODE_SUCCESS == code) { - code = setQueryResultFromRsp(&pRequest->body.resInfo, pRes, false, true); + code = setQueryResultFromRsp(&pRequest->body.resInfo, pRes, false); } if (code != 0) { @@ -651,7 +651,7 @@ int32_t processCompactDbRsp(void* param, SDataBuf* pMsg, int32_t code) { code = buildRetriveTableRspForCompactDb(&rsp, &pRes); } if (TSDB_CODE_SUCCESS == code) { - code = setQueryResultFromRsp(&pRequest->body.resInfo, pRes, false, true); + code = setQueryResultFromRsp(&pRequest->body.resInfo, pRes, false); } if (code != 0) { diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index 0270ae9657..c8fc556150 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -779,7 +779,7 @@ int32_t tmqHbCb(void* param, SDataBuf* pMsg, int32_t code) { taosWUnLockLatch(&tmq->lock); taosReleaseRef(tmqMgmt.rsetId, refId); } - tDeatroySMqHbRsp(&rsp); + tDestroySMqHbRsp(&rsp); taosMemoryFree(pMsg->pData); taosMemoryFree(pMsg->pEpSet); } @@ -861,7 +861,7 @@ void tmqSendHbReq(void* param, void* tmrId) { asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); OVER: - tDeatroySMqHbReq(&req); + tDestroySMqHbReq(&req); taosTmrReset(tmqSendHbReq, DEFAULT_HEARTBEAT_INTERVAL, param, tmqMgmt.timer, &tmq->hbLiveTimer); taosReleaseRef(tmqMgmt.rsetId, refId); } @@ -2628,13 +2628,9 @@ SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4) { SRetrieveTableRspForTmq* pRetrieveTmq = (SRetrieveTableRspForTmq*)taosArrayGetP(pRspObj->rsp.blockData, pRspObj->resIter); if (pRspObj->rsp.withSchema) { + doFreeReqResultInfo(&pRspObj->resInfo); SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(pRspObj->rsp.blockSchema, pRspObj->resIter); setResSchemaInfo(&pRspObj->resInfo, pSW->pSchema, pSW->nCols); - taosMemoryFreeClear(pRspObj->resInfo.row); - taosMemoryFreeClear(pRspObj->resInfo.pCol); - taosMemoryFreeClear(pRspObj->resInfo.length); - taosMemoryFreeClear(pRspObj->resInfo.convertBuf); - taosMemoryFreeClear(pRspObj->resInfo.convertJson); } pRspObj->resInfo.pData = (void*)pRetrieveTmq->data; diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index fde8313228..7a5a7d1afc 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -268,7 +268,7 @@ bool tsDisableStream = false; int64_t tsStreamBufferSize = 128 * 1024 * 1024; bool tsFilterScalarMode = false; int tsResolveFQDNRetryTime = 100; // seconds -int tsStreamAggCnt = 1000; +int tsStreamAggCnt = 100000; char tsS3Endpoint[TSDB_FQDN_LEN] = ""; char tsS3AccessKey[TSDB_FQDN_LEN] = ""; @@ -502,7 +502,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "maxRetryWaitTime", tsMaxRetryWaitTime, 0, 86400000, CFG_SCOPE_BOTH, CFG_DYN_CLIENT) != 0) return -1; if (cfgAddBool(pCfg, "useAdapter", tsUseAdapter, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) != 0) return -1; - if (cfgAddBool(pCfg, "crashReporting", tsEnableCrashReport, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) != 0) return -1; + if (cfgAddBool(pCfg, "crashReporting", tsEnableCrashReport, CFG_SCOPE_BOTH, CFG_DYN_CLIENT) != 0) return -1; if (cfgAddInt64(pCfg, "queryMaxConcurrentTables", tsQueryMaxConcurrentTables, INT64_MIN, INT64_MAX, CFG_SCOPE_CLIENT, CFG_DYN_NONE) != 0) return -1; @@ -538,8 +538,8 @@ static int32_t taosAddClientCfg(SConfig *pCfg) { return -1; if (cfgAddBool(pCfg, "experimental", tsExperimental, CFG_SCOPE_BOTH, CFG_DYN_BOTH) != 0) return -1; - if (cfgAddBool(pCfg, "monitor", tsEnableMonitor, CFG_SCOPE_SERVER, CFG_DYN_SERVER) != 0) return -1; - if (cfgAddInt32(pCfg, "monitorInterval", tsMonitorInterval, 1, 200000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1; + if (cfgAddBool(pCfg, "monitor", tsEnableMonitor, CFG_SCOPE_BOTH, CFG_DYN_BOTH) != 0) return -1; + if (cfgAddInt32(pCfg, "monitorInterval", tsMonitorInterval, 1, 200000, CFG_SCOPE_BOTH, CFG_DYN_NONE) != 0) return -1; return 0; } @@ -600,18 +600,6 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { return -1; if (cfgAddInt32(pCfg, "queryRspPolicy", tsQueryRspPolicy, 0, 1, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1; - tsNumOfRpcThreads = tsNumOfCores / 2; - tsNumOfRpcThreads = TRANGE(tsNumOfRpcThreads, 2, TSDB_MAX_RPC_THREADS); - if (cfgAddInt32(pCfg, "numOfRpcThreads", tsNumOfRpcThreads, 1, 1024, CFG_SCOPE_BOTH, CFG_DYN_NONE) != 0) return -1; - - tsNumOfRpcSessions = TRANGE(tsNumOfRpcSessions, 100, 10000); - if (cfgAddInt32(pCfg, "numOfRpcSessions", tsNumOfRpcSessions, 1, 100000, CFG_SCOPE_BOTH, CFG_DYN_NONE) != 0) - return -1; - - tsTimeToGetAvailableConn = TRANGE(tsTimeToGetAvailableConn, 20, 1000000); - if (cfgAddInt32(pCfg, "timeToGetAvailableConn", tsNumOfRpcSessions, 20, 1000000, CFG_SCOPE_BOTH, CFG_DYN_NONE) != 0) - return -1; - tsNumOfCommitThreads = tsNumOfCores / 2; tsNumOfCommitThreads = TRANGE(tsNumOfCommitThreads, 2, 4); if (cfgAddInt32(pCfg, "numOfCommitThreads", tsNumOfCommitThreads, 1, 1024, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) @@ -691,9 +679,6 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "grantMode", tsMndGrantMode, 0, 10000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1; if (cfgAddBool(pCfg, "skipGrant", tsMndSkipGrant, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1; - if (cfgAddBool(pCfg, "monitor", tsEnableMonitor, CFG_SCOPE_SERVER, CFG_DYN_SERVER) != 0) return -1; - if (cfgAddInt32(pCfg, "monitorInterval", tsMonitorInterval, 1, 200000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) - return -1; if (cfgAddString(pCfg, "monitorFqdn", tsMonitorFqdn, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1; if (cfgAddInt32(pCfg, "monitorPort", tsMonitorPort, 1, 65056, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1; if (cfgAddInt32(pCfg, "monitorMaxLogs", tsMonitorMaxLogs, 1, 1000000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1; @@ -707,7 +692,6 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddBool(pCfg, "auditCreateTable", tsEnableAuditCreateTable, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1; if (cfgAddInt32(pCfg, "auditInterval", tsAuditInterval, 500, 200000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1; - if (cfgAddBool(pCfg, "crashReporting", tsEnableCrashReport, CFG_SCOPE_BOTH, CFG_DYN_NONE) != 0) return -1; if (cfgAddBool(pCfg, "telemetryReporting", tsEnableTelem, CFG_SCOPE_BOTH, CFG_DYN_ENT_SERVER) != 0) return -1; if (cfgAddInt32(pCfg, "telemetryInterval", tsTelemInterval, 1, 200000, CFG_SCOPE_BOTH, CFG_DYN_NONE) != 0) return -1; if (cfgAddString(pCfg, "telemetryServer", tsTelemServer, CFG_SCOPE_BOTH, CFG_DYN_BOTH) != 0) return -1; @@ -814,8 +798,6 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { return -1; if (cfgAddBool(pCfg, "enableWhiteList", tsEnableWhiteList, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1; - if (cfgAddBool(pCfg, "experimental", tsExperimental, CFG_SCOPE_BOTH, CFG_DYN_BOTH) != 0) return -1; - // GRANT_CFG_ADD; return 0; } @@ -1353,6 +1335,7 @@ int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile if (taosAddClientLogCfg(tsCfg) != 0) return -1; if (taosAddServerLogCfg(tsCfg) != 0) return -1; } + taosAddSystemCfg(tsCfg); if (taosLoadCfg(tsCfg, envCmd, cfgDir, envFile, apolloUrl) != 0) { @@ -1379,7 +1362,9 @@ int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile if (taosSetTfsCfg(tsCfg) != 0) return -1; if (taosSetS3Cfg(tsCfg) != 0) return -1; } + taosSetSystemCfg(tsCfg); + if (taosSetFileHandlesLimit() != 0) return -1; taosSetAllDebugFlag(tsCfg, cfgGetItem(tsCfg, "debugFlag")->i32); @@ -1626,6 +1611,10 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, char *name) { tsLogSpace.reserved = (int64_t)(((double)pItem->fval) * 1024 * 1024 * 1024); uInfo("%s set to %" PRId64, name, tsLogSpace.reserved); matched = true; + } else if (strcasecmp("monitor", name) == 0) { + tsEnableMonitor = pItem->bval; + uInfo("%s set to %d", name, tsEnableMonitor); + matched = true; } break; } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 9138d7c983..5b154df8a3 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -6201,9 +6201,8 @@ int32_t tDeserializeSMqAskEpReq(void *buf, int32_t bufLen, SMqAskEpReq *pReq) { return 0; } -int32_t tDeatroySMqHbRsp(SMqHbRsp *pRsp) { +void tDestroySMqHbRsp(SMqHbRsp *pRsp) { taosArrayDestroy(pRsp->topicPrivileges); - return 0; } int32_t tSerializeSMqHbRsp(void *buf, int32_t bufLen, SMqHbRsp *pRsp) { @@ -6250,13 +6249,12 @@ int32_t tDeserializeSMqHbRsp(void *buf, int32_t bufLen, SMqHbRsp *pRsp) { return 0; } -int32_t tDeatroySMqHbReq(SMqHbReq *pReq) { +void tDestroySMqHbReq(SMqHbReq *pReq) { for (int i = 0; i < taosArrayGetSize(pReq->topics); i++) { TopicOffsetRows *vgs = taosArrayGet(pReq->topics, i); if (vgs) taosArrayDestroy(vgs->offsetRows); } taosArrayDestroy(pReq->topics); - return 0; } int32_t tSerializeSMqHbReq(void *buf, int32_t bufLen, SMqHbReq *pReq) { diff --git a/source/common/src/ttypes.c b/source/common/src/ttypes.c index 8827ddc811..57bc875fce 100644 --- a/source/common/src/ttypes.c +++ b/source/common/src/ttypes.c @@ -34,7 +34,7 @@ const int32_t TYPE_BYTES[21] = { INT_BYTES, // TSDB_DATA_TYPE_UINT sizeof(uint64_t), // TSDB_DATA_TYPE_UBIGINT TSDB_MAX_JSON_TAG_LEN, // TSDB_DATA_TYPE_JSON - TSDB_MAX_TAGS_LEN, // TSDB_DATA_TYPE_VARBINARY: placeholder, not implemented + sizeof(VarDataOffsetT), // TSDB_DATA_TYPE_VARBINARY TSDB_MAX_TAGS_LEN, // TSDB_DATA_TYPE_DECIMAL: placeholder, not implemented TSDB_MAX_TAGS_LEN, // TSDB_DATA_TYPE_BLOB: placeholder, not implemented TSDB_MAX_TAGS_LEN, // TSDB_DATA_TYPE_MEDIUMBLOB: placeholder, not implemented diff --git a/source/common/src/tvariant.c b/source/common/src/tvariant.c index dd5e8240b9..ae2c8c0c14 100644 --- a/source/common/src/tvariant.c +++ b/source/common/src/tvariant.c @@ -19,7 +19,7 @@ #include "ttokendef.h" #include "tvariant.h" -int32_t parseBinaryUInteger(const char *z, int32_t n, uint64_t *value) { +static int32_t parseBinaryUInteger(const char *z, int32_t n, uint64_t *value) { // skip head 0b const char *p = z + 2; int32_t l = n - 2; @@ -45,7 +45,7 @@ int32_t parseBinaryUInteger(const char *z, int32_t n, uint64_t *value) { return TSDB_CODE_SUCCESS; } -int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint64_t *value) { +static int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint64_t *value, bool parseFloat) { // parse sign bool has_sign = false; if (z[0] == '-') { @@ -65,8 +65,7 @@ int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint64_t *v } errno = 0; - char *endPtr = NULL; - bool parsed = false; + char *endPtr = NULL; if (z[0] == '0' && n > 2) { if (z[1] == 'b' || z[1] == 'B') { // paring as binary @@ -76,44 +75,87 @@ int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint64_t *v if (z[1] == 'x' || z[1] == 'X') { // parsing as hex *value = taosStr2UInt64(z, &endPtr, 16); - parsed = true; + if (errno == ERANGE || errno == EINVAL || endPtr - z != n) { + return TSDB_CODE_FAILED; + } + return TSDB_CODE_SUCCESS; } } - if (!parsed) { + if (parseFloat) { // parsing as double double val = taosStr2Double(z, &endPtr); + if (errno == ERANGE || errno == EINVAL || endPtr - z != n) { + return TSDB_CODE_FAILED; + } if (val > UINT64_MAX) { + errno = ERANGE; return TSDB_CODE_FAILED; } *value = round(val); - } - - if (errno == ERANGE || errno == EINVAL || endPtr - z != n) { - return TSDB_CODE_FAILED; - } - return TSDB_CODE_SUCCESS; -} - - -int32_t toDoubleEx(const char *z, int32_t n, uint32_t type, double* value) { - if (n == 0) { - *value = 0; return TSDB_CODE_SUCCESS; } + return TSDB_CODE_FAILED; +} + +int32_t toDoubleEx(const char *z, int32_t n, uint32_t type, double *value) { + if (n == 0) { + errno = EINVAL; + return TSDB_CODE_FAILED; + } + errno = 0; - char* endPtr = NULL; - *value = taosStr2Double(z, &endPtr); + char *endPtr = NULL; + *value = taosStr2Double(z, &endPtr); // 0x already converted here + if (errno == ERANGE || errno == EINVAL) return TSDB_CODE_FAILED; + if (endPtr - z == n) return TSDB_CODE_SUCCESS; - if (errno == ERANGE || errno == EINVAL) { - return TSDB_CODE_FAILED; + if (type == TK_NK_BIN || type == TK_NK_STRING) { + bool is_neg = false; + uint64_t uv = 0; + if (TSDB_CODE_SUCCESS == parseSignAndUInteger(z, n, &is_neg, &uv, false)) { + *value = is_neg ? -(double)uv : uv; + return TSDB_CODE_SUCCESS; + } } - if (endPtr - z != n) { - return TSDB_CODE_FAILED; + return TSDB_CODE_FAILED; +} + +int32_t toIntegerPure(const char *z, int32_t n, int32_t base, int64_t *value) { + errno = 0; + + char *endPtr = NULL; + *value = taosStr2Int64(z, &endPtr, base); + if (endPtr - z == n) { + if (errno == ERANGE || errno == EINVAL) { + return TSDB_CODE_FAILED; + } + return TSDB_CODE_SUCCESS; } - return TSDB_CODE_SUCCESS; + + bool is_neg = false; + uint64_t uv = 0; + int32_t code = parseSignAndUInteger(z, n, &is_neg, &uv, false); // support 0b/0x + if (code == TSDB_CODE_SUCCESS) { + if (is_neg) { + if (uv > 1ull + INT64_MAX) { + *value = INT64_MIN; + return TSDB_CODE_FAILED; + } else { + *value = -(int64_t)uv; + } + } else { + if (uv > INT64_MAX) { + *value = INT64_MAX; + return TSDB_CODE_FAILED; + } + *value = uv; + } + } + + return code; } int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) { @@ -144,8 +186,8 @@ int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) { } if (n == 0) { - *value = 0; - return TSDB_CODE_SUCCESS; + errno = EINVAL; + return TSDB_CODE_FAILED; } // 1. try to parse as integer @@ -190,7 +232,7 @@ int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) { // 2. parse as other bool is_neg = false; uint64_t uv = 0; - int32_t code = parseSignAndUInteger(z, n, &is_neg, &uv); + int32_t code = parseSignAndUInteger(z, n, &is_neg, &uv, true); if (code == TSDB_CODE_SUCCESS) { // truncate into int64 if (is_neg) { @@ -198,7 +240,7 @@ int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) { *value = INT64_MIN; return TSDB_CODE_FAILED; } else { - *value = -uv; + *value = -(int64_t)uv; } } else { if (uv > INT64_MAX) { @@ -216,9 +258,6 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) { errno = 0; char *endPtr = NULL; const char *p = z; - while (*p == ' ') { - p++; - } switch (type) { case TK_NK_INTEGER: { *value = taosStr2UInt64(p, &endPtr, 10); @@ -246,24 +285,22 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) { } if (n == 0) { - *value = 0; - return TSDB_CODE_SUCCESS; + errno = EINVAL; + return TSDB_CODE_FAILED; } // 1. parse as integer *value = taosStr2UInt64(p, &endPtr, 10); - if (*p == '-' && *value) { - return TSDB_CODE_FAILED; - } + if (endPtr - z == n) { - if (errno == ERANGE || errno == EINVAL) { + if (errno == ERANGE || errno == EINVAL || (*p == '-' && *value)) { return TSDB_CODE_FAILED; } return TSDB_CODE_SUCCESS; } else if (errno == 0 && *endPtr == '.') { const char *s = endPtr + 1; const char *end = z + n; - bool pure = true; + bool pure = true; while (s < end) { if (*s < '0' || *s > '9') { pure = false; @@ -275,13 +312,16 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) { if (endPtr + 1 < end && endPtr[1] > '4' && *value < UINT64_MAX) { (*value)++; } + if (*p == '-' && *value) { + return TSDB_CODE_FAILED; + } return TSDB_CODE_SUCCESS; } } - // 2. parse as other + // 2. parse as other bool is_neg = false; - int32_t code = parseSignAndUInteger(z, n, &is_neg, value); + int32_t code = parseSignAndUInteger(z, n, &is_neg, value, true); if (is_neg) { if (TSDB_CODE_SUCCESS == code && 0 == *value) { return TSDB_CODE_SUCCESS; diff --git a/source/dnode/mnode/impl/inc/mndConsumer.h b/source/dnode/mnode/impl/inc/mndConsumer.h index 8c89ddc825..5184ad0eca 100644 --- a/source/dnode/mnode/impl/inc/mndConsumer.h +++ b/source/dnode/mnode/impl/inc/mndConsumer.h @@ -24,27 +24,22 @@ extern "C" { enum { MQ_CONSUMER_STATUS_REBALANCE = 1, -// MQ_CONSUMER_STATUS__MODIFY_IN_REB, // this value is not used anymore MQ_CONSUMER_STATUS_READY, MQ_CONSUMER_STATUS_LOST, -// MQ_CONSUMER_STATUS__LOST_IN_REB, // this value is not used anymore -// MQ_CONSUMER_STATUS__LOST_REBD, -};\ +}; int32_t mndInitConsumer(SMnode *pMnode); void mndCleanupConsumer(SMnode *pMnode); -void mndDropConsumerFromSdb(SMnode *pMnode, int64_t consumerId, SRpcHandleInfo* info); +void mndSendConsumerMsg(SMnode *pMnode, int64_t consumerId, uint16_t msgType, SRpcHandleInfo* info); SMqConsumerObj *mndAcquireConsumer(SMnode *pMnode, int64_t consumerId); void mndReleaseConsumer(SMnode *pMnode, SMqConsumerObj *pConsumer); -SMqConsumerObj *mndCreateConsumer(int64_t consumerId, const char *cgroup); - SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer); SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw); -int32_t mndSetConsumerCommitLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *pConsumer); -int32_t mndSetConsumerDropLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *pConsumer); +int32_t mndSetConsumerCommitLogs(STrans *pTrans, SMqConsumerObj *pConsumer); +int32_t mndSetConsumerDropLogs(STrans *pTrans, SMqConsumerObj *pConsumer); const char *mndConsumerStatusName(int status); diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 4a092057ce..b98ef31d75 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -149,6 +149,7 @@ typedef enum { CONSUMER_REMOVE_REB, // remove after rebalance CONSUMER_UPDATE_REC, // update after recover CONSUMER_UPDATE_SUB, // update after subscribe req + CONSUMER_INSERT_SUB, } ECsmUpdateType; typedef struct { @@ -556,8 +557,9 @@ typedef struct { int32_t resetOffsetCfg; } SMqConsumerObj; -SMqConsumerObj* tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_LEN]); -void tDeleteSMqConsumerObj(SMqConsumerObj* pConsumer, bool isDeleted); +SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType, char *topic, SCMSubscribeReq *subscribe); +void tClearSMqConsumerObj(SMqConsumerObj* pConsumer); +void tDeleteSMqConsumerObj(SMqConsumerObj* pConsumer); int32_t tEncodeSMqConsumerObj(void** buf, const SMqConsumerObj* pConsumer); void* tDecodeSMqConsumerObj(const void* buf, SMqConsumerObj* pConsumer, int8_t sver); diff --git a/source/dnode/mnode/impl/inc/mndSubscribe.h b/source/dnode/mnode/impl/inc/mndSubscribe.h index 23b3a7d1fe..eb9902a75c 100644 --- a/source/dnode/mnode/impl/inc/mndSubscribe.h +++ b/source/dnode/mnode/impl/inc/mndSubscribe.h @@ -30,7 +30,7 @@ SMqSubscribeObj *mndAcquireSubscribe(SMnode *pMnode, const char *CGroup, const c SMqSubscribeObj *mndAcquireSubscribeByKey(SMnode *pMnode, const char *key); void mndReleaseSubscribe(SMnode *pMnode, SMqSubscribeObj *pSub); -int32_t mndMakeSubscribeKey(char *key, const char *cgroup, const char *topicName); +void mndMakeSubscribeKey(char *key, const char *cgroup, const char *topicName); int32_t mndDropSubByTopic(SMnode *pMnode, STrans *pTrans, const char *topic); int32_t mndSetDropSubCommitLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeObj *pSub); diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index f60d8035e3..52671f6b66 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -68,25 +68,27 @@ int32_t mndInitConsumer(SMnode *pMnode) { void mndCleanupConsumer(SMnode *pMnode) {} -void mndDropConsumerFromSdb(SMnode *pMnode, int64_t consumerId, SRpcHandleInfo *info) { - SMqConsumerClearMsg *pClearMsg = rpcMallocCont(sizeof(SMqConsumerClearMsg)); - if (pClearMsg == NULL) { +void mndSendConsumerMsg(SMnode *pMnode, int64_t consumerId, uint16_t msgType, SRpcHandleInfo *info) { + void *msg = rpcMallocCont(sizeof(int64_t)); + if (msg == NULL) { mError("consumer:0x%" PRIx64 " failed to clear consumer due to out of memory. alloc size:%d", consumerId, - (int32_t)sizeof(SMqConsumerClearMsg)); + (int32_t)sizeof(int64_t)); return; } - pClearMsg->consumerId = consumerId; + *(int64_t*)msg = consumerId; SRpcMsg rpcMsg = { - .msgType = TDMT_MND_TMQ_LOST_CONSUMER_CLEAR, - .pCont = pClearMsg, - .contLen = sizeof(SMqConsumerClearMsg), + .msgType = msgType, + .pCont = msg, + .contLen = sizeof(int64_t), .info = *info, }; - mInfo("consumer:0x%" PRIx64 " drop from sdb", consumerId); - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); - return; + mInfo("mndSendConsumerMsg type:%d consumer:0x%" PRIx64, msgType, consumerId); + int32_t code = tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + if (code != 0){ + mError("consumer:%"PRId64" send consumer msg:%d error:%d", consumerId, msgType, code); + } } static int32_t validateTopics(STrans *pTrans, const SArray *pTopicList, SMnode *pMnode, const char *pUser, @@ -148,54 +150,62 @@ FAILED: } static int32_t mndProcessConsumerRecoverMsg(SRpcMsg *pMsg) { + int32_t code = 0; SMnode *pMnode = pMsg->info.node; SMqConsumerRecoverMsg *pRecoverMsg = pMsg->pCont; + SMqConsumerObj *pConsumerNew = NULL; + STrans *pTrans = NULL; SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, pRecoverMsg->consumerId); if (pConsumer == NULL) { mError("cannot find consumer %" PRId64 " when processing consumer recover msg", pRecoverMsg->consumerId); - return -1; + code = -1; + goto END; } mInfo("receive consumer recover msg, consumer:0x%" PRIx64 " status:%d(%s)", pRecoverMsg->consumerId, pConsumer->status, mndConsumerStatusName(pConsumer->status)); if (pConsumer->status != MQ_CONSUMER_STATUS_LOST) { - mndReleaseConsumer(pMnode, pConsumer); terrno = TSDB_CODE_MND_CONSUMER_NOT_READY; - return -1; + code = -1; + goto END; } - SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(pConsumer->consumerId, pConsumer->cgroup); - pConsumerNew->updateType = CONSUMER_UPDATE_REC; + pConsumerNew = tNewSMqConsumerObj(pConsumer->consumerId, pConsumer->cgroup, CONSUMER_UPDATE_REC, NULL, NULL); + if (pConsumerNew == NULL){ + code = -1; + goto END; + } - mndReleaseConsumer(pMnode, pConsumer); - - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_TOPIC, pMsg, "recover-csm"); + pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_TOPIC, pMsg, "recover-csm"); if (pTrans == NULL) { - goto FAIL; + code = -1; + goto END; } - if (validateTopics(pTrans, pConsumer->assignedTopics, pMnode, pMsg->info.conn.user, false) != 0) { - goto FAIL; + code = validateTopics(pTrans, pConsumer->assignedTopics, pMnode, pMsg->info.conn.user, false); + if (code != 0) { + goto END; } - if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) goto FAIL; - if (mndTransPrepare(pMnode, pTrans) != 0) goto FAIL; - - tDeleteSMqConsumerObj(pConsumerNew, true); + code = mndSetConsumerCommitLogs(pTrans, pConsumerNew); + if (code != 0) { + goto END; + } + code = mndTransPrepare(pMnode, pTrans); +END: + mndReleaseConsumer(pMnode, pConsumer); + tDeleteSMqConsumerObj(pConsumerNew); mndTransDrop(pTrans); - return 0; -FAIL: - tDeleteSMqConsumerObj(pConsumerNew, true); - - mndTransDrop(pTrans); - return -1; + return code; } -// todo check the clear process static int32_t mndProcessConsumerClearMsg(SRpcMsg *pMsg) { + int32_t code = 0; SMnode *pMnode = pMsg->info.node; SMqConsumerClearMsg *pClearMsg = pMsg->pCont; + SMqConsumerObj *pConsumerNew = NULL; + STrans *pTrans = NULL; SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, pClearMsg->consumerId); if (pConsumer == NULL) { @@ -206,33 +216,37 @@ static int32_t mndProcessConsumerClearMsg(SRpcMsg *pMsg) { mInfo("consumer:0x%" PRIx64 " needs to be cleared, status %s", pClearMsg->consumerId, mndConsumerStatusName(pConsumer->status)); - SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(pConsumer->consumerId, pConsumer->cgroup); + pConsumerNew = tNewSMqConsumerObj(pConsumer->consumerId, pConsumer->cgroup, -1, NULL, NULL); + if (pConsumerNew == NULL){ + code = -1; + goto END; + } - mndReleaseConsumer(pMnode, pConsumer); + pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pMsg, "clear-csm"); + if (pTrans == NULL) { + code = -1; + goto END; + } - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pMsg, "clear-csm"); - if (pTrans == NULL) goto FAIL; // this is the drop action, not the update action - if (mndSetConsumerDropLogs(pMnode, pTrans, pConsumerNew) != 0) goto FAIL; - if (mndTransPrepare(pMnode, pTrans) != 0) goto FAIL; + code = mndSetConsumerDropLogs(pTrans, pConsumerNew); + if (code != 0) { + goto END; + } - tDeleteSMqConsumerObj(pConsumerNew, true); + code = mndTransPrepare(pMnode, pTrans); +END: + mndReleaseConsumer(pMnode, pConsumer); + tDeleteSMqConsumerObj(pConsumerNew); mndTransDrop(pTrans); - return 0; - -FAIL: - tDeleteSMqConsumerObj(pConsumerNew, true); - - mndTransDrop(pTrans); - return -1; + return code; } static int32_t checkPrivilege(SMnode *pMnode, SMqConsumerObj *pConsumer, SMqHbRsp *rsp, char *user) { rsp->topicPrivileges = taosArrayInit(taosArrayGetSize(pConsumer->currentTopics), sizeof(STopicPrivilege)); if (rsp->topicPrivileges == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return terrno; + return TSDB_CODE_OUT_OF_MEMORY; } for (int32_t i = 0; i < taosArrayGetSize(pConsumer->currentTopics); i++) { char *topic = taosArrayGetP(pConsumer->currentTopics, i); @@ -253,6 +267,47 @@ static int32_t checkPrivilege(SMnode *pMnode, SMqConsumerObj *pConsumer, SMqHbRs return 0; } +static void storeOffsetRows(SMnode *pMnode, SMqHbReq *req, SMqConsumerObj *pConsumer){ + for (int i = 0; i < taosArrayGetSize(req->topics); i++) { + TopicOffsetRows *data = taosArrayGet(req->topics, i); + mInfo("heartbeat report offset rows.%s:%s", pConsumer->cgroup, data->topicName); + + SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, pConsumer->cgroup, data->topicName); + if (pSub == NULL) { + continue; + } + taosWLockLatch(&pSub->lock); + SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &pConsumer->consumerId, sizeof(int64_t)); + if (pConsumerEp) { + taosArrayDestroy(pConsumerEp->offsetRows); + pConsumerEp->offsetRows = data->offsetRows; + data->offsetRows = NULL; + } + taosWUnLockLatch(&pSub->lock); + + mndReleaseSubscribe(pMnode, pSub); + } +} + +static int32_t buildMqHbRsp(SRpcMsg *pMsg, SMqHbRsp *rsp){ + int32_t tlen = tSerializeSMqHbRsp(NULL, 0, rsp); + if (tlen <= 0){ + return TSDB_CODE_OUT_OF_MEMORY; + } + void *buf = rpcMallocCont(tlen); + if (buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + if(tSerializeSMqHbRsp(buf, tlen, rsp) != 0){ + rpcFreeCont(buf); + return TSDB_CODE_OUT_OF_MEMORY; + } + pMsg->info.rsp = buf; + pMsg->info.rspLen = tlen; + return 0; +} + static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { int32_t code = 0; SMnode *pMnode = pMsg->info.node; @@ -261,7 +316,6 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { SMqConsumerObj *pConsumer = NULL; if (tDeserializeSMqHbReq(pMsg->pCont, pMsg->contLen, &req) < 0) { - terrno = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY; goto end; } @@ -270,7 +324,6 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { pConsumer = mndAcquireConsumer(pMnode, consumerId); if (pConsumer == NULL) { mError("consumer:0x%" PRIx64 " not exist", consumerId); - terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST; code = TSDB_CODE_MND_CONSUMER_NOT_EXIST; goto end; } @@ -284,88 +337,152 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { int32_t status = atomic_load_32(&pConsumer->status); if (status == MQ_CONSUMER_STATUS_LOST) { - mInfo("try to recover consumer:0x%" PRIx64 "", consumerId); - SMqConsumerRecoverMsg *pRecoverMsg = rpcMallocCont(sizeof(SMqConsumerRecoverMsg)); - - pRecoverMsg->consumerId = consumerId; - SRpcMsg pRpcMsg = { - .msgType = TDMT_MND_TMQ_CONSUMER_RECOVER, - .pCont = pRecoverMsg, - .contLen = sizeof(SMqConsumerRecoverMsg), - .info = pMsg->info, - }; - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &pRpcMsg); + mInfo("try to recover consumer:0x%" PRIx64, consumerId); + mndSendConsumerMsg(pMnode, pConsumer->consumerId, TDMT_MND_TMQ_CONSUMER_RECOVER, &pMsg->info); } - for (int i = 0; i < taosArrayGetSize(req.topics); i++) { - TopicOffsetRows *data = taosArrayGet(req.topics, i); - mInfo("heartbeat report offset rows.%s:%s", pConsumer->cgroup, data->topicName); - - SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, pConsumer->cgroup, data->topicName); - if (pSub == NULL) { -#ifdef TMQ_DEBUG - ASSERT(0); -#endif - continue; - } - taosWLockLatch(&pSub->lock); - SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &consumerId, sizeof(int64_t)); - if (pConsumerEp) { - taosArrayDestroy(pConsumerEp->offsetRows); - pConsumerEp->offsetRows = data->offsetRows; - data->offsetRows = NULL; - } - taosWUnLockLatch(&pSub->lock); - - mndReleaseSubscribe(pMnode, pSub); - } - - // encode rsp - int32_t tlen = tSerializeSMqHbRsp(NULL, 0, &rsp); - void *buf = rpcMallocCont(tlen); - if (buf == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - code = TSDB_CODE_OUT_OF_MEMORY; - goto end; - } - - tSerializeSMqHbRsp(buf, tlen, &rsp); - pMsg->info.rsp = buf; - pMsg->info.rspLen = tlen; + storeOffsetRows(pMnode, &req, pConsumer); + code = buildMqHbRsp(pMsg, &rsp); end: - tDeatroySMqHbRsp(&rsp); + tDestroySMqHbRsp(&rsp); mndReleaseConsumer(pMnode, pConsumer); - tDeatroySMqHbReq(&req); + tDestroySMqHbReq(&req); return code; } +static int32_t addEpSetInfo(SMnode *pMnode, SMqConsumerObj *pConsumer, int32_t epoch, SMqAskEpRsp *rsp){ + taosRLockLatch(&pConsumer->lock); + + int32_t numOfTopics = taosArrayGetSize(pConsumer->currentTopics); + + rsp->topics = taosArrayInit(numOfTopics, sizeof(SMqSubTopicEp)); + if (rsp->topics == NULL) { + taosRUnLockLatch(&pConsumer->lock); + return TSDB_CODE_OUT_OF_MEMORY; + } + + // handle all topics subscribed by this consumer + for (int32_t i = 0; i < numOfTopics; i++) { + char *topic = taosArrayGetP(pConsumer->currentTopics, i); + SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, pConsumer->cgroup, topic); + // txn guarantees pSub is created + if (pSub == NULL) { + continue; + } + taosRLockLatch(&pSub->lock); + + SMqSubTopicEp topicEp = {0}; + strcpy(topicEp.topic, topic); + + // 2.1 fetch topic schema + SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); + if (pTopic == NULL) { + taosRUnLockLatch(&pSub->lock); + mndReleaseSubscribe(pMnode, pSub); + continue; + } + taosRLockLatch(&pTopic->lock); + tstrncpy(topicEp.db, pTopic->db, TSDB_DB_FNAME_LEN); + topicEp.schema.nCols = pTopic->schema.nCols; + if (topicEp.schema.nCols) { + topicEp.schema.pSchema = taosMemoryCalloc(topicEp.schema.nCols, sizeof(SSchema)); + memcpy(topicEp.schema.pSchema, pTopic->schema.pSchema, topicEp.schema.nCols * sizeof(SSchema)); + } + taosRUnLockLatch(&pTopic->lock); + mndReleaseTopic(pMnode, pTopic); + + // 2.2 iterate all vg assigned to the consumer of that topic + SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &pConsumer->consumerId, sizeof(int64_t)); + int32_t vgNum = taosArrayGetSize(pConsumerEp->vgs); + + // this customer assigned vgroups + topicEp.vgs = taosArrayInit(vgNum, sizeof(SMqSubVgEp)); + if (topicEp.vgs == NULL) { + taosRUnLockLatch(&pConsumer->lock); + taosRUnLockLatch(&pSub->lock); + mndReleaseSubscribe(pMnode, pSub); + return TSDB_CODE_OUT_OF_MEMORY; + } + + for (int32_t j = 0; j < vgNum; j++) { + SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, j); + // char offsetKey[TSDB_PARTITION_KEY_LEN]; + // mndMakePartitionKey(offsetKey, pConsumer->cgroup, topic, pVgEp->vgId); + + if (epoch == -1) { + SVgObj *pVgroup = mndAcquireVgroup(pMnode, pVgEp->vgId); + if (pVgroup) { + pVgEp->epSet = mndGetVgroupEpset(pMnode, pVgroup); + mndReleaseVgroup(pMnode, pVgroup); + } + } + // 2.2.1 build vg ep + SMqSubVgEp vgEp = { + .epSet = pVgEp->epSet, + .vgId = pVgEp->vgId, + .offset = -1, + }; + + taosArrayPush(topicEp.vgs, &vgEp); + } + taosArrayPush(rsp->topics, &topicEp); + + taosRUnLockLatch(&pSub->lock); + mndReleaseSubscribe(pMnode, pSub); + } + taosRUnLockLatch(&pConsumer->lock); + return 0; +} + +static int32_t buildAskEpRsp(SRpcMsg *pMsg, SMqAskEpRsp *rsp, int32_t serverEpoch, int64_t consumerId){ + // encode rsp + int32_t tlen = sizeof(SMqRspHead) + tEncodeSMqAskEpRsp(NULL, rsp); + void *buf = rpcMallocCont(tlen); + if (buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + SMqRspHead *pHead = buf; + + pHead->mqMsgType = TMQ_MSG_TYPE__EP_RSP; + pHead->epoch = serverEpoch; + pHead->consumerId = consumerId; + pHead->walsver = 0; + pHead->walever = 0; + + void *abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead)); + tEncodeSMqAskEpRsp(&abuf, rsp); + + // send rsp + pMsg->info.rsp = buf; + pMsg->info.rspLen = tlen; + return 0; +} + static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) { SMnode *pMnode = pMsg->info.node; SMqAskEpReq req = {0}; SMqAskEpRsp rsp = {0}; + int32_t code = 0; if (tDeserializeSMqAskEpReq(pMsg->pCont, pMsg->contLen, &req) < 0) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; + return TSDB_CODE_OUT_OF_MEMORY; } int64_t consumerId = req.consumerId; - int32_t epoch = req.epoch; SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, consumerId); if (pConsumer == NULL) { mError("consumer:0x%" PRIx64 " group:%s not exists in sdb", consumerId, req.cgroup); - terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST; - return -1; + return TSDB_CODE_MND_CONSUMER_NOT_EXIST; } - int32_t ret = strncmp(req.cgroup, pConsumer->cgroup, tListLen(pConsumer->cgroup)); - if (ret != 0) { + if (strncmp(req.cgroup, pConsumer->cgroup, tListLen(pConsumer->cgroup)) != 0) { mError("consumer:0x%" PRIx64 " group:%s not consistent with data in sdb, saved cgroup:%s", consumerId, req.cgroup, pConsumer->cgroup); - terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST; - goto FAIL; + code = TSDB_CODE_MND_CONSUMER_NOT_EXIST; + goto END; } atomic_store_32(&pConsumer->hbStatus, 0); @@ -374,156 +491,37 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) { int32_t status = atomic_load_32(&pConsumer->status); if (status == MQ_CONSUMER_STATUS_LOST) { - mInfo("try to recover consumer:0x%" PRIx64, consumerId); - SMqConsumerRecoverMsg *pRecoverMsg = rpcMallocCont(sizeof(SMqConsumerRecoverMsg)); - - pRecoverMsg->consumerId = consumerId; - SRpcMsg pRpcMsg = { - .msgType = TDMT_MND_TMQ_CONSUMER_RECOVER, - .pCont = pRecoverMsg, - .contLen = sizeof(SMqConsumerRecoverMsg), - .info = pMsg->info, - }; - - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &pRpcMsg); + mndSendConsumerMsg(pMnode, pConsumer->consumerId, TDMT_MND_TMQ_CONSUMER_RECOVER, &pMsg->info); } if (status != MQ_CONSUMER_STATUS_READY) { mInfo("consumer:0x%" PRIx64 " not ready, status: %s", consumerId, mndConsumerStatusName(status)); - terrno = TSDB_CODE_MND_CONSUMER_NOT_READY; - goto FAIL; + code = TSDB_CODE_MND_CONSUMER_NOT_READY; + goto END; } + int32_t epoch = req.epoch; int32_t serverEpoch = atomic_load_32(&pConsumer->epoch); // 2. check epoch, only send ep info when epochs do not match if (epoch != serverEpoch) { - taosRLockLatch(&pConsumer->lock); - mInfo("process ask ep, consumer:0x%" PRIx64 "(epoch %d) update with server epoch %d", consumerId, epoch, - serverEpoch); - int32_t numOfTopics = taosArrayGetSize(pConsumer->currentTopics); - - rsp.topics = taosArrayInit(numOfTopics, sizeof(SMqSubTopicEp)); - if (rsp.topics == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - taosRUnLockLatch(&pConsumer->lock); - goto FAIL; + mInfo("process ask ep, consumer:0x%" PRIx64 "(epoch %d) update with server epoch %d", + consumerId, epoch, serverEpoch); + code = addEpSetInfo(pMnode, pConsumer, epoch, &rsp); + if(code != 0){ + goto END; } - - // handle all topics subscribed by this consumer - for (int32_t i = 0; i < numOfTopics; i++) { - char *topic = taosArrayGetP(pConsumer->currentTopics, i); - SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, pConsumer->cgroup, topic); - // txn guarantees pSub is created - if (pSub == NULL) { -#ifdef TMQ_DEBUG - ASSERT(0); -#endif - continue; - } - taosRLockLatch(&pSub->lock); - - SMqSubTopicEp topicEp = {0}; - strcpy(topicEp.topic, topic); - - // 2.1 fetch topic schema - SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); - if (pTopic == NULL) { -#ifdef TMQ_DEBUG - ASSERT(0); -#endif - taosRUnLockLatch(&pSub->lock); - mndReleaseSubscribe(pMnode, pSub); - continue; - } - taosRLockLatch(&pTopic->lock); - tstrncpy(topicEp.db, pTopic->db, TSDB_DB_FNAME_LEN); - topicEp.schema.nCols = pTopic->schema.nCols; - if (topicEp.schema.nCols) { - topicEp.schema.pSchema = taosMemoryCalloc(topicEp.schema.nCols, sizeof(SSchema)); - memcpy(topicEp.schema.pSchema, pTopic->schema.pSchema, topicEp.schema.nCols * sizeof(SSchema)); - } - taosRUnLockLatch(&pTopic->lock); - mndReleaseTopic(pMnode, pTopic); - - // 2.2 iterate all vg assigned to the consumer of that topic - SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &consumerId, sizeof(int64_t)); - int32_t vgNum = taosArrayGetSize(pConsumerEp->vgs); - - // this customer assigned vgroups - topicEp.vgs = taosArrayInit(vgNum, sizeof(SMqSubVgEp)); - if (topicEp.vgs == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - taosRUnLockLatch(&pConsumer->lock); - taosRUnLockLatch(&pSub->lock); - mndReleaseSubscribe(pMnode, pSub); - goto FAIL; - } - - for (int32_t j = 0; j < vgNum; j++) { - SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, j); - // char offsetKey[TSDB_PARTITION_KEY_LEN]; - // mndMakePartitionKey(offsetKey, pConsumer->cgroup, topic, pVgEp->vgId); - - if (epoch == -1) { - SVgObj *pVgroup = mndAcquireVgroup(pMnode, pVgEp->vgId); - if (pVgroup) { - pVgEp->epSet = mndGetVgroupEpset(pMnode, pVgroup); - mndReleaseVgroup(pMnode, pVgroup); - } - } - // 2.2.1 build vg ep - SMqSubVgEp vgEp = { - .epSet = pVgEp->epSet, - .vgId = pVgEp->vgId, - .offset = -1, - }; - - taosArrayPush(topicEp.vgs, &vgEp); - } - taosArrayPush(rsp.topics, &topicEp); - - taosRUnLockLatch(&pSub->lock); - mndReleaseSubscribe(pMnode, pSub); - } - taosRUnLockLatch(&pConsumer->lock); } - // encode rsp - int32_t tlen = sizeof(SMqRspHead) + tEncodeSMqAskEpRsp(NULL, &rsp); - void *buf = rpcMallocCont(tlen); - if (buf == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - goto FAIL; - } + code = buildAskEpRsp(pMsg, &rsp, serverEpoch, consumerId); - SMqRspHead *pHead = buf; - - pHead->mqMsgType = TMQ_MSG_TYPE__EP_RSP; - pHead->epoch = serverEpoch; - pHead->consumerId = pConsumer->consumerId; - pHead->walsver = 0; - pHead->walever = 0; - - void *abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead)); - tEncodeSMqAskEpRsp(&abuf, &rsp); - - // release consumer and free memory +END: tDeleteSMqAskEpRsp(&rsp); mndReleaseConsumer(pMnode, pConsumer); - - // send rsp - pMsg->info.rsp = buf; - pMsg->info.rspLen = tlen; - return 0; - -FAIL: - tDeleteSMqAskEpRsp(&rsp); - mndReleaseConsumer(pMnode, pConsumer); - return -1; + return code; } -int32_t mndSetConsumerDropLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *pConsumer) { +int32_t mndSetConsumerDropLogs(STrans *pTrans, SMqConsumerObj *pConsumer) { SSdbRaw *pCommitRaw = mndConsumerActionEncode(pConsumer); if (pCommitRaw == NULL) return -1; if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1; @@ -531,7 +529,7 @@ int32_t mndSetConsumerDropLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *p return 0; } -int32_t mndSetConsumerCommitLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *pConsumer) { +int32_t mndSetConsumerCommitLogs(STrans *pTrans, SMqConsumerObj *pConsumer) { SSdbRaw *pCommitRaw = mndConsumerActionEncode(pConsumer); if (pCommitRaw == NULL) return -1; if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1; @@ -539,8 +537,6 @@ int32_t mndSetConsumerCommitLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj return 0; } -static void *topicNameDup(void *p) { return taosStrdup((char *)p); } - static void freeItem(void *param) { void *pItem = *(void **)param; if (pItem != NULL) { @@ -548,21 +544,52 @@ static void freeItem(void *param) { } } -int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { - SMnode *pMnode = pMsg->info.node; - char *msgStr = pMsg->pCont; - int32_t code = -1; +static int32_t getTopicAddDelete(SMqConsumerObj *pExistedConsumer, SMqConsumerObj *pConsumerNew){ + pConsumerNew->rebNewTopics = taosArrayInit(0, sizeof(void *)); + pConsumerNew->rebRemovedTopics = taosArrayInit(0, sizeof(void *)); + if(pConsumerNew->rebNewTopics == NULL || pConsumerNew->rebRemovedTopics == NULL){ + return TSDB_CODE_OUT_OF_MEMORY; + } + int32_t newTopicNum = taosArrayGetSize(pConsumerNew->assignedTopics); + int32_t oldTopicNum = taosArrayGetSize(pExistedConsumer->currentTopics); - SCMSubscribeReq subscribe = {0}; - tDeserializeSCMSubscribeReq(msgStr, &subscribe); + int32_t i = 0, j = 0; + while (i < oldTopicNum || j < newTopicNum) { + if (i >= oldTopicNum) { + char *newTopicCopy = taosStrdup(taosArrayGetP(pConsumerNew->assignedTopics, j)); + taosArrayPush(pConsumerNew->rebNewTopics, &newTopicCopy); + j++; + continue; + } else if (j >= newTopicNum) { + char *oldTopicCopy = taosStrdup(taosArrayGetP(pExistedConsumer->currentTopics, i)); + taosArrayPush(pConsumerNew->rebRemovedTopics, &oldTopicCopy); + i++; + continue; + } else { + char *oldTopic = taosArrayGetP(pExistedConsumer->currentTopics, i); + char *newTopic = taosArrayGetP(pConsumerNew->assignedTopics, j); + int comp = strcmp(oldTopic, newTopic); + if (comp == 0) { + i++; + j++; + continue; + } else if (comp < 0) { + char *oldTopicCopy = taosStrdup(oldTopic); + taosArrayPush(pConsumerNew->rebRemovedTopics, &oldTopicCopy); + i++; + continue; + } else { + char *newTopicCopy = taosStrdup(newTopic); + taosArrayPush(pConsumerNew->rebNewTopics, &newTopicCopy); + j++; + continue; + } + } + } + return 0; +} - int64_t consumerId = subscribe.consumerId; - char *cgroup = subscribe.cgroup; - SMqConsumerObj *pExistedConsumer = NULL; - SMqConsumerObj *pConsumerNew = NULL; - STrans *pTrans = NULL; - - SArray *pTopicList = subscribe.topicNames; +static int32_t checkAndSortTopic(SMnode *pMnode, SArray *pTopicList){ taosArraySort(pTopicList, taosArrayCompareString); taosArrayRemoveDuplicate(pTopicList, taosArrayCompareString, freeItem); @@ -571,125 +598,102 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { int32_t gNum = mndGetGroupNumByTopic(pMnode, (const char *)taosArrayGetP(pTopicList, i)); if (gNum >= MND_MAX_GROUP_PER_TOPIC) { terrno = TSDB_CODE_TMQ_GROUP_OUT_OF_RANGE; - code = terrno; - goto _over; + return -1; } } + return TSDB_CODE_SUCCESS; +} - // check topic existence - pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_TOPIC_INSIDE, pMsg, "subscribe"); - if (pTrans == NULL) { - goto _over; - } - - code = validateTopics(pTrans, pTopicList, pMnode, pMsg->info.conn.user, subscribe.enableReplay); - if (code != TSDB_CODE_SUCCESS) { - goto _over; - } - +static SMqConsumerObj* buildSubConsumer(SMnode *pMnode, SCMSubscribeReq *subscribe){ + int64_t consumerId = subscribe->consumerId; + char *cgroup = subscribe->cgroup; + SMqConsumerObj *pConsumerNew = NULL; + SMqConsumerObj *pExistedConsumer = NULL; pExistedConsumer = mndAcquireConsumer(pMnode, consumerId); if (pExistedConsumer == NULL) { - mInfo("receive subscribe request from new consumer:0x%" PRIx64 " cgroup:%s, numOfTopics:%d", consumerId, - subscribe.cgroup, (int32_t)taosArrayGetSize(pTopicList)); + mInfo("receive subscribe request from new consumer:0x%" PRIx64 + ",cgroup:%s, numOfTopics:%d", consumerId, + subscribe->cgroup, (int32_t)taosArrayGetSize(subscribe->topicNames)); - pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup); - tstrncpy(pConsumerNew->clientId, subscribe.clientId, tListLen(pConsumerNew->clientId)); - - pConsumerNew->withTbName = subscribe.withTbName; - pConsumerNew->autoCommit = subscribe.autoCommit; - pConsumerNew->autoCommitInterval = subscribe.autoCommitInterval; - pConsumerNew->resetOffsetCfg = subscribe.resetOffsetCfg; - - // pConsumerNew->updateType = CONSUMER_UPDATE_SUB; // use insert logic - taosArrayDestroy(pConsumerNew->assignedTopics); - pConsumerNew->assignedTopics = taosArrayDup(pTopicList, topicNameDup); - - // all subscribed topics should re-balance. - taosArrayDestroy(pConsumerNew->rebNewTopics); - pConsumerNew->rebNewTopics = pTopicList; - subscribe.topicNames = NULL; - - if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) goto _over; - if (mndTransPrepare(pMnode, pTrans) != 0) goto _over; + pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup, CONSUMER_INSERT_SUB, NULL, subscribe); + if (pConsumerNew == NULL) { + goto _over; + } } else { int32_t status = atomic_load_32(&pExistedConsumer->status); mInfo("receive subscribe request from existed consumer:0x%" PRIx64 - " cgroup:%s, current status:%d(%s), subscribe topic num: %d", - consumerId, subscribe.cgroup, status, mndConsumerStatusName(status), newTopicNum); + ",cgroup:%s, current status:%d(%s), subscribe topic num: %d", + consumerId, subscribe->cgroup, status, mndConsumerStatusName(status), + (int32_t)taosArrayGetSize(subscribe->topicNames)); if (status != MQ_CONSUMER_STATUS_READY) { terrno = TSDB_CODE_MND_CONSUMER_NOT_READY; goto _over; } - - pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup); + pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup, CONSUMER_UPDATE_SUB, NULL, subscribe); if (pConsumerNew == NULL) { goto _over; } - // set the update type - pConsumerNew->updateType = CONSUMER_UPDATE_SUB; - taosArrayDestroy(pConsumerNew->assignedTopics); - pConsumerNew->assignedTopics = taosArrayDup(pTopicList, topicNameDup); - - int32_t oldTopicNum = taosArrayGetSize(pExistedConsumer->currentTopics); - - int32_t i = 0, j = 0; - while (i < oldTopicNum || j < newTopicNum) { - if (i >= oldTopicNum) { - char *newTopicCopy = taosStrdup(taosArrayGetP(pTopicList, j)); - taosArrayPush(pConsumerNew->rebNewTopics, &newTopicCopy); - j++; - continue; - } else if (j >= newTopicNum) { - char *oldTopicCopy = taosStrdup(taosArrayGetP(pExistedConsumer->currentTopics, i)); - taosArrayPush(pConsumerNew->rebRemovedTopics, &oldTopicCopy); - i++; - continue; - } else { - char *oldTopic = taosArrayGetP(pExistedConsumer->currentTopics, i); - char *newTopic = taosArrayGetP(pTopicList, j); - int comp = strcmp(oldTopic, newTopic); - if (comp == 0) { - i++; - j++; - continue; - } else if (comp < 0) { - char *oldTopicCopy = taosStrdup(oldTopic); - taosArrayPush(pConsumerNew->rebRemovedTopics, &oldTopicCopy); - i++; - continue; - } else { - char *newTopicCopy = taosStrdup(newTopic); - taosArrayPush(pConsumerNew->rebNewTopics, &newTopicCopy); - j++; - continue; - } - } - } - - // no topics need to be rebalanced - if (taosArrayGetSize(pConsumerNew->rebNewTopics) == 0 && taosArrayGetSize(pConsumerNew->rebRemovedTopics) == 0) { + int32_t code = getTopicAddDelete(pExistedConsumer, pConsumerNew); + if (code != 0){ + terrno = code; goto _over; } + } + mndReleaseConsumer(pMnode, pExistedConsumer); + return pConsumerNew; - if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) goto _over; - if (mndTransPrepare(pMnode, pTrans) != 0) goto _over; +_over: + mndReleaseConsumer(pMnode, pExistedConsumer); + tDeleteSMqConsumerObj(pConsumerNew); + taosArrayDestroyP(subscribe->topicNames, (FDelete)taosMemoryFree); + return NULL; +} + +int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { + SMnode *pMnode = pMsg->info.node; + char *msgStr = pMsg->pCont; + int32_t code = 0; + + SCMSubscribeReq subscribe = {0}; + tDeserializeSCMSubscribeReq(msgStr, &subscribe); + + SMqConsumerObj *pConsumerNew = NULL; + STrans *pTrans = NULL; + + code = checkAndSortTopic(pMnode, subscribe.topicNames); + if(code != TSDB_CODE_SUCCESS){ + goto _over; } + pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_TOPIC_INSIDE, pMsg, "subscribe"); + if (pTrans == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _over; + } + + code = validateTopics(pTrans, subscribe.topicNames, pMnode, pMsg->info.conn.user, subscribe.enableReplay); + if (code != TSDB_CODE_SUCCESS) { + goto _over; + } + + pConsumerNew = buildSubConsumer(pMnode, &subscribe); + if(pConsumerNew == NULL){ + code = -1; + goto _over; + } + code = mndSetConsumerCommitLogs(pTrans, pConsumerNew); + if (code != 0) goto _over; + + code = mndTransPrepare(pMnode, pTrans); + if (code != 0) goto _over; code = TSDB_CODE_ACTION_IN_PROGRESS; _over: mndTransDrop(pTrans); - - if (pExistedConsumer) { - /*taosRUnLockLatch(&pExistedConsumer->lock);*/ - mndReleaseConsumer(pMnode, pExistedConsumer); - } - - tDeleteSMqConsumerObj(pConsumerNew, true); - + tDeleteSMqConsumerObj(pConsumerNew); taosArrayDestroyP(subscribe.topicNames, (FDelete)taosMemoryFree); return code; } @@ -796,7 +800,7 @@ static int32_t mndConsumerActionInsert(SSdb *pSdb, SMqConsumerObj *pConsumer) { static int32_t mndConsumerActionDelete(SSdb *pSdb, SMqConsumerObj *pConsumer) { mInfo("consumer:0x%" PRIx64 " perform delete action, status:(%d)%s", pConsumer->consumerId, pConsumer->status, mndConsumerStatusName(pConsumer->status)); - tDeleteSMqConsumerObj(pConsumer, false); + tClearSMqConsumerObj(pConsumer); return 0; } @@ -812,48 +816,17 @@ static void updateConsumerStatus(SMqConsumerObj *pConsumer) { } } -// remove from new topic -static void removeFromNewTopicList(SMqConsumerObj *pConsumer, const char *pTopic) { - int32_t size = taosArrayGetSize(pConsumer->rebNewTopics); +// remove from topic list +static void removeFromTopicList(SArray *topicList, const char *pTopic, int64_t consumerId, char *type) { + int32_t size = taosArrayGetSize(topicList); for (int32_t i = 0; i < size; i++) { - char *p = taosArrayGetP(pConsumer->rebNewTopics, i); + char *p = taosArrayGetP(topicList, i); if (strcmp(pTopic, p) == 0) { - taosArrayRemove(pConsumer->rebNewTopics, i); + taosArrayRemove(topicList, i); taosMemoryFree(p); - mInfo("consumer:0x%" PRIx64 " remove new topic:%s in the topic list, remain newTopics:%d", pConsumer->consumerId, - pTopic, (int)taosArrayGetSize(pConsumer->rebNewTopics)); - break; - } - } -} - -// remove from removed topic -static void removeFromRemoveTopicList(SMqConsumerObj *pConsumer, const char *pTopic) { - int32_t size = taosArrayGetSize(pConsumer->rebRemovedTopics); - for (int32_t i = 0; i < size; i++) { - char *p = taosArrayGetP(pConsumer->rebRemovedTopics, i); - if (strcmp(pTopic, p) == 0) { - taosArrayRemove(pConsumer->rebRemovedTopics, i); - taosMemoryFree(p); - - mInfo("consumer:0x%" PRIx64 " remove topic:%s in the removed topic list, remain removedTopics:%d", - pConsumer->consumerId, pTopic, (int)taosArrayGetSize(pConsumer->rebRemovedTopics)); - break; - } - } -} - -static void removeFromCurrentTopicList(SMqConsumerObj *pConsumer, const char *pTopic) { - int32_t sz = taosArrayGetSize(pConsumer->currentTopics); - for (int32_t i = 0; i < sz; i++) { - char *topic = taosArrayGetP(pConsumer->currentTopics, i); - if (strcmp(pTopic, topic) == 0) { - taosArrayRemove(pConsumer->currentTopics, i); - taosMemoryFree(topic); - - mInfo("consumer:0x%" PRIx64 " remove topic:%s in the current topic list, remain currentTopics:%d", - pConsumer->consumerId, pTopic, (int)taosArrayGetSize(pConsumer->currentTopics)); + mInfo("[rebalance] consumer:0x%" PRIx64 " remove topic:%s in the %s topic list, remain newTopics:%d", + consumerId, pTopic, type, (int)taosArrayGetSize(topicList)); break; } } @@ -887,60 +860,38 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, pOldConsumer->subscribeTime = taosGetTimestampMs(); pOldConsumer->status = MQ_CONSUMER_STATUS_REBALANCE; - mInfo("consumer:0x%" PRIx64 " sub update, modify existed consumer", pOldConsumer->consumerId); - // } else if (pNewConsumer->updateType == CONSUMER_UPDATE_TIMER_LOST) { - // int32_t sz = taosArrayGetSize(pOldConsumer->currentTopics); - // for (int32_t i = 0; i < sz; i++) { - // char *topic = taosStrdup(taosArrayGetP(pOldConsumer->currentTopics, i)); - // taosArrayPush(pOldConsumer->rebRemovedTopics, &topic); - // } - // - // int32_t prevStatus = pOldConsumer->status; - // pOldConsumer->status = MQ_CONSUMER_STATUS_LOST; - // mInfo("consumer:0x%" PRIx64 " timer update, timer lost. state %s -> %s, reb-time:%" PRId64 ", - // reb-removed-topics:%d", - // pOldConsumer->consumerId, mndConsumerStatusName(prevStatus), - // mndConsumerStatusName(pOldConsumer->status), pOldConsumer->rebalanceTime, - // (int)taosArrayGetSize(pOldConsumer->rebRemovedTopics)); + mInfo("consumer:0x%" PRIx64 " subscribe update, modify existed consumer", pOldConsumer->consumerId); } else if (pNewConsumer->updateType == CONSUMER_UPDATE_REC) { int32_t sz = taosArrayGetSize(pOldConsumer->assignedTopics); for (int32_t i = 0; i < sz; i++) { char *topic = taosStrdup(taosArrayGetP(pOldConsumer->assignedTopics, i)); taosArrayPush(pOldConsumer->rebNewTopics, &topic); } - pOldConsumer->status = MQ_CONSUMER_STATUS_REBALANCE; - mInfo("consumer:0x%" PRIx64 " timer update, timer recover", pOldConsumer->consumerId); + mInfo("consumer:0x%" PRIx64 " recover update", pOldConsumer->consumerId); } else if (pNewConsumer->updateType == CONSUMER_UPDATE_REB) { atomic_add_fetch_32(&pOldConsumer->epoch, 1); pOldConsumer->rebalanceTime = taosGetTimestampMs(); - mInfo("consumer:0x%" PRIx64 " reb update, only rebalance time", pOldConsumer->consumerId); + mInfo("[rebalance] consumer:0x%" PRIx64 " rebalance update, only rebalance time", pOldConsumer->consumerId); } else if (pNewConsumer->updateType == CONSUMER_ADD_REB) { char *pNewTopic = taosStrdup(taosArrayGetP(pNewConsumer->rebNewTopics, 0)); - - // check if exist in current topic - removeFromNewTopicList(pOldConsumer, pNewTopic); - - // add to current topic + removeFromTopicList(pOldConsumer->rebNewTopics, pNewTopic, pOldConsumer->consumerId, "new"); bool existing = existInCurrentTopicList(pOldConsumer, pNewTopic); if (existing) { - mError("consumer:0x%" PRIx64 "new topic:%s should not in currentTopics", pOldConsumer->consumerId, pNewTopic); + mError("[rebalance] consumer:0x%" PRIx64 " add new topic:%s should not in currentTopics", pOldConsumer->consumerId, pNewTopic); taosMemoryFree(pNewTopic); - } else { // added into current topic list + } else { taosArrayPush(pOldConsumer->currentTopics, &pNewTopic); taosArraySort(pOldConsumer->currentTopics, taosArrayCompareString); } - // set status int32_t status = pOldConsumer->status; updateConsumerStatus(pOldConsumer); - - // the re-balance is triggered when the new consumer is launched. pOldConsumer->rebalanceTime = taosGetTimestampMs(); - atomic_add_fetch_32(&pOldConsumer->epoch, 1); - mInfo("consumer:0x%" PRIx64 " reb update add, state (%d)%s -> (%d)%s, new epoch:%d, reb-time:%" PRId64 + + mInfo("[rebalance] consumer:0x%" PRIx64 " rebalance update add, state (%d)%s -> (%d)%s, new epoch:%d, reb-time:%" PRId64 ", current topics:%d, newTopics:%d, removeTopics:%d", pOldConsumer->consumerId, status, mndConsumerStatusName(status), pOldConsumer->status, mndConsumerStatusName(pOldConsumer->status), pOldConsumer->epoch, pOldConsumer->rebalanceTime, @@ -948,22 +899,16 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, (int)taosArrayGetSize(pOldConsumer->rebRemovedTopics)); } else if (pNewConsumer->updateType == CONSUMER_REMOVE_REB) { - char *removedTopic = taosArrayGetP(pNewConsumer->rebRemovedTopics, 0); + char *topic = taosArrayGetP(pNewConsumer->rebRemovedTopics, 0); + removeFromTopicList(pOldConsumer->rebRemovedTopics, topic, pOldConsumer->consumerId, "remove"); + removeFromTopicList(pOldConsumer->currentTopics, topic, pOldConsumer->consumerId, "current"); - // remove from removed topic - removeFromRemoveTopicList(pOldConsumer, removedTopic); - - // remove from current topic - removeFromCurrentTopicList(pOldConsumer, removedTopic); - - // set status int32_t status = pOldConsumer->status; updateConsumerStatus(pOldConsumer); - pOldConsumer->rebalanceTime = taosGetTimestampMs(); atomic_add_fetch_32(&pOldConsumer->epoch, 1); - mInfo("consumer:0x%" PRIx64 " reb update remove, state (%d)%s -> (%d)%s, new epoch:%d, reb-time:%" PRId64 + mInfo("[rebalance]consumer:0x%" PRIx64 " rebalance update remove, state (%d)%s -> (%d)%s, new epoch:%d, reb-time:%" PRId64 ", current topics:%d, newTopics:%d, removeTopics:%d", pOldConsumer->consumerId, status, mndConsumerStatusName(status), pOldConsumer->status, mndConsumerStatusName(pOldConsumer->status), pOldConsumer->epoch, pOldConsumer->rebalanceTime, diff --git a/source/dnode/mnode/impl/src/mndDef.c b/source/dnode/mnode/impl/src/mndDef.c index 5be641d1c2..3f69c7def3 100644 --- a/source/dnode/mnode/impl/src/mndDef.c +++ b/source/dnode/mnode/impl/src/mndDef.c @@ -249,7 +249,9 @@ void *tDecodeSMqVgEp(const void *buf, SMqVgEp *pVgEp, int8_t sver) { return (void *)buf; } -SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char *cgroup) { +static void *topicNameDup(void *p) { return taosStrdup((char *)p); } + +SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType, char *topic, SCMSubscribeReq *subscribe) { SMqConsumerObj *pConsumer = taosMemoryCalloc(1, sizeof(SMqConsumerObj)); if (pConsumer == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -264,36 +266,64 @@ SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char *cgroup) { pConsumer->hbStatus = 0; taosInitRWLatch(&pConsumer->lock); + pConsumer->createTime = taosGetTimestampMs(); + pConsumer->updateType = updateType; - pConsumer->currentTopics = taosArrayInit(0, sizeof(void *)); - pConsumer->rebNewTopics = taosArrayInit(0, sizeof(void *)); - pConsumer->rebRemovedTopics = taosArrayInit(0, sizeof(void *)); - pConsumer->assignedTopics = taosArrayInit(0, sizeof(void *)); + if (updateType == CONSUMER_ADD_REB){ + pConsumer->rebNewTopics = taosArrayInit(0, sizeof(void *)); + if(pConsumer->rebNewTopics == NULL){ + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto END; + } - if (pConsumer->currentTopics == NULL || pConsumer->rebNewTopics == NULL || pConsumer->rebRemovedTopics == NULL || - pConsumer->assignedTopics == NULL) { - taosArrayDestroy(pConsumer->currentTopics); - taosArrayDestroy(pConsumer->rebNewTopics); - taosArrayDestroy(pConsumer->rebRemovedTopics); - taosArrayDestroy(pConsumer->assignedTopics); - taosMemoryFree(pConsumer); - return NULL; + char* topicTmp = taosStrdup(topic); + taosArrayPush(pConsumer->rebNewTopics, &topicTmp); + }else if (updateType == CONSUMER_REMOVE_REB) { + pConsumer->rebRemovedTopics = taosArrayInit(0, sizeof(void *)); + if(pConsumer->rebRemovedTopics == NULL){ + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto END; + } + char* topicTmp = taosStrdup(topic); + taosArrayPush(pConsumer->rebRemovedTopics, &topicTmp); + }else if (updateType == CONSUMER_INSERT_SUB){ + tstrncpy(pConsumer->clientId, subscribe->clientId, tListLen(pConsumer->clientId)); + pConsumer->withTbName = subscribe->withTbName; + pConsumer->autoCommit = subscribe->autoCommit; + pConsumer->autoCommitInterval = subscribe->autoCommitInterval; + pConsumer->resetOffsetCfg = subscribe->resetOffsetCfg; + + + pConsumer->rebNewTopics = taosArrayDup(subscribe->topicNames, topicNameDup); + if (pConsumer->rebNewTopics == NULL){ + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto END; + } + pConsumer->assignedTopics = subscribe->topicNames; + subscribe->topicNames = NULL; + }else if (updateType == CONSUMER_UPDATE_SUB){ + pConsumer->assignedTopics = subscribe->topicNames; + subscribe->topicNames = NULL; } - pConsumer->createTime = taosGetTimestampMs(); - return pConsumer; + +END: + tDeleteSMqConsumerObj(pConsumer); + return NULL; } -void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer, bool delete) { +void tClearSMqConsumerObj(SMqConsumerObj *pConsumer) { if (pConsumer == NULL) return; taosArrayDestroyP(pConsumer->currentTopics, (FDelete)taosMemoryFree); taosArrayDestroyP(pConsumer->rebNewTopics, (FDelete)taosMemoryFree); taosArrayDestroyP(pConsumer->rebRemovedTopics, (FDelete)taosMemoryFree); taosArrayDestroyP(pConsumer->assignedTopics, (FDelete)taosMemoryFree); - if (delete) { - taosMemoryFree(pConsumer); - } +} + +void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer) { + tClearSMqConsumerObj(pConsumer); + taosMemoryFree(pConsumer); } int32_t tEncodeSMqConsumerObj(void **buf, const SMqConsumerObj *pConsumer) { @@ -548,6 +578,7 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) { } void tDeleteSubscribeObj(SMqSubscribeObj *pSub) { + if (pSub == NULL) return; void *pIter = NULL; while (1) { pIter = taosHashIterate(pSub->consumerHash, pIter); diff --git a/source/dnode/mnode/impl/src/mndIndex.c b/source/dnode/mnode/impl/src/mndIndex.c index 622ed0080f..f2e2c556cf 100644 --- a/source/dnode/mnode/impl/src/mndIndex.c +++ b/source/dnode/mnode/impl/src/mndIndex.c @@ -597,6 +597,7 @@ static int32_t mndSetUpdateIdxStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStb taosRUnLockLatch(&pOld->lock); pNew->pTags = NULL; + pNew->pColumns = NULL; pNew->updateTime = taosGetTimestampMs(); pNew->lock = 0; diff --git a/source/dnode/mnode/impl/src/mndStreamUtil.c b/source/dnode/mnode/impl/src/mndStreamUtil.c index 2b8fcee9fd..a124b4052c 100644 --- a/source/dnode/mnode/impl/src/mndStreamUtil.c +++ b/source/dnode/mnode/impl/src/mndStreamUtil.c @@ -115,6 +115,7 @@ SArray *mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady) { char buf[256] = {0}; EPSET_TO_STR(&entry.epset, buf); + mDebug("take node snapshot, nodeId:%d %s", entry.nodeId, buf); taosArrayPush(pVgroupListSnapshot, &entry); sdbRelease(pSdb, pVgroup); @@ -300,7 +301,10 @@ static int32_t doSetPauseAction(SMnode *pMnode, STrans *pTrans, SStreamTask *pTa return code; } - mDebug("pause node:%d, epset:%d", pTask->info.nodeId, epset.numOfEps); + char buf[256] = {0}; + EPSET_TO_STR(&epset, buf); + mDebug("pause stream task in node:%d, epset:%s", pTask->info.nodeId, buf); + code = setTransAction(pTrans, pReq, sizeof(SVPauseStreamTaskReq), TDMT_STREAM_TASK_PAUSE, &epset, 0); if (code != 0) { taosMemoryFree(pReq); diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index fbdfd81cdf..a6d7a24323 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -41,9 +41,9 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg); static int32_t mndProcessDropCgroupReq(SRpcMsg *pMsg); static int32_t mndRetrieveSubscribe(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextSubscribe(SMnode *pMnode, void *pIter); -static int32_t mndCheckConsumer(SRpcMsg *pMsg, SHashObj* hash); +static void mndCheckConsumer(SRpcMsg *pMsg, SHashObj* hash); -static int32_t mndSetSubCommitLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeObj *pSub) { +static int32_t mndSetSubCommitLogs(STrans *pTrans, SMqSubscribeObj *pSub) { SSdbRaw *pCommitRaw = mndSubActionEncode(pSub); if (pCommitRaw == NULL) return -1; if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1; @@ -223,47 +223,44 @@ static SMqRebInfo *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) { return pRebInfo; } -static void doRemoveLostConsumers(SMqRebOutputObj *pOutput, SHashObj *pHash, const SMqRebInputObj *pInput) { - int32_t numOfRemoved = taosArrayGetSize(pInput->pRebInfo->removedConsumers); - const char *pSubKey = pOutput->pSub->key; +static void pushVgDataToHash(SArray *vgs, SHashObj *pHash, int64_t consumerId, char* key){ + SMqVgEp *pVgEp = *(SMqVgEp **)taosArrayPop(vgs); + SMqRebOutputVg outputVg = {consumerId, -1, pVgEp}; + taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); + mInfo("[rebalance] sub:%s mq rebalance remove vgId:%d from consumer:0x%" PRIx64, + key, pVgEp->vgId, consumerId); +} +static void processRemovedConsumers(SMqRebOutputObj *pOutput, SHashObj *pHash, const SMqRebInputObj *pInput) { + int32_t numOfRemoved = taosArrayGetSize(pInput->pRebInfo->removedConsumers); int32_t actualRemoved = 0; for (int32_t i = 0; i < numOfRemoved; i++) { uint64_t consumerId = *(uint64_t *)taosArrayGet(pInput->pRebInfo->removedConsumers, i); - SMqConsumerEp *pConsumerEp = taosHashGet(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t)); - - // consumer exists till now - if (pConsumerEp) { - actualRemoved++; - - int32_t consumerVgNum = taosArrayGetSize(pConsumerEp->vgs); - for (int32_t j = 0; j < consumerVgNum; j++) { - SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, j); - - SMqRebOutputVg outputVg = {.oldConsumerId = consumerId, .newConsumerId = -1, .pVgEp = pVgEp}; - taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("sub:%s mq re-balance remove vgId:%d from consumer:0x%" PRIx64, pSubKey, pVgEp->vgId, consumerId); - } - - taosArrayDestroy(pConsumerEp->vgs); - taosHashRemove(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t)); - - // put into removed - taosArrayPush(pOutput->removedConsumers, &consumerId); + if (pConsumerEp == NULL) { + continue; } + + int32_t consumerVgNum = taosArrayGetSize(pConsumerEp->vgs); + for (int32_t j = 0; j < consumerVgNum; j++) { + pushVgDataToHash(pConsumerEp->vgs, pHash, consumerId, pOutput->pSub->key); + } + + taosArrayDestroy(pConsumerEp->vgs); + taosHashRemove(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t)); + taosArrayPush(pOutput->removedConsumers, &consumerId); + actualRemoved++; } if (numOfRemoved != actualRemoved) { - mError("sub:%s mq re-balance removedNum:%d not matched with actual:%d", pSubKey, numOfRemoved, actualRemoved); + mError("[rebalance] sub:%s mq rebalance removedNum:%d not matched with actual:%d", pOutput->pSub->key, numOfRemoved, actualRemoved); } else { - mInfo("sub:%s removed %d consumers", pSubKey, numOfRemoved); + mInfo("[rebalance] sub:%s removed %d consumers", pOutput->pSub->key, numOfRemoved); } } -static void doAddNewConsumers(SMqRebOutputObj *pOutput, const SMqRebInputObj *pInput) { +static void processNewConsumers(SMqRebOutputObj *pOutput, const SMqRebInputObj *pInput) { int32_t numOfNewConsumers = taosArrayGetSize(pInput->pRebInfo->newConsumers); - const char *pSubKey = pOutput->pSub->key; for (int32_t i = 0; i < numOfNewConsumers; i++) { int64_t consumerId = *(int64_t *)taosArrayGet(pInput->pRebInfo->newConsumers, i); @@ -274,24 +271,14 @@ static void doAddNewConsumers(SMqRebOutputObj *pOutput, const SMqRebInputObj *pI taosHashPut(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t), &newConsumerEp, sizeof(SMqConsumerEp)); taosArrayPush(pOutput->newConsumers, &consumerId); - mInfo("sub:%s mq rebalance add new consumer:0x%" PRIx64, pSubKey, consumerId); + mInfo("[rebalance] sub:%s mq rebalance add new consumer:0x%" PRIx64, pOutput->pSub->key, consumerId); } } -static void addUnassignedVgroups(SMqRebOutputObj *pOutput, SHashObj *pHash) { - const char *pSubKey = pOutput->pSub->key; +static void processUnassignedVgroups(SMqRebOutputObj *pOutput, SHashObj *pHash) { int32_t numOfVgroups = taosArrayGetSize(pOutput->pSub->unassignedVgs); - for (int32_t i = 0; i < numOfVgroups; i++) { - SMqVgEp *pVgEp = *(SMqVgEp **)taosArrayPop(pOutput->pSub->unassignedVgs); - SMqRebOutputVg rebOutput = { - .oldConsumerId = -1, - .newConsumerId = -1, - .pVgEp = pVgEp, - }; - - taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &rebOutput, sizeof(SMqRebOutputVg)); - mInfo("sub:%s mq re-balance addUnassignedVgroups vgId:%d from unassigned", pSubKey, pVgEp->vgId); + pushVgDataToHash(pOutput->pSub->unassignedVgs, pHash, -1, pOutput->pSub->key); } } @@ -307,11 +294,9 @@ static void addUnassignedVgroups(SMqRebOutputObj *pOutput, SHashObj *pHash) { // } //} -static void transferVgroupsForConsumers(SMqRebOutputObj *pOutput, SHashObj *pHash, int32_t minVgCnt, - int32_t imbConsumerNum) { - const char *pSubKey = pOutput->pSub->key; - - int32_t imbCnt = 0; +static void processModifiedConsumers(SMqRebOutputObj *pOutput, SHashObj *pHash, int32_t minVgCnt, + int32_t remainderVgCnt) { + int32_t cnt = 0; void *pIter = NULL; while (1) { @@ -323,36 +308,16 @@ static void transferVgroupsForConsumers(SMqRebOutputObj *pOutput, SHashObj *pHas SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; int32_t consumerVgNum = taosArrayGetSize(pConsumerEp->vgs); - // all old consumers still existing need to be modified - // TODO optimize: modify only consumer whose vgs changed taosArrayPush(pOutput->modifyConsumers, &pConsumerEp->consumerId); if (consumerVgNum > minVgCnt) { - if (imbCnt < imbConsumerNum) { - // pop until equal minVg + 1 - while (taosArrayGetSize(pConsumerEp->vgs) > minVgCnt + 1) { - SMqVgEp *pVgEp = *(SMqVgEp **)taosArrayPop(pConsumerEp->vgs); - SMqRebOutputVg outputVg = { - .oldConsumerId = pConsumerEp->consumerId, - .newConsumerId = -1, - .pVgEp = pVgEp, - }; - taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("sub:%s mq rebalance remove vgId:%d from consumer:0x%" PRIx64 ",(first scan)", pSubKey, pVgEp->vgId, - pConsumerEp->consumerId); + if (cnt < remainderVgCnt) { + while (taosArrayGetSize(pConsumerEp->vgs) > minVgCnt + 1) { // pop until equal minVg + 1 + pushVgDataToHash(pConsumerEp->vgs, pHash, pConsumerEp->consumerId, pOutput->pSub->key); } - imbCnt++; + cnt++; } else { - // all the remain consumers should only have the number of vgroups, which is equalled to the value of minVg while (taosArrayGetSize(pConsumerEp->vgs) > minVgCnt) { - SMqVgEp *pVgEp = *(SMqVgEp **)taosArrayPop(pConsumerEp->vgs); - SMqRebOutputVg outputVg = { - .oldConsumerId = pConsumerEp->consumerId, - .newConsumerId = -1, - .pVgEp = pVgEp, - }; - taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("sub:%s mq rebalance remove vgId:%d from consumer:0x%" PRIx64 ",(first scan)", pSubKey, pVgEp->vgId, - pConsumerEp->consumerId); + pushVgDataToHash(pConsumerEp->vgs, pHash, pConsumerEp->consumerId, pOutput->pSub->key); } } } @@ -404,7 +369,7 @@ static int32_t processRemoveAddVgs(SMnode *pMnode, SMqRebOutputObj *pOutput){ } } if(!find){ - mInfo("processRemoveAddVgs old vgId:%d", pVgEp->vgId); + mInfo("[rebalance] processRemoveAddVgs old vgId:%d", pVgEp->vgId); tDeleteSMqVgEp(pVgEp); taosArrayRemove(pConsumerEp->vgs, j); continue; @@ -415,7 +380,7 @@ static int32_t processRemoveAddVgs(SMnode *pMnode, SMqRebOutputObj *pOutput){ if(taosArrayGetSize(pOutput->pSub->unassignedVgs) == 0 && taosArrayGetSize(newVgs) != 0){ taosArrayAddAll(pOutput->pSub->unassignedVgs, newVgs); - mInfo("processRemoveAddVgs add new vg num:%d", (int)taosArrayGetSize(newVgs)); + mInfo("[rebalance] processRemoveAddVgs add new vg num:%d", (int)taosArrayGetSize(newVgs)); taosArrayDestroy(newVgs); }else{ taosArrayDestroyP(newVgs, (FDelete)tDeleteSMqVgEp); @@ -423,194 +388,229 @@ static int32_t processRemoveAddVgs(SMnode *pMnode, SMqRebOutputObj *pOutput){ return totalVgNum; } -static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput) { - int32_t totalVgNum = processRemoveAddVgs(pMnode, pOutput); - const char *pSubKey = pOutput->pSub->key; - - int32_t numOfRemoved = taosArrayGetSize(pInput->pRebInfo->removedConsumers); - int32_t numOfAdded = taosArrayGetSize(pInput->pRebInfo->newConsumers); - mInfo("sub:%s mq re-balance %d vgroups, existed consumers:%d, added:%d, removed:%d", pSubKey, totalVgNum, - pInput->oldConsumerNum, numOfAdded, numOfRemoved); - - // 1. build temporary hash(vgId -> SMqRebOutputVg) to store vg that need to be assigned - SHashObj *pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); - - // 2. check and get actual removed consumers, put their vg into pHash - doRemoveLostConsumers(pOutput, pHash, pInput); - - // 3. if previously no consumer, there are vgs not assigned, put these vg into pHash - addUnassignedVgroups(pOutput, pHash); - - // 4. calc vg number of each consumer - int32_t numOfFinal = pInput->oldConsumerNum + numOfAdded - numOfRemoved; - - int32_t minVgCnt = 0; - int32_t imbConsumerNum = 0; - - // calc num - if (numOfFinal) { - minVgCnt = totalVgNum / numOfFinal; - imbConsumerNum = totalVgNum % numOfFinal; - mInfo("sub:%s mq re-balance %d consumers: at least %d vgs each, %d consumers has 1 more vgroups than avg value", - pSubKey, numOfFinal, minVgCnt, imbConsumerNum); - } else { - mInfo("sub:%s no consumer subscribe this topic", pSubKey); - } - - // 5. remove vgroups from consumers who have more vgroups than the threshold value(minVgCnt or minVgCnt + 1), and then another vg into pHash - transferVgroupsForConsumers(pOutput, pHash, minVgCnt, imbConsumerNum); - - // 6. add new consumer into sub - doAddNewConsumers(pOutput, pInput); - - SMqRebOutputVg *pRebVg = NULL; - void *pRemovedIter = NULL; - void *pIter = NULL; - - // 7. extract bgroups from pHash and assign to consumers that do not have enough vgroups - while (1) { - pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); - if (pIter == NULL) { - break; - } - - SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; - - // push until equal minVg - while (taosArrayGetSize(pConsumerEp->vgs) < minVgCnt) { - // iter hash and find one vg - pRemovedIter = taosHashIterate(pHash, pRemovedIter); - if (pRemovedIter == NULL) { - mError("sub:%s removed iter is null, never can reach hear", pSubKey); - break; - } - - pRebVg = (SMqRebOutputVg *)pRemovedIter; - pRebVg->newConsumerId = pConsumerEp->consumerId; - taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp); - mInfo("mq rebalance: add vgId:%d to consumer:0x%" PRIx64 " for average", pRebVg->pVgEp->vgId, pConsumerEp->consumerId); - } - } - - while (1) { - pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); - if (pIter == NULL) { - break; - } - SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; - - if (taosArrayGetSize(pConsumerEp->vgs) == minVgCnt) { - pRemovedIter = taosHashIterate(pHash, pRemovedIter); - if (pRemovedIter == NULL) { - mInfo("sub:%s removed iter is null", pSubKey); - break; - } - - pRebVg = (SMqRebOutputVg *)pRemovedIter; - pRebVg->newConsumerId = pConsumerEp->consumerId; - taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp); - mInfo("mq rebalance: add vgId:%d to consumer:0x%" PRIx64 " for average + 1", pRebVg->pVgEp->vgId, pConsumerEp->consumerId); - } - } - - // All assigned vg should be put into pOutput->rebVgs - if(pRemovedIter != NULL){ - mError("sub:%s error pRemovedIter should be NULL", pSubKey); - } - while (1) { - pRemovedIter = taosHashIterate(pHash, pRemovedIter); - if (pRemovedIter == NULL) { - break; - } - - SMqRebOutputVg* pRebOutput = (SMqRebOutputVg *)pRemovedIter; - taosArrayPush(pOutput->rebVgs, pRebOutput); - if(taosHashGetSize(pOutput->pSub->consumerHash) == 0){ // if all consumer is removed - taosArrayPush(pOutput->pSub->unassignedVgs, &pRebOutput->pVgEp); // put all vg into unassigned - } - } - +static void processSubOffsetRows(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput){ SMqSubscribeObj *pSub = mndAcquireSubscribeByKey(pMnode, pInput->pRebInfo->key); // put all offset rows - if (pSub) { - taosRLockLatch(&pSub->lock); - if (pOutput->pSub->offsetRows == NULL) { - pOutput->pSub->offsetRows = taosArrayInit(4, sizeof(OffsetRows)); - } - pIter = NULL; - while (1) { - pIter = taosHashIterate(pSub->consumerHash, pIter); - if (pIter == NULL) break; - SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; - SMqConsumerEp *pConsumerEpNew = taosHashGet(pOutput->pSub->consumerHash, &pConsumerEp->consumerId, sizeof(int64_t)); + if (pSub == NULL) { + return; + } + taosRLockLatch(&pSub->lock); + if (pOutput->pSub->offsetRows == NULL) { + pOutput->pSub->offsetRows = taosArrayInit(4, sizeof(OffsetRows)); + } + void *pIter = NULL; + while (1) { + pIter = taosHashIterate(pSub->consumerHash, pIter); + if (pIter == NULL) break; + SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; + SMqConsumerEp *pConsumerEpNew = taosHashGet(pOutput->pSub->consumerHash, &pConsumerEp->consumerId, sizeof(int64_t)); - for (int j = 0; j < taosArrayGetSize(pConsumerEp->offsetRows); j++) { - OffsetRows *d1 = taosArrayGet(pConsumerEp->offsetRows, j); - bool jump = false; - for (int i = 0; pConsumerEpNew && i < taosArrayGetSize(pConsumerEpNew->vgs); i++){ - SMqVgEp *pVgEp = taosArrayGetP(pConsumerEpNew->vgs, i); - if(pVgEp->vgId == d1->vgId){ - jump = true; - mInfo("pSub->offsetRows jump, because consumer id:0x%"PRIx64 " and vgId:%d not change", pConsumerEp->consumerId, pVgEp->vgId); - break; - } - } - if(jump) continue; - bool find = false; - for (int i = 0; i < taosArrayGetSize(pOutput->pSub->offsetRows); i++) { - OffsetRows *d2 = taosArrayGet(pOutput->pSub->offsetRows, i); - if (d1->vgId == d2->vgId) { - d2->rows += d1->rows; - d2->offset = d1->offset; - d2->ever = d1->ever; - find = true; - mInfo("pSub->offsetRows add vgId:%d, after:%"PRId64", before:%"PRId64, d2->vgId, d2->rows, d1->rows); - break; - } - } - if(!find){ - taosArrayPush(pOutput->pSub->offsetRows, d1); + for (int j = 0; j < taosArrayGetSize(pConsumerEp->offsetRows); j++) { + OffsetRows *d1 = taosArrayGet(pConsumerEp->offsetRows, j); + bool jump = false; + for (int i = 0; pConsumerEpNew && i < taosArrayGetSize(pConsumerEpNew->vgs); i++){ + SMqVgEp *pVgEp = taosArrayGetP(pConsumerEpNew->vgs, i); + if(pVgEp->vgId == d1->vgId){ + jump = true; + mInfo("pSub->offsetRows jump, because consumer id:0x%"PRIx64 " and vgId:%d not change", pConsumerEp->consumerId, pVgEp->vgId); + break; } } + if(jump) continue; + bool find = false; + for (int i = 0; i < taosArrayGetSize(pOutput->pSub->offsetRows); i++) { + OffsetRows *d2 = taosArrayGet(pOutput->pSub->offsetRows, i); + if (d1->vgId == d2->vgId) { + d2->rows += d1->rows; + d2->offset = d1->offset; + d2->ever = d1->ever; + find = true; + mInfo("pSub->offsetRows add vgId:%d, after:%"PRId64", before:%"PRId64, d2->vgId, d2->rows, d1->rows); + break; + } + } + if(!find){ + taosArrayPush(pOutput->pSub->offsetRows, d1); + } } - taosRUnLockLatch(&pSub->lock); - mndReleaseSubscribe(pMnode, pSub); } + taosRUnLockLatch(&pSub->lock); + mndReleaseSubscribe(pMnode, pSub); +} - // 8. generate logs - mInfo("sub:%s mq re-balance calculation completed, re-balanced vg", pSubKey); +static void printRebalanceLog(SMqRebOutputObj *pOutput){ + mInfo("sub:%s mq re-balance calculation completed, re-balanced vg", pOutput->pSub->key); for (int32_t i = 0; i < taosArrayGetSize(pOutput->rebVgs); i++) { SMqRebOutputVg *pOutputRebVg = taosArrayGet(pOutput->rebVgs, i); - mInfo("sub:%s mq re-balance vgId:%d, moved from consumer:0x%" PRIx64 ", to consumer:0x%" PRIx64, pSubKey, + mInfo("sub:%s mq re-balance vgId:%d, moved from consumer:0x%" PRIx64 ", to consumer:0x%" PRIx64, pOutput->pSub->key, pOutputRebVg->pVgEp->vgId, pOutputRebVg->oldConsumerId, pOutputRebVg->newConsumerId); } - pIter = NULL; + void *pIter = NULL; while (1) { pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); if (pIter == NULL) break; SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; int32_t sz = taosArrayGetSize(pConsumerEp->vgs); - mInfo("sub:%s mq re-balance final cfg: consumer:0x%" PRIx64 " has %d vg", pSubKey, pConsumerEp->consumerId, sz); + mInfo("sub:%s mq re-balance final cfg: consumer:0x%" PRIx64 " has %d vg", pOutput->pSub->key, pConsumerEp->consumerId, sz); for (int32_t i = 0; i < sz; i++) { SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, i); - mInfo("sub:%s mq re-balance final cfg: vg %d to consumer:0x%" PRIx64, pSubKey, pVgEp->vgId, + mInfo("sub:%s mq re-balance final cfg: vg %d to consumer:0x%" PRIx64, pOutput->pSub->key, pVgEp->vgId, pConsumerEp->consumerId); } } +} - // 9. clear +static void calcVgroupsCnt(const SMqRebInputObj *pInput, int32_t totalVgNum, const char *pSubKey, + int32_t *minVgCnt, int32_t *remainderVgCnt){ + int32_t numOfRemoved = taosArrayGetSize(pInput->pRebInfo->removedConsumers); + int32_t numOfAdded = taosArrayGetSize(pInput->pRebInfo->newConsumers); + int32_t numOfFinal = pInput->oldConsumerNum + numOfAdded - numOfRemoved; + + // calc num + if (numOfFinal != 0) { + *minVgCnt = totalVgNum / numOfFinal; + *remainderVgCnt = totalVgNum % numOfFinal; + } else { + mInfo("[rebalance] sub:%s no consumer subscribe this topic", pSubKey); + } + mInfo("[rebalance] sub:%s mq rebalance %d vgroups, existed consumers:%d, added:%d, removed:%d, minVg:%d remainderVg:%d", + pSubKey, totalVgNum, pInput->oldConsumerNum, numOfAdded, numOfRemoved, *minVgCnt, *remainderVgCnt); +} + +static void assignVgroups(SMqRebOutputObj *pOutput, SHashObj *pHash, int32_t minVgCnt){ + SMqRebOutputVg *pRebVg = NULL; + void *pAssignIter = NULL; + void *pIter = NULL; + + while (1) { + pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); + if (pIter == NULL) { + break; + } + SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; + while (taosArrayGetSize(pConsumerEp->vgs) < minVgCnt) { + pAssignIter = taosHashIterate(pHash, pAssignIter); + if (pAssignIter == NULL) { + mError("[rebalance] sub:%s assign iter is NULL, never should reach here", pOutput->pSub->key); + break; + } + + pRebVg = (SMqRebOutputVg *)pAssignIter; + pRebVg->newConsumerId = pConsumerEp->consumerId; + taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp); + mInfo("[rebalance] mq rebalance: add vgId:%d to consumer:0x%" PRIx64 " for average", + pRebVg->pVgEp->vgId, pConsumerEp->consumerId); + } + } + + while (1) { + pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); + if (pIter == NULL) { + break; + } + SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; + if (taosArrayGetSize(pConsumerEp->vgs) == minVgCnt) { + pAssignIter = taosHashIterate(pHash, pAssignIter); + if (pAssignIter == NULL) { + mInfo("[rebalance] sub:%s assign iter is used up", pOutput->pSub->key); + break; + } + + pRebVg = (SMqRebOutputVg *)pAssignIter; + pRebVg->newConsumerId = pConsumerEp->consumerId; + taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp); + mInfo("[rebalance] mq rebalance: add vgId:%d to consumer:0x%" PRIx64 " for average + 1", + pRebVg->pVgEp->vgId, pConsumerEp->consumerId); + } + } + + taosHashCancelIterate(pOutput->pSub->consumerHash, pIter); + if(pAssignIter != NULL){ + mError("[rebalance]sub:%s assign iter is not NULL, never should reach here", pOutput->pSub->key); + } + while (1) { + pAssignIter = taosHashIterate(pHash, pAssignIter); + if (pAssignIter == NULL) { + break; + } + + SMqRebOutputVg* pRebOutput = (SMqRebOutputVg *)pAssignIter; + taosArrayPush(pOutput->rebVgs, pRebOutput); + if(taosHashGetSize(pOutput->pSub->consumerHash) == 0){ // if all consumer is removed + taosArrayPush(pOutput->pSub->unassignedVgs, &pRebOutput->pVgEp); // put all vg into unassigned + } + } +} + +static void mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput) { + int32_t totalVgNum = processRemoveAddVgs(pMnode, pOutput); + const char *pSubKey = pOutput->pSub->key; + int32_t minVgCnt = 0; + int32_t remainderVgCnt = 0; + + SHashObj *pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + + processRemovedConsumers(pOutput, pHash, pInput); + processUnassignedVgroups(pOutput, pHash); + calcVgroupsCnt(pInput, totalVgNum, pSubKey, &minVgCnt, &remainderVgCnt); + processModifiedConsumers(pOutput, pHash, minVgCnt, remainderVgCnt); + processNewConsumers(pOutput, pInput); + assignVgroups(pOutput, pHash, minVgCnt); + processSubOffsetRows(pMnode, pInput, pOutput); + printRebalanceLog(pOutput); taosHashCleanup(pHash); +} - return 0; +static int32_t presistConsumerByType(STrans *pTrans, SArray* consumers, int8_t type, char *cgroup, char *topic){ + int32_t code = 0; + SMqConsumerObj *pConsumerNew = NULL; + int32_t consumerNum = taosArrayGetSize(consumers); + for (int32_t i = 0; i < consumerNum; i++) { + int64_t consumerId = *(int64_t *)taosArrayGet(consumers, i); + pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup, type, topic, NULL); + if (pConsumerNew == NULL){ + code = TSDB_CODE_OUT_OF_MEMORY; + goto END; + } + + code = mndSetConsumerCommitLogs(pTrans, pConsumerNew); + if (code != 0) { + goto END; + } + + tDeleteSMqConsumerObj(pConsumerNew); + } + pConsumerNew = NULL; + +END: + tDeleteSMqConsumerObj(pConsumerNew); + return code; +} + +static int32_t mndPresistConsumer(STrans *pTrans, const SMqRebOutputObj *pOutput, char *cgroup, char *topic){ + int32_t code = presistConsumerByType(pTrans, pOutput->modifyConsumers, CONSUMER_UPDATE_REB, cgroup, NULL); + if (code != 0) { + return code; + } + + code = presistConsumerByType(pTrans, pOutput->newConsumers, CONSUMER_ADD_REB, cgroup, topic); + if (code != 0) { + return code; + } + + return presistConsumerByType(pTrans, pOutput->removedConsumers, CONSUMER_REMOVE_REB, cgroup, topic); } static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOutputObj *pOutput) { - struct SSubplan* pPlan = NULL; + struct SSubplan *pPlan = NULL; + int32_t code = 0; + STrans *pTrans = NULL; + if(strcmp(pOutput->pSub->qmsg, "") != 0){ - int32_t code = qStringToSubplan(pOutput->pSub->qmsg, &pPlan); - if (code != TSDB_CODE_SUCCESS) { + code = qStringToSubplan(pOutput->pSub->qmsg, &pPlan); + if (code != 0) { terrno = code; - return -1; + goto END; } } @@ -618,110 +618,51 @@ static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOu char cgroup[TSDB_CGROUP_LEN] = {0}; mndSplitSubscribeKey(pOutput->pSub->key, topic, cgroup, true); - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_TOPIC_INSIDE, pMsg, "tmq-reb"); + pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_TOPIC_INSIDE, pMsg, "tmq-reb"); if (pTrans == NULL) { - nodesDestroyNode((SNode*)pPlan); - return -1; + code = TSDB_CODE_OUT_OF_MEMORY; + goto END; } mndTransSetDbName(pTrans, topic, cgroup); - if (mndTransCheckConflict(pMnode, pTrans) != 0) { - mndTransDrop(pTrans); - nodesDestroyNode((SNode*)pPlan); - return -1; + code = mndTransCheckConflict(pMnode, pTrans); + if (code != 0) { + goto END; } - // make txn: // 1. redo action: action to all vg const SArray *rebVgs = pOutput->rebVgs; int32_t vgNum = taosArrayGetSize(rebVgs); for (int32_t i = 0; i < vgNum; i++) { SMqRebOutputVg *pRebVg = taosArrayGet(rebVgs, i); - if (mndPersistSubChangeVgReq(pMnode, pTrans, pOutput->pSub, pRebVg, pPlan) < 0) { - mndTransDrop(pTrans); - nodesDestroyNode((SNode*)pPlan); - return -1; + code = mndPersistSubChangeVgReq(pMnode, pTrans, pOutput->pSub, pRebVg, pPlan); + if (code != 0) { + goto END; } } - nodesDestroyNode((SNode*)pPlan); - // 2. redo log: subscribe and vg assignment - // subscribe - if (mndSetSubCommitLogs(pMnode, pTrans, pOutput->pSub) != 0) { - mndTransDrop(pTrans); - return -1; + // 2. commit log: subscribe and vg assignment + code = mndSetSubCommitLogs(pTrans, pOutput->pSub); + if (code != 0) { + goto END; } // 3. commit log: consumer to update status and epoch - // 3.1 set touched consumer - int32_t consumerNum = taosArrayGetSize(pOutput->modifyConsumers); - for (int32_t i = 0; i < consumerNum; i++) { - int64_t consumerId = *(int64_t *)taosArrayGet(pOutput->modifyConsumers, i); - SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup); - pConsumerNew->updateType = CONSUMER_UPDATE_REB; - if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) { - tDeleteSMqConsumerObj(pConsumerNew, true); - - mndTransDrop(pTrans); - return -1; - } - - tDeleteSMqConsumerObj(pConsumerNew, true); + code = mndPresistConsumer(pTrans, pOutput, cgroup, topic); + if (code != 0) { + goto END; } - // 3.2 set new consumer - consumerNum = taosArrayGetSize(pOutput->newConsumers); - for (int32_t i = 0; i < consumerNum; i++) { - int64_t consumerId = *(int64_t *)taosArrayGet(pOutput->newConsumers, i); - SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup); - pConsumerNew->updateType = CONSUMER_ADD_REB; - - char* topicTmp = taosStrdup(topic); - taosArrayPush(pConsumerNew->rebNewTopics, &topicTmp); - if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) { - tDeleteSMqConsumerObj(pConsumerNew, true); - - mndTransDrop(pTrans); - return -1; - } - - tDeleteSMqConsumerObj(pConsumerNew, true); - } - - // 3.3 set removed consumer - consumerNum = taosArrayGetSize(pOutput->removedConsumers); - for (int32_t i = 0; i < consumerNum; i++) { - int64_t consumerId = *(int64_t *)taosArrayGet(pOutput->removedConsumers, i); - - SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup); - pConsumerNew->updateType = CONSUMER_REMOVE_REB; - - char* topicTmp = taosStrdup(topic); - taosArrayPush(pConsumerNew->rebRemovedTopics, &topicTmp); - if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) { - tDeleteSMqConsumerObj(pConsumerNew, true); - - mndTransDrop(pTrans); - return -1; - } - - tDeleteSMqConsumerObj(pConsumerNew, true); - } - - // 4. TODO commit log: modification log - - // 5. set cb + // 4. set cb mndTransSetCb(pTrans, TRANS_START_FUNC_MQ_REB, TRANS_STOP_FUNC_MQ_REB, NULL, 0); - // 6. execution - if (mndTransPrepare(pMnode, pTrans) != 0) { - mError("failed to prepare trans rebalance since %s", terrstr()); - mndTransDrop(pTrans); - return -1; - } + // 5. execution + code = mndTransPrepare(pMnode, pTrans); +END: + nodesDestroyNode((SNode*)pPlan); mndTransDrop(pTrans); - return 0; + return code; } static void freeRebalanceItem(void *param) { @@ -730,10 +671,55 @@ static void freeRebalanceItem(void *param) { taosArrayDestroy(pInfo->removedConsumers); } -static int32_t mndCheckConsumer(SRpcMsg *pMsg, SHashObj* rebSubHash) { +// type = 0 remove type = 1 add +static void buildRebInfo(SHashObj* rebSubHash, SArray* topicList, int8_t type, char *group, int64_t consumerId){ + int32_t topicNum = taosArrayGetSize(topicList); + for (int32_t i = 0; i < topicNum; i++) { + char key[TSDB_SUBSCRIBE_KEY_LEN]; + char *removedTopic = taosArrayGetP(topicList, i); + mndMakeSubscribeKey(key, group, removedTopic); + SMqRebInfo *pRebSub = mndGetOrCreateRebSub(rebSubHash, key); + if(type == 0) + taosArrayPush(pRebSub->removedConsumers, &consumerId); + else if(type == 1) + taosArrayPush(pRebSub->newConsumers, &consumerId); + } +} + +static void checkForVgroupSplit(SMnode *pMnode, SMqConsumerObj *pConsumer, SHashObj* rebSubHash){ + int32_t newTopicNum = taosArrayGetSize(pConsumer->currentTopics); + for (int32_t i = 0; i < newTopicNum; i++) { + char * topic = taosArrayGetP(pConsumer->currentTopics, i); + SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, pConsumer->cgroup, topic); + if (pSub == NULL) { + continue; + } + taosRLockLatch(&pSub->lock); + + // iterate all vg assigned to the consumer of that topic + SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &pConsumer->consumerId, sizeof(int64_t)); + int32_t vgNum = taosArrayGetSize(pConsumerEp->vgs); + + for (int32_t j = 0; j < vgNum; j++) { + SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, j); + SVgObj * pVgroup = mndAcquireVgroup(pMnode, pVgEp->vgId); + if (!pVgroup) { + char key[TSDB_SUBSCRIBE_KEY_LEN]; + mndMakeSubscribeKey(key, pConsumer->cgroup, topic); + mndGetOrCreateRebSub(rebSubHash, key); + mInfo("vnode splitted, vgId:%d rebalance will be triggered", pVgEp->vgId); + } + mndReleaseVgroup(pMnode, pVgroup); + } + taosRUnLockLatch(&pSub->lock); + mndReleaseSubscribe(pMnode, pSub); + } +} + +static void mndCheckConsumer(SRpcMsg *pMsg, SHashObj* rebSubHash) { SMnode *pMnode = pMsg->info.node; SSdb *pSdb = pMnode->pSdb; - SMqConsumerObj *pConsumer; + SMqConsumerObj *pConsumer = NULL; void *pIter = NULL; // iterate all consumers, find all modification @@ -746,89 +732,32 @@ static int32_t mndCheckConsumer(SRpcMsg *pMsg, SHashObj* rebSubHash) { int32_t hbStatus = atomic_add_fetch_32(&pConsumer->hbStatus, 1); int32_t status = atomic_load_32(&pConsumer->status); - mDebug("check for consumer:0x%" PRIx64 " status:%d(%s), sub-time:%" PRId64 ", createTime:%" PRId64 ", hbstatus:%d", - pConsumer->consumerId, status, mndConsumerStatusName(status), pConsumer->subscribeTime, pConsumer->createTime, - hbStatus); + mDebug("[rebalance] check for consumer:0x%" PRIx64 " status:%d(%s), sub-time:%" PRId64 ", createTime:%" PRId64 ", hbstatus:%d", + pConsumer->consumerId, status, mndConsumerStatusName(status), pConsumer->subscribeTime, pConsumer->createTime, hbStatus); if (status == MQ_CONSUMER_STATUS_READY) { - if (taosArrayGetSize(pConsumer->assignedTopics) == 0) { // unsubscribe or close - mndDropConsumerFromSdb(pMnode, pConsumer->consumerId, &pMsg->info); + if (taosArrayGetSize(pConsumer->assignedTopics) == 0) {// unsubscribe or close + mndSendConsumerMsg(pMnode, pConsumer->consumerId, TDMT_MND_TMQ_LOST_CONSUMER_CLEAR, &pMsg->info); } else if (hbStatus > MND_CONSUMER_LOST_HB_CNT) { taosRLockLatch(&pConsumer->lock); - int32_t topicNum = taosArrayGetSize(pConsumer->currentTopics); - for (int32_t i = 0; i < topicNum; i++) { - char key[TSDB_SUBSCRIBE_KEY_LEN]; - char *removedTopic = taosArrayGetP(pConsumer->currentTopics, i); - mndMakeSubscribeKey(key, pConsumer->cgroup, removedTopic); - SMqRebInfo *pRebSub = mndGetOrCreateRebSub(rebSubHash, key); - taosArrayPush(pRebSub->removedConsumers, &pConsumer->consumerId); - } + buildRebInfo(rebSubHash, pConsumer->currentTopics, 0, pConsumer->cgroup, pConsumer->consumerId); taosRUnLockLatch(&pConsumer->lock); }else{ - int32_t newTopicNum = taosArrayGetSize(pConsumer->currentTopics); - for (int32_t i = 0; i < newTopicNum; i++) { - char * topic = taosArrayGetP(pConsumer->currentTopics, i); - SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, pConsumer->cgroup, topic); - if (pSub == NULL) { - continue; - } - taosRLockLatch(&pSub->lock); - - // 2.2 iterate all vg assigned to the consumer of that topic - SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &pConsumer->consumerId, sizeof(int64_t)); - int32_t vgNum = taosArrayGetSize(pConsumerEp->vgs); - - for (int32_t j = 0; j < vgNum; j++) { - SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, j); - SVgObj * pVgroup = mndAcquireVgroup(pMnode, pVgEp->vgId); - if (!pVgroup) { - char key[TSDB_SUBSCRIBE_KEY_LEN]; - mndMakeSubscribeKey(key, pConsumer->cgroup, topic); - mndGetOrCreateRebSub(rebSubHash, key); - mInfo("vnode splitted, vgId:%d rebalance will be triggered", pVgEp->vgId); - } - mndReleaseVgroup(pMnode, pVgroup); - } - taosRUnLockLatch(&pSub->lock); - mndReleaseSubscribe(pMnode, pSub); - } + checkForVgroupSplit(pMnode, pConsumer, rebSubHash); } } else if (status == MQ_CONSUMER_STATUS_LOST) { - if (hbStatus > MND_CONSUMER_LOST_CLEAR_THRESHOLD) { // clear consumer if lost a day - mndDropConsumerFromSdb(pMnode, pConsumer->consumerId, &pMsg->info); + if (hbStatus > MND_CONSUMER_LOST_CLEAR_THRESHOLD) { // clear consumer if lost a day + mndSendConsumerMsg(pMnode, pConsumer->consumerId, TDMT_MND_TMQ_LOST_CONSUMER_CLEAR, &pMsg->info); } } else { taosRLockLatch(&pConsumer->lock); - - int32_t newTopicNum = taosArrayGetSize(pConsumer->rebNewTopics); - for (int32_t i = 0; i < newTopicNum; i++) { - char key[TSDB_SUBSCRIBE_KEY_LEN]; - char *newTopic = taosArrayGetP(pConsumer->rebNewTopics, i); - mndMakeSubscribeKey(key, pConsumer->cgroup, newTopic); - SMqRebInfo *pRebSub = mndGetOrCreateRebSub(rebSubHash, key); - taosArrayPush(pRebSub->newConsumers, &pConsumer->consumerId); - } - - int32_t removedTopicNum = taosArrayGetSize(pConsumer->rebRemovedTopics); - for (int32_t i = 0; i < removedTopicNum; i++) { - char key[TSDB_SUBSCRIBE_KEY_LEN]; - char *removedTopic = taosArrayGetP(pConsumer->rebRemovedTopics, i); - mndMakeSubscribeKey(key, pConsumer->cgroup, removedTopic); - SMqRebInfo *pRebSub = mndGetOrCreateRebSub(rebSubHash, key); - taosArrayPush(pRebSub->removedConsumers, &pConsumer->consumerId); - } - - if (newTopicNum == 0 && removedTopicNum == 0 && taosArrayGetSize(pConsumer->assignedTopics) == 0) { // unsubscribe or close - mndDropConsumerFromSdb(pMnode, pConsumer->consumerId, &pMsg->info); - } - + buildRebInfo(rebSubHash, pConsumer->rebNewTopics, 1, pConsumer->cgroup, pConsumer->consumerId); + buildRebInfo(rebSubHash, pConsumer->rebRemovedTopics, 0, pConsumer->cgroup, pConsumer->consumerId); taosRUnLockLatch(&pConsumer->lock); } mndReleaseConsumer(pMnode, pConsumer); } - - return 0; } bool mndRebTryStart() { @@ -847,31 +776,95 @@ void mndRebCntDec() { mInfo("rebalance cnt sub, value:%d", val); } +static void clearRebOutput(SMqRebOutputObj *rebOutput){ + taosArrayDestroy(rebOutput->newConsumers); + taosArrayDestroy(rebOutput->modifyConsumers); + taosArrayDestroy(rebOutput->removedConsumers); + taosArrayDestroy(rebOutput->rebVgs); + tDeleteSubscribeObj(rebOutput->pSub); + taosMemoryFree(rebOutput->pSub); +} + +static int32_t initRebOutput(SMqRebOutputObj *rebOutput) { + rebOutput->newConsumers = taosArrayInit(0, sizeof(int64_t)); + rebOutput->removedConsumers = taosArrayInit(0, sizeof(int64_t)); + rebOutput->modifyConsumers = taosArrayInit(0, sizeof(int64_t)); + rebOutput->rebVgs = taosArrayInit(0, sizeof(SMqRebOutputVg)); + + if (rebOutput->newConsumers == NULL || rebOutput->removedConsumers == NULL || rebOutput->modifyConsumers == NULL || + rebOutput->rebVgs == NULL) { + clearRebOutput(rebOutput); + return TSDB_CODE_OUT_OF_MEMORY; + } + return 0; +} + +static int32_t buildRebOutput(SMnode *pMnode, SMqRebInputObj *rebInput, SMqRebOutputObj *rebOutput){ + const char *key = rebInput->pRebInfo->key; + SMqSubscribeObj *pSub = mndAcquireSubscribeByKey(pMnode, key); + + if (pSub == NULL) { + // split sub key and extract topic + char topic[TSDB_TOPIC_FNAME_LEN]; + char cgroup[TSDB_CGROUP_LEN]; + mndSplitSubscribeKey(key, topic, cgroup, true); + + SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); + if (pTopic == NULL) { + mError("[rebalance] mq rebalance %s ignored since topic %s doesn't exist", key, topic); + return -1; + } + + taosRLockLatch(&pTopic->lock); + + rebInput->oldConsumerNum = 0; + rebOutput->pSub = mndCreateSubscription(pMnode, pTopic, key); + + if (rebOutput->pSub == NULL) { + mError("[rebalance] mq rebalance %s failed create sub since %s, ignore", key, terrstr()); + taosRUnLockLatch(&pTopic->lock); + mndReleaseTopic(pMnode, pTopic); + return -1; + } + + memcpy(rebOutput->pSub->dbName, pTopic->db, TSDB_DB_FNAME_LEN); + taosRUnLockLatch(&pTopic->lock); + mndReleaseTopic(pMnode, pTopic); + + mInfo("[rebalance] sub topic:%s has no consumers sub yet", key); + } else { + taosRLockLatch(&pSub->lock); + rebInput->oldConsumerNum = taosHashGetSize(pSub->consumerHash); + rebOutput->pSub = tCloneSubscribeObj(pSub); + taosRUnLockLatch(&pSub->lock); + + mInfo("[rebalance] sub topic:%s has %d consumers sub till now", key, rebInput->oldConsumerNum); + mndReleaseSubscribe(pMnode, pSub); + } + return 0; +} + static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { - int code = 0; - mInfo("start to process mq timer"); + int code = 0; + void *pIter = NULL; + SMnode *pMnode = pMsg->info.node; + mInfo("[rebalance] start to process mq timer"); if (!mndRebTryStart()) { - mInfo("mq rebalance already in progress, do nothing"); + mInfo("[rebalance] mq rebalance already in progress, do nothing"); return code; } SHashObj *rebSubHash = taosHashInit(64, MurmurHash3_32, true, HASH_NO_LOCK); if (rebSubHash == NULL) { - mError("failed to create rebalance hashmap"); - terrno = TSDB_CODE_OUT_OF_MEMORY; - code = -1; + code = TSDB_CODE_OUT_OF_MEMORY; goto END; } - taosHashSetFreeFp(rebSubHash, freeRebalanceItem); mndCheckConsumer(pMsg, rebSubHash); - mInfo("mq re-balance start, total required re-balanced trans:%d", taosHashGetSize(rebSubHash)); + mInfo("[rebalance] mq re-balance start, total required re-balanced trans:%d", taosHashGetSize(rebSubHash)); - // here we only handle one topic rebalance requirement to ensure the atomic execution of this transaction. - void *pIter = NULL; - SMnode *pMnode = pMsg->info.node; while (1) { pIter = taosHashIterate(rebSubHash, pIter); if (pIter == NULL) { @@ -880,92 +873,30 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { SMqRebInputObj rebInput = {0}; SMqRebOutputObj rebOutput = {0}; - rebOutput.newConsumers = taosArrayInit(0, sizeof(int64_t)); - rebOutput.removedConsumers = taosArrayInit(0, sizeof(int64_t)); - rebOutput.modifyConsumers = taosArrayInit(0, sizeof(int64_t)); - rebOutput.rebVgs = taosArrayInit(0, sizeof(SMqRebOutputVg)); - - if (rebOutput.newConsumers == NULL || rebOutput.removedConsumers == NULL || rebOutput.modifyConsumers == NULL || - rebOutput.rebVgs == NULL) { - taosArrayDestroy(rebOutput.newConsumers); - taosArrayDestroy(rebOutput.removedConsumers); - taosArrayDestroy(rebOutput.modifyConsumers); - taosArrayDestroy(rebOutput.rebVgs); - - taosHashCancelIterate(rebSubHash, pIter); - terrno = TSDB_CODE_OUT_OF_MEMORY; - mError("mq re-balance failed, due to out of memory"); - code = -1; + code = initRebOutput(&rebOutput); + if (code != 0){ goto END; } - SMqRebInfo *pRebInfo = (SMqRebInfo *)pIter; - SMqSubscribeObj *pSub = mndAcquireSubscribeByKey(pMnode, pRebInfo->key); + rebInput.pRebInfo = (SMqRebInfo*)pIter; - rebInput.pRebInfo = pRebInfo; - - if (pSub == NULL) { - // split sub key and extract topic - char topic[TSDB_TOPIC_FNAME_LEN]; - char cgroup[TSDB_CGROUP_LEN]; - mndSplitSubscribeKey(pRebInfo->key, topic, cgroup, true); - - SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); - if (pTopic == NULL) { - mError("mq re-balance %s ignored since topic %s doesn't exist", pRebInfo->key, topic); - continue; - } - - taosRLockLatch(&pTopic->lock); - - rebOutput.pSub = mndCreateSubscription(pMnode, pTopic, pRebInfo->key); - - if (rebOutput.pSub == NULL) { - mError("mq rebalance %s failed create sub since %s, ignore", pRebInfo->key, terrstr()); - taosRUnLockLatch(&pTopic->lock); - mndReleaseTopic(pMnode, pTopic); - continue; - } - - memcpy(rebOutput.pSub->dbName, pTopic->db, TSDB_DB_FNAME_LEN); - taosRUnLockLatch(&pTopic->lock); - mndReleaseTopic(pMnode, pTopic); - - rebInput.oldConsumerNum = 0; - mInfo("sub topic:%s has no consumers sub yet", pRebInfo->key); - } else { - taosRLockLatch(&pSub->lock); - rebInput.oldConsumerNum = taosHashGetSize(pSub->consumerHash); - rebOutput.pSub = tCloneSubscribeObj(pSub); - taosRUnLockLatch(&pSub->lock); - - mInfo("sub topic:%s has %d consumers sub till now", pRebInfo->key, rebInput.oldConsumerNum); - mndReleaseSubscribe(pMnode, pSub); + if (buildRebOutput(pMnode, &rebInput, &rebOutput) != 0){ + continue; } - if (mndDoRebalance(pMnode, &rebInput, &rebOutput) < 0) { - mError("mq re-balance internal error"); - } + mndDoRebalance(pMnode, &rebInput, &rebOutput); - // if add more consumer to balanced subscribe, - // possibly no vg is changed - // when each topic is re-balanced, issue an trans to save the results in sdb. - if (mndPersistRebResult(pMnode, pMsg, &rebOutput) < 0) { + if (mndPersistRebResult(pMnode, pMsg, &rebOutput) != 0) { mError("mq re-balance persist output error, possibly vnode splitted or dropped,msg:%s", terrstr()); } - taosArrayDestroy(rebOutput.newConsumers); - taosArrayDestroy(rebOutput.modifyConsumers); - taosArrayDestroy(rebOutput.removedConsumers); - taosArrayDestroy(rebOutput.rebVgs); - tDeleteSubscribeObj(rebOutput.pSub); - taosMemoryFree(rebOutput.pSub); + clearRebOutput(&rebOutput); } - // reset flag - mInfo("mq re-balance completed successfully"); + mInfo("[rebalance] mq re-balance completed successfully, wait trans finish"); END: + taosHashCancelIterate(rebSubHash, pIter); taosHashCleanup(rebSubHash); mndRebCntDec(); @@ -995,6 +926,28 @@ static int32_t sendDeleteSubToVnode(SMqSubscribeObj *pSub, STrans *pTrans){ return 0; } +static int32_t mndDropConsumerByGroup(SMnode *pMnode, STrans *pTrans, char *cgroup, char *topic){ + void *pIter = NULL; + SMqConsumerObj *pConsumer = NULL; + while (1) { + pIter = sdbFetch(pMnode->pSdb, SDB_CONSUMER, pIter, (void **)&pConsumer); + if (pIter == NULL) { + break; + } + + if (strcmp(cgroup, pConsumer->cgroup) == 0 && taosArrayGetSize(pConsumer->currentTopics) == 0) { + int32_t code = mndSetConsumerDropLogs(pTrans, pConsumer); + if (code != 0) { + sdbRelease(pMnode->pSdb, pConsumer); + sdbCancelFetch(pMnode->pSdb, pIter); + return code; + } + } + sdbRelease(pMnode->pSdb, pConsumer); + } + return 0; +} + static int32_t mndProcessDropCgroupReq(SRpcMsg *pMsg) { SMnode *pMnode = pMsg->info.node; SMDropCgroupReq dropReq = {0}; @@ -1033,41 +986,31 @@ static int32_t mndProcessDropCgroupReq(SRpcMsg *pMsg) { goto end; } + mInfo("trans:%d, used to drop cgroup:%s on topic %s", pTrans->id, dropReq.cgroup, dropReq.topic); mndTransSetDbName(pTrans, dropReq.topic, dropReq.cgroup); code = mndTransCheckConflict(pMnode, pTrans); if (code != 0) { goto end; } - void *pIter = NULL; - SMqConsumerObj *pConsumer; - while (1) { - pIter = sdbFetch(pMnode->pSdb, SDB_CONSUMER, pIter, (void **)&pConsumer); - if (pIter == NULL) { - break; - } - - if (strcmp(dropReq.cgroup, pConsumer->cgroup) == 0) { - mndDropConsumerFromSdb(pMnode, pConsumer->consumerId, &pMsg->info); - } - sdbRelease(pMnode->pSdb, pConsumer); + code = mndDropConsumerByGroup(pMnode, pTrans, dropReq.cgroup, dropReq.topic); + if (code != 0) { + goto end; } - mInfo("trans:%d, used to drop cgroup:%s on topic %s", pTrans->id, dropReq.cgroup, dropReq.topic); - code = sendDeleteSubToVnode(pSub, pTrans); if (code != 0) { goto end; } - if (mndSetDropSubCommitLogs(pMnode, pTrans, pSub) < 0) { + code = mndSetDropSubCommitLogs(pMnode, pTrans, pSub); + if (code != 0) { mError("cgroup %s on topic:%s, failed to drop since %s", dropReq.cgroup, dropReq.topic, terrstr()); - code = -1; goto end; } - if (mndTransPrepare(pMnode, pTrans) < 0) { - code = -1; + code = mndTransPrepare(pMnode, pTrans); + if (code != 0) { goto end; } @@ -1219,12 +1162,11 @@ static int32_t mndSubActionUpdate(SSdb *pSdb, SMqSubscribeObj *pOldSub, SMqSubsc return 0; } -int32_t mndMakeSubscribeKey(char *key, const char *cgroup, const char *topicName) { +void mndMakeSubscribeKey(char *key, const char *cgroup, const char *topicName) { int32_t tlen = strlen(cgroup); memcpy(key, cgroup, tlen); key[tlen] = TMQ_SEPARATOR; strcpy(key + tlen + 1, topicName); - return 0; } SMqSubscribeObj *mndAcquireSubscribe(SMnode *pMnode, const char *cgroup, const char *topicName) { @@ -1294,40 +1236,13 @@ int32_t mndSetDropSubCommitLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeObj return 0; } -//int32_t mndDropSubByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { -// int32_t code = 0; -// SSdb *pSdb = pMnode->pSdb; -// -// void *pIter = NULL; -// SMqSubscribeObj *pSub = NULL; -// while (1) { -// pIter = sdbFetch(pSdb, SDB_SUBSCRIBE, pIter, (void **)&pSub); -// if (pIter == NULL) break; -// -// if (pSub->dbUid != pDb->uid) { -// sdbRelease(pSdb, pSub); -// continue; -// } -// -// if (mndSetDropSubCommitLogs(pMnode, pTrans, pSub) < 0) { -// sdbRelease(pSdb, pSub); -// sdbCancelFetch(pSdb, pIter); -// code = -1; -// break; -// } -// -// sdbRelease(pSdb, pSub); -// } -// -// return code; -//} - int32_t mndDropSubByTopic(SMnode *pMnode, STrans *pTrans, const char *topicName) { - SSdb *pSdb = pMnode->pSdb; - + SSdb *pSdb = pMnode->pSdb; + int32_t code = 0; void *pIter = NULL; SMqSubscribeObj *pSub = NULL; while (1) { + sdbRelease(pSdb, pSub); pIter = sdbFetch(pSdb, SDB_SUBSCRIBE, pIter, (void **)&pSub); if (pIter == NULL) break; @@ -1335,33 +1250,31 @@ int32_t mndDropSubByTopic(SMnode *pMnode, STrans *pTrans, const char *topicName) char cgroup[TSDB_CGROUP_LEN] = {0}; mndSplitSubscribeKey(pSub->key, topic, cgroup, true); if (strcmp(topic, topicName) != 0) { - sdbRelease(pSdb, pSub); continue; } // iter all vnode to delete handle if (taosHashGetSize(pSub->consumerHash) != 0) { - sdbRelease(pSdb, pSub); - terrno = TSDB_CODE_MND_IN_REBALANCE; - sdbCancelFetch(pSdb, pIter); - return -1; - } - if (sendDeleteSubToVnode(pSub, pTrans) != 0) { - sdbRelease(pSdb, pSub); - sdbCancelFetch(pSdb, pIter); - return -1; + code = TSDB_CODE_MND_IN_REBALANCE; + goto END; } - if (mndSetDropSubCommitLogs(pMnode, pTrans, pSub) < 0) { - sdbRelease(pSdb, pSub); - sdbCancelFetch(pSdb, pIter); - return -1; + code = sendDeleteSubToVnode(pSub, pTrans); + if (code != 0) { + goto END; } - sdbRelease(pSdb, pSub); + code = mndSetDropSubCommitLogs(pMnode, pTrans, pSub); + if (code != 0) { + goto END; + } } - return 0; +END: + sdbRelease(pSdb, pSub); + sdbCancelFetch(pSdb, pIter); + + return code; } static int32_t buildResult(SSDataBlock *pBlock, int32_t* numOfRows, int64_t consumerId, const char* topic, const char* cgroup, SArray* vgs, SArray *offsetRows){ diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index de543f4256..4a0d58a32e 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -353,6 +353,66 @@ static int32_t extractTopicTbInfo(SNode *pAst, SMqTopicObj *pTopic) { return 0; } +static int32_t sendCheckInfoToVnode(STrans *pTrans, SMnode *pMnode, SMqTopicObj *topicObj){ + STqCheckInfo info; + memcpy(info.topic, topicObj->name, TSDB_TOPIC_FNAME_LEN); + info.ntbUid = topicObj->ntbUid; + info.colIdList = topicObj->ntbColIds; + // broadcast forbid alter info + void *pIter = NULL; + SSdb *pSdb = pMnode->pSdb; + SVgObj *pVgroup = NULL; + int32_t code = 0; + void *buf = NULL; + + while (1) { + // iterate vg + pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); + if (pIter == NULL) break; + if (!mndVgroupInDb(pVgroup, topicObj->dbUid)) { + sdbRelease(pSdb, pVgroup); + continue; + } + + // encoder check alter info + int32_t len; + tEncodeSize(tEncodeSTqCheckInfo, &info, len, code); + if (code != 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto END; + } + buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len); + void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); + SEncoder encoder; + tEncoderInit(&encoder, abuf, len); + code = tEncodeSTqCheckInfo(&encoder, &info); + if (code < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto END; + } + tEncoderClear(&encoder); + ((SMsgHead *)buf)->vgId = htonl(pVgroup->vgId); + // add redo action + STransAction action = {0}; + action.epSet = mndGetVgroupEpset(pMnode, pVgroup); + action.pCont = buf; + action.contLen = sizeof(SMsgHead) + len; + action.msgType = TDMT_VND_TMQ_ADD_CHECKINFO; + code = mndTransAppendRedoAction(pTrans, &action); + if (code != 0) { + goto END; + } + sdbRelease(pSdb, pVgroup); + buf = NULL; + } + +END: + taosMemoryFree(buf); + sdbRelease(pSdb, pVgroup); + sdbCancelFetch(pSdb, pIter); + return code; +} + static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *pCreate, SDbObj *pDb, const char *userName) { mInfo("start to create topic:%s", pCreate->name); @@ -396,13 +456,6 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq * topicObj.withMeta = pCreate->withMeta; if (pCreate->subType == TOPIC_SUB_TYPE__COLUMN) { - if (pCreate->withMeta) { - terrno = TSDB_CODE_MND_INVALID_TOPIC_OPTION; - mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); - code = terrno; - goto _OUT; - } - topicObj.ast = taosStrdup(pCreate->ast); topicObj.astLen = strlen(pCreate->ast) + 1; @@ -474,59 +527,9 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq * (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); if (topicObj.ntbUid != 0) { - STqCheckInfo info; - memcpy(info.topic, topicObj.name, TSDB_TOPIC_FNAME_LEN); - info.ntbUid = topicObj.ntbUid; - info.colIdList = topicObj.ntbColIds; - // broadcast forbid alter info - void *pIter = NULL; - SSdb *pSdb = pMnode->pSdb; - SVgObj *pVgroup = NULL; - while (1) { - // iterate vg - pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); - if (pIter == NULL) break; - if (!mndVgroupInDb(pVgroup, topicObj.dbUid)) { - sdbRelease(pSdb, pVgroup); - continue; - } - - // encoder check alter info - int32_t len; - tEncodeSize(tEncodeSTqCheckInfo, &info, len, code); - if (code < 0) { - sdbRelease(pSdb, pVgroup); - sdbCancelFetch(pSdb, pIter); - goto _OUT; - } - void *buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len); - void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); - SEncoder encoder; - tEncoderInit(&encoder, abuf, len); - if (tEncodeSTqCheckInfo(&encoder, &info) < 0) { - taosMemoryFree(buf); - sdbRelease(pSdb, pVgroup); - sdbCancelFetch(pSdb, pIter); - code = -1; - goto _OUT; - } - tEncoderClear(&encoder); - ((SMsgHead *)buf)->vgId = htonl(pVgroup->vgId); - // add redo action - STransAction action = {0}; - action.epSet = mndGetVgroupEpset(pMnode, pVgroup); - action.pCont = buf; - action.contLen = sizeof(SMsgHead) + len; - action.msgType = TDMT_VND_TMQ_ADD_CHECKINFO; - if (mndTransAppendRedoAction(pTrans, &action) != 0) { - taosMemoryFree(buf); - sdbRelease(pSdb, pVgroup); - sdbCancelFetch(pSdb, pIter); - code = -1; - goto _OUT; - } - buf = NULL; - sdbRelease(pSdb, pVgroup); + code = sendCheckInfoToVnode(pTrans, pMnode, &topicObj); + if (code != 0){ + goto _OUT; } } @@ -618,7 +621,7 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) { tNameFromString(&topicName, createTopicReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); //reuse this function for topic - auditRecord(pReq, pMnode->clusterId, "createTopic", dbname.dbname, topicName.dbname, + auditRecord(pReq, pMnode->clusterId, "createTopic", dbname.dbname, topicName.dbname, createTopicReq.sql, strlen(createTopicReq.sql)); _OVER: @@ -653,9 +656,104 @@ _OVER: return code; } +static bool checkTopic(SArray *topics, char *topicName){ + int32_t sz = taosArrayGetSize(topics); + for (int32_t i = 0; i < sz; i++) { + char *name = taosArrayGetP(topics, i); + if (strcmp(name, topicName) == 0) { + return true; + } + } + return false; +} + +static int32_t mndDropConsumerByTopic(SMnode *pMnode, STrans *pTrans, char *topicName){ + int32_t code = 0; + SSdb *pSdb = pMnode->pSdb; + void *pIter = NULL; + SMqConsumerObj *pConsumer = NULL; + while (1) { + pIter = sdbFetch(pSdb, SDB_CONSUMER, pIter, (void **)&pConsumer); + if (pIter == NULL) { + break; + } + + bool found = checkTopic(pConsumer->assignedTopics, topicName); + if (found){ + if (pConsumer->status == MQ_CONSUMER_STATUS_LOST) { + code = mndSetConsumerDropLogs(pTrans, pConsumer); + if (code != 0) { + goto end; + } + sdbRelease(pSdb, pConsumer); + continue; + } + mError("topic:%s, failed to drop since subscribed by consumer:0x%" PRIx64 ", in consumer group %s", + topicName, pConsumer->consumerId, pConsumer->cgroup); + code = TSDB_CODE_MND_TOPIC_SUBSCRIBED; + goto end; + } + + if (checkTopic(pConsumer->rebNewTopics, topicName) || checkTopic(pConsumer->rebRemovedTopics, topicName)) { + code = TSDB_CODE_MND_TOPIC_SUBSCRIBED; + mError("topic:%s, failed to drop since subscribed by consumer:%" PRId64 ", in consumer group %s (reb new)", + topicName, pConsumer->consumerId, pConsumer->cgroup); + goto end; + } + sdbRelease(pSdb, pConsumer); + } + +end: + sdbRelease(pSdb, pConsumer); + sdbCancelFetch(pSdb, pIter); + return code; +} + +static int32_t mndDropCheckInfoByTopic(SMnode *pMnode, STrans *pTrans, SMqTopicObj *pTopic){ + // broadcast to all vnode + void *pIter = NULL; + SVgObj *pVgroup = NULL; + int32_t code = 0; + SSdb *pSdb = pMnode->pSdb; + void *buf = NULL; + while (1) { + pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); + if (pIter == NULL) break; + if (!mndVgroupInDb(pVgroup, pTopic->dbUid)) { + sdbRelease(pSdb, pVgroup); + continue; + } + + buf = taosMemoryCalloc(1, sizeof(SMsgHead) + TSDB_TOPIC_FNAME_LEN); + if (buf == NULL){ + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); + ((SMsgHead *)buf)->vgId = htonl(pVgroup->vgId); + memcpy(abuf, pTopic->name, TSDB_TOPIC_FNAME_LEN); + + STransAction action = {0}; + action.epSet = mndGetVgroupEpset(pMnode, pVgroup); + action.pCont = buf; + action.contLen = sizeof(SMsgHead) + TSDB_TOPIC_FNAME_LEN; + action.msgType = TDMT_VND_TMQ_DEL_CHECKINFO; + code = mndTransAppendRedoAction(pTrans, &action); + if (code != 0) { + taosMemoryFree(buf); + goto end; + } + sdbRelease(pSdb, pVgroup); + } + +end: + sdbRelease(pSdb, pVgroup); + sdbCancelFetch(pSdb, pIter); + return code; +} + static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; - SSdb *pSdb = pMnode->pSdb; SMDropTopicReq dropReq = {0}; int32_t code = 0; SMqTopicObj *pTopic = NULL; @@ -705,68 +803,9 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) { goto end; } - void *pIter = NULL; - SMqConsumerObj *pConsumer; - while (1) { - pIter = sdbFetch(pSdb, SDB_CONSUMER, pIter, (void **)&pConsumer); - if (pIter == NULL) { - break; - } - - bool found = false; - int32_t sz = taosArrayGetSize(pConsumer->assignedTopics); - for (int32_t i = 0; i < sz; i++) { - char *name = taosArrayGetP(pConsumer->assignedTopics, i); - if (strcmp(name, pTopic->name) == 0) { - found = true; - break; - } - } - if (found){ - if (pConsumer->status == MQ_CONSUMER_STATUS_LOST) { - mndDropConsumerFromSdb(pMnode, pConsumer->consumerId, &pReq->info); - mndReleaseConsumer(pMnode, pConsumer); - continue; - } - - mndReleaseConsumer(pMnode, pConsumer); - sdbCancelFetch(pSdb, pIter); - terrno = TSDB_CODE_MND_TOPIC_SUBSCRIBED; - mError("topic:%s, failed to drop since subscribed by consumer:0x%" PRIx64 ", in consumer group %s", - dropReq.name, pConsumer->consumerId, pConsumer->cgroup); - code = -1; - goto end; - } - - sz = taosArrayGetSize(pConsumer->rebNewTopics); - for (int32_t i = 0; i < sz; i++) { - char *name = taosArrayGetP(pConsumer->rebNewTopics, i); - if (strcmp(name, pTopic->name) == 0) { - mndReleaseConsumer(pMnode, pConsumer); - sdbCancelFetch(pSdb, pIter); - terrno = TSDB_CODE_MND_TOPIC_SUBSCRIBED; - mError("topic:%s, failed to drop since subscribed by consumer:%" PRId64 ", in consumer group %s (reb new)", - dropReq.name, pConsumer->consumerId, pConsumer->cgroup); - code = -1; - goto end; - } - } - - sz = taosArrayGetSize(pConsumer->rebRemovedTopics); - for (int32_t i = 0; i < sz; i++) { - char *name = taosArrayGetP(pConsumer->rebRemovedTopics, i); - if (strcmp(name, pTopic->name) == 0) { - mndReleaseConsumer(pMnode, pConsumer); - sdbCancelFetch(pSdb, pIter); - terrno = TSDB_CODE_MND_TOPIC_SUBSCRIBED; - mError("topic:%s, failed to drop since subscribed by consumer:%" PRId64 ", in consumer group %s (reb remove)", - dropReq.name, pConsumer->consumerId, pConsumer->cgroup); - code = -1; - goto end; - } - } - - sdbRelease(pSdb, pConsumer); + code = mndDropConsumerByTopic(pMnode, pTrans, dropReq.name); + if (code != 0) { + goto end; } code = mndDropSubByTopic(pMnode, pTrans, dropReq.name); @@ -776,36 +815,9 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) { } if (pTopic->ntbUid != 0) { - // broadcast to all vnode - pIter = NULL; - SVgObj *pVgroup = NULL; - - while (1) { - pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); - if (pIter == NULL) break; - if (!mndVgroupInDb(pVgroup, pTopic->dbUid)) { - sdbRelease(pSdb, pVgroup); - continue; - } - - void *buf = taosMemoryCalloc(1, sizeof(SMsgHead) + TSDB_TOPIC_FNAME_LEN); - void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); - ((SMsgHead *)buf)->vgId = htonl(pVgroup->vgId); - memcpy(abuf, pTopic->name, TSDB_TOPIC_FNAME_LEN); - - STransAction action = {0}; - action.epSet = mndGetVgroupEpset(pMnode, pVgroup); - action.pCont = buf; - action.contLen = sizeof(SMsgHead) + TSDB_TOPIC_FNAME_LEN; - action.msgType = TDMT_VND_TMQ_DEL_CHECKINFO; - code = mndTransAppendRedoAction(pTrans, &action); - if (code != 0) { - taosMemoryFree(buf); - sdbRelease(pSdb, pVgroup); - sdbCancelFetch(pSdb, pIter); - goto end; - } - sdbRelease(pSdb, pVgroup); + code = mndDropCheckInfoByTopic(pMnode, pTrans, pTopic); + if (code != 0) { + goto end; } } @@ -822,7 +834,6 @@ end: SName name = {0}; tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); - //reuse this function for topic auditRecord(pReq, pMnode->clusterId, "dropTopic", name.dbname, name.tname, dropReq.sql, dropReq.sqlLen); diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 04d74112d4..f7db0d7b15 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -15,11 +15,11 @@ #define _DEFAULT_SOURCE #include "mndTrans.h" -#include "mndSubscribe.h" #include "mndDb.h" #include "mndPrivilege.h" #include "mndShow.h" #include "mndStb.h" +#include "mndSubscribe.h" #include "mndSync.h" #include "mndUser.h" @@ -801,16 +801,17 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) { if (pNew->conflict == TRN_CONFLICT_TOPIC) { if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true; if (pTrans->conflict == TRN_CONFLICT_TOPIC || pTrans->conflict == TRN_CONFLICT_TOPIC_INSIDE) { - if (strcasecmp(pNew->dbname, pTrans->dbname) == 0 ) conflict = true; + if (strcasecmp(pNew->dbname, pTrans->dbname) == 0) conflict = true; } } if (pNew->conflict == TRN_CONFLICT_TOPIC_INSIDE) { if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true; - if (pTrans->conflict == TRN_CONFLICT_TOPIC ) { - if (strcasecmp(pNew->dbname, pTrans->dbname) == 0 ) conflict = true; + if (pTrans->conflict == TRN_CONFLICT_TOPIC) { + if (strcasecmp(pNew->dbname, pTrans->dbname) == 0) conflict = true; } if (pTrans->conflict == TRN_CONFLICT_TOPIC_INSIDE) { - if (strcasecmp(pNew->dbname, pTrans->dbname) == 0 && strcasecmp(pNew->stbname, pTrans->stbname) == 0) conflict = true; + if (strcasecmp(pNew->dbname, pTrans->dbname) == 0 && strcasecmp(pNew->stbname, pTrans->stbname) == 0) + conflict = true; } } @@ -847,7 +848,7 @@ int32_t mndTransCheckConflict(SMnode *pMnode, STrans *pTrans) { } int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) { - if(pTrans == NULL) return -1; + if (pTrans == NULL) return -1; if (mndTransCheckConflict(pMnode, pTrans) != 0) { return -1; @@ -1142,6 +1143,7 @@ static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransActio return -1; } rpcMsg.info.traceId.rootId = pTrans->mTraceId; + rpcMsg.info.notFreeAhandle = 1; memcpy(rpcMsg.pCont, pAction->pCont, pAction->contLen); @@ -1156,7 +1158,7 @@ static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransActio int32_t code = tmsgSendReq(&pAction->epSet, &rpcMsg); if (code == 0) { pAction->msgSent = 1; - //pAction->msgReceived = 0; + // pAction->msgReceived = 0; pAction->errCode = TSDB_CODE_ACTION_IN_PROGRESS; mInfo("trans:%d, %s:%d is sent, %s", pTrans->id, mndTransStr(pAction->stage), pAction->id, detail); @@ -1253,16 +1255,16 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA for (int32_t action = 0; action < numOfActions; ++action) { STransAction *pAction = taosArrayGet(pArray, action); - mDebug("trans:%d, %s:%d Sent:%d, Received:%d, errCode:0x%x, acceptableCode:0x%x, retryCode:0x%x", - pTrans->id, mndTransStr(pAction->stage), pAction->id, pAction->msgSent, pAction->msgReceived, - pAction->errCode, pAction->acceptableCode, pAction->retryCode); + mDebug("trans:%d, %s:%d Sent:%d, Received:%d, errCode:0x%x, acceptableCode:0x%x, retryCode:0x%x", pTrans->id, + mndTransStr(pAction->stage), pAction->id, pAction->msgSent, pAction->msgReceived, pAction->errCode, + pAction->acceptableCode, pAction->retryCode); if (pAction->msgSent) { if (pAction->msgReceived) { if (pAction->errCode != 0 && pAction->errCode != pAction->acceptableCode) { mndTransResetAction(pMnode, pTrans, pAction); mInfo("trans:%d, %s:%d reset", pTrans->id, mndTransStr(pAction->stage), pAction->id); } - } + } } } return TSDB_CODE_ACTION_IN_PROGRESS; diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index e610161544..9fdb4993bd 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -106,7 +106,7 @@ typedef struct SQueryNode SQueryNode; #define VND_INFO_FNAME "vnode.json" #define VND_INFO_FNAME_TMP "vnode_tmp.json" -#define VNODE_METRIC_SQL_COUNT "taos_sql_req:count" +#define VNODE_METRIC_SQL_COUNT "taosd_sql_req:count" #define VNODE_METRIC_TAG_NAME_SQL_TYPE "sql_type" #define VNODE_METRIC_TAG_NAME_CLUSTER_ID "cluster_id" diff --git a/source/dnode/vnode/src/tq/tqMeta.c b/source/dnode/vnode/src/tq/tqMeta.c index 4c403dc18f..e64de9a423 100644 --- a/source/dnode/vnode/src/tq/tqMeta.c +++ b/source/dnode/vnode/src/tq/tqMeta.c @@ -88,10 +88,6 @@ int32_t tqMetaOpen(STQ* pTq) { return -1; } -// if (tqMetaRestoreHandle(pTq) < 0) { -// return -1; -// } - if (tqMetaRestoreCheckInfo(pTq) < 0) { return -1; } @@ -167,32 +163,30 @@ int32_t tqMetaRestoreCheckInfo(STQ* pTq) { void* pVal = NULL; int vLen = 0; SDecoder decoder; + int32_t code = 0; tdbTbcMoveToFirst(pCur); while (tdbTbcNext(pCur, &pKey, &kLen, &pVal, &vLen) == 0) { STqCheckInfo info; tDecoderInit(&decoder, (uint8_t*)pVal, vLen); - if (tDecodeSTqCheckInfo(&decoder, &info) < 0) { + code = tDecodeSTqCheckInfo(&decoder, &info); + if (code != 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; - tdbFree(pKey); - tdbFree(pVal); - tdbTbcClose(pCur); - return -1; + goto END; } tDecoderClear(&decoder); - if (taosHashPut(pTq->pCheckInfo, info.topic, strlen(info.topic), &info, sizeof(STqCheckInfo)) < 0) { + code = taosHashPut(pTq->pCheckInfo, info.topic, strlen(info.topic), &info, sizeof(STqCheckInfo)); + if (code != 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; - tdbFree(pKey); - tdbFree(pVal); - tdbTbcClose(pCur); - return -1; + goto END; } } +END: tdbFree(pKey); tdbFree(pVal); tdbTbcClose(pCur); - return 0; + return code; } int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) { diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 2be71fd68c..4d6fb11747 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -368,24 +368,11 @@ int32_t extractMsgFromWal(SWalReader* pReader, void** pItem, int64_t maxVer, con } } -// todo ignore the error in wal? bool tqNextBlockInWal(STqReader* pReader, const char* id, int sourceExcluded) { SWalReader* pWalReader = pReader->pWalReader; - SSDataBlock* pDataBlock = NULL; uint64_t st = taosGetTimestampMs(); while (1) { - // try next message in wal file - if (walNextValidMsg(pWalReader) < 0) { - return false; - } - - void* pBody = POINTER_SHIFT(pWalReader->pHead->head.body, sizeof(SSubmitReq2Msg)); - int32_t bodyLen = pWalReader->pHead->head.bodyLen - sizeof(SSubmitReq2Msg); - int64_t ver = pWalReader->pHead->head.version; - - tqReaderSetSubmitMsg(pReader, pBody, bodyLen, ver); - pReader->nextBlk = 0; int32_t numOfBlocks = taosArrayGetSize(pReader->submit.aSubmitTbData); while (pReader->nextBlk < numOfBlocks) { tqTrace("tq reader next data block %d/%d, len:%d %" PRId64, pReader->nextBlk, numOfBlocks, pReader->msg.msgLen, @@ -400,33 +387,32 @@ bool tqNextBlockInWal(STqReader* pReader, const char* id, int sourceExcluded) { tqTrace("tq reader return submit block, uid:%" PRId64, pSubmitTbData->uid); SSDataBlock* pRes = NULL; int32_t code = tqRetrieveDataBlock(pReader, &pRes, NULL); - if (code == TSDB_CODE_SUCCESS && pRes->info.rows > 0) { - if (pDataBlock == NULL) { - pDataBlock = createOneDataBlock(pRes, true); - } else { - blockDataMerge(pDataBlock, pRes); - } + if (code == TSDB_CODE_SUCCESS) { + return true; } } else { pReader->nextBlk += 1; tqTrace("tq reader discard submit block, uid:%" PRId64 ", continue", pSubmitTbData->uid); } } + tDestroySubmitReq(&pReader->submit, TSDB_MSG_FLG_DECODE); pReader->msg.msgStr = NULL; - if (pDataBlock != NULL) { - blockDataCleanup(pReader->pResBlock); - copyDataBlock(pReader->pResBlock, pDataBlock); - blockDataDestroy(pDataBlock); - return true; - } else { - qTrace("stream scan return empty, all %d submit blocks consumed, %s", numOfBlocks, id); - } - if (taosGetTimestampMs() - st > 1000) { return false; } + + // try next message in wal file + if (walNextValidMsg(pWalReader) < 0) { + return false; + } + + void* pBody = POINTER_SHIFT(pWalReader->pHead->head.body, sizeof(SSubmitReq2Msg)); + int32_t bodyLen = pWalReader->pHead->head.bodyLen - sizeof(SSubmitReq2Msg); + int64_t ver = pWalReader->pHead->head.version; + tqReaderSetSubmitMsg(pReader, pBody, bodyLen, ver); + pReader->nextBlk = 0; } } @@ -680,20 +666,19 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char* int32_t targetIdx = 0; int32_t sourceIdx = 0; while (targetIdx < colActual) { + SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx); + if (sourceIdx >= numOfCols) { - tqError("tqRetrieveDataBlock sourceIdx:%d >= numOfCols:%d", sourceIdx, numOfCols); - return -1; + tqError("lostdata tqRetrieveDataBlock sourceIdx:%d >= numOfCols:%d", sourceIdx, numOfCols); + colDataSetNNULL(pColData, 0, numOfRows); + targetIdx++; + continue; } SColData* pCol = taosArrayGet(pCols, sourceIdx); - SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx); SColVal colVal; - if (pCol->nVal != numOfRows) { - tqError("tqRetrieveDataBlock pCol->nVal:%d != numOfRows:%d", pCol->nVal, numOfRows); - return -1; - } - + tqTrace("lostdata colActual:%d, sourceIdx:%d, targetIdx:%d, numOfCols:%d, source cid:%d, dst cid:%d", colActual, sourceIdx, targetIdx, numOfCols, pCol->cid, pColData->info.colId); if (pCol->cid < pColData->info.colId) { sourceIdx++; } else if (pCol->cid == pColData->info.colId) { @@ -707,7 +692,7 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char* sourceIdx++; targetIdx++; } else { - colDataSetNNULL(pColData, 0, pCol->nVal); + colDataSetNNULL(pColData, 0, numOfRows); targetIdx++; } } @@ -726,9 +711,6 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char* SColVal colVal; tRowGet(pRow, pTSchema, sourceIdx, &colVal); if (colVal.cid < pColData->info.colId) { - // tqDebug("colIndex:%d column id:%d in row, ignore, the required colId:%d, total cols in - // schema:%d", - // sourceIdx, colVal.cid, pColData->info.colId, pTSchema->numOfCols); sourceIdx++; continue; } else if (colVal.cid == pColData->info.colId) { diff --git a/source/dnode/vnode/src/tqCommon/tqCommon.c b/source/dnode/vnode/src/tqCommon/tqCommon.c index 9bfdd70477..1b67dce9b0 100644 --- a/source/dnode/vnode/src/tqCommon/tqCommon.c +++ b/source/dnode/vnode/src/tqCommon/tqCommon.c @@ -929,6 +929,7 @@ static int32_t tqProcessTaskResumeImpl(void* handle, SStreamTask* pTask, int64_t } if (level == TASK_LEVEL__SOURCE && pTask->info.fillHistory && status == TASK_STATUS__SCAN_HISTORY) { + pTask->hTaskInfo.operatorOpen = false; streamStartScanHistoryAsync(pTask, igUntreated); } else if (level == TASK_LEVEL__SOURCE && (streamQueueGetNumOfItems(pTask->inputq.queue) == 0)) { tqScanWalAsync((STQ*)handle, false); diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index 81a136a0e3..849d2c791c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -584,13 +584,30 @@ struct STsdbSnapWriter { // APIs static int32_t tsdbSnapWriteTimeSeriesRow(STsdbSnapWriter* writer, SRowInfo* row) { - int32_t code = 0; - int32_t lino = 0; + int32_t code = 0; + int32_t lino = 0; + TABLEID tbid = {0}; + SMetaInfo info; while (writer->ctx->hasData) { - SRowInfo* row1 = tsdbIterMergerGetData(writer->ctx->dataIterMerger); - if (row1 == NULL) { - writer->ctx->hasData = false; + SRowInfo* row1; + for (;;) { + row1 = tsdbIterMergerGetData(writer->ctx->dataIterMerger); + if (row1 == NULL) { + writer->ctx->hasData = false; + } else if (row1->uid != tbid.uid) { + tbid.suid = row1->suid; + tbid.uid = row1->uid; + if (metaGetInfo(writer->tsdb->pVnode->pMeta, tbid.uid, &info, NULL) != 0) { + code = tsdbIterMergerSkipTableData(writer->ctx->dataIterMerger, &tbid); + TSDB_CHECK_CODE(code, lino, _exit); + continue; + } + } + break; + } + + if (writer->ctx->hasData == false) { break; } diff --git a/source/dnode/vnode/src/vnd/vnodeInitApi.c b/source/dnode/vnode/src/vnd/vnodeInitApi.c index aff7e4642b..16abe69def 100644 --- a/source/dnode/vnode/src/vnd/vnodeInitApi.c +++ b/source/dnode/vnode/src/vnd/vnodeInitApi.c @@ -128,12 +128,12 @@ void initTqAPI(SStoreTqReader* pTq) { pTq->tqReaderCurrentBlockConsumed = tqCurrentBlockConsumed; pTq->tqReaderGetWalReader = tqGetWalReader; // todo remove it - pTq->tqReaderRetrieveTaosXBlock = tqRetrieveTaosxBlock; // todo remove it +// pTq->tqReaderRetrieveTaosXBlock = tqRetrieveTaosxBlock; // todo remove it pTq->tqReaderSetSubmitMsg = tqReaderSetSubmitMsg; // todo remove it pTq->tqGetResultBlock = tqGetResultBlock; - pTq->tqReaderNextBlockFilterOut = tqNextDataBlockFilterOut; +// pTq->tqReaderNextBlockFilterOut = tqNextDataBlockFilterOut; pTq->tqGetResultBlockTime = tqGetResultBlockTime; pTq->tqGetStreamExecProgress = tqGetStreamExecInfo; diff --git a/source/libs/executor/CMakeLists.txt b/source/libs/executor/CMakeLists.txt index d2c39aba74..838233346e 100644 --- a/source/libs/executor/CMakeLists.txt +++ b/source/libs/executor/CMakeLists.txt @@ -3,7 +3,7 @@ aux_source_directory(src EXECUTOR_SRC) add_library(executor STATIC ${EXECUTOR_SRC}) target_link_libraries(executor - PRIVATE os util common function parser planner qcom scalar nodes index wal tdb + PRIVATE os util common function parser planner qcom scalar nodes index wal tdb geometry ) target_include_directories( diff --git a/source/libs/executor/inc/executorInt.h b/source/libs/executor/inc/executorInt.h index a280fd6e9b..5263546765 100644 --- a/source/libs/executor/inc/executorInt.h +++ b/source/libs/executor/inc/executorInt.h @@ -352,6 +352,8 @@ typedef struct STableMergeScanInfo { SSDataBlock* nextDurationBlocks[2]; bool rtnNextDurationBlocks; int32_t nextDurationBlocksIdx; + + bool bSortRowId; STmsSubTablesMergeInfo* pSubTablesMergeInfo; } STableMergeScanInfo; @@ -600,6 +602,8 @@ typedef struct SStreamIntervalOperatorInfo { bool recvPullover; SSDataBlock* pMidPulloverRes; bool clearState; + SArray* pMidPullDatas; + int32_t midDelIndex; } SStreamIntervalOperatorInfo; typedef struct SDataGroupInfo { diff --git a/source/libs/executor/inc/tsort.h b/source/libs/executor/inc/tsort.h index 436d1cefb8..ca799673ea 100644 --- a/source/libs/executor/inc/tsort.h +++ b/source/libs/executor/inc/tsort.h @@ -194,6 +194,9 @@ void tsortSetClosed(SSortHandle* pHandle); void tsortSetSingleTableMerge(SSortHandle* pHandle); void tsortSetAbortCheckFn(SSortHandle* pHandle, bool (*checkFn)(void* param), void* param); +int32_t tsortSetSortByRowId(SSortHandle* pHandle, int32_t extRowsSize); + +void tsortAppendTupleToBlock(SSortHandle* pHandle, SSDataBlock* pBlock, STupleHandle* pTupleHandle); /** * @brief comp the tuple with keyBuf, if not equal, new keys will be built in keyBuf, newLen will be stored in keyLen * @param [in] pSortCols cols to comp and build diff --git a/source/libs/executor/src/filloperator.c b/source/libs/executor/src/filloperator.c index ecc2526dd9..e1aa75d828 100644 --- a/source/libs/executor/src/filloperator.c +++ b/source/libs/executor/src/filloperator.c @@ -32,12 +32,6 @@ #include "operator.h" #include "querytask.h" - -#define FILL_POS_INVALID 0 -#define FILL_POS_START 1 -#define FILL_POS_MID 2 -#define FILL_POS_END 3 - typedef struct STimeRange { TSKEY skey; TSKEY ekey; @@ -474,1139 +468,3 @@ _error: taosMemoryFreeClear(pOperator); return NULL; } - -TSKEY getNextWindowTs(TSKEY ts, SInterval* pInterval) { - STimeWindow win = {.skey = ts, .ekey = ts}; - getNextTimeWindow(pInterval, &win, TSDB_ORDER_ASC); - return win.skey; -} - -TSKEY getPrevWindowTs(TSKEY ts, SInterval* pInterval) { - STimeWindow win = {.skey = ts, .ekey = ts}; - getNextTimeWindow(pInterval, &win, TSDB_ORDER_DESC); - return win.skey; -} - -void setRowCell(SColumnInfoData* pCol, int32_t rowId, const SResultCellData* pCell) { - colDataSetVal(pCol, rowId, pCell->pData, pCell->isNull); -} - -SResultCellData* getResultCell(SResultRowData* pRaw, int32_t index) { - if (!pRaw || !pRaw->pRowVal) { - return NULL; - } - char* pData = (char*)pRaw->pRowVal; - SResultCellData* pCell = pRaw->pRowVal; - for (int32_t i = 0; i < index; i++) { - pData += (pCell->bytes + sizeof(SResultCellData)); - pCell = (SResultCellData*)pData; - } - return pCell; -} - -void* destroyFillColumnInfo(SFillColInfo* pFillCol, int32_t start, int32_t end) { - for (int32_t i = start; i < end; i++) { - destroyExprInfo(pFillCol[i].pExpr, 1); - taosVariantDestroy(&pFillCol[i].fillVal); - } - taosMemoryFreeClear(pFillCol[start].pExpr); - taosMemoryFree(pFillCol); - return NULL; -} - -void* destroyStreamFillSupporter(SStreamFillSupporter* pFillSup) { - pFillSup->pAllColInfo = destroyFillColumnInfo(pFillSup->pAllColInfo, pFillSup->numOfFillCols, pFillSup->numOfAllCols); - tSimpleHashCleanup(pFillSup->pResMap); - pFillSup->pResMap = NULL; - cleanupExprSupp(&pFillSup->notFillExprSup); - if (pFillSup->cur.pRowVal != pFillSup->prev.pRowVal && pFillSup->cur.pRowVal != pFillSup->next.pRowVal) { - taosMemoryFree(pFillSup->cur.pRowVal); - } - taosMemoryFree(pFillSup->prev.pRowVal); - taosMemoryFree(pFillSup->next.pRowVal); - taosMemoryFree(pFillSup->nextNext.pRowVal); - - taosMemoryFree(pFillSup); - return NULL; -} - -void destroySPoint(void* ptr) { - SPoint* point = (SPoint*) ptr; - taosMemoryFreeClear(point->val); -} - -void* destroyStreamFillLinearInfo(SStreamFillLinearInfo* pFillLinear) { - taosArrayDestroyEx(pFillLinear->pEndPoints, destroySPoint); - taosArrayDestroyEx(pFillLinear->pNextEndPoints, destroySPoint); - taosMemoryFree(pFillLinear); - return NULL; -} -void* destroyStreamFillInfo(SStreamFillInfo* pFillInfo) { - if (pFillInfo->type == TSDB_FILL_SET_VALUE || pFillInfo->type == TSDB_FILL_SET_VALUE_F || - pFillInfo->type == TSDB_FILL_NULL || pFillInfo->type == TSDB_FILL_NULL_F) { - taosMemoryFreeClear(pFillInfo->pResRow->pRowVal); - taosMemoryFreeClear(pFillInfo->pResRow); - } - pFillInfo->pLinearInfo = destroyStreamFillLinearInfo(pFillInfo->pLinearInfo); - taosArrayDestroy(pFillInfo->delRanges); - taosMemoryFree(pFillInfo); - return NULL; -} - -static void destroyStreamFillOperatorInfo(void* param) { - SStreamFillOperatorInfo* pInfo = (SStreamFillOperatorInfo*)param; - pInfo->pFillInfo = destroyStreamFillInfo(pInfo->pFillInfo); - pInfo->pFillSup = destroyStreamFillSupporter(pInfo->pFillSup); - pInfo->pRes = blockDataDestroy(pInfo->pRes); - pInfo->pSrcBlock = blockDataDestroy(pInfo->pSrcBlock); - pInfo->pDelRes = blockDataDestroy(pInfo->pDelRes); - pInfo->matchInfo.pList = taosArrayDestroy(pInfo->matchInfo.pList); - taosMemoryFree(pInfo); -} - -static void resetFillWindow(SResultRowData* pRowData) { - pRowData->key = INT64_MIN; - taosMemoryFreeClear(pRowData->pRowVal); -} - -void resetPrevAndNextWindow(SStreamFillSupporter* pFillSup, void* pState, SStorageAPI* pAPI) { - if (pFillSup->cur.pRowVal != pFillSup->prev.pRowVal && pFillSup->cur.pRowVal != pFillSup->next.pRowVal) { - resetFillWindow(&pFillSup->cur); - } else { - pFillSup->cur.key = INT64_MIN; - pFillSup->cur.pRowVal = NULL; - } - resetFillWindow(&pFillSup->prev); - resetFillWindow(&pFillSup->next); - resetFillWindow(&pFillSup->nextNext); -} - -void getCurWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId, SStreamFillSupporter* pFillSup) { - SStorageAPI* pAPI = &pOperator->pTaskInfo->storageAPI; - - void* pState = pOperator->pTaskInfo->streamInfo.pState; - resetPrevAndNextWindow(pFillSup, pState, pAPI); - - SWinKey key = {.ts = ts, .groupId = groupId}; - int32_t curVLen = 0; - - int32_t code = pAPI->stateStore.streamStateFillGet(pState, &key, (void**)&pFillSup->cur.pRowVal, &curVLen); - ASSERT(code == TSDB_CODE_SUCCESS); - pFillSup->cur.key = key.ts; -} - -void getWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId, SStreamFillSupporter* pFillSup) { - SStorageAPI* pAPI = &pOperator->pTaskInfo->storageAPI; - void* pState = pOperator->pTaskInfo->streamInfo.pState; - resetPrevAndNextWindow(pFillSup, pState, pAPI); - - SWinKey key = {.ts = ts, .groupId = groupId}; - void* curVal = NULL; - int32_t curVLen = 0; - int32_t code = pAPI->stateStore.streamStateFillGet(pState, &key, (void**)&curVal, &curVLen); - ASSERT(code == TSDB_CODE_SUCCESS); - pFillSup->cur.key = key.ts; - pFillSup->cur.pRowVal = curVal; - - SStreamStateCur* pCur = pAPI->stateStore.streamStateFillSeekKeyPrev(pState, &key); - SWinKey preKey = {.ts = INT64_MIN, .groupId = groupId}; - void* preVal = NULL; - int32_t preVLen = 0; - code = pAPI->stateStore.streamStateGetGroupKVByCur(pCur, &preKey, (const void**)&preVal, &preVLen); - - if (code == TSDB_CODE_SUCCESS) { - pFillSup->prev.key = preKey.ts; - pFillSup->prev.pRowVal = preVal; - - code = pAPI->stateStore.streamStateCurNext(pState, pCur); - ASSERT(code == TSDB_CODE_SUCCESS); - - code = pAPI->stateStore.streamStateCurNext(pState, pCur); - if (code != TSDB_CODE_SUCCESS) { - pAPI->stateStore.streamStateFreeCur(pCur); - pCur = NULL; - } - } else { - pAPI->stateStore.streamStateFreeCur(pCur); - pCur = pAPI->stateStore.streamStateFillSeekKeyNext(pState, &key); - } - - SWinKey nextKey = {.ts = INT64_MIN, .groupId = groupId}; - void* nextVal = NULL; - int32_t nextVLen = 0; - code = pAPI->stateStore.streamStateGetGroupKVByCur(pCur, &nextKey, (const void**)&nextVal, &nextVLen); - if (code == TSDB_CODE_SUCCESS) { - pFillSup->next.key = nextKey.ts; - pFillSup->next.pRowVal = nextVal; - if (pFillSup->type == TSDB_FILL_PREV || pFillSup->type == TSDB_FILL_NEXT) { - code = pAPI->stateStore.streamStateCurNext(pState, pCur); - if (code == TSDB_CODE_SUCCESS) { - SWinKey nextNextKey = {.groupId = groupId}; - void* nextNextVal = NULL; - int32_t nextNextVLen = 0; - code = pAPI->stateStore.streamStateGetGroupKVByCur(pCur, &nextNextKey, (const void**)&nextNextVal, &nextNextVLen); - if (code == TSDB_CODE_SUCCESS) { - pFillSup->nextNext.key = nextNextKey.ts; - pFillSup->nextNext.pRowVal = nextNextVal; - } - } - } - } - pAPI->stateStore.streamStateFreeCur(pCur); -} - -static bool hasPrevWindow(SStreamFillSupporter* pFillSup) { return pFillSup->prev.key != INT64_MIN; } -static bool hasNextWindow(SStreamFillSupporter* pFillSup) { return pFillSup->next.key != INT64_MIN; } -static bool hasNextNextWindow(SStreamFillSupporter* pFillSup) { - return pFillSup->nextNext.key != INT64_MIN; - return false; -} - -static void transBlockToResultRow(const SSDataBlock* pBlock, int32_t rowId, TSKEY ts, SResultRowData* pRowVal) { - int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); - for (int32_t i = 0; i < numOfCols; ++i) { - SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, i); - SResultCellData* pCell = getResultCell(pRowVal, i); - if (!colDataIsNull_s(pColData, rowId)) { - pCell->isNull = false; - pCell->type = pColData->info.type; - pCell->bytes = pColData->info.bytes; - char* val = colDataGetData(pColData, rowId); - if (IS_VAR_DATA_TYPE(pCell->type)) { - memcpy(pCell->pData, val, varDataTLen(val)); - } else { - memcpy(pCell->pData, val, pCell->bytes); - } - } else { - pCell->isNull = true; - } - } - pRowVal->key = ts; -} - -static void calcDeltaData(SSDataBlock* pBlock, int32_t rowId, SResultRowData* pRowVal, SArray* pDelta, - SFillColInfo* pFillCol, int32_t numOfCol, int32_t winCount, int32_t order) { - for (int32_t i = 0; i < numOfCol; i++) { - if (!pFillCol[i].notFillCol) { - int32_t slotId = GET_DEST_SLOT_ID(pFillCol + i); - SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); - char* var = colDataGetData(pCol, rowId); - double start = 0; - GET_TYPED_DATA(start, double, pCol->info.type, var); - SResultCellData* pCell = getResultCell(pRowVal, slotId); - double end = 0; - GET_TYPED_DATA(end, double, pCell->type, pCell->pData); - double delta = 0; - if (order == TSDB_ORDER_ASC) { - delta = (end - start) / winCount; - } else { - delta = (start - end) / winCount; - } - taosArraySet(pDelta, slotId, &delta); - } - } -} - -static void calcRowDeltaData(SResultRowData* pEndRow, SArray* pEndPoins, SFillColInfo* pFillCol, - int32_t numOfCol) { - for (int32_t i = 0; i < numOfCol; i++) { - if (!pFillCol[i].notFillCol) { - int32_t slotId = GET_DEST_SLOT_ID(pFillCol + i); - SResultCellData* pECell = getResultCell(pEndRow, slotId); - SPoint* pPoint = taosArrayGet(pEndPoins, slotId); - pPoint->key = pEndRow->key; - memcpy(pPoint->val, pECell->pData, pECell->bytes); - } - } -} - -static void setFillInfoStart(TSKEY ts, SInterval* pInterval, SStreamFillInfo* pFillInfo) { - ts = taosTimeAdd(ts, pInterval->sliding, pInterval->slidingUnit, pInterval->precision); - pFillInfo->start = ts; -} - -static void setFillInfoEnd(TSKEY ts, SInterval* pInterval, SStreamFillInfo* pFillInfo) { - ts = taosTimeAdd(ts, pInterval->sliding * -1, pInterval->slidingUnit, pInterval->precision); - pFillInfo->end = ts; -} - -static void setFillKeyInfo(TSKEY start, TSKEY end, SInterval* pInterval, SStreamFillInfo* pFillInfo) { - setFillInfoStart(start, pInterval, pFillInfo); - pFillInfo->current = pFillInfo->start; - setFillInfoEnd(end, pInterval, pFillInfo); -} - -void setDeleteFillValueInfo(TSKEY start, TSKEY end, SStreamFillSupporter* pFillSup, SStreamFillInfo* pFillInfo) { - if (!hasPrevWindow(pFillSup) || !hasNextWindow(pFillSup)) { - pFillInfo->needFill = false; - return; - } - - TSKEY realStart = taosTimeAdd(pFillSup->prev.key, pFillSup->interval.sliding, pFillSup->interval.slidingUnit, - pFillSup->interval.precision); - - pFillInfo->needFill = true; - pFillInfo->start = realStart; - pFillInfo->current = pFillInfo->start; - pFillInfo->end = end; - pFillInfo->pos = FILL_POS_INVALID; - switch (pFillInfo->type) { - case TSDB_FILL_NULL: - case TSDB_FILL_NULL_F: - case TSDB_FILL_SET_VALUE: - case TSDB_FILL_SET_VALUE_F: - break; - case TSDB_FILL_PREV: - pFillInfo->pResRow = &pFillSup->prev; - break; - case TSDB_FILL_NEXT: - pFillInfo->pResRow = &pFillSup->next; - break; - case TSDB_FILL_LINEAR: { - setFillKeyInfo(pFillSup->prev.key, pFillSup->next.key, &pFillSup->interval, pFillInfo); - pFillInfo->pLinearInfo->hasNext = false; - pFillInfo->pLinearInfo->nextEnd = INT64_MIN; - calcRowDeltaData(&pFillSup->next, pFillInfo->pLinearInfo->pEndPoints, pFillSup->pAllColInfo, - pFillSup->numOfAllCols); - pFillInfo->pResRow = &pFillSup->prev; - pFillInfo->pLinearInfo->winIndex = 0; - } break; - default: - ASSERT(0); - break; - } -} - -void copyNotFillExpData(SStreamFillSupporter* pFillSup, SStreamFillInfo* pFillInfo) { - for (int32_t i = pFillSup->numOfFillCols; i < pFillSup->numOfAllCols; ++i) { - SFillColInfo* pFillCol = pFillSup->pAllColInfo + i; - int32_t slotId = GET_DEST_SLOT_ID(pFillCol); - SResultCellData* pCell = getResultCell(pFillInfo->pResRow, slotId); - SResultCellData* pCurCell = getResultCell(&pFillSup->cur, slotId); - pCell->isNull = pCurCell->isNull; - if (!pCurCell->isNull) { - memcpy(pCell->pData, pCurCell->pData, pCell->bytes); - } - } -} - -void setFillValueInfo(SSDataBlock* pBlock, TSKEY ts, int32_t rowId, SStreamFillSupporter* pFillSup, - SStreamFillInfo* pFillInfo) { - pFillInfo->preRowKey = pFillSup->cur.key; - if (!hasPrevWindow(pFillSup) && !hasNextWindow(pFillSup)) { - pFillInfo->needFill = false; - pFillInfo->pos = FILL_POS_START; - return; - } - TSKEY prevWKey = INT64_MIN; - TSKEY nextWKey = INT64_MIN; - if (hasPrevWindow(pFillSup)) { - prevWKey = pFillSup->prev.key; - } - if (hasNextWindow(pFillSup)) { - nextWKey = pFillSup->next.key; - } - - pFillInfo->needFill = true; - pFillInfo->pos = FILL_POS_INVALID; - switch (pFillInfo->type) { - case TSDB_FILL_NULL: - case TSDB_FILL_NULL_F: - case TSDB_FILL_SET_VALUE: - case TSDB_FILL_SET_VALUE_F: { - if (pFillSup->prev.key == pFillInfo->preRowKey) { - resetFillWindow(&pFillSup->prev); - } - if (hasPrevWindow(pFillSup) && hasNextWindow(pFillSup)) { - if (pFillSup->next.key == pFillInfo->nextRowKey) { - pFillInfo->preRowKey = INT64_MIN; - setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); - pFillInfo->pos = FILL_POS_END; - } else { - pFillInfo->needFill = false; - pFillInfo->pos = FILL_POS_START; - } - } else if (hasPrevWindow(pFillSup)) { - setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); - pFillInfo->pos = FILL_POS_END; - } else { - setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo); - pFillInfo->pos = FILL_POS_START; - } - copyNotFillExpData(pFillSup, pFillInfo); - } break; - case TSDB_FILL_PREV: { - if (hasNextWindow(pFillSup) && ((pFillSup->next.key != pFillInfo->nextRowKey) || - (pFillSup->next.key == pFillInfo->nextRowKey && hasNextNextWindow(pFillSup)) || - (pFillSup->next.key == pFillInfo->nextRowKey && !hasPrevWindow(pFillSup)))) { - setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo); - pFillInfo->pos = FILL_POS_START; - resetFillWindow(&pFillSup->prev); - pFillSup->prev.key = pFillSup->cur.key; - pFillSup->prev.pRowVal = pFillSup->cur.pRowVal; - } else if (hasPrevWindow(pFillSup)) { - setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); - pFillInfo->pos = FILL_POS_END; - pFillInfo->preRowKey = INT64_MIN; - } - pFillInfo->pResRow = &pFillSup->prev; - } break; - case TSDB_FILL_NEXT: { - if (hasPrevWindow(pFillSup)) { - setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); - pFillInfo->pos = FILL_POS_END; - resetFillWindow(&pFillSup->next); - pFillSup->next.key = pFillSup->cur.key; - pFillSup->next.pRowVal = pFillSup->cur.pRowVal; - pFillInfo->preRowKey = INT64_MIN; - } else { - ASSERT(hasNextWindow(pFillSup)); - setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo); - pFillInfo->pos = FILL_POS_START; - } - pFillInfo->pResRow = &pFillSup->next; - } break; - case TSDB_FILL_LINEAR: { - pFillInfo->pLinearInfo->winIndex = 0; - if (hasPrevWindow(pFillSup) && hasNextWindow(pFillSup)) { - setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); - pFillInfo->pos = FILL_POS_MID; - pFillInfo->pLinearInfo->nextEnd = nextWKey; - calcRowDeltaData(&pFillSup->cur, pFillInfo->pLinearInfo->pEndPoints, pFillSup->pAllColInfo, - pFillSup->numOfAllCols); - pFillInfo->pResRow = &pFillSup->prev; - - calcRowDeltaData(&pFillSup->next, pFillInfo->pLinearInfo->pNextEndPoints, pFillSup->pAllColInfo, - pFillSup->numOfAllCols); - pFillInfo->pLinearInfo->hasNext = true; - } else if (hasPrevWindow(pFillSup)) { - setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); - pFillInfo->pos = FILL_POS_END; - pFillInfo->pLinearInfo->nextEnd = INT64_MIN; - calcRowDeltaData(&pFillSup->cur, pFillInfo->pLinearInfo->pEndPoints, pFillSup->pAllColInfo, - pFillSup->numOfAllCols); - pFillInfo->pResRow = &pFillSup->prev; - pFillInfo->pLinearInfo->hasNext = false; - } else { - ASSERT(hasNextWindow(pFillSup)); - setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo); - pFillInfo->pos = FILL_POS_START; - pFillInfo->pLinearInfo->nextEnd = INT64_MIN; - calcRowDeltaData(&pFillSup->next, pFillInfo->pLinearInfo->pEndPoints, pFillSup->pAllColInfo, - pFillSup->numOfAllCols); - pFillInfo->pResRow = &pFillSup->cur; - pFillInfo->pLinearInfo->hasNext = false; - } - } break; - default: - ASSERT(0); - break; - } - ASSERT(pFillInfo->pos != FILL_POS_INVALID); -} - -static bool checkResult(SStreamFillSupporter* pFillSup, TSKEY ts, uint64_t groupId) { - SWinKey key = {.groupId = groupId, .ts = ts}; - if (tSimpleHashGet(pFillSup->pResMap, &key, sizeof(SWinKey)) != NULL) { - return false; - } - tSimpleHashPut(pFillSup->pResMap, &key, sizeof(SWinKey), NULL, 0); - return true; -} - -static bool buildFillResult(SResultRowData* pResRow, SStreamFillSupporter* pFillSup, TSKEY ts, SSDataBlock* pBlock) { - if (pBlock->info.rows >= pBlock->info.capacity) { - return false; - } - uint64_t groupId = pBlock->info.id.groupId; - if (pFillSup->hasDelete && !checkResult(pFillSup, ts, groupId)) { - return true; - } - for (int32_t i = 0; i < pFillSup->numOfAllCols; ++i) { - SFillColInfo* pFillCol = pFillSup->pAllColInfo + i; - int32_t slotId = GET_DEST_SLOT_ID(pFillCol); - SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, slotId); - SFillInfo tmpInfo = { - .currentKey = ts, - .order = TSDB_ORDER_ASC, - .interval = pFillSup->interval, - }; - bool filled = fillIfWindowPseudoColumn(&tmpInfo, pFillCol, pColData, pBlock->info.rows); - if (!filled) { - SResultCellData* pCell = getResultCell(pResRow, slotId); - setRowCell(pColData, pBlock->info.rows, pCell); - } - } - pBlock->info.rows++; - return true; -} - -static bool hasRemainCalc(SStreamFillInfo* pFillInfo) { - if (pFillInfo->current != INT64_MIN && pFillInfo->current <= pFillInfo->end) { - return true; - } - return false; -} - -static void doStreamFillNormal(SStreamFillSupporter* pFillSup, SStreamFillInfo* pFillInfo, SSDataBlock* pBlock) { - while (hasRemainCalc(pFillInfo) && pBlock->info.rows < pBlock->info.capacity) { - STimeWindow st = {.skey = pFillInfo->current, .ekey = pFillInfo->current}; - if (inWinRange(&pFillSup->winRange, &st)) { - buildFillResult(pFillInfo->pResRow, pFillSup, pFillInfo->current, pBlock); - } - pFillInfo->current = taosTimeAdd(pFillInfo->current, pFillSup->interval.sliding, pFillSup->interval.slidingUnit, - pFillSup->interval.precision); - } -} - -static void doStreamFillLinear(SStreamFillSupporter* pFillSup, SStreamFillInfo* pFillInfo, SSDataBlock* pBlock) { - while (hasRemainCalc(pFillInfo) && pBlock->info.rows < pBlock->info.capacity) { - uint64_t groupId = pBlock->info.id.groupId; - SWinKey key = {.groupId = groupId, .ts = pFillInfo->current}; - STimeWindow st = {.skey = pFillInfo->current, .ekey = pFillInfo->current}; - if ( ( pFillSup->hasDelete && !checkResult(pFillSup, pFillInfo->current, groupId) ) || !inWinRange(&pFillSup->winRange, &st) ) { - pFillInfo->current = taosTimeAdd(pFillInfo->current, pFillSup->interval.sliding, pFillSup->interval.slidingUnit, - pFillSup->interval.precision); - pFillInfo->pLinearInfo->winIndex++; - continue; - } - pFillInfo->pLinearInfo->winIndex++; - for (int32_t i = 0; i < pFillSup->numOfAllCols; ++i) { - SFillColInfo* pFillCol = pFillSup->pAllColInfo + i; - SFillInfo tmp = { - .currentKey = pFillInfo->current, - .order = TSDB_ORDER_ASC, - .interval = pFillSup->interval, - }; - - int32_t slotId = GET_DEST_SLOT_ID(pFillCol); - SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, slotId); - int16_t type = pColData->info.type; - SResultCellData* pCell = getResultCell(pFillInfo->pResRow, slotId); - int32_t index = pBlock->info.rows; - if (pFillCol->notFillCol) { - bool filled = fillIfWindowPseudoColumn(&tmp, pFillCol, pColData, index); - if (!filled) { - setRowCell(pColData, index, pCell); - } - } else { - if (IS_VAR_DATA_TYPE(type) || type == TSDB_DATA_TYPE_BOOL || pCell->isNull) { - colDataSetNULL(pColData, index); - continue; - } - SPoint* pEnd = taosArrayGet(pFillInfo->pLinearInfo->pEndPoints, slotId); - double vCell = 0; - SPoint start = {0}; - start.key = pFillInfo->pResRow->key; - start.val = pCell->pData; - - SPoint cur = {0}; - cur.key = pFillInfo->current; - cur.val = taosMemoryCalloc(1, pCell->bytes); - taosGetLinearInterpolationVal(&cur, pCell->type, &start, pEnd, pCell->type); - colDataSetVal(pColData, index, (const char*)cur.val, false); - destroySPoint(&cur); - } - } - pFillInfo->current = taosTimeAdd(pFillInfo->current, pFillSup->interval.sliding, pFillSup->interval.slidingUnit, - pFillSup->interval.precision); - pBlock->info.rows++; - } -} - -static void keepResultInDiscBuf(SOperatorInfo* pOperator, uint64_t groupId, SResultRowData* pRow, int32_t len) { - SStorageAPI* pAPI = &pOperator->pTaskInfo->storageAPI; - - SWinKey key = {.groupId = groupId, .ts = pRow->key}; - int32_t code = pAPI->stateStore.streamStateFillPut(pOperator->pTaskInfo->streamInfo.pState, &key, pRow->pRowVal, len); - qDebug("===stream===fill operator save key ts:%" PRId64 " group id:%" PRIu64 " code:%d", key.ts, key.groupId, code); - ASSERT(code == TSDB_CODE_SUCCESS); -} - -static void doStreamFillRange(SStreamFillInfo* pFillInfo, SStreamFillSupporter* pFillSup, SSDataBlock* pRes) { - if (pFillInfo->needFill == false) { - buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes); - return; - } - - if (pFillInfo->pos == FILL_POS_START) { - if (buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes)) { - pFillInfo->pos = FILL_POS_INVALID; - } - } - if (pFillInfo->type != TSDB_FILL_LINEAR) { - doStreamFillNormal(pFillSup, pFillInfo, pRes); - } else { - doStreamFillLinear(pFillSup, pFillInfo, pRes); - - if (pFillInfo->pos == FILL_POS_MID) { - if (buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes)) { - pFillInfo->pos = FILL_POS_INVALID; - } - } - - if (pFillInfo->current > pFillInfo->end && pFillInfo->pLinearInfo->hasNext) { - pFillInfo->pLinearInfo->hasNext = false; - pFillInfo->pLinearInfo->winIndex = 0; - taosArraySwap(pFillInfo->pLinearInfo->pEndPoints, pFillInfo->pLinearInfo->pNextEndPoints); - pFillInfo->pResRow = &pFillSup->cur; - setFillKeyInfo(pFillSup->cur.key, pFillInfo->pLinearInfo->nextEnd, &pFillSup->interval, pFillInfo); - doStreamFillLinear(pFillSup, pFillInfo, pRes); - } - } - if (pFillInfo->pos == FILL_POS_END) { - if (buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes)) { - pFillInfo->pos = FILL_POS_INVALID; - } - } -} - -void keepBlockRowInDiscBuf(SOperatorInfo* pOperator, SStreamFillInfo* pFillInfo, SSDataBlock* pBlock, TSKEY* tsCol, - int32_t rowId, uint64_t groupId, int32_t rowSize) { - TSKEY ts = tsCol[rowId]; - pFillInfo->nextRowKey = ts; - SResultRowData tmpNextRow = {.key = ts}; - tmpNextRow.pRowVal = taosMemoryCalloc(1, rowSize); - transBlockToResultRow(pBlock, rowId, ts, &tmpNextRow); - keepResultInDiscBuf(pOperator, groupId, &tmpNextRow, rowSize); - taosMemoryFreeClear(tmpNextRow.pRowVal); -} - -static void doFillResults(SOperatorInfo* pOperator, SStreamFillSupporter* pFillSup, SStreamFillInfo* pFillInfo, - SSDataBlock* pBlock, TSKEY* tsCol, int32_t rowId, SSDataBlock* pRes) { - uint64_t groupId = pBlock->info.id.groupId; - getWindowFromDiscBuf(pOperator, tsCol[rowId], groupId, pFillSup); - if (pFillSup->prev.key == pFillInfo->preRowKey) { - resetFillWindow(&pFillSup->prev); - } - setFillValueInfo(pBlock, tsCol[rowId], rowId, pFillSup, pFillInfo); - doStreamFillRange(pFillInfo, pFillSup, pRes); -} - -static void doStreamFillImpl(SOperatorInfo* pOperator) { - SStreamFillOperatorInfo* pInfo = pOperator->info; - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - SStreamFillSupporter* pFillSup = pInfo->pFillSup; - SStreamFillInfo* pFillInfo = pInfo->pFillInfo; - SSDataBlock* pBlock = pInfo->pSrcBlock; - uint64_t groupId = pBlock->info.id.groupId; - SSDataBlock* pRes = pInfo->pRes; - SColumnInfoData* pTsCol = taosArrayGet(pInfo->pSrcBlock->pDataBlock, pInfo->primaryTsCol); - TSKEY* tsCol = (TSKEY*)pTsCol->pData; - pRes->info.id.groupId = groupId; - pInfo->srcRowIndex++; - - if (pInfo->srcRowIndex == 0) { - keepBlockRowInDiscBuf(pOperator, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex, groupId, pFillSup->rowSize); - pInfo->srcRowIndex++; - } - - while (pInfo->srcRowIndex < pBlock->info.rows) { - TSKEY ts = tsCol[pInfo->srcRowIndex]; - keepBlockRowInDiscBuf(pOperator, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex, groupId, pFillSup->rowSize); - doFillResults(pOperator, pFillSup, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex - 1, pRes); - if (pInfo->pRes->info.rows == pInfo->pRes->info.capacity) { - blockDataUpdateTsWindow(pRes, pInfo->primaryTsCol); - return; - } - pInfo->srcRowIndex++; - } - doFillResults(pOperator, pFillSup, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex - 1, pRes); - blockDataUpdateTsWindow(pRes, pInfo->primaryTsCol); - blockDataCleanup(pInfo->pSrcBlock); -} - -static void buildDeleteRange(SOperatorInfo* pOp, TSKEY start, TSKEY end, uint64_t groupId, SSDataBlock* delRes) { - SStorageAPI* pAPI = &pOp->pTaskInfo->storageAPI; - void* pState = pOp->pTaskInfo->streamInfo.pState; - - SSDataBlock* pBlock = delRes; - SColumnInfoData* pStartCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); - SColumnInfoData* pEndCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX); - SColumnInfoData* pUidCol = taosArrayGet(pBlock->pDataBlock, UID_COLUMN_INDEX); - SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); - SColumnInfoData* pCalStartCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX); - SColumnInfoData* pCalEndCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX); - SColumnInfoData* pTbNameCol = taosArrayGet(pBlock->pDataBlock, TABLE_NAME_COLUMN_INDEX); - colDataSetVal(pStartCol, pBlock->info.rows, (const char*)&start, false); - colDataSetVal(pEndCol, pBlock->info.rows, (const char*)&end, false); - colDataSetNULL(pUidCol, pBlock->info.rows); - colDataSetVal(pGroupCol, pBlock->info.rows, (const char*)&groupId, false); - colDataSetNULL(pCalStartCol, pBlock->info.rows); - colDataSetNULL(pCalEndCol, pBlock->info.rows); - - SColumnInfoData* pTableCol = taosArrayGet(pBlock->pDataBlock, TABLE_NAME_COLUMN_INDEX); - - void* tbname = NULL; - pAPI->stateStore.streamStateGetParName(pOp->pTaskInfo->streamInfo.pState, groupId, &tbname); - if (tbname == NULL) { - colDataSetNULL(pTableCol, pBlock->info.rows); - } else { - char parTbName[VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN]; - STR_WITH_MAXSIZE_TO_VARSTR(parTbName, tbname, sizeof(parTbName)); - colDataSetVal(pTableCol, pBlock->info.rows, (const char*)parTbName, false); - pAPI->stateStore.streamStateFreeVal(tbname); - } - - pBlock->info.rows++; -} - -static void buildDeleteResult(SOperatorInfo* pOperator, TSKEY startTs, TSKEY endTs, uint64_t groupId, - SSDataBlock* delRes) { - SStreamFillOperatorInfo* pInfo = pOperator->info; - SStreamFillSupporter* pFillSup = pInfo->pFillSup; - if (hasPrevWindow(pFillSup)) { - TSKEY start = getNextWindowTs(pFillSup->prev.key, &pFillSup->interval); - buildDeleteRange(pOperator, start, endTs, groupId, delRes); - } else if (hasNextWindow(pFillSup)) { - TSKEY end = getPrevWindowTs(pFillSup->next.key, &pFillSup->interval); - buildDeleteRange(pOperator, startTs, end, groupId, delRes); - } else { - buildDeleteRange(pOperator, startTs, endTs, groupId, delRes); - } -} - -static void doDeleteFillResultImpl(SOperatorInfo* pOperator, TSKEY startTs, TSKEY endTs, uint64_t groupId) { - SStorageAPI* pAPI = &pOperator->pTaskInfo->storageAPI; - SStreamFillOperatorInfo* pInfo = pOperator->info; - getWindowFromDiscBuf(pOperator, startTs, groupId, pInfo->pFillSup); - setDeleteFillValueInfo(startTs, endTs, pInfo->pFillSup, pInfo->pFillInfo); - SWinKey key = {.ts = startTs, .groupId = groupId}; - if (!pInfo->pFillInfo->needFill) { - pAPI->stateStore.streamStateFillDel(pOperator->pTaskInfo->streamInfo.pState, &key); - buildDeleteResult(pOperator, startTs, endTs, groupId, pInfo->pDelRes); - } else { - STimeRange tw = { - .skey = startTs, - .ekey = endTs, - .groupId = groupId, - }; - taosArrayPush(pInfo->pFillInfo->delRanges, &tw); - while (key.ts <= endTs) { - key.ts = taosTimeAdd(key.ts, pInfo->pFillSup->interval.sliding, pInfo->pFillSup->interval.slidingUnit, - pInfo->pFillSup->interval.precision); - tSimpleHashPut(pInfo->pFillSup->pResMap, &key, sizeof(SWinKey), NULL, 0); - } - } -} - -static void doDeleteFillFinalize(SOperatorInfo* pOperator) { - SStorageAPI* pAPI = &pOperator->pTaskInfo->storageAPI; - - SStreamFillOperatorInfo* pInfo = pOperator->info; - SStreamFillInfo* pFillInfo = pInfo->pFillInfo; - int32_t size = taosArrayGetSize(pFillInfo->delRanges); - tSimpleHashClear(pInfo->pFillSup->pResMap); - for (; pFillInfo->delIndex < size; pFillInfo->delIndex++) { - STimeRange* range = taosArrayGet(pFillInfo->delRanges, pFillInfo->delIndex); - if (pInfo->pRes->info.id.groupId != 0 && pInfo->pRes->info.id.groupId != range->groupId) { - return; - } - getWindowFromDiscBuf(pOperator, range->skey, range->groupId, pInfo->pFillSup); - setDeleteFillValueInfo(range->skey, range->ekey, pInfo->pFillSup, pInfo->pFillInfo); - if (pInfo->pFillInfo->needFill) { - doStreamFillRange(pInfo->pFillInfo, pInfo->pFillSup, pInfo->pRes); - pInfo->pRes->info.id.groupId = range->groupId; - } - SWinKey key = {.ts = range->skey, .groupId = range->groupId}; - pAPI->stateStore.streamStateFillDel(pOperator->pTaskInfo->streamInfo.pState, &key); - } -} - -static void doDeleteFillResult(SOperatorInfo* pOperator) { - SStorageAPI* pAPI = &pOperator->pTaskInfo->storageAPI; - - SStreamFillOperatorInfo* pInfo = pOperator->info; - SStreamFillInfo* pFillInfo = pInfo->pFillInfo; - SSDataBlock* pBlock = pInfo->pSrcDelBlock; - - SColumnInfoData* pStartCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); - TSKEY* tsStarts = (TSKEY*)pStartCol->pData; - SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); - uint64_t* groupIds = (uint64_t*)pGroupCol->pData; - while (pInfo->srcDelRowIndex < pBlock->info.rows) { - TSKEY ts = tsStarts[pInfo->srcDelRowIndex]; - TSKEY endTs = ts; - uint64_t groupId = groupIds[pInfo->srcDelRowIndex]; - SWinKey key = {.ts = ts, .groupId = groupId}; - SStreamStateCur* pCur = pAPI->stateStore.streamStateGetAndCheckCur(pOperator->pTaskInfo->streamInfo.pState, &key); - - if (!pCur) { - pInfo->srcDelRowIndex++; - continue; - } - - SWinKey nextKey = {.groupId = groupId, .ts = ts}; - while (pInfo->srcDelRowIndex < pBlock->info.rows) { - TSKEY delTs = tsStarts[pInfo->srcDelRowIndex]; - uint64_t delGroupId = groupIds[pInfo->srcDelRowIndex]; - int32_t code = TSDB_CODE_SUCCESS; - if (groupId != delGroupId) { - break; - } - if (delTs > nextKey.ts) { - break; - } - - SWinKey delKey = {.groupId = delGroupId, .ts = delTs}; - if (delTs == nextKey.ts) { - code = pAPI->stateStore.streamStateCurNext(pOperator->pTaskInfo->streamInfo.pState, pCur); - if (code == TSDB_CODE_SUCCESS) { - code = pAPI->stateStore.streamStateGetGroupKVByCur(pCur, &nextKey, NULL, NULL); - } - // ts will be deleted later - if (delTs != ts) { - pAPI->stateStore.streamStateFillDel(pOperator->pTaskInfo->streamInfo.pState, &delKey); - pAPI->stateStore.streamStateFreeCur(pCur); - pCur = pAPI->stateStore.streamStateGetAndCheckCur(pOperator->pTaskInfo->streamInfo.pState, &nextKey); - } - endTs = TMAX(delTs, nextKey.ts - 1); - if (code != TSDB_CODE_SUCCESS) { - break; - } - } - pInfo->srcDelRowIndex++; - } - - pAPI->stateStore.streamStateFreeCur(pCur); - doDeleteFillResultImpl(pOperator, ts, endTs, groupId); - } - - pFillInfo->current = pFillInfo->end + 1; -} - -static void resetStreamFillInfo(SStreamFillOperatorInfo* pInfo) { - tSimpleHashClear(pInfo->pFillSup->pResMap); - pInfo->pFillSup->hasDelete = false; - taosArrayClear(pInfo->pFillInfo->delRanges); - pInfo->pFillInfo->delIndex = 0; -} - -static void doApplyStreamScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pSrcBlock, SSDataBlock* pDstBlock) { - SStreamFillOperatorInfo* pInfo = pOperator->info; - SExprSupp* pSup = &pOperator->exprSupp; - - blockDataCleanup(pDstBlock); - blockDataEnsureCapacity(pDstBlock, pSrcBlock->info.rows); - setInputDataBlock(pSup, pSrcBlock, TSDB_ORDER_ASC, MAIN_SCAN, false); - projectApplyFunctions(pSup->pExprInfo, pDstBlock, pSrcBlock, pSup->pCtx, pSup->numOfExprs, NULL); - - pDstBlock->info.rows = 0; - pSup = &pInfo->pFillSup->notFillExprSup; - setInputDataBlock(pSup, pSrcBlock, TSDB_ORDER_ASC, MAIN_SCAN, false); - projectApplyFunctions(pSup->pExprInfo, pDstBlock, pSrcBlock, pSup->pCtx, pSup->numOfExprs, NULL); - pDstBlock->info.id.groupId = pSrcBlock->info.id.groupId; - - blockDataUpdateTsWindow(pDstBlock, pInfo->primaryTsCol); -} - -static SSDataBlock* doStreamFill(SOperatorInfo* pOperator) { - SStreamFillOperatorInfo* pInfo = pOperator->info; - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - - if (pOperator->status == OP_EXEC_DONE) { - return NULL; - } - blockDataCleanup(pInfo->pRes); - if (hasRemainCalc(pInfo->pFillInfo) || - (pInfo->pFillInfo->pos != FILL_POS_INVALID && pInfo->pFillInfo->needFill == true)) { - doStreamFillRange(pInfo->pFillInfo, pInfo->pFillSup, pInfo->pRes); - if (pInfo->pRes->info.rows > 0) { - printDataBlock(pInfo->pRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); - return pInfo->pRes; - } - } - if (pOperator->status == OP_RES_TO_RETURN) { - doDeleteFillFinalize(pOperator); - if (pInfo->pRes->info.rows > 0) { - printDataBlock(pInfo->pRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); - return pInfo->pRes; - } - setOperatorCompleted(pOperator); - resetStreamFillInfo(pInfo); - return NULL; - } - - SSDataBlock* fillResult = NULL; - SOperatorInfo* downstream = pOperator->pDownstream[0]; - while (1) { - if (pInfo->srcRowIndex >= pInfo->pSrcBlock->info.rows || pInfo->pSrcBlock->info.rows == 0) { - // If there are delete datablocks, we receive them first. - SSDataBlock* pBlock = getNextBlockFromDownstream(pOperator, 0); - if (pBlock == NULL) { - pOperator->status = OP_RES_TO_RETURN; - pInfo->pFillInfo->preRowKey = INT64_MIN; - if (pInfo->pRes->info.rows > 0) { - printDataBlock(pInfo->pRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); - return pInfo->pRes; - } - break; - } - printSpecDataBlock(pBlock, getStreamOpName(pOperator->operatorType), "recv", GET_TASKID(pTaskInfo)); - - if (pInfo->pFillInfo->curGroupId != pBlock->info.id.groupId) { - pInfo->pFillInfo->curGroupId = pBlock->info.id.groupId; - pInfo->pFillInfo->preRowKey = INT64_MIN; - } - - pInfo->pFillSup->winRange = pTaskInfo->streamInfo.fillHistoryWindow; - if (pInfo->pFillSup->winRange.ekey <= 0) { - pInfo->pFillSup->winRange.ekey = INT64_MAX; - } - - switch (pBlock->info.type) { - case STREAM_RETRIEVE: - return pBlock; - case STREAM_DELETE_RESULT: { - pInfo->pSrcDelBlock = pBlock; - pInfo->srcDelRowIndex = 0; - blockDataCleanup(pInfo->pDelRes); - pInfo->pFillSup->hasDelete = true; - doDeleteFillResult(pOperator); - if (pInfo->pDelRes->info.rows > 0) { - printDataBlock(pInfo->pDelRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); - return pInfo->pDelRes; - } - continue; - } break; - case STREAM_NORMAL: - case STREAM_INVALID: - case STREAM_PULL_DATA: { - doApplyStreamScalarCalculation(pOperator, pBlock, pInfo->pSrcBlock); - memcpy(pInfo->pSrcBlock->info.parTbName, pBlock->info.parTbName, TSDB_TABLE_NAME_LEN); - pInfo->srcRowIndex = -1; - } break; - case STREAM_CHECKPOINT: - case STREAM_CREATE_CHILD_TABLE: { - return pBlock; - } break; - default: - ASSERTS(false, "invalid SSDataBlock type"); - } - } - - doStreamFillImpl(pOperator); - doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, &pInfo->matchInfo); - memcpy(pInfo->pRes->info.parTbName, pInfo->pSrcBlock->info.parTbName, TSDB_TABLE_NAME_LEN); - pOperator->resultInfo.totalRows += pInfo->pRes->info.rows; - if (pInfo->pRes->info.rows > 0) { - break; - } - } - if (pOperator->status == OP_RES_TO_RETURN) { - doDeleteFillFinalize(pOperator); - } - - if (pInfo->pRes->info.rows == 0) { - setOperatorCompleted(pOperator); - resetStreamFillInfo(pInfo); - return NULL; - } - - pOperator->resultInfo.totalRows += pInfo->pRes->info.rows; - printDataBlock(pInfo->pRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); - return pInfo->pRes; -} - -static int32_t initResultBuf(SStreamFillSupporter* pFillSup) { - pFillSup->rowSize = sizeof(SResultCellData) * pFillSup->numOfAllCols; - for (int i = 0; i < pFillSup->numOfAllCols; i++) { - SFillColInfo* pCol = &pFillSup->pAllColInfo[i]; - SResSchema* pSchema = &pCol->pExpr->base.resSchema; - pFillSup->rowSize += pSchema->bytes; - } - pFillSup->next.key = INT64_MIN; - pFillSup->nextNext.key = INT64_MIN; - pFillSup->prev.key = INT64_MIN; - pFillSup->cur.key = INT64_MIN; - pFillSup->next.pRowVal = NULL; - pFillSup->nextNext.pRowVal = NULL; - pFillSup->prev.pRowVal = NULL; - pFillSup->cur.pRowVal = NULL; - - return TSDB_CODE_SUCCESS; -} - -static SStreamFillSupporter* initStreamFillSup(SStreamFillPhysiNode* pPhyFillNode, SInterval* pInterval, - SExprInfo* pFillExprInfo, int32_t numOfFillCols, SStorageAPI* pAPI) { - SStreamFillSupporter* pFillSup = taosMemoryCalloc(1, sizeof(SStreamFillSupporter)); - if (!pFillSup) { - return NULL; - } - pFillSup->numOfFillCols = numOfFillCols; - int32_t numOfNotFillCols = 0; - SExprInfo* noFillExprInfo = createExprInfo(pPhyFillNode->pNotFillExprs, NULL, &numOfNotFillCols); - pFillSup->pAllColInfo = createFillColInfo(pFillExprInfo, pFillSup->numOfFillCols, noFillExprInfo, numOfNotFillCols, - (const SNodeListNode*)(pPhyFillNode->pValues)); - pFillSup->type = convertFillType(pPhyFillNode->mode); - pFillSup->numOfAllCols = pFillSup->numOfFillCols + numOfNotFillCols; - pFillSup->interval = *pInterval; - pFillSup->pAPI = pAPI; - - int32_t code = initResultBuf(pFillSup); - if (code != TSDB_CODE_SUCCESS) { - destroyStreamFillSupporter(pFillSup); - return NULL; - } - - SExprInfo* noFillExpr = createExprInfo(pPhyFillNode->pNotFillExprs, NULL, &numOfNotFillCols); - code = initExprSupp(&pFillSup->notFillExprSup, noFillExpr, numOfNotFillCols, &pAPI->functionStore); - if (code != TSDB_CODE_SUCCESS) { - destroyStreamFillSupporter(pFillSup); - return NULL; - } - - _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); - pFillSup->pResMap = tSimpleHashInit(16, hashFn); - pFillSup->hasDelete = false; - return pFillSup; -} - -SStreamFillInfo* initStreamFillInfo(SStreamFillSupporter* pFillSup, SSDataBlock* pRes) { - SStreamFillInfo* pFillInfo = taosMemoryCalloc(1, sizeof(SStreamFillInfo)); - pFillInfo->start = INT64_MIN; - pFillInfo->current = INT64_MIN; - pFillInfo->end = INT64_MIN; - pFillInfo->preRowKey = INT64_MIN; - pFillInfo->needFill = false; - pFillInfo->pLinearInfo = taosMemoryCalloc(1, sizeof(SStreamFillLinearInfo)); - pFillInfo->pLinearInfo->hasNext = false; - pFillInfo->pLinearInfo->nextEnd = INT64_MIN; - pFillInfo->pLinearInfo->pEndPoints = NULL; - pFillInfo->pLinearInfo->pNextEndPoints = NULL; - if (pFillSup->type == TSDB_FILL_LINEAR) { - pFillInfo->pLinearInfo->pEndPoints = taosArrayInit(pFillSup->numOfAllCols, sizeof(SPoint)); - pFillInfo->pLinearInfo->pNextEndPoints = taosArrayInit(pFillSup->numOfAllCols, sizeof(SPoint)); - for (int32_t i = 0; i < pFillSup->numOfAllCols; i++) { - SColumnInfoData* pColData = taosArrayGet(pRes->pDataBlock, i); - SPoint value = {0}; - value.val = taosMemoryCalloc(1, pColData->info.bytes); - taosArrayPush(pFillInfo->pLinearInfo->pEndPoints, &value); - - value.val = taosMemoryCalloc(1, pColData->info.bytes); - taosArrayPush(pFillInfo->pLinearInfo->pNextEndPoints, &value); - } - } - pFillInfo->pLinearInfo->winIndex = 0; - - pFillInfo->pResRow = NULL; - if (pFillSup->type == TSDB_FILL_SET_VALUE || pFillSup->type == TSDB_FILL_SET_VALUE_F || - pFillSup->type == TSDB_FILL_NULL || pFillSup->type == TSDB_FILL_NULL_F) { - pFillInfo->pResRow = taosMemoryCalloc(1, sizeof(SResultRowData)); - pFillInfo->pResRow->key = INT64_MIN; - pFillInfo->pResRow->pRowVal = taosMemoryCalloc(1, pFillSup->rowSize); - for (int32_t i = 0; i < pFillSup->numOfAllCols; ++i) { - SColumnInfoData* pColData = taosArrayGet(pRes->pDataBlock, i); - SResultCellData* pCell = getResultCell(pFillInfo->pResRow, i); - pCell->bytes = pColData->info.bytes; - pCell->type = pColData->info.type; - } - } - - pFillInfo->type = pFillSup->type; - pFillInfo->delRanges = taosArrayInit(16, sizeof(STimeRange)); - pFillInfo->delIndex = 0; - pFillInfo->curGroupId = 0; - return pFillInfo; -} - -SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFillPhysiNode* pPhyFillNode, - SExecTaskInfo* pTaskInfo) { - SStreamFillOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamFillOperatorInfo)); - SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); - if (pInfo == NULL || pOperator == NULL) { - goto _error; - } - - SInterval* pInterval = &((SStreamIntervalOperatorInfo*)downstream->info)->interval; - int32_t numOfFillCols = 0; - SExprInfo* pFillExprInfo = createExprInfo(pPhyFillNode->pFillExprs, NULL, &numOfFillCols); - pInfo->pFillSup = initStreamFillSup(pPhyFillNode, pInterval, pFillExprInfo, numOfFillCols, &pTaskInfo->storageAPI); - if (!pInfo->pFillSup) { - goto _error; - } - - initResultSizeInfo(&pOperator->resultInfo, 4096); - pInfo->pRes = createDataBlockFromDescNode(pPhyFillNode->node.pOutputDataBlockDesc); - pInfo->pSrcBlock = createDataBlockFromDescNode(pPhyFillNode->node.pOutputDataBlockDesc); - blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity); - blockDataEnsureCapacity(pInfo->pSrcBlock, pOperator->resultInfo.capacity); - - pInfo->pFillInfo = initStreamFillInfo(pInfo->pFillSup, pInfo->pRes); - if (!pInfo->pFillInfo) { - goto _error; - } - - if (pInfo->pFillInfo->type == TSDB_FILL_SET_VALUE || pInfo->pFillInfo->type == TSDB_FILL_SET_VALUE_F) { - for (int32_t i = 0; i < pInfo->pFillSup->numOfAllCols; ++i) { - SFillColInfo* pFillCol = pInfo->pFillSup->pAllColInfo + i; - int32_t slotId = GET_DEST_SLOT_ID(pFillCol); - SResultCellData* pCell = getResultCell(pInfo->pFillInfo->pResRow, slotId); - SVariant* pVar = &(pFillCol->fillVal); - if (pCell->type == TSDB_DATA_TYPE_FLOAT) { - float v = 0; - GET_TYPED_DATA(v, float, pVar->nType, &pVar->i); - SET_TYPED_DATA(pCell->pData, pCell->type, v); - } else if (IS_FLOAT_TYPE(pCell->type)) { - double v = 0; - GET_TYPED_DATA(v, double, pVar->nType, &pVar->i); - SET_TYPED_DATA(pCell->pData, pCell->type, v); - } else if (IS_INTEGER_TYPE(pCell->type)) { - int64_t v = 0; - GET_TYPED_DATA(v, int64_t, pVar->nType, &pVar->i); - SET_TYPED_DATA(pCell->pData, pCell->type, v); - } else { - pCell->isNull = true; - } - } - } else if (pInfo->pFillInfo->type == TSDB_FILL_NULL || pInfo->pFillInfo->type == TSDB_FILL_NULL_F) { - for (int32_t i = 0; i < pInfo->pFillSup->numOfAllCols; ++i) { - SFillColInfo* pFillCol = pInfo->pFillSup->pAllColInfo + i; - int32_t slotId = GET_DEST_SLOT_ID(pFillCol); - SResultCellData* pCell = getResultCell(pInfo->pFillInfo->pResRow, slotId); - pCell->isNull = true; - } - } - - pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT); - blockDataEnsureCapacity(pInfo->pDelRes, pOperator->resultInfo.capacity); - - pInfo->primaryTsCol = ((STargetNode*)pPhyFillNode->pWStartTs)->slotId; - pInfo->primarySrcSlotId = ((SColumnNode*)((STargetNode*)pPhyFillNode->pWStartTs)->pExpr)->slotId; - - int32_t numOfOutputCols = 0; - int32_t code = extractColMatchInfo(pPhyFillNode->pFillExprs, pPhyFillNode->node.pOutputDataBlockDesc, - &numOfOutputCols, COL_MATCH_FROM_SLOT_ID, &pInfo->matchInfo); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - code = filterInitFromNode((SNode*)pPhyFillNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - code = initExprSupp(&pOperator->exprSupp, pFillExprInfo, numOfFillCols, &pTaskInfo->storageAPI.functionStore); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - pInfo->srcRowIndex = -1; - setOperatorInfo(pOperator, "StreamFillOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL, false, OP_NOT_OPENED, pInfo, - pTaskInfo); - pOperator->fpSet = - createOperatorFpSet(optrDummyOpenFn, doStreamFill, NULL, destroyStreamFillOperatorInfo, optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL); - setOperatorStreamStateFn(pOperator, streamOpReleaseState, streamOpReloadState); - - code = appendDownstream(pOperator, &downstream, 1); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - return pOperator; - -_error: - destroyStreamFillOperatorInfo(pInfo); - taosMemoryFreeClear(pOperator); - pTaskInfo->code = code; - return NULL; -} diff --git a/source/libs/executor/src/mergeoperator.c b/source/libs/executor/src/mergeoperator.c index 093b6ab11e..c1a51898bc 100755 --- a/source/libs/executor/src/mergeoperator.c +++ b/source/libs/executor/src/mergeoperator.c @@ -269,6 +269,7 @@ SSDataBlock* doNonSortMerge(SOperatorInfo* pOperator) { SMultiwayMergeOperatorInfo* pInfo = pOperator->info; SNonSortMergeInfo* pNonSortMerge = &pInfo->nsortMergeInfo; SSDataBlock* pBlock = NULL; + SSDataBlock* pRes = pInfo->binfo.pRes; qDebug("start to merge no sorted rows, %s", GET_TASKID(pTaskInfo)); @@ -278,13 +279,18 @@ SSDataBlock* doNonSortMerge(SOperatorInfo* pOperator) { if (NULL == pBlock) { TSWAP(pNonSortMerge->pSourceStatus[pNonSortMerge->sourceWorkIdx], pNonSortMerge->pSourceStatus[idx]); pNonSortMerge->sourceWorkIdx++; - idx = NON_SORT_NEXT_SRC(pNonSortMerge, idx); + idx = NON_SORT_NEXT_SRC(pNonSortMerge, pNonSortMerge->lastSourceIdx); continue; } break; } - return pBlock; + if (!pBlock) { + return NULL; + } + copyDataBlock(pRes, pBlock); + + return pRes; } void destroyNonSortMergeOperatorInfo(void* param) { @@ -491,6 +497,9 @@ SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size } case MERGE_TYPE_NON_SORT: { SNonSortMergeInfo* pNonSortMerge = &pInfo->nsortMergeInfo; + pInfo->binfo.pRes = createDataBlockFromDescNode(pDescNode); + initResultSizeInfo(&pOperator->resultInfo, 1024); + blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity); break; } case MERGE_TYPE_COLUMNS: { diff --git a/source/libs/executor/src/projectoperator.c b/source/libs/executor/src/projectoperator.c index 691210e5ba..c6ebb04446 100644 --- a/source/libs/executor/src/projectoperator.c +++ b/source/libs/executor/src/projectoperator.c @@ -28,6 +28,7 @@ typedef struct SProjectOperatorInfo { bool mergeDataBlocks; SSDataBlock* pFinalRes; bool inputIgnoreGroup; + bool outputIgnoreGroup; } SProjectOperatorInfo; typedef struct SIndefOperatorInfo { @@ -111,6 +112,7 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys pInfo->binfo.inputTsOrder = pProjPhyNode->node.inputTsOrder; pInfo->binfo.outputTsOrder = pProjPhyNode->node.outputTsOrder; pInfo->inputIgnoreGroup = pProjPhyNode->inputIgnoreGroup; + pInfo->outputIgnoreGroup = pProjPhyNode->ignoreGroupId; if (pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM || pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE) { pInfo->mergeDataBlocks = false; @@ -276,6 +278,10 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { T_LONG_JMP(pTaskInfo->env, code); } + if (pProjectInfo->outputIgnoreGroup) { + pRes->info.id.groupId = 0; + } + return (pRes->info.rows > 0) ? pRes : NULL; } @@ -385,6 +391,10 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { printDataBlock(p, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); } + if (pProjectInfo->outputIgnoreGroup) { + p->info.id.groupId = 0; + } + return (p->info.rows > 0) ? p : NULL; } diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index de74623974..a6613e589a 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -2084,6 +2084,8 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { blockDataCleanup(pInfo->pRes); STimeWindow defaultWindow = {.skey = INT64_MIN, .ekey = INT64_MAX}; setBlockIntoRes(pInfo, pRes, &defaultWindow, true); + qDebug("doQueueScan after filter get data from log %" PRId64 " rows, version:%" PRId64, pInfo->pRes->info.rows, + pTaskInfo->streamInfo.currentOffset.version); if (pInfo->pRes->info.rows > 0) { return pInfo->pRes; } @@ -2269,6 +2271,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { if (pStreamInfo->recoverStep == STREAM_RECOVER_STEP__SCAN1) { if (isTaskKilled(pTaskInfo)) { + qInfo("===stream===stream scan is killed. task id:%s, code %s", id, tstrerror(pTaskInfo->code)); return NULL; } @@ -3870,6 +3873,7 @@ static void doGetBlockForTableMergeScan(SOperatorInfo* pOperator, bool* pFinishe uint32_t status = 0; code = loadDataBlock(pOperator, &pInfo->base, pBlock, &status); + if (code != TSDB_CODE_SUCCESS) { qInfo("table merge scan load datablock code %d, %s", code, GET_TASKID(pTaskInfo)); T_LONG_JMP(pTaskInfo->env, code); @@ -3956,7 +3960,9 @@ static SSDataBlock* getBlockForTableMergeScan(void* param) { pBlock->info.id.groupId = tableListGetTableGroupId(pInfo->base.pTableListInfo, pBlock->info.id.uid); pOperator->resultInfo.totalRows += pBlock->info.rows; + pInfo->base.readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0; + return pBlock; } @@ -4008,9 +4014,16 @@ int32_t startDurationForGroupTableMergeScan(SOperatorInfo* pOperator) { pInfo->sortBufSize = 2048 * pInfo->bufPageSize; int32_t numOfBufPage = pInfo->sortBufSize / pInfo->bufPageSize; - pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, SORT_BLOCK_TS_MERGE, pInfo->bufPageSize, numOfBufPage, - pInfo->pSortInputBlock, pTaskInfo->id.str, 0, 0, 0); + pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, SORT_BLOCK_TS_MERGE, pInfo->bufPageSize, numOfBufPage, + pInfo->pSortInputBlock, pTaskInfo->id.str, 0, 0, 0); + if (pInfo->bSortRowId && numOfTable != 1) { + int32_t memSize = 512 * 1024 * 1024; + code = tsortSetSortByRowId(pInfo->pSortHandle, memSize); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + } tsortSetMergeLimit(pInfo->pSortHandle, pInfo->mergeLimit); tsortSetMergeLimitReachedFp(pInfo->pSortHandle, tableMergeScanDoSkipTable, pInfo); tsortSetAbortCheckFn(pInfo->pSortHandle, isTaskKilled, pOperator->pTaskInfo); @@ -4047,6 +4060,7 @@ void stopDurationForGroupTableMergeScan(SOperatorInfo* pOperator) { tsortDestroySortHandle(pInfo->pSortHandle); pInfo->pSortHandle = NULL; + } int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) { @@ -4131,8 +4145,7 @@ SSDataBlock* getSortedTableMergeScanBlockData(SSortHandle* pHandle, SSDataBlock* if (pTupleHandle == NULL) { break; } - - appendOneRowToDataBlock(pResBlock, pTupleHandle); + tsortAppendTupleToBlock(pInfo->pSortHandle, pResBlock, pTupleHandle); if (pResBlock->info.rows >= capacity) { break; } @@ -4199,7 +4212,10 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) { } else { if (pInfo->bNewFilesetEvent) { stopDurationForGroupTableMergeScan(pOperator); - startDurationForGroupTableMergeScan(pOperator); + code = startDurationForGroupTableMergeScan(pOperator); + if (code != TSDB_CODE_SUCCESS) { + T_LONG_JMP(pTaskInfo->env, terrno); + } } else { // Data of this group are all dumped, let's try the next group stopGroupTableMergeScan(pOperator); @@ -4330,10 +4346,15 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN pInfo->mergeLimit = pInfo->limitInfo.limit.limit + pInfo->limitInfo.limit.offset; pInfo->mSkipTables = NULL; } - + initResultSizeInfo(&pOperator->resultInfo, 1024); pInfo->pResBlock = createDataBlockFromDescNode(pDescNode); blockDataEnsureCapacity(pInfo->pResBlock, pOperator->resultInfo.capacity); + if (!hasLimit && blockDataGetRowSize(pInfo->pResBlock) >= 256 && !pTableScanNode->smallDataTsSort) { + pInfo->bSortRowId = true; + } else { + pInfo->bSortRowId = false; + } pInfo->pSortInfo = generateSortByTsInfo(pInfo->base.matchInfo.pList, pInfo->base.cond.order); pInfo->pReaderBlock = createOneDataBlock(pInfo->pResBlock, false); @@ -4342,6 +4363,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN int32_t rowSize = pInfo->pResBlock->info.rowSize; uint32_t nCols = taosArrayGetSize(pInfo->pResBlock->pDataBlock); + pInfo->bufPageSize = getProperSortPageSize(rowSize, nCols); //start one reader variable diff --git a/source/libs/executor/src/streameventwindowoperator.c b/source/libs/executor/src/streameventwindowoperator.c index 11d8d1487a..ef5c2572d9 100644 --- a/source/libs/executor/src/streameventwindowoperator.c +++ b/source/libs/executor/src/streameventwindowoperator.c @@ -99,6 +99,11 @@ int32_t getEndCondIndex(bool* pEnd, int32_t start, int32_t rows) { return -1; } +int32_t reuseOutputBuf(void* pState, SRowBuffPos* pPos, SStateStore* pAPI) { + pAPI->streamStateReleaseBuf(pState, pPos, true); + return TSDB_CODE_SUCCESS; +} + void setEventOutputBuf(SStreamAggSupporter* pAggSup, TSKEY* pTs, uint64_t groupId, bool* pStart, bool* pEnd, int32_t index, int32_t rows, SEventWindowInfo* pCurWin, SSessionKey* pNextWinKey) { int32_t code = TSDB_CODE_SUCCESS; int32_t size = pAggSup->resultRowSize; @@ -143,6 +148,7 @@ void setEventOutputBuf(SStreamAggSupporter* pAggSup, TSKEY* pTs, uint64_t groupI pCurWin->winInfo.isOutput = false; _end: + reuseOutputBuf(pAggSup->pState, pCurWin->winInfo.pStatePos, &pAggSup->stateStore); pAggSup->stateStore.streamStateCurNext(pAggSup->pState, pCur); pNextWinKey->groupId = groupId; code = pAggSup->stateStore.streamStateSessionGetKVByCur(pCur, pNextWinKey, NULL, 0); @@ -341,6 +347,7 @@ static void doStreamEventAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl } if (isWindowIncomplete(&curWin)) { + releaseOutputBuf(pAggSup->pState, curWin.winInfo.pStatePos, &pAggSup->stateStore); continue; } diff --git a/source/libs/executor/src/streamfilloperator.c b/source/libs/executor/src/streamfilloperator.c new file mode 100644 index 0000000000..b54802e2c6 --- /dev/null +++ b/source/libs/executor/src/streamfilloperator.c @@ -0,0 +1,1181 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "filter.h" +#include "os.h" +#include "query.h" +#include "taosdef.h" +#include "tmsg.h" +#include "ttypes.h" + +#include "executorInt.h" +#include "tcommon.h" +#include "thash.h" +#include "ttime.h" + +#include "function.h" +#include "querynodes.h" +#include "tdatablock.h" +#include "tfill.h" +#include "operator.h" +#include "querytask.h" + + +#define FILL_POS_INVALID 0 +#define FILL_POS_START 1 +#define FILL_POS_MID 2 +#define FILL_POS_END 3 + +typedef struct STimeRange { + TSKEY skey; + TSKEY ekey; + uint64_t groupId; +} STimeRange; + +TSKEY getNextWindowTs(TSKEY ts, SInterval* pInterval) { + STimeWindow win = {.skey = ts, .ekey = ts}; + getNextTimeWindow(pInterval, &win, TSDB_ORDER_ASC); + return win.skey; +} + +TSKEY getPrevWindowTs(TSKEY ts, SInterval* pInterval) { + STimeWindow win = {.skey = ts, .ekey = ts}; + getNextTimeWindow(pInterval, &win, TSDB_ORDER_DESC); + return win.skey; +} + +void setRowCell(SColumnInfoData* pCol, int32_t rowId, const SResultCellData* pCell) { + colDataSetVal(pCol, rowId, pCell->pData, pCell->isNull); +} + +SResultCellData* getResultCell(SResultRowData* pRaw, int32_t index) { + if (!pRaw || !pRaw->pRowVal) { + return NULL; + } + char* pData = (char*)pRaw->pRowVal; + SResultCellData* pCell = pRaw->pRowVal; + for (int32_t i = 0; i < index; i++) { + pData += (pCell->bytes + sizeof(SResultCellData)); + pCell = (SResultCellData*)pData; + } + return pCell; +} + +void* destroyFillColumnInfo(SFillColInfo* pFillCol, int32_t start, int32_t end) { + for (int32_t i = start; i < end; i++) { + destroyExprInfo(pFillCol[i].pExpr, 1); + taosVariantDestroy(&pFillCol[i].fillVal); + } + taosMemoryFreeClear(pFillCol[start].pExpr); + taosMemoryFree(pFillCol); + return NULL; +} + +void* destroyStreamFillSupporter(SStreamFillSupporter* pFillSup) { + pFillSup->pAllColInfo = destroyFillColumnInfo(pFillSup->pAllColInfo, pFillSup->numOfFillCols, pFillSup->numOfAllCols); + tSimpleHashCleanup(pFillSup->pResMap); + pFillSup->pResMap = NULL; + cleanupExprSupp(&pFillSup->notFillExprSup); + if (pFillSup->cur.pRowVal != pFillSup->prev.pRowVal && pFillSup->cur.pRowVal != pFillSup->next.pRowVal) { + taosMemoryFree(pFillSup->cur.pRowVal); + } + taosMemoryFree(pFillSup->prev.pRowVal); + taosMemoryFree(pFillSup->next.pRowVal); + taosMemoryFree(pFillSup->nextNext.pRowVal); + + taosMemoryFree(pFillSup); + return NULL; +} + +void destroySPoint(void* ptr) { + SPoint* point = (SPoint*) ptr; + taosMemoryFreeClear(point->val); +} + +void* destroyStreamFillLinearInfo(SStreamFillLinearInfo* pFillLinear) { + taosArrayDestroyEx(pFillLinear->pEndPoints, destroySPoint); + taosArrayDestroyEx(pFillLinear->pNextEndPoints, destroySPoint); + taosMemoryFree(pFillLinear); + return NULL; +} +void* destroyStreamFillInfo(SStreamFillInfo* pFillInfo) { + if (pFillInfo->type == TSDB_FILL_SET_VALUE || pFillInfo->type == TSDB_FILL_SET_VALUE_F || + pFillInfo->type == TSDB_FILL_NULL || pFillInfo->type == TSDB_FILL_NULL_F) { + taosMemoryFreeClear(pFillInfo->pResRow->pRowVal); + taosMemoryFreeClear(pFillInfo->pResRow); + } + pFillInfo->pLinearInfo = destroyStreamFillLinearInfo(pFillInfo->pLinearInfo); + taosArrayDestroy(pFillInfo->delRanges); + taosMemoryFree(pFillInfo); + return NULL; +} + +static void destroyStreamFillOperatorInfo(void* param) { + SStreamFillOperatorInfo* pInfo = (SStreamFillOperatorInfo*)param; + pInfo->pFillInfo = destroyStreamFillInfo(pInfo->pFillInfo); + pInfo->pFillSup = destroyStreamFillSupporter(pInfo->pFillSup); + pInfo->pRes = blockDataDestroy(pInfo->pRes); + pInfo->pSrcBlock = blockDataDestroy(pInfo->pSrcBlock); + pInfo->pDelRes = blockDataDestroy(pInfo->pDelRes); + pInfo->matchInfo.pList = taosArrayDestroy(pInfo->matchInfo.pList); + taosMemoryFree(pInfo); +} + +static void resetFillWindow(SResultRowData* pRowData) { + pRowData->key = INT64_MIN; + taosMemoryFreeClear(pRowData->pRowVal); +} + +void resetPrevAndNextWindow(SStreamFillSupporter* pFillSup, void* pState, SStorageAPI* pAPI) { + if (pFillSup->cur.pRowVal != pFillSup->prev.pRowVal && pFillSup->cur.pRowVal != pFillSup->next.pRowVal) { + resetFillWindow(&pFillSup->cur); + } else { + pFillSup->cur.key = INT64_MIN; + pFillSup->cur.pRowVal = NULL; + } + resetFillWindow(&pFillSup->prev); + resetFillWindow(&pFillSup->next); + resetFillWindow(&pFillSup->nextNext); +} + +void getCurWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId, SStreamFillSupporter* pFillSup) { + SStorageAPI* pAPI = &pOperator->pTaskInfo->storageAPI; + + void* pState = pOperator->pTaskInfo->streamInfo.pState; + resetPrevAndNextWindow(pFillSup, pState, pAPI); + + SWinKey key = {.ts = ts, .groupId = groupId}; + int32_t curVLen = 0; + + int32_t code = pAPI->stateStore.streamStateFillGet(pState, &key, (void**)&pFillSup->cur.pRowVal, &curVLen); + ASSERT(code == TSDB_CODE_SUCCESS); + pFillSup->cur.key = key.ts; +} + +void getWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId, SStreamFillSupporter* pFillSup) { + SStorageAPI* pAPI = &pOperator->pTaskInfo->storageAPI; + void* pState = pOperator->pTaskInfo->streamInfo.pState; + resetPrevAndNextWindow(pFillSup, pState, pAPI); + + SWinKey key = {.ts = ts, .groupId = groupId}; + void* curVal = NULL; + int32_t curVLen = 0; + int32_t code = pAPI->stateStore.streamStateFillGet(pState, &key, (void**)&curVal, &curVLen); + ASSERT(code == TSDB_CODE_SUCCESS); + pFillSup->cur.key = key.ts; + pFillSup->cur.pRowVal = curVal; + + SStreamStateCur* pCur = pAPI->stateStore.streamStateFillSeekKeyPrev(pState, &key); + SWinKey preKey = {.ts = INT64_MIN, .groupId = groupId}; + void* preVal = NULL; + int32_t preVLen = 0; + code = pAPI->stateStore.streamStateGetGroupKVByCur(pCur, &preKey, (const void**)&preVal, &preVLen); + + if (code == TSDB_CODE_SUCCESS) { + pFillSup->prev.key = preKey.ts; + pFillSup->prev.pRowVal = preVal; + + code = pAPI->stateStore.streamStateCurNext(pState, pCur); + ASSERT(code == TSDB_CODE_SUCCESS); + + code = pAPI->stateStore.streamStateCurNext(pState, pCur); + if (code != TSDB_CODE_SUCCESS) { + pAPI->stateStore.streamStateFreeCur(pCur); + pCur = NULL; + } + } else { + pAPI->stateStore.streamStateFreeCur(pCur); + pCur = pAPI->stateStore.streamStateFillSeekKeyNext(pState, &key); + } + + SWinKey nextKey = {.ts = INT64_MIN, .groupId = groupId}; + void* nextVal = NULL; + int32_t nextVLen = 0; + code = pAPI->stateStore.streamStateGetGroupKVByCur(pCur, &nextKey, (const void**)&nextVal, &nextVLen); + if (code == TSDB_CODE_SUCCESS) { + pFillSup->next.key = nextKey.ts; + pFillSup->next.pRowVal = nextVal; + if (pFillSup->type == TSDB_FILL_PREV || pFillSup->type == TSDB_FILL_NEXT) { + code = pAPI->stateStore.streamStateCurNext(pState, pCur); + if (code == TSDB_CODE_SUCCESS) { + SWinKey nextNextKey = {.groupId = groupId}; + void* nextNextVal = NULL; + int32_t nextNextVLen = 0; + code = pAPI->stateStore.streamStateGetGroupKVByCur(pCur, &nextNextKey, (const void**)&nextNextVal, &nextNextVLen); + if (code == TSDB_CODE_SUCCESS) { + pFillSup->nextNext.key = nextNextKey.ts; + pFillSup->nextNext.pRowVal = nextNextVal; + } + } + } + } + pAPI->stateStore.streamStateFreeCur(pCur); +} + +static bool hasPrevWindow(SStreamFillSupporter* pFillSup) { return pFillSup->prev.key != INT64_MIN; } +static bool hasNextWindow(SStreamFillSupporter* pFillSup) { return pFillSup->next.key != INT64_MIN; } +static bool hasNextNextWindow(SStreamFillSupporter* pFillSup) { + return pFillSup->nextNext.key != INT64_MIN; + return false; +} + +static void transBlockToResultRow(const SSDataBlock* pBlock, int32_t rowId, TSKEY ts, SResultRowData* pRowVal) { + int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, i); + SResultCellData* pCell = getResultCell(pRowVal, i); + if (!colDataIsNull_s(pColData, rowId)) { + pCell->isNull = false; + pCell->type = pColData->info.type; + pCell->bytes = pColData->info.bytes; + char* val = colDataGetData(pColData, rowId); + if (IS_VAR_DATA_TYPE(pCell->type)) { + memcpy(pCell->pData, val, varDataTLen(val)); + } else { + memcpy(pCell->pData, val, pCell->bytes); + } + } else { + pCell->isNull = true; + } + } + pRowVal->key = ts; +} + +static void calcDeltaData(SSDataBlock* pBlock, int32_t rowId, SResultRowData* pRowVal, SArray* pDelta, + SFillColInfo* pFillCol, int32_t numOfCol, int32_t winCount, int32_t order) { + for (int32_t i = 0; i < numOfCol; i++) { + if (!pFillCol[i].notFillCol) { + int32_t slotId = GET_DEST_SLOT_ID(pFillCol + i); + SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); + char* var = colDataGetData(pCol, rowId); + double start = 0; + GET_TYPED_DATA(start, double, pCol->info.type, var); + SResultCellData* pCell = getResultCell(pRowVal, slotId); + double end = 0; + GET_TYPED_DATA(end, double, pCell->type, pCell->pData); + double delta = 0; + if (order == TSDB_ORDER_ASC) { + delta = (end - start) / winCount; + } else { + delta = (start - end) / winCount; + } + taosArraySet(pDelta, slotId, &delta); + } + } +} + +static void calcRowDeltaData(SResultRowData* pEndRow, SArray* pEndPoins, SFillColInfo* pFillCol, + int32_t numOfCol) { + for (int32_t i = 0; i < numOfCol; i++) { + if (!pFillCol[i].notFillCol) { + int32_t slotId = GET_DEST_SLOT_ID(pFillCol + i); + SResultCellData* pECell = getResultCell(pEndRow, slotId); + SPoint* pPoint = taosArrayGet(pEndPoins, slotId); + pPoint->key = pEndRow->key; + memcpy(pPoint->val, pECell->pData, pECell->bytes); + } + } +} + +static void setFillInfoStart(TSKEY ts, SInterval* pInterval, SStreamFillInfo* pFillInfo) { + ts = taosTimeAdd(ts, pInterval->sliding, pInterval->slidingUnit, pInterval->precision); + pFillInfo->start = ts; +} + +static void setFillInfoEnd(TSKEY ts, SInterval* pInterval, SStreamFillInfo* pFillInfo) { + ts = taosTimeAdd(ts, pInterval->sliding * -1, pInterval->slidingUnit, pInterval->precision); + pFillInfo->end = ts; +} + +static void setFillKeyInfo(TSKEY start, TSKEY end, SInterval* pInterval, SStreamFillInfo* pFillInfo) { + setFillInfoStart(start, pInterval, pFillInfo); + pFillInfo->current = pFillInfo->start; + setFillInfoEnd(end, pInterval, pFillInfo); +} + +void setDeleteFillValueInfo(TSKEY start, TSKEY end, SStreamFillSupporter* pFillSup, SStreamFillInfo* pFillInfo) { + if (!hasPrevWindow(pFillSup) || !hasNextWindow(pFillSup)) { + pFillInfo->needFill = false; + return; + } + + TSKEY realStart = taosTimeAdd(pFillSup->prev.key, pFillSup->interval.sliding, pFillSup->interval.slidingUnit, + pFillSup->interval.precision); + + pFillInfo->needFill = true; + pFillInfo->start = realStart; + pFillInfo->current = pFillInfo->start; + pFillInfo->end = end; + pFillInfo->pos = FILL_POS_INVALID; + switch (pFillInfo->type) { + case TSDB_FILL_NULL: + case TSDB_FILL_NULL_F: + case TSDB_FILL_SET_VALUE: + case TSDB_FILL_SET_VALUE_F: + break; + case TSDB_FILL_PREV: + pFillInfo->pResRow = &pFillSup->prev; + break; + case TSDB_FILL_NEXT: + pFillInfo->pResRow = &pFillSup->next; + break; + case TSDB_FILL_LINEAR: { + setFillKeyInfo(pFillSup->prev.key, pFillSup->next.key, &pFillSup->interval, pFillInfo); + pFillInfo->pLinearInfo->hasNext = false; + pFillInfo->pLinearInfo->nextEnd = INT64_MIN; + calcRowDeltaData(&pFillSup->next, pFillInfo->pLinearInfo->pEndPoints, pFillSup->pAllColInfo, + pFillSup->numOfAllCols); + pFillInfo->pResRow = &pFillSup->prev; + pFillInfo->pLinearInfo->winIndex = 0; + } break; + default: + ASSERT(0); + break; + } +} + +void copyNotFillExpData(SStreamFillSupporter* pFillSup, SStreamFillInfo* pFillInfo) { + for (int32_t i = pFillSup->numOfFillCols; i < pFillSup->numOfAllCols; ++i) { + SFillColInfo* pFillCol = pFillSup->pAllColInfo + i; + int32_t slotId = GET_DEST_SLOT_ID(pFillCol); + SResultCellData* pCell = getResultCell(pFillInfo->pResRow, slotId); + SResultCellData* pCurCell = getResultCell(&pFillSup->cur, slotId); + pCell->isNull = pCurCell->isNull; + if (!pCurCell->isNull) { + memcpy(pCell->pData, pCurCell->pData, pCell->bytes); + } + } +} + +void setFillValueInfo(SSDataBlock* pBlock, TSKEY ts, int32_t rowId, SStreamFillSupporter* pFillSup, + SStreamFillInfo* pFillInfo) { + pFillInfo->preRowKey = pFillSup->cur.key; + if (!hasPrevWindow(pFillSup) && !hasNextWindow(pFillSup)) { + pFillInfo->needFill = false; + pFillInfo->pos = FILL_POS_START; + return; + } + TSKEY prevWKey = INT64_MIN; + TSKEY nextWKey = INT64_MIN; + if (hasPrevWindow(pFillSup)) { + prevWKey = pFillSup->prev.key; + } + if (hasNextWindow(pFillSup)) { + nextWKey = pFillSup->next.key; + } + + pFillInfo->needFill = true; + pFillInfo->pos = FILL_POS_INVALID; + switch (pFillInfo->type) { + case TSDB_FILL_NULL: + case TSDB_FILL_NULL_F: + case TSDB_FILL_SET_VALUE: + case TSDB_FILL_SET_VALUE_F: { + if (pFillSup->prev.key == pFillInfo->preRowKey) { + resetFillWindow(&pFillSup->prev); + } + if (hasPrevWindow(pFillSup) && hasNextWindow(pFillSup)) { + if (pFillSup->next.key == pFillInfo->nextRowKey) { + pFillInfo->preRowKey = INT64_MIN; + setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_END; + } else { + pFillInfo->needFill = false; + pFillInfo->pos = FILL_POS_START; + } + } else if (hasPrevWindow(pFillSup)) { + setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_END; + } else { + setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_START; + } + copyNotFillExpData(pFillSup, pFillInfo); + } break; + case TSDB_FILL_PREV: { + if (hasNextWindow(pFillSup) && ((pFillSup->next.key != pFillInfo->nextRowKey) || + (pFillSup->next.key == pFillInfo->nextRowKey && hasNextNextWindow(pFillSup)) || + (pFillSup->next.key == pFillInfo->nextRowKey && !hasPrevWindow(pFillSup)))) { + setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_START; + resetFillWindow(&pFillSup->prev); + pFillSup->prev.key = pFillSup->cur.key; + pFillSup->prev.pRowVal = pFillSup->cur.pRowVal; + } else if (hasPrevWindow(pFillSup)) { + setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_END; + pFillInfo->preRowKey = INT64_MIN; + } + pFillInfo->pResRow = &pFillSup->prev; + } break; + case TSDB_FILL_NEXT: { + if (hasPrevWindow(pFillSup)) { + setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_END; + resetFillWindow(&pFillSup->next); + pFillSup->next.key = pFillSup->cur.key; + pFillSup->next.pRowVal = pFillSup->cur.pRowVal; + pFillInfo->preRowKey = INT64_MIN; + } else { + ASSERT(hasNextWindow(pFillSup)); + setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_START; + } + pFillInfo->pResRow = &pFillSup->next; + } break; + case TSDB_FILL_LINEAR: { + pFillInfo->pLinearInfo->winIndex = 0; + if (hasPrevWindow(pFillSup) && hasNextWindow(pFillSup)) { + setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_MID; + pFillInfo->pLinearInfo->nextEnd = nextWKey; + calcRowDeltaData(&pFillSup->cur, pFillInfo->pLinearInfo->pEndPoints, pFillSup->pAllColInfo, + pFillSup->numOfAllCols); + pFillInfo->pResRow = &pFillSup->prev; + + calcRowDeltaData(&pFillSup->next, pFillInfo->pLinearInfo->pNextEndPoints, pFillSup->pAllColInfo, + pFillSup->numOfAllCols); + pFillInfo->pLinearInfo->hasNext = true; + } else if (hasPrevWindow(pFillSup)) { + setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_END; + pFillInfo->pLinearInfo->nextEnd = INT64_MIN; + calcRowDeltaData(&pFillSup->cur, pFillInfo->pLinearInfo->pEndPoints, pFillSup->pAllColInfo, + pFillSup->numOfAllCols); + pFillInfo->pResRow = &pFillSup->prev; + pFillInfo->pLinearInfo->hasNext = false; + } else { + ASSERT(hasNextWindow(pFillSup)); + setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_START; + pFillInfo->pLinearInfo->nextEnd = INT64_MIN; + calcRowDeltaData(&pFillSup->next, pFillInfo->pLinearInfo->pEndPoints, pFillSup->pAllColInfo, + pFillSup->numOfAllCols); + pFillInfo->pResRow = &pFillSup->cur; + pFillInfo->pLinearInfo->hasNext = false; + } + } break; + default: + ASSERT(0); + break; + } + ASSERT(pFillInfo->pos != FILL_POS_INVALID); +} + +static bool checkResult(SStreamFillSupporter* pFillSup, TSKEY ts, uint64_t groupId) { + SWinKey key = {.groupId = groupId, .ts = ts}; + if (tSimpleHashGet(pFillSup->pResMap, &key, sizeof(SWinKey)) != NULL) { + return false; + } + tSimpleHashPut(pFillSup->pResMap, &key, sizeof(SWinKey), NULL, 0); + return true; +} + +static bool buildFillResult(SResultRowData* pResRow, SStreamFillSupporter* pFillSup, TSKEY ts, SSDataBlock* pBlock) { + if (pBlock->info.rows >= pBlock->info.capacity) { + return false; + } + uint64_t groupId = pBlock->info.id.groupId; + if (pFillSup->hasDelete && !checkResult(pFillSup, ts, groupId)) { + return true; + } + for (int32_t i = 0; i < pFillSup->numOfAllCols; ++i) { + SFillColInfo* pFillCol = pFillSup->pAllColInfo + i; + int32_t slotId = GET_DEST_SLOT_ID(pFillCol); + SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, slotId); + SFillInfo tmpInfo = { + .currentKey = ts, + .order = TSDB_ORDER_ASC, + .interval = pFillSup->interval, + }; + bool filled = fillIfWindowPseudoColumn(&tmpInfo, pFillCol, pColData, pBlock->info.rows); + if (!filled) { + SResultCellData* pCell = getResultCell(pResRow, slotId); + setRowCell(pColData, pBlock->info.rows, pCell); + } + } + pBlock->info.rows++; + return true; +} + +static bool hasRemainCalc(SStreamFillInfo* pFillInfo) { + if (pFillInfo->current != INT64_MIN && pFillInfo->current <= pFillInfo->end) { + return true; + } + return false; +} + +static void doStreamFillNormal(SStreamFillSupporter* pFillSup, SStreamFillInfo* pFillInfo, SSDataBlock* pBlock) { + while (hasRemainCalc(pFillInfo) && pBlock->info.rows < pBlock->info.capacity) { + STimeWindow st = {.skey = pFillInfo->current, .ekey = pFillInfo->current}; + if (inWinRange(&pFillSup->winRange, &st)) { + buildFillResult(pFillInfo->pResRow, pFillSup, pFillInfo->current, pBlock); + } + pFillInfo->current = taosTimeAdd(pFillInfo->current, pFillSup->interval.sliding, pFillSup->interval.slidingUnit, + pFillSup->interval.precision); + } +} + +static void doStreamFillLinear(SStreamFillSupporter* pFillSup, SStreamFillInfo* pFillInfo, SSDataBlock* pBlock) { + while (hasRemainCalc(pFillInfo) && pBlock->info.rows < pBlock->info.capacity) { + uint64_t groupId = pBlock->info.id.groupId; + SWinKey key = {.groupId = groupId, .ts = pFillInfo->current}; + STimeWindow st = {.skey = pFillInfo->current, .ekey = pFillInfo->current}; + if ( ( pFillSup->hasDelete && !checkResult(pFillSup, pFillInfo->current, groupId) ) || !inWinRange(&pFillSup->winRange, &st) ) { + pFillInfo->current = taosTimeAdd(pFillInfo->current, pFillSup->interval.sliding, pFillSup->interval.slidingUnit, + pFillSup->interval.precision); + pFillInfo->pLinearInfo->winIndex++; + continue; + } + pFillInfo->pLinearInfo->winIndex++; + for (int32_t i = 0; i < pFillSup->numOfAllCols; ++i) { + SFillColInfo* pFillCol = pFillSup->pAllColInfo + i; + SFillInfo tmp = { + .currentKey = pFillInfo->current, + .order = TSDB_ORDER_ASC, + .interval = pFillSup->interval, + }; + + int32_t slotId = GET_DEST_SLOT_ID(pFillCol); + SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, slotId); + int16_t type = pColData->info.type; + SResultCellData* pCell = getResultCell(pFillInfo->pResRow, slotId); + int32_t index = pBlock->info.rows; + if (pFillCol->notFillCol) { + bool filled = fillIfWindowPseudoColumn(&tmp, pFillCol, pColData, index); + if (!filled) { + setRowCell(pColData, index, pCell); + } + } else { + if (IS_VAR_DATA_TYPE(type) || type == TSDB_DATA_TYPE_BOOL || pCell->isNull) { + colDataSetNULL(pColData, index); + continue; + } + SPoint* pEnd = taosArrayGet(pFillInfo->pLinearInfo->pEndPoints, slotId); + double vCell = 0; + SPoint start = {0}; + start.key = pFillInfo->pResRow->key; + start.val = pCell->pData; + + SPoint cur = {0}; + cur.key = pFillInfo->current; + cur.val = taosMemoryCalloc(1, pCell->bytes); + taosGetLinearInterpolationVal(&cur, pCell->type, &start, pEnd, pCell->type); + colDataSetVal(pColData, index, (const char*)cur.val, false); + destroySPoint(&cur); + } + } + pFillInfo->current = taosTimeAdd(pFillInfo->current, pFillSup->interval.sliding, pFillSup->interval.slidingUnit, + pFillSup->interval.precision); + pBlock->info.rows++; + } +} + +static void keepResultInDiscBuf(SOperatorInfo* pOperator, uint64_t groupId, SResultRowData* pRow, int32_t len) { + SStorageAPI* pAPI = &pOperator->pTaskInfo->storageAPI; + + SWinKey key = {.groupId = groupId, .ts = pRow->key}; + int32_t code = pAPI->stateStore.streamStateFillPut(pOperator->pTaskInfo->streamInfo.pState, &key, pRow->pRowVal, len); + qDebug("===stream===fill operator save key ts:%" PRId64 " group id:%" PRIu64 " code:%d", key.ts, key.groupId, code); + ASSERT(code == TSDB_CODE_SUCCESS); +} + +static void doStreamFillRange(SStreamFillInfo* pFillInfo, SStreamFillSupporter* pFillSup, SSDataBlock* pRes) { + if (pFillInfo->needFill == false) { + buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes); + return; + } + + if (pFillInfo->pos == FILL_POS_START) { + if (buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes)) { + pFillInfo->pos = FILL_POS_INVALID; + } + } + if (pFillInfo->type != TSDB_FILL_LINEAR) { + doStreamFillNormal(pFillSup, pFillInfo, pRes); + } else { + doStreamFillLinear(pFillSup, pFillInfo, pRes); + + if (pFillInfo->pos == FILL_POS_MID) { + if (buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes)) { + pFillInfo->pos = FILL_POS_INVALID; + } + } + + if (pFillInfo->current > pFillInfo->end && pFillInfo->pLinearInfo->hasNext) { + pFillInfo->pLinearInfo->hasNext = false; + pFillInfo->pLinearInfo->winIndex = 0; + taosArraySwap(pFillInfo->pLinearInfo->pEndPoints, pFillInfo->pLinearInfo->pNextEndPoints); + pFillInfo->pResRow = &pFillSup->cur; + setFillKeyInfo(pFillSup->cur.key, pFillInfo->pLinearInfo->nextEnd, &pFillSup->interval, pFillInfo); + doStreamFillLinear(pFillSup, pFillInfo, pRes); + } + } + if (pFillInfo->pos == FILL_POS_END) { + if (buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes)) { + pFillInfo->pos = FILL_POS_INVALID; + } + } +} + +void keepBlockRowInDiscBuf(SOperatorInfo* pOperator, SStreamFillInfo* pFillInfo, SSDataBlock* pBlock, TSKEY* tsCol, + int32_t rowId, uint64_t groupId, int32_t rowSize) { + TSKEY ts = tsCol[rowId]; + pFillInfo->nextRowKey = ts; + SResultRowData tmpNextRow = {.key = ts}; + tmpNextRow.pRowVal = taosMemoryCalloc(1, rowSize); + transBlockToResultRow(pBlock, rowId, ts, &tmpNextRow); + keepResultInDiscBuf(pOperator, groupId, &tmpNextRow, rowSize); + taosMemoryFreeClear(tmpNextRow.pRowVal); +} + +static void doFillResults(SOperatorInfo* pOperator, SStreamFillSupporter* pFillSup, SStreamFillInfo* pFillInfo, + SSDataBlock* pBlock, TSKEY* tsCol, int32_t rowId, SSDataBlock* pRes) { + uint64_t groupId = pBlock->info.id.groupId; + getWindowFromDiscBuf(pOperator, tsCol[rowId], groupId, pFillSup); + if (pFillSup->prev.key == pFillInfo->preRowKey) { + resetFillWindow(&pFillSup->prev); + } + setFillValueInfo(pBlock, tsCol[rowId], rowId, pFillSup, pFillInfo); + doStreamFillRange(pFillInfo, pFillSup, pRes); +} + +static void doStreamFillImpl(SOperatorInfo* pOperator) { + SStreamFillOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SStreamFillSupporter* pFillSup = pInfo->pFillSup; + SStreamFillInfo* pFillInfo = pInfo->pFillInfo; + SSDataBlock* pBlock = pInfo->pSrcBlock; + uint64_t groupId = pBlock->info.id.groupId; + SSDataBlock* pRes = pInfo->pRes; + SColumnInfoData* pTsCol = taosArrayGet(pInfo->pSrcBlock->pDataBlock, pInfo->primaryTsCol); + TSKEY* tsCol = (TSKEY*)pTsCol->pData; + pRes->info.id.groupId = groupId; + pInfo->srcRowIndex++; + + if (pInfo->srcRowIndex == 0) { + keepBlockRowInDiscBuf(pOperator, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex, groupId, pFillSup->rowSize); + pInfo->srcRowIndex++; + } + + while (pInfo->srcRowIndex < pBlock->info.rows) { + TSKEY ts = tsCol[pInfo->srcRowIndex]; + keepBlockRowInDiscBuf(pOperator, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex, groupId, pFillSup->rowSize); + doFillResults(pOperator, pFillSup, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex - 1, pRes); + if (pInfo->pRes->info.rows == pInfo->pRes->info.capacity) { + blockDataUpdateTsWindow(pRes, pInfo->primaryTsCol); + return; + } + pInfo->srcRowIndex++; + } + doFillResults(pOperator, pFillSup, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex - 1, pRes); + blockDataUpdateTsWindow(pRes, pInfo->primaryTsCol); + blockDataCleanup(pInfo->pSrcBlock); +} + +static void buildDeleteRange(SOperatorInfo* pOp, TSKEY start, TSKEY end, uint64_t groupId, SSDataBlock* delRes) { + SStorageAPI* pAPI = &pOp->pTaskInfo->storageAPI; + void* pState = pOp->pTaskInfo->streamInfo.pState; + + SSDataBlock* pBlock = delRes; + SColumnInfoData* pStartCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); + SColumnInfoData* pEndCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX); + SColumnInfoData* pUidCol = taosArrayGet(pBlock->pDataBlock, UID_COLUMN_INDEX); + SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); + SColumnInfoData* pCalStartCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX); + SColumnInfoData* pCalEndCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX); + SColumnInfoData* pTbNameCol = taosArrayGet(pBlock->pDataBlock, TABLE_NAME_COLUMN_INDEX); + colDataSetVal(pStartCol, pBlock->info.rows, (const char*)&start, false); + colDataSetVal(pEndCol, pBlock->info.rows, (const char*)&end, false); + colDataSetNULL(pUidCol, pBlock->info.rows); + colDataSetVal(pGroupCol, pBlock->info.rows, (const char*)&groupId, false); + colDataSetNULL(pCalStartCol, pBlock->info.rows); + colDataSetNULL(pCalEndCol, pBlock->info.rows); + + SColumnInfoData* pTableCol = taosArrayGet(pBlock->pDataBlock, TABLE_NAME_COLUMN_INDEX); + + void* tbname = NULL; + pAPI->stateStore.streamStateGetParName(pOp->pTaskInfo->streamInfo.pState, groupId, &tbname); + if (tbname == NULL) { + colDataSetNULL(pTableCol, pBlock->info.rows); + } else { + char parTbName[VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN]; + STR_WITH_MAXSIZE_TO_VARSTR(parTbName, tbname, sizeof(parTbName)); + colDataSetVal(pTableCol, pBlock->info.rows, (const char*)parTbName, false); + pAPI->stateStore.streamStateFreeVal(tbname); + } + + pBlock->info.rows++; +} + +static void buildDeleteResult(SOperatorInfo* pOperator, TSKEY startTs, TSKEY endTs, uint64_t groupId, + SSDataBlock* delRes) { + SStreamFillOperatorInfo* pInfo = pOperator->info; + SStreamFillSupporter* pFillSup = pInfo->pFillSup; + if (hasPrevWindow(pFillSup)) { + TSKEY start = getNextWindowTs(pFillSup->prev.key, &pFillSup->interval); + buildDeleteRange(pOperator, start, endTs, groupId, delRes); + } else if (hasNextWindow(pFillSup)) { + TSKEY end = getPrevWindowTs(pFillSup->next.key, &pFillSup->interval); + buildDeleteRange(pOperator, startTs, end, groupId, delRes); + } else { + buildDeleteRange(pOperator, startTs, endTs, groupId, delRes); + } +} + +static void doDeleteFillResultImpl(SOperatorInfo* pOperator, TSKEY startTs, TSKEY endTs, uint64_t groupId) { + SStorageAPI* pAPI = &pOperator->pTaskInfo->storageAPI; + SStreamFillOperatorInfo* pInfo = pOperator->info; + getWindowFromDiscBuf(pOperator, startTs, groupId, pInfo->pFillSup); + setDeleteFillValueInfo(startTs, endTs, pInfo->pFillSup, pInfo->pFillInfo); + SWinKey key = {.ts = startTs, .groupId = groupId}; + if (!pInfo->pFillInfo->needFill) { + pAPI->stateStore.streamStateFillDel(pOperator->pTaskInfo->streamInfo.pState, &key); + buildDeleteResult(pOperator, startTs, endTs, groupId, pInfo->pDelRes); + } else { + STimeRange tw = { + .skey = startTs, + .ekey = endTs, + .groupId = groupId, + }; + taosArrayPush(pInfo->pFillInfo->delRanges, &tw); + while (key.ts <= endTs) { + key.ts = taosTimeAdd(key.ts, pInfo->pFillSup->interval.sliding, pInfo->pFillSup->interval.slidingUnit, + pInfo->pFillSup->interval.precision); + tSimpleHashPut(pInfo->pFillSup->pResMap, &key, sizeof(SWinKey), NULL, 0); + } + } +} + +static void doDeleteFillFinalize(SOperatorInfo* pOperator) { + SStorageAPI* pAPI = &pOperator->pTaskInfo->storageAPI; + + SStreamFillOperatorInfo* pInfo = pOperator->info; + SStreamFillInfo* pFillInfo = pInfo->pFillInfo; + int32_t size = taosArrayGetSize(pFillInfo->delRanges); + tSimpleHashClear(pInfo->pFillSup->pResMap); + for (; pFillInfo->delIndex < size; pFillInfo->delIndex++) { + STimeRange* range = taosArrayGet(pFillInfo->delRanges, pFillInfo->delIndex); + if (pInfo->pRes->info.id.groupId != 0 && pInfo->pRes->info.id.groupId != range->groupId) { + return; + } + getWindowFromDiscBuf(pOperator, range->skey, range->groupId, pInfo->pFillSup); + setDeleteFillValueInfo(range->skey, range->ekey, pInfo->pFillSup, pInfo->pFillInfo); + if (pInfo->pFillInfo->needFill) { + doStreamFillRange(pInfo->pFillInfo, pInfo->pFillSup, pInfo->pRes); + pInfo->pRes->info.id.groupId = range->groupId; + } + SWinKey key = {.ts = range->skey, .groupId = range->groupId}; + pAPI->stateStore.streamStateFillDel(pOperator->pTaskInfo->streamInfo.pState, &key); + } +} + +static void doDeleteFillResult(SOperatorInfo* pOperator) { + SStorageAPI* pAPI = &pOperator->pTaskInfo->storageAPI; + + SStreamFillOperatorInfo* pInfo = pOperator->info; + SStreamFillInfo* pFillInfo = pInfo->pFillInfo; + SSDataBlock* pBlock = pInfo->pSrcDelBlock; + + SColumnInfoData* pStartCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); + TSKEY* tsStarts = (TSKEY*)pStartCol->pData; + SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); + uint64_t* groupIds = (uint64_t*)pGroupCol->pData; + while (pInfo->srcDelRowIndex < pBlock->info.rows) { + TSKEY ts = tsStarts[pInfo->srcDelRowIndex]; + TSKEY endTs = ts; + uint64_t groupId = groupIds[pInfo->srcDelRowIndex]; + SWinKey key = {.ts = ts, .groupId = groupId}; + SStreamStateCur* pCur = pAPI->stateStore.streamStateGetAndCheckCur(pOperator->pTaskInfo->streamInfo.pState, &key); + + if (!pCur) { + pInfo->srcDelRowIndex++; + continue; + } + + SWinKey nextKey = {.groupId = groupId, .ts = ts}; + while (pInfo->srcDelRowIndex < pBlock->info.rows) { + TSKEY delTs = tsStarts[pInfo->srcDelRowIndex]; + uint64_t delGroupId = groupIds[pInfo->srcDelRowIndex]; + int32_t code = TSDB_CODE_SUCCESS; + if (groupId != delGroupId) { + break; + } + if (delTs > nextKey.ts) { + break; + } + + SWinKey delKey = {.groupId = delGroupId, .ts = delTs}; + if (delTs == nextKey.ts) { + code = pAPI->stateStore.streamStateCurNext(pOperator->pTaskInfo->streamInfo.pState, pCur); + if (code == TSDB_CODE_SUCCESS) { + code = pAPI->stateStore.streamStateGetGroupKVByCur(pCur, &nextKey, NULL, NULL); + } + // ts will be deleted later + if (delTs != ts) { + pAPI->stateStore.streamStateFillDel(pOperator->pTaskInfo->streamInfo.pState, &delKey); + pAPI->stateStore.streamStateFreeCur(pCur); + pCur = pAPI->stateStore.streamStateGetAndCheckCur(pOperator->pTaskInfo->streamInfo.pState, &nextKey); + } + endTs = TMAX(delTs, nextKey.ts - 1); + if (code != TSDB_CODE_SUCCESS) { + break; + } + } + pInfo->srcDelRowIndex++; + } + + pAPI->stateStore.streamStateFreeCur(pCur); + doDeleteFillResultImpl(pOperator, ts, endTs, groupId); + } + + pFillInfo->current = pFillInfo->end + 1; +} + +static void resetStreamFillInfo(SStreamFillOperatorInfo* pInfo) { + tSimpleHashClear(pInfo->pFillSup->pResMap); + pInfo->pFillSup->hasDelete = false; + taosArrayClear(pInfo->pFillInfo->delRanges); + pInfo->pFillInfo->delIndex = 0; +} + +static void doApplyStreamScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pSrcBlock, SSDataBlock* pDstBlock) { + SStreamFillOperatorInfo* pInfo = pOperator->info; + SExprSupp* pSup = &pOperator->exprSupp; + + blockDataCleanup(pDstBlock); + blockDataEnsureCapacity(pDstBlock, pSrcBlock->info.rows); + setInputDataBlock(pSup, pSrcBlock, TSDB_ORDER_ASC, MAIN_SCAN, false); + projectApplyFunctions(pSup->pExprInfo, pDstBlock, pSrcBlock, pSup->pCtx, pSup->numOfExprs, NULL); + + pDstBlock->info.rows = 0; + pSup = &pInfo->pFillSup->notFillExprSup; + setInputDataBlock(pSup, pSrcBlock, TSDB_ORDER_ASC, MAIN_SCAN, false); + projectApplyFunctions(pSup->pExprInfo, pDstBlock, pSrcBlock, pSup->pCtx, pSup->numOfExprs, NULL); + pDstBlock->info.id.groupId = pSrcBlock->info.id.groupId; + + blockDataUpdateTsWindow(pDstBlock, pInfo->primaryTsCol); +} + +static SSDataBlock* doStreamFill(SOperatorInfo* pOperator) { + SStreamFillOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } + blockDataCleanup(pInfo->pRes); + if (hasRemainCalc(pInfo->pFillInfo) || + (pInfo->pFillInfo->pos != FILL_POS_INVALID && pInfo->pFillInfo->needFill == true)) { + doStreamFillRange(pInfo->pFillInfo, pInfo->pFillSup, pInfo->pRes); + if (pInfo->pRes->info.rows > 0) { + printDataBlock(pInfo->pRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pInfo->pRes; + } + } + if (pOperator->status == OP_RES_TO_RETURN) { + doDeleteFillFinalize(pOperator); + if (pInfo->pRes->info.rows > 0) { + printDataBlock(pInfo->pRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pInfo->pRes; + } + setOperatorCompleted(pOperator); + resetStreamFillInfo(pInfo); + return NULL; + } + + SSDataBlock* fillResult = NULL; + SOperatorInfo* downstream = pOperator->pDownstream[0]; + while (1) { + if (pInfo->srcRowIndex >= pInfo->pSrcBlock->info.rows || pInfo->pSrcBlock->info.rows == 0) { + // If there are delete datablocks, we receive them first. + SSDataBlock* pBlock = getNextBlockFromDownstream(pOperator, 0); + if (pBlock == NULL) { + pOperator->status = OP_RES_TO_RETURN; + pInfo->pFillInfo->preRowKey = INT64_MIN; + if (pInfo->pRes->info.rows > 0) { + printDataBlock(pInfo->pRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pInfo->pRes; + } + break; + } + printSpecDataBlock(pBlock, getStreamOpName(pOperator->operatorType), "recv", GET_TASKID(pTaskInfo)); + + if (pInfo->pFillInfo->curGroupId != pBlock->info.id.groupId) { + pInfo->pFillInfo->curGroupId = pBlock->info.id.groupId; + pInfo->pFillInfo->preRowKey = INT64_MIN; + } + + pInfo->pFillSup->winRange = pTaskInfo->streamInfo.fillHistoryWindow; + if (pInfo->pFillSup->winRange.ekey <= 0) { + pInfo->pFillSup->winRange.ekey = INT64_MAX; + } + + switch (pBlock->info.type) { + case STREAM_RETRIEVE: + return pBlock; + case STREAM_DELETE_RESULT: { + pInfo->pSrcDelBlock = pBlock; + pInfo->srcDelRowIndex = 0; + blockDataCleanup(pInfo->pDelRes); + pInfo->pFillSup->hasDelete = true; + doDeleteFillResult(pOperator); + if (pInfo->pDelRes->info.rows > 0) { + printDataBlock(pInfo->pDelRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pInfo->pDelRes; + } + continue; + } break; + case STREAM_NORMAL: + case STREAM_INVALID: + case STREAM_PULL_DATA: { + doApplyStreamScalarCalculation(pOperator, pBlock, pInfo->pSrcBlock); + memcpy(pInfo->pSrcBlock->info.parTbName, pBlock->info.parTbName, TSDB_TABLE_NAME_LEN); + pInfo->srcRowIndex = -1; + } break; + case STREAM_CHECKPOINT: + case STREAM_CREATE_CHILD_TABLE: { + return pBlock; + } break; + default: + ASSERTS(false, "invalid SSDataBlock type"); + } + } + + doStreamFillImpl(pOperator); + doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, &pInfo->matchInfo); + memcpy(pInfo->pRes->info.parTbName, pInfo->pSrcBlock->info.parTbName, TSDB_TABLE_NAME_LEN); + pOperator->resultInfo.totalRows += pInfo->pRes->info.rows; + if (pInfo->pRes->info.rows > 0) { + break; + } + } + if (pOperator->status == OP_RES_TO_RETURN) { + doDeleteFillFinalize(pOperator); + } + + if (pInfo->pRes->info.rows == 0) { + setOperatorCompleted(pOperator); + resetStreamFillInfo(pInfo); + return NULL; + } + + pOperator->resultInfo.totalRows += pInfo->pRes->info.rows; + printDataBlock(pInfo->pRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pInfo->pRes; +} + +static int32_t initResultBuf(SStreamFillSupporter* pFillSup) { + pFillSup->rowSize = sizeof(SResultCellData) * pFillSup->numOfAllCols; + for (int i = 0; i < pFillSup->numOfAllCols; i++) { + SFillColInfo* pCol = &pFillSup->pAllColInfo[i]; + SResSchema* pSchema = &pCol->pExpr->base.resSchema; + pFillSup->rowSize += pSchema->bytes; + } + pFillSup->next.key = INT64_MIN; + pFillSup->nextNext.key = INT64_MIN; + pFillSup->prev.key = INT64_MIN; + pFillSup->cur.key = INT64_MIN; + pFillSup->next.pRowVal = NULL; + pFillSup->nextNext.pRowVal = NULL; + pFillSup->prev.pRowVal = NULL; + pFillSup->cur.pRowVal = NULL; + + return TSDB_CODE_SUCCESS; +} + +static SStreamFillSupporter* initStreamFillSup(SStreamFillPhysiNode* pPhyFillNode, SInterval* pInterval, + SExprInfo* pFillExprInfo, int32_t numOfFillCols, SStorageAPI* pAPI) { + SStreamFillSupporter* pFillSup = taosMemoryCalloc(1, sizeof(SStreamFillSupporter)); + if (!pFillSup) { + return NULL; + } + pFillSup->numOfFillCols = numOfFillCols; + int32_t numOfNotFillCols = 0; + SExprInfo* noFillExprInfo = createExprInfo(pPhyFillNode->pNotFillExprs, NULL, &numOfNotFillCols); + pFillSup->pAllColInfo = createFillColInfo(pFillExprInfo, pFillSup->numOfFillCols, noFillExprInfo, numOfNotFillCols, + (const SNodeListNode*)(pPhyFillNode->pValues)); + pFillSup->type = convertFillType(pPhyFillNode->mode); + pFillSup->numOfAllCols = pFillSup->numOfFillCols + numOfNotFillCols; + pFillSup->interval = *pInterval; + pFillSup->pAPI = pAPI; + + int32_t code = initResultBuf(pFillSup); + if (code != TSDB_CODE_SUCCESS) { + destroyStreamFillSupporter(pFillSup); + return NULL; + } + + SExprInfo* noFillExpr = createExprInfo(pPhyFillNode->pNotFillExprs, NULL, &numOfNotFillCols); + code = initExprSupp(&pFillSup->notFillExprSup, noFillExpr, numOfNotFillCols, &pAPI->functionStore); + if (code != TSDB_CODE_SUCCESS) { + destroyStreamFillSupporter(pFillSup); + return NULL; + } + + _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); + pFillSup->pResMap = tSimpleHashInit(16, hashFn); + pFillSup->hasDelete = false; + return pFillSup; +} + +SStreamFillInfo* initStreamFillInfo(SStreamFillSupporter* pFillSup, SSDataBlock* pRes) { + SStreamFillInfo* pFillInfo = taosMemoryCalloc(1, sizeof(SStreamFillInfo)); + pFillInfo->start = INT64_MIN; + pFillInfo->current = INT64_MIN; + pFillInfo->end = INT64_MIN; + pFillInfo->preRowKey = INT64_MIN; + pFillInfo->needFill = false; + pFillInfo->pLinearInfo = taosMemoryCalloc(1, sizeof(SStreamFillLinearInfo)); + pFillInfo->pLinearInfo->hasNext = false; + pFillInfo->pLinearInfo->nextEnd = INT64_MIN; + pFillInfo->pLinearInfo->pEndPoints = NULL; + pFillInfo->pLinearInfo->pNextEndPoints = NULL; + if (pFillSup->type == TSDB_FILL_LINEAR) { + pFillInfo->pLinearInfo->pEndPoints = taosArrayInit(pFillSup->numOfAllCols, sizeof(SPoint)); + pFillInfo->pLinearInfo->pNextEndPoints = taosArrayInit(pFillSup->numOfAllCols, sizeof(SPoint)); + for (int32_t i = 0; i < pFillSup->numOfAllCols; i++) { + SColumnInfoData* pColData = taosArrayGet(pRes->pDataBlock, i); + SPoint value = {0}; + value.val = taosMemoryCalloc(1, pColData->info.bytes); + taosArrayPush(pFillInfo->pLinearInfo->pEndPoints, &value); + + value.val = taosMemoryCalloc(1, pColData->info.bytes); + taosArrayPush(pFillInfo->pLinearInfo->pNextEndPoints, &value); + } + } + pFillInfo->pLinearInfo->winIndex = 0; + + pFillInfo->pResRow = NULL; + if (pFillSup->type == TSDB_FILL_SET_VALUE || pFillSup->type == TSDB_FILL_SET_VALUE_F || + pFillSup->type == TSDB_FILL_NULL || pFillSup->type == TSDB_FILL_NULL_F) { + pFillInfo->pResRow = taosMemoryCalloc(1, sizeof(SResultRowData)); + pFillInfo->pResRow->key = INT64_MIN; + pFillInfo->pResRow->pRowVal = taosMemoryCalloc(1, pFillSup->rowSize); + for (int32_t i = 0; i < pFillSup->numOfAllCols; ++i) { + SColumnInfoData* pColData = taosArrayGet(pRes->pDataBlock, i); + SResultCellData* pCell = getResultCell(pFillInfo->pResRow, i); + pCell->bytes = pColData->info.bytes; + pCell->type = pColData->info.type; + } + } + + pFillInfo->type = pFillSup->type; + pFillInfo->delRanges = taosArrayInit(16, sizeof(STimeRange)); + pFillInfo->delIndex = 0; + pFillInfo->curGroupId = 0; + return pFillInfo; +} + +SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFillPhysiNode* pPhyFillNode, + SExecTaskInfo* pTaskInfo) { + SStreamFillOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamFillOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + if (pInfo == NULL || pOperator == NULL) { + goto _error; + } + + SInterval* pInterval = &((SStreamIntervalOperatorInfo*)downstream->info)->interval; + int32_t numOfFillCols = 0; + SExprInfo* pFillExprInfo = createExprInfo(pPhyFillNode->pFillExprs, NULL, &numOfFillCols); + pInfo->pFillSup = initStreamFillSup(pPhyFillNode, pInterval, pFillExprInfo, numOfFillCols, &pTaskInfo->storageAPI); + if (!pInfo->pFillSup) { + goto _error; + } + + initResultSizeInfo(&pOperator->resultInfo, 4096); + pInfo->pRes = createDataBlockFromDescNode(pPhyFillNode->node.pOutputDataBlockDesc); + pInfo->pSrcBlock = createDataBlockFromDescNode(pPhyFillNode->node.pOutputDataBlockDesc); + blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity); + blockDataEnsureCapacity(pInfo->pSrcBlock, pOperator->resultInfo.capacity); + + pInfo->pFillInfo = initStreamFillInfo(pInfo->pFillSup, pInfo->pRes); + if (!pInfo->pFillInfo) { + goto _error; + } + + if (pInfo->pFillInfo->type == TSDB_FILL_SET_VALUE || pInfo->pFillInfo->type == TSDB_FILL_SET_VALUE_F) { + for (int32_t i = 0; i < pInfo->pFillSup->numOfAllCols; ++i) { + SFillColInfo* pFillCol = pInfo->pFillSup->pAllColInfo + i; + int32_t slotId = GET_DEST_SLOT_ID(pFillCol); + SResultCellData* pCell = getResultCell(pInfo->pFillInfo->pResRow, slotId); + SVariant* pVar = &(pFillCol->fillVal); + if (pCell->type == TSDB_DATA_TYPE_FLOAT) { + float v = 0; + GET_TYPED_DATA(v, float, pVar->nType, &pVar->i); + SET_TYPED_DATA(pCell->pData, pCell->type, v); + } else if (IS_FLOAT_TYPE(pCell->type)) { + double v = 0; + GET_TYPED_DATA(v, double, pVar->nType, &pVar->i); + SET_TYPED_DATA(pCell->pData, pCell->type, v); + } else if (IS_INTEGER_TYPE(pCell->type)) { + int64_t v = 0; + GET_TYPED_DATA(v, int64_t, pVar->nType, &pVar->i); + SET_TYPED_DATA(pCell->pData, pCell->type, v); + } else { + pCell->isNull = true; + } + } + } else if (pInfo->pFillInfo->type == TSDB_FILL_NULL || pInfo->pFillInfo->type == TSDB_FILL_NULL_F) { + for (int32_t i = 0; i < pInfo->pFillSup->numOfAllCols; ++i) { + SFillColInfo* pFillCol = pInfo->pFillSup->pAllColInfo + i; + int32_t slotId = GET_DEST_SLOT_ID(pFillCol); + SResultCellData* pCell = getResultCell(pInfo->pFillInfo->pResRow, slotId); + pCell->isNull = true; + } + } + + pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT); + blockDataEnsureCapacity(pInfo->pDelRes, pOperator->resultInfo.capacity); + + pInfo->primaryTsCol = ((STargetNode*)pPhyFillNode->pWStartTs)->slotId; + pInfo->primarySrcSlotId = ((SColumnNode*)((STargetNode*)pPhyFillNode->pWStartTs)->pExpr)->slotId; + + int32_t numOfOutputCols = 0; + int32_t code = extractColMatchInfo(pPhyFillNode->pFillExprs, pPhyFillNode->node.pOutputDataBlockDesc, + &numOfOutputCols, COL_MATCH_FROM_SLOT_ID, &pInfo->matchInfo); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + code = filterInitFromNode((SNode*)pPhyFillNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + code = initExprSupp(&pOperator->exprSupp, pFillExprInfo, numOfFillCols, &pTaskInfo->storageAPI.functionStore); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + pInfo->srcRowIndex = -1; + setOperatorInfo(pOperator, "StreamFillOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL, false, OP_NOT_OPENED, pInfo, + pTaskInfo); + pOperator->fpSet = + createOperatorFpSet(optrDummyOpenFn, doStreamFill, NULL, destroyStreamFillOperatorInfo, optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL); + setOperatorStreamStateFn(pOperator, streamOpReleaseState, streamOpReloadState); + + code = appendDownstream(pOperator, &downstream, 1); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + return pOperator; + +_error: + destroyStreamFillOperatorInfo(pInfo); + taosMemoryFreeClear(pOperator); + pTaskInfo->code = code; + return NULL; +} diff --git a/source/libs/executor/src/streamtimewindowoperator.c b/source/libs/executor/src/streamtimewindowoperator.c index 7a1bb2729c..51071e2b4a 100644 --- a/source/libs/executor/src/streamtimewindowoperator.c +++ b/source/libs/executor/src/streamtimewindowoperator.c @@ -221,7 +221,7 @@ static bool doDeleteWindow(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId) static int32_t getChildIndex(SSDataBlock* pBlock) { return pBlock->info.childId; } static void doDeleteWindows(SOperatorInfo* pOperator, SInterval* pInterval, SSDataBlock* pBlock, SArray* pUpWins, - SSHashObj* pUpdatedMap) { + SSHashObj* pUpdatedMap, SHashObj* pInvalidWins) { SStreamIntervalOperatorInfo* pInfo = pOperator->info; SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); TSKEY* startTsCols = (TSKEY*)pStartTsCol->pData; @@ -255,10 +255,15 @@ static void doDeleteWindows(SOperatorInfo* pOperator, SInterval* pInterval, SSDa void* chIds = taosHashGet(pInfo->pPullDataMap, &winRes, sizeof(SWinKey)); if (chIds) { int32_t childId = getChildIndex(pBlock); + if (pInvalidWins) { + qDebug("===stream===save mid delete window:%" PRId64 ",groupId:%" PRId64 ",chId:%d", winRes.ts, winRes.groupId, childId); + taosHashPut(pInvalidWins, &winRes, sizeof(SWinKey), NULL, 0); + } + SArray* chArray = *(void**)chIds; int32_t index = taosArraySearchIdx(chArray, &childId, compareInt32Val, TD_EQ); if (index != -1) { - qDebug("===stream===try push delete window%" PRId64 "chId:%d ,continue", win.skey, childId); + qDebug("===stream===try push delete window:%" PRId64 ",groupId:%" PRId64 ",chId:%d ,continue", win.skey, winGpId, childId); getNextTimeWindow(pInterval, &win, TSDB_ORDER_ASC); continue; } @@ -413,6 +418,7 @@ void destroyStreamFinalIntervalOperatorInfo(void* param) { blockDataDestroy(pInfo->pMidRetriveRes); blockDataDestroy(pInfo->pMidPulloverRes); pInfo->stateStore.streamFileStateDestroy(pInfo->pState->pFileState); + taosArrayDestroy(pInfo->pMidPullDatas); if (pInfo->pState->dump == 1) { taosMemoryFreeClear(pInfo->pState->pTdbState->pOwner); @@ -642,9 +648,12 @@ static bool processPullOver(SSDataBlock* pBlock, SHashObj* pMap, SHashObj* pFina .calWin.skey = nextWin.skey, .calWin.ekey = nextWin.skey}; // add pull data request - if (savePullWindow(&pull, pPullWins) == TSDB_CODE_SUCCESS) { + qDebug("===stream===prepare final retrive for delete window:%" PRId64 ",groupId%" PRId64 ", size:%d", winRes.ts, winRes.groupId, numOfCh); + if (IS_MID_INTERVAL_OP(pOperator)) { + SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperator->info; + taosArrayPush(pInfo->pMidPullDatas, &winRes); + } else if (savePullWindow(&pull, pPullWins) == TSDB_CODE_SUCCESS) { addPullWindow(pMap, &winRes, numOfCh); - qDebug("===stream===prepare final retrive for delete %" PRId64 ", size:%d", winRes.ts, numOfCh); } } } @@ -1191,11 +1200,6 @@ static SSDataBlock* buildIntervalResult(SOperatorInfo* pOperator) { return pInfo->binfo.pRes; } - if (pInfo->recvPullover) { - pInfo->recvPullover = false; - printDataBlock(pInfo->pMidPulloverRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); - return pInfo->pMidPulloverRes; - } return NULL; } @@ -1273,16 +1277,8 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { while (1) { if (isTaskKilled(pTaskInfo)) { - if (pInfo->pUpdated != NULL) { - pInfo->pUpdated = taosArrayDestroy(pInfo->pUpdated); - } - - if (pInfo->pUpdatedMap != NULL) { - tSimpleHashCleanup(pInfo->pUpdatedMap); - pInfo->pUpdatedMap = NULL; - } - qInfo("%s task is killed, code %s", GET_TASKID(pTaskInfo), tstrerror(pTaskInfo->code)); - T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); + qInfo("===stream=== %s task is killed, code %s", GET_TASKID(pTaskInfo), tstrerror(pTaskInfo->code)); + return NULL; } SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); @@ -1301,7 +1297,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT || pBlock->info.type == STREAM_CLEAR) { SArray* delWins = taosArrayInit(8, sizeof(SWinKey)); - doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap); + doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap, NULL); if (IS_FINAL_INTERVAL_OP(pOperator)) { int32_t chId = getChildIndex(pBlock); addRetriveWindow(delWins, pInfo, chId); @@ -1337,7 +1333,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { pInfo->recvRetrive = true; copyDataBlock(pInfo->pMidRetriveRes, pBlock); pInfo->pMidRetriveRes->info.type = STREAM_MID_RETRIEVE; - doDeleteWindows(pOperator, &pInfo->interval, pBlock, NULL, pInfo->pUpdatedMap); + doDeleteWindows(pOperator, &pInfo->interval, pBlock, NULL, pInfo->pUpdatedMap, NULL); break; } continue; @@ -1565,8 +1561,10 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, pInfo->pCheckpointRes = createSpecialDataBlock(STREAM_CHECKPOINT); pInfo->recvRetrive = false; pInfo->pMidRetriveRes = createSpecialDataBlock(STREAM_MID_RETRIEVE); + pInfo->recvPullover = false; pInfo->pMidPulloverRes = createSpecialDataBlock(STREAM_MID_RETRIEVE); pInfo->clearState = false; + pInfo->pMidPullDatas = taosArrayInit(4, sizeof(SWinKey)); pOperator->operatorType = pPhyNode->type; if (!IS_FINAL_INTERVAL_OP(pOperator) || numOfChild == 0) { @@ -1845,11 +1843,6 @@ int32_t releaseOutputBuf(void* pState, SRowBuffPos* pPos, SStateStore* pAPI) { return TSDB_CODE_SUCCESS; } -int32_t reuseOutputBuf(void* pState, SRowBuffPos* pPos, SStateStore* pAPI) { - pAPI->streamStateReleaseBuf(pState, pPos, true); - return TSDB_CODE_SUCCESS; -} - void removeSessionResult(SStreamAggSupporter* pAggSup, SSHashObj* pHashMap, SSHashObj* pResMap, SSessionKey* pKey) { SSessionKey key = {0}; getSessionHashKey(pKey, &key); @@ -2495,7 +2488,7 @@ void getMaxTsWins(const SArray* pAllWins, SArray* pMaxWins) { return; } SResultWindowInfo* pWinInfo = taosArrayGet(pAllWins, size - 1); - SSessionKey* pSeKey = pWinInfo->pStatePos->pKey; + SSessionKey* pSeKey = &pWinInfo->sessionWin; taosArrayPush(pMaxWins, pSeKey); if (pSeKey->groupId == 0) { return; @@ -2503,7 +2496,7 @@ void getMaxTsWins(const SArray* pAllWins, SArray* pMaxWins) { uint64_t preGpId = pSeKey->groupId; for (int32_t i = size - 2; i >= 0; i--) { pWinInfo = taosArrayGet(pAllWins, i); - pSeKey = pWinInfo->pStatePos->pKey; + pSeKey = &pWinInfo->sessionWin; if (preGpId != pSeKey->groupId) { taosArrayPush(pMaxWins, pSeKey); preGpId = pSeKey->groupId; @@ -3979,7 +3972,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT || pBlock->info.type == STREAM_CLEAR) { - doDeleteWindows(pOperator, &pInfo->interval, pBlock, pInfo->pDelWins, pInfo->pUpdatedMap); + doDeleteWindows(pOperator, &pInfo->interval, pBlock, pInfo->pDelWins, pInfo->pUpdatedMap, NULL); continue; } else if (pBlock->info.type == STREAM_GET_ALL) { pInfo->recvGetAll = true; @@ -4272,6 +4265,34 @@ static void addMidRetriveWindow(SArray* wins, SHashObj* pMidPullMap, int32_t num } } +static SSDataBlock* buildMidIntervalResult(SOperatorInfo* pOperator) { + SStreamIntervalOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + uint16_t opType = pOperator->operatorType; + + if (pInfo->recvPullover) { + pInfo->recvPullover = false; + printDataBlock(pInfo->pMidPulloverRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pInfo->pMidPulloverRes; + } + + qDebug("===stream=== build mid interval result"); + doBuildDeleteResult(pInfo, pInfo->pMidPullDatas, &pInfo->midDelIndex, pInfo->pDelRes); + if (pInfo->pDelRes->info.rows != 0) { + // process the rest of the data + printDataBlock(pInfo->pDelRes, getStreamOpName(opType), GET_TASKID(pTaskInfo)); + return pInfo->pDelRes; + } + + if (pInfo->recvRetrive) { + pInfo->recvRetrive = false; + printDataBlock(pInfo->pMidRetriveRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pInfo->pMidRetriveRes; + } + + return NULL; +} + static SSDataBlock* doStreamMidIntervalAgg(SOperatorInfo* pOperator) { SStreamIntervalOperatorInfo* pInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; @@ -4300,10 +4321,9 @@ static SSDataBlock* doStreamMidIntervalAgg(SOperatorInfo* pOperator) { return resBlock; } - if (pInfo->recvRetrive) { - pInfo->recvRetrive = false; - printDataBlock(pInfo->pMidRetriveRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); - return pInfo->pMidRetriveRes; + resBlock = buildMidIntervalResult(pOperator); + if (resBlock != NULL) { + return resBlock; } if (pInfo->clearState) { @@ -4323,16 +4343,8 @@ static SSDataBlock* doStreamMidIntervalAgg(SOperatorInfo* pOperator) { while (1) { if (isTaskKilled(pTaskInfo)) { - if (pInfo->pUpdated != NULL) { - pInfo->pUpdated = taosArrayDestroy(pInfo->pUpdated); - } - - if (pInfo->pUpdatedMap != NULL) { - tSimpleHashCleanup(pInfo->pUpdatedMap); - pInfo->pUpdatedMap = NULL; - } - - T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); + qInfo("===stream=== %s task is killed, code %s", GET_TASKID(pTaskInfo), tstrerror(pTaskInfo->code)); + return NULL; } SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); @@ -4351,7 +4363,7 @@ static SSDataBlock* doStreamMidIntervalAgg(SOperatorInfo* pOperator) { } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT || pBlock->info.type == STREAM_CLEAR) { SArray* delWins = taosArrayInit(8, sizeof(SWinKey)); - doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap); + doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap, pInfo->pFinalPullDataMap); removeResults(delWins, pInfo->pUpdatedMap); taosArrayAddAll(pInfo->pDelWins, delWins); taosArrayDestroy(delWins); @@ -4387,7 +4399,7 @@ static SSDataBlock* doStreamMidIntervalAgg(SOperatorInfo* pOperator) { continue; } else if (pBlock->info.type == STREAM_MID_RETRIEVE) { SArray* delWins = taosArrayInit(8, sizeof(SWinKey)); - doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap); + doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap, NULL); addMidRetriveWindow(delWins, pInfo->pPullDataMap, pInfo->numOfChild); taosArrayDestroy(delWins); pInfo->recvRetrive = true; @@ -4432,10 +4444,9 @@ static SSDataBlock* doStreamMidIntervalAgg(SOperatorInfo* pOperator) { return resBlock; } - if (pInfo->recvRetrive) { - pInfo->recvRetrive = false; - printDataBlock(pInfo->pMidRetriveRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); - return pInfo->pMidRetriveRes; + resBlock = buildMidIntervalResult(pOperator); + if (resBlock != NULL) { + return resBlock; } if (pInfo->clearState) { diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index f13ac88ae1..5735ee298b 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -14,6 +14,7 @@ */ #include "executorInt.h" +#include "geosWrapper.h" #include "filter.h" #include "functionMgt.h" #include "querynodes.h" @@ -811,6 +812,8 @@ int32_t convertTagDataToStr(char* str, int type, void* buf, int32_t bufSize, int break; case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_VARBINARY: + case TSDB_DATA_TYPE_GEOMETRY: if (bufSize < 0) { return TSDB_CODE_TSC_INVALID_VALUE; } @@ -854,6 +857,30 @@ int32_t convertTagDataToStr(char* str, int type, void* buf, int32_t bufSize, int return TSDB_CODE_SUCCESS; } +static int32_t sysTableGetGeomText(char* iGeom, int32_t nGeom, char** output, int32_t* nOutput) { + int32_t code = 0; + char* outputWKT = NULL; + + if (nGeom == 0) { + if (!(*output = strdup(""))) code = TSDB_CODE_OUT_OF_MEMORY; + *nOutput = 0; + return code; + } + + if (TSDB_CODE_SUCCESS != (code = initCtxAsText()) || + TSDB_CODE_SUCCESS != (code = doAsText(iGeom, nGeom, &outputWKT))) { + qError("geo text for systable failed:%s", getThreadLocalGeosCtx()->errMsg); + *output = NULL; + *nOutput = 0; + return code; + } + + *output = outputWKT; + *nOutput = strlen(outputWKT); + + return code; +} + static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo, SMetaReader* smrSuperTable, SMetaReader* smrChildTable, const char* dbname, const char* tableName, int32_t* pNumOfRows, const SSDataBlock* dataBlock) { @@ -889,13 +916,13 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo, pColInfoData = taosArrayGet(dataBlock->pDataBlock, 4); char tagTypeStr[VARSTR_HEADER_SIZE + 32]; int tagTypeLen = sprintf(varDataVal(tagTypeStr), "%s", tDataTypes[tagType].name); - if (tagType == TSDB_DATA_TYPE_VARCHAR) { - tagTypeLen += sprintf(varDataVal(tagTypeStr) + tagTypeLen, "(%d)", - (int32_t)((*smrSuperTable).me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE)); - } else if (tagType == TSDB_DATA_TYPE_NCHAR) { + if (tagType == TSDB_DATA_TYPE_NCHAR) { tagTypeLen += sprintf( varDataVal(tagTypeStr) + tagTypeLen, "(%d)", (int32_t)(((*smrSuperTable).me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)); + } else if (IS_VAR_DATA_TYPE(tagType)) { + tagTypeLen += sprintf(varDataVal(tagTypeStr) + tagTypeLen, "(%d)", + (int32_t)((*smrSuperTable).me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE)); } varDataSetLen(tagTypeStr, tagTypeLen); colDataSetVal(pColInfoData, numOfRows, (char*)tagTypeStr, false); @@ -910,7 +937,13 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo, } else { bool exist = tTagGet((STag*)smrChildTable->me.ctbEntry.pTags, &tagVal); if (exist) { - if (IS_VAR_DATA_TYPE(tagType)) { + if (tagType == TSDB_DATA_TYPE_GEOMETRY) { + sysTableGetGeomText(tagVal.pData, tagVal.nData, &tagData, &tagLen); + } else if (tagType == TSDB_DATA_TYPE_VARBINARY) { + if (taosAscii2Hex(tagVal.pData, tagVal.nData, (void**)&tagData, &tagLen) < 0) { + qError("varbinary for systable failed since %s", tstrerror(TSDB_CODE_OUT_OF_MEMORY)); + } + } else if (IS_VAR_DATA_TYPE(tagType)) { tagData = (char*)tagVal.pData; tagLen = tagVal.nData; } else { @@ -940,6 +973,7 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo, pColInfoData = taosArrayGet(dataBlock->pDataBlock, 5); colDataSetVal(pColInfoData, numOfRows, tagVarChar, (tagData == NULL) || (tagType == TSDB_DATA_TYPE_JSON && tTagIsJsonNull(tagData))); + if (tagType == TSDB_DATA_TYPE_GEOMETRY || tagType == TSDB_DATA_TYPE_VARBINARY) taosMemoryFreeClear(tagData); taosMemoryFree(tagVarChar); ++numOfRows; } diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 10220426a3..82881dcd14 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -32,6 +32,32 @@ struct STupleHandle { int32_t rowIndex; }; +typedef struct SSortMemFileRegion { + int64_t fileOffset; + int32_t regionSize; + + int32_t bufRegOffset; + int32_t bufLen; + char* buf; +} SSortMemFileRegion; + +typedef struct SSortMemFile { + char* writeBuf; + int32_t writeBufSize; + int64_t writeFileOffset; + + int32_t currRegionId; + int32_t currRegionOffset; + bool bRegionDirty; + + SArray* aFileRegions; + int32_t cacheSize; + int32_t blockSize; + + FILE* pTdFile; + char memFilePath[PATH_MAX]; +} SSortMemFile; + struct SSortHandle { int32_t type; int32_t pageSize; @@ -76,10 +102,21 @@ struct SSortHandle { bool (*abortCheckFn)(void* param); void* abortCheckParam; + bool bSortByRowId; + SSortMemFile* pExtRowsMemFile; + int32_t extRowBytes; + int32_t extRowsPageSize; + int32_t extRowsMemSize; + int32_t srcTsSlotId; + SBlockOrderInfo extRowsOrderInfo; + void (*mergeLimitReachedFn)(uint64_t tableUid, void* param); void* mergeLimitReachedParam; }; +static int32_t destroySortMemFile(SSortHandle* pHandle); +static int32_t getRowBufFromExtMemFile(SSortHandle* pHandle, int32_t regionId, int32_t tupleOffset, int32_t rowLen, + char** ppRow, bool* pFreeRow); void tsortSetSingleTableMerge(SSortHandle* pHandle) { pHandle->singleTableMerge = true; } @@ -189,6 +226,7 @@ void destroyTuple(void* t) { } } + /** * * @param type @@ -202,7 +240,7 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t page pSortHandle->type = type; pSortHandle->pageSize = pageSize; pSortHandle->numOfPages = numOfPages; - pSortHandle->pSortInfo = pSortInfo; + pSortHandle->pSortInfo = taosArrayDup(pSortInfo, NULL); pSortHandle->loops = 0; pSortHandle->pqMaxTupleLength = pqMaxTupleLength; @@ -305,6 +343,10 @@ void tsortDestroySortHandle(SSortHandle* pSortHandle) { qDebug("all source fetch time: %" PRId64 "us num:%" PRId64 " %s", fetchUs, fetchNum, pSortHandle->idStr); taosArrayDestroy(pSortHandle->pOrderedSource); + if (pSortHandle->pExtRowsMemFile != NULL) { + destroySortMemFile(pSortHandle); + } + taosArrayDestroy(pSortHandle->pSortInfo); taosMemoryFreeClear(pSortHandle); } @@ -851,6 +893,389 @@ static int32_t createPageBuf(SSortHandle* pHandle) { return 0; } +void tsortAppendTupleToBlock(SSortHandle* pHandle, SSDataBlock* pBlock, STupleHandle* pTupleHandle) { + if (pHandle->bSortByRowId) { + int32_t regionId = *(int32_t*)tsortGetValue(pTupleHandle, 1); + int32_t offset = *(int32_t*)tsortGetValue(pTupleHandle, 2); + int32_t length = *(int32_t*)tsortGetValue(pTupleHandle, 3); + + char* buf = NULL; + bool bFreeRow = false; + getRowBufFromExtMemFile(pHandle, regionId, offset, length, &buf, &bFreeRow); + int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); + char* isNull = (char*)buf; + char* pStart = (char*)buf + sizeof(int8_t) * numOfCols; + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, i); + + if (!isNull[i]) { + colDataSetVal(pColInfo, pBlock->info.rows, pStart, false); + if (pColInfo->info.type == TSDB_DATA_TYPE_JSON) { + int32_t dataLen = getJsonValueLen(pStart); + pStart += dataLen; + } else if (IS_VAR_DATA_TYPE(pColInfo->info.type)) { + pStart += varDataTLen(pStart); + } else { + int32_t bytes = pColInfo->info.bytes; + pStart += bytes; + } + } else { + colDataSetNULL(pColInfo, pBlock->info.rows); + } + } + if (bFreeRow) { + taosMemoryFree(buf); + } + if (*(int32_t*)pStart != pStart - buf) { + qError("table merge scan row buf deserialization. length error %d != %d ", *(int32_t*)pStart, + (int32_t)(pStart - buf)); + }; + + pBlock->info.dataLoad = 1; + pBlock->info.scanFlag = ((SDataBlockInfo*)tsortGetBlockInfo(pTupleHandle))->scanFlag; + pBlock->info.rows += 1; + + } else { + for (int32_t i = 0; i < taosArrayGetSize(pBlock->pDataBlock); ++i) { + SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, i); + bool isNull = tsortIsNullVal(pTupleHandle, i); + if (isNull) { + colDataSetNULL(pColInfo, pBlock->info.rows); + } else { + char* pData = tsortGetValue(pTupleHandle, i); + if (pData != NULL) { + colDataSetVal(pColInfo, pBlock->info.rows, pData, false); + } + } + } + + pBlock->info.dataLoad = 1; + pBlock->info.scanFlag = ((SDataBlockInfo*)tsortGetBlockInfo(pTupleHandle))->scanFlag; + pBlock->info.rows += 1; + } +} + +static int32_t blockRowToBuf(SSDataBlock* pBlock, int32_t rowIdx, char* buf) { + size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); + + char* isNull = (char*)buf; + char* pStart = (char*)buf + sizeof(int8_t) * numOfCols; + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, i); + if (colDataIsNull_s(pCol, rowIdx)) { + isNull[i] = 1; + continue; + } + + isNull[i] = 0; + char* pData = colDataGetData(pCol, rowIdx); + if (pCol->info.type == TSDB_DATA_TYPE_JSON) { + if (pCol->pData) { + int32_t dataLen = getJsonValueLen(pData); + memcpy(pStart, pData, dataLen); + pStart += dataLen; + } else { + // the column that is pre-allocated has no data and has offset + *pStart = 0; + pStart += 1; + } + } else if (IS_VAR_DATA_TYPE(pCol->info.type)) { + if (pCol->pData) { + varDataCopy(pStart, pData); + pStart += varDataTLen(pData); + } else { + // the column that is pre-allocated has no data and has offset + *(VarDataLenT*)(pStart) = 0; + pStart += VARSTR_HEADER_SIZE; + } + } else { + int32_t bytes = pCol->info.bytes; + memcpy(pStart, pData, bytes); + pStart += bytes; + } + } + *(int32_t*)pStart = (char*)pStart - (char*)buf; + pStart += sizeof(int32_t); + return (int32_t)(pStart - (char*)buf); +} + +static int32_t getRowBufFromExtMemFile(SSortHandle* pHandle, int32_t regionId, int32_t tupleOffset, int32_t rowLen, + char** ppRow, bool* pFreeRow) { + SSortMemFile* pMemFile = pHandle->pExtRowsMemFile; + SSortMemFileRegion* pRegion = taosArrayGet(pMemFile->aFileRegions, regionId); + if (pRegion->buf == NULL) { + pRegion->bufRegOffset = 0; + pRegion->buf = taosMemoryMalloc(pMemFile->blockSize); + if (pRegion->buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + taosSeekCFile(pMemFile->pTdFile, pRegion->fileOffset, SEEK_SET); + int32_t readBytes = TMIN(pMemFile->blockSize, pRegion->regionSize); + int ret = taosReadFromCFile(pRegion->buf, readBytes, 1, pMemFile->pTdFile); + if (ret != 1) { + terrno = TAOS_SYSTEM_ERROR(errno); + return terrno; + } + pRegion->bufLen = readBytes; + } + ASSERT(pRegion->bufRegOffset <= tupleOffset); + if (pRegion->bufRegOffset + pRegion->bufLen >= tupleOffset + rowLen) { + *pFreeRow = false; + *ppRow = pRegion->buf + tupleOffset - pRegion->bufRegOffset; + } else { + *ppRow = taosMemoryMalloc(rowLen); + if (*ppRow == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + int32_t szThisBlock = pRegion->bufLen - (tupleOffset - pRegion->bufRegOffset); + memcpy(*ppRow, pRegion->buf + tupleOffset - pRegion->bufRegOffset, szThisBlock); + taosSeekCFile(pMemFile->pTdFile, pRegion->fileOffset + pRegion->bufRegOffset + pRegion->bufLen, SEEK_SET); + int32_t readBytes = TMIN(pMemFile->blockSize, pRegion->regionSize - (pRegion->bufRegOffset + pRegion->bufLen)); + int ret = taosReadFromCFile(pRegion->buf, readBytes, 1, pMemFile->pTdFile); + if (ret != 1) { + taosMemoryFreeClear(*ppRow); + terrno = TAOS_SYSTEM_ERROR(errno); + return terrno; + } + memcpy(*ppRow + szThisBlock, pRegion->buf, rowLen - szThisBlock); + *pFreeRow = true; + pRegion->bufRegOffset += pRegion->bufLen; + pRegion->bufLen = readBytes; + } + return TSDB_CODE_SUCCESS; +} + +static int32_t createSortMemFile(SSortHandle* pHandle) { + if (pHandle->pExtRowsMemFile != NULL) { + return TSDB_CODE_SUCCESS; + } + int32_t code = TSDB_CODE_SUCCESS; + SSortMemFile* pMemFile = taosMemoryCalloc(1, sizeof(SSortMemFile)); + if (pMemFile == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + if (code == TSDB_CODE_SUCCESS) { + taosGetTmpfilePath(tsTempDir, "sort-ext-mem", pMemFile->memFilePath); + pMemFile->pTdFile = taosOpenCFile(pMemFile->memFilePath, "w+"); + if (pMemFile->pTdFile == NULL) { + code = terrno = TAOS_SYSTEM_ERROR(errno); + } + } + if (code == TSDB_CODE_SUCCESS) { + taosSetAutoDelFile(pMemFile->memFilePath); + + pMemFile->currRegionId = -1; + pMemFile->currRegionOffset = -1; + + pMemFile->writeBufSize = 4 * 1024 * 1024; + pMemFile->writeFileOffset = -1; + pMemFile->bRegionDirty = false; + + pMemFile->writeBuf = taosMemoryMalloc(pMemFile->writeBufSize); + if (pMemFile->writeBuf == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + if (code == TSDB_CODE_SUCCESS) { + pMemFile->cacheSize = pHandle->extRowsMemSize; + pMemFile->aFileRegions = taosArrayInit(64, sizeof(SSortMemFileRegion)); + if (pMemFile->aFileRegions == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + if (code == TSDB_CODE_SUCCESS) { + pHandle->pExtRowsMemFile = pMemFile; + } else { + if (pMemFile) { + if (pMemFile->aFileRegions) taosMemoryFreeClear(pMemFile->aFileRegions); + if (pMemFile->writeBuf) taosMemoryFreeClear(pMemFile->writeBuf); + if (pMemFile->pTdFile) { + taosCloseCFile(pMemFile->pTdFile); + pMemFile->pTdFile = NULL; + } + taosMemoryFreeClear(pMemFile); + } + } + return code; +} + +static int32_t destroySortMemFile(SSortHandle* pHandle) { + if (pHandle->pExtRowsMemFile == NULL) return TSDB_CODE_SUCCESS; + + SSortMemFile* pMemFile = pHandle->pExtRowsMemFile; + for (int32_t i = 0; i < taosArrayGetSize(pMemFile->aFileRegions); ++i) { + SSortMemFileRegion* pRegion = taosArrayGet(pMemFile->aFileRegions, i); + taosMemoryFree(pRegion->buf); + } + taosArrayDestroy(pMemFile->aFileRegions); + pMemFile->aFileRegions = NULL; + + taosMemoryFree(pMemFile->writeBuf); + pMemFile->writeBuf = NULL; + + taosCloseCFile(pMemFile->pTdFile); + pMemFile->pTdFile = NULL; + taosRemoveFile(pMemFile->memFilePath); + taosMemoryFree(pMemFile); + pHandle->pExtRowsMemFile = NULL; + return TSDB_CODE_SUCCESS; +} + +static int32_t tsortOpenRegion(SSortHandle* pHandle) { + SSortMemFile* pMemFile = pHandle->pExtRowsMemFile; + if (pMemFile->currRegionId == -1) { + SSortMemFileRegion region = {0}; + region.fileOffset = 0; + region.bufRegOffset = 0; + taosArrayPush(pMemFile->aFileRegions, ®ion); + pMemFile->currRegionId = 0; + pMemFile->currRegionOffset = 0; + pMemFile->writeFileOffset = 0; + } else { + SSortMemFileRegion regionNew = {0}; + SSortMemFileRegion* pRegion = taosArrayGet(pMemFile->aFileRegions, pMemFile->currRegionId); + regionNew.fileOffset = pRegion->fileOffset + pRegion->regionSize; + regionNew.bufRegOffset = 0; + taosArrayPush(pMemFile->aFileRegions, ®ionNew); + ++pMemFile->currRegionId; + pMemFile->currRegionOffset = 0; + pMemFile->writeFileOffset = regionNew.fileOffset; + } + return TSDB_CODE_SUCCESS; +} + +static int32_t tsortCloseRegion(SSortHandle* pHandle) { + SSortMemFile* pMemFile = pHandle->pExtRowsMemFile; + SSortMemFileRegion* pRegion = taosArrayGet(pMemFile->aFileRegions, pMemFile->currRegionId); + pRegion->regionSize = pMemFile->currRegionOffset; + int32_t writeBytes = pRegion->regionSize - (pMemFile->writeFileOffset - pRegion->fileOffset); + if (writeBytes > 0) { + int ret = fwrite(pMemFile->writeBuf, writeBytes, 1, pMemFile->pTdFile); + if (ret != 1) { + terrno = TAOS_SYSTEM_ERROR(errno); + return terrno; + } + pMemFile->bRegionDirty = false; + } + return TSDB_CODE_SUCCESS; +} + +static int32_t tsortFinalizeRegions(SSortHandle* pHandle) { + SSortMemFile* pMemFile = pHandle->pExtRowsMemFile; + size_t numRegions = taosArrayGetSize(pMemFile->aFileRegions); + ASSERT(numRegions == (pMemFile->currRegionId + 1)); + if (numRegions == 0) return TSDB_CODE_SUCCESS; + int32_t blockReadBytes = (pMemFile->cacheSize / numRegions + 4095) & ~4095; + pMemFile->blockSize = blockReadBytes; + + for (int32_t i = 0; i < numRegions; ++i) { + SSortMemFileRegion* pRegion = taosArrayGet(pMemFile->aFileRegions, i); + pRegion->bufRegOffset = 0; + } + taosMemoryFree(pMemFile->writeBuf); + pMemFile->writeBuf = NULL; + return TSDB_CODE_SUCCESS; +} + +static int32_t saveBlockRowToExtRowsMemFile(SSortHandle* pHandle, SSDataBlock* pBlock, int32_t rowIdx, int32_t* pRegionId, int32_t* pOffset, int32_t* pLength) { + SSortMemFile* pMemFile = pHandle->pExtRowsMemFile; + SSortMemFileRegion* pRegion = taosArrayGet(pMemFile->aFileRegions, pMemFile->currRegionId); + { + if (pMemFile->currRegionOffset + pHandle->extRowBytes >= pMemFile->writeBufSize) { + int32_t writeBytes = pMemFile->currRegionOffset - (pMemFile->writeFileOffset - pRegion->fileOffset); + int ret = fwrite(pMemFile->writeBuf, writeBytes, 1, pMemFile->pTdFile); + if (ret != 1) { + terrno = TAOS_SYSTEM_ERROR(errno); + return terrno; + } + pMemFile->writeFileOffset = pRegion->fileOffset + pMemFile->currRegionOffset; + } + } + *pRegionId = pMemFile->currRegionId; + *pOffset = pMemFile->currRegionOffset; + int32_t writeBufOffset = pMemFile->currRegionOffset - (pMemFile->writeFileOffset - pRegion->fileOffset); + int32_t blockLen = blockRowToBuf(pBlock, rowIdx, pMemFile->writeBuf + writeBufOffset); + *pLength = blockLen; + pMemFile->currRegionOffset += blockLen; + pMemFile->bRegionDirty = true; + return TSDB_CODE_SUCCESS; +} + +static void appendToRowIndexDataBlock(SSortHandle* pHandle, SSDataBlock* pSource, int32_t* rowIndex) { + int32_t pageId = -1; + int32_t offset = -1; + int32_t length = -1; + saveBlockRowToExtRowsMemFile(pHandle, pSource, *rowIndex, &pageId, &offset, &length); + + SSDataBlock* pBlock = pHandle->pDataBlock; + SColumnInfoData* pSrcTsCol = taosArrayGet(pSource->pDataBlock, pHandle->extRowsOrderInfo.slotId); + SColumnInfoData* pTsCol = taosArrayGet(pBlock->pDataBlock, 0); + char* pData = colDataGetData(pSrcTsCol, *rowIndex); + colDataSetVal(pTsCol, pBlock->info.rows, pData, false); + + SColumnInfoData* pRegionIdCol = taosArrayGet(pBlock->pDataBlock, 1); + colDataSetInt32(pRegionIdCol, pBlock->info.rows, &pageId); + + SColumnInfoData* pOffsetCol = taosArrayGet(pBlock->pDataBlock, 2); + colDataSetInt32(pOffsetCol, pBlock->info.rows, &offset); + + SColumnInfoData* pLengthCol = taosArrayGet(pBlock->pDataBlock, 3); + colDataSetInt32(pLengthCol, pBlock->info.rows, &length); + + pBlock->info.rows += 1; + *rowIndex += 1; +} + +static void initRowIdSort(SSortHandle* pHandle) { + + SSDataBlock* pSortInput = createDataBlock(); + SColumnInfoData tsCol = createColumnInfoData(TSDB_DATA_TYPE_TIMESTAMP, 8, 1); + blockDataAppendColInfo(pSortInput, &tsCol); + SColumnInfoData regionIdCol = createColumnInfoData(TSDB_DATA_TYPE_INT, 4, 2); + blockDataAppendColInfo(pSortInput, ®ionIdCol); + SColumnInfoData offsetCol = createColumnInfoData(TSDB_DATA_TYPE_INT, 4, 3); + blockDataAppendColInfo(pSortInput, &offsetCol); + SColumnInfoData lengthCol = createColumnInfoData(TSDB_DATA_TYPE_INT, 4, 4); + blockDataAppendColInfo(pSortInput, &lengthCol); + + blockDataDestroy(pHandle->pDataBlock); + pHandle->pDataBlock = pSortInput; + + int32_t rowSize = blockDataGetRowSize(pHandle->pDataBlock); + size_t nCols = taosArrayGetSize(pHandle->pDataBlock->pDataBlock); + pHandle->pageSize = 256 * 1024; // 256k + pHandle->numOfPages = 256; + + SBlockOrderInfo* pOrder = taosArrayGet(pHandle->pSortInfo, 0); + SBlockOrderInfo bi = {0}; + bi.order = pOrder->order; + bi.slotId = 0; + bi.nullFirst = NULL_ORDER_FIRST; + + SArray* aOrder = taosArrayInit(1, sizeof(SBlockOrderInfo)); + taosArrayPush(aOrder, &bi); + + taosArrayDestroy(pHandle->pSortInfo); + pHandle->pSortInfo = aOrder; + return; +} + +int32_t tsortSetSortByRowId(SSortHandle* pHandle, int32_t extRowsMemSize) { + pHandle->extRowBytes = blockDataGetRowSize(pHandle->pDataBlock) + taosArrayGetSize(pHandle->pDataBlock->pDataBlock) + sizeof(int32_t); + pHandle->extRowsMemSize = extRowsMemSize; + SBlockOrderInfo* pOrder = taosArrayGet(pHandle->pSortInfo, 0); + pHandle->extRowsOrderInfo = *pOrder; + initRowIdSort(pHandle); + if (!osTempSpaceAvailable()) { + terrno = TSDB_CODE_NO_DISKSPACE; + qError("create sort mem file failed since %s, tempDir:%s", terrstr(), tsTempDir); + return terrno; + } + int32_t code = createSortMemFile(pHandle); + pHandle->bSortByRowId = true; + return code; +} + typedef struct SBlkMergeSupport { int64_t** aTs; int32_t* aRowIdx; @@ -925,7 +1350,7 @@ static int32_t getPageBufIncForRow(SSDataBlock* blk, int32_t row, int32_t rowIdx return sz; } -static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SBlockOrderInfo* order, SArray* aExtSrc) { +static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray* aExtSrc) { int32_t code = TSDB_CODE_SUCCESS; int pgHeaderSz = sizeof(int32_t) + sizeof(int32_t) * taosArrayGetSize(pHandle->pDataBlock->pDataBlock); int32_t rowCap = blockDataGetCapacityInRow(pHandle->pDataBlock, pHandle->pageSize, pgHeaderSz); @@ -933,13 +1358,15 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SBlockO blockDataCleanup(pHandle->pDataBlock); int32_t numBlks = taosArrayGetSize(aBlk); + SBlockOrderInfo* pOrigBlockOrder = (!pHandle->bSortByRowId) ? taosArrayGet(pHandle->pSortInfo, 0) : &pHandle->extRowsOrderInfo; + SBlockOrderInfo* pHandleBlockOrder = taosArrayGet(pHandle->pSortInfo, 0); SBlkMergeSupport sup; sup.aRowIdx = taosMemoryCalloc(numBlks, sizeof(int32_t)); sup.aTs = taosMemoryCalloc(numBlks, sizeof(int64_t*)); - sup.order = order->order; + sup.order = pOrigBlockOrder->order; for (int i = 0; i < numBlks; ++i) { SSDataBlock* blk = taosArrayGetP(aBlk, i); - SColumnInfoData* col = taosArrayGet(blk->pDataBlock, order->slotId); + SColumnInfoData* col = taosArrayGet(blk->pDataBlock, pOrigBlockOrder->slotId); sup.aTs[i] = (int64_t*)col->pData; sup.aRowIdx[i] = 0; } @@ -963,16 +1390,17 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SBlockO int32_t nMergedRows = 0; bool mergeLimitReached = false; size_t blkPgSz = pgHeaderSz; - int64_t lastPageBufTs = (order->order == TSDB_ORDER_ASC) ? INT64_MAX : INT64_MIN; - int64_t currTs = (order->order == TSDB_ORDER_ASC) ? INT64_MAX : INT64_MIN; + int64_t lastPageBufTs = (pHandleBlockOrder->order == TSDB_ORDER_ASC) ? INT64_MAX : INT64_MIN; + int64_t currTs = (pHandleBlockOrder->order == TSDB_ORDER_ASC) ? INT64_MAX : INT64_MIN; while (nRows < totalRows) { int32_t minIdx = tMergeTreeGetChosenIndex(pTree); SSDataBlock* minBlk = taosArrayGetP(aBlk, minIdx); int32_t minRow = sup.aRowIdx[minIdx]; - int32_t bufInc = getPageBufIncForRow(minBlk, minRow, pHandle->pDataBlock->info.rows); + SSDataBlock* incBlock = (pHandle->bSortByRowId) ? pHandle->pDataBlock : minBlk; + int32_t bufInc = getPageBufIncForRow(incBlock, minRow, pHandle->pDataBlock->info.rows); if (blkPgSz <= pHandle->pageSize && blkPgSz + bufInc > pHandle->pageSize) { - SColumnInfoData* tsCol = taosArrayGet(pHandle->pDataBlock->pDataBlock, order->slotId); + SColumnInfoData* tsCol = taosArrayGet(pHandle->pDataBlock->pDataBlock, pHandleBlockOrder->slotId); lastPageBufTs = ((int64_t*)tsCol->pData)[pHandle->pDataBlock->info.rows - 1]; code = appendDataBlockToPageBuf(pHandle, pHandle->pDataBlock, aPgId); if (code != TSDB_CODE_SUCCESS) { @@ -985,19 +1413,24 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SBlockO nMergedRows += pHandle->pDataBlock->info.rows; blockDataCleanup(pHandle->pDataBlock); blkPgSz = pgHeaderSz; - bufInc = getPageBufIncForRow(minBlk, minRow, 0); + incBlock = (pHandle->bSortByRowId) ? pHandle->pDataBlock : minBlk; + bufInc = getPageBufIncForRow(incBlock, minRow, 0); if ((pHandle->mergeLimit != -1) && (nMergedRows >= pHandle->mergeLimit)) { mergeLimitReached = true; - if ((lastPageBufTs < pHandle->currMergeLimitTs && order->order == TSDB_ORDER_ASC) || - (lastPageBufTs > pHandle->currMergeLimitTs && order->order == TSDB_ORDER_DESC)) { + if ((lastPageBufTs < pHandle->currMergeLimitTs && pHandleBlockOrder->order == TSDB_ORDER_ASC) || + (lastPageBufTs > pHandle->currMergeLimitTs && pHandleBlockOrder->order == TSDB_ORDER_DESC)) { pHandle->currMergeLimitTs = lastPageBufTs; } break; } } blockDataEnsureCapacity(pHandle->pDataBlock, pHandle->pDataBlock->info.rows + 1); - appendOneRowToDataBlock(pHandle->pDataBlock, minBlk, &minRow); + if (!pHandle->bSortByRowId) { + appendOneRowToDataBlock(pHandle->pDataBlock, minBlk, &minRow); + } else { + appendToRowIndexDataBlock(pHandle, minBlk, &minRow); + } blkPgSz += bufInc; ++nRows; @@ -1011,7 +1444,7 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SBlockO } if (pHandle->pDataBlock->info.rows > 0) { if (!mergeLimitReached) { - SColumnInfoData* tsCol = taosArrayGet(pHandle->pDataBlock->pDataBlock, order->slotId); + SColumnInfoData* tsCol = taosArrayGet(pHandle->pDataBlock->pDataBlock, pHandleBlockOrder->slotId); lastPageBufTs = ((int64_t*)tsCol->pData)[pHandle->pDataBlock->info.rows - 1]; code = appendDataBlockToPageBuf(pHandle, pHandle->pDataBlock, aPgId); if (code != TSDB_CODE_SUCCESS) { @@ -1024,14 +1457,15 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SBlockO nMergedRows += pHandle->pDataBlock->info.rows; if ((pHandle->mergeLimit != -1) && (nMergedRows >= pHandle->mergeLimit)) { mergeLimitReached = true; - if ((lastPageBufTs < pHandle->currMergeLimitTs && order->order == TSDB_ORDER_ASC) || - (lastPageBufTs > pHandle->currMergeLimitTs && order->order == TSDB_ORDER_DESC)) { + if ((lastPageBufTs < pHandle->currMergeLimitTs && pHandleBlockOrder->order == TSDB_ORDER_ASC) || + (lastPageBufTs > pHandle->currMergeLimitTs && pHandleBlockOrder->order == TSDB_ORDER_DESC)) { pHandle->currMergeLimitTs = lastPageBufTs; } } } blockDataCleanup(pHandle->pDataBlock); } + SSDataBlock* pMemSrcBlk = createOneDataBlock(pHandle->pDataBlock, false); doAddNewExternalMemSource(pHandle->pBuf, aExtSrc, pMemSrcBlk, &pHandle->sourceId, aPgId); @@ -1083,11 +1517,10 @@ static SSDataBlock* getRowsBlockWithinMergeLimit(const SSortHandle* pHandle, SSH } static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) { - SBlockOrderInfo* pOrder = taosArrayGet(pHandle->pSortInfo, 0); size_t nSrc = taosArrayGetSize(pHandle->pOrderedSource); SArray* aExtSrc = taosArrayInit(nSrc, POINTER_BYTES); - size_t maxBufSize = pHandle->numOfPages * pHandle->pageSize; + size_t maxBufSize = (pHandle->bSortByRowId) ? pHandle->extRowsMemSize : (pHandle->numOfPages * pHandle->pageSize); int32_t code = createPageBuf(pHandle); if (code != TSDB_CODE_SUCCESS) { @@ -1098,7 +1531,8 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) { SSortSource* pSrc = taosArrayGetP(pHandle->pOrderedSource, 0); int32_t szSort = 0; - if (pOrder->order == TSDB_ORDER_ASC) { + SBlockOrderInfo* pOrigOrder = (!pHandle->bSortByRowId) ? taosArrayGet(pHandle->pSortInfo, 0) : &pHandle->extRowsOrderInfo; + if (pOrigOrder->order == TSDB_ORDER_ASC) { pHandle->currMergeLimitTs = INT64_MAX; } else { pHandle->currMergeLimitTs = INT64_MIN; @@ -1110,7 +1544,6 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) { while (1) { SSDataBlock* pBlk = pHandle->fetchfp(pSrc->param); - int64_t p = taosGetTimestampUs(); bool bExtractedBlock = false; bool bSkipBlock = false; if (pBlk != NULL && pHandle->mergeLimit > 0) { @@ -1121,13 +1554,13 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) { } if (pBlk != NULL) { - SColumnInfoData* tsCol = taosArrayGet(pBlk->pDataBlock, pOrder->slotId); + SColumnInfoData* tsCol = taosArrayGet(pBlk->pDataBlock, pOrigOrder->slotId); int64_t firstRowTs = *(int64_t*)tsCol->pData; - if ((pOrder->order == TSDB_ORDER_ASC && firstRowTs > pHandle->currMergeLimitTs) || - (pOrder->order == TSDB_ORDER_DESC && firstRowTs < pHandle->currMergeLimitTs)) { + if ((pOrigOrder->order == TSDB_ORDER_ASC && firstRowTs > pHandle->currMergeLimitTs) || + (pOrigOrder->order == TSDB_ORDER_DESC && firstRowTs < pHandle->currMergeLimitTs)) { if (bExtractedBlock) { blockDataDestroy(pBlk); - } + } continue; } } @@ -1150,7 +1583,13 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) { if ((pBlk != NULL && szSort > maxBufSize) || (pBlk == NULL && szSort > 0)) { tSimpleHashClear(mUidBlk); - code = sortBlocksToExtSource(pHandle, aBlkSort, pOrder, aExtSrc); + + int64_t p = taosGetTimestampUs(); + if (pHandle->bSortByRowId) { + tsortOpenRegion(pHandle); + } + code = sortBlocksToExtSource(pHandle, aBlkSort, aExtSrc); + if (code != TSDB_CODE_SUCCESS) { for (int i = 0; i < taosArrayGetSize(aBlkSort); ++i) { blockDataDestroy(taosArrayGetP(aBlkSort, i)); @@ -1158,7 +1597,9 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) { taosArrayClear(aBlkSort); break; } - + if (pHandle->bSortByRowId) { + tsortCloseRegion(pHandle); + } int64_t el = taosGetTimestampUs() - p; pHandle->sortElapsed += el; @@ -1195,6 +1636,9 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) { } taosArrayDestroy(aExtSrc); tSimpleHashCleanup(mTableNumRows); + if (pHandle->bSortByRowId) { + tsortFinalizeRegions(pHandle); + } pHandle->type = SORT_SINGLESOURCE_SORT; return code; } diff --git a/source/libs/geometry/src/geosWrapper.c b/source/libs/geometry/src/geosWrapper.c index 993178e2b0..ad2d477a13 100644 --- a/source/libs/geometry/src/geosWrapper.c +++ b/source/libs/geometry/src/geosWrapper.c @@ -199,6 +199,7 @@ int32_t doAsText(const unsigned char *inputGeom, size_t size, char **outputWKT) wkt = GEOSWKTWriter_write_r(geosCtx->handle, geosCtx->WKTWriter, geom); if (wkt == NULL) { + code = TSDB_CODE_MSG_DECODE_ERROR; goto _exit; } *outputWKT = wkt; diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 3f5ffcae32..453d927378 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -457,6 +457,7 @@ static int32_t logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) { COPY_SCALAR_FIELD(isCountByTag); CLONE_OBJECT_FIELD(pFuncTypes, functParamClone); COPY_SCALAR_FIELD(paraTablesSort); + COPY_SCALAR_FIELD(smallDataTsSort); return TSDB_CODE_SUCCESS; } @@ -690,6 +691,7 @@ static int32_t physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhy COPY_SCALAR_FIELD(filesetDelimited); COPY_SCALAR_FIELD(needCountEmptyTable); COPY_SCALAR_FIELD(paraTablesSort); + COPY_SCALAR_FIELD(smallDataTsSort); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 689886c366..019ef6f18b 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -699,6 +699,7 @@ static const char* jkScanLogicPlanGroupTags = "GroupTags"; static const char* jkScanLogicPlanOnlyMetaCtbIdx = "OnlyMetaCtbIdx"; static const char* jkScanLogicPlanFilesetDelimited = "FilesetDelimited"; static const char* jkScanLogicPlanParaTablesSort = "ParaTablesSort"; +static const char* jkScanLogicPlanSmallDataTsSort = "SmallDataTsSort"; static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) { const SScanLogicNode* pNode = (const SScanLogicNode*)pObj; @@ -749,6 +750,9 @@ static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkScanLogicPlanParaTablesSort, pNode->paraTablesSort); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddBoolToObject(pJson, jkScanLogicPlanSmallDataTsSort, pNode->paraTablesSort); + } return code; } @@ -800,7 +804,10 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) { code = tjsonGetBoolValue(pJson, jkScanLogicPlanFilesetDelimited, &pNode->filesetDelimited); } if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBoolValue(pJson, jkScanLogicPlanParaTablesSort, &pNode->paraTablesSort); + code = tjsonGetBoolValue(pJson, jkScanLogicPlanParaTablesSort, &pNode->smallDataTsSort); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBoolValue(pJson, jkScanLogicPlanSmallDataTsSort, &pNode->smallDataTsSort); } return code; } @@ -1896,6 +1903,7 @@ static const char* jkTableScanPhysiPlanIgnoreUpdate = "IgnoreUpdate"; static const char* jkTableScanPhysiPlanFilesetDelimited = "FilesetDelimited"; static const char* jkTableScanPhysiPlanNeedCountEmptyTable = "NeedCountEmptyTable"; static const char* jkTableScanPhysiPlanParaTablesSort = "ParaTablesSort"; +static const char* jkTableScanPhysiPlanSmallDataTsSort = "SmallDataTsSort"; static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj; @@ -1973,6 +1981,9 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkTableScanPhysiPlanParaTablesSort, pNode->paraTablesSort); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddBoolToObject(pJson, jkTableScanPhysiPlanSmallDataTsSort, pNode->smallDataTsSort); + } return code; } @@ -2052,6 +2063,9 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetBoolValue(pJson, jkTableScanPhysiPlanParaTablesSort, &pNode->paraTablesSort); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBoolValue(pJson, jkTableScanPhysiPlanSmallDataTsSort, &pNode->smallDataTsSort); + } return code; } diff --git a/source/libs/nodes/src/nodesMsgFuncs.c b/source/libs/nodes/src/nodesMsgFuncs.c index 357abc2858..95a5c2f51e 100644 --- a/source/libs/nodes/src/nodesMsgFuncs.c +++ b/source/libs/nodes/src/nodesMsgFuncs.c @@ -2188,6 +2188,9 @@ static int32_t physiTableScanNodeInlineToMsg(const void* pObj, STlvEncoder* pEnc if (TSDB_CODE_SUCCESS == code) { code = tlvEncodeValueBool(pEncoder, pNode->paraTablesSort); } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueBool(pEncoder, pNode->smallDataTsSort); + } return code; } @@ -2275,6 +2278,9 @@ static int32_t msgToPhysiTableScanNodeInline(STlvDecoder* pDecoder, void* pObj) if (TSDB_CODE_SUCCESS == code) { code = tlvDecodeValueBool(pDecoder, &pNode->paraTablesSort); } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueBool(pDecoder, &pNode->smallDataTsSort); + } return code; } diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index f13f9f1b96..dcd102b92d 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -108,6 +108,8 @@ SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pColumnName); SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral); +SNode* createRawValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral, SNode *pNode); +SNode* createRawValueNodeExt(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral, SNode *pLeft, SNode *pRight); SNodeList* createHintNodeList(SAstCreateContext* pCxt, const SToken* pLiteral); SNode* createIdentifierValueNode(SAstCreateContext* pCxt, SToken* pLiteral); SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral); diff --git a/source/libs/parser/inc/parToken.h b/source/libs/parser/inc/parToken.h index 86bcc18fd5..87e9a82d2b 100644 --- a/source/libs/parser/inc/parToken.h +++ b/source/libs/parser/inc/parToken.h @@ -24,6 +24,15 @@ extern "C" { #include "ttokendef.h" +#define IS_TRUE_STR(s, n) \ + (n == 4 && (*(s) == 't' || *(s) == 'T') && (*((s) + 1) == 'r' || *((s) + 1) == 'R') && \ + (*((s) + 2) == 'u' || *((s) + 2) == 'U') && (*((s) + 3) == 'e' || *((s) + 3) == 'E')) + +#define IS_FALSE_STR(s, n) \ + (n == 5 && (*(s) == 'f' || *(s) == 'F') && (*((s) + 1) == 'a' || *((s) + 1) == 'A') && \ + (*((s) + 2) == 'l' || *((s) + 2) == 'L') && (*((s) + 3) == 's' || *((s) + 3) == 'S') && \ + (*((s) + 4) == 'e' || *((s) + 4) == 'E')) + // used to denote the minimum unite in sql parsing typedef struct SToken { uint32_t n; diff --git a/source/libs/parser/inc/parUtil.h b/source/libs/parser/inc/parUtil.h index 11a3a40a1e..b6170aaca6 100644 --- a/source/libs/parser/inc/parUtil.h +++ b/source/libs/parser/inc/parUtil.h @@ -23,6 +23,7 @@ extern "C" { #include "catalog.h" #include "os.h" #include "parser.h" +#include "parToken.h" #include "query.h" #define parserFatal(param, ...) qFatal("PARSER: " param, ##__VA_ARGS__) @@ -35,6 +36,45 @@ extern "C" { #define ROWTS_PSEUDO_COLUMN_NAME "_rowts" #define C0_PSEUDO_COLUMN_NAME "_c0" +#define IS_NOW_STR(s, n) \ + ((*(s) == 'n' || *(s) == 'N') && (*((s) + 1) == 'o' || *((s) + 1) == 'O') && \ + (*((s) + 2) == 'w' || *((s) + 2) == 'W') && (n == 3 || (n == 5 && *((s) + 3) == '(' && *((s) + 4) == ')'))) + +#define IS_TODAY_STR(s, n) \ + ((*(s) == 't' || *(s) == 'T') && (*((s) + 1) == 'o' || *((s) + 1) == 'O') && \ + (*((s) + 2) == 'd' || *((s) + 2) == 'D') && (*((s) + 3) == 'a' || *((s) + 3) == 'A') && \ + (*((s) + 4) == 'y' || *((s) + 4) == 'Y') && (n == 5 || (n == 7 && *((s) + 5) == '(' && *((s) + 6) == ')'))) + +#define IS_NULL_STR(s, n) \ + (n == 4 && (*(s) == 'N' || *(s) == 'n') && (*((s) + 1) == 'U' || *((s) + 1) == 'u') && \ + (*((s) + 2) == 'L' || *((s) + 2) == 'l') && (*((s) + 3) == 'L' || *((s) + 3) == 'l')) + +#define NEXT_TOKEN_WITH_PREV(pSql, token) \ + do { \ + int32_t index = 0; \ + token = tStrGetToken(pSql, &index, true, NULL); \ + pSql += index; \ + } while (0) + +#define NEXT_TOKEN_WITH_PREV_EXT(pSql, token, pIgnoreComma) \ + do { \ + int32_t index = 0; \ + token = tStrGetToken(pSql, &index, true, pIgnoreComma); \ + pSql += index; \ + } while (0) + +#define NEXT_TOKEN_KEEP_SQL(pSql, token, index) \ + do { \ + token = tStrGetToken(pSql, &index, false, NULL); \ + } while (0) + +#define NEXT_VALID_TOKEN(pSql, token) \ + do { \ + (token).n = tGetToken(pSql, &(token).type); \ + (token).z = (char*)pSql; \ + pSql += (token).n; \ + } while (TK_NK_SPACE == (token).type) + typedef struct SMsgBuf { int32_t len; char* buf; @@ -89,6 +129,9 @@ int32_t getTableTypeFromTableNode(SNode *pTable); int32_t trimString(const char* src, int32_t len, char* dst, int32_t dlen); int32_t getVnodeSysTableTargetName(int32_t acctId, SNode* pWhere, SName* pName); +int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, SMsgBuf* pMsgBuf, int8_t type); +int32_t parseTagValue(SMsgBuf* pMsgBuf, const char** pSql, uint8_t precision, SSchema* pTagSchema, SToken* pToken, + SArray* pTagName, SArray* pTagVals, STag** pTag); int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalogReq); int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMetaData, SParseMetaCache* pMetaCache); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 4c59f3abd7..0e738679ce 100755 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -354,7 +354,7 @@ alter_table_clause(A) ::= alter_table_clause(A) ::= full_table_name(B) RENAME TAG column_name(C) column_name(D). { A = createAlterTableRenameCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &C, &D); } alter_table_clause(A) ::= - full_table_name(B) SET TAG column_name(C) NK_EQ signed_literal(D). { A = createAlterTableSetTag(pCxt, B, &C, D); } + full_table_name(B) SET TAG column_name(C) NK_EQ tags_literal(D). { A = createAlterTableSetTag(pCxt, B, &C, D); } %type multi_create_clause { SNodeList* } %destructor multi_create_clause { nodesDestroyList($$); } @@ -363,7 +363,7 @@ multi_create_clause(A) ::= multi_create_clause(B) create_subtable_clause(C). create_subtable_clause(A) ::= not_exists_opt(B) full_table_name(C) USING full_table_name(D) - specific_cols_opt(E) TAGS NK_LP expression_list(F) NK_RP table_options(G). { A = createCreateSubTableClause(pCxt, B, C, D, E, F, G); } + specific_cols_opt(E) TAGS NK_LP tags_literal_list(F) NK_RP table_options(G). { A = createCreateSubTableClause(pCxt, B, C, D, E, F, G); } %type multi_drop_clause { SNodeList* } %destructor multi_drop_clause { nodesDestroyList($$); } @@ -744,6 +744,76 @@ insert_query(A) ::= INSERT INTO full_table_name(D) NK_LP col_name_list(B) NK_RP query_or_subquery(C). { A = createInsertStmt(pCxt, D, B, C); } insert_query(A) ::= INSERT INTO full_table_name(C) query_or_subquery(B). { A = createInsertStmt(pCxt, C, NULL, B); } +/************************************************ tags_literal *************************************************************/ +tags_literal(A) ::= NK_INTEGER(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B, NULL); } +tags_literal(A) ::= NK_PLUS(B) NK_INTEGER(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); + } +tags_literal(A) ::= NK_MINUS(B) NK_INTEGER(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); + } +tags_literal(A) ::= NK_FLOAT(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &B, NULL); } +tags_literal(A) ::= NK_PLUS(B) NK_FLOAT(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t, NULL); + } +tags_literal(A) ::= NK_MINUS(B) NK_FLOAT(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t, NULL); + } + +tags_literal(A) ::= NK_BIN(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B, NULL); } +tags_literal(A) ::= NK_PLUS(B) NK_BIN(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); + } +tags_literal(A) ::= NK_MINUS(B) NK_BIN(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); + } +tags_literal(A) ::= NK_HEX(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B, NULL); } +tags_literal(A) ::= NK_PLUS(B) NK_HEX(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); + } +tags_literal(A) ::= NK_MINUS(B) NK_HEX(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); + } + +tags_literal(A) ::= NK_STRING(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B, NULL); } +tags_literal(A) ::= NK_BOOL(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &B, NULL); } +tags_literal(A) ::= NULL(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_NULL, &B, NULL); } + +tags_literal(A) ::= literal_func(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, NULL, B); } +tags_literal(A) ::= literal_func(B) NK_PLUS duration_literal(C). { + SToken l = getTokenFromRawExprNode(pCxt, B); + SToken r = getTokenFromRawExprNode(pCxt, C); + l.n = (r.z + r.n) - l.z; + A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, B, C); + } +tags_literal(A) ::= literal_func(B) NK_MINUS duration_literal(C). { + SToken l = getTokenFromRawExprNode(pCxt, B); + SToken r = getTokenFromRawExprNode(pCxt, C); + l.n = (r.z + r.n) - l.z; + A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, B, C); + } + +%type tags_literal_list { SNodeList* } +%destructor tags_literal_list { nodesDestroyList($$); } +tags_literal_list(A) ::= tags_literal(B). { A = createNodeList(pCxt, B); } +tags_literal_list(A) ::= tags_literal_list(B) NK_COMMA tags_literal(C). { A = addNodeToList(pCxt, B, C); } + /************************************************ literal *************************************************************/ literal(A) ::= NK_INTEGER(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B)); } literal(A) ::= NK_FLOAT(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &B)); } @@ -924,6 +994,7 @@ function_expression(A) ::= literal_func(B). literal_func(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &B, NULL)); } literal_func(A) ::= NOW(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } +literal_func(A) ::= TODAY(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } %type noarg_func { SToken } %destructor noarg_func { } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 1d6c5e800e..8613fd3e7a 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -371,6 +371,80 @@ SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* return (SNode*)val; } +SNode* createRawValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral, SNode* pNode) { + CHECK_PARSER_STATUS(pCxt); + SValueNode* val = NULL; + + if (!(val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE))) { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY, "Out of memory"); + goto _exit; + } + if (pLiteral) { + val->literal = strndup(pLiteral->z, pLiteral->n); + } else if (pNode) { + SRawExprNode* pRawExpr = (SRawExprNode*)pNode; + if (!nodesIsExprNode(pRawExpr->pNode)) { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, pRawExpr->p); + goto _exit; + } + val->literal = strndup(pRawExpr->p, pRawExpr->n); + } else { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTERNAL_ERROR, "Invalid parameters"); + goto _exit; + } + if (!val->literal) { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY, "Out of memory"); + goto _exit; + } + + val->node.resType.type = dataType; + val->node.resType.bytes = IS_VAR_DATA_TYPE(dataType) ? strlen(val->literal) : tDataTypes[dataType].bytes; + if (TSDB_DATA_TYPE_TIMESTAMP == dataType) { + val->node.resType.precision = TSDB_TIME_PRECISION_MILLI; + } +_exit: + nodesDestroyNode(pNode); + if (pCxt->errCode != 0) { + nodesDestroyNode((SNode*)val); + return NULL; + } + return (SNode*)val; +} + +SNode* createRawValueNodeExt(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral, SNode* pLeft, + SNode* pRight) { + CHECK_PARSER_STATUS(pCxt); + SValueNode* val = NULL; + + if (!(val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE))) { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY, "Out of memory"); + goto _exit; + } + if (pLiteral) { + if (!(val->literal = strndup(pLiteral->z, pLiteral->n))) { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY, "Out of memory"); + goto _exit; + } + } else { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTERNAL_ERROR, "Invalid parameters"); + goto _exit; + } + + val->node.resType.type = dataType; + val->node.resType.bytes = IS_VAR_DATA_TYPE(dataType) ? strlen(val->literal) : tDataTypes[dataType].bytes; + if (TSDB_DATA_TYPE_TIMESTAMP == dataType) { + val->node.resType.precision = TSDB_TIME_PRECISION_MILLI; + } +_exit: + nodesDestroyNode(pLeft); + nodesDestroyNode(pRight); + if (pCxt->errCode != 0) { + nodesDestroyNode((SNode*)val); + return NULL; + } + return (SNode*)val; +} + static bool hasHint(SNodeList* pHintList, EHintOption hint) { if (!pHintList) return false; SNode* pNode; @@ -404,6 +478,9 @@ bool addHintNodeToList(SAstCreateContext* pCxt, SNodeList** ppHintList, EHintOpt case HINT_PARA_TABLES_SORT: if (paramNum > 0 || hasHint(*ppHintList, HINT_PARA_TABLES_SORT)) return true; break; + case HINT_SMALLDATA_TS_SORT: + if (paramNum > 0 || hasHint(*ppHintList, HINT_SMALLDATA_TS_SORT)) return true; + break; default: return true; } @@ -490,6 +567,14 @@ SNodeList* createHintNodeList(SAstCreateContext* pCxt, const SToken* pLiteral) { } opt = HINT_PARA_TABLES_SORT; break; + case TK_SMALLDATA_TS_SORT: + lastComma = false; + if (0 != opt || inParamList) { + quit = true; + break; + } + opt = HINT_SMALLDATA_TS_SORT; + break; case TK_NK_LP: lastComma = false; if (0 == opt || inParamList) { diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index 9b34672418..5d268f7bda 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -72,9 +72,7 @@ int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) { cxt.errCode = TSDB_CODE_PAR_SYNTAX_ERROR; goto abort_parse; } - case TK_NK_HEX: - case TK_NK_OCT: - case TK_NK_BIN: { + case TK_NK_OCT: { snprintf(cxt.pQueryCxt->pMsg, cxt.pQueryCxt->msgLen, "unsupported token: \"%s\"", t0.z); cxt.errCode = TSDB_CODE_PAR_SYNTAX_ERROR; goto abort_parse; diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index 7d10d1f2df..5eb0b67884 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -20,32 +20,6 @@ #include "ttime.h" #include "geosWrapper.h" -#define NEXT_TOKEN_WITH_PREV(pSql, token) \ - do { \ - int32_t index = 0; \ - token = tStrGetToken(pSql, &index, true, NULL); \ - pSql += index; \ - } while (0) - -#define NEXT_TOKEN_WITH_PREV_EXT(pSql, token, pIgnoreComma) \ - do { \ - int32_t index = 0; \ - token = tStrGetToken(pSql, &index, true, pIgnoreComma); \ - pSql += index; \ - } while (0) - -#define NEXT_TOKEN_KEEP_SQL(pSql, token, index) \ - do { \ - token = tStrGetToken(pSql, &index, false, NULL); \ - } while (0) - -#define NEXT_VALID_TOKEN(pSql, token) \ - do { \ - (token).n = tGetToken(pSql, &(token).type); \ - (token).z = (char*)pSql; \ - pSql += (token).n; \ - } while (TK_NK_SPACE == (token).type) - typedef struct SInsertParseContext { SParseContext* pComCxt; SMsgBuf msg; @@ -63,13 +37,9 @@ typedef int32_t (*_row_append_fn_t)(SMsgBuf* pMsgBuf, const void* value, int32_t static uint8_t TRUE_VALUE = (uint8_t)TSDB_TRUE; static uint8_t FALSE_VALUE = (uint8_t)TSDB_FALSE; -static bool isNullStr(SToken* pToken) { - return ((pToken->type == TK_NK_STRING) && (strlen(TSDB_DATA_NULL_STR_L) == pToken->n) && - (strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0)); -} - -static bool isNullValue(int8_t dataType, SToken* pToken) { - return TK_NULL == pToken->type || (!IS_STR_DATA_TYPE(dataType) && isNullStr(pToken)); +static FORCE_INLINE bool isNullValue(int8_t dataType, SToken* pToken) { + return TK_NULL == pToken->type || + (TK_NK_STRING == pToken->type && !IS_STR_DATA_TYPE(dataType) && IS_NULL_STR(pToken->z, pToken->n)); } static FORCE_INLINE int32_t toDouble(SToken* pToken, double* value, char** endPtr) { @@ -268,7 +238,8 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, const char** pSql, E return code; } -static int parseTimestampOrInterval(const char** end, SToken* pToken, int16_t timePrec, int64_t* ts, int64_t* interval, SMsgBuf* pMsgBuf, bool* isTs) { +static int parseTimestampOrInterval(const char** end, SToken* pToken, int16_t timePrec, int64_t* ts, int64_t* interval, + SMsgBuf* pMsgBuf, bool* isTs) { if (pToken->type == TK_NOW) { *isTs = true; *ts = taosGetTimestamp(timePrec); @@ -289,7 +260,21 @@ static int parseTimestampOrInterval(const char** end, SToken* pToken, int16_t ti } else { // parse the RFC-3339/ISO-8601 timestamp format string *isTs = true; if (taosParseTime(pToken->z, ts, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) { - return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z); + if ((pToken->n == 0) || + (pToken->type != TK_NK_STRING && pToken->type != TK_NK_HEX && pToken->type != TK_NK_BIN)) { + return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z); + } + if (IS_NOW_STR(pToken->z, pToken->n)) { + *isTs = true; + *ts = taosGetTimestamp(timePrec); + } else if (IS_TODAY_STR(pToken->z, pToken->n)) { + *isTs = true; + *ts = taosGetTimestampToday(timePrec); + } else if (TSDB_CODE_SUCCESS == toIntegerPure(pToken->z, pToken->n, 10, ts)) { + *isTs = true; + } else { + return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z); + } } } @@ -313,10 +298,22 @@ static int parseTime(const char** end, SToken* pToken, int16_t timePrec, int64_t for (int k = pToken->n; pToken->z[k] != '\0'; k++) { if (pToken->z[k] == ' ' || pToken->z[k] == '\t') continue; - if (pToken->z[k] == '(' && pToken->z[k + 1] == ')') { // for insert NOW()/TODAY() - *end = pTokenEnd = &pToken->z[k + 2]; - k++; - continue; + if (pToken->z[k] == '(') { // for insert NOW()/TODAY() + if (pToken->z[k + 1] == ')') { + *end = pTokenEnd = &pToken->z[k + 2]; + ++k; + continue; + } else { + char nc = pToken->z[k + 1]; + while (nc == ' ' || nc == '\t' || nc == '\n' || nc == '\r' || nc == '\f') { + nc = pToken->z[(++k) + 1]; + } + if (nc == ')') { + *end = pTokenEnd = &pToken->z[k + 2]; + ++k; + continue; + } + } } if (pToken->z[k] == ',') { *end = pTokenEnd; @@ -491,10 +488,12 @@ static int32_t parseTagToken(const char** end, SToken* pToken, SSchema* pSchema, switch (pSchema->type) { case TSDB_DATA_TYPE_BOOL: { if ((pToken->type == TK_NK_BOOL || pToken->type == TK_NK_STRING) && (pToken->n != 0)) { - if (strncmp(pToken->z, "true", pToken->n) == 0) { + if (IS_TRUE_STR(pToken->z, pToken->n)) { *(int8_t*)(&val->i64) = TRUE_VALUE; - } else if (strncmp(pToken->z, "false", pToken->n) == 0) { + } else if (IS_FALSE_STR(pToken->z, pToken->n)) { *(int8_t*)(&val->i64) = FALSE_VALUE; + } else if (TSDB_CODE_SUCCESS == toDoubleEx(pToken->z, pToken->n, pToken->type, (double*)&iv)) { + *(int8_t*)(&val->i64) = (*(double*)&iv == 0 ? FALSE_VALUE : TRUE_VALUE); } else { return buildSyntaxErrMsg(pMsgBuf, "invalid bool data", pToken->z); } @@ -502,6 +501,9 @@ static int32_t parseTagToken(const char** end, SToken* pToken, SSchema* pSchema, *(int8_t*)(&val->i64) = ((taosStr2Int64(pToken->z, NULL, 10) == 0) ? FALSE_VALUE : TRUE_VALUE); } else if (pToken->type == TK_NK_FLOAT) { *(int8_t*)(&val->i64) = ((taosStr2Double(pToken->z, NULL) == 0) ? FALSE_VALUE : TRUE_VALUE); + } else if ((pToken->type == TK_NK_HEX || pToken->type == TK_NK_BIN) && + (TSDB_CODE_SUCCESS == toDoubleEx(pToken->z, pToken->n, pToken->type, (double*)&iv))) { + *(int8_t*)(&val->i64) = (*(double*)&iv == 0 ? FALSE_VALUE : TRUE_VALUE); } else { return buildSyntaxErrMsg(pMsgBuf, "invalid bool data", pToken->z); } @@ -709,30 +711,29 @@ static int32_t parseBoundTagsClause(SInsertParseContext* pCxt, SVnodeModifyOpStm return parseBoundColumns(pCxt, &pStmt->pSql, BOUND_TAGS, pStmt->pTableMeta, &pCxt->tags); } -static int32_t parseTagValue(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, const char** ppSql, SSchema* pTagSchema, SToken* pToken, - SArray* pTagName, SArray* pTagVals, STag** pTag) { +int32_t parseTagValue(SMsgBuf* pMsgBuf, const char** pSql, uint8_t precision, SSchema* pTagSchema, SToken* pToken, + SArray* pTagName, SArray* pTagVals, STag** pTag) { bool isNull = isNullValue(pTagSchema->type, pToken); - if (!isNull) { + if (!isNull && pTagName) { taosArrayPush(pTagName, pTagSchema->name); } if (pTagSchema->type == TSDB_DATA_TYPE_JSON) { if (pToken->n > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { - return buildSyntaxErrMsg(&pCxt->msg, "json string too long than 4095", pToken->z); + return buildSyntaxErrMsg(pMsgBuf, "json string too long than 4095", pToken->z); } if (isNull) { return tTagNew(pTagVals, 1, true, pTag); } else { - return parseJsontoTagData(pToken->z, pTagVals, pTag, &pCxt->msg); + return parseJsontoTagData(pToken->z, pTagVals, pTag, pMsgBuf); } } if (isNull) return 0; STagVal val = {0}; - int32_t code = - parseTagToken(ppSql, pToken, pTagSchema, pStmt->pTableMeta->tableInfo.precision, &val, &pCxt->msg); + int32_t code = parseTagToken(pSql, pToken, pTagSchema, precision, &val, pMsgBuf); if (TSDB_CODE_SUCCESS == code) { taosArrayPush(pTagVals, &val); } @@ -755,7 +756,7 @@ static int32_t buildCreateTbReq(SVnodeModifyOpStmt* pStmt, STag* pTag, SArray* p return TSDB_CODE_SUCCESS; } -static int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, SMsgBuf* pMsgBuf, int8_t type) { +int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, SMsgBuf* pMsgBuf, int8_t type) { if ((pToken->type != TK_NOW && pToken->type != TK_TODAY && pToken->type != TK_NK_INTEGER && pToken->type != TK_NK_STRING && pToken->type != TK_NK_FLOAT && pToken->type != TK_NK_BOOL && pToken->type != TK_NULL && pToken->type != TK_NK_HEX && pToken->type != TK_NK_OCT && @@ -911,12 +912,20 @@ static int32_t checkSubtablePrivilege(SArray* pTagVals, SArray* pTagName, SNode* static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt) { int32_t code = TSDB_CODE_SUCCESS; SSchema* pSchema = getTableTagSchema(pStmt->pTableMeta); - SArray* pTagVals = taosArrayInit(pCxt->tags.numOfBound, sizeof(STagVal)); - SArray* pTagName = taosArrayInit(8, TSDB_COL_NAME_LEN); + SArray* pTagVals = NULL; + SArray* pTagName = NULL; + uint8_t precision = pStmt->pTableMeta->tableInfo.precision; SToken token; bool isParseBindParam = false; bool isJson = false; STag* pTag = NULL; + + if (!(pTagVals = taosArrayInit(pCxt->tags.numOfBound, sizeof(STagVal))) || + !(pTagName = taosArrayInit(pCxt->tags.numOfBound, TSDB_COL_NAME_LEN))) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + for (int i = 0; TSDB_CODE_SUCCESS == code && i < pCxt->tags.numOfBound; ++i) { NEXT_TOKEN_WITH_PREV(pStmt->pSql, token); @@ -938,11 +947,11 @@ static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt SSchema* pTagSchema = &pSchema[pCxt->tags.pColIndex[i]]; isJson = pTagSchema->type == TSDB_DATA_TYPE_JSON; code = checkAndTrimValue(&token, pCxt->tmpTokenBuf, &pCxt->msg, pTagSchema->type); - if (TK_NK_VARIABLE == token.type) { + if (TSDB_CODE_SUCCESS == code && TK_NK_VARIABLE == token.type) { code = buildSyntaxErrMsg(&pCxt->msg, "not expected tags values ", token.z); } if (TSDB_CODE_SUCCESS == code) { - code = parseTagValue(pCxt, pStmt, &pStmt->pSql, pTagSchema, &token, pTagName, pTagVals, &pTag); + code = parseTagValue(&pCxt->msg, &pStmt->pSql, precision, pTagSchema, &token, pTagName, pTagVals, &pTag); } } @@ -959,8 +968,9 @@ static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt pTag = NULL; } - for (int i = 0; i < taosArrayGetSize(pTagVals); ++i) { - STagVal* p = (STagVal*)taosArrayGet(pTagVals, i); +_exit: + for (int32_t i = 0; i < TARRAY_SIZE(pTagVals); ++i) { + STagVal* p = (STagVal*)TARRAY_GET_ELEM(pTagVals, i); if (IS_VAR_DATA_TYPE(p->type)) { taosMemoryFreeClear(p->pData); } @@ -1425,10 +1435,12 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql, switch (pSchema->type) { case TSDB_DATA_TYPE_BOOL: { if ((pToken->type == TK_NK_BOOL || pToken->type == TK_NK_STRING) && (pToken->n != 0)) { - if (strncmp(pToken->z, "true", pToken->n) == 0) { + if (IS_TRUE_STR(pToken->z, pToken->n)) { pVal->value.val = TRUE_VALUE; - } else if (strncmp(pToken->z, "false", pToken->n) == 0) { + } else if (IS_FALSE_STR(pToken->z, pToken->n)) { pVal->value.val = FALSE_VALUE; + } else if (TSDB_CODE_SUCCESS == toDoubleEx(pToken->z, pToken->n, pToken->type, (double*)&pVal->value.val)) { + *(int8_t*)(&pVal->value.val) = (*(double*)&pVal->value.val == 0 ? FALSE_VALUE : TRUE_VALUE); } else { return buildSyntaxErrMsg(&pCxt->msg, "invalid bool data", pToken->z); } @@ -1436,6 +1448,9 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql, pVal->value.val = ((taosStr2Int64(pToken->z, NULL, 10) == 0) ? FALSE_VALUE : TRUE_VALUE); } else if (pToken->type == TK_NK_FLOAT) { pVal->value.val = ((taosStr2Double(pToken->z, NULL) == 0) ? FALSE_VALUE : TRUE_VALUE); + } else if ((pToken->type == TK_NK_HEX || pToken->type == TK_NK_BIN) && + (TSDB_CODE_SUCCESS == toDoubleEx(pToken->z, pToken->n, pToken->type, (double*)&pVal->value.val))) { + *(int8_t*)(&pVal->value.val) = (*(double*)&pVal->value.val == 0 ? FALSE_VALUE : TRUE_VALUE); } else { return buildSyntaxErrMsg(&pCxt->msg, "invalid bool data", pToken->z); } @@ -1510,7 +1525,7 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql, break; } case TSDB_DATA_TYPE_FLOAT: { - double dv; + double dv; int32_t code = toDoubleEx(pToken->z, pToken->n, pToken->type, &dv); if (TSDB_CODE_SUCCESS != code) { return buildSyntaxErrMsg(&pCxt->msg, "illegal float data", pToken->z); @@ -1523,7 +1538,7 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql, break; } case TSDB_DATA_TYPE_DOUBLE: { - double dv; + double dv; int32_t code = toDoubleEx(pToken->z, pToken->n, pToken->type, &dv); if (TSDB_CODE_SUCCESS != code) { return buildSyntaxErrMsg(&pCxt->msg, "illegal float data", pToken->z); @@ -1549,7 +1564,7 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql, } case TSDB_DATA_TYPE_VARBINARY: { int32_t code = parseVarbinary(pToken, &pVal->value.pData, &pVal->value.nData, pSchema->bytes); - if(code != TSDB_CODE_SUCCESS){ + if (code != TSDB_CODE_SUCCESS) { return generateSyntaxErrMsg(&pCxt->msg, code, pSchema->name); } break; @@ -1587,9 +1602,9 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql, break; } case TSDB_DATA_TYPE_GEOMETRY: { - int32_t code = TSDB_CODE_FAILED; - unsigned char *output = NULL; - size_t size = 0; + int32_t code = TSDB_CODE_FAILED; + unsigned char* output = NULL; + size_t size = 0; code = parseGeometry(pToken, &output, &size); if (code != TSDB_CODE_SUCCESS) { @@ -1598,13 +1613,11 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql, // Too long values will raise the invalid sql error message else if (size + VARSTR_HEADER_SIZE > pSchema->bytes) { code = generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name); - } - else { + } else { pVal->value.pData = taosMemoryMalloc(size); if (NULL == pVal->value.pData) { code = TSDB_CODE_OUT_OF_MEMORY; - } - else { + } else { memcpy(pVal->value.pData, output, size); pVal->value.nData = size; } @@ -1639,18 +1652,14 @@ static int32_t parseValueToken(SInsertParseContext* pCxt, const char** pSql, STo return buildSyntaxErrMsg(&pCxt->msg, "primary timestamp should not be null", pToken->z); } - if (TK_NK_VARIABLE == pToken->type && pSchema->type != TSDB_DATA_TYPE_TIMESTAMP) { - return buildSyntaxErrMsg(&pCxt->msg, "invalid values", pToken->z); - } pVal->flag = CV_FLAG_NULL; return TSDB_CODE_SUCCESS; } - if (TSDB_CODE_SUCCESS == code && IS_NUMERIC_TYPE(pSchema->type) && pToken->n == 0) { - return buildSyntaxErrMsg(&pCxt->msg, "invalid numeric data", pToken->z); - } - if (TSDB_CODE_SUCCESS == code) { + if (pToken->n == 0 && IS_NUMERIC_TYPE(pSchema->type)) { + return buildSyntaxErrMsg(&pCxt->msg, "invalid numeric data", pToken->z); + } code = parseValueTokenImpl(pCxt, pSql, pToken, pSchema, timePrec, pVal); } @@ -1728,18 +1737,19 @@ static int32_t processCtbTagsAfterCtbName(SInsertParseContext* pCxt, SVnodeModif const SToken* tagTokens, SSchema* const* tagSchemas, int numOfTagTokens) { int32_t code = TSDB_CODE_SUCCESS; + uint8_t precision = pStmt->pTableMeta->tableInfo.precision; if (code == TSDB_CODE_SUCCESS && ctbFirst) { for (int32_t i = 0; code == TSDB_CODE_SUCCESS && i < numOfTagTokens; ++i) { SToken* pTagToken = (SToken*)(tagTokens + i); SSchema* pTagSchema = tagSchemas[i]; code = checkAndTrimValue(pTagToken, pCxt->tmpTokenBuf, &pCxt->msg, pTagSchema->type); - if (TK_NK_VARIABLE == pTagToken->type) { + if (code == TSDB_CODE_SUCCESS && TK_NK_VARIABLE == pTagToken->type) { code = buildInvalidOperationMsg(&pCxt->msg, "not expected tag"); } if (code == TSDB_CODE_SUCCESS) { - code = parseTagValue(pCxt, pStmt, NULL, pTagSchema, pTagToken, pStbRowsCxt->aTagNames, pStbRowsCxt->aTagVals, + code = parseTagValue(&pCxt->msg, NULL, precision, pTagSchema, pTagToken, pStbRowsCxt->aTagNames, pStbRowsCxt->aTagVals, &pStbRowsCxt->pTag); } } @@ -1759,11 +1769,12 @@ static int32_t doGetStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt* const SBoundColInfo* pCols, const SSchema* pSchemas, SToken* tagTokens, SSchema** tagSchemas, int* pNumOfTagTokens, bool* bFoundTbName) { int32_t code = TSDB_CODE_SUCCESS; - SArray* pTagNames = pStbRowsCxt->aTagNames; - SArray* pTagVals = pStbRowsCxt->aTagVals; - bool canParseTagsAfter = !pStbRowsCxt->pTagCond && !pStbRowsCxt->hasTimestampTag; + SArray* pTagNames = pStbRowsCxt->aTagNames; + SArray* pTagVals = pStbRowsCxt->aTagVals; + bool canParseTagsAfter = !pStbRowsCxt->pTagCond && !pStbRowsCxt->hasTimestampTag; int32_t numOfCols = getNumOfColumns(pStbRowsCxt->pStbMeta); int32_t tbnameIdx = getTbnameSchemaIndex(pStbRowsCxt->pStbMeta); + uint8_t precision = getTableInfo(pStbRowsCxt->pStbMeta).precision; for (int i = 0; i < pCols->numOfBound && (code) == TSDB_CODE_SUCCESS; ++i) { const char* pTmpSql = *ppSql; bool ignoreComma = false; @@ -1781,7 +1792,7 @@ static int32_t doGetStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt* if (pCols->pColIndex[i] < numOfCols) { const SSchema* pSchema = &pSchemas[pCols->pColIndex[i]]; SColVal* pVal = taosArrayGet(pStbRowsCxt->aColVals, pCols->pColIndex[i]); - code = parseValueToken(pCxt, ppSql, pToken, (SSchema*)pSchema, getTableInfo(pStbRowsCxt->pStbMeta).precision, pVal); + code = parseValueToken(pCxt, ppSql, pToken, (SSchema*)pSchema, precision, pVal); if (TK_NK_VARIABLE == pToken->type) { code = buildInvalidOperationMsg(&pCxt->msg, "not expected row value"); } @@ -1793,11 +1804,11 @@ static int32_t doGetStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt* ++(*pNumOfTagTokens); } else { code = checkAndTrimValue(pToken, pCxt->tmpTokenBuf, &pCxt->msg, pTagSchema->type); - if (TK_NK_VARIABLE == pToken->type) { + if (code == TSDB_CODE_SUCCESS && TK_NK_VARIABLE == pToken->type) { code = buildInvalidOperationMsg(&pCxt->msg, "not expected row value"); } if (code == TSDB_CODE_SUCCESS) { - code = parseTagValue(pCxt, pStmt, ppSql, (SSchema*)pTagSchema, pToken, pTagNames, pTagVals, &pStbRowsCxt->pTag); + code = parseTagValue(&pCxt->msg, ppSql, precision, (SSchema*)pTagSchema, pToken, pTagNames, pTagVals, &pStbRowsCxt->pTag); } } } diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index f1013d6157..514ad930c3 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -213,6 +213,7 @@ static SKeyword keywordTable[] = { {"SLIDING", TK_SLIDING}, {"SLIMIT", TK_SLIMIT}, {"SMA", TK_SMA}, + {"SMALLDATA_TS_SORT", TK_SMALLDATA_TS_SORT}, {"SMALLINT", TK_SMALLINT}, {"SNODE", TK_SNODE}, {"SNODES", TK_SNODES}, @@ -656,7 +657,7 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) { *tokenId = TK_NK_ALIAS; // must be alias return i; } - if ((i == 4 && strncasecmp(z, "true", 4) == 0) || (i == 5 && strncasecmp(z, "false", 5) == 0)) { + if (IS_TRUE_STR(z, i) || IS_FALSE_STR(z, i)) { *tokenId = TK_NK_BOOL; return i; } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 38737d7a17..3bfa2122f6 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -1517,12 +1517,13 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal, void* data = NULL; uint32_t size = 0; - bool isHexChar = isHex(pVal->literal, strlen(pVal->literal)); + uint32_t vlen = strlen(pVal->literal); + bool isHexChar = isHex(pVal->literal, vlen); if (isHexChar) { - if (!isValidateHex(pVal->literal, strlen(pVal->literal))) { + if (!isValidateHex(pVal->literal, vlen)) { return TSDB_CODE_PAR_INVALID_VARBINARY; } - if (taosHex2Ascii(pVal->literal, strlen(pVal->literal), &data, &size) < 0) { + if (taosHex2Ascii(pVal->literal, vlen, &data, &size) < 0) { return TSDB_CODE_OUT_OF_MEMORY; } } else { @@ -1546,14 +1547,15 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal, } case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_GEOMETRY: { - if (strict && (pVal->node.resType.bytes > targetDt.bytes - VARSTR_HEADER_SIZE)) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal); + int32_t vlen = IS_VAR_DATA_TYPE(pVal->node.resType.type) ? pVal->node.resType.bytes : strlen(pVal->literal); + if (strict && (vlen > targetDt.bytes - VARSTR_HEADER_SIZE)) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_VALUE_TOO_LONG, pVal->literal); } - pVal->datum.p = taosMemoryCalloc(1, targetDt.bytes + 1); + int32_t len = TMIN(targetDt.bytes - VARSTR_HEADER_SIZE, vlen); + pVal->datum.p = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE + 1); if (NULL == pVal->datum.p) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY); } - int32_t len = TMIN(targetDt.bytes - VARSTR_HEADER_SIZE, pVal->node.resType.bytes); varDataSetLen(pVal->datum.p, len); strncpy(varDataVal(pVal->datum.p), pVal->literal, len); break; @@ -10024,75 +10026,6 @@ static int32_t createCastFuncForTag(STranslateContext* pCxt, SNode* pNode, SData return code; } -static int32_t createTagValFromExpr(STranslateContext* pCxt, SDataType targetDt, SNode* pNode, SValueNode** pVal) { - SNode* pCast = NULL; - int32_t code = createCastFuncForTag(pCxt, pNode, targetDt, &pCast); - SNode* pNew = NULL; - if (TSDB_CODE_SUCCESS == code) { - code = scalarCalculateConstants(pCast, &pNew); - } - if (TSDB_CODE_SUCCESS == code) { - pCast = pNew; - if (QUERY_NODE_VALUE != nodeType(pCast)) { - code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)pNode)->aliasName); - } - } - - if (TSDB_CODE_SUCCESS == code) { - *pVal = (SValueNode*)pCast; - } else { - nodesDestroyNode(pCast); - } - return code; -} - -static int32_t createTagValFromVal(STranslateContext* pCxt, SDataType targetDt, SNode* pNode, SValueNode** pVal) { - SValueNode* pTempVal = (SValueNode*)nodesCloneNode(pNode); - if (NULL == pTempVal) { - return TSDB_CODE_OUT_OF_MEMORY; - } - if (DEAL_RES_ERROR == translateValueImpl(pCxt, pTempVal, targetDt, true)) { - nodesDestroyNode((SNode*)pTempVal); - return pCxt->errCode; - } - *pVal = pTempVal; - return TSDB_CODE_SUCCESS; -} - -static int32_t createTagVal(STranslateContext* pCxt, uint8_t precision, SSchema* pSchema, SNode* pNode, - SValueNode** pVal) { - if (QUERY_NODE_VALUE == nodeType(pNode)) { - return createTagValFromVal(pCxt, schemaToDataType(precision, pSchema), pNode, pVal); - } else { - return createTagValFromExpr(pCxt, schemaToDataType(precision, pSchema), pNode, pVal); - } -} - -static int32_t buildJsonTagVal(STranslateContext* pCxt, SSchema* pTagSchema, SValueNode* pVal, SArray* pTagArray, - STag** ppTag) { - if (pVal->literal && strlen(pVal->literal) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { - return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pVal->literal); - } - - return parseJsontoTagData(pVal->literal, pTagArray, ppTag, &pCxt->msgBuf); -} - -static int32_t buildNormalTagVal(STranslateContext* pCxt, SSchema* pTagSchema, SValueNode* pVal, SArray* pTagArray) { - if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) { - void* nodeVal = nodesGetValueFromNode(pVal); - STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; - // strcpy(val.colName, pTagSchema->name); - if (IS_VAR_DATA_TYPE(pTagSchema->type)) { - val.pData = varDataVal(nodeVal); - val.nData = varDataLen(nodeVal); - } else { - memcpy(&val.i64, nodeVal, pTagSchema->bytes); - } - taosArrayPush(pTagArray, &val); - } - return TSDB_CODE_SUCCESS; -} - static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta, STag** ppTag, SArray* tagName) { int32_t numOfTags = getNumOfTags(pSuperTableMeta); @@ -10108,42 +10041,56 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla int32_t code = TSDB_CODE_SUCCESS; - bool isJson = false; - SNodeList* pVals = NULL; - SNode * pTag = NULL, *pNode = NULL; - FORBOTH(pTag, pStmt->pSpecificTags, pNode, pStmt->pValsOfTags) { - SColumnNode* pCol = (SColumnNode*)pTag; - SSchema* pSchema = getTagSchema(pSuperTableMeta, pCol->colName); - if (NULL == pSchema) { - code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAG_NAME, pCol->colName); - } - SValueNode* pVal = NULL; + bool isJson = false; + SNode * pTagNode = NULL, *pNode = NULL; + uint8_t precision = pSuperTableMeta->tableInfo.precision; + SToken token; + char tokenBuf[TSDB_MAX_TAGS_LEN]; + const char* tagStr = NULL; + FORBOTH(pTagNode, pStmt->pSpecificTags, pNode, pStmt->pValsOfTags) { + tagStr = ((SValueNode*)pNode)->literal; + NEXT_TOKEN_WITH_PREV(tagStr, token); + + SSchema* pSchema = NULL; if (TSDB_CODE_SUCCESS == code) { - code = createTagVal(pCxt, pSuperTableMeta->tableInfo.precision, pSchema, pNode, &pVal); + if ((pSchema = getTagSchema(pSuperTableMeta, ((SColumnNode*)pTagNode)->colName))) { + code = checkAndTrimValue(&token, tokenBuf, &pCxt->msgBuf, pSchema->type); + if (TSDB_CODE_SUCCESS == code && TK_NK_VARIABLE == token.type) { + code = TSDB_CODE_TSC_SQL_SYNTAX_ERROR; + } + } else { + code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAG_NAME, ((SColumnNode*)pTagNode)->colName); + } } + if (TSDB_CODE_SUCCESS == code) { if (pSchema->type == TSDB_DATA_TYPE_JSON) { isJson = true; - code = buildJsonTagVal(pCxt, pSchema, pVal, pTagArray, ppTag); - taosArrayPush(tagName, pCol->colName); - } else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) { - code = buildNormalTagVal(pCxt, pSchema, pVal, pTagArray); - taosArrayPush(tagName, pCol->colName); + } + code = parseTagValue(&pCxt->msgBuf, &tagStr, precision, pSchema, &token, tagName, pTagArray, ppTag); + } + + if (TSDB_CODE_SUCCESS == code) { + NEXT_VALID_TOKEN(tagStr, token); + if (token.n != 0) { + code = buildSyntaxErrMsg(&pCxt->msgBuf, "not expected tags values", token.z); } } - if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeAppend(&pVals, (SNode*)pVal); - } + if (TSDB_CODE_SUCCESS != code) { break; } } - if (TSDB_CODE_SUCCESS == code && !isJson) { code = tTagNew(pTagArray, 1, false, ppTag); } - nodesDestroyList(pVals); + for (int i = 0; i < taosArrayGetSize(pTagArray); ++i) { + STagVal* p = (STagVal*)taosArrayGet(pTagArray, i); + if (IS_VAR_DATA_TYPE(p->type)) { + taosMemoryFreeClear(p->pData); + } + } taosArrayDestroy(pTagArray); return code; } @@ -10161,51 +10108,52 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau int32_t code = TSDB_CODE_SUCCESS; - bool isJson = false; - int32_t index = 0; - SSchema* pTagSchemas = getTableTagSchema(pSuperTableMeta); - SNodeList* pVals = NULL; - SNode* pNode; + bool isJson = false; + SNode* pNode; + uint8_t precision = pSuperTableMeta->tableInfo.precision; + SSchema* pTagSchema = getTableTagSchema(pSuperTableMeta); + SToken token; + char tokenBuf[TSDB_MAX_TAGS_LEN]; + const char* tagStr = NULL; FOREACH(pNode, pStmt->pValsOfTags) { - SValueNode* pVal = NULL; - SSchema* pTagSchema = pTagSchemas + index; - code = createTagVal(pCxt, pSuperTableMeta->tableInfo.precision, pTagSchema, pNode, &pVal); + tagStr = ((SValueNode*)pNode)->literal; + NEXT_TOKEN_WITH_PREV(tagStr, token); + + code = checkAndTrimValue(&token, tokenBuf, &pCxt->msgBuf, pTagSchema->type); + if (TSDB_CODE_SUCCESS == code && TK_NK_VARIABLE == token.type) { + code = buildSyntaxErrMsg(&pCxt->msgBuf, "not expected tags values", token.z); + } + if (TSDB_CODE_SUCCESS == code) { if (pTagSchema->type == TSDB_DATA_TYPE_JSON) { isJson = true; - code = buildJsonTagVal(pCxt, pTagSchema, pVal, pTagArray, ppTag); - if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode((SNode*)pVal); - } - taosArrayPush(tagName, pTagSchema->name); - } else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL && !pVal->isNull) { - char* tmpVal = nodesGetValueFromNode(pVal); - STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; - // strcpy(val.colName, pTagSchema->name); - if (IS_VAR_DATA_TYPE(pTagSchema->type)) { - val.pData = varDataVal(tmpVal); - val.nData = varDataLen(tmpVal); - } else { - memcpy(&val.i64, tmpVal, pTagSchema->bytes); - } - taosArrayPush(pTagArray, &val); - taosArrayPush(tagName, pTagSchema->name); + } + code = parseTagValue(&pCxt->msgBuf, &tagStr, precision, pTagSchema, &token, tagName, pTagArray, ppTag); + } + + if (TSDB_CODE_SUCCESS == code) { + NEXT_VALID_TOKEN(tagStr, token); + if (token.n != 0) { + code = buildSyntaxErrMsg(&pCxt->msgBuf, "not expected tags values", token.z); } } - if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeAppend(&pVals, (SNode*)pVal); - } + if (TSDB_CODE_SUCCESS != code) { break; } - ++index; + ++pTagSchema; } if (TSDB_CODE_SUCCESS == code && !isJson) { code = tTagNew(pTagArray, 1, false, ppTag); } - nodesDestroyList(pVals); + for (int32_t i = 0; i < TARRAY_SIZE(pTagArray); ++i) { + STagVal* p = (STagVal*)TARRAY_GET_ELEM(pTagArray, i); + if (IS_VAR_DATA_TYPE(p->type)) { + taosMemoryFreeClear(p->pData); + } + } taosArrayDestroy(pTagArray); return code; } @@ -10466,58 +10414,68 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE, "Invalid tag name: %s", pStmt->colName); } - pReq->tagName = taosStrdup(pStmt->colName); if (NULL == pReq->tagName) { return TSDB_CODE_OUT_OF_MEMORY; } + pReq->pTagArray = taosArrayInit(1, sizeof(STagVal)); + if (NULL == pReq->pTagArray) { + return TSDB_CODE_OUT_OF_MEMORY; + } pReq->colId = pSchema->colId; + pReq->tagType = pSchema->type; - SDataType targetDt = schemaToDataType(pTableMeta->tableInfo.precision, pSchema); + int32_t code = 0; - if (QUERY_NODE_VALUE != pStmt->pVal->node.type) { - SValueNode* pVal = NULL; - pCxt->errCode = createTagValFromExpr(pCxt, targetDt, (SNode*)pStmt->pVal, &pVal); - if (pCxt->errCode) { - return pCxt->errCode; - } - - nodesDestroyNode((SNode*)pStmt->pVal); - pStmt->pVal = pVal; - } else if (DEAL_RES_ERROR == translateValueImpl(pCxt, pStmt->pVal, targetDt, true)) { - return pCxt->errCode; - } - - pReq->tagType = targetDt.type; - if (targetDt.type == TSDB_DATA_TYPE_JSON) { - if (pStmt->pVal->literal && - strlen(pStmt->pVal->literal) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { - return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pStmt->pVal->literal); - } - SArray* pTagVals = taosArrayInit(1, sizeof(STagVal)); - int32_t code = TSDB_CODE_SUCCESS; - STag* pTag = NULL; - code = parseJsontoTagData(pStmt->pVal->literal, pTagVals, &pTag, &pCxt->msgBuf); - taosArrayDestroy(pTagVals); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - pReq->nTagVal = pTag->len; - pReq->pTagVal = (uint8_t*)pTag; - pStmt->pVal->datum.p = (char*)pTag; // for free - } else { - pReq->isNull = pStmt->pVal->isNull; - pReq->nTagVal = pStmt->pVal->node.resType.bytes; - pReq->pTagVal = nodesGetValueFromNode(pStmt->pVal); - - // data and length are seperated for new tag format STagVal - if (IS_VAR_DATA_TYPE(pStmt->pVal->node.resType.type)) { - pReq->nTagVal = varDataLen(pReq->pTagVal); - pReq->pTagVal = varDataVal(pReq->pTagVal); + STag* pTag = NULL; + SToken token; + char tokenBuf[TSDB_MAX_TAGS_LEN]; + const char* tagStr = pStmt->pVal->literal; + NEXT_TOKEN_WITH_PREV(tagStr, token); + if (TSDB_CODE_SUCCESS == code) { + code = checkAndTrimValue(&token, tokenBuf, &pCxt->msgBuf, pSchema->type); + if (TSDB_CODE_SUCCESS == code && TK_NK_VARIABLE == token.type) { + code = buildSyntaxErrMsg(&pCxt->msgBuf, "not expected tags values", token.z); } } - return TSDB_CODE_SUCCESS; + if (TSDB_CODE_SUCCESS == code) { + code = parseTagValue(&pCxt->msgBuf, &tagStr, pTableMeta->tableInfo.precision, pSchema, &token, NULL, + pReq->pTagArray, &pTag); + if (pSchema->type == TSDB_DATA_TYPE_JSON && token.type == TK_NULL && code == TSDB_CODE_SUCCESS) { + pReq->tagFree = true; + } + } + if (TSDB_CODE_SUCCESS == code && tagStr) { + NEXT_VALID_TOKEN(tagStr, token); + if (token.n != 0) { + code = buildSyntaxErrMsg(&pCxt->msgBuf, "not expected tags values", token.z); + } + } + + if (TSDB_CODE_SUCCESS == code) { + if (pSchema->type == TSDB_DATA_TYPE_JSON) { + pReq->nTagVal = pTag->len; + pReq->pTagVal = (uint8_t*)pTag; + pStmt->pVal->datum.p = (char*)pTag; // for free + } else { + STagVal* pTagVal = taosArrayGet(pReq->pTagArray, 0); + if (pTagVal) { + pReq->isNull = false; + if (IS_VAR_DATA_TYPE(pSchema->type)) { + pReq->nTagVal = pTagVal->nData; + pReq->pTagVal = pTagVal->pData; + } else { + pReq->nTagVal = pSchema->bytes; + pReq->pTagVal = (uint8_t*)&pTagVal->i64; + } + } else { + pReq->isNull = true; + } + } + } + + return code; } static int32_t buildAddColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta, @@ -10741,6 +10699,14 @@ static void destoryAlterTbReq(SVAlterTbReq* pReq) { taosMemoryFree(pReq->colNewName); taosMemoryFree(pReq->tagName); taosMemoryFree(pReq->newComment); + for (int i = 0; i < taosArrayGetSize(pReq->pTagArray); ++i) { + STagVal* p = (STagVal*)taosArrayGet(pReq->pTagArray, i); + if (IS_VAR_DATA_TYPE(p->type)) { + taosMemoryFreeClear(p->pData); + } + } + taosArrayDestroy(pReq->pTagArray); + if(pReq->tagFree) tTagFree((STag*)pReq->pTagVal); } static int32_t rewriteAlterTableImpl(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta, diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 76d8022578..9c8f6d3c98 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -355,7 +355,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi SHashObj* keyHash = NULL; int32_t size = 0; // set json NULL data - if (!json || strtrim((char*)json) == 0 || strcasecmp(json, TSDB_DATA_NULL_STR_L) == 0) { + if (!json || strcasecmp(json, TSDB_DATA_NULL_STR_L) == 0 || strtrim((char*)json) == 0) { retCode = TSDB_CODE_SUCCESS; goto end; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 9833c8151b..d9ede90113 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -1,5 +1,3 @@ -/* This file is automatically generated by Lemon from input grammar -** source file "sql.y". */ /* ** 2000-05-29 ** @@ -24,7 +22,10 @@ ** The following is the concatenation of all %include directives from the ** input grammar file: */ +#include +#include /************ Begin %include sections from the grammar ************************/ + #include #include #include @@ -41,361 +42,11 @@ #define YYSTACKDEPTH 0 /**************** End of %include directives **********************************/ -/* These constants specify the various numeric values for terminal symbols. -***************** Begin token definitions *************************************/ -#ifndef TK_OR -#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_NK_COMMA 33 -#define TK_HOST 34 -#define TK_USER 35 -#define TK_ENABLE 36 -#define TK_NK_INTEGER 37 -#define TK_SYSINFO 38 -#define TK_ADD 39 -#define TK_DROP 40 -#define TK_GRANT 41 -#define TK_ON 42 -#define TK_TO 43 -#define TK_REVOKE 44 -#define TK_FROM 45 -#define TK_SUBSCRIBE 46 -#define TK_READ 47 -#define TK_WRITE 48 -#define TK_NK_DOT 49 -#define TK_WITH 50 -#define TK_DNODE 51 -#define TK_PORT 52 -#define TK_DNODES 53 -#define TK_RESTORE 54 -#define TK_NK_IPTOKEN 55 -#define TK_FORCE 56 -#define TK_UNSAFE 57 -#define TK_CLUSTER 58 -#define TK_LOCAL 59 -#define TK_QNODE 60 -#define TK_BNODE 61 -#define TK_SNODE 62 -#define TK_MNODE 63 -#define TK_VNODE 64 -#define TK_DATABASE 65 -#define TK_USE 66 -#define TK_FLUSH 67 -#define TK_TRIM 68 -#define TK_COMPACT 69 -#define TK_IF 70 -#define TK_NOT 71 -#define TK_EXISTS 72 -#define TK_BUFFER 73 -#define TK_CACHEMODEL 74 -#define TK_CACHESIZE 75 -#define TK_COMP 76 -#define TK_DURATION 77 -#define TK_NK_VARIABLE 78 -#define TK_MAXROWS 79 -#define TK_MINROWS 80 -#define TK_KEEP 81 -#define TK_PAGES 82 -#define TK_PAGESIZE 83 -#define TK_TSDB_PAGESIZE 84 -#define TK_PRECISION 85 -#define TK_REPLICA 86 -#define TK_VGROUPS 87 -#define TK_SINGLE_STABLE 88 -#define TK_RETENTIONS 89 -#define TK_SCHEMALESS 90 -#define TK_WAL_LEVEL 91 -#define TK_WAL_FSYNC_PERIOD 92 -#define TK_WAL_RETENTION_PERIOD 93 -#define TK_WAL_RETENTION_SIZE 94 -#define TK_WAL_ROLL_PERIOD 95 -#define TK_WAL_SEGMENT_SIZE 96 -#define TK_STT_TRIGGER 97 -#define TK_TABLE_PREFIX 98 -#define TK_TABLE_SUFFIX 99 -#define TK_KEEP_TIME_OFFSET 100 -#define TK_NK_COLON 101 -#define TK_BWLIMIT 102 -#define TK_START 103 -#define TK_TIMESTAMP 104 -#define TK_END 105 -#define TK_TABLE 106 -#define TK_NK_LP 107 -#define TK_NK_RP 108 -#define TK_STABLE 109 -#define TK_COLUMN 110 -#define TK_MODIFY 111 -#define TK_RENAME 112 -#define TK_TAG 113 -#define TK_SET 114 -#define TK_NK_EQ 115 -#define TK_USING 116 -#define TK_TAGS 117 -#define TK_BOOL 118 -#define TK_TINYINT 119 -#define TK_SMALLINT 120 -#define TK_INT 121 -#define TK_INTEGER 122 -#define TK_BIGINT 123 -#define TK_FLOAT 124 -#define TK_DOUBLE 125 -#define TK_BINARY 126 -#define TK_NCHAR 127 -#define TK_UNSIGNED 128 -#define TK_JSON 129 -#define TK_VARCHAR 130 -#define TK_MEDIUMBLOB 131 -#define TK_BLOB 132 -#define TK_VARBINARY 133 -#define TK_GEOMETRY 134 -#define TK_DECIMAL 135 -#define TK_COMMENT 136 -#define TK_MAX_DELAY 137 -#define TK_WATERMARK 138 -#define TK_ROLLUP 139 -#define TK_TTL 140 -#define TK_SMA 141 -#define TK_DELETE_MARK 142 -#define TK_FIRST 143 -#define TK_LAST 144 -#define TK_SHOW 145 -#define TK_PRIVILEGES 146 -#define TK_DATABASES 147 -#define TK_TABLES 148 -#define TK_STABLES 149 -#define TK_MNODES 150 -#define TK_QNODES 151 -#define TK_FUNCTIONS 152 -#define TK_INDEXES 153 -#define TK_ACCOUNTS 154 -#define TK_APPS 155 -#define TK_CONNECTIONS 156 -#define TK_LICENCES 157 -#define TK_GRANTS 158 -#define TK_FULL 159 -#define TK_LOGS 160 -#define TK_MACHINES 161 -#define TK_QUERIES 162 -#define TK_SCORES 163 -#define TK_TOPICS 164 -#define TK_VARIABLES 165 -#define TK_BNODES 166 -#define TK_SNODES 167 -#define TK_TRANSACTIONS 168 -#define TK_DISTRIBUTED 169 -#define TK_CONSUMERS 170 -#define TK_SUBSCRIPTIONS 171 -#define TK_VNODES 172 -#define TK_ALIVE 173 -#define TK_VIEWS 174 -#define TK_VIEW 175 -#define TK_COMPACTS 176 -#define TK_NORMAL 177 -#define TK_CHILD 178 -#define TK_LIKE 179 -#define TK_TBNAME 180 -#define TK_QTAGS 181 -#define TK_AS 182 -#define TK_SYSTEM 183 -#define TK_INDEX 184 -#define TK_FUNCTION 185 -#define TK_INTERVAL 186 -#define TK_COUNT 187 -#define TK_LAST_ROW 188 -#define TK_META 189 -#define TK_ONLY 190 -#define TK_TOPIC 191 -#define TK_CONSUMER 192 -#define TK_GROUP 193 -#define TK_DESC 194 -#define TK_DESCRIBE 195 -#define TK_RESET 196 -#define TK_QUERY 197 -#define TK_CACHE 198 -#define TK_EXPLAIN 199 -#define TK_ANALYZE 200 -#define TK_VERBOSE 201 -#define TK_NK_BOOL 202 -#define TK_RATIO 203 -#define TK_NK_FLOAT 204 -#define TK_OUTPUTTYPE 205 -#define TK_AGGREGATE 206 -#define TK_BUFSIZE 207 -#define TK_LANGUAGE 208 -#define TK_REPLACE 209 -#define TK_STREAM 210 -#define TK_INTO 211 -#define TK_PAUSE 212 -#define TK_RESUME 213 -#define TK_TRIGGER 214 -#define TK_AT_ONCE 215 -#define TK_WINDOW_CLOSE 216 -#define TK_IGNORE 217 -#define TK_EXPIRED 218 -#define TK_FILL_HISTORY 219 -#define TK_UPDATE 220 -#define TK_SUBTABLE 221 -#define TK_UNTREATED 222 -#define TK_KILL 223 -#define TK_CONNECTION 224 -#define TK_TRANSACTION 225 -#define TK_BALANCE 226 -#define TK_VGROUP 227 -#define TK_LEADER 228 -#define TK_MERGE 229 -#define TK_REDISTRIBUTE 230 -#define TK_SPLIT 231 -#define TK_DELETE 232 -#define TK_INSERT 233 -#define TK_NULL 234 -#define TK_NK_QUESTION 235 -#define TK_NK_ALIAS 236 -#define TK_NK_ARROW 237 -#define TK_ROWTS 238 -#define TK_QSTART 239 -#define TK_QEND 240 -#define TK_QDURATION 241 -#define TK_WSTART 242 -#define TK_WEND 243 -#define TK_WDURATION 244 -#define TK_IROWTS 245 -#define TK_ISFILLED 246 -#define TK_CAST 247 -#define TK_NOW 248 -#define TK_TODAY 249 -#define TK_TIMEZONE 250 -#define TK_CLIENT_VERSION 251 -#define TK_SERVER_VERSION 252 -#define TK_SERVER_STATUS 253 -#define TK_CURRENT_USER 254 -#define TK_CASE 255 -#define TK_WHEN 256 -#define TK_THEN 257 -#define TK_ELSE 258 -#define TK_BETWEEN 259 -#define TK_IS 260 -#define TK_NK_LT 261 -#define TK_NK_GT 262 -#define TK_NK_LE 263 -#define TK_NK_GE 264 -#define TK_NK_NE 265 -#define TK_MATCH 266 -#define TK_NMATCH 267 -#define TK_CONTAINS 268 -#define TK_IN 269 -#define TK_JOIN 270 -#define TK_INNER 271 -#define TK_SELECT 272 -#define TK_NK_HINT 273 -#define TK_DISTINCT 274 -#define TK_WHERE 275 -#define TK_PARTITION 276 -#define TK_BY 277 -#define TK_SESSION 278 -#define TK_STATE_WINDOW 279 -#define TK_EVENT_WINDOW 280 -#define TK_COUNT_WINDOW 281 -#define TK_SLIDING 282 -#define TK_FILL 283 -#define TK_VALUE 284 -#define TK_VALUE_F 285 -#define TK_NONE 286 -#define TK_PREV 287 -#define TK_NULL_F 288 -#define TK_LINEAR 289 -#define TK_NEXT 290 -#define TK_HAVING 291 -#define TK_RANGE 292 -#define TK_EVERY 293 -#define TK_ORDER 294 -#define TK_SLIMIT 295 -#define TK_SOFFSET 296 -#define TK_LIMIT 297 -#define TK_OFFSET 298 -#define TK_ASC 299 -#define TK_NULLS 300 -#define TK_ABORT 301 -#define TK_AFTER 302 -#define TK_ATTACH 303 -#define TK_BEFORE 304 -#define TK_BEGIN 305 -#define TK_BITAND 306 -#define TK_BITNOT 307 -#define TK_BITOR 308 -#define TK_BLOCKS 309 -#define TK_CHANGE 310 -#define TK_COMMA 311 -#define TK_CONCAT 312 -#define TK_CONFLICT 313 -#define TK_COPY 314 -#define TK_DEFERRED 315 -#define TK_DELIMITERS 316 -#define TK_DETACH 317 -#define TK_DIVIDE 318 -#define TK_DOT 319 -#define TK_EACH 320 -#define TK_FAIL 321 -#define TK_FILE 322 -#define TK_FOR 323 -#define TK_GLOB 324 -#define TK_ID 325 -#define TK_IMMEDIATE 326 -#define TK_IMPORT 327 -#define TK_INITIALLY 328 -#define TK_INSTEAD 329 -#define TK_ISNULL 330 -#define TK_KEY 331 -#define TK_MODULES 332 -#define TK_NK_BITNOT 333 -#define TK_NK_SEMI 334 -#define TK_NOTNULL 335 -#define TK_OF 336 -#define TK_PLUS 337 -#define TK_PRIVILEGE 338 -#define TK_RAISE 339 -#define TK_RESTRICT 340 -#define TK_ROW 341 -#define TK_SEMI 342 -#define TK_STAR 343 -#define TK_STATEMENT 344 -#define TK_STRICT 345 -#define TK_STRING 346 -#define TK_TIMES 347 -#define TK_VALUES 348 -#define TK_VARIABLE 349 -#define TK_WAL 350 -#endif -/**************** End token definitions ***************************************/ +/* These constants specify the various numeric values for terminal symbols +** in a format understandable to "makeheaders". This section is blank unless +** "lemon" is run with the "-m" command-line option. +***************** Begin makeheaders token definitions *************************/ +/**************** End makeheaders token definitions ***************************/ /* The next sections is a series of control #defines. ** various aspects of the generated parser. @@ -453,29 +104,29 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 512 +#define YYNOCODE 516 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - STokenPair yy57; - int64_t yy221; - EOperatorType yy252; - EShowKind yy321; - bool yy345; - EFillMode yy358; - SNode* yy360; - SNodeList* yy536; - int32_t yy580; - ENullOrder yy585; - EJoinType yy596; - EOrder yy642; - int8_t yy695; - SAlterOption yy797; - SDataType yy912; - SToken yy929; - SShowTablesOption yy1005; + ENullOrder yy73; + SNodeList* yy136; + int8_t yy191; + SDataType yy256; + SShowTablesOption yy493; + bool yy497; + EShowKind yy633; + SNode* yy656; + EJoinType yy660; + SToken yy665; + EOrder yy674; + int32_t yy676; + SAlterOption yy749; + STokenPair yy753; + EFillMode yy822; + EOperatorType yy836; + int64_t yy909; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -491,18 +142,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 852 -#define YYNRULE 649 -#define YYNRULE_WITH_ACTION 649 -#define YYNTOKEN 351 -#define YY_MAX_SHIFT 851 -#define YY_MIN_SHIFTREDUCE 1256 -#define YY_MAX_SHIFTREDUCE 1904 -#define YY_ERROR_ACTION 1905 -#define YY_ACCEPT_ACTION 1906 -#define YY_NO_ACTION 1907 -#define YY_MIN_REDUCE 1908 -#define YY_MAX_REDUCE 2556 +#define YYNSTATE 859 +#define YYNRULE 670 +#define YYNRULE_WITH_ACTION 670 +#define YYNTOKEN 353 +#define YY_MAX_SHIFT 858 +#define YY_MIN_SHIFTREDUCE 1281 +#define YY_MAX_SHIFTREDUCE 1950 +#define YY_ERROR_ACTION 1951 +#define YY_ACCEPT_ACTION 1952 +#define YY_NO_ACTION 1953 +#define YY_MIN_REDUCE 1954 +#define YY_MAX_REDUCE 2623 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -569,853 +220,864 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2941) +#define YY_ACTTAB_COUNT (2992) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 95, 2332, 567, 2151, 468, 568, 1951, 14, 13, 467, - /* 10 */ 2185, 2315, 48, 46, 1826, 2340, 2532, 387, 723, 2527, - /* 20 */ 419, 699, 1667, 41, 40, 2336, 2093, 47, 45, 44, - /* 30 */ 43, 42, 174, 647, 1920, 1752, 1994, 1665, 2531, 737, - /* 40 */ 2098, 704, 2528, 2530, 2527, 2356, 38, 321, 645, 584, - /* 50 */ 643, 270, 269, 1696, 675, 716, 146, 2527, 719, 137, - /* 60 */ 112, 675, 703, 203, 2527, 1747, 610, 2528, 705, 2338, - /* 70 */ 416, 19, 739, 2236, 2418, 2533, 203, 147, 1673, 747, - /* 80 */ 2528, 705, 2533, 203, 2236, 2090, 2374, 2528, 705, 41, - /* 90 */ 40, 2234, 724, 47, 45, 44, 43, 42, 2322, 412, - /* 100 */ 753, 587, 2233, 724, 848, 585, 2229, 15, 475, 823, - /* 110 */ 822, 821, 820, 431, 1795, 819, 818, 151, 813, 812, - /* 120 */ 811, 810, 809, 808, 807, 150, 801, 800, 799, 430, - /* 130 */ 429, 796, 795, 794, 183, 182, 793, 2074, 1322, 2355, - /* 140 */ 1321, 63, 2393, 1754, 1755, 114, 2357, 757, 2359, 2360, - /* 150 */ 752, 1692, 747, 534, 532, 142, 367, 186, 575, 2446, - /* 160 */ 217, 568, 1951, 415, 2442, 301, 2454, 715, 572, 138, - /* 170 */ 714, 511, 2527, 1323, 569, 510, 184, 2151, 205, 2532, - /* 180 */ 1727, 1737, 2527, 509, 383, 736, 2476, 1753, 1756, 1870, - /* 190 */ 703, 203, 2149, 716, 146, 2528, 705, 1908, 385, 52, - /* 200 */ 2216, 2531, 1668, 63, 1666, 2528, 2529, 792, 196, 1901, - /* 210 */ 1692, 41, 40, 2145, 2146, 47, 45, 44, 43, 42, - /* 220 */ 2138, 136, 135, 134, 133, 132, 131, 130, 129, 128, - /* 230 */ 736, 484, 2212, 528, 1671, 1672, 1724, 1724, 1726, 1729, - /* 240 */ 1730, 1731, 1732, 1733, 1734, 1735, 1736, 749, 745, 1745, - /* 250 */ 1746, 1748, 1749, 1750, 1751, 2, 48, 46, 1325, 1326, - /* 260 */ 1693, 365, 704, 1690, 419, 2527, 1667, 428, 427, 1697, - /* 270 */ 518, 238, 2356, 537, 377, 570, 658, 1959, 536, 1752, - /* 280 */ 219, 1665, 223, 703, 203, 751, 273, 240, 2528, 705, - /* 290 */ 272, 570, 1674, 1959, 498, 228, 538, 466, 1696, 465, - /* 300 */ 698, 366, 500, 202, 2454, 2455, 305, 144, 2459, 1747, - /* 310 */ 1931, 659, 478, 2374, 1900, 19, 1460, 51, 1781, 527, - /* 320 */ 227, 452, 1673, 90, 274, 2322, 89, 753, 2374, 464, - /* 330 */ 1451, 782, 781, 780, 1455, 779, 1457, 1458, 778, 775, - /* 340 */ 583, 1466, 772, 1468, 1469, 769, 766, 763, 848, 386, - /* 350 */ 1693, 15, 790, 161, 160, 787, 786, 785, 158, 98, - /* 360 */ 486, 1997, 372, 2322, 305, 398, 2355, 649, 305, 2393, - /* 370 */ 1566, 1567, 357, 2357, 757, 2359, 2360, 752, 750, 747, - /* 380 */ 738, 2411, 1782, 1586, 1587, 577, 2275, 1754, 1755, 697, - /* 390 */ 2223, 2202, 88, 525, 524, 523, 522, 517, 516, 515, - /* 400 */ 514, 369, 1635, 1636, 1930, 504, 503, 502, 501, 495, - /* 410 */ 494, 493, 2532, 488, 487, 384, 184, 737, 2098, 479, - /* 420 */ 1554, 1555, 716, 146, 1727, 1737, 1573, 1585, 1588, 1695, - /* 430 */ 2461, 1753, 1756, 1695, 629, 628, 627, 137, 716, 146, - /* 440 */ 2217, 619, 143, 623, 615, 1305, 1668, 622, 1666, 456, - /* 450 */ 1696, 1691, 621, 626, 393, 392, 2458, 2322, 620, 1677, - /* 460 */ 194, 616, 37, 417, 1776, 1777, 1778, 1779, 1780, 1784, - /* 470 */ 1785, 1786, 1787, 1495, 1496, 792, 458, 454, 1671, 1672, - /* 480 */ 1724, 744, 1726, 1729, 1730, 1731, 1732, 1733, 1734, 1735, - /* 490 */ 1736, 749, 745, 1745, 1746, 1748, 1749, 1750, 1751, 2, - /* 500 */ 12, 48, 46, 2356, 1322, 2332, 1321, 736, 2531, 419, - /* 510 */ 2075, 1667, 422, 1823, 1697, 256, 754, 1894, 424, 2089, - /* 520 */ 168, 2144, 2146, 2151, 1752, 1929, 1665, 400, 2100, 2336, - /* 530 */ 399, 179, 204, 2454, 2455, 2149, 144, 2459, 2149, 1323, - /* 540 */ 604, 600, 596, 592, 2374, 255, 106, 718, 201, 2454, - /* 550 */ 2455, 1303, 144, 2459, 1747, 12, 2322, 2151, 753, 656, - /* 560 */ 19, 629, 628, 627, 409, 3, 694, 1673, 619, 143, - /* 570 */ 623, 2091, 2149, 2338, 622, 1301, 1302, 54, 2322, 621, - /* 580 */ 626, 393, 392, 747, 1859, 620, 96, 1692, 616, 253, - /* 590 */ 12, 303, 10, 848, 51, 303, 15, 2355, 737, 2098, - /* 600 */ 2393, 2356, 95, 114, 2357, 757, 2359, 2360, 752, 741, - /* 610 */ 747, 2418, 198, 149, 754, 156, 2417, 2446, 492, 41, - /* 620 */ 40, 415, 2442, 47, 45, 44, 43, 42, 2094, 2332, - /* 630 */ 1415, 1696, 1754, 1755, 691, 690, 1857, 1858, 1860, 1861, - /* 640 */ 1862, 1928, 2374, 2341, 1773, 1414, 790, 161, 160, 787, - /* 650 */ 786, 785, 158, 2336, 2322, 243, 753, 1909, 700, 695, - /* 660 */ 688, 684, 490, 2212, 252, 245, 1697, 520, 2212, 1727, - /* 670 */ 1737, 250, 581, 1927, 63, 659, 1753, 1756, 127, 68, - /* 680 */ 2303, 126, 125, 124, 123, 122, 121, 120, 119, 118, - /* 690 */ 242, 1668, 173, 1666, 2322, 2355, 806, 2338, 2393, 2059, - /* 700 */ 2037, 114, 2357, 757, 2359, 2360, 752, 747, 747, 564, - /* 710 */ 1926, 221, 539, 2421, 2316, 2446, 226, 1673, 562, 415, - /* 720 */ 2442, 558, 554, 1671, 1672, 1724, 2322, 1726, 1729, 1730, - /* 730 */ 1731, 1732, 1733, 1734, 1735, 1736, 749, 745, 1745, 1746, - /* 740 */ 1748, 1749, 1750, 1751, 2, 48, 46, 1757, 2356, 661, - /* 750 */ 2275, 737, 2098, 419, 2284, 1667, 654, 312, 313, 305, - /* 760 */ 159, 719, 311, 2322, 675, 1936, 843, 2527, 1752, 127, - /* 770 */ 1665, 208, 126, 125, 124, 123, 122, 121, 120, 119, - /* 780 */ 118, 2356, 63, 1822, 413, 2533, 203, 737, 2098, 2374, - /* 790 */ 2528, 705, 171, 199, 754, 2151, 1961, 326, 1747, 707, - /* 800 */ 2100, 2322, 414, 753, 737, 2098, 675, 56, 275, 2527, - /* 810 */ 2149, 1673, 41, 40, 2151, 422, 47, 45, 44, 43, - /* 820 */ 42, 423, 2374, 171, 472, 606, 605, 2533, 203, 2149, - /* 830 */ 425, 2100, 2528, 705, 2322, 55, 753, 848, 171, 305, - /* 840 */ 49, 9, 2355, 737, 2098, 2393, 2100, 1697, 114, 2357, - /* 850 */ 757, 2359, 2360, 752, 1925, 747, 2356, 1924, 783, 1667, - /* 860 */ 186, 1296, 2446, 473, 171, 1923, 415, 2442, 2461, 754, - /* 870 */ 737, 2098, 2101, 1922, 1665, 2355, 1754, 1755, 2393, 2073, - /* 880 */ 1303, 114, 2357, 757, 2359, 2360, 752, 1919, 747, 2477, - /* 890 */ 505, 636, 1830, 2547, 2457, 2446, 1762, 2374, 1692, 415, - /* 900 */ 2442, 197, 1692, 1298, 1301, 1302, 648, 2322, 210, 2322, - /* 910 */ 2322, 753, 1842, 1727, 1737, 1673, 737, 2098, 2322, 2306, - /* 920 */ 1753, 1756, 271, 41, 40, 1692, 2322, 47, 45, 44, - /* 930 */ 43, 42, 44, 43, 42, 1668, 506, 1666, 639, 1851, - /* 940 */ 2322, 848, 674, 625, 624, 633, 631, 305, 30, 2151, - /* 950 */ 2355, 1403, 268, 2393, 1852, 660, 176, 2357, 757, 2359, - /* 960 */ 2360, 752, 2087, 747, 732, 608, 607, 1671, 1672, 1724, - /* 970 */ 441, 1726, 1729, 1730, 1731, 1732, 1733, 1734, 1735, 1736, - /* 980 */ 749, 745, 1745, 1746, 1748, 1749, 1750, 1751, 2, 48, - /* 990 */ 46, 2083, 1405, 72, 1918, 1850, 71, 419, 1917, 1667, - /* 1000 */ 47, 45, 44, 43, 42, 675, 1916, 1915, 2527, 2085, - /* 1010 */ 706, 2548, 1752, 2151, 1665, 790, 161, 160, 787, 786, - /* 1020 */ 785, 158, 1914, 1871, 1913, 2356, 2533, 203, 2150, 41, - /* 1030 */ 40, 2528, 705, 47, 45, 44, 43, 42, 754, 1668, - /* 1040 */ 2484, 1666, 1747, 1783, 737, 2098, 1692, 2322, 2356, 737, - /* 1050 */ 2098, 2322, 1419, 737, 2098, 1673, 737, 2098, 1728, 2322, - /* 1060 */ 2322, 754, 1728, 2497, 507, 148, 2374, 1418, 2417, 586, - /* 1070 */ 1815, 1671, 1672, 2095, 61, 2322, 276, 2322, 2322, 76, - /* 1080 */ 753, 848, 672, 2356, 49, 1728, 614, 41, 40, 2374, - /* 1090 */ 613, 47, 45, 44, 43, 42, 754, 708, 686, 34, - /* 1100 */ 2169, 2322, 2081, 753, 784, 41, 40, 2142, 1912, 47, - /* 1110 */ 45, 44, 43, 42, 1725, 737, 2098, 803, 1725, 2355, - /* 1120 */ 1754, 1755, 2393, 35, 2374, 114, 2357, 757, 2359, 2360, - /* 1130 */ 752, 87, 747, 1788, 541, 284, 2322, 2547, 753, 2446, - /* 1140 */ 711, 1725, 2355, 415, 2442, 2393, 1981, 99, 114, 2357, - /* 1150 */ 757, 2359, 2360, 752, 2195, 747, 1911, 1727, 1737, 1676, - /* 1160 */ 2547, 2322, 2446, 1675, 1753, 1756, 415, 2442, 630, 737, - /* 1170 */ 2098, 737, 2098, 788, 737, 2098, 2142, 2355, 1614, 1668, - /* 1180 */ 2393, 1666, 805, 114, 2357, 757, 2359, 2360, 752, 322, - /* 1190 */ 747, 722, 720, 36, 316, 2547, 482, 2446, 139, 41, - /* 1200 */ 40, 415, 2442, 47, 45, 44, 43, 42, 2102, 2322, - /* 1210 */ 86, 1671, 1672, 1724, 281, 1726, 1729, 1730, 1731, 1732, - /* 1220 */ 1733, 1734, 1735, 1736, 749, 745, 1745, 1746, 1748, 1749, - /* 1230 */ 1750, 1751, 2, 48, 46, 391, 390, 737, 2098, 2461, - /* 1240 */ 2076, 419, 675, 1667, 159, 2527, 737, 2098, 817, 815, - /* 1250 */ 737, 2098, 789, 2466, 1815, 2142, 1752, 734, 1665, 513, - /* 1260 */ 512, 170, 1725, 2533, 203, 2456, 735, 159, 2528, 705, - /* 1270 */ 426, 335, 261, 152, 2128, 259, 2356, 263, 265, 617, - /* 1280 */ 262, 264, 267, 1979, 1970, 266, 1747, 618, 682, 754, - /* 1290 */ 1968, 2520, 651, 285, 650, 2343, 50, 50, 1921, 1673, - /* 1300 */ 1903, 1904, 748, 1400, 1358, 632, 634, 389, 388, 187, - /* 1310 */ 612, 1398, 637, 14, 13, 2038, 2490, 2374, 172, 1630, - /* 1320 */ 298, 159, 50, 341, 310, 848, 1679, 797, 15, 2322, - /* 1330 */ 1678, 753, 614, 692, 2356, 75, 613, 100, 292, 157, - /* 1340 */ 339, 74, 1633, 159, 73, 1359, 66, 754, 141, 2465, - /* 1350 */ 111, 1377, 50, 2345, 368, 50, 2375, 761, 157, 108, - /* 1360 */ 709, 798, 2035, 1846, 1754, 1755, 236, 549, 547, 544, - /* 1370 */ 2355, 1856, 1855, 2393, 159, 2374, 114, 2357, 757, 2359, - /* 1380 */ 2360, 752, 2034, 747, 290, 1375, 2221, 2322, 2547, 753, - /* 1390 */ 2446, 1962, 1952, 2480, 415, 2442, 721, 1583, 689, 314, - /* 1400 */ 405, 1727, 1737, 140, 157, 712, 696, 63, 1753, 1756, - /* 1410 */ 729, 401, 432, 2222, 318, 1958, 2139, 2481, 1445, 726, - /* 1420 */ 2491, 1789, 668, 1668, 717, 1666, 300, 1738, 2355, 297, - /* 1430 */ 334, 2393, 1473, 1477, 114, 2357, 757, 2359, 2360, 752, - /* 1440 */ 2060, 747, 304, 841, 5, 64, 2547, 435, 2446, 1484, - /* 1450 */ 440, 381, 415, 2442, 448, 1671, 1672, 1724, 449, 1726, - /* 1460 */ 1729, 1730, 1731, 1732, 1733, 1734, 1735, 1736, 749, 745, - /* 1470 */ 1745, 1746, 1748, 1749, 1750, 1751, 2, 1700, 1482, 162, - /* 1480 */ 460, 428, 427, 211, 2356, 459, 212, 462, 214, 329, - /* 1490 */ 1690, 1681, 1607, 476, 84, 83, 471, 754, 1691, 216, - /* 1500 */ 483, 225, 485, 489, 1752, 491, 1674, 2356, 530, 496, - /* 1510 */ 508, 2214, 463, 461, 519, 521, 526, 543, 529, 531, - /* 1520 */ 754, 542, 540, 364, 231, 2374, 450, 230, 545, 447, - /* 1530 */ 443, 439, 436, 464, 1747, 1698, 1906, 2322, 546, 753, - /* 1540 */ 233, 548, 2356, 550, 4, 565, 566, 1673, 2374, 573, - /* 1550 */ 574, 576, 1693, 241, 92, 754, 244, 578, 1699, 1701, - /* 1560 */ 2322, 579, 753, 580, 247, 582, 1702, 249, 588, 93, - /* 1570 */ 94, 609, 305, 743, 2230, 254, 640, 611, 2355, 2088, - /* 1580 */ 116, 2393, 641, 2374, 114, 2357, 757, 2359, 2360, 752, - /* 1590 */ 361, 747, 97, 258, 2084, 2322, 2419, 753, 2446, 260, - /* 1600 */ 164, 2355, 415, 2442, 2393, 165, 653, 114, 2357, 757, - /* 1610 */ 2359, 2360, 752, 2086, 747, 434, 2293, 2082, 166, 740, - /* 1620 */ 433, 2446, 167, 2290, 2289, 415, 2442, 277, 1694, 663, - /* 1630 */ 662, 282, 693, 667, 669, 670, 2355, 679, 727, 2393, - /* 1640 */ 664, 2356, 115, 2357, 757, 2359, 2360, 752, 8, 747, - /* 1650 */ 330, 153, 655, 280, 754, 2496, 2446, 287, 289, 702, - /* 1660 */ 2445, 2442, 2495, 677, 2468, 675, 291, 2276, 2527, 680, - /* 1670 */ 293, 1682, 2356, 1677, 678, 296, 713, 406, 710, 1815, - /* 1680 */ 1695, 2526, 2374, 145, 1820, 754, 2533, 203, 2462, 190, - /* 1690 */ 1818, 2528, 705, 306, 2322, 331, 753, 332, 730, 2356, - /* 1700 */ 154, 725, 294, 1685, 1687, 2244, 2243, 731, 2242, 155, - /* 1710 */ 411, 178, 754, 2374, 333, 105, 62, 745, 1745, 1746, - /* 1720 */ 1748, 1749, 1750, 1751, 295, 2322, 2099, 753, 1, 206, - /* 1730 */ 2427, 107, 759, 299, 336, 2355, 324, 2143, 2393, 1280, - /* 1740 */ 2374, 115, 2357, 757, 2359, 2360, 752, 842, 747, 2550, - /* 1750 */ 845, 847, 2322, 163, 753, 2446, 345, 2356, 360, 742, - /* 1760 */ 2442, 373, 53, 374, 359, 340, 755, 349, 2314, 2393, - /* 1770 */ 754, 338, 115, 2357, 757, 2359, 2360, 752, 2313, 747, - /* 1780 */ 2312, 81, 2307, 437, 438, 1658, 2446, 1659, 209, 442, - /* 1790 */ 376, 2442, 2356, 2355, 2305, 444, 2393, 445, 2374, 175, - /* 1800 */ 2357, 757, 2359, 2360, 752, 754, 747, 446, 1657, 2304, - /* 1810 */ 2322, 382, 753, 2302, 451, 2301, 453, 2300, 455, 2299, - /* 1820 */ 457, 1646, 2356, 213, 2279, 215, 1610, 82, 1609, 2257, - /* 1830 */ 2256, 2255, 469, 2374, 2280, 754, 470, 2254, 2253, 2204, - /* 1840 */ 474, 676, 2487, 2201, 1553, 2322, 2200, 753, 477, 2194, - /* 1850 */ 481, 2355, 2191, 480, 2393, 218, 2190, 115, 2357, 757, - /* 1860 */ 2359, 2360, 752, 2374, 747, 85, 2189, 2188, 403, 2193, - /* 1870 */ 220, 2446, 2192, 2187, 2186, 2322, 2443, 753, 2184, 2183, - /* 1880 */ 2182, 222, 497, 2181, 499, 2179, 2355, 2356, 2178, 2393, - /* 1890 */ 2177, 2176, 175, 2357, 757, 2359, 2360, 752, 91, 747, - /* 1900 */ 754, 2199, 2356, 2175, 2174, 2173, 2197, 2180, 2172, 2171, - /* 1910 */ 2170, 2168, 2167, 2166, 2165, 754, 2355, 2356, 1559, 2393, - /* 1920 */ 2164, 2163, 358, 2357, 757, 2359, 2360, 752, 2374, 747, - /* 1930 */ 754, 224, 2162, 404, 229, 2488, 2161, 2160, 2159, 2198, - /* 1940 */ 2322, 2196, 753, 2374, 2158, 2157, 2156, 2155, 533, 2154, - /* 1950 */ 535, 2153, 2152, 1416, 2000, 2322, 1412, 753, 2374, 232, - /* 1960 */ 1999, 1998, 1420, 1996, 234, 370, 371, 235, 1993, 553, - /* 1970 */ 2322, 1992, 753, 552, 556, 557, 1985, 560, 1972, 551, - /* 1980 */ 555, 2355, 1947, 185, 2393, 559, 1304, 358, 2357, 757, - /* 1990 */ 2359, 2360, 752, 563, 747, 561, 2355, 2356, 1946, 2393, - /* 2000 */ 237, 78, 351, 2357, 757, 2359, 2360, 752, 239, 747, - /* 2010 */ 754, 2355, 79, 2342, 2393, 2356, 195, 176, 2357, 757, - /* 2020 */ 2359, 2360, 752, 571, 747, 2278, 2274, 2264, 751, 246, - /* 2030 */ 2251, 2228, 248, 251, 2077, 1995, 1991, 589, 2374, 2252, - /* 2040 */ 2356, 1351, 1989, 410, 590, 591, 593, 594, 701, 595, - /* 2050 */ 2322, 1987, 753, 754, 597, 598, 2374, 599, 1984, 601, - /* 2060 */ 603, 602, 1967, 1965, 1966, 1964, 1943, 2079, 2322, 1489, - /* 2070 */ 753, 2078, 2549, 65, 1488, 257, 1388, 1402, 1401, 1982, - /* 2080 */ 1399, 2374, 1397, 1396, 1395, 1394, 418, 1393, 814, 816, - /* 2090 */ 1390, 2355, 394, 2322, 2393, 753, 1389, 358, 2357, 757, - /* 2100 */ 2359, 2360, 752, 1980, 747, 1387, 395, 1971, 396, 2355, - /* 2110 */ 2356, 1969, 2393, 635, 657, 357, 2357, 757, 2359, 2360, - /* 2120 */ 752, 397, 747, 754, 2412, 638, 1942, 1941, 1940, 642, - /* 2130 */ 1939, 644, 851, 1938, 2355, 117, 646, 2393, 1640, 1642, - /* 2140 */ 358, 2357, 757, 2359, 2360, 752, 2356, 747, 328, 1639, - /* 2150 */ 2277, 2374, 1644, 279, 2273, 57, 420, 58, 1616, 754, - /* 2160 */ 1618, 2263, 665, 2322, 193, 753, 1620, 666, 29, 2250, - /* 2170 */ 2249, 169, 1595, 839, 835, 831, 827, 2356, 325, 69, - /* 2180 */ 283, 671, 2532, 1594, 20, 31, 673, 2374, 1873, 286, - /* 2190 */ 754, 1847, 681, 402, 17, 6, 683, 7, 685, 2322, - /* 2200 */ 687, 753, 200, 288, 2355, 21, 22, 2393, 1854, 189, - /* 2210 */ 358, 2357, 757, 2359, 2360, 752, 177, 747, 2374, 113, - /* 2220 */ 2343, 33, 319, 188, 32, 67, 1841, 80, 24, 1888, - /* 2230 */ 2322, 1893, 753, 1894, 1887, 407, 1892, 1891, 408, 1812, - /* 2240 */ 652, 60, 1811, 2393, 2248, 302, 353, 2357, 757, 2359, - /* 2250 */ 2360, 752, 2356, 747, 733, 180, 23, 18, 59, 2227, - /* 2260 */ 102, 728, 2226, 103, 101, 754, 25, 26, 108, 317, - /* 2270 */ 309, 2355, 2356, 1849, 2393, 191, 320, 343, 2357, 757, - /* 2280 */ 2359, 2360, 752, 1764, 747, 754, 1763, 315, 2356, 70, - /* 2290 */ 104, 1683, 13, 2374, 11, 1742, 2396, 308, 746, 181, - /* 2300 */ 39, 754, 1740, 1774, 307, 2322, 192, 753, 1717, 323, - /* 2310 */ 1739, 16, 27, 2374, 756, 1709, 28, 760, 1474, 421, - /* 2320 */ 758, 762, 764, 278, 1471, 2322, 765, 753, 1470, 2374, - /* 2330 */ 767, 768, 770, 1467, 1461, 771, 773, 774, 776, 1459, - /* 2340 */ 777, 2322, 1483, 753, 109, 2356, 2355, 110, 77, 2393, - /* 2350 */ 1479, 1465, 342, 2357, 757, 2359, 2360, 752, 754, 747, - /* 2360 */ 1464, 1384, 791, 1463, 1462, 2356, 2355, 1381, 1349, 2393, - /* 2370 */ 1380, 1379, 344, 2357, 757, 2359, 2360, 752, 754, 747, - /* 2380 */ 1378, 1376, 2355, 2356, 1374, 2393, 2374, 1373, 350, 2357, - /* 2390 */ 757, 2359, 2360, 752, 1372, 747, 754, 1410, 2322, 802, - /* 2400 */ 753, 1409, 207, 2356, 804, 1370, 2374, 1369, 1368, 1367, - /* 2410 */ 1366, 1365, 1364, 1406, 1404, 1361, 754, 1360, 2322, 1357, - /* 2420 */ 753, 1355, 1356, 1354, 2374, 1990, 824, 825, 1988, 828, - /* 2430 */ 826, 1986, 829, 830, 832, 834, 2322, 1983, 753, 2355, - /* 2440 */ 836, 2356, 2393, 838, 2374, 354, 2357, 757, 2359, 2360, - /* 2450 */ 752, 833, 747, 837, 754, 1963, 2322, 840, 753, 2355, - /* 2460 */ 1293, 1937, 2393, 1281, 846, 346, 2357, 757, 2359, 2360, - /* 2470 */ 752, 844, 747, 327, 1669, 337, 850, 2355, 2356, 849, - /* 2480 */ 2393, 1907, 2374, 355, 2357, 757, 2359, 2360, 752, 1907, - /* 2490 */ 747, 754, 1907, 1907, 2322, 1907, 753, 2355, 2356, 1907, - /* 2500 */ 2393, 1907, 1907, 347, 2357, 757, 2359, 2360, 752, 1907, - /* 2510 */ 747, 754, 1907, 1907, 2356, 1907, 1907, 1907, 1907, 2374, - /* 2520 */ 1907, 1907, 1907, 1907, 1907, 1907, 1907, 754, 1907, 1907, - /* 2530 */ 1907, 2322, 1907, 753, 1907, 2355, 1907, 1907, 2393, 2374, - /* 2540 */ 1907, 356, 2357, 757, 2359, 2360, 752, 1907, 747, 1907, - /* 2550 */ 1907, 2322, 1907, 753, 1907, 2374, 1907, 1907, 1907, 1907, - /* 2560 */ 1907, 1907, 1907, 1907, 1907, 1907, 1907, 2322, 1907, 753, - /* 2570 */ 1907, 1907, 2355, 1907, 1907, 2393, 1907, 1907, 348, 2357, - /* 2580 */ 757, 2359, 2360, 752, 1907, 747, 1907, 1907, 1907, 1907, - /* 2590 */ 1907, 1907, 2355, 1907, 1907, 2393, 1907, 1907, 362, 2357, - /* 2600 */ 757, 2359, 2360, 752, 1907, 747, 1907, 2356, 2355, 1907, - /* 2610 */ 1907, 2393, 1907, 1907, 363, 2357, 757, 2359, 2360, 752, - /* 2620 */ 754, 747, 1907, 1907, 1907, 1907, 2356, 1907, 1907, 1907, - /* 2630 */ 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, 754, - /* 2640 */ 1907, 1907, 1907, 2356, 1907, 1907, 1907, 1907, 2374, 1907, - /* 2650 */ 1907, 1907, 1907, 1907, 1907, 1907, 754, 1907, 1907, 1907, - /* 2660 */ 2322, 1907, 753, 1907, 1907, 1907, 1907, 2374, 1907, 1907, - /* 2670 */ 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, 2322, - /* 2680 */ 1907, 753, 1907, 1907, 2374, 1907, 1907, 1907, 1907, 1907, - /* 2690 */ 1907, 1907, 1907, 1907, 1907, 1907, 2322, 1907, 753, 1907, - /* 2700 */ 2356, 2355, 1907, 1907, 2393, 1907, 1907, 2368, 2357, 757, - /* 2710 */ 2359, 2360, 752, 754, 747, 1907, 1907, 1907, 1907, 1907, - /* 2720 */ 2355, 2356, 1907, 2393, 1907, 1907, 2367, 2357, 757, 2359, - /* 2730 */ 2360, 752, 1907, 747, 754, 1907, 1907, 2355, 2356, 1907, - /* 2740 */ 2393, 2374, 1907, 2366, 2357, 757, 2359, 2360, 752, 1907, - /* 2750 */ 747, 754, 1907, 2322, 1907, 753, 1907, 1907, 2356, 1907, - /* 2760 */ 1907, 1907, 2374, 1907, 1907, 1907, 1907, 1907, 1907, 1907, - /* 2770 */ 1907, 754, 1907, 1907, 2322, 1907, 753, 1907, 1907, 2374, - /* 2780 */ 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, - /* 2790 */ 1907, 2322, 1907, 753, 2355, 1907, 2356, 2393, 1907, 2374, - /* 2800 */ 378, 2357, 757, 2359, 2360, 752, 1907, 747, 1907, 754, - /* 2810 */ 1907, 2322, 1907, 753, 1907, 2355, 1907, 1907, 2393, 1907, - /* 2820 */ 1907, 379, 2357, 757, 2359, 2360, 752, 1907, 747, 1907, - /* 2830 */ 1907, 1907, 2355, 2356, 1907, 2393, 1907, 2374, 375, 2357, - /* 2840 */ 757, 2359, 2360, 752, 1907, 747, 754, 1907, 1907, 2322, - /* 2850 */ 1907, 753, 2355, 1907, 1907, 2393, 1907, 1907, 380, 2357, - /* 2860 */ 757, 2359, 2360, 752, 1907, 747, 1907, 1907, 1907, 1907, - /* 2870 */ 1907, 1907, 1907, 1907, 2374, 1907, 1907, 1907, 1907, 1907, - /* 2880 */ 1907, 1907, 1907, 1907, 1907, 1907, 2322, 1907, 753, 1907, - /* 2890 */ 755, 1907, 1907, 2393, 1907, 1907, 353, 2357, 757, 2359, - /* 2900 */ 2360, 752, 1907, 747, 1907, 1907, 1907, 1907, 1907, 1907, - /* 2910 */ 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, - /* 2920 */ 1907, 1907, 1907, 1907, 1907, 1907, 1907, 2355, 1907, 1907, - /* 2930 */ 2393, 1907, 1907, 352, 2357, 757, 2359, 2360, 752, 1907, - /* 2940 */ 747, + /* 0 */ 2197, 2197, 573, 428, 474, 574, 1997, 404, 414, 473, + /* 10 */ 2197, 169, 47, 45, 1872, 2195, 2195, 33, 405, 2146, + /* 20 */ 419, 1737, 1712, 40, 39, 729, 2195, 46, 44, 43, + /* 30 */ 42, 41, 1738, 2282, 35, 1798, 2040, 1710, 2215, 759, + /* 40 */ 40, 39, 653, 2422, 46, 44, 43, 42, 41, 481, + /* 50 */ 1328, 2280, 747, 722, 147, 681, 725, 651, 2594, 649, + /* 60 */ 271, 270, 40, 39, 759, 1793, 46, 44, 43, 42, + /* 70 */ 41, 19, 1692, 1737, 1326, 1327, 2600, 204, 1718, 760, + /* 80 */ 2144, 2595, 711, 664, 2440, 40, 39, 29, 2528, 46, + /* 90 */ 44, 43, 42, 41, 540, 538, 2388, 370, 742, 138, + /* 100 */ 1977, 218, 37, 310, 855, 2381, 616, 15, 426, 830, + /* 110 */ 829, 828, 827, 437, 2525, 826, 825, 152, 820, 819, + /* 120 */ 818, 817, 816, 815, 814, 151, 808, 807, 806, 436, + /* 130 */ 435, 803, 802, 801, 184, 183, 800, 593, 2421, 2135, + /* 140 */ 175, 2459, 1966, 1800, 1801, 115, 2423, 746, 2425, 2426, + /* 150 */ 741, 50, 764, 2388, 1740, 1611, 1612, 187, 2282, 2513, + /* 160 */ 425, 66, 1917, 415, 2509, 302, 2521, 721, 2197, 139, + /* 170 */ 720, 764, 2594, 422, 2352, 424, 2279, 747, 206, 62, + /* 180 */ 1772, 1782, 1955, 2195, 759, 1916, 2543, 1799, 1802, 581, + /* 190 */ 709, 204, 574, 1997, 425, 2595, 711, 519, 518, 1610, + /* 200 */ 1613, 1485, 1713, 128, 1711, 764, 127, 126, 125, 124, + /* 210 */ 123, 122, 121, 120, 119, 1476, 789, 788, 787, 1480, + /* 220 */ 786, 1482, 1483, 785, 782, 447, 1491, 779, 1493, 1494, + /* 230 */ 776, 773, 770, 1591, 1592, 2349, 1716, 1717, 1769, 1695, + /* 240 */ 1771, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 738, + /* 250 */ 762, 761, 1792, 1794, 1795, 1796, 1797, 2, 47, 45, + /* 260 */ 96, 578, 589, 368, 62, 1735, 419, 575, 1712, 1698, + /* 270 */ 1701, 50, 524, 710, 2422, 543, 2594, 392, 1321, 2122, + /* 280 */ 542, 1798, 1976, 1710, 40, 39, 2139, 740, 46, 44, + /* 290 */ 43, 42, 41, 2528, 709, 204, 504, 1328, 544, 2595, + /* 300 */ 711, 40, 39, 369, 506, 46, 44, 43, 42, 41, + /* 310 */ 62, 1793, 153, 1741, 484, 2440, 304, 19, 306, 2524, + /* 320 */ 1323, 1326, 1327, 107, 1718, 760, 2144, 2388, 430, 742, + /* 330 */ 799, 2190, 2192, 128, 1738, 2388, 127, 126, 125, 124, + /* 340 */ 123, 122, 121, 120, 119, 138, 306, 380, 2137, 2398, + /* 350 */ 855, 391, 621, 15, 46, 44, 43, 42, 41, 40, + /* 360 */ 39, 2528, 492, 46, 44, 43, 42, 41, 1876, 2421, + /* 370 */ 185, 2599, 2459, 2402, 1737, 534, 360, 2423, 746, 2425, + /* 380 */ 2426, 741, 739, 764, 730, 2478, 1737, 2523, 1740, 1800, + /* 390 */ 1801, 1827, 2269, 2248, 2263, 531, 530, 529, 528, 523, + /* 400 */ 522, 521, 520, 374, 472, 51, 471, 510, 509, 508, + /* 410 */ 507, 501, 500, 499, 1954, 494, 493, 389, 2404, 2406, + /* 420 */ 416, 485, 1579, 1580, 12, 185, 1772, 1782, 1598, 764, + /* 430 */ 173, 306, 1952, 1799, 1802, 344, 470, 229, 137, 136, + /* 440 */ 135, 134, 133, 132, 131, 130, 129, 390, 1713, 2262, + /* 450 */ 1711, 705, 342, 75, 1808, 1828, 74, 1520, 1521, 1888, + /* 460 */ 1737, 533, 228, 211, 40, 39, 371, 810, 46, 44, + /* 470 */ 43, 42, 41, 62, 662, 200, 1940, 306, 237, 555, + /* 480 */ 553, 550, 1716, 1717, 1769, 329, 1771, 1774, 1775, 1776, + /* 490 */ 1777, 1778, 1779, 1780, 1781, 738, 762, 761, 1792, 1794, + /* 500 */ 1795, 1796, 1797, 2, 12, 47, 45, 2382, 43, 42, + /* 510 */ 41, 2398, 440, 419, 2197, 1712, 1347, 439, 1346, 62, + /* 520 */ 239, 388, 314, 315, 576, 1718, 2005, 313, 1798, 2195, + /* 530 */ 1710, 1742, 812, 143, 1773, 2402, 700, 36, 417, 1822, + /* 540 */ 1823, 1824, 1825, 1826, 1830, 1831, 1832, 1833, 40, 39, + /* 550 */ 304, 1348, 46, 44, 43, 42, 41, 63, 1793, 760, + /* 560 */ 2144, 2422, 425, 681, 19, 12, 2594, 10, 434, 433, + /* 570 */ 174, 1718, 306, 764, 743, 2361, 722, 147, 2083, 209, + /* 580 */ 2404, 2407, 396, 395, 2600, 204, 570, 9, 1691, 2595, + /* 590 */ 711, 764, 1770, 1719, 731, 568, 2485, 855, 564, 560, + /* 600 */ 15, 710, 2440, 2598, 2594, 2422, 85, 84, 477, 1975, + /* 610 */ 2133, 217, 490, 2258, 2388, 241, 742, 2027, 743, 576, + /* 620 */ 1773, 2005, 709, 204, 469, 467, 681, 2595, 711, 2594, + /* 630 */ 706, 701, 694, 690, 1440, 367, 1800, 1801, 456, 636, + /* 640 */ 306, 453, 449, 445, 442, 470, 2440, 2600, 204, 1439, + /* 650 */ 1947, 1741, 2595, 711, 394, 393, 2421, 618, 2388, 2459, + /* 660 */ 742, 220, 2388, 176, 2423, 746, 2425, 2426, 741, 1769, + /* 670 */ 764, 790, 2599, 1772, 1782, 2594, 760, 2144, 1770, 620, + /* 680 */ 1799, 1802, 714, 619, 760, 2144, 306, 724, 202, 2521, + /* 690 */ 2522, 1428, 145, 2526, 2598, 1713, 55, 1711, 2595, 2597, + /* 700 */ 2421, 14, 13, 2459, 478, 682, 2554, 115, 2423, 746, + /* 710 */ 2425, 2426, 741, 1741, 764, 2362, 545, 149, 286, 156, + /* 720 */ 2484, 2513, 171, 496, 2258, 415, 2509, 1905, 704, 1716, + /* 730 */ 1717, 1769, 1430, 1771, 1774, 1775, 1776, 1777, 1778, 1779, + /* 740 */ 1780, 1781, 738, 762, 761, 1792, 1794, 1795, 1796, 1797, + /* 750 */ 2, 47, 45, 1803, 2422, 1694, 2440, 1946, 96, 419, + /* 760 */ 1722, 1712, 101, 197, 722, 147, 681, 725, 680, 2594, + /* 770 */ 760, 2144, 222, 257, 1798, 2184, 1710, 697, 696, 1903, + /* 780 */ 1904, 1906, 1907, 1908, 2140, 1697, 1700, 2600, 204, 180, + /* 790 */ 479, 813, 2595, 711, 2105, 2440, 2121, 1444, 610, 606, + /* 800 */ 602, 598, 2599, 256, 1793, 2594, 2129, 2388, 1841, 742, + /* 810 */ 760, 2144, 1443, 195, 635, 634, 633, 1718, 1861, 703, + /* 820 */ 1829, 625, 144, 629, 2598, 760, 2144, 628, 2595, 2596, + /* 830 */ 498, 2131, 627, 632, 398, 397, 1974, 1347, 626, 1346, + /* 840 */ 642, 622, 1741, 855, 97, 511, 48, 254, 2231, 2421, + /* 850 */ 2127, 2422, 2459, 760, 2144, 654, 115, 2423, 746, 2425, + /* 860 */ 2426, 741, 148, 764, 743, 2484, 2007, 1869, 187, 1742, + /* 870 */ 2513, 272, 1348, 512, 415, 2509, 203, 2521, 2522, 547, + /* 880 */ 145, 2526, 1800, 1801, 1712, 760, 2144, 645, 2119, 2388, + /* 890 */ 526, 2258, 2440, 665, 639, 637, 713, 2544, 665, 1710, + /* 900 */ 60, 269, 34, 620, 2388, 513, 742, 619, 678, 1973, + /* 910 */ 40, 39, 1834, 244, 46, 44, 43, 42, 41, 1772, + /* 920 */ 1782, 100, 253, 246, 275, 791, 1799, 1802, 2188, 251, + /* 930 */ 587, 1742, 797, 162, 161, 794, 793, 792, 159, 227, + /* 940 */ 1718, 1713, 71, 1711, 590, 70, 2421, 715, 243, 2459, + /* 950 */ 760, 2144, 1639, 115, 2423, 746, 2425, 2426, 741, 733, + /* 960 */ 764, 2485, 2388, 1897, 660, 2614, 855, 2513, 583, 2321, + /* 970 */ 592, 415, 2509, 667, 2321, 1716, 1717, 1769, 1898, 1771, + /* 980 */ 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 738, 762, + /* 990 */ 761, 1792, 1794, 1795, 1796, 1797, 2, 47, 45, 2422, + /* 1000 */ 591, 2275, 1660, 1661, 199, 419, 2148, 1712, 666, 517, + /* 1010 */ 722, 147, 743, 516, 2551, 681, 1972, 1971, 2594, 1896, + /* 1020 */ 1798, 515, 1710, 423, 797, 162, 161, 794, 793, 792, + /* 1030 */ 159, 172, 1737, 2191, 2192, 1970, 2600, 204, 2422, 2146, + /* 1040 */ 2440, 2595, 711, 797, 162, 161, 794, 793, 792, 159, + /* 1050 */ 1793, 743, 2388, 2564, 742, 760, 2144, 428, 458, 681, + /* 1060 */ 1742, 1969, 2594, 1718, 1713, 172, 1711, 760, 2144, 2388, + /* 1070 */ 2388, 1350, 1351, 2146, 431, 2141, 612, 611, 2120, 2440, + /* 1080 */ 2600, 204, 172, 1737, 726, 2595, 711, 277, 2388, 855, + /* 1090 */ 2146, 2388, 48, 742, 2421, 282, 2422, 2459, 1716, 1717, + /* 1100 */ 1968, 115, 2423, 746, 2425, 2426, 741, 1965, 764, 743, + /* 1110 */ 2197, 692, 77, 2614, 2388, 2513, 717, 429, 737, 415, + /* 1120 */ 2509, 1964, 205, 2521, 2522, 2195, 145, 2526, 1800, 1801, + /* 1130 */ 760, 2144, 2557, 2421, 3, 681, 2459, 2440, 2594, 1868, + /* 1140 */ 115, 2423, 746, 2425, 2426, 741, 53, 764, 799, 2388, + /* 1150 */ 285, 742, 2614, 2388, 2513, 1963, 2600, 204, 415, 2509, + /* 1160 */ 2388, 2595, 711, 224, 88, 1772, 1782, 1962, 760, 2144, + /* 1170 */ 760, 2144, 1799, 1802, 2388, 198, 760, 2144, 2197, 274, + /* 1180 */ 631, 630, 2197, 273, 1982, 850, 462, 1713, 728, 1711, + /* 1190 */ 318, 2421, 1773, 755, 2459, 736, 757, 2196, 115, 2423, + /* 1200 */ 746, 2425, 2426, 741, 91, 764, 1961, 90, 2388, 1330, + /* 1210 */ 2614, 1967, 2513, 464, 460, 1736, 415, 2509, 614, 613, + /* 1220 */ 2388, 1716, 1717, 1769, 2330, 1771, 1774, 1775, 1776, 1777, + /* 1230 */ 1778, 1779, 1780, 1781, 738, 762, 761, 1792, 1794, 1795, + /* 1240 */ 1796, 1797, 2, 47, 45, 760, 2144, 760, 2144, 2422, + /* 1250 */ 1770, 419, 99, 1712, 1960, 377, 160, 1959, 403, 2388, + /* 1260 */ 655, 113, 743, 2241, 2587, 758, 1798, 325, 1710, 1958, + /* 1270 */ 1957, 824, 822, 89, 760, 2144, 1721, 172, 150, 276, + /* 1280 */ 795, 2533, 1861, 2188, 2422, 2147, 2136, 160, 796, 338, + /* 1290 */ 2440, 2188, 2174, 160, 432, 262, 1793, 743, 260, 2532, + /* 1300 */ 623, 1770, 2388, 140, 742, 488, 624, 2388, 264, 1718, + /* 1310 */ 2388, 263, 2025, 266, 268, 87, 265, 267, 2016, 2014, + /* 1320 */ 1949, 1950, 2388, 2388, 1425, 2440, 657, 688, 656, 1720, + /* 1330 */ 1423, 54, 49, 2084, 638, 855, 698, 2388, 15, 742, + /* 1340 */ 640, 643, 49, 804, 2421, 2409, 188, 2459, 160, 14, + /* 1350 */ 13, 115, 2423, 746, 2425, 2426, 741, 64, 764, 49, + /* 1360 */ 1819, 2008, 1655, 2614, 49, 2513, 312, 1402, 1658, 415, + /* 1370 */ 2509, 434, 433, 805, 1800, 1801, 76, 324, 323, 2421, + /* 1380 */ 158, 1726, 2459, 718, 160, 73, 115, 2423, 746, 2425, + /* 1390 */ 2426, 741, 112, 764, 1798, 2422, 1719, 1400, 2614, 299, + /* 1400 */ 2513, 109, 1892, 2411, 415, 2509, 1383, 1902, 743, 142, + /* 1410 */ 2441, 1772, 1782, 848, 768, 293, 158, 1901, 1799, 1802, + /* 1420 */ 160, 291, 2267, 727, 1793, 2081, 1998, 2080, 141, 2547, + /* 1430 */ 158, 695, 1835, 1713, 1783, 1711, 2440, 1718, 410, 1608, + /* 1440 */ 702, 316, 406, 1724, 749, 438, 2268, 1384, 2388, 2004, + /* 1450 */ 742, 752, 2185, 2422, 674, 320, 2548, 2558, 723, 1470, + /* 1460 */ 337, 301, 298, 735, 305, 5, 743, 1716, 1717, 1769, + /* 1470 */ 441, 1771, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, + /* 1480 */ 738, 762, 761, 1792, 1794, 1795, 1796, 1797, 2, 1498, + /* 1490 */ 2421, 1502, 2106, 2459, 2440, 1509, 1723, 115, 2423, 746, + /* 1500 */ 2425, 2426, 741, 1507, 764, 163, 2388, 2043, 742, 2488, + /* 1510 */ 446, 2513, 373, 372, 386, 415, 2509, 454, 455, 1745, + /* 1520 */ 466, 465, 1702, 2422, 212, 213, 468, 215, 1632, 332, + /* 1530 */ 1735, 482, 1736, 489, 226, 1798, 743, 1690, 491, 495, + /* 1540 */ 497, 536, 502, 514, 527, 525, 2260, 532, 2421, 535, + /* 1550 */ 537, 2459, 548, 549, 546, 115, 2423, 746, 2425, 2426, + /* 1560 */ 741, 1727, 764, 1722, 2440, 1793, 231, 2486, 232, 2513, + /* 1570 */ 551, 552, 1743, 415, 2509, 234, 2388, 554, 742, 556, + /* 1580 */ 635, 634, 633, 571, 4, 572, 579, 625, 144, 629, + /* 1590 */ 582, 580, 2422, 628, 242, 1730, 1732, 1738, 627, 632, + /* 1600 */ 398, 397, 584, 1744, 626, 743, 93, 622, 585, 762, + /* 1610 */ 761, 1792, 1794, 1795, 1796, 1797, 586, 245, 2421, 1746, + /* 1620 */ 248, 2459, 588, 2422, 250, 115, 2423, 746, 2425, 2426, + /* 1630 */ 741, 1747, 764, 2440, 94, 2276, 743, 732, 95, 2513, + /* 1640 */ 594, 255, 615, 415, 2509, 2388, 617, 742, 2134, 646, + /* 1650 */ 259, 117, 2130, 261, 647, 165, 166, 2339, 364, 2132, + /* 1660 */ 659, 661, 2128, 167, 2440, 168, 98, 1739, 154, 333, + /* 1670 */ 669, 2322, 670, 278, 668, 281, 2388, 283, 742, 675, + /* 1680 */ 2336, 699, 2335, 750, 676, 673, 685, 2421, 2563, 2562, + /* 1690 */ 2459, 8, 2422, 292, 116, 2423, 746, 2425, 2426, 741, + /* 1700 */ 2535, 764, 1703, 288, 1693, 743, 290, 708, 2513, 179, + /* 1710 */ 686, 684, 2512, 2509, 683, 411, 297, 719, 2421, 716, + /* 1720 */ 2617, 2459, 294, 300, 296, 116, 2423, 746, 2425, 2426, + /* 1730 */ 741, 1861, 764, 2440, 1696, 1699, 1704, 295, 1740, 2513, + /* 1740 */ 146, 2529, 2593, 734, 2509, 2388, 1866, 742, 1864, 191, + /* 1750 */ 762, 761, 1792, 1794, 1795, 1796, 1797, 307, 61, 1, + /* 1760 */ 155, 2422, 334, 207, 2494, 748, 2290, 2289, 335, 753, + /* 1770 */ 336, 2145, 2288, 421, 743, 157, 2422, 754, 106, 2380, + /* 1780 */ 108, 2379, 2189, 327, 339, 766, 1305, 744, 852, 743, + /* 1790 */ 2459, 849, 52, 164, 116, 2423, 746, 2425, 2426, 741, + /* 1800 */ 351, 764, 2440, 854, 384, 2422, 385, 343, 2513, 341, + /* 1810 */ 362, 2360, 379, 2509, 2388, 352, 742, 2440, 743, 2359, + /* 1820 */ 363, 2358, 82, 2353, 443, 444, 1683, 1684, 210, 2388, + /* 1830 */ 448, 742, 2351, 450, 451, 2422, 452, 1682, 2350, 387, + /* 1840 */ 2348, 457, 2347, 2346, 459, 2345, 2440, 461, 743, 463, + /* 1850 */ 1671, 2326, 214, 2325, 216, 1634, 2421, 83, 2388, 2459, + /* 1860 */ 742, 1635, 2303, 177, 2423, 746, 2425, 2426, 741, 2302, + /* 1870 */ 764, 2421, 2301, 475, 2459, 476, 2440, 2300, 116, 2423, + /* 1880 */ 746, 2425, 2426, 741, 2299, 764, 2250, 2247, 2388, 483, + /* 1890 */ 742, 2246, 2513, 2422, 2240, 480, 1578, 2510, 486, 487, + /* 1900 */ 2421, 2237, 2236, 2459, 219, 86, 743, 176, 2423, 746, + /* 1910 */ 2425, 2426, 741, 2235, 764, 2234, 2239, 712, 2615, 2422, + /* 1920 */ 221, 2238, 2233, 2232, 2230, 2229, 2228, 223, 2227, 503, + /* 1930 */ 2421, 505, 743, 2459, 2440, 2225, 2224, 354, 2423, 746, + /* 1940 */ 2425, 2426, 741, 2223, 764, 2222, 2388, 2245, 742, 2221, + /* 1950 */ 2555, 2220, 2422, 225, 2208, 92, 2207, 2206, 2205, 2244, + /* 1960 */ 2440, 2219, 2243, 2226, 2218, 743, 2217, 2216, 408, 2214, + /* 1970 */ 2213, 2212, 2388, 2211, 742, 230, 2201, 1584, 2202, 2200, + /* 1980 */ 539, 541, 2199, 707, 2210, 2209, 2242, 2204, 2421, 2203, + /* 1990 */ 2422, 2459, 2198, 2440, 409, 361, 2423, 746, 2425, 2426, + /* 2000 */ 741, 2046, 764, 740, 233, 2388, 2045, 742, 2044, 1437, + /* 2010 */ 1441, 235, 1445, 236, 2421, 375, 2042, 2459, 376, 2039, + /* 2020 */ 557, 361, 2423, 746, 2425, 2426, 741, 2038, 764, 2031, + /* 2030 */ 561, 2440, 558, 559, 2018, 565, 563, 1993, 567, 569, + /* 2040 */ 186, 1992, 1329, 2388, 238, 742, 562, 2421, 240, 2422, + /* 2050 */ 2459, 566, 79, 2408, 177, 2423, 746, 2425, 2426, 741, + /* 2060 */ 196, 764, 743, 577, 80, 2422, 2324, 2320, 2310, 2298, + /* 2070 */ 2297, 249, 247, 252, 2274, 2123, 2041, 2037, 743, 595, + /* 2080 */ 597, 1376, 596, 2035, 599, 2421, 600, 601, 2459, 2033, + /* 2090 */ 2440, 603, 360, 2423, 746, 2425, 2426, 741, 605, 764, + /* 2100 */ 604, 2479, 2388, 2030, 742, 609, 2440, 2013, 607, 2616, + /* 2110 */ 608, 2011, 2012, 2010, 1989, 2125, 258, 1514, 2388, 1513, + /* 2120 */ 742, 2124, 1427, 1426, 418, 1424, 1413, 72, 1422, 1421, + /* 2130 */ 1420, 821, 1419, 1418, 823, 2028, 1415, 1414, 399, 1412, + /* 2140 */ 420, 2026, 400, 2017, 2421, 401, 663, 2459, 2015, 402, + /* 2150 */ 1988, 361, 2423, 746, 2425, 2426, 741, 1987, 764, 641, + /* 2160 */ 2421, 644, 2422, 2459, 858, 1986, 648, 361, 2423, 746, + /* 2170 */ 2425, 2426, 741, 1985, 764, 743, 650, 1984, 652, 118, + /* 2180 */ 331, 1665, 2323, 1667, 1664, 28, 2422, 1669, 67, 1645, + /* 2190 */ 2319, 280, 1641, 1643, 2309, 56, 194, 57, 671, 743, + /* 2200 */ 672, 2296, 2295, 2440, 687, 846, 842, 838, 834, 677, + /* 2210 */ 328, 284, 679, 2599, 1620, 2388, 20, 742, 1619, 17, + /* 2220 */ 6, 2422, 170, 407, 30, 7, 1919, 2440, 21, 287, + /* 2230 */ 22, 190, 65, 689, 743, 691, 1893, 693, 178, 2388, + /* 2240 */ 289, 742, 201, 1934, 1900, 189, 32, 31, 2409, 24, + /* 2250 */ 59, 114, 1933, 23, 321, 412, 81, 658, 1938, 1887, + /* 2260 */ 2459, 1939, 2440, 1937, 356, 2423, 746, 2425, 2426, 741, + /* 2270 */ 1940, 764, 413, 303, 2388, 2294, 742, 181, 2273, 103, + /* 2280 */ 1858, 2421, 1857, 25, 2459, 102, 756, 13, 346, 2423, + /* 2290 */ 746, 2425, 2426, 741, 2422, 764, 1810, 58, 11, 1728, + /* 2300 */ 18, 1809, 182, 192, 1762, 751, 2272, 743, 1820, 2422, + /* 2310 */ 104, 1785, 38, 322, 326, 1784, 2421, 1754, 16, 2459, + /* 2320 */ 311, 26, 743, 345, 2423, 746, 2425, 2426, 741, 309, + /* 2330 */ 764, 2422, 27, 767, 193, 2440, 308, 765, 1895, 317, + /* 2340 */ 69, 105, 319, 809, 743, 2464, 2463, 2388, 745, 742, + /* 2350 */ 2440, 1787, 109, 2422, 763, 279, 68, 427, 771, 1499, + /* 2360 */ 1496, 774, 2388, 769, 742, 772, 743, 1495, 775, 777, + /* 2370 */ 1492, 1486, 2440, 778, 780, 1484, 781, 783, 784, 110, + /* 2380 */ 111, 1504, 1508, 78, 2388, 1490, 742, 1374, 1489, 2421, + /* 2390 */ 798, 1435, 2459, 1488, 2440, 1409, 347, 2423, 746, 2425, + /* 2400 */ 2426, 741, 1487, 764, 2421, 1406, 2388, 2459, 742, 1405, + /* 2410 */ 1404, 353, 2423, 746, 2425, 2426, 741, 1403, 764, 1401, + /* 2420 */ 1399, 1398, 1397, 811, 1434, 208, 2421, 1395, 1394, 2459, + /* 2430 */ 1393, 1392, 1391, 357, 2423, 746, 2425, 2426, 741, 1390, + /* 2440 */ 764, 1389, 1431, 1429, 1386, 1385, 1380, 1382, 2421, 2036, + /* 2450 */ 2422, 2459, 1381, 1379, 831, 348, 2423, 746, 2425, 2426, + /* 2460 */ 741, 833, 764, 743, 832, 2034, 2422, 835, 837, 836, + /* 2470 */ 2032, 839, 840, 841, 2029, 843, 844, 845, 2009, 743, + /* 2480 */ 847, 2422, 1318, 1983, 1306, 851, 330, 853, 1953, 1714, + /* 2490 */ 340, 2440, 856, 857, 743, 1953, 1953, 1953, 1953, 1953, + /* 2500 */ 1953, 1953, 1953, 2388, 1953, 742, 1953, 2440, 1953, 1953, + /* 2510 */ 2422, 1953, 1953, 1953, 1953, 1953, 1953, 1953, 1953, 2388, + /* 2520 */ 1953, 742, 2440, 743, 1953, 2422, 1953, 1953, 1953, 1953, + /* 2530 */ 1953, 1953, 1953, 1953, 2388, 1953, 742, 1953, 743, 1953, + /* 2540 */ 1953, 1953, 1953, 1953, 1953, 2421, 1953, 1953, 2459, 1953, + /* 2550 */ 1953, 2440, 358, 2423, 746, 2425, 2426, 741, 1953, 764, + /* 2560 */ 1953, 2421, 1953, 2388, 2459, 742, 2440, 1953, 349, 2423, + /* 2570 */ 746, 2425, 2426, 741, 1953, 764, 2421, 1953, 2388, 2459, + /* 2580 */ 742, 1953, 1953, 359, 2423, 746, 2425, 2426, 741, 1953, + /* 2590 */ 764, 1953, 1953, 1953, 1953, 1953, 2422, 1953, 1953, 1953, + /* 2600 */ 1953, 1953, 1953, 1953, 1953, 2421, 1953, 1953, 2459, 743, + /* 2610 */ 1953, 2422, 350, 2423, 746, 2425, 2426, 741, 1953, 764, + /* 2620 */ 2421, 1953, 1953, 2459, 743, 1953, 2422, 365, 2423, 746, + /* 2630 */ 2425, 2426, 741, 1953, 764, 1953, 1953, 2440, 1953, 743, + /* 2640 */ 1953, 1953, 1953, 1953, 1953, 1953, 1953, 1953, 1953, 2388, + /* 2650 */ 1953, 742, 2440, 1953, 1953, 1953, 1953, 1953, 1953, 1953, + /* 2660 */ 1953, 1953, 1953, 1953, 2388, 1953, 742, 2440, 1953, 1953, + /* 2670 */ 1953, 1953, 1953, 1953, 1953, 1953, 1953, 1953, 1953, 2388, + /* 2680 */ 1953, 742, 1953, 1953, 2422, 1953, 1953, 1953, 1953, 1953, + /* 2690 */ 1953, 2421, 1953, 1953, 2459, 1953, 1953, 743, 366, 2423, + /* 2700 */ 746, 2425, 2426, 741, 1953, 764, 2421, 1953, 1953, 2459, + /* 2710 */ 2422, 1953, 1953, 2434, 2423, 746, 2425, 2426, 741, 1953, + /* 2720 */ 764, 2421, 1953, 743, 2459, 2440, 1953, 1953, 2433, 2423, + /* 2730 */ 746, 2425, 2426, 741, 1953, 764, 1953, 2388, 1953, 742, + /* 2740 */ 1953, 1953, 1953, 2422, 1953, 1953, 1953, 1953, 1953, 1953, + /* 2750 */ 1953, 2440, 1953, 1953, 1953, 1953, 743, 1953, 1953, 1953, + /* 2760 */ 1953, 1953, 1953, 2388, 1953, 742, 1953, 1953, 2422, 1953, + /* 2770 */ 1953, 1953, 1953, 1953, 1953, 1953, 1953, 1953, 1953, 2421, + /* 2780 */ 1953, 743, 2459, 1953, 2440, 1953, 2432, 2423, 746, 2425, + /* 2790 */ 2426, 741, 1953, 764, 1953, 1953, 2388, 1953, 742, 1953, + /* 2800 */ 1953, 1953, 1953, 1953, 1953, 2421, 1953, 1953, 2459, 2440, + /* 2810 */ 1953, 1953, 381, 2423, 746, 2425, 2426, 741, 1953, 764, + /* 2820 */ 1953, 2388, 1953, 742, 1953, 1953, 1953, 1953, 1953, 1953, + /* 2830 */ 1953, 1953, 1953, 1953, 1953, 1953, 1953, 1953, 2421, 1953, + /* 2840 */ 1953, 2459, 1953, 1953, 1953, 382, 2423, 746, 2425, 2426, + /* 2850 */ 741, 2422, 764, 1953, 1953, 1953, 1953, 1953, 1953, 1953, + /* 2860 */ 1953, 1953, 1953, 2421, 743, 1953, 2459, 2422, 1953, 1953, + /* 2870 */ 378, 2423, 746, 2425, 2426, 741, 1953, 764, 1953, 1953, + /* 2880 */ 743, 1953, 2422, 1953, 1953, 1953, 1953, 1953, 1953, 1953, + /* 2890 */ 1953, 1953, 2440, 1953, 1953, 743, 1953, 1953, 1953, 1953, + /* 2900 */ 1953, 1953, 1953, 1953, 2388, 1953, 742, 1953, 2440, 1953, + /* 2910 */ 1953, 1953, 1953, 1953, 1953, 1953, 1953, 1953, 1953, 1953, + /* 2920 */ 2388, 1953, 742, 2440, 1953, 1953, 1953, 1953, 1953, 1953, + /* 2930 */ 1953, 1953, 1953, 1953, 1953, 2388, 1953, 742, 1953, 1953, + /* 2940 */ 1953, 1953, 1953, 1953, 1953, 1953, 2421, 1953, 1953, 2459, + /* 2950 */ 1953, 1953, 1953, 383, 2423, 746, 2425, 2426, 741, 1953, + /* 2960 */ 764, 1953, 744, 1953, 1953, 2459, 1953, 1953, 1953, 356, + /* 2970 */ 2423, 746, 2425, 2426, 741, 1953, 764, 2421, 1953, 1953, + /* 2980 */ 2459, 1953, 1953, 1953, 355, 2423, 746, 2425, 2426, 741, + /* 2990 */ 1953, 764, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 375, 383, 361, 395, 430, 364, 365, 1, 2, 435, - /* 10 */ 0, 430, 12, 13, 14, 397, 480, 392, 410, 483, - /* 20 */ 20, 20, 22, 8, 9, 407, 401, 12, 13, 14, - /* 30 */ 15, 16, 353, 21, 355, 35, 0, 37, 502, 366, - /* 40 */ 367, 480, 506, 507, 483, 354, 469, 470, 36, 366, - /* 50 */ 38, 39, 40, 20, 480, 366, 367, 483, 367, 386, - /* 60 */ 373, 480, 501, 502, 483, 65, 393, 506, 507, 451, - /* 70 */ 452, 71, 465, 409, 467, 501, 502, 390, 78, 461, - /* 80 */ 506, 507, 501, 502, 409, 398, 395, 506, 507, 8, - /* 90 */ 9, 427, 428, 12, 13, 14, 15, 16, 407, 424, - /* 100 */ 409, 70, 427, 428, 104, 422, 423, 107, 366, 73, - /* 110 */ 74, 75, 76, 77, 108, 79, 80, 81, 82, 83, + /* 0 */ 397, 397, 363, 389, 433, 366, 367, 404, 404, 438, + /* 10 */ 397, 397, 12, 13, 14, 412, 412, 2, 404, 405, + /* 20 */ 20, 20, 22, 8, 9, 412, 412, 12, 13, 14, + /* 30 */ 15, 16, 20, 411, 2, 35, 0, 37, 0, 20, + /* 40 */ 8, 9, 21, 356, 12, 13, 14, 15, 16, 368, + /* 50 */ 23, 429, 430, 368, 369, 484, 369, 36, 487, 38, + /* 60 */ 39, 40, 8, 9, 20, 65, 12, 13, 14, 15, + /* 70 */ 16, 71, 37, 20, 47, 48, 505, 506, 78, 368, + /* 80 */ 369, 510, 511, 20, 397, 8, 9, 33, 457, 12, + /* 90 */ 13, 14, 15, 16, 413, 414, 409, 416, 411, 388, + /* 100 */ 356, 420, 473, 474, 104, 399, 395, 107, 402, 73, + /* 110 */ 74, 75, 76, 77, 483, 79, 80, 81, 82, 83, /* 120 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, - /* 130 */ 94, 95, 96, 97, 98, 99, 100, 0, 20, 448, - /* 140 */ 22, 107, 451, 143, 144, 454, 455, 456, 457, 458, - /* 150 */ 459, 20, 461, 411, 412, 37, 414, 466, 361, 468, - /* 160 */ 418, 364, 365, 472, 473, 476, 477, 478, 14, 480, - /* 170 */ 481, 161, 483, 55, 20, 165, 395, 395, 487, 480, - /* 180 */ 180, 181, 483, 173, 402, 20, 495, 187, 188, 108, - /* 190 */ 501, 502, 410, 366, 367, 506, 507, 0, 417, 107, - /* 200 */ 419, 502, 202, 107, 204, 506, 507, 70, 394, 194, - /* 210 */ 20, 8, 9, 408, 409, 12, 13, 14, 15, 16, - /* 220 */ 406, 24, 25, 26, 27, 28, 29, 30, 31, 32, - /* 230 */ 20, 366, 367, 87, 234, 235, 236, 236, 238, 239, + /* 130 */ 94, 95, 96, 97, 98, 99, 100, 70, 451, 399, + /* 140 */ 355, 454, 357, 143, 144, 458, 459, 460, 461, 462, + /* 150 */ 463, 107, 465, 409, 20, 143, 144, 470, 411, 472, + /* 160 */ 454, 4, 108, 476, 477, 480, 481, 482, 397, 484, + /* 170 */ 485, 465, 487, 426, 0, 404, 429, 430, 491, 107, + /* 180 */ 180, 181, 0, 412, 20, 108, 499, 187, 188, 363, + /* 190 */ 505, 506, 366, 367, 454, 510, 511, 159, 160, 187, + /* 200 */ 188, 104, 202, 21, 204, 465, 24, 25, 26, 27, + /* 210 */ 28, 29, 30, 31, 32, 118, 119, 120, 121, 122, + /* 220 */ 123, 124, 125, 126, 127, 51, 129, 130, 131, 132, + /* 230 */ 133, 134, 135, 180, 181, 0, 236, 237, 238, 204, /* 240 */ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, - /* 250 */ 250, 251, 252, 253, 254, 255, 12, 13, 56, 57, - /* 260 */ 20, 18, 480, 20, 20, 483, 22, 12, 13, 236, - /* 270 */ 27, 362, 354, 30, 71, 366, 20, 368, 35, 35, - /* 280 */ 415, 37, 65, 501, 502, 367, 138, 362, 506, 507, - /* 290 */ 142, 366, 37, 368, 51, 149, 53, 201, 20, 203, - /* 300 */ 367, 58, 59, 476, 477, 478, 272, 480, 481, 65, - /* 310 */ 354, 366, 69, 395, 299, 71, 104, 107, 115, 173, - /* 320 */ 174, 69, 78, 106, 137, 407, 109, 409, 395, 233, - /* 330 */ 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - /* 340 */ 20, 129, 130, 131, 132, 133, 134, 135, 104, 106, - /* 350 */ 20, 107, 136, 137, 138, 139, 140, 141, 142, 211, - /* 360 */ 117, 0, 214, 407, 272, 217, 448, 219, 272, 451, - /* 370 */ 180, 181, 454, 455, 456, 457, 458, 459, 460, 461, - /* 380 */ 462, 463, 179, 143, 144, 440, 441, 143, 144, 456, - /* 390 */ 147, 148, 175, 150, 151, 152, 153, 154, 155, 156, - /* 400 */ 157, 158, 215, 216, 354, 162, 163, 164, 165, 166, - /* 410 */ 167, 168, 3, 170, 171, 172, 395, 366, 367, 176, - /* 420 */ 177, 178, 366, 367, 180, 181, 183, 187, 188, 20, - /* 430 */ 453, 187, 188, 20, 73, 74, 75, 386, 366, 367, - /* 440 */ 419, 80, 81, 82, 393, 14, 202, 86, 204, 197, - /* 450 */ 20, 20, 91, 92, 93, 94, 479, 407, 97, 204, - /* 460 */ 182, 100, 259, 260, 261, 262, 263, 264, 265, 266, - /* 470 */ 267, 268, 269, 143, 144, 70, 224, 225, 234, 235, - /* 480 */ 236, 71, 238, 239, 240, 241, 242, 243, 244, 245, - /* 490 */ 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, - /* 500 */ 256, 12, 13, 354, 20, 383, 22, 20, 3, 20, - /* 510 */ 0, 22, 387, 4, 236, 35, 367, 108, 405, 397, - /* 520 */ 395, 408, 409, 395, 35, 354, 37, 402, 403, 407, - /* 530 */ 402, 51, 476, 477, 478, 410, 480, 481, 410, 55, - /* 540 */ 60, 61, 62, 63, 395, 65, 373, 475, 476, 477, - /* 550 */ 478, 23, 480, 481, 65, 256, 407, 395, 409, 117, - /* 560 */ 71, 73, 74, 75, 402, 33, 186, 78, 80, 81, - /* 570 */ 82, 398, 410, 451, 86, 47, 48, 45, 407, 91, - /* 580 */ 92, 93, 94, 461, 234, 97, 106, 20, 100, 109, - /* 590 */ 256, 182, 258, 104, 107, 182, 107, 448, 366, 367, - /* 600 */ 451, 354, 375, 454, 455, 456, 457, 458, 459, 465, - /* 610 */ 461, 467, 182, 464, 367, 466, 467, 468, 386, 8, - /* 620 */ 9, 472, 473, 12, 13, 14, 15, 16, 401, 383, - /* 630 */ 22, 20, 143, 144, 284, 285, 286, 287, 288, 289, - /* 640 */ 290, 354, 395, 397, 234, 37, 136, 137, 138, 139, - /* 650 */ 140, 141, 142, 407, 407, 175, 409, 0, 278, 279, - /* 660 */ 280, 281, 366, 367, 184, 185, 236, 366, 367, 180, - /* 670 */ 181, 191, 192, 354, 107, 366, 187, 188, 21, 4, - /* 680 */ 0, 24, 25, 26, 27, 28, 29, 30, 31, 32, - /* 690 */ 210, 202, 376, 204, 407, 448, 382, 451, 451, 385, - /* 700 */ 384, 454, 455, 456, 457, 458, 459, 461, 461, 51, - /* 710 */ 354, 415, 104, 466, 430, 468, 415, 78, 60, 472, - /* 720 */ 473, 63, 64, 234, 235, 236, 407, 238, 239, 240, - /* 730 */ 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, - /* 740 */ 251, 252, 253, 254, 255, 12, 13, 14, 354, 440, - /* 750 */ 441, 366, 367, 20, 391, 22, 430, 137, 138, 272, - /* 760 */ 33, 367, 142, 407, 480, 357, 358, 483, 35, 21, - /* 770 */ 37, 386, 24, 25, 26, 27, 28, 29, 30, 31, - /* 780 */ 32, 354, 107, 274, 387, 501, 502, 366, 367, 395, - /* 790 */ 506, 507, 395, 182, 367, 395, 369, 34, 65, 294, - /* 800 */ 403, 407, 402, 409, 366, 367, 480, 386, 445, 483, - /* 810 */ 410, 78, 8, 9, 395, 387, 12, 13, 14, 15, - /* 820 */ 16, 402, 395, 395, 386, 371, 372, 501, 502, 410, - /* 830 */ 387, 403, 506, 507, 407, 108, 409, 104, 395, 272, - /* 840 */ 107, 42, 448, 366, 367, 451, 403, 236, 454, 455, - /* 850 */ 456, 457, 458, 459, 354, 461, 354, 354, 117, 22, - /* 860 */ 466, 4, 468, 386, 395, 354, 472, 473, 453, 367, - /* 870 */ 366, 367, 403, 354, 37, 448, 143, 144, 451, 0, - /* 880 */ 23, 454, 455, 456, 457, 458, 459, 354, 461, 495, - /* 890 */ 386, 4, 14, 466, 479, 468, 14, 395, 20, 472, - /* 900 */ 473, 436, 20, 46, 47, 48, 19, 407, 228, 407, - /* 910 */ 407, 409, 108, 180, 181, 78, 366, 367, 407, 0, - /* 920 */ 187, 188, 35, 8, 9, 20, 407, 12, 13, 14, - /* 930 */ 15, 16, 14, 15, 16, 202, 386, 204, 51, 22, - /* 940 */ 407, 104, 50, 380, 381, 58, 59, 272, 33, 395, - /* 950 */ 448, 37, 65, 451, 37, 430, 454, 455, 456, 457, - /* 960 */ 458, 459, 396, 461, 410, 371, 372, 234, 235, 236, - /* 970 */ 51, 238, 239, 240, 241, 242, 243, 244, 245, 246, - /* 980 */ 247, 248, 249, 250, 251, 252, 253, 254, 255, 12, - /* 990 */ 13, 396, 78, 106, 354, 78, 109, 20, 354, 22, - /* 1000 */ 12, 13, 14, 15, 16, 480, 354, 354, 483, 396, - /* 1010 */ 508, 509, 35, 395, 37, 136, 137, 138, 139, 140, - /* 1020 */ 141, 142, 354, 108, 354, 354, 501, 502, 410, 8, - /* 1030 */ 9, 506, 507, 12, 13, 14, 15, 16, 367, 202, - /* 1040 */ 369, 204, 65, 179, 366, 367, 20, 407, 354, 366, - /* 1050 */ 367, 407, 22, 366, 367, 78, 366, 367, 180, 407, - /* 1060 */ 407, 367, 180, 369, 386, 464, 395, 37, 467, 386, - /* 1070 */ 271, 234, 235, 386, 182, 407, 386, 407, 407, 117, - /* 1080 */ 409, 104, 190, 354, 107, 180, 136, 8, 9, 395, - /* 1090 */ 140, 12, 13, 14, 15, 16, 367, 33, 369, 2, - /* 1100 */ 0, 407, 396, 409, 404, 8, 9, 407, 354, 12, - /* 1110 */ 13, 14, 15, 16, 236, 366, 367, 13, 236, 448, - /* 1120 */ 143, 144, 451, 259, 395, 454, 455, 456, 457, 458, - /* 1130 */ 459, 169, 461, 269, 104, 386, 407, 466, 409, 468, - /* 1140 */ 33, 236, 448, 472, 473, 451, 0, 175, 454, 455, - /* 1150 */ 456, 457, 458, 459, 0, 461, 354, 180, 181, 37, - /* 1160 */ 466, 407, 468, 37, 187, 188, 472, 473, 22, 366, - /* 1170 */ 367, 366, 367, 404, 366, 367, 407, 448, 206, 202, - /* 1180 */ 451, 204, 78, 454, 455, 456, 457, 458, 459, 386, - /* 1190 */ 461, 386, 430, 2, 386, 466, 42, 468, 33, 8, - /* 1200 */ 9, 472, 473, 12, 13, 14, 15, 16, 396, 407, - /* 1210 */ 45, 234, 235, 236, 396, 238, 239, 240, 241, 242, - /* 1220 */ 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, - /* 1230 */ 253, 254, 255, 12, 13, 39, 40, 366, 367, 453, - /* 1240 */ 0, 20, 480, 22, 33, 483, 366, 367, 380, 381, - /* 1250 */ 366, 367, 404, 270, 271, 407, 35, 386, 37, 159, - /* 1260 */ 160, 182, 236, 501, 502, 479, 386, 33, 506, 507, - /* 1270 */ 386, 388, 110, 33, 391, 113, 354, 110, 110, 13, - /* 1280 */ 113, 113, 110, 0, 0, 113, 65, 13, 33, 367, - /* 1290 */ 0, 369, 218, 65, 220, 49, 33, 33, 355, 78, - /* 1300 */ 143, 144, 396, 37, 37, 22, 22, 111, 112, 33, - /* 1310 */ 114, 37, 22, 1, 2, 384, 420, 395, 18, 108, - /* 1320 */ 510, 33, 33, 23, 33, 104, 204, 13, 107, 407, - /* 1330 */ 204, 409, 136, 499, 354, 33, 140, 109, 492, 33, - /* 1340 */ 40, 41, 108, 33, 44, 78, 33, 367, 370, 369, - /* 1350 */ 107, 37, 33, 107, 54, 33, 395, 33, 33, 116, - /* 1360 */ 296, 13, 383, 108, 143, 144, 66, 67, 68, 69, - /* 1370 */ 448, 108, 108, 451, 33, 395, 454, 455, 456, 457, - /* 1380 */ 458, 459, 383, 461, 108, 37, 420, 407, 466, 409, - /* 1390 */ 468, 0, 365, 420, 472, 473, 108, 108, 498, 108, - /* 1400 */ 498, 180, 181, 33, 33, 298, 498, 107, 187, 188, - /* 1410 */ 108, 429, 370, 420, 108, 367, 406, 420, 108, 498, - /* 1420 */ 420, 108, 437, 202, 482, 204, 503, 108, 448, 474, - /* 1430 */ 108, 451, 108, 108, 454, 455, 456, 457, 458, 459, - /* 1440 */ 385, 461, 485, 52, 275, 145, 466, 431, 468, 108, - /* 1450 */ 51, 450, 472, 473, 42, 234, 235, 236, 449, 238, - /* 1460 */ 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, - /* 1470 */ 249, 250, 251, 252, 253, 254, 255, 20, 108, 108, - /* 1480 */ 442, 12, 13, 447, 354, 217, 375, 442, 375, 433, - /* 1490 */ 20, 22, 200, 366, 194, 195, 196, 367, 20, 199, - /* 1500 */ 367, 45, 416, 367, 35, 416, 37, 354, 179, 413, - /* 1510 */ 366, 366, 212, 213, 367, 416, 413, 379, 413, 413, - /* 1520 */ 367, 105, 103, 223, 366, 395, 226, 378, 102, 229, - /* 1530 */ 230, 231, 232, 233, 65, 20, 351, 407, 377, 409, - /* 1540 */ 366, 366, 354, 366, 50, 359, 363, 78, 395, 359, - /* 1550 */ 363, 442, 20, 375, 375, 367, 375, 409, 20, 20, - /* 1560 */ 407, 368, 409, 432, 375, 368, 20, 375, 366, 375, - /* 1570 */ 375, 359, 272, 104, 423, 375, 357, 395, 448, 395, - /* 1580 */ 366, 451, 357, 395, 454, 455, 456, 457, 458, 459, - /* 1590 */ 359, 461, 107, 395, 395, 407, 466, 409, 468, 395, - /* 1600 */ 395, 448, 472, 473, 451, 395, 221, 454, 455, 456, - /* 1610 */ 457, 458, 459, 395, 461, 430, 407, 395, 395, 466, - /* 1620 */ 435, 468, 395, 407, 407, 472, 473, 373, 20, 208, - /* 1630 */ 207, 373, 283, 409, 431, 366, 448, 407, 282, 451, - /* 1640 */ 439, 354, 454, 455, 456, 457, 458, 459, 291, 461, - /* 1650 */ 442, 444, 446, 438, 367, 491, 468, 425, 425, 193, - /* 1660 */ 472, 473, 491, 276, 494, 480, 493, 441, 483, 293, - /* 1670 */ 490, 202, 354, 204, 292, 431, 297, 300, 295, 271, - /* 1680 */ 20, 505, 395, 367, 117, 367, 501, 502, 453, 368, - /* 1690 */ 273, 506, 507, 373, 407, 425, 409, 425, 185, 354, - /* 1700 */ 373, 407, 489, 234, 235, 407, 407, 421, 407, 373, - /* 1710 */ 407, 491, 367, 395, 391, 373, 107, 248, 249, 250, - /* 1720 */ 251, 252, 253, 254, 488, 407, 367, 409, 486, 484, - /* 1730 */ 471, 107, 399, 504, 366, 448, 373, 407, 451, 22, - /* 1740 */ 395, 454, 455, 456, 457, 458, 459, 38, 461, 511, - /* 1750 */ 356, 359, 407, 360, 409, 468, 389, 354, 443, 472, - /* 1760 */ 473, 426, 434, 426, 389, 352, 448, 389, 0, 451, - /* 1770 */ 367, 374, 454, 455, 456, 457, 458, 459, 0, 461, - /* 1780 */ 0, 45, 0, 37, 227, 37, 468, 37, 37, 227, - /* 1790 */ 472, 473, 354, 448, 0, 37, 451, 37, 395, 454, - /* 1800 */ 455, 456, 457, 458, 459, 367, 461, 227, 37, 0, - /* 1810 */ 407, 227, 409, 0, 37, 0, 37, 0, 22, 0, - /* 1820 */ 37, 222, 354, 210, 0, 210, 204, 211, 202, 0, - /* 1830 */ 0, 0, 198, 395, 0, 367, 197, 0, 0, 148, - /* 1840 */ 49, 496, 497, 0, 49, 407, 0, 409, 37, 0, - /* 1850 */ 51, 448, 0, 37, 451, 49, 0, 454, 455, 456, - /* 1860 */ 457, 458, 459, 395, 461, 45, 0, 0, 400, 0, - /* 1870 */ 49, 468, 0, 0, 0, 407, 473, 409, 0, 0, - /* 1880 */ 0, 165, 37, 0, 165, 0, 448, 354, 0, 451, - /* 1890 */ 0, 0, 454, 455, 456, 457, 458, 459, 45, 461, - /* 1900 */ 367, 0, 354, 0, 0, 0, 0, 0, 0, 0, - /* 1910 */ 0, 0, 0, 0, 0, 367, 448, 354, 22, 451, - /* 1920 */ 0, 0, 454, 455, 456, 457, 458, 459, 395, 461, - /* 1930 */ 367, 49, 0, 400, 148, 497, 0, 0, 0, 0, - /* 1940 */ 407, 0, 409, 395, 0, 0, 0, 0, 147, 0, - /* 1950 */ 146, 0, 0, 22, 0, 407, 37, 409, 395, 65, - /* 1960 */ 0, 0, 22, 0, 65, 50, 50, 65, 0, 42, - /* 1970 */ 407, 0, 409, 51, 51, 42, 0, 51, 0, 37, - /* 1980 */ 37, 448, 0, 33, 451, 37, 14, 454, 455, 456, - /* 1990 */ 457, 458, 459, 37, 461, 42, 448, 354, 0, 451, - /* 2000 */ 45, 42, 454, 455, 456, 457, 458, 459, 43, 461, - /* 2010 */ 367, 448, 42, 49, 451, 354, 49, 454, 455, 456, - /* 2020 */ 457, 458, 459, 49, 461, 0, 0, 0, 367, 42, - /* 2030 */ 0, 0, 193, 49, 0, 0, 0, 37, 395, 0, - /* 2040 */ 354, 72, 0, 400, 51, 42, 37, 51, 500, 42, - /* 2050 */ 407, 0, 409, 367, 37, 51, 395, 42, 0, 37, - /* 2060 */ 42, 51, 0, 0, 0, 0, 0, 0, 407, 37, - /* 2070 */ 409, 0, 509, 115, 22, 113, 22, 37, 37, 0, - /* 2080 */ 37, 395, 37, 37, 37, 37, 400, 37, 33, 33, - /* 2090 */ 37, 448, 22, 407, 451, 409, 37, 454, 455, 456, - /* 2100 */ 457, 458, 459, 0, 461, 37, 22, 0, 22, 448, - /* 2110 */ 354, 0, 451, 53, 1, 454, 455, 456, 457, 458, - /* 2120 */ 459, 22, 461, 367, 463, 37, 0, 0, 0, 37, - /* 2130 */ 0, 37, 19, 0, 448, 20, 22, 451, 37, 37, - /* 2140 */ 454, 455, 456, 457, 458, 459, 354, 461, 35, 37, - /* 2150 */ 0, 395, 108, 49, 0, 182, 400, 182, 37, 367, - /* 2160 */ 22, 0, 22, 407, 51, 409, 209, 182, 107, 0, - /* 2170 */ 0, 205, 182, 60, 61, 62, 63, 354, 65, 107, - /* 2180 */ 185, 189, 3, 182, 33, 107, 189, 395, 108, 107, - /* 2190 */ 367, 108, 37, 37, 277, 50, 107, 50, 105, 407, - /* 2200 */ 103, 409, 49, 108, 448, 33, 33, 451, 108, 33, - /* 2210 */ 454, 455, 456, 457, 458, 459, 107, 461, 395, 106, - /* 2220 */ 49, 33, 109, 107, 107, 3, 108, 107, 33, 37, - /* 2230 */ 407, 108, 409, 108, 37, 37, 37, 37, 37, 108, - /* 2240 */ 448, 33, 108, 451, 0, 49, 454, 455, 456, 457, - /* 2250 */ 458, 459, 354, 461, 141, 49, 277, 277, 270, 0, - /* 2260 */ 42, 186, 0, 42, 107, 367, 107, 33, 116, 184, - /* 2270 */ 108, 448, 354, 108, 451, 107, 49, 454, 455, 456, - /* 2280 */ 457, 458, 459, 105, 461, 367, 105, 107, 354, 107, - /* 2290 */ 107, 22, 2, 395, 257, 108, 107, 184, 107, 49, - /* 2300 */ 107, 367, 108, 234, 191, 407, 49, 409, 22, 33, - /* 2310 */ 108, 107, 107, 395, 237, 108, 107, 37, 108, 37, - /* 2320 */ 117, 107, 37, 210, 108, 407, 107, 409, 108, 395, - /* 2330 */ 37, 107, 37, 108, 108, 107, 37, 107, 37, 108, - /* 2340 */ 107, 407, 37, 409, 107, 354, 448, 107, 107, 451, - /* 2350 */ 22, 128, 454, 455, 456, 457, 458, 459, 367, 461, - /* 2360 */ 128, 37, 71, 128, 128, 354, 448, 37, 72, 451, - /* 2370 */ 37, 37, 454, 455, 456, 457, 458, 459, 367, 461, - /* 2380 */ 37, 37, 448, 354, 37, 451, 395, 37, 454, 455, - /* 2390 */ 456, 457, 458, 459, 37, 461, 367, 78, 407, 101, - /* 2400 */ 409, 78, 33, 354, 101, 37, 395, 37, 37, 22, - /* 2410 */ 37, 37, 37, 78, 37, 37, 367, 37, 407, 37, - /* 2420 */ 409, 22, 37, 37, 395, 0, 37, 51, 0, 37, - /* 2430 */ 42, 0, 51, 42, 37, 42, 407, 0, 409, 448, - /* 2440 */ 37, 354, 451, 42, 395, 454, 455, 456, 457, 458, - /* 2450 */ 459, 51, 461, 51, 367, 0, 407, 37, 409, 448, - /* 2460 */ 37, 0, 451, 22, 21, 454, 455, 456, 457, 458, - /* 2470 */ 459, 33, 461, 22, 22, 22, 20, 448, 354, 21, - /* 2480 */ 451, 512, 395, 454, 455, 456, 457, 458, 459, 512, - /* 2490 */ 461, 367, 512, 512, 407, 512, 409, 448, 354, 512, - /* 2500 */ 451, 512, 512, 454, 455, 456, 457, 458, 459, 512, - /* 2510 */ 461, 367, 512, 512, 354, 512, 512, 512, 512, 395, - /* 2520 */ 512, 512, 512, 512, 512, 512, 512, 367, 512, 512, - /* 2530 */ 512, 407, 512, 409, 512, 448, 512, 512, 451, 395, - /* 2540 */ 512, 454, 455, 456, 457, 458, 459, 512, 461, 512, - /* 2550 */ 512, 407, 512, 409, 512, 395, 512, 512, 512, 512, - /* 2560 */ 512, 512, 512, 512, 512, 512, 512, 407, 512, 409, - /* 2570 */ 512, 512, 448, 512, 512, 451, 512, 512, 454, 455, - /* 2580 */ 456, 457, 458, 459, 512, 461, 512, 512, 512, 512, - /* 2590 */ 512, 512, 448, 512, 512, 451, 512, 512, 454, 455, - /* 2600 */ 456, 457, 458, 459, 512, 461, 512, 354, 448, 512, - /* 2610 */ 512, 451, 512, 512, 454, 455, 456, 457, 458, 459, - /* 2620 */ 367, 461, 512, 512, 512, 512, 354, 512, 512, 512, - /* 2630 */ 512, 512, 512, 512, 512, 512, 512, 512, 512, 367, - /* 2640 */ 512, 512, 512, 354, 512, 512, 512, 512, 395, 512, - /* 2650 */ 512, 512, 512, 512, 512, 512, 367, 512, 512, 512, - /* 2660 */ 407, 512, 409, 512, 512, 512, 512, 395, 512, 512, - /* 2670 */ 512, 512, 512, 512, 512, 512, 512, 512, 512, 407, - /* 2680 */ 512, 409, 512, 512, 395, 512, 512, 512, 512, 512, - /* 2690 */ 512, 512, 512, 512, 512, 512, 407, 512, 409, 512, - /* 2700 */ 354, 448, 512, 512, 451, 512, 512, 454, 455, 456, - /* 2710 */ 457, 458, 459, 367, 461, 512, 512, 512, 512, 512, - /* 2720 */ 448, 354, 512, 451, 512, 512, 454, 455, 456, 457, - /* 2730 */ 458, 459, 512, 461, 367, 512, 512, 448, 354, 512, - /* 2740 */ 451, 395, 512, 454, 455, 456, 457, 458, 459, 512, - /* 2750 */ 461, 367, 512, 407, 512, 409, 512, 512, 354, 512, - /* 2760 */ 512, 512, 395, 512, 512, 512, 512, 512, 512, 512, - /* 2770 */ 512, 367, 512, 512, 407, 512, 409, 512, 512, 395, - /* 2780 */ 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, - /* 2790 */ 512, 407, 512, 409, 448, 512, 354, 451, 512, 395, - /* 2800 */ 454, 455, 456, 457, 458, 459, 512, 461, 512, 367, - /* 2810 */ 512, 407, 512, 409, 512, 448, 512, 512, 451, 512, - /* 2820 */ 512, 454, 455, 456, 457, 458, 459, 512, 461, 512, - /* 2830 */ 512, 512, 448, 354, 512, 451, 512, 395, 454, 455, - /* 2840 */ 456, 457, 458, 459, 512, 461, 367, 512, 512, 407, - /* 2850 */ 512, 409, 448, 512, 512, 451, 512, 512, 454, 455, - /* 2860 */ 456, 457, 458, 459, 512, 461, 512, 512, 512, 512, - /* 2870 */ 512, 512, 512, 512, 395, 512, 512, 512, 512, 512, - /* 2880 */ 512, 512, 512, 512, 512, 512, 407, 512, 409, 512, - /* 2890 */ 448, 512, 512, 451, 512, 512, 454, 455, 456, 457, - /* 2900 */ 458, 459, 512, 461, 512, 512, 512, 512, 512, 512, - /* 2910 */ 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, - /* 2920 */ 512, 512, 512, 512, 512, 512, 512, 448, 512, 512, - /* 2930 */ 451, 512, 512, 454, 455, 456, 457, 458, 459, 512, - /* 2940 */ 461, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 2950 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 2960 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 2970 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 2980 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 2990 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3000 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3010 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3020 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3030 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3040 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3050 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3060 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3070 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3080 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3090 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3100 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3110 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3120 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3130 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3140 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3150 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3160 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3170 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3180 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3190 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3200 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3210 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3220 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3230 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3240 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3250 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3260 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3270 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3280 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, - /* 3290 */ 351, 351, + /* 250 */ 250, 251, 252, 253, 254, 255, 256, 257, 12, 13, + /* 260 */ 377, 14, 20, 18, 107, 20, 20, 20, 22, 234, + /* 270 */ 235, 107, 27, 484, 356, 30, 487, 394, 4, 0, + /* 280 */ 35, 35, 356, 37, 8, 9, 403, 369, 12, 13, + /* 290 */ 14, 15, 16, 457, 505, 506, 51, 23, 53, 510, + /* 300 */ 511, 8, 9, 58, 59, 12, 13, 14, 15, 16, + /* 310 */ 107, 65, 33, 20, 69, 397, 182, 71, 274, 483, + /* 320 */ 46, 47, 48, 375, 78, 368, 369, 409, 407, 411, + /* 330 */ 70, 410, 411, 21, 20, 409, 24, 25, 26, 27, + /* 340 */ 28, 29, 30, 31, 32, 388, 274, 71, 400, 385, + /* 350 */ 104, 106, 395, 107, 12, 13, 14, 15, 16, 8, + /* 360 */ 9, 457, 117, 12, 13, 14, 15, 16, 14, 451, + /* 370 */ 397, 3, 454, 409, 20, 87, 458, 459, 460, 461, + /* 380 */ 462, 463, 464, 465, 466, 467, 20, 483, 20, 143, + /* 390 */ 144, 115, 147, 148, 421, 150, 151, 152, 153, 154, + /* 400 */ 155, 156, 157, 158, 201, 107, 203, 162, 163, 164, + /* 410 */ 165, 166, 167, 168, 0, 170, 171, 172, 454, 455, + /* 420 */ 456, 176, 177, 178, 258, 397, 180, 181, 183, 465, + /* 430 */ 18, 274, 353, 187, 188, 23, 233, 149, 24, 25, + /* 440 */ 26, 27, 28, 29, 30, 31, 32, 419, 202, 421, + /* 450 */ 204, 20, 40, 41, 14, 179, 44, 143, 144, 108, + /* 460 */ 20, 173, 174, 228, 8, 9, 54, 13, 12, 13, + /* 470 */ 14, 15, 16, 107, 117, 182, 108, 274, 66, 67, + /* 480 */ 68, 69, 236, 237, 238, 34, 240, 241, 242, 243, + /* 490 */ 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, + /* 500 */ 254, 255, 256, 257, 258, 12, 13, 399, 14, 15, + /* 510 */ 16, 385, 433, 20, 397, 22, 20, 438, 22, 107, + /* 520 */ 364, 404, 137, 138, 368, 78, 370, 142, 35, 412, + /* 530 */ 37, 238, 78, 37, 180, 409, 186, 261, 262, 263, + /* 540 */ 264, 265, 266, 267, 268, 269, 270, 271, 8, 9, + /* 550 */ 182, 55, 12, 13, 14, 15, 16, 145, 65, 368, + /* 560 */ 369, 356, 454, 484, 71, 258, 487, 260, 12, 13, + /* 570 */ 378, 78, 274, 465, 369, 433, 368, 369, 386, 388, + /* 580 */ 454, 455, 39, 40, 505, 506, 51, 42, 37, 510, + /* 590 */ 511, 465, 238, 37, 469, 60, 471, 104, 63, 64, + /* 600 */ 107, 484, 397, 3, 487, 356, 194, 195, 196, 356, + /* 610 */ 398, 199, 368, 369, 409, 364, 411, 0, 369, 368, + /* 620 */ 180, 370, 505, 506, 212, 213, 484, 510, 511, 487, + /* 630 */ 280, 281, 282, 283, 22, 223, 143, 144, 226, 22, + /* 640 */ 274, 229, 230, 231, 232, 233, 397, 505, 506, 37, + /* 650 */ 194, 20, 510, 511, 111, 112, 451, 114, 409, 454, + /* 660 */ 411, 417, 409, 458, 459, 460, 461, 462, 463, 238, + /* 670 */ 465, 117, 484, 180, 181, 487, 368, 369, 238, 136, + /* 680 */ 187, 188, 33, 140, 368, 369, 274, 479, 480, 481, + /* 690 */ 482, 37, 484, 485, 506, 202, 388, 204, 510, 511, + /* 700 */ 451, 1, 2, 454, 388, 500, 501, 458, 459, 460, + /* 710 */ 461, 462, 463, 20, 465, 433, 104, 468, 65, 470, + /* 720 */ 471, 472, 182, 368, 369, 476, 477, 236, 369, 236, + /* 730 */ 237, 238, 78, 240, 241, 242, 243, 244, 245, 246, + /* 740 */ 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, + /* 750 */ 257, 12, 13, 14, 356, 204, 397, 301, 377, 20, + /* 760 */ 204, 22, 109, 396, 368, 369, 484, 369, 50, 487, + /* 770 */ 368, 369, 417, 35, 35, 408, 37, 286, 287, 288, + /* 780 */ 289, 290, 291, 292, 403, 234, 235, 505, 506, 51, + /* 790 */ 388, 384, 510, 511, 387, 397, 0, 22, 60, 61, + /* 800 */ 62, 63, 484, 65, 65, 487, 398, 409, 108, 411, + /* 810 */ 368, 369, 37, 182, 73, 74, 75, 78, 273, 460, + /* 820 */ 179, 80, 81, 82, 506, 368, 369, 86, 510, 511, + /* 830 */ 388, 398, 91, 92, 93, 94, 356, 20, 97, 22, + /* 840 */ 4, 100, 20, 104, 106, 388, 107, 109, 0, 451, + /* 850 */ 398, 356, 454, 368, 369, 19, 458, 459, 460, 461, + /* 860 */ 462, 463, 468, 465, 369, 471, 371, 4, 470, 238, + /* 870 */ 472, 35, 55, 388, 476, 477, 480, 481, 482, 104, + /* 880 */ 484, 485, 143, 144, 22, 368, 369, 51, 0, 409, + /* 890 */ 368, 369, 397, 368, 58, 59, 296, 499, 368, 37, + /* 900 */ 182, 65, 261, 136, 409, 388, 411, 140, 190, 356, + /* 910 */ 8, 9, 271, 175, 12, 13, 14, 15, 16, 180, + /* 920 */ 181, 175, 184, 185, 137, 406, 187, 188, 409, 191, + /* 930 */ 192, 238, 136, 137, 138, 139, 140, 141, 142, 417, + /* 940 */ 78, 202, 106, 204, 368, 109, 451, 298, 210, 454, + /* 950 */ 368, 369, 206, 458, 459, 460, 461, 462, 463, 469, + /* 960 */ 465, 471, 409, 22, 433, 470, 104, 472, 443, 444, + /* 970 */ 388, 476, 477, 443, 444, 236, 237, 238, 37, 240, + /* 980 */ 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, + /* 990 */ 251, 252, 253, 254, 255, 256, 257, 12, 13, 356, + /* 1000 */ 424, 425, 215, 216, 182, 20, 398, 22, 433, 161, + /* 1010 */ 368, 369, 369, 165, 371, 484, 356, 356, 487, 78, + /* 1020 */ 35, 173, 37, 389, 136, 137, 138, 139, 140, 141, + /* 1030 */ 142, 397, 20, 410, 411, 356, 505, 506, 356, 405, + /* 1040 */ 397, 510, 511, 136, 137, 138, 139, 140, 141, 142, + /* 1050 */ 65, 369, 409, 371, 411, 368, 369, 389, 69, 484, + /* 1060 */ 238, 356, 487, 78, 202, 397, 204, 368, 369, 409, + /* 1070 */ 409, 56, 57, 405, 389, 388, 373, 374, 0, 397, + /* 1080 */ 505, 506, 397, 20, 433, 510, 511, 388, 409, 104, + /* 1090 */ 405, 409, 107, 411, 451, 398, 356, 454, 236, 237, + /* 1100 */ 356, 458, 459, 460, 461, 462, 463, 356, 465, 369, + /* 1110 */ 397, 371, 117, 470, 409, 472, 33, 404, 398, 476, + /* 1120 */ 477, 356, 480, 481, 482, 412, 484, 485, 143, 144, + /* 1130 */ 368, 369, 422, 451, 33, 484, 454, 397, 487, 276, + /* 1140 */ 458, 459, 460, 461, 462, 463, 45, 465, 70, 409, + /* 1150 */ 388, 411, 470, 409, 472, 356, 505, 506, 476, 477, + /* 1160 */ 409, 510, 511, 65, 169, 180, 181, 356, 368, 369, + /* 1170 */ 368, 369, 187, 188, 409, 439, 368, 369, 397, 138, + /* 1180 */ 382, 383, 397, 142, 359, 360, 197, 202, 388, 204, + /* 1190 */ 388, 451, 180, 412, 454, 71, 388, 412, 458, 459, + /* 1200 */ 460, 461, 462, 463, 106, 465, 356, 109, 409, 14, + /* 1210 */ 470, 357, 472, 224, 225, 20, 476, 477, 373, 374, + /* 1220 */ 409, 236, 237, 238, 393, 240, 241, 242, 243, 244, + /* 1230 */ 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, + /* 1240 */ 255, 256, 257, 12, 13, 368, 369, 368, 369, 356, + /* 1250 */ 238, 20, 211, 22, 356, 214, 33, 356, 217, 409, + /* 1260 */ 219, 375, 369, 0, 371, 388, 35, 388, 37, 356, + /* 1270 */ 356, 382, 383, 175, 368, 369, 37, 397, 392, 448, + /* 1280 */ 406, 272, 273, 409, 356, 405, 400, 33, 406, 390, + /* 1290 */ 397, 409, 393, 33, 388, 110, 65, 369, 113, 371, + /* 1300 */ 13, 238, 409, 33, 411, 42, 13, 409, 110, 78, + /* 1310 */ 409, 113, 0, 110, 110, 45, 113, 113, 0, 0, + /* 1320 */ 143, 144, 409, 409, 37, 397, 218, 33, 220, 37, + /* 1330 */ 37, 108, 33, 386, 22, 104, 503, 409, 107, 411, + /* 1340 */ 22, 22, 33, 13, 451, 49, 33, 454, 33, 1, + /* 1350 */ 2, 458, 459, 460, 461, 462, 463, 33, 465, 33, + /* 1360 */ 236, 0, 108, 470, 33, 472, 33, 37, 108, 476, + /* 1370 */ 477, 12, 13, 13, 143, 144, 33, 12, 13, 451, + /* 1380 */ 33, 22, 454, 300, 33, 33, 458, 459, 460, 461, + /* 1390 */ 462, 463, 107, 465, 35, 356, 37, 37, 470, 514, + /* 1400 */ 472, 116, 108, 107, 476, 477, 37, 108, 369, 372, + /* 1410 */ 397, 180, 181, 52, 33, 496, 33, 108, 187, 188, + /* 1420 */ 33, 108, 422, 108, 65, 385, 367, 385, 33, 422, + /* 1430 */ 33, 502, 108, 202, 108, 204, 397, 78, 502, 108, + /* 1440 */ 502, 108, 432, 204, 502, 372, 422, 78, 409, 369, + /* 1450 */ 411, 108, 408, 356, 440, 108, 422, 422, 486, 108, + /* 1460 */ 108, 507, 478, 104, 489, 277, 369, 236, 237, 238, + /* 1470 */ 434, 240, 241, 242, 243, 244, 245, 246, 247, 248, + /* 1480 */ 249, 250, 251, 252, 253, 254, 255, 256, 257, 108, + /* 1490 */ 451, 108, 387, 454, 397, 108, 204, 458, 459, 460, + /* 1500 */ 461, 462, 463, 108, 465, 108, 409, 0, 411, 470, + /* 1510 */ 51, 472, 12, 13, 453, 476, 477, 42, 452, 20, + /* 1520 */ 445, 217, 22, 356, 450, 377, 445, 377, 200, 436, + /* 1530 */ 20, 368, 20, 369, 45, 35, 369, 37, 418, 369, + /* 1540 */ 418, 179, 415, 368, 418, 369, 368, 415, 451, 415, + /* 1550 */ 415, 454, 105, 381, 103, 458, 459, 460, 461, 462, + /* 1560 */ 463, 202, 465, 204, 397, 65, 380, 470, 368, 472, + /* 1570 */ 102, 379, 20, 476, 477, 368, 409, 368, 411, 368, + /* 1580 */ 73, 74, 75, 361, 50, 365, 361, 80, 81, 82, + /* 1590 */ 445, 365, 356, 86, 377, 236, 237, 20, 91, 92, + /* 1600 */ 93, 94, 411, 20, 97, 369, 377, 100, 370, 250, + /* 1610 */ 251, 252, 253, 254, 255, 256, 435, 377, 451, 20, + /* 1620 */ 377, 454, 370, 356, 377, 458, 459, 460, 461, 462, + /* 1630 */ 463, 20, 465, 397, 377, 425, 369, 470, 377, 472, + /* 1640 */ 368, 377, 361, 476, 477, 409, 397, 411, 397, 359, + /* 1650 */ 397, 368, 397, 397, 359, 397, 397, 409, 361, 397, + /* 1660 */ 221, 449, 397, 397, 397, 397, 107, 20, 447, 445, + /* 1670 */ 208, 444, 442, 375, 207, 441, 409, 375, 411, 434, + /* 1680 */ 409, 285, 409, 284, 368, 411, 409, 451, 495, 495, + /* 1690 */ 454, 293, 356, 497, 458, 459, 460, 461, 462, 463, + /* 1700 */ 498, 465, 202, 427, 204, 369, 427, 193, 472, 495, + /* 1710 */ 295, 294, 476, 477, 278, 302, 434, 299, 451, 297, + /* 1720 */ 515, 454, 494, 508, 492, 458, 459, 460, 461, 462, + /* 1730 */ 463, 273, 465, 397, 234, 235, 236, 493, 20, 472, + /* 1740 */ 369, 457, 509, 476, 477, 409, 117, 411, 275, 370, + /* 1750 */ 250, 251, 252, 253, 254, 255, 256, 375, 107, 490, + /* 1760 */ 375, 356, 427, 488, 475, 409, 409, 409, 427, 185, + /* 1770 */ 393, 369, 409, 409, 369, 375, 356, 423, 375, 409, + /* 1780 */ 107, 409, 409, 375, 368, 401, 22, 451, 358, 369, + /* 1790 */ 454, 38, 437, 362, 458, 459, 460, 461, 462, 463, + /* 1800 */ 391, 465, 397, 361, 428, 356, 428, 354, 472, 376, + /* 1810 */ 391, 0, 476, 477, 409, 391, 411, 397, 369, 0, + /* 1820 */ 446, 0, 45, 0, 37, 227, 37, 37, 37, 409, + /* 1830 */ 227, 411, 0, 37, 37, 356, 227, 37, 0, 227, + /* 1840 */ 0, 37, 0, 0, 37, 0, 397, 22, 369, 37, + /* 1850 */ 222, 0, 210, 0, 210, 202, 451, 211, 409, 454, + /* 1860 */ 411, 204, 0, 458, 459, 460, 461, 462, 463, 0, + /* 1870 */ 465, 451, 0, 198, 454, 197, 397, 0, 458, 459, + /* 1880 */ 460, 461, 462, 463, 0, 465, 148, 0, 409, 37, + /* 1890 */ 411, 0, 472, 356, 0, 49, 49, 477, 37, 51, + /* 1900 */ 451, 0, 0, 454, 49, 45, 369, 458, 459, 460, + /* 1910 */ 461, 462, 463, 0, 465, 0, 0, 512, 513, 356, + /* 1920 */ 49, 0, 0, 0, 0, 0, 0, 165, 0, 37, + /* 1930 */ 451, 165, 369, 454, 397, 0, 0, 458, 459, 460, + /* 1940 */ 461, 462, 463, 0, 465, 0, 409, 0, 411, 0, + /* 1950 */ 501, 0, 356, 49, 0, 45, 0, 0, 0, 0, + /* 1960 */ 397, 0, 0, 0, 0, 369, 0, 0, 431, 0, + /* 1970 */ 0, 0, 409, 0, 411, 148, 0, 22, 0, 0, + /* 1980 */ 147, 146, 0, 504, 0, 0, 0, 0, 451, 0, + /* 1990 */ 356, 454, 0, 397, 431, 458, 459, 460, 461, 462, + /* 2000 */ 463, 0, 465, 369, 65, 409, 0, 411, 0, 37, + /* 2010 */ 22, 65, 22, 65, 451, 50, 0, 454, 50, 0, + /* 2020 */ 37, 458, 459, 460, 461, 462, 463, 0, 465, 0, + /* 2030 */ 37, 397, 51, 42, 0, 37, 42, 0, 42, 37, + /* 2040 */ 33, 0, 14, 409, 45, 411, 51, 451, 43, 356, + /* 2050 */ 454, 51, 42, 49, 458, 459, 460, 461, 462, 463, + /* 2060 */ 49, 465, 369, 49, 42, 356, 0, 0, 0, 0, + /* 2070 */ 0, 193, 42, 49, 0, 0, 0, 0, 369, 37, + /* 2080 */ 42, 72, 51, 0, 37, 451, 51, 42, 454, 0, + /* 2090 */ 397, 37, 458, 459, 460, 461, 462, 463, 42, 465, + /* 2100 */ 51, 467, 409, 0, 411, 42, 397, 0, 37, 513, + /* 2110 */ 51, 0, 0, 0, 0, 0, 113, 37, 409, 22, + /* 2120 */ 411, 0, 37, 37, 431, 37, 22, 115, 37, 37, + /* 2130 */ 37, 33, 37, 37, 33, 0, 37, 37, 22, 37, + /* 2140 */ 431, 0, 22, 0, 451, 22, 1, 454, 0, 22, + /* 2150 */ 0, 458, 459, 460, 461, 462, 463, 0, 465, 53, + /* 2160 */ 451, 37, 356, 454, 19, 0, 37, 458, 459, 460, + /* 2170 */ 461, 462, 463, 0, 465, 369, 37, 0, 22, 20, + /* 2180 */ 35, 37, 0, 37, 37, 107, 356, 108, 107, 209, + /* 2190 */ 0, 49, 37, 22, 0, 182, 51, 182, 22, 369, + /* 2200 */ 182, 0, 0, 397, 37, 60, 61, 62, 63, 189, + /* 2210 */ 65, 185, 189, 3, 182, 409, 33, 411, 182, 279, + /* 2220 */ 50, 356, 205, 37, 107, 50, 108, 397, 33, 107, + /* 2230 */ 33, 33, 3, 107, 369, 105, 108, 103, 107, 409, + /* 2240 */ 108, 411, 49, 37, 108, 107, 33, 107, 49, 33, + /* 2250 */ 33, 106, 37, 279, 109, 37, 107, 451, 37, 108, + /* 2260 */ 454, 108, 397, 37, 458, 459, 460, 461, 462, 463, + /* 2270 */ 108, 465, 37, 49, 409, 0, 411, 49, 0, 42, + /* 2280 */ 108, 451, 108, 33, 454, 107, 141, 2, 458, 459, + /* 2290 */ 460, 461, 462, 463, 356, 465, 105, 272, 259, 22, + /* 2300 */ 279, 105, 49, 49, 22, 186, 0, 369, 236, 356, + /* 2310 */ 42, 108, 107, 49, 33, 108, 451, 108, 107, 454, + /* 2320 */ 108, 107, 369, 458, 459, 460, 461, 462, 463, 184, + /* 2330 */ 465, 356, 107, 37, 107, 397, 191, 117, 108, 107, + /* 2340 */ 107, 107, 184, 101, 369, 107, 107, 409, 239, 411, + /* 2350 */ 397, 108, 116, 356, 107, 210, 107, 37, 37, 108, + /* 2360 */ 108, 37, 409, 107, 411, 107, 369, 108, 107, 37, + /* 2370 */ 108, 108, 397, 107, 37, 108, 107, 37, 107, 107, + /* 2380 */ 107, 22, 37, 107, 409, 128, 411, 72, 128, 451, + /* 2390 */ 71, 78, 454, 128, 397, 37, 458, 459, 460, 461, + /* 2400 */ 462, 463, 128, 465, 451, 37, 409, 454, 411, 37, + /* 2410 */ 37, 458, 459, 460, 461, 462, 463, 37, 465, 37, + /* 2420 */ 37, 37, 37, 101, 78, 33, 451, 37, 37, 454, + /* 2430 */ 37, 22, 37, 458, 459, 460, 461, 462, 463, 37, + /* 2440 */ 465, 37, 78, 37, 37, 37, 22, 37, 451, 0, + /* 2450 */ 356, 454, 37, 37, 37, 458, 459, 460, 461, 462, + /* 2460 */ 463, 42, 465, 369, 51, 0, 356, 37, 42, 51, + /* 2470 */ 0, 37, 51, 42, 0, 37, 51, 42, 0, 369, + /* 2480 */ 37, 356, 37, 0, 22, 33, 22, 21, 516, 22, + /* 2490 */ 22, 397, 21, 20, 369, 516, 516, 516, 516, 516, + /* 2500 */ 516, 516, 516, 409, 516, 411, 516, 397, 516, 516, + /* 2510 */ 356, 516, 516, 516, 516, 516, 516, 516, 516, 409, + /* 2520 */ 516, 411, 397, 369, 516, 356, 516, 516, 516, 516, + /* 2530 */ 516, 516, 516, 516, 409, 516, 411, 516, 369, 516, + /* 2540 */ 516, 516, 516, 516, 516, 451, 516, 516, 454, 516, + /* 2550 */ 516, 397, 458, 459, 460, 461, 462, 463, 516, 465, + /* 2560 */ 516, 451, 516, 409, 454, 411, 397, 516, 458, 459, + /* 2570 */ 460, 461, 462, 463, 516, 465, 451, 516, 409, 454, + /* 2580 */ 411, 516, 516, 458, 459, 460, 461, 462, 463, 516, + /* 2590 */ 465, 516, 516, 516, 516, 516, 356, 516, 516, 516, + /* 2600 */ 516, 516, 516, 516, 516, 451, 516, 516, 454, 369, + /* 2610 */ 516, 356, 458, 459, 460, 461, 462, 463, 516, 465, + /* 2620 */ 451, 516, 516, 454, 369, 516, 356, 458, 459, 460, + /* 2630 */ 461, 462, 463, 516, 465, 516, 516, 397, 516, 369, + /* 2640 */ 516, 516, 516, 516, 516, 516, 516, 516, 516, 409, + /* 2650 */ 516, 411, 397, 516, 516, 516, 516, 516, 516, 516, + /* 2660 */ 516, 516, 516, 516, 409, 516, 411, 397, 516, 516, + /* 2670 */ 516, 516, 516, 516, 516, 516, 516, 516, 516, 409, + /* 2680 */ 516, 411, 516, 516, 356, 516, 516, 516, 516, 516, + /* 2690 */ 516, 451, 516, 516, 454, 516, 516, 369, 458, 459, + /* 2700 */ 460, 461, 462, 463, 516, 465, 451, 516, 516, 454, + /* 2710 */ 356, 516, 516, 458, 459, 460, 461, 462, 463, 516, + /* 2720 */ 465, 451, 516, 369, 454, 397, 516, 516, 458, 459, + /* 2730 */ 460, 461, 462, 463, 516, 465, 516, 409, 516, 411, + /* 2740 */ 516, 516, 516, 356, 516, 516, 516, 516, 516, 516, + /* 2750 */ 516, 397, 516, 516, 516, 516, 369, 516, 516, 516, + /* 2760 */ 516, 516, 516, 409, 516, 411, 516, 516, 356, 516, + /* 2770 */ 516, 516, 516, 516, 516, 516, 516, 516, 516, 451, + /* 2780 */ 516, 369, 454, 516, 397, 516, 458, 459, 460, 461, + /* 2790 */ 462, 463, 516, 465, 516, 516, 409, 516, 411, 516, + /* 2800 */ 516, 516, 516, 516, 516, 451, 516, 516, 454, 397, + /* 2810 */ 516, 516, 458, 459, 460, 461, 462, 463, 516, 465, + /* 2820 */ 516, 409, 516, 411, 516, 516, 516, 516, 516, 516, + /* 2830 */ 516, 516, 516, 516, 516, 516, 516, 516, 451, 516, + /* 2840 */ 516, 454, 516, 516, 516, 458, 459, 460, 461, 462, + /* 2850 */ 463, 356, 465, 516, 516, 516, 516, 516, 516, 516, + /* 2860 */ 516, 516, 516, 451, 369, 516, 454, 356, 516, 516, + /* 2870 */ 458, 459, 460, 461, 462, 463, 516, 465, 516, 516, + /* 2880 */ 369, 516, 356, 516, 516, 516, 516, 516, 516, 516, + /* 2890 */ 516, 516, 397, 516, 516, 369, 516, 516, 516, 516, + /* 2900 */ 516, 516, 516, 516, 409, 516, 411, 516, 397, 516, + /* 2910 */ 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, + /* 2920 */ 409, 516, 411, 397, 516, 516, 516, 516, 516, 516, + /* 2930 */ 516, 516, 516, 516, 516, 409, 516, 411, 516, 516, + /* 2940 */ 516, 516, 516, 516, 516, 516, 451, 516, 516, 454, + /* 2950 */ 516, 516, 516, 458, 459, 460, 461, 462, 463, 516, + /* 2960 */ 465, 516, 451, 516, 516, 454, 516, 516, 516, 458, + /* 2970 */ 459, 460, 461, 462, 463, 516, 465, 451, 516, 516, + /* 2980 */ 454, 516, 516, 516, 458, 459, 460, 461, 462, 463, + /* 2990 */ 516, 465, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3000 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3010 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3020 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3030 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3040 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3050 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3060 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3070 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3080 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3090 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3100 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3110 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3120 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3130 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3140 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3150 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3160 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3170 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3180 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3190 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3200 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3210 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3220 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3230 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3240 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3250 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3260 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3270 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3280 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3290 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3300 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3310 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3320 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3330 */ 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, + /* 3340 */ 353, 353, 353, 353, 353, }; -#define YY_SHIFT_COUNT (851) +#define YY_SHIFT_COUNT (858) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2461) +#define YY_SHIFT_MAX (2483) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 1300, 0, 244, 0, 489, 489, 489, 489, 489, 489, - /* 10 */ 489, 489, 489, 489, 489, 489, 733, 977, 977, 1221, - /* 20 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 30 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 40 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 50 */ 977, 487, 567, 96, 210, 34, 92, 34, 34, 210, - /* 60 */ 210, 34, 1469, 34, 243, 1469, 1469, 675, 34, 131, - /* 70 */ 240, 165, 165, 857, 857, 240, 190, 330, 154, 154, - /* 80 */ 1, 165, 165, 165, 165, 165, 165, 165, 165, 165, - /* 90 */ 165, 165, 256, 320, 165, 165, 31, 131, 165, 256, - /* 100 */ 165, 131, 165, 165, 131, 165, 165, 131, 165, 131, - /* 110 */ 131, 131, 165, 405, 203, 203, 488, 748, 837, 837, - /* 120 */ 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, - /* 130 */ 837, 837, 837, 837, 837, 837, 837, 1196, 409, 190, - /* 140 */ 330, 202, 202, 914, 413, 413, 413, 137, 334, 334, - /* 150 */ 1104, 914, 31, 442, 131, 131, 299, 131, 639, 131, - /* 160 */ 639, 639, 741, 763, 212, 212, 212, 212, 212, 212, - /* 170 */ 212, 212, 2113, 361, 657, 611, 15, 350, 380, 118, - /* 180 */ 878, 882, 255, 255, 278, 528, 430, 917, 917, 917, - /* 190 */ 892, 917, 905, 484, 33, 431, 950, 972, 33, 33, - /* 200 */ 1026, 983, 799, 505, 983, 532, 509, 1104, 1169, 1399, - /* 210 */ 1412, 1457, 1268, 31, 1457, 31, 1292, 1470, 1478, 1456, - /* 220 */ 1478, 1456, 1329, 1470, 1478, 1470, 1456, 1329, 1329, 1329, - /* 230 */ 1416, 1419, 1470, 1426, 1470, 1470, 1470, 1515, 1494, 1515, - /* 240 */ 1494, 1457, 31, 31, 1532, 31, 1538, 1539, 31, 1538, - /* 250 */ 31, 1546, 31, 31, 1470, 31, 1515, 131, 131, 131, - /* 260 */ 131, 131, 131, 131, 131, 131, 131, 131, 1470, 763, - /* 270 */ 763, 1515, 639, 639, 639, 1385, 1485, 1457, 405, 1608, - /* 280 */ 1421, 1423, 1532, 405, 1169, 1470, 639, 1349, 1356, 1349, - /* 290 */ 1356, 1357, 1466, 1349, 1376, 1382, 1387, 1169, 1377, 1379, - /* 300 */ 1383, 1408, 1478, 1660, 1567, 1417, 1538, 405, 405, 1356, - /* 310 */ 639, 639, 639, 639, 1356, 639, 1513, 405, 741, 405, - /* 320 */ 1478, 1609, 1624, 639, 1470, 405, 1717, 1709, 1515, 2941, - /* 330 */ 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 36, 480, - /* 340 */ 197, 887, 915, 81, 804, 510, 1097, 1191, 1079, 879, - /* 350 */ 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 216, - /* 360 */ 148, 12, 988, 988, 252, 217, 10, 146, 658, 1100, - /* 370 */ 608, 1030, 187, 620, 620, 918, 6, 864, 918, 918, - /* 380 */ 918, 919, 680, 727, 1154, 1165, 962, 1240, 1162, 1167, - /* 390 */ 1168, 1172, 1266, 1274, 1146, 1283, 1284, 1290, 1074, 1211, - /* 400 */ 1234, 1228, 1255, 1263, 1264, 1276, 1157, 1064, 1107, 1288, - /* 410 */ 1289, 1291, 1302, 1306, 1310, 1312, 1313, 410, 1319, 1246, - /* 420 */ 1322, 1324, 1325, 1341, 1370, 1371, 1243, 1122, 1126, 1314, - /* 430 */ 1348, 1267, 1391, 1768, 1778, 1780, 1736, 1782, 1746, 1557, - /* 440 */ 1748, 1750, 1751, 1562, 1794, 1758, 1760, 1580, 1771, 1809, - /* 450 */ 1584, 1813, 1777, 1815, 1779, 1817, 1796, 1819, 1783, 1599, - /* 460 */ 1834, 1613, 1824, 1615, 1616, 1622, 1626, 1829, 1830, 1831, - /* 470 */ 1634, 1639, 1837, 1838, 1691, 1791, 1795, 1843, 1811, 1846, - /* 480 */ 1849, 1816, 1799, 1852, 1806, 1856, 1820, 1866, 1867, 1869, - /* 490 */ 1821, 1872, 1873, 1874, 1878, 1879, 1880, 1716, 1845, 1883, - /* 500 */ 1719, 1885, 1888, 1890, 1891, 1901, 1903, 1904, 1905, 1906, - /* 510 */ 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1920, 1921, - /* 520 */ 1882, 1932, 1853, 1936, 1937, 1938, 1939, 1941, 1944, 1945, - /* 530 */ 1896, 1946, 1786, 1947, 1801, 1949, 1804, 1951, 1952, 1931, - /* 540 */ 1915, 1940, 1916, 1954, 1894, 1919, 1960, 1899, 1961, 1902, - /* 550 */ 1963, 1968, 1942, 1922, 1927, 1971, 1943, 1923, 1933, 1976, - /* 560 */ 1948, 1926, 1953, 1978, 1956, 1982, 1955, 1959, 1950, 1964, - /* 570 */ 1967, 1972, 1974, 1998, 1965, 1970, 2025, 2026, 2027, 2039, - /* 580 */ 1987, 1839, 2030, 1964, 1984, 2031, 2034, 1969, 2035, 2036, - /* 590 */ 2000, 1993, 2003, 2042, 2009, 1996, 2007, 2051, 2017, 2004, - /* 600 */ 2015, 2058, 2022, 2010, 2018, 2062, 2063, 2064, 2065, 2066, - /* 610 */ 2067, 1958, 1962, 2032, 2052, 2071, 2040, 2041, 2043, 2045, - /* 620 */ 2046, 2047, 2048, 2050, 2055, 2056, 2053, 2059, 2054, 2068, - /* 630 */ 2079, 2070, 2103, 2084, 2107, 2086, 2060, 2111, 2099, 2088, - /* 640 */ 2126, 2127, 2128, 2092, 2130, 2094, 2133, 2114, 2115, 2101, - /* 650 */ 2102, 2112, 2044, 2061, 2150, 1973, 2072, 1957, 1964, 2104, - /* 660 */ 2154, 1975, 2121, 2138, 2161, 1966, 2140, 1985, 1995, 2169, - /* 670 */ 2170, 1990, 1992, 2001, 1997, 2179, 2151, 1917, 2078, 2080, - /* 680 */ 2082, 2083, 2155, 2156, 2089, 2145, 2093, 2147, 2097, 2095, - /* 690 */ 2172, 2173, 2100, 2109, 2116, 2117, 2118, 2176, 2153, 2171, - /* 700 */ 2120, 2188, 1979, 2123, 2125, 2222, 2195, 1980, 2192, 2197, - /* 710 */ 2198, 2199, 2200, 2201, 2131, 2134, 2196, 1988, 2208, 2206, - /* 720 */ 2244, 2259, 2157, 2218, 2159, 2162, 2165, 2168, 2180, 2075, - /* 730 */ 2182, 2262, 2221, 2085, 2183, 2152, 1964, 2227, 2234, 2178, - /* 740 */ 2037, 2181, 2290, 2269, 2069, 2189, 2187, 2191, 2194, 2193, - /* 750 */ 2202, 2250, 2204, 2205, 2257, 2207, 2286, 2077, 2209, 2203, - /* 760 */ 2210, 2280, 2282, 2214, 2216, 2285, 2219, 2220, 2293, 2224, - /* 770 */ 2225, 2295, 2228, 2226, 2299, 2230, 2231, 2301, 2233, 2223, - /* 780 */ 2232, 2235, 2236, 2237, 2276, 2240, 2305, 2241, 2276, 2276, - /* 790 */ 2328, 2296, 2291, 2324, 2330, 2333, 2334, 2343, 2344, 2347, - /* 800 */ 2350, 2357, 2319, 2298, 2323, 2303, 2369, 2368, 2370, 2371, - /* 810 */ 2387, 2373, 2374, 2375, 2335, 2055, 2377, 2056, 2378, 2380, - /* 820 */ 2382, 2385, 2399, 2386, 2425, 2389, 2376, 2388, 2428, 2392, - /* 830 */ 2381, 2391, 2431, 2397, 2400, 2393, 2437, 2403, 2402, 2401, - /* 840 */ 2455, 2420, 2423, 2461, 2441, 2438, 2451, 2443, 2452, 2453, - /* 850 */ 2458, 2456, + /* 0 */ 412, 0, 246, 0, 493, 493, 493, 493, 493, 493, + /* 10 */ 493, 493, 493, 493, 493, 493, 739, 985, 985, 1231, + /* 20 */ 985, 985, 985, 985, 985, 985, 985, 985, 985, 985, + /* 30 */ 985, 985, 985, 985, 985, 985, 985, 985, 985, 985, + /* 40 */ 985, 985, 985, 985, 985, 985, 985, 985, 985, 985, + /* 50 */ 44, 366, 203, 164, 72, 298, 72, 72, 164, 164, + /* 60 */ 72, 1359, 72, 245, 1359, 157, 72, 1, 1500, 12, + /* 70 */ 19, 19, 1500, 1500, 274, 274, 12, 53, 314, 247, + /* 80 */ 247, 431, 19, 19, 19, 19, 19, 19, 19, 19, + /* 90 */ 19, 19, 19, 63, 242, 19, 19, 67, 1, 19, + /* 100 */ 63, 19, 1, 19, 19, 1, 19, 19, 1, 19, + /* 110 */ 1, 1, 1, 19, 260, 276, 276, 741, 312, 862, + /* 120 */ 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, + /* 130 */ 862, 862, 862, 862, 862, 862, 862, 862, 543, 368, + /* 140 */ 53, 314, 1015, 1015, 654, 134, 134, 134, 307, 307, + /* 150 */ 1078, 454, 654, 67, 357, 1, 166, 1, 1, 447, + /* 160 */ 1, 447, 447, 554, 451, 97, 97, 97, 97, 97, + /* 170 */ 97, 97, 97, 2145, 1507, 182, 293, 456, 491, 350, + /* 180 */ 496, 354, 440, 556, 556, 631, 27, 822, 941, 941, + /* 190 */ 941, 718, 1012, 941, 817, 693, 1195, 767, 746, 693, + /* 200 */ 693, 1063, 1009, 545, 600, 1009, 1101, 863, 454, 1188, + /* 210 */ 1459, 1475, 1499, 1304, 67, 1499, 67, 1328, 1510, 1512, + /* 220 */ 1489, 1512, 1489, 1362, 1510, 1512, 1510, 1489, 1362, 1362, + /* 230 */ 1362, 1447, 1451, 1510, 1468, 1510, 1510, 1510, 1552, 1534, + /* 240 */ 1552, 1534, 1499, 67, 67, 1577, 67, 1583, 1599, 67, + /* 250 */ 1583, 67, 1611, 67, 67, 1510, 67, 1552, 1, 1, + /* 260 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1510, + /* 270 */ 451, 451, 1552, 447, 447, 447, 1439, 1559, 1499, 260, + /* 280 */ 1647, 1462, 1467, 1577, 260, 1188, 1510, 447, 1396, 1399, + /* 290 */ 1396, 1399, 1398, 1514, 1396, 1415, 1417, 1436, 1188, 1413, + /* 300 */ 1418, 1422, 1458, 1512, 1718, 1629, 1473, 1583, 260, 260, + /* 310 */ 1651, 1399, 447, 447, 447, 447, 1399, 447, 1584, 260, + /* 320 */ 554, 260, 1512, 447, 447, 1673, 447, 1510, 260, 1764, + /* 330 */ 1753, 1552, 2992, 2992, 2992, 2992, 2992, 2992, 2992, 2992, + /* 340 */ 2992, 36, 738, 414, 836, 54, 77, 351, 15, 32, + /* 350 */ 540, 796, 888, 902, 902, 902, 902, 902, 902, 902, + /* 360 */ 902, 902, 907, 1041, 21, 342, 342, 989, 1098, 848, + /* 370 */ 288, 535, 35, 551, 38, 612, 775, 787, 494, 700, + /* 380 */ 641, 494, 494, 494, 385, 385, 174, 235, 1223, 1263, + /* 390 */ 1270, 995, 279, 1185, 1198, 1203, 1204, 1287, 1293, 617, + /* 400 */ 1312, 1318, 1319, 1108, 1254, 1260, 653, 1294, 1299, 1309, + /* 410 */ 1313, 1177, 649, 1083, 1315, 1348, 1324, 1124, 1326, 1296, + /* 420 */ 1331, 1333, 1343, 1347, 1351, 1365, 1352, 1381, 1383, 1387, + /* 430 */ 1395, 1397, 1285, 1239, 1292, 1330, 1360, 1369, 1361, 1811, + /* 440 */ 1819, 1821, 1777, 1823, 1787, 1598, 1789, 1790, 1791, 1603, + /* 450 */ 1832, 1796, 1797, 1609, 1800, 1838, 1612, 1840, 1804, 1842, + /* 460 */ 1807, 1843, 1825, 1845, 1812, 1628, 1851, 1642, 1853, 1644, + /* 470 */ 1646, 1657, 1653, 1862, 1869, 1872, 1675, 1678, 1877, 1884, + /* 480 */ 1738, 1846, 1847, 1887, 1852, 1891, 1894, 1861, 1848, 1901, + /* 490 */ 1855, 1902, 1860, 1913, 1915, 1916, 1871, 1921, 1922, 1923, + /* 500 */ 1924, 1925, 1926, 1762, 1892, 1928, 1766, 1935, 1936, 1943, + /* 510 */ 1945, 1947, 1949, 1951, 1961, 1962, 1963, 1964, 1966, 1967, + /* 520 */ 1969, 1970, 1971, 1973, 1984, 1985, 1904, 1954, 1910, 1956, + /* 530 */ 1957, 1958, 1959, 1986, 1987, 1989, 1955, 1978, 1827, 1976, + /* 540 */ 1833, 1979, 1835, 1982, 1992, 1988, 1965, 1990, 1968, 2001, + /* 550 */ 1939, 1972, 2006, 1946, 2008, 1948, 2016, 2019, 1983, 1981, + /* 560 */ 1991, 2027, 1993, 1995, 1994, 2029, 1998, 2000, 1996, 2034, + /* 570 */ 2002, 2037, 1999, 2010, 2007, 2004, 2011, 2028, 2014, 2041, + /* 580 */ 2005, 2022, 2066, 2067, 2068, 2069, 2030, 1878, 2070, 2004, + /* 590 */ 2024, 2074, 2075, 2009, 2076, 2077, 2042, 2031, 2038, 2083, + /* 600 */ 2047, 2035, 2045, 2089, 2054, 2049, 2056, 2103, 2071, 2059, + /* 610 */ 2063, 2107, 2111, 2112, 2113, 2114, 2115, 2012, 2003, 2080, + /* 620 */ 2097, 2121, 2085, 2086, 2088, 2091, 2092, 2093, 2095, 2096, + /* 630 */ 2098, 2101, 2099, 2100, 2104, 2102, 2135, 2116, 2141, 2120, + /* 640 */ 2143, 2123, 2106, 2148, 2127, 2124, 2150, 2157, 2165, 2129, + /* 650 */ 2173, 2139, 2177, 2156, 2159, 2144, 2146, 2147, 2079, 2078, + /* 660 */ 2182, 2013, 2081, 1980, 2004, 2142, 2190, 2015, 2155, 2171, + /* 670 */ 2194, 2017, 2176, 2018, 2026, 2201, 2202, 2032, 2020, 2036, + /* 680 */ 2023, 2210, 2183, 1940, 2117, 2118, 2122, 2128, 2167, 2186, + /* 690 */ 2126, 2170, 2130, 2175, 2134, 2132, 2195, 2197, 2136, 2131, + /* 700 */ 2138, 2140, 2151, 2198, 2193, 2199, 2149, 2213, 1974, 2153, + /* 710 */ 2162, 2229, 2216, 2021, 2206, 2215, 2218, 2221, 2226, 2235, + /* 720 */ 2172, 2174, 2224, 2025, 2217, 2228, 2275, 2278, 2178, 2237, + /* 730 */ 2250, 2191, 2039, 2196, 2285, 2277, 2072, 2203, 2205, 2207, + /* 740 */ 2253, 2211, 2214, 2254, 2209, 2282, 2109, 2225, 2212, 2230, + /* 750 */ 2227, 2232, 2119, 2233, 2306, 2268, 2158, 2234, 2236, 2004, + /* 760 */ 2264, 2238, 2239, 2243, 2247, 2249, 2220, 2251, 2296, 2320, + /* 770 */ 2256, 2252, 2321, 2258, 2259, 2324, 2261, 2262, 2332, 2266, + /* 780 */ 2263, 2337, 2269, 2267, 2340, 2271, 2257, 2260, 2265, 2274, + /* 790 */ 2272, 2281, 2273, 2345, 2276, 2281, 2281, 2359, 2315, 2319, + /* 800 */ 2358, 2368, 2372, 2373, 2380, 2382, 2383, 2384, 2385, 2313, + /* 810 */ 2242, 2346, 2322, 2392, 2390, 2391, 2393, 2409, 2395, 2402, + /* 820 */ 2404, 2364, 2098, 2406, 2101, 2407, 2408, 2410, 2415, 2424, + /* 830 */ 2416, 2449, 2417, 2413, 2419, 2465, 2430, 2418, 2426, 2470, + /* 840 */ 2434, 2421, 2431, 2474, 2438, 2425, 2435, 2478, 2443, 2445, + /* 850 */ 2483, 2462, 2452, 2464, 2466, 2467, 2468, 2471, 2473, }; -#define YY_REDUCE_COUNT (337) -#define YY_REDUCE_MIN (-464) -#define YY_REDUCE_MAX (2479) +#define YY_REDUCE_COUNT (340) +#define YY_REDUCE_MIN (-429) +#define YY_REDUCE_MAX (2526) static const short yy_reduce_ofst[] = { - /* 0 */ 1185, -309, 149, 394, 427, 671, 694, 729, 922, 980, - /* 10 */ 247, 1130, 1153, 1188, 1287, 1318, -82, 1345, 502, 1403, - /* 20 */ 1438, 1468, 1533, 1548, 1563, 1643, 1661, 1686, 1756, 1792, - /* 30 */ 1823, 1898, 1918, 1934, 1991, 2011, 2029, 2049, 2087, 2124, - /* 40 */ 2144, 2160, 2253, 2272, 2289, 2346, 2367, 2384, 2404, 2442, - /* 50 */ 2479, -311, -218, -426, 72, -419, 284, 326, 525, -173, - /* 60 */ 56, 762, -382, -439, -258, 122, 246, -464, -301, 125, - /* 70 */ -325, -327, 51, -359, -203, -336, -219, 113, -91, -75, - /* 80 */ -67, 385, 421, 438, 477, -135, 296, 232, 504, 550, - /* 90 */ 678, 301, -55, -317, 683, 687, -375, 128, 690, 309, - /* 100 */ 749, 162, 805, 808, 397, 871, 880, 400, 803, 428, - /* 110 */ 419, 443, 884, -313, -423, -423, 316, -321, -44, 50, - /* 120 */ 171, 287, 319, 356, 500, 503, 511, 519, 533, 640, - /* 130 */ 644, 652, 653, 668, 670, 754, 802, -186, -23, 21, - /* 140 */ -195, 454, 594, 563, -23, 415, 786, 173, -393, 144, - /* 150 */ 314, 868, 227, 363, -392, 554, 601, 469, 700, 618, - /* 160 */ 769, 848, 883, 408, 566, 595, 613, 706, 812, 818, - /* 170 */ 906, 812, 465, 931, 943, 896, 810, 834, 846, 978, - /* 180 */ 961, 961, 979, 999, 966, 1027, 973, 900, 902, 908, - /* 190 */ 982, 921, 961, 1042, 993, 1048, 1010, 985, 997, 1000, - /* 200 */ 961, 942, 942, 923, 942, 955, 957, 1055, 1016, 1001, - /* 210 */ 1009, 1038, 1036, 1111, 1045, 1113, 1056, 1127, 1133, 1086, - /* 220 */ 1136, 1089, 1096, 1144, 1147, 1145, 1099, 1103, 1105, 1106, - /* 230 */ 1138, 1149, 1158, 1161, 1174, 1175, 1177, 1186, 1183, 1190, - /* 240 */ 1187, 1109, 1178, 1179, 1148, 1181, 1193, 1131, 1189, 1197, - /* 250 */ 1192, 1151, 1194, 1195, 1202, 1200, 1212, 1182, 1184, 1198, - /* 260 */ 1199, 1204, 1205, 1210, 1218, 1222, 1223, 1227, 1214, 1219, - /* 270 */ 1225, 1231, 1209, 1216, 1217, 1206, 1207, 1208, 1254, 1226, - /* 280 */ 1201, 1215, 1224, 1258, 1203, 1269, 1230, 1164, 1232, 1171, - /* 290 */ 1233, 1170, 1173, 1220, 1180, 1213, 1236, 1244, 1238, 1176, - /* 300 */ 1229, 942, 1316, 1235, 1242, 1245, 1321, 1320, 1327, 1270, - /* 310 */ 1294, 1298, 1299, 1301, 1272, 1303, 1286, 1336, 1323, 1342, - /* 320 */ 1359, 1259, 1333, 1330, 1368, 1363, 1394, 1393, 1392, 1328, - /* 330 */ 1315, 1335, 1337, 1367, 1375, 1378, 1397, 1413, + /* 0 */ 79, -313, 249, 398, 495, 643, 682, 740, 893, 928, + /* 10 */ 1039, 1097, 1167, 1236, 1267, 1336, -82, 205, 1405, 1420, + /* 20 */ 1449, 1537, 1563, 1479, 1596, 1634, 1693, 1709, 1806, 1830, + /* 30 */ 1865, 1938, 1953, 1975, 1997, 2094, 2110, 2125, 2154, 2169, + /* 40 */ 2240, 2255, 2270, 2328, 2354, 2387, 2412, 2495, 2511, 2526, + /* 50 */ -315, 117, -429, 208, 142, 282, 531, 575, 396, 642, + /* 60 */ 651, -36, -211, -319, 126, 188, 318, -386, -294, -253, + /* 70 */ -289, -43, -260, 108, -361, -174, -378, 28, -79, 156, + /* 80 */ 251, 359, 191, 308, 316, 402, 244, 355, 442, 457, + /* 90 */ 485, 517, 522, 525, 576, 582, 687, -117, -397, 699, + /* 100 */ 530, 762, -396, 800, 802, 634, 808, 877, -229, 879, + /* 110 */ 668, 713, 685, 906, 886, -371, -371, 192, -215, -256, + /* 120 */ -74, 253, 480, 553, 660, 661, 679, 705, 744, 751, + /* 130 */ 765, 799, 811, 850, 898, 901, 913, 914, 367, -369, + /* 140 */ -27, 623, 703, 845, 798, -369, -164, -96, 125, 490, + /* 150 */ -52, 407, 889, 381, 831, -387, 394, 781, 880, 519, + /* 160 */ 785, 874, 882, 899, 825, 212, 408, 433, 452, 608, + /* 170 */ 697, 720, 608, 736, 947, 854, 710, 885, 833, 919, + /* 180 */ 1037, 1013, 1013, 1040, 1042, 1000, 1059, 1007, 929, 936, + /* 190 */ 938, 1010, 1013, 942, 1073, 1024, 1080, 1044, 1014, 1034, + /* 200 */ 1035, 1013, 972, 972, 954, 972, 984, 975, 1105, 1036, + /* 210 */ 1061, 1066, 1075, 1074, 1148, 1081, 1150, 1093, 1163, 1164, + /* 220 */ 1120, 1170, 1122, 1127, 1175, 1176, 1178, 1126, 1132, 1134, + /* 230 */ 1135, 1172, 1186, 1200, 1192, 1207, 1209, 1211, 1222, 1220, + /* 240 */ 1225, 1226, 1145, 1217, 1229, 1191, 1240, 1238, 1181, 1243, + /* 250 */ 1252, 1247, 1210, 1257, 1261, 1272, 1264, 1281, 1249, 1251, + /* 260 */ 1253, 1255, 1256, 1258, 1259, 1262, 1265, 1266, 1268, 1283, + /* 270 */ 1290, 1295, 1297, 1248, 1271, 1273, 1212, 1221, 1224, 1298, + /* 280 */ 1227, 1230, 1234, 1274, 1302, 1245, 1316, 1277, 1193, 1276, + /* 290 */ 1194, 1279, 1202, 1196, 1214, 1228, 1244, 1232, 1282, 1205, + /* 300 */ 1233, 1215, 972, 1371, 1284, 1269, 1275, 1379, 1382, 1385, + /* 310 */ 1289, 1335, 1356, 1357, 1358, 1363, 1341, 1364, 1354, 1400, + /* 320 */ 1377, 1403, 1402, 1370, 1372, 1384, 1373, 1416, 1408, 1430, + /* 330 */ 1431, 1442, 1355, 1374, 1376, 1378, 1409, 1419, 1424, 1433, + /* 340 */ 1453, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 10 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 20 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 30 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 40 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 50 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 60 */ 1905, 2245, 1905, 1905, 2208, 1905, 1905, 1905, 1905, 1905, - /* 70 */ 1905, 1905, 1905, 1905, 1905, 1905, 2215, 1905, 1905, 1905, - /* 80 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 90 */ 1905, 1905, 1905, 1905, 1905, 1905, 2004, 1905, 1905, 1905, - /* 100 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 110 */ 1905, 1905, 1905, 2002, 2448, 1905, 1905, 1905, 1905, 1905, - /* 120 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 130 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 2460, 1905, - /* 140 */ 1905, 1976, 1976, 1905, 2460, 2460, 2460, 2002, 2420, 2420, - /* 150 */ 1905, 1905, 2004, 2283, 1905, 1905, 1905, 1905, 1905, 1905, - /* 160 */ 1905, 1905, 2127, 1935, 1905, 1905, 1905, 1905, 2151, 1905, - /* 170 */ 1905, 1905, 2271, 1905, 1905, 2489, 2551, 1905, 2492, 1905, - /* 180 */ 1905, 1905, 1905, 1905, 2220, 1905, 2479, 1905, 1905, 1905, - /* 190 */ 1905, 1905, 1905, 1905, 1905, 1905, 2080, 2265, 1905, 1905, - /* 200 */ 1905, 2452, 2466, 2535, 2453, 2450, 2473, 1905, 2483, 1905, - /* 210 */ 2308, 1905, 2297, 2004, 1905, 2004, 2258, 2203, 1905, 2213, - /* 220 */ 1905, 2213, 2210, 1905, 1905, 1905, 2213, 2210, 2210, 2210, - /* 230 */ 2069, 2065, 1905, 2063, 1905, 1905, 1905, 1905, 1960, 1905, - /* 240 */ 1960, 1905, 2004, 2004, 1905, 2004, 1905, 1905, 2004, 1905, - /* 250 */ 2004, 1905, 2004, 2004, 1905, 2004, 1905, 1905, 1905, 1905, - /* 260 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 270 */ 1905, 1905, 1905, 1905, 1905, 2295, 2281, 1905, 2002, 1905, - /* 280 */ 2269, 2267, 1905, 2002, 2483, 1905, 1905, 2505, 2500, 2505, - /* 290 */ 2500, 2519, 2515, 2505, 2524, 2521, 2485, 2483, 2554, 2541, - /* 300 */ 2537, 2466, 1905, 1905, 2471, 2469, 1905, 2002, 2002, 2500, - /* 310 */ 1905, 1905, 1905, 1905, 2500, 1905, 1905, 2002, 1905, 2002, - /* 320 */ 1905, 1905, 2096, 1905, 1905, 2002, 1905, 1944, 1905, 2260, - /* 330 */ 2286, 2241, 2241, 2130, 2130, 2130, 2005, 1910, 1905, 1905, - /* 340 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 350 */ 2518, 2517, 2373, 1905, 2424, 2423, 2422, 2413, 2372, 2092, - /* 360 */ 1905, 1905, 2371, 2370, 1905, 1905, 1905, 1905, 1905, 1905, - /* 370 */ 1905, 1905, 1905, 2232, 2231, 2364, 1905, 1905, 2365, 2363, - /* 380 */ 2362, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 390 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 400 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 2538, 2542, 1905, - /* 410 */ 1905, 1905, 1905, 1905, 1905, 2449, 1905, 1905, 1905, 2344, - /* 420 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 430 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 440 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 450 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 460 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 470 */ 1905, 1905, 1905, 1905, 2209, 1905, 1905, 1905, 1905, 1905, - /* 480 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 490 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 500 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 510 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 520 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 530 */ 1905, 1905, 1905, 1905, 1905, 1905, 2224, 1905, 1905, 1905, - /* 540 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 550 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 560 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1949, 2351, - /* 570 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 580 */ 1905, 1905, 1905, 2354, 1905, 1905, 1905, 1905, 1905, 1905, - /* 590 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 600 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 610 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 620 */ 1905, 1905, 1905, 1905, 2044, 2043, 1905, 1905, 1905, 1905, - /* 630 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 640 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 650 */ 1905, 1905, 2355, 1905, 1905, 1905, 1905, 1905, 2346, 1905, - /* 660 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 670 */ 1905, 1905, 1905, 1905, 1905, 2534, 2486, 1905, 1905, 1905, - /* 680 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 690 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 2344, - /* 700 */ 1905, 2516, 1905, 1905, 2532, 1905, 2536, 1905, 1905, 1905, - /* 710 */ 1905, 1905, 1905, 1905, 2459, 2455, 1905, 1905, 2451, 1905, - /* 720 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 730 */ 1905, 1905, 1905, 1905, 1905, 1905, 2343, 1905, 2410, 1905, - /* 740 */ 1905, 1905, 2444, 1905, 1905, 2395, 1905, 1905, 1905, 1905, - /* 750 */ 1905, 1905, 1905, 1905, 1905, 2355, 1905, 2358, 1905, 1905, - /* 760 */ 1905, 1905, 1905, 2124, 1905, 1905, 1905, 1905, 1905, 1905, - /* 770 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 2108, - /* 780 */ 2106, 2105, 2104, 1905, 2137, 1905, 1905, 1905, 2133, 2132, - /* 790 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 800 */ 1905, 1905, 1905, 1905, 1905, 1905, 2023, 1905, 1905, 1905, - /* 810 */ 1905, 1905, 1905, 1905, 1905, 2015, 1905, 2014, 1905, 1905, - /* 820 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 830 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, - /* 840 */ 1905, 1905, 1905, 1905, 1905, 1934, 1905, 1905, 1905, 1905, - /* 850 */ 1905, 1905, + /* 0 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 10 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 20 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 30 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 40 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 50 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 60 */ 2291, 1951, 1951, 2254, 1951, 1951, 1951, 1951, 1951, 1951, + /* 70 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 2261, 1951, 1951, + /* 80 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 90 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 2050, 1951, 1951, + /* 100 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 110 */ 1951, 1951, 1951, 1951, 2048, 2515, 1951, 1951, 1951, 1951, + /* 120 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 130 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 2527, + /* 140 */ 1951, 1951, 2022, 2022, 1951, 2527, 2527, 2527, 2487, 2487, + /* 150 */ 2048, 1951, 1951, 2050, 2329, 1951, 1951, 1951, 1951, 1951, + /* 160 */ 1951, 1951, 1951, 2173, 1981, 1951, 1951, 1951, 1951, 2197, + /* 170 */ 1951, 1951, 1951, 2317, 1951, 1951, 2556, 2618, 1951, 2559, + /* 180 */ 1951, 1951, 1951, 1951, 1951, 2266, 1951, 2546, 1951, 1951, + /* 190 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 2126, 2311, 1951, + /* 200 */ 1951, 1951, 2519, 2533, 2602, 2520, 2517, 2540, 1951, 2550, + /* 210 */ 1951, 2354, 1951, 2343, 2050, 1951, 2050, 2304, 2249, 1951, + /* 220 */ 2259, 1951, 2259, 2256, 1951, 1951, 1951, 2259, 2256, 2256, + /* 230 */ 2256, 2115, 2111, 1951, 2109, 1951, 1951, 1951, 1951, 2006, + /* 240 */ 1951, 2006, 1951, 2050, 2050, 1951, 2050, 1951, 1951, 2050, + /* 250 */ 1951, 2050, 1951, 2050, 2050, 1951, 2050, 1951, 1951, 1951, + /* 260 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 270 */ 1951, 1951, 1951, 1951, 1951, 1951, 2341, 2327, 1951, 2048, + /* 280 */ 1951, 2315, 2313, 1951, 2048, 2550, 1951, 1951, 2572, 2567, + /* 290 */ 2572, 2567, 2586, 2582, 2572, 2591, 2588, 2552, 2550, 2621, + /* 300 */ 2608, 2604, 2533, 1951, 1951, 2538, 2536, 1951, 2048, 2048, + /* 310 */ 1951, 2567, 1951, 1951, 1951, 1951, 2567, 1951, 1951, 2048, + /* 320 */ 1951, 2048, 1951, 1951, 1951, 2142, 1951, 1951, 2048, 1951, + /* 330 */ 1990, 1951, 2306, 2332, 2287, 2287, 2176, 2176, 2176, 2051, + /* 340 */ 1956, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 350 */ 1951, 1951, 1951, 2585, 2584, 2439, 1951, 2491, 2490, 2489, + /* 360 */ 2480, 2438, 2138, 1951, 1951, 2437, 2436, 1951, 1951, 1951, + /* 370 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 2430, 1951, + /* 380 */ 1951, 2431, 2429, 2428, 2278, 2277, 1951, 1951, 1951, 1951, + /* 390 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 400 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 410 */ 1951, 1951, 2605, 2609, 1951, 2516, 1951, 1951, 1951, 2410, + /* 420 */ 1951, 1951, 1951, 1951, 1951, 2378, 1951, 1951, 1951, 1951, + /* 430 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 440 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 450 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 460 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 470 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 480 */ 2255, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 490 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 500 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 510 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 520 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 530 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 540 */ 1951, 1951, 2270, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 550 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 560 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 570 */ 1951, 1951, 1951, 1951, 1995, 2417, 1951, 1951, 1951, 1951, + /* 580 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 2420, + /* 590 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 600 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 610 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 620 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 630 */ 2090, 2089, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 640 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 650 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 2421, 1951, + /* 660 */ 1951, 1951, 1951, 1951, 2412, 1951, 1951, 1951, 1951, 1951, + /* 670 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 680 */ 1951, 2601, 2553, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 690 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 700 */ 1951, 1951, 1951, 1951, 1951, 2410, 1951, 2583, 1951, 1951, + /* 710 */ 2599, 1951, 2603, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 720 */ 2526, 2522, 1951, 1951, 2518, 1951, 1951, 1951, 1951, 1951, + /* 730 */ 2477, 1951, 1951, 1951, 2511, 1951, 1951, 1951, 1951, 1951, + /* 740 */ 1951, 1951, 1951, 1951, 2421, 1951, 2424, 1951, 1951, 1951, + /* 750 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 2409, + /* 760 */ 1951, 2462, 2461, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 770 */ 2170, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 780 */ 1951, 1951, 1951, 1951, 1951, 1951, 2154, 2152, 2151, 2150, + /* 790 */ 1951, 2183, 1951, 1951, 1951, 2179, 2178, 1951, 1951, 1951, + /* 800 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 810 */ 1951, 1951, 1951, 2069, 1951, 1951, 1951, 1951, 1951, 1951, + /* 820 */ 1951, 1951, 2061, 1951, 2060, 1951, 1951, 1951, 1951, 1951, + /* 830 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 840 */ 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, 1951, + /* 850 */ 1951, 1951, 1980, 1951, 1951, 1951, 1951, 1951, 1951, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1540,7 +1202,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* BWLIMIT => nothing */ 0, /* START => nothing */ 0, /* TIMESTAMP => nothing */ - 301, /* END => ABORT */ + 303, /* END => ABORT */ 0, /* TABLE => nothing */ 0, /* NK_LP => nothing */ 0, /* NK_RP => nothing */ @@ -1610,7 +1272,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* VNODES => nothing */ 0, /* ALIVE => nothing */ 0, /* VIEWS => nothing */ - 301, /* VIEW => ABORT */ + 303, /* VIEW => ABORT */ 0, /* COMPACTS => nothing */ 0, /* NORMAL => nothing */ 0, /* CHILD => nothing */ @@ -1669,6 +1331,8 @@ static const YYCODETYPE yyFallback[] = { 0, /* SPLIT => nothing */ 0, /* DELETE => nothing */ 0, /* INSERT => nothing */ + 0, /* NK_BIN => nothing */ + 0, /* NK_HEX => nothing */ 0, /* NULL => nothing */ 0, /* NK_QUESTION => nothing */ 0, /* NK_ALIAS => nothing */ @@ -1737,55 +1401,55 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ABORT => nothing */ - 301, /* AFTER => ABORT */ - 301, /* ATTACH => ABORT */ - 301, /* BEFORE => ABORT */ - 301, /* BEGIN => ABORT */ - 301, /* BITAND => ABORT */ - 301, /* BITNOT => ABORT */ - 301, /* BITOR => ABORT */ - 301, /* BLOCKS => ABORT */ - 301, /* CHANGE => ABORT */ - 301, /* COMMA => ABORT */ - 301, /* CONCAT => ABORT */ - 301, /* CONFLICT => ABORT */ - 301, /* COPY => ABORT */ - 301, /* DEFERRED => ABORT */ - 301, /* DELIMITERS => ABORT */ - 301, /* DETACH => ABORT */ - 301, /* DIVIDE => ABORT */ - 301, /* DOT => ABORT */ - 301, /* EACH => ABORT */ - 301, /* FAIL => ABORT */ - 301, /* FILE => ABORT */ - 301, /* FOR => ABORT */ - 301, /* GLOB => ABORT */ - 301, /* ID => ABORT */ - 301, /* IMMEDIATE => ABORT */ - 301, /* IMPORT => ABORT */ - 301, /* INITIALLY => ABORT */ - 301, /* INSTEAD => ABORT */ - 301, /* ISNULL => ABORT */ - 301, /* KEY => ABORT */ - 301, /* MODULES => ABORT */ - 301, /* NK_BITNOT => ABORT */ - 301, /* NK_SEMI => ABORT */ - 301, /* NOTNULL => ABORT */ - 301, /* OF => ABORT */ - 301, /* PLUS => ABORT */ - 301, /* PRIVILEGE => ABORT */ - 301, /* RAISE => ABORT */ - 301, /* RESTRICT => ABORT */ - 301, /* ROW => ABORT */ - 301, /* SEMI => ABORT */ - 301, /* STAR => ABORT */ - 301, /* STATEMENT => ABORT */ - 301, /* STRICT => ABORT */ - 301, /* STRING => ABORT */ - 301, /* TIMES => ABORT */ - 301, /* VALUES => ABORT */ - 301, /* VARIABLE => ABORT */ - 301, /* WAL => ABORT */ + 303, /* AFTER => ABORT */ + 303, /* ATTACH => ABORT */ + 303, /* BEFORE => ABORT */ + 303, /* BEGIN => ABORT */ + 303, /* BITAND => ABORT */ + 303, /* BITNOT => ABORT */ + 303, /* BITOR => ABORT */ + 303, /* BLOCKS => ABORT */ + 303, /* CHANGE => ABORT */ + 303, /* COMMA => ABORT */ + 303, /* CONCAT => ABORT */ + 303, /* CONFLICT => ABORT */ + 303, /* COPY => ABORT */ + 303, /* DEFERRED => ABORT */ + 303, /* DELIMITERS => ABORT */ + 303, /* DETACH => ABORT */ + 303, /* DIVIDE => ABORT */ + 303, /* DOT => ABORT */ + 303, /* EACH => ABORT */ + 303, /* FAIL => ABORT */ + 303, /* FILE => ABORT */ + 303, /* FOR => ABORT */ + 303, /* GLOB => ABORT */ + 303, /* ID => ABORT */ + 303, /* IMMEDIATE => ABORT */ + 303, /* IMPORT => ABORT */ + 303, /* INITIALLY => ABORT */ + 303, /* INSTEAD => ABORT */ + 303, /* ISNULL => ABORT */ + 303, /* KEY => ABORT */ + 303, /* MODULES => ABORT */ + 303, /* NK_BITNOT => ABORT */ + 303, /* NK_SEMI => ABORT */ + 303, /* NOTNULL => ABORT */ + 303, /* OF => ABORT */ + 303, /* PLUS => ABORT */ + 303, /* PRIVILEGE => ABORT */ + 303, /* RAISE => ABORT */ + 303, /* RESTRICT => ABORT */ + 303, /* ROW => ABORT */ + 303, /* SEMI => ABORT */ + 303, /* STAR => ABORT */ + 303, /* STATEMENT => ABORT */ + 303, /* STRICT => ABORT */ + 303, /* STRING => ABORT */ + 303, /* TIMES => ABORT */ + 303, /* VALUES => ABORT */ + 303, /* VARIABLE => ABORT */ + 303, /* WAL => ABORT */ }; #endif /* YYFALLBACK */ @@ -1837,7 +1501,6 @@ struct yyParser { }; typedef struct yyParser yyParser; -#include #ifndef NDEBUG #include static FILE *yyTraceFILE = 0; @@ -2108,284 +1771,288 @@ static const char *const yyTokenName[] = { /* 231 */ "SPLIT", /* 232 */ "DELETE", /* 233 */ "INSERT", - /* 234 */ "NULL", - /* 235 */ "NK_QUESTION", - /* 236 */ "NK_ALIAS", - /* 237 */ "NK_ARROW", - /* 238 */ "ROWTS", - /* 239 */ "QSTART", - /* 240 */ "QEND", - /* 241 */ "QDURATION", - /* 242 */ "WSTART", - /* 243 */ "WEND", - /* 244 */ "WDURATION", - /* 245 */ "IROWTS", - /* 246 */ "ISFILLED", - /* 247 */ "CAST", - /* 248 */ "NOW", - /* 249 */ "TODAY", - /* 250 */ "TIMEZONE", - /* 251 */ "CLIENT_VERSION", - /* 252 */ "SERVER_VERSION", - /* 253 */ "SERVER_STATUS", - /* 254 */ "CURRENT_USER", - /* 255 */ "CASE", - /* 256 */ "WHEN", - /* 257 */ "THEN", - /* 258 */ "ELSE", - /* 259 */ "BETWEEN", - /* 260 */ "IS", - /* 261 */ "NK_LT", - /* 262 */ "NK_GT", - /* 263 */ "NK_LE", - /* 264 */ "NK_GE", - /* 265 */ "NK_NE", - /* 266 */ "MATCH", - /* 267 */ "NMATCH", - /* 268 */ "CONTAINS", - /* 269 */ "IN", - /* 270 */ "JOIN", - /* 271 */ "INNER", - /* 272 */ "SELECT", - /* 273 */ "NK_HINT", - /* 274 */ "DISTINCT", - /* 275 */ "WHERE", - /* 276 */ "PARTITION", - /* 277 */ "BY", - /* 278 */ "SESSION", - /* 279 */ "STATE_WINDOW", - /* 280 */ "EVENT_WINDOW", - /* 281 */ "COUNT_WINDOW", - /* 282 */ "SLIDING", - /* 283 */ "FILL", - /* 284 */ "VALUE", - /* 285 */ "VALUE_F", - /* 286 */ "NONE", - /* 287 */ "PREV", - /* 288 */ "NULL_F", - /* 289 */ "LINEAR", - /* 290 */ "NEXT", - /* 291 */ "HAVING", - /* 292 */ "RANGE", - /* 293 */ "EVERY", - /* 294 */ "ORDER", - /* 295 */ "SLIMIT", - /* 296 */ "SOFFSET", - /* 297 */ "LIMIT", - /* 298 */ "OFFSET", - /* 299 */ "ASC", - /* 300 */ "NULLS", - /* 301 */ "ABORT", - /* 302 */ "AFTER", - /* 303 */ "ATTACH", - /* 304 */ "BEFORE", - /* 305 */ "BEGIN", - /* 306 */ "BITAND", - /* 307 */ "BITNOT", - /* 308 */ "BITOR", - /* 309 */ "BLOCKS", - /* 310 */ "CHANGE", - /* 311 */ "COMMA", - /* 312 */ "CONCAT", - /* 313 */ "CONFLICT", - /* 314 */ "COPY", - /* 315 */ "DEFERRED", - /* 316 */ "DELIMITERS", - /* 317 */ "DETACH", - /* 318 */ "DIVIDE", - /* 319 */ "DOT", - /* 320 */ "EACH", - /* 321 */ "FAIL", - /* 322 */ "FILE", - /* 323 */ "FOR", - /* 324 */ "GLOB", - /* 325 */ "ID", - /* 326 */ "IMMEDIATE", - /* 327 */ "IMPORT", - /* 328 */ "INITIALLY", - /* 329 */ "INSTEAD", - /* 330 */ "ISNULL", - /* 331 */ "KEY", - /* 332 */ "MODULES", - /* 333 */ "NK_BITNOT", - /* 334 */ "NK_SEMI", - /* 335 */ "NOTNULL", - /* 336 */ "OF", - /* 337 */ "PLUS", - /* 338 */ "PRIVILEGE", - /* 339 */ "RAISE", - /* 340 */ "RESTRICT", - /* 341 */ "ROW", - /* 342 */ "SEMI", - /* 343 */ "STAR", - /* 344 */ "STATEMENT", - /* 345 */ "STRICT", - /* 346 */ "STRING", - /* 347 */ "TIMES", - /* 348 */ "VALUES", - /* 349 */ "VARIABLE", - /* 350 */ "WAL", - /* 351 */ "cmd", - /* 352 */ "account_options", - /* 353 */ "alter_account_options", - /* 354 */ "literal", - /* 355 */ "alter_account_option", - /* 356 */ "ip_range_list", - /* 357 */ "white_list", - /* 358 */ "white_list_opt", - /* 359 */ "user_name", - /* 360 */ "sysinfo_opt", - /* 361 */ "privileges", - /* 362 */ "priv_level", - /* 363 */ "with_opt", - /* 364 */ "priv_type_list", - /* 365 */ "priv_type", - /* 366 */ "db_name", - /* 367 */ "table_name", - /* 368 */ "topic_name", - /* 369 */ "search_condition", - /* 370 */ "dnode_endpoint", - /* 371 */ "force_opt", - /* 372 */ "unsafe_opt", - /* 373 */ "not_exists_opt", - /* 374 */ "db_options", - /* 375 */ "exists_opt", - /* 376 */ "alter_db_options", - /* 377 */ "speed_opt", - /* 378 */ "start_opt", - /* 379 */ "end_opt", - /* 380 */ "integer_list", - /* 381 */ "variable_list", - /* 382 */ "retention_list", - /* 383 */ "signed", - /* 384 */ "alter_db_option", - /* 385 */ "retention", - /* 386 */ "full_table_name", - /* 387 */ "column_def_list", - /* 388 */ "tags_def_opt", - /* 389 */ "table_options", - /* 390 */ "multi_create_clause", - /* 391 */ "tags_def", - /* 392 */ "multi_drop_clause", - /* 393 */ "alter_table_clause", - /* 394 */ "alter_table_options", - /* 395 */ "column_name", - /* 396 */ "type_name", - /* 397 */ "signed_literal", - /* 398 */ "create_subtable_clause", - /* 399 */ "specific_cols_opt", - /* 400 */ "expression_list", - /* 401 */ "drop_table_clause", - /* 402 */ "col_name_list", - /* 403 */ "column_def", - /* 404 */ "duration_list", - /* 405 */ "rollup_func_list", - /* 406 */ "alter_table_option", - /* 407 */ "duration_literal", - /* 408 */ "rollup_func_name", - /* 409 */ "function_name", - /* 410 */ "col_name", - /* 411 */ "db_kind_opt", - /* 412 */ "table_kind_db_name_cond_opt", - /* 413 */ "like_pattern_opt", - /* 414 */ "db_name_cond_opt", - /* 415 */ "table_name_cond", - /* 416 */ "from_db_opt", - /* 417 */ "tag_list_opt", - /* 418 */ "table_kind", - /* 419 */ "tag_item", - /* 420 */ "column_alias", - /* 421 */ "index_options", - /* 422 */ "full_index_name", - /* 423 */ "index_name", - /* 424 */ "func_list", - /* 425 */ "sliding_opt", - /* 426 */ "sma_stream_opt", - /* 427 */ "func", - /* 428 */ "sma_func_name", - /* 429 */ "with_meta", - /* 430 */ "query_or_subquery", - /* 431 */ "where_clause_opt", - /* 432 */ "cgroup_name", - /* 433 */ "analyze_opt", - /* 434 */ "explain_options", - /* 435 */ "insert_query", - /* 436 */ "or_replace_opt", - /* 437 */ "agg_func_opt", - /* 438 */ "bufsize_opt", - /* 439 */ "language_opt", - /* 440 */ "full_view_name", - /* 441 */ "view_name", - /* 442 */ "stream_name", - /* 443 */ "stream_options", - /* 444 */ "col_list_opt", - /* 445 */ "tag_def_or_ref_opt", - /* 446 */ "subtable_opt", - /* 447 */ "ignore_opt", - /* 448 */ "expression", - /* 449 */ "on_vgroup_id", - /* 450 */ "dnode_list", - /* 451 */ "literal_func", - /* 452 */ "literal_list", - /* 453 */ "table_alias", - /* 454 */ "expr_or_subquery", - /* 455 */ "pseudo_column", - /* 456 */ "column_reference", - /* 457 */ "function_expression", - /* 458 */ "case_when_expression", - /* 459 */ "star_func", - /* 460 */ "star_func_para_list", - /* 461 */ "noarg_func", - /* 462 */ "other_para_list", - /* 463 */ "star_func_para", - /* 464 */ "when_then_list", - /* 465 */ "case_when_else_opt", - /* 466 */ "common_expression", - /* 467 */ "when_then_expr", - /* 468 */ "predicate", - /* 469 */ "compare_op", - /* 470 */ "in_op", - /* 471 */ "in_predicate_value", - /* 472 */ "boolean_value_expression", - /* 473 */ "boolean_primary", - /* 474 */ "from_clause_opt", - /* 475 */ "table_reference_list", - /* 476 */ "table_reference", - /* 477 */ "table_primary", - /* 478 */ "joined_table", - /* 479 */ "alias_opt", - /* 480 */ "subquery", - /* 481 */ "parenthesized_joined_table", - /* 482 */ "join_type", - /* 483 */ "query_specification", - /* 484 */ "hint_list", - /* 485 */ "set_quantifier_opt", - /* 486 */ "tag_mode_opt", - /* 487 */ "select_list", - /* 488 */ "partition_by_clause_opt", - /* 489 */ "range_opt", - /* 490 */ "every_opt", - /* 491 */ "fill_opt", - /* 492 */ "twindow_clause_opt", - /* 493 */ "group_by_clause_opt", - /* 494 */ "having_clause_opt", - /* 495 */ "select_item", - /* 496 */ "partition_list", - /* 497 */ "partition_item", - /* 498 */ "interval_sliding_duration_literal", - /* 499 */ "fill_mode", - /* 500 */ "group_by_list", - /* 501 */ "query_expression", - /* 502 */ "query_simple", - /* 503 */ "order_by_clause_opt", - /* 504 */ "slimit_clause_opt", - /* 505 */ "limit_clause_opt", - /* 506 */ "union_query_expression", - /* 507 */ "query_simple_or_subquery", - /* 508 */ "sort_specification_list", - /* 509 */ "sort_specification", - /* 510 */ "ordering_specification_opt", - /* 511 */ "null_ordering_opt", + /* 234 */ "NK_BIN", + /* 235 */ "NK_HEX", + /* 236 */ "NULL", + /* 237 */ "NK_QUESTION", + /* 238 */ "NK_ALIAS", + /* 239 */ "NK_ARROW", + /* 240 */ "ROWTS", + /* 241 */ "QSTART", + /* 242 */ "QEND", + /* 243 */ "QDURATION", + /* 244 */ "WSTART", + /* 245 */ "WEND", + /* 246 */ "WDURATION", + /* 247 */ "IROWTS", + /* 248 */ "ISFILLED", + /* 249 */ "CAST", + /* 250 */ "NOW", + /* 251 */ "TODAY", + /* 252 */ "TIMEZONE", + /* 253 */ "CLIENT_VERSION", + /* 254 */ "SERVER_VERSION", + /* 255 */ "SERVER_STATUS", + /* 256 */ "CURRENT_USER", + /* 257 */ "CASE", + /* 258 */ "WHEN", + /* 259 */ "THEN", + /* 260 */ "ELSE", + /* 261 */ "BETWEEN", + /* 262 */ "IS", + /* 263 */ "NK_LT", + /* 264 */ "NK_GT", + /* 265 */ "NK_LE", + /* 266 */ "NK_GE", + /* 267 */ "NK_NE", + /* 268 */ "MATCH", + /* 269 */ "NMATCH", + /* 270 */ "CONTAINS", + /* 271 */ "IN", + /* 272 */ "JOIN", + /* 273 */ "INNER", + /* 274 */ "SELECT", + /* 275 */ "NK_HINT", + /* 276 */ "DISTINCT", + /* 277 */ "WHERE", + /* 278 */ "PARTITION", + /* 279 */ "BY", + /* 280 */ "SESSION", + /* 281 */ "STATE_WINDOW", + /* 282 */ "EVENT_WINDOW", + /* 283 */ "COUNT_WINDOW", + /* 284 */ "SLIDING", + /* 285 */ "FILL", + /* 286 */ "VALUE", + /* 287 */ "VALUE_F", + /* 288 */ "NONE", + /* 289 */ "PREV", + /* 290 */ "NULL_F", + /* 291 */ "LINEAR", + /* 292 */ "NEXT", + /* 293 */ "HAVING", + /* 294 */ "RANGE", + /* 295 */ "EVERY", + /* 296 */ "ORDER", + /* 297 */ "SLIMIT", + /* 298 */ "SOFFSET", + /* 299 */ "LIMIT", + /* 300 */ "OFFSET", + /* 301 */ "ASC", + /* 302 */ "NULLS", + /* 303 */ "ABORT", + /* 304 */ "AFTER", + /* 305 */ "ATTACH", + /* 306 */ "BEFORE", + /* 307 */ "BEGIN", + /* 308 */ "BITAND", + /* 309 */ "BITNOT", + /* 310 */ "BITOR", + /* 311 */ "BLOCKS", + /* 312 */ "CHANGE", + /* 313 */ "COMMA", + /* 314 */ "CONCAT", + /* 315 */ "CONFLICT", + /* 316 */ "COPY", + /* 317 */ "DEFERRED", + /* 318 */ "DELIMITERS", + /* 319 */ "DETACH", + /* 320 */ "DIVIDE", + /* 321 */ "DOT", + /* 322 */ "EACH", + /* 323 */ "FAIL", + /* 324 */ "FILE", + /* 325 */ "FOR", + /* 326 */ "GLOB", + /* 327 */ "ID", + /* 328 */ "IMMEDIATE", + /* 329 */ "IMPORT", + /* 330 */ "INITIALLY", + /* 331 */ "INSTEAD", + /* 332 */ "ISNULL", + /* 333 */ "KEY", + /* 334 */ "MODULES", + /* 335 */ "NK_BITNOT", + /* 336 */ "NK_SEMI", + /* 337 */ "NOTNULL", + /* 338 */ "OF", + /* 339 */ "PLUS", + /* 340 */ "PRIVILEGE", + /* 341 */ "RAISE", + /* 342 */ "RESTRICT", + /* 343 */ "ROW", + /* 344 */ "SEMI", + /* 345 */ "STAR", + /* 346 */ "STATEMENT", + /* 347 */ "STRICT", + /* 348 */ "STRING", + /* 349 */ "TIMES", + /* 350 */ "VALUES", + /* 351 */ "VARIABLE", + /* 352 */ "WAL", + /* 353 */ "cmd", + /* 354 */ "account_options", + /* 355 */ "alter_account_options", + /* 356 */ "literal", + /* 357 */ "alter_account_option", + /* 358 */ "ip_range_list", + /* 359 */ "white_list", + /* 360 */ "white_list_opt", + /* 361 */ "user_name", + /* 362 */ "sysinfo_opt", + /* 363 */ "privileges", + /* 364 */ "priv_level", + /* 365 */ "with_opt", + /* 366 */ "priv_type_list", + /* 367 */ "priv_type", + /* 368 */ "db_name", + /* 369 */ "table_name", + /* 370 */ "topic_name", + /* 371 */ "search_condition", + /* 372 */ "dnode_endpoint", + /* 373 */ "force_opt", + /* 374 */ "unsafe_opt", + /* 375 */ "not_exists_opt", + /* 376 */ "db_options", + /* 377 */ "exists_opt", + /* 378 */ "alter_db_options", + /* 379 */ "speed_opt", + /* 380 */ "start_opt", + /* 381 */ "end_opt", + /* 382 */ "integer_list", + /* 383 */ "variable_list", + /* 384 */ "retention_list", + /* 385 */ "signed", + /* 386 */ "alter_db_option", + /* 387 */ "retention", + /* 388 */ "full_table_name", + /* 389 */ "column_def_list", + /* 390 */ "tags_def_opt", + /* 391 */ "table_options", + /* 392 */ "multi_create_clause", + /* 393 */ "tags_def", + /* 394 */ "multi_drop_clause", + /* 395 */ "alter_table_clause", + /* 396 */ "alter_table_options", + /* 397 */ "column_name", + /* 398 */ "type_name", + /* 399 */ "tags_literal", + /* 400 */ "create_subtable_clause", + /* 401 */ "specific_cols_opt", + /* 402 */ "tags_literal_list", + /* 403 */ "drop_table_clause", + /* 404 */ "col_name_list", + /* 405 */ "column_def", + /* 406 */ "duration_list", + /* 407 */ "rollup_func_list", + /* 408 */ "alter_table_option", + /* 409 */ "duration_literal", + /* 410 */ "rollup_func_name", + /* 411 */ "function_name", + /* 412 */ "col_name", + /* 413 */ "db_kind_opt", + /* 414 */ "table_kind_db_name_cond_opt", + /* 415 */ "like_pattern_opt", + /* 416 */ "db_name_cond_opt", + /* 417 */ "table_name_cond", + /* 418 */ "from_db_opt", + /* 419 */ "tag_list_opt", + /* 420 */ "table_kind", + /* 421 */ "tag_item", + /* 422 */ "column_alias", + /* 423 */ "index_options", + /* 424 */ "full_index_name", + /* 425 */ "index_name", + /* 426 */ "func_list", + /* 427 */ "sliding_opt", + /* 428 */ "sma_stream_opt", + /* 429 */ "func", + /* 430 */ "sma_func_name", + /* 431 */ "expression_list", + /* 432 */ "with_meta", + /* 433 */ "query_or_subquery", + /* 434 */ "where_clause_opt", + /* 435 */ "cgroup_name", + /* 436 */ "analyze_opt", + /* 437 */ "explain_options", + /* 438 */ "insert_query", + /* 439 */ "or_replace_opt", + /* 440 */ "agg_func_opt", + /* 441 */ "bufsize_opt", + /* 442 */ "language_opt", + /* 443 */ "full_view_name", + /* 444 */ "view_name", + /* 445 */ "stream_name", + /* 446 */ "stream_options", + /* 447 */ "col_list_opt", + /* 448 */ "tag_def_or_ref_opt", + /* 449 */ "subtable_opt", + /* 450 */ "ignore_opt", + /* 451 */ "expression", + /* 452 */ "on_vgroup_id", + /* 453 */ "dnode_list", + /* 454 */ "literal_func", + /* 455 */ "signed_literal", + /* 456 */ "literal_list", + /* 457 */ "table_alias", + /* 458 */ "expr_or_subquery", + /* 459 */ "pseudo_column", + /* 460 */ "column_reference", + /* 461 */ "function_expression", + /* 462 */ "case_when_expression", + /* 463 */ "star_func", + /* 464 */ "star_func_para_list", + /* 465 */ "noarg_func", + /* 466 */ "other_para_list", + /* 467 */ "star_func_para", + /* 468 */ "when_then_list", + /* 469 */ "case_when_else_opt", + /* 470 */ "common_expression", + /* 471 */ "when_then_expr", + /* 472 */ "predicate", + /* 473 */ "compare_op", + /* 474 */ "in_op", + /* 475 */ "in_predicate_value", + /* 476 */ "boolean_value_expression", + /* 477 */ "boolean_primary", + /* 478 */ "from_clause_opt", + /* 479 */ "table_reference_list", + /* 480 */ "table_reference", + /* 481 */ "table_primary", + /* 482 */ "joined_table", + /* 483 */ "alias_opt", + /* 484 */ "subquery", + /* 485 */ "parenthesized_joined_table", + /* 486 */ "join_type", + /* 487 */ "query_specification", + /* 488 */ "hint_list", + /* 489 */ "set_quantifier_opt", + /* 490 */ "tag_mode_opt", + /* 491 */ "select_list", + /* 492 */ "partition_by_clause_opt", + /* 493 */ "range_opt", + /* 494 */ "every_opt", + /* 495 */ "fill_opt", + /* 496 */ "twindow_clause_opt", + /* 497 */ "group_by_clause_opt", + /* 498 */ "having_clause_opt", + /* 499 */ "select_item", + /* 500 */ "partition_list", + /* 501 */ "partition_item", + /* 502 */ "interval_sliding_duration_literal", + /* 503 */ "fill_mode", + /* 504 */ "group_by_list", + /* 505 */ "query_expression", + /* 506 */ "query_simple", + /* 507 */ "order_by_clause_opt", + /* 508 */ "slimit_clause_opt", + /* 509 */ "limit_clause_opt", + /* 510 */ "union_query_expression", + /* 511 */ "query_simple_or_subquery", + /* 512 */ "sort_specification_list", + /* 513 */ "sort_specification", + /* 514 */ "ordering_specification_opt", + /* 515 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -2574,10 +2241,10 @@ static const char *const yyRuleName[] = { /* 178 */ "alter_table_clause ::= full_table_name DROP TAG column_name", /* 179 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", /* 180 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 181 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", + /* 181 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal", /* 182 */ "multi_create_clause ::= create_subtable_clause", /* 183 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 184 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options", + /* 184 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP tags_literal_list NK_RP table_options", /* 185 */ "multi_drop_clause ::= drop_table_clause", /* 186 */ "multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause", /* 187 */ "drop_table_clause ::= exists_opt full_table_name", @@ -2802,246 +2469,267 @@ static const char *const yyRuleName[] = { /* 406 */ "cmd ::= insert_query", /* 407 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", /* 408 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", - /* 409 */ "literal ::= NK_INTEGER", - /* 410 */ "literal ::= NK_FLOAT", - /* 411 */ "literal ::= NK_STRING", - /* 412 */ "literal ::= NK_BOOL", - /* 413 */ "literal ::= TIMESTAMP NK_STRING", - /* 414 */ "literal ::= duration_literal", - /* 415 */ "literal ::= NULL", - /* 416 */ "literal ::= NK_QUESTION", - /* 417 */ "duration_literal ::= NK_VARIABLE", - /* 418 */ "signed ::= NK_INTEGER", - /* 419 */ "signed ::= NK_PLUS NK_INTEGER", - /* 420 */ "signed ::= NK_MINUS NK_INTEGER", - /* 421 */ "signed ::= NK_FLOAT", - /* 422 */ "signed ::= NK_PLUS NK_FLOAT", - /* 423 */ "signed ::= NK_MINUS NK_FLOAT", - /* 424 */ "signed_literal ::= signed", - /* 425 */ "signed_literal ::= NK_STRING", - /* 426 */ "signed_literal ::= NK_BOOL", - /* 427 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 428 */ "signed_literal ::= duration_literal", - /* 429 */ "signed_literal ::= NULL", - /* 430 */ "signed_literal ::= literal_func", - /* 431 */ "signed_literal ::= NK_QUESTION", - /* 432 */ "literal_list ::= signed_literal", - /* 433 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 434 */ "db_name ::= NK_ID", - /* 435 */ "table_name ::= NK_ID", - /* 436 */ "column_name ::= NK_ID", - /* 437 */ "function_name ::= NK_ID", - /* 438 */ "view_name ::= NK_ID", - /* 439 */ "table_alias ::= NK_ID", - /* 440 */ "column_alias ::= NK_ID", - /* 441 */ "column_alias ::= NK_ALIAS", - /* 442 */ "user_name ::= NK_ID", - /* 443 */ "topic_name ::= NK_ID", - /* 444 */ "stream_name ::= NK_ID", - /* 445 */ "cgroup_name ::= NK_ID", - /* 446 */ "index_name ::= NK_ID", - /* 447 */ "expr_or_subquery ::= expression", - /* 448 */ "expression ::= literal", - /* 449 */ "expression ::= pseudo_column", - /* 450 */ "expression ::= column_reference", - /* 451 */ "expression ::= function_expression", - /* 452 */ "expression ::= case_when_expression", - /* 453 */ "expression ::= NK_LP expression NK_RP", - /* 454 */ "expression ::= NK_PLUS expr_or_subquery", - /* 455 */ "expression ::= NK_MINUS expr_or_subquery", - /* 456 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 457 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 458 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 459 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 460 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 461 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 462 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 463 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 464 */ "expression_list ::= expr_or_subquery", - /* 465 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 466 */ "column_reference ::= column_name", - /* 467 */ "column_reference ::= table_name NK_DOT column_name", - /* 468 */ "column_reference ::= NK_ALIAS", - /* 469 */ "column_reference ::= table_name NK_DOT NK_ALIAS", - /* 470 */ "pseudo_column ::= ROWTS", - /* 471 */ "pseudo_column ::= TBNAME", - /* 472 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 473 */ "pseudo_column ::= QSTART", - /* 474 */ "pseudo_column ::= QEND", - /* 475 */ "pseudo_column ::= QDURATION", - /* 476 */ "pseudo_column ::= WSTART", - /* 477 */ "pseudo_column ::= WEND", - /* 478 */ "pseudo_column ::= WDURATION", - /* 479 */ "pseudo_column ::= IROWTS", - /* 480 */ "pseudo_column ::= ISFILLED", - /* 481 */ "pseudo_column ::= QTAGS", - /* 482 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 483 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 484 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 485 */ "function_expression ::= literal_func", - /* 486 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 487 */ "literal_func ::= NOW", - /* 488 */ "noarg_func ::= NOW", - /* 489 */ "noarg_func ::= TODAY", - /* 490 */ "noarg_func ::= TIMEZONE", - /* 491 */ "noarg_func ::= DATABASE", - /* 492 */ "noarg_func ::= CLIENT_VERSION", - /* 493 */ "noarg_func ::= SERVER_VERSION", - /* 494 */ "noarg_func ::= SERVER_STATUS", - /* 495 */ "noarg_func ::= CURRENT_USER", - /* 496 */ "noarg_func ::= USER", - /* 497 */ "star_func ::= COUNT", - /* 498 */ "star_func ::= FIRST", - /* 499 */ "star_func ::= LAST", - /* 500 */ "star_func ::= LAST_ROW", - /* 501 */ "star_func_para_list ::= NK_STAR", - /* 502 */ "star_func_para_list ::= other_para_list", - /* 503 */ "other_para_list ::= star_func_para", - /* 504 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 505 */ "star_func_para ::= expr_or_subquery", - /* 506 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 507 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 508 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 509 */ "when_then_list ::= when_then_expr", - /* 510 */ "when_then_list ::= when_then_list when_then_expr", - /* 511 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 512 */ "case_when_else_opt ::=", - /* 513 */ "case_when_else_opt ::= ELSE common_expression", - /* 514 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 515 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 516 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 517 */ "predicate ::= expr_or_subquery IS NULL", - /* 518 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 519 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 520 */ "compare_op ::= NK_LT", - /* 521 */ "compare_op ::= NK_GT", - /* 522 */ "compare_op ::= NK_LE", - /* 523 */ "compare_op ::= NK_GE", - /* 524 */ "compare_op ::= NK_NE", - /* 525 */ "compare_op ::= NK_EQ", - /* 526 */ "compare_op ::= LIKE", - /* 527 */ "compare_op ::= NOT LIKE", - /* 528 */ "compare_op ::= MATCH", - /* 529 */ "compare_op ::= NMATCH", - /* 530 */ "compare_op ::= CONTAINS", - /* 531 */ "in_op ::= IN", - /* 532 */ "in_op ::= NOT IN", - /* 533 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 534 */ "boolean_value_expression ::= boolean_primary", - /* 535 */ "boolean_value_expression ::= NOT boolean_primary", - /* 536 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 537 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 538 */ "boolean_primary ::= predicate", - /* 539 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 540 */ "common_expression ::= expr_or_subquery", - /* 541 */ "common_expression ::= boolean_value_expression", - /* 542 */ "from_clause_opt ::=", - /* 543 */ "from_clause_opt ::= FROM table_reference_list", - /* 544 */ "table_reference_list ::= table_reference", - /* 545 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 546 */ "table_reference ::= table_primary", - /* 547 */ "table_reference ::= joined_table", - /* 548 */ "table_primary ::= table_name alias_opt", - /* 549 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 550 */ "table_primary ::= subquery alias_opt", - /* 551 */ "table_primary ::= parenthesized_joined_table", - /* 552 */ "alias_opt ::=", - /* 553 */ "alias_opt ::= table_alias", - /* 554 */ "alias_opt ::= AS table_alias", - /* 555 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 556 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 557 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 558 */ "join_type ::=", - /* 559 */ "join_type ::= INNER", - /* 560 */ "query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_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", - /* 561 */ "hint_list ::=", - /* 562 */ "hint_list ::= NK_HINT", - /* 563 */ "tag_mode_opt ::=", - /* 564 */ "tag_mode_opt ::= TAGS", - /* 565 */ "set_quantifier_opt ::=", - /* 566 */ "set_quantifier_opt ::= DISTINCT", - /* 567 */ "set_quantifier_opt ::= ALL", - /* 568 */ "select_list ::= select_item", - /* 569 */ "select_list ::= select_list NK_COMMA select_item", - /* 570 */ "select_item ::= NK_STAR", - /* 571 */ "select_item ::= common_expression", - /* 572 */ "select_item ::= common_expression column_alias", - /* 573 */ "select_item ::= common_expression AS column_alias", - /* 574 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 575 */ "where_clause_opt ::=", - /* 576 */ "where_clause_opt ::= WHERE search_condition", - /* 577 */ "partition_by_clause_opt ::=", - /* 578 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 579 */ "partition_list ::= partition_item", - /* 580 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 581 */ "partition_item ::= expr_or_subquery", - /* 582 */ "partition_item ::= expr_or_subquery column_alias", - /* 583 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 584 */ "twindow_clause_opt ::=", - /* 585 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", - /* 586 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 587 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 588 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 589 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", - /* 590 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP", - /* 591 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 592 */ "sliding_opt ::=", - /* 593 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", - /* 594 */ "interval_sliding_duration_literal ::= NK_VARIABLE", - /* 595 */ "interval_sliding_duration_literal ::= NK_STRING", - /* 596 */ "interval_sliding_duration_literal ::= NK_INTEGER", - /* 597 */ "fill_opt ::=", - /* 598 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 599 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", - /* 600 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", - /* 601 */ "fill_mode ::= NONE", - /* 602 */ "fill_mode ::= PREV", - /* 603 */ "fill_mode ::= NULL", - /* 604 */ "fill_mode ::= NULL_F", - /* 605 */ "fill_mode ::= LINEAR", - /* 606 */ "fill_mode ::= NEXT", - /* 607 */ "group_by_clause_opt ::=", - /* 608 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 609 */ "group_by_list ::= expr_or_subquery", - /* 610 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 611 */ "having_clause_opt ::=", - /* 612 */ "having_clause_opt ::= HAVING search_condition", - /* 613 */ "range_opt ::=", - /* 614 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 615 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", - /* 616 */ "every_opt ::=", - /* 617 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 618 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 619 */ "query_simple ::= query_specification", - /* 620 */ "query_simple ::= union_query_expression", - /* 621 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 622 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 623 */ "query_simple_or_subquery ::= query_simple", - /* 624 */ "query_simple_or_subquery ::= subquery", - /* 625 */ "query_or_subquery ::= query_expression", - /* 626 */ "query_or_subquery ::= subquery", - /* 627 */ "order_by_clause_opt ::=", - /* 628 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 629 */ "slimit_clause_opt ::=", - /* 630 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 631 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 632 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 633 */ "limit_clause_opt ::=", - /* 634 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 635 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 636 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 637 */ "subquery ::= NK_LP query_expression NK_RP", - /* 638 */ "subquery ::= NK_LP subquery NK_RP", - /* 639 */ "search_condition ::= common_expression", - /* 640 */ "sort_specification_list ::= sort_specification", - /* 641 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 642 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 643 */ "ordering_specification_opt ::=", - /* 644 */ "ordering_specification_opt ::= ASC", - /* 645 */ "ordering_specification_opt ::= DESC", - /* 646 */ "null_ordering_opt ::=", - /* 647 */ "null_ordering_opt ::= NULLS FIRST", - /* 648 */ "null_ordering_opt ::= NULLS LAST", + /* 409 */ "tags_literal ::= NK_INTEGER", + /* 410 */ "tags_literal ::= NK_PLUS NK_INTEGER", + /* 411 */ "tags_literal ::= NK_MINUS NK_INTEGER", + /* 412 */ "tags_literal ::= NK_FLOAT", + /* 413 */ "tags_literal ::= NK_PLUS NK_FLOAT", + /* 414 */ "tags_literal ::= NK_MINUS NK_FLOAT", + /* 415 */ "tags_literal ::= NK_BIN", + /* 416 */ "tags_literal ::= NK_PLUS NK_BIN", + /* 417 */ "tags_literal ::= NK_MINUS NK_BIN", + /* 418 */ "tags_literal ::= NK_HEX", + /* 419 */ "tags_literal ::= NK_PLUS NK_HEX", + /* 420 */ "tags_literal ::= NK_MINUS NK_HEX", + /* 421 */ "tags_literal ::= NK_STRING", + /* 422 */ "tags_literal ::= NK_BOOL", + /* 423 */ "tags_literal ::= NULL", + /* 424 */ "tags_literal ::= literal_func", + /* 425 */ "tags_literal ::= literal_func NK_PLUS duration_literal", + /* 426 */ "tags_literal ::= literal_func NK_MINUS duration_literal", + /* 427 */ "tags_literal_list ::= tags_literal", + /* 428 */ "tags_literal_list ::= tags_literal_list NK_COMMA tags_literal", + /* 429 */ "literal ::= NK_INTEGER", + /* 430 */ "literal ::= NK_FLOAT", + /* 431 */ "literal ::= NK_STRING", + /* 432 */ "literal ::= NK_BOOL", + /* 433 */ "literal ::= TIMESTAMP NK_STRING", + /* 434 */ "literal ::= duration_literal", + /* 435 */ "literal ::= NULL", + /* 436 */ "literal ::= NK_QUESTION", + /* 437 */ "duration_literal ::= NK_VARIABLE", + /* 438 */ "signed ::= NK_INTEGER", + /* 439 */ "signed ::= NK_PLUS NK_INTEGER", + /* 440 */ "signed ::= NK_MINUS NK_INTEGER", + /* 441 */ "signed ::= NK_FLOAT", + /* 442 */ "signed ::= NK_PLUS NK_FLOAT", + /* 443 */ "signed ::= NK_MINUS NK_FLOAT", + /* 444 */ "signed_literal ::= signed", + /* 445 */ "signed_literal ::= NK_STRING", + /* 446 */ "signed_literal ::= NK_BOOL", + /* 447 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 448 */ "signed_literal ::= duration_literal", + /* 449 */ "signed_literal ::= NULL", + /* 450 */ "signed_literal ::= literal_func", + /* 451 */ "signed_literal ::= NK_QUESTION", + /* 452 */ "literal_list ::= signed_literal", + /* 453 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 454 */ "db_name ::= NK_ID", + /* 455 */ "table_name ::= NK_ID", + /* 456 */ "column_name ::= NK_ID", + /* 457 */ "function_name ::= NK_ID", + /* 458 */ "view_name ::= NK_ID", + /* 459 */ "table_alias ::= NK_ID", + /* 460 */ "column_alias ::= NK_ID", + /* 461 */ "column_alias ::= NK_ALIAS", + /* 462 */ "user_name ::= NK_ID", + /* 463 */ "topic_name ::= NK_ID", + /* 464 */ "stream_name ::= NK_ID", + /* 465 */ "cgroup_name ::= NK_ID", + /* 466 */ "index_name ::= NK_ID", + /* 467 */ "expr_or_subquery ::= expression", + /* 468 */ "expression ::= literal", + /* 469 */ "expression ::= pseudo_column", + /* 470 */ "expression ::= column_reference", + /* 471 */ "expression ::= function_expression", + /* 472 */ "expression ::= case_when_expression", + /* 473 */ "expression ::= NK_LP expression NK_RP", + /* 474 */ "expression ::= NK_PLUS expr_or_subquery", + /* 475 */ "expression ::= NK_MINUS expr_or_subquery", + /* 476 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 477 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 478 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 479 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 480 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 481 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 482 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 483 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 484 */ "expression_list ::= expr_or_subquery", + /* 485 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 486 */ "column_reference ::= column_name", + /* 487 */ "column_reference ::= table_name NK_DOT column_name", + /* 488 */ "column_reference ::= NK_ALIAS", + /* 489 */ "column_reference ::= table_name NK_DOT NK_ALIAS", + /* 490 */ "pseudo_column ::= ROWTS", + /* 491 */ "pseudo_column ::= TBNAME", + /* 492 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 493 */ "pseudo_column ::= QSTART", + /* 494 */ "pseudo_column ::= QEND", + /* 495 */ "pseudo_column ::= QDURATION", + /* 496 */ "pseudo_column ::= WSTART", + /* 497 */ "pseudo_column ::= WEND", + /* 498 */ "pseudo_column ::= WDURATION", + /* 499 */ "pseudo_column ::= IROWTS", + /* 500 */ "pseudo_column ::= ISFILLED", + /* 501 */ "pseudo_column ::= QTAGS", + /* 502 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 503 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 504 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 505 */ "function_expression ::= literal_func", + /* 506 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 507 */ "literal_func ::= NOW", + /* 508 */ "literal_func ::= TODAY", + /* 509 */ "noarg_func ::= NOW", + /* 510 */ "noarg_func ::= TODAY", + /* 511 */ "noarg_func ::= TIMEZONE", + /* 512 */ "noarg_func ::= DATABASE", + /* 513 */ "noarg_func ::= CLIENT_VERSION", + /* 514 */ "noarg_func ::= SERVER_VERSION", + /* 515 */ "noarg_func ::= SERVER_STATUS", + /* 516 */ "noarg_func ::= CURRENT_USER", + /* 517 */ "noarg_func ::= USER", + /* 518 */ "star_func ::= COUNT", + /* 519 */ "star_func ::= FIRST", + /* 520 */ "star_func ::= LAST", + /* 521 */ "star_func ::= LAST_ROW", + /* 522 */ "star_func_para_list ::= NK_STAR", + /* 523 */ "star_func_para_list ::= other_para_list", + /* 524 */ "other_para_list ::= star_func_para", + /* 525 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 526 */ "star_func_para ::= expr_or_subquery", + /* 527 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 528 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 529 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 530 */ "when_then_list ::= when_then_expr", + /* 531 */ "when_then_list ::= when_then_list when_then_expr", + /* 532 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 533 */ "case_when_else_opt ::=", + /* 534 */ "case_when_else_opt ::= ELSE common_expression", + /* 535 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 536 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 537 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 538 */ "predicate ::= expr_or_subquery IS NULL", + /* 539 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 540 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 541 */ "compare_op ::= NK_LT", + /* 542 */ "compare_op ::= NK_GT", + /* 543 */ "compare_op ::= NK_LE", + /* 544 */ "compare_op ::= NK_GE", + /* 545 */ "compare_op ::= NK_NE", + /* 546 */ "compare_op ::= NK_EQ", + /* 547 */ "compare_op ::= LIKE", + /* 548 */ "compare_op ::= NOT LIKE", + /* 549 */ "compare_op ::= MATCH", + /* 550 */ "compare_op ::= NMATCH", + /* 551 */ "compare_op ::= CONTAINS", + /* 552 */ "in_op ::= IN", + /* 553 */ "in_op ::= NOT IN", + /* 554 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 555 */ "boolean_value_expression ::= boolean_primary", + /* 556 */ "boolean_value_expression ::= NOT boolean_primary", + /* 557 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 558 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 559 */ "boolean_primary ::= predicate", + /* 560 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 561 */ "common_expression ::= expr_or_subquery", + /* 562 */ "common_expression ::= boolean_value_expression", + /* 563 */ "from_clause_opt ::=", + /* 564 */ "from_clause_opt ::= FROM table_reference_list", + /* 565 */ "table_reference_list ::= table_reference", + /* 566 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 567 */ "table_reference ::= table_primary", + /* 568 */ "table_reference ::= joined_table", + /* 569 */ "table_primary ::= table_name alias_opt", + /* 570 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 571 */ "table_primary ::= subquery alias_opt", + /* 572 */ "table_primary ::= parenthesized_joined_table", + /* 573 */ "alias_opt ::=", + /* 574 */ "alias_opt ::= table_alias", + /* 575 */ "alias_opt ::= AS table_alias", + /* 576 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 577 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 578 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 579 */ "join_type ::=", + /* 580 */ "join_type ::= INNER", + /* 581 */ "query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_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", + /* 582 */ "hint_list ::=", + /* 583 */ "hint_list ::= NK_HINT", + /* 584 */ "tag_mode_opt ::=", + /* 585 */ "tag_mode_opt ::= TAGS", + /* 586 */ "set_quantifier_opt ::=", + /* 587 */ "set_quantifier_opt ::= DISTINCT", + /* 588 */ "set_quantifier_opt ::= ALL", + /* 589 */ "select_list ::= select_item", + /* 590 */ "select_list ::= select_list NK_COMMA select_item", + /* 591 */ "select_item ::= NK_STAR", + /* 592 */ "select_item ::= common_expression", + /* 593 */ "select_item ::= common_expression column_alias", + /* 594 */ "select_item ::= common_expression AS column_alias", + /* 595 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 596 */ "where_clause_opt ::=", + /* 597 */ "where_clause_opt ::= WHERE search_condition", + /* 598 */ "partition_by_clause_opt ::=", + /* 599 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 600 */ "partition_list ::= partition_item", + /* 601 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 602 */ "partition_item ::= expr_or_subquery", + /* 603 */ "partition_item ::= expr_or_subquery column_alias", + /* 604 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 605 */ "twindow_clause_opt ::=", + /* 606 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", + /* 607 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 608 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", + /* 609 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", + /* 610 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", + /* 611 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP", + /* 612 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 613 */ "sliding_opt ::=", + /* 614 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", + /* 615 */ "interval_sliding_duration_literal ::= NK_VARIABLE", + /* 616 */ "interval_sliding_duration_literal ::= NK_STRING", + /* 617 */ "interval_sliding_duration_literal ::= NK_INTEGER", + /* 618 */ "fill_opt ::=", + /* 619 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 620 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", + /* 621 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", + /* 622 */ "fill_mode ::= NONE", + /* 623 */ "fill_mode ::= PREV", + /* 624 */ "fill_mode ::= NULL", + /* 625 */ "fill_mode ::= NULL_F", + /* 626 */ "fill_mode ::= LINEAR", + /* 627 */ "fill_mode ::= NEXT", + /* 628 */ "group_by_clause_opt ::=", + /* 629 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 630 */ "group_by_list ::= expr_or_subquery", + /* 631 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 632 */ "having_clause_opt ::=", + /* 633 */ "having_clause_opt ::= HAVING search_condition", + /* 634 */ "range_opt ::=", + /* 635 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 636 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", + /* 637 */ "every_opt ::=", + /* 638 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 639 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 640 */ "query_simple ::= query_specification", + /* 641 */ "query_simple ::= union_query_expression", + /* 642 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 643 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 644 */ "query_simple_or_subquery ::= query_simple", + /* 645 */ "query_simple_or_subquery ::= subquery", + /* 646 */ "query_or_subquery ::= query_expression", + /* 647 */ "query_or_subquery ::= subquery", + /* 648 */ "order_by_clause_opt ::=", + /* 649 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 650 */ "slimit_clause_opt ::=", + /* 651 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 652 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 653 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 654 */ "limit_clause_opt ::=", + /* 655 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 656 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 657 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 658 */ "subquery ::= NK_LP query_expression NK_RP", + /* 659 */ "subquery ::= NK_LP subquery NK_RP", + /* 660 */ "search_condition ::= common_expression", + /* 661 */ "sort_specification_list ::= sort_specification", + /* 662 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 663 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 664 */ "ordering_specification_opt ::=", + /* 665 */ "ordering_specification_opt ::= ASC", + /* 666 */ "ordering_specification_opt ::= DESC", + /* 667 */ "null_ordering_opt ::=", + /* 668 */ "null_ordering_opt ::= NULLS FIRST", + /* 669 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -3168,231 +2856,233 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 351: /* cmd */ - case 354: /* literal */ - case 363: /* with_opt */ - case 369: /* search_condition */ - case 374: /* db_options */ - case 376: /* alter_db_options */ - case 378: /* start_opt */ - case 379: /* end_opt */ - case 383: /* signed */ - case 385: /* retention */ - case 386: /* full_table_name */ - case 389: /* table_options */ - case 393: /* alter_table_clause */ - case 394: /* alter_table_options */ - case 397: /* signed_literal */ - case 398: /* create_subtable_clause */ - case 401: /* drop_table_clause */ - case 403: /* column_def */ - case 407: /* duration_literal */ - case 408: /* rollup_func_name */ - case 410: /* col_name */ - case 413: /* like_pattern_opt */ - case 414: /* db_name_cond_opt */ - case 415: /* table_name_cond */ - case 416: /* from_db_opt */ - case 419: /* tag_item */ - case 421: /* index_options */ - case 422: /* full_index_name */ - case 425: /* sliding_opt */ - case 426: /* sma_stream_opt */ - case 427: /* func */ - case 430: /* query_or_subquery */ - case 431: /* where_clause_opt */ - case 434: /* explain_options */ - case 435: /* insert_query */ - case 440: /* full_view_name */ - case 443: /* stream_options */ - case 446: /* subtable_opt */ - case 448: /* expression */ - case 451: /* literal_func */ - case 454: /* expr_or_subquery */ - case 455: /* pseudo_column */ - case 456: /* column_reference */ - case 457: /* function_expression */ - case 458: /* case_when_expression */ - case 463: /* star_func_para */ - case 465: /* case_when_else_opt */ - case 466: /* common_expression */ - case 467: /* when_then_expr */ - case 468: /* predicate */ - case 471: /* in_predicate_value */ - case 472: /* boolean_value_expression */ - case 473: /* boolean_primary */ - case 474: /* from_clause_opt */ - case 475: /* table_reference_list */ - case 476: /* table_reference */ - case 477: /* table_primary */ - case 478: /* joined_table */ - case 480: /* subquery */ - case 481: /* parenthesized_joined_table */ - case 483: /* query_specification */ - case 489: /* range_opt */ - case 490: /* every_opt */ - case 491: /* fill_opt */ - case 492: /* twindow_clause_opt */ - case 494: /* having_clause_opt */ - case 495: /* select_item */ - case 497: /* partition_item */ - case 498: /* interval_sliding_duration_literal */ - case 501: /* query_expression */ - case 502: /* query_simple */ - case 504: /* slimit_clause_opt */ - case 505: /* limit_clause_opt */ - case 506: /* union_query_expression */ - case 507: /* query_simple_or_subquery */ - case 509: /* sort_specification */ + case 353: /* cmd */ + case 356: /* literal */ + case 365: /* with_opt */ + case 371: /* search_condition */ + case 376: /* db_options */ + case 378: /* alter_db_options */ + case 380: /* start_opt */ + case 381: /* end_opt */ + case 385: /* signed */ + case 387: /* retention */ + case 388: /* full_table_name */ + case 391: /* table_options */ + case 395: /* alter_table_clause */ + case 396: /* alter_table_options */ + case 399: /* tags_literal */ + case 400: /* create_subtable_clause */ + case 403: /* drop_table_clause */ + case 405: /* column_def */ + case 409: /* duration_literal */ + case 410: /* rollup_func_name */ + case 412: /* col_name */ + case 415: /* like_pattern_opt */ + case 416: /* db_name_cond_opt */ + case 417: /* table_name_cond */ + case 418: /* from_db_opt */ + case 421: /* tag_item */ + case 423: /* index_options */ + case 424: /* full_index_name */ + case 427: /* sliding_opt */ + case 428: /* sma_stream_opt */ + case 429: /* func */ + case 433: /* query_or_subquery */ + case 434: /* where_clause_opt */ + case 437: /* explain_options */ + case 438: /* insert_query */ + case 443: /* full_view_name */ + case 446: /* stream_options */ + case 449: /* subtable_opt */ + case 451: /* expression */ + case 454: /* literal_func */ + case 455: /* signed_literal */ + case 458: /* expr_or_subquery */ + case 459: /* pseudo_column */ + case 460: /* column_reference */ + case 461: /* function_expression */ + case 462: /* case_when_expression */ + case 467: /* star_func_para */ + case 469: /* case_when_else_opt */ + case 470: /* common_expression */ + case 471: /* when_then_expr */ + case 472: /* predicate */ + case 475: /* in_predicate_value */ + case 476: /* boolean_value_expression */ + case 477: /* boolean_primary */ + case 478: /* from_clause_opt */ + case 479: /* table_reference_list */ + case 480: /* table_reference */ + case 481: /* table_primary */ + case 482: /* joined_table */ + case 484: /* subquery */ + case 485: /* parenthesized_joined_table */ + case 487: /* query_specification */ + case 493: /* range_opt */ + case 494: /* every_opt */ + case 495: /* fill_opt */ + case 496: /* twindow_clause_opt */ + case 498: /* having_clause_opt */ + case 499: /* select_item */ + case 501: /* partition_item */ + case 502: /* interval_sliding_duration_literal */ + case 505: /* query_expression */ + case 506: /* query_simple */ + case 508: /* slimit_clause_opt */ + case 509: /* limit_clause_opt */ + case 510: /* union_query_expression */ + case 511: /* query_simple_or_subquery */ + case 513: /* sort_specification */ { - nodesDestroyNode((yypminor->yy360)); + nodesDestroyNode((yypminor->yy656)); } break; - case 352: /* account_options */ - case 353: /* alter_account_options */ - case 355: /* alter_account_option */ - case 377: /* speed_opt */ - case 429: /* with_meta */ - case 438: /* bufsize_opt */ + case 354: /* account_options */ + case 355: /* alter_account_options */ + case 357: /* alter_account_option */ + case 379: /* speed_opt */ + case 432: /* with_meta */ + case 441: /* bufsize_opt */ { } break; - case 356: /* ip_range_list */ - case 357: /* white_list */ - case 358: /* white_list_opt */ - case 380: /* integer_list */ - case 381: /* variable_list */ - case 382: /* retention_list */ - case 387: /* column_def_list */ - case 388: /* tags_def_opt */ - case 390: /* multi_create_clause */ - case 391: /* tags_def */ - case 392: /* multi_drop_clause */ - case 399: /* specific_cols_opt */ - case 400: /* expression_list */ - case 402: /* col_name_list */ - case 404: /* duration_list */ - case 405: /* rollup_func_list */ - case 417: /* tag_list_opt */ - case 424: /* func_list */ - case 444: /* col_list_opt */ - case 445: /* tag_def_or_ref_opt */ - case 450: /* dnode_list */ - case 452: /* literal_list */ - case 460: /* star_func_para_list */ - case 462: /* other_para_list */ - case 464: /* when_then_list */ - case 484: /* hint_list */ - case 487: /* select_list */ - case 488: /* partition_by_clause_opt */ - case 493: /* group_by_clause_opt */ - case 496: /* partition_list */ - case 500: /* group_by_list */ - case 503: /* order_by_clause_opt */ - case 508: /* sort_specification_list */ + case 358: /* ip_range_list */ + case 359: /* white_list */ + case 360: /* white_list_opt */ + case 382: /* integer_list */ + case 383: /* variable_list */ + case 384: /* retention_list */ + case 389: /* column_def_list */ + case 390: /* tags_def_opt */ + case 392: /* multi_create_clause */ + case 393: /* tags_def */ + case 394: /* multi_drop_clause */ + case 401: /* specific_cols_opt */ + case 402: /* tags_literal_list */ + case 404: /* col_name_list */ + case 406: /* duration_list */ + case 407: /* rollup_func_list */ + case 419: /* tag_list_opt */ + case 426: /* func_list */ + case 431: /* expression_list */ + case 447: /* col_list_opt */ + case 448: /* tag_def_or_ref_opt */ + case 453: /* dnode_list */ + case 456: /* literal_list */ + case 464: /* star_func_para_list */ + case 466: /* other_para_list */ + case 468: /* when_then_list */ + case 488: /* hint_list */ + case 491: /* select_list */ + case 492: /* partition_by_clause_opt */ + case 497: /* group_by_clause_opt */ + case 500: /* partition_list */ + case 504: /* group_by_list */ + case 507: /* order_by_clause_opt */ + case 512: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy536)); + nodesDestroyList((yypminor->yy136)); } break; - case 359: /* user_name */ - case 366: /* db_name */ - case 367: /* table_name */ - case 368: /* topic_name */ - case 370: /* dnode_endpoint */ - case 395: /* column_name */ - case 409: /* function_name */ - case 420: /* column_alias */ - case 423: /* index_name */ - case 428: /* sma_func_name */ - case 432: /* cgroup_name */ - case 439: /* language_opt */ - case 441: /* view_name */ - case 442: /* stream_name */ - case 449: /* on_vgroup_id */ - case 453: /* table_alias */ - case 459: /* star_func */ - case 461: /* noarg_func */ - case 479: /* alias_opt */ + case 361: /* user_name */ + case 368: /* db_name */ + case 369: /* table_name */ + case 370: /* topic_name */ + case 372: /* dnode_endpoint */ + case 397: /* column_name */ + case 411: /* function_name */ + case 422: /* column_alias */ + case 425: /* index_name */ + case 430: /* sma_func_name */ + case 435: /* cgroup_name */ + case 442: /* language_opt */ + case 444: /* view_name */ + case 445: /* stream_name */ + case 452: /* on_vgroup_id */ + case 457: /* table_alias */ + case 463: /* star_func */ + case 465: /* noarg_func */ + case 483: /* alias_opt */ { } break; - case 360: /* sysinfo_opt */ + case 362: /* sysinfo_opt */ { } break; - case 361: /* privileges */ - case 364: /* priv_type_list */ - case 365: /* priv_type */ + case 363: /* privileges */ + case 366: /* priv_type_list */ + case 367: /* priv_type */ { } break; - case 362: /* priv_level */ + case 364: /* priv_level */ { } break; - case 371: /* force_opt */ - case 372: /* unsafe_opt */ - case 373: /* not_exists_opt */ - case 375: /* exists_opt */ - case 433: /* analyze_opt */ - case 436: /* or_replace_opt */ - case 437: /* agg_func_opt */ - case 447: /* ignore_opt */ - case 485: /* set_quantifier_opt */ - case 486: /* tag_mode_opt */ + case 373: /* force_opt */ + case 374: /* unsafe_opt */ + case 375: /* not_exists_opt */ + case 377: /* exists_opt */ + case 436: /* analyze_opt */ + case 439: /* or_replace_opt */ + case 440: /* agg_func_opt */ + case 450: /* ignore_opt */ + case 489: /* set_quantifier_opt */ + case 490: /* tag_mode_opt */ { } break; - case 384: /* alter_db_option */ - case 406: /* alter_table_option */ + case 386: /* alter_db_option */ + case 408: /* alter_table_option */ { } break; - case 396: /* type_name */ + case 398: /* type_name */ { } break; - case 411: /* db_kind_opt */ - case 418: /* table_kind */ + case 413: /* db_kind_opt */ + case 420: /* table_kind */ { } break; - case 412: /* table_kind_db_name_cond_opt */ + case 414: /* table_kind_db_name_cond_opt */ { } break; - case 469: /* compare_op */ - case 470: /* in_op */ + case 473: /* compare_op */ + case 474: /* in_op */ { } break; - case 482: /* join_type */ + case 486: /* join_type */ { } break; - case 499: /* fill_mode */ + case 503: /* fill_mode */ { } break; - case 510: /* ordering_specification_opt */ + case 514: /* ordering_specification_opt */ { } break; - case 511: /* null_ordering_opt */ + case 515: /* null_ordering_opt */ { } @@ -3561,7 +3251,7 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ - assert( i>=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) ); + assert( i>=0 && iyytos; +#ifndef NDEBUG + if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ + yysize = yyRuleInfoNRhs[yyruleno]; + if( yysize ){ + fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", + yyTracePrompt, + yyruleno, yyRuleName[yyruleno], + yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ + yypParser->yyhwm++; + assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack)); + } +#endif +#if YYSTACKDEPTH>0 + if( yypParser->yytos>=yypParser->yystackEnd ){ + yyStackOverflow(yypParser); + /* The call to yyStackOverflow() above pops the stack until it is + ** empty, causing the main parser loop to exit. So the return value + ** is never used and does not matter. */ + return 0; + } +#else + if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ + if( yyGrowStack(yypParser) ){ + yyStackOverflow(yypParser); + /* The call to yyStackOverflow() above pops the stack until it is + ** empty, causing the main parser loop to exit. So the return value + ** is never used and does not matter. */ + return 0; + } + yymsp = yypParser->yytos; + } +#endif + } switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example @@ -5029,11 +4809,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,352,&yymsp[0].minor); + yy_destructor(yypParser,354,&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,353,&yymsp[0].minor); + yy_destructor(yypParser,355,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -5047,20 +4827,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,352,&yymsp[-2].minor); +{ yy_destructor(yypParser,354,&yymsp[-2].minor); { } - yy_destructor(yypParser,354,&yymsp[0].minor); + yy_destructor(yypParser,356,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,355,&yymsp[0].minor); +{ yy_destructor(yypParser,357,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,353,&yymsp[-1].minor); +{ yy_destructor(yypParser,355,&yymsp[-1].minor); { } - yy_destructor(yypParser,355,&yymsp[0].minor); + yy_destructor(yypParser,357,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -5074,18 +4854,18 @@ 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,354,&yymsp[0].minor); + yy_destructor(yypParser,356,&yymsp[0].minor); break; case 24: /* ip_range_list ::= NK_STRING */ -{ yylhsminor.yy536 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy536 = yylhsminor.yy536; +{ yylhsminor.yy136 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy136 = yylhsminor.yy136; break; case 25: /* ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ -{ yylhsminor.yy536 = addNodeToList(pCxt, yymsp[-2].minor.yy536, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy536 = yylhsminor.yy536; +{ yylhsminor.yy136 = addNodeToList(pCxt, yymsp[-2].minor.yy136, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy136 = yylhsminor.yy136; break; case 26: /* white_list ::= HOST ip_range_list */ -{ yymsp[-1].minor.yy536 = yymsp[0].minor.yy536; } +{ yymsp[-1].minor.yy136 = yymsp[0].minor.yy136; } break; case 27: /* white_list_opt ::= */ case 188: /* specific_cols_opt ::= */ yytestcase(yyruleno==188); @@ -5093,135 +4873,135 @@ static YYACTIONTYPE yy_reduce( case 307: /* tag_list_opt ::= */ yytestcase(yyruleno==307); case 373: /* col_list_opt ::= */ yytestcase(yyruleno==373); case 375: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==375); - case 577: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==577); - case 607: /* group_by_clause_opt ::= */ yytestcase(yyruleno==607); - case 627: /* order_by_clause_opt ::= */ yytestcase(yyruleno==627); -{ yymsp[1].minor.yy536 = NULL; } + case 598: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==598); + case 628: /* group_by_clause_opt ::= */ yytestcase(yyruleno==628); + case 648: /* order_by_clause_opt ::= */ yytestcase(yyruleno==648); +{ yymsp[1].minor.yy136 = NULL; } break; case 28: /* white_list_opt ::= white_list */ case 220: /* tags_def_opt ::= tags_def */ yytestcase(yyruleno==220); case 376: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==376); - case 502: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==502); -{ yylhsminor.yy536 = yymsp[0].minor.yy536; } - yymsp[0].minor.yy536 = yylhsminor.yy536; + case 523: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==523); +{ yylhsminor.yy136 = yymsp[0].minor.yy136; } + yymsp[0].minor.yy136 = yylhsminor.yy136; break; case 29: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ { - pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-4].minor.yy929, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy695); - pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy536); + pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-4].minor.yy665, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy191); + pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy136); } break; case 30: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy929, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy665, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 31: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy929, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy665, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } break; case 32: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy929, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy665, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 33: /* cmd ::= ALTER USER user_name ADD white_list */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy929, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy536); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy665, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy136); } break; case 34: /* cmd ::= ALTER USER user_name DROP white_list */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy929, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy536); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy665, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy136); } break; case 35: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy929); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy665); } break; case 36: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy695 = 1; } +{ yymsp[1].minor.yy191 = 1; } break; case 37: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy695 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy191 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } break; case 38: /* cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy221, &yymsp[-3].minor.yy57, &yymsp[0].minor.yy929, yymsp[-2].minor.yy360); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy909, &yymsp[-3].minor.yy753, &yymsp[0].minor.yy665, yymsp[-2].minor.yy656); } break; case 39: /* cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy221, &yymsp[-3].minor.yy57, &yymsp[0].minor.yy929, yymsp[-2].minor.yy360); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy909, &yymsp[-3].minor.yy753, &yymsp[0].minor.yy665, yymsp[-2].minor.yy656); } break; case 40: /* privileges ::= ALL */ -{ yymsp[0].minor.yy221 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy909 = PRIVILEGE_TYPE_ALL; } break; case 41: /* privileges ::= priv_type_list */ case 43: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==43); -{ yylhsminor.yy221 = yymsp[0].minor.yy221; } - yymsp[0].minor.yy221 = yylhsminor.yy221; +{ yylhsminor.yy909 = yymsp[0].minor.yy909; } + yymsp[0].minor.yy909 = yylhsminor.yy909; break; case 42: /* privileges ::= SUBSCRIBE */ -{ yymsp[0].minor.yy221 = PRIVILEGE_TYPE_SUBSCRIBE; } +{ yymsp[0].minor.yy909 = PRIVILEGE_TYPE_SUBSCRIBE; } break; case 44: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy221 = yymsp[-2].minor.yy221 | yymsp[0].minor.yy221; } - yymsp[-2].minor.yy221 = yylhsminor.yy221; +{ yylhsminor.yy909 = yymsp[-2].minor.yy909 | yymsp[0].minor.yy909; } + yymsp[-2].minor.yy909 = yylhsminor.yy909; break; case 45: /* priv_type ::= READ */ -{ yymsp[0].minor.yy221 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy909 = PRIVILEGE_TYPE_READ; } break; case 46: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy221 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy909 = PRIVILEGE_TYPE_WRITE; } break; case 47: /* priv_type ::= ALTER */ -{ yymsp[0].minor.yy221 = PRIVILEGE_TYPE_ALTER; } +{ yymsp[0].minor.yy909 = PRIVILEGE_TYPE_ALTER; } break; case 48: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy57.first = yymsp[-2].minor.yy0; yylhsminor.yy57.second = yymsp[0].minor.yy0; } - yymsp[-2].minor.yy57 = yylhsminor.yy57; +{ yylhsminor.yy753.first = yymsp[-2].minor.yy0; yylhsminor.yy753.second = yymsp[0].minor.yy0; } + yymsp[-2].minor.yy753 = yylhsminor.yy753; break; case 49: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy57.first = yymsp[-2].minor.yy929; yylhsminor.yy57.second = yymsp[0].minor.yy0; } - yymsp[-2].minor.yy57 = yylhsminor.yy57; +{ yylhsminor.yy753.first = yymsp[-2].minor.yy665; yylhsminor.yy753.second = yymsp[0].minor.yy0; } + yymsp[-2].minor.yy753 = yylhsminor.yy753; break; case 50: /* priv_level ::= db_name NK_DOT table_name */ -{ yylhsminor.yy57.first = yymsp[-2].minor.yy929; yylhsminor.yy57.second = yymsp[0].minor.yy929; } - yymsp[-2].minor.yy57 = yylhsminor.yy57; +{ yylhsminor.yy753.first = yymsp[-2].minor.yy665; yylhsminor.yy753.second = yymsp[0].minor.yy665; } + yymsp[-2].minor.yy753 = yylhsminor.yy753; break; case 51: /* priv_level ::= topic_name */ -{ yylhsminor.yy57.first = yymsp[0].minor.yy929; yylhsminor.yy57.second = nil_token; } - yymsp[0].minor.yy57 = yylhsminor.yy57; +{ yylhsminor.yy753.first = yymsp[0].minor.yy665; yylhsminor.yy753.second = nil_token; } + yymsp[0].minor.yy753 = yylhsminor.yy753; break; case 52: /* with_opt ::= */ case 157: /* start_opt ::= */ yytestcase(yyruleno==157); case 161: /* end_opt ::= */ yytestcase(yyruleno==161); case 302: /* like_pattern_opt ::= */ yytestcase(yyruleno==302); case 387: /* subtable_opt ::= */ yytestcase(yyruleno==387); - case 512: /* case_when_else_opt ::= */ yytestcase(yyruleno==512); - case 542: /* from_clause_opt ::= */ yytestcase(yyruleno==542); - case 575: /* where_clause_opt ::= */ yytestcase(yyruleno==575); - case 584: /* twindow_clause_opt ::= */ yytestcase(yyruleno==584); - case 592: /* sliding_opt ::= */ yytestcase(yyruleno==592); - case 597: /* fill_opt ::= */ yytestcase(yyruleno==597); - case 611: /* having_clause_opt ::= */ yytestcase(yyruleno==611); - case 613: /* range_opt ::= */ yytestcase(yyruleno==613); - case 616: /* every_opt ::= */ yytestcase(yyruleno==616); - case 629: /* slimit_clause_opt ::= */ yytestcase(yyruleno==629); - case 633: /* limit_clause_opt ::= */ yytestcase(yyruleno==633); -{ yymsp[1].minor.yy360 = NULL; } + case 533: /* case_when_else_opt ::= */ yytestcase(yyruleno==533); + case 563: /* from_clause_opt ::= */ yytestcase(yyruleno==563); + case 596: /* where_clause_opt ::= */ yytestcase(yyruleno==596); + case 605: /* twindow_clause_opt ::= */ yytestcase(yyruleno==605); + case 613: /* sliding_opt ::= */ yytestcase(yyruleno==613); + case 618: /* fill_opt ::= */ yytestcase(yyruleno==618); + case 632: /* having_clause_opt ::= */ yytestcase(yyruleno==632); + case 634: /* range_opt ::= */ yytestcase(yyruleno==634); + case 637: /* every_opt ::= */ yytestcase(yyruleno==637); + case 650: /* slimit_clause_opt ::= */ yytestcase(yyruleno==650); + case 654: /* limit_clause_opt ::= */ yytestcase(yyruleno==654); +{ yymsp[1].minor.yy656 = NULL; } break; case 53: /* with_opt ::= WITH search_condition */ - case 543: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==543); - case 576: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==576); - case 612: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==612); -{ yymsp[-1].minor.yy360 = yymsp[0].minor.yy360; } + case 564: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==564); + case 597: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==597); + case 633: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==633); +{ yymsp[-1].minor.yy656 = yymsp[0].minor.yy656; } break; case 54: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy929, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy665, NULL); } break; case 55: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy665, &yymsp[0].minor.yy0); } break; case 56: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy345, false); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy497, false); } break; case 57: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy929, yymsp[0].minor.yy345, false); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy665, yymsp[0].minor.yy497, false); } break; case 58: /* cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy345); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy497); } break; case 59: /* cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy929, false, yymsp[0].minor.yy345); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy665, false, yymsp[0].minor.yy497); } break; case 60: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -5245,34 +5025,34 @@ static YYACTIONTYPE yy_reduce( case 330: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==330); case 331: /* sma_func_name ::= LAST */ yytestcase(yyruleno==331); case 332: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==332); - case 434: /* db_name ::= NK_ID */ yytestcase(yyruleno==434); - case 435: /* table_name ::= NK_ID */ yytestcase(yyruleno==435); - case 436: /* column_name ::= NK_ID */ yytestcase(yyruleno==436); - case 437: /* function_name ::= NK_ID */ yytestcase(yyruleno==437); - case 438: /* view_name ::= NK_ID */ yytestcase(yyruleno==438); - case 439: /* table_alias ::= NK_ID */ yytestcase(yyruleno==439); - case 440: /* column_alias ::= NK_ID */ yytestcase(yyruleno==440); - case 441: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==441); - case 442: /* user_name ::= NK_ID */ yytestcase(yyruleno==442); - case 443: /* topic_name ::= NK_ID */ yytestcase(yyruleno==443); - case 444: /* stream_name ::= NK_ID */ yytestcase(yyruleno==444); - case 445: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==445); - case 446: /* index_name ::= NK_ID */ yytestcase(yyruleno==446); - case 488: /* noarg_func ::= NOW */ yytestcase(yyruleno==488); - case 489: /* noarg_func ::= TODAY */ yytestcase(yyruleno==489); - case 490: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==490); - case 491: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==491); - case 492: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==492); - case 493: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==493); - case 494: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==494); - case 495: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==495); - case 496: /* noarg_func ::= USER */ yytestcase(yyruleno==496); - case 497: /* star_func ::= COUNT */ yytestcase(yyruleno==497); - case 498: /* star_func ::= FIRST */ yytestcase(yyruleno==498); - case 499: /* star_func ::= LAST */ yytestcase(yyruleno==499); - case 500: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==500); -{ yylhsminor.yy929 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy929 = yylhsminor.yy929; + case 454: /* db_name ::= NK_ID */ yytestcase(yyruleno==454); + case 455: /* table_name ::= NK_ID */ yytestcase(yyruleno==455); + case 456: /* column_name ::= NK_ID */ yytestcase(yyruleno==456); + case 457: /* function_name ::= NK_ID */ yytestcase(yyruleno==457); + case 458: /* view_name ::= NK_ID */ yytestcase(yyruleno==458); + case 459: /* table_alias ::= NK_ID */ yytestcase(yyruleno==459); + case 460: /* column_alias ::= NK_ID */ yytestcase(yyruleno==460); + case 461: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==461); + case 462: /* user_name ::= NK_ID */ yytestcase(yyruleno==462); + case 463: /* topic_name ::= NK_ID */ yytestcase(yyruleno==463); + case 464: /* stream_name ::= NK_ID */ yytestcase(yyruleno==464); + case 465: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==465); + case 466: /* index_name ::= NK_ID */ yytestcase(yyruleno==466); + case 509: /* noarg_func ::= NOW */ yytestcase(yyruleno==509); + case 510: /* noarg_func ::= TODAY */ yytestcase(yyruleno==510); + case 511: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==511); + case 512: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==512); + case 513: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==513); + case 514: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==514); + case 515: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==515); + case 516: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==516); + case 517: /* noarg_func ::= USER */ yytestcase(yyruleno==517); + case 518: /* star_func ::= COUNT */ yytestcase(yyruleno==518); + case 519: /* star_func ::= FIRST */ yytestcase(yyruleno==519); + case 520: /* star_func ::= LAST */ yytestcase(yyruleno==520); + case 521: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==521); +{ yylhsminor.yy665 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy665 = yylhsminor.yy665; break; case 68: /* force_opt ::= */ case 94: /* not_exists_opt ::= */ yytestcase(yyruleno==94); @@ -5281,17 +5061,17 @@ static YYACTIONTYPE yy_reduce( case 357: /* agg_func_opt ::= */ yytestcase(yyruleno==357); case 363: /* or_replace_opt ::= */ yytestcase(yyruleno==363); case 389: /* ignore_opt ::= */ yytestcase(yyruleno==389); - case 563: /* tag_mode_opt ::= */ yytestcase(yyruleno==563); - case 565: /* set_quantifier_opt ::= */ yytestcase(yyruleno==565); -{ yymsp[1].minor.yy345 = false; } + case 584: /* tag_mode_opt ::= */ yytestcase(yyruleno==584); + case 586: /* set_quantifier_opt ::= */ yytestcase(yyruleno==586); +{ yymsp[1].minor.yy497 = false; } break; case 69: /* force_opt ::= FORCE */ case 70: /* unsafe_opt ::= UNSAFE */ yytestcase(yyruleno==70); case 351: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==351); case 358: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==358); - case 564: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==564); - case 566: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==566); -{ yymsp[0].minor.yy345 = true; } + case 585: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==585); + case 587: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==587); +{ yymsp[0].minor.yy497 = true; } break; case 71: /* cmd ::= ALTER CLUSTER NK_STRING */ { pCxt->pRootNode = createAlterClusterStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -5339,241 +5119,241 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_VNODE_STMT, &yymsp[0].minor.yy0); } break; case 86: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy345, &yymsp[-1].minor.yy929, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy497, &yymsp[-1].minor.yy665, yymsp[0].minor.yy656); } break; case 87: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy345, &yymsp[0].minor.yy929); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy497, &yymsp[0].minor.yy665); } break; case 88: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy929); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy665); } break; case 89: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy929, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy665, yymsp[0].minor.yy656); } break; case 90: /* cmd ::= FLUSH DATABASE db_name */ -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy929); } +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy665); } break; case 91: /* cmd ::= TRIM DATABASE db_name speed_opt */ -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy929, yymsp[0].minor.yy580); } +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy665, yymsp[0].minor.yy676); } break; case 92: /* cmd ::= COMPACT DATABASE db_name start_opt end_opt */ -{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy929, yymsp[-1].minor.yy360, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy665, yymsp[-1].minor.yy656, yymsp[0].minor.yy656); } break; case 93: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy345 = true; } +{ yymsp[-2].minor.yy497 = true; } break; case 95: /* exists_opt ::= IF EXISTS */ case 364: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==364); case 390: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==390); -{ yymsp[-1].minor.yy345 = true; } +{ yymsp[-1].minor.yy497 = true; } break; case 97: /* db_options ::= */ -{ yymsp[1].minor.yy360 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy656 = createDefaultDatabaseOptions(pCxt); } break; case 98: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 99: /* db_options ::= db_options CACHEMODEL NK_STRING */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 100: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 101: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 102: /* db_options ::= db_options DURATION NK_INTEGER */ case 103: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==103); -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 104: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 105: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 106: /* db_options ::= db_options KEEP integer_list */ case 107: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==107); -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_KEEP, yymsp[0].minor.yy536); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_KEEP, yymsp[0].minor.yy136); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 108: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 109: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 110: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 111: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 112: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 113: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 114: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 115: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_RETENTIONS, yymsp[0].minor.yy536); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_RETENTIONS, yymsp[0].minor.yy136); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 116: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 117: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 118: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 119: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 120: /* db_options ::= db_options WAL_RETENTION_PERIOD 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.yy360 = setDatabaseOption(pCxt, yymsp[-3].minor.yy360, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-3].minor.yy656, DB_OPTION_WAL_RETENTION_PERIOD, &t); } - yymsp[-3].minor.yy360 = yylhsminor.yy360; + yymsp[-3].minor.yy656 = yylhsminor.yy656; break; case 121: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 122: /* db_options ::= db_options WAL_RETENTION_SIZE 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.yy360 = setDatabaseOption(pCxt, yymsp[-3].minor.yy360, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-3].minor.yy656, DB_OPTION_WAL_RETENTION_SIZE, &t); } - yymsp[-3].minor.yy360 = yylhsminor.yy360; + yymsp[-3].minor.yy656 = yylhsminor.yy656; break; case 123: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 124: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 125: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 126: /* db_options ::= db_options TABLE_PREFIX signed */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy360); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy656); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 127: /* db_options ::= db_options TABLE_SUFFIX signed */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy360); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy656); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 128: /* db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ -{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setDatabaseOption(pCxt, yymsp[-2].minor.yy656, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 129: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy360 = createAlterDatabaseOptions(pCxt); yylhsminor.yy360 = setAlterDatabaseOption(pCxt, yylhsminor.yy360, &yymsp[0].minor.yy797); } - yymsp[0].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createAlterDatabaseOptions(pCxt); yylhsminor.yy656 = setAlterDatabaseOption(pCxt, yylhsminor.yy656, &yymsp[0].minor.yy749); } + yymsp[0].minor.yy656 = yylhsminor.yy656; break; case 130: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy360 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy360, &yymsp[0].minor.yy797); } - yymsp[-1].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy656, &yymsp[0].minor.yy749); } + yymsp[-1].minor.yy656 = yylhsminor.yy656; break; case 131: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy797.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy749.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy749.val = yymsp[0].minor.yy0; } break; case 132: /* alter_db_option ::= CACHEMODEL NK_STRING */ -{ yymsp[-1].minor.yy797.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy749.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy749.val = yymsp[0].minor.yy0; } break; case 133: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -{ yymsp[-1].minor.yy797.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy749.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy749.val = yymsp[0].minor.yy0; } break; case 134: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy797.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy749.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy749.val = yymsp[0].minor.yy0; } break; case 135: /* alter_db_option ::= KEEP integer_list */ case 136: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==136); -{ yymsp[-1].minor.yy797.type = DB_OPTION_KEEP; yymsp[-1].minor.yy797.pList = yymsp[0].minor.yy536; } +{ yymsp[-1].minor.yy749.type = DB_OPTION_KEEP; yymsp[-1].minor.yy749.pList = yymsp[0].minor.yy136; } break; case 137: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy797.type = DB_OPTION_PAGES; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy749.type = DB_OPTION_PAGES; yymsp[-1].minor.yy749.val = yymsp[0].minor.yy0; } break; case 138: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy797.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy749.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy749.val = yymsp[0].minor.yy0; } break; case 139: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -{ yymsp[-1].minor.yy797.type = DB_OPTION_WAL; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy749.type = DB_OPTION_WAL; yymsp[-1].minor.yy749.val = yymsp[0].minor.yy0; } break; case 140: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ -{ yymsp[-1].minor.yy797.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy749.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy749.val = yymsp[0].minor.yy0; } break; case 141: /* alter_db_option ::= MINROWS NK_INTEGER */ -{ yymsp[-1].minor.yy797.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy749.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy749.val = yymsp[0].minor.yy0; } break; case 142: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy797.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy749.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy749.val = yymsp[0].minor.yy0; } break; case 143: /* alter_db_option ::= WAL_RETENTION_PERIOD 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; - yymsp[-2].minor.yy797.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy797.val = t; + yymsp[-2].minor.yy749.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy749.val = t; } break; case 144: /* alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ -{ yymsp[-1].minor.yy797.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy749.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy749.val = yymsp[0].minor.yy0; } break; case 145: /* alter_db_option ::= WAL_RETENTION_SIZE 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; - yymsp[-2].minor.yy797.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy797.val = t; + yymsp[-2].minor.yy749.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy749.val = t; } break; case 146: /* alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ -{ yymsp[-1].minor.yy797.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy749.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy749.val = yymsp[0].minor.yy0; } break; case 147: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy536 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy536 = yylhsminor.yy536; +{ yylhsminor.yy136 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy136 = yylhsminor.yy136; break; case 148: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ case 403: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==403); -{ yylhsminor.yy536 = addNodeToList(pCxt, yymsp[-2].minor.yy536, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy536 = yylhsminor.yy536; +{ yylhsminor.yy136 = addNodeToList(pCxt, yymsp[-2].minor.yy136, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy136 = yylhsminor.yy136; break; case 149: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy536 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy536 = yylhsminor.yy536; +{ yylhsminor.yy136 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy136 = yylhsminor.yy136; break; case 150: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy536 = addNodeToList(pCxt, yymsp[-2].minor.yy536, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy536 = yylhsminor.yy536; +{ yylhsminor.yy136 = addNodeToList(pCxt, yymsp[-2].minor.yy136, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy136 = yylhsminor.yy136; break; case 151: /* retention_list ::= retention */ case 182: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==182); @@ -5583,14 +5363,15 @@ static YYACTIONTYPE yy_reduce( case 241: /* col_name_list ::= col_name */ yytestcase(yyruleno==241); case 308: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==308); case 325: /* func_list ::= func */ yytestcase(yyruleno==325); - case 432: /* literal_list ::= signed_literal */ yytestcase(yyruleno==432); - case 503: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==503); - case 509: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==509); - case 568: /* select_list ::= select_item */ yytestcase(yyruleno==568); - case 579: /* partition_list ::= partition_item */ yytestcase(yyruleno==579); - case 640: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==640); -{ yylhsminor.yy536 = createNodeList(pCxt, yymsp[0].minor.yy360); } - yymsp[0].minor.yy536 = yylhsminor.yy536; + case 427: /* tags_literal_list ::= tags_literal */ yytestcase(yyruleno==427); + case 452: /* literal_list ::= signed_literal */ yytestcase(yyruleno==452); + case 524: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==524); + case 530: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==530); + case 589: /* select_list ::= select_item */ yytestcase(yyruleno==589); + case 600: /* partition_list ::= partition_item */ yytestcase(yyruleno==600); + case 661: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==661); +{ yylhsminor.yy136 = createNodeList(pCxt, yymsp[0].minor.yy656); } + yymsp[0].minor.yy136 = yylhsminor.yy136; break; case 152: /* retention_list ::= retention_list NK_COMMA retention */ case 186: /* multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ yytestcase(yyruleno==186); @@ -5599,272 +5380,273 @@ static YYACTIONTYPE yy_reduce( case 242: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==242); case 309: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==309); case 326: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==326); - case 433: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==433); - case 504: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==504); - case 569: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==569); - case 580: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==580); - case 641: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==641); -{ yylhsminor.yy536 = addNodeToList(pCxt, yymsp[-2].minor.yy536, yymsp[0].minor.yy360); } - yymsp[-2].minor.yy536 = yylhsminor.yy536; + case 428: /* tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ yytestcase(yyruleno==428); + case 453: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==453); + case 525: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==525); + case 590: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==590); + case 601: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==601); + case 662: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==662); +{ yylhsminor.yy136 = addNodeToList(pCxt, yymsp[-2].minor.yy136, yymsp[0].minor.yy656); } + yymsp[-2].minor.yy136 = yylhsminor.yy136; break; case 153: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ case 154: /* retention ::= NK_MINUS NK_COLON NK_VARIABLE */ yytestcase(yyruleno==154); -{ yylhsminor.yy360 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 155: /* speed_opt ::= */ case 359: /* bufsize_opt ::= */ yytestcase(yyruleno==359); -{ yymsp[1].minor.yy580 = 0; } +{ yymsp[1].minor.yy676 = 0; } break; case 156: /* speed_opt ::= BWLIMIT NK_INTEGER */ case 360: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==360); -{ yymsp[-1].minor.yy580 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy676 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; case 158: /* start_opt ::= START WITH NK_INTEGER */ case 162: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==162); -{ yymsp[-2].minor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-2].minor.yy656 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 159: /* start_opt ::= START WITH NK_STRING */ case 163: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==163); -{ yymsp[-2].minor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +{ yymsp[-2].minor.yy656 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; case 160: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ case 164: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==164); -{ yymsp[-3].minor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +{ yymsp[-3].minor.yy656 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; case 165: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 167: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==167); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy345, yymsp[-5].minor.yy360, yymsp[-3].minor.yy536, yymsp[-1].minor.yy536, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy497, yymsp[-5].minor.yy656, yymsp[-3].minor.yy136, yymsp[-1].minor.yy136, yymsp[0].minor.yy656); } break; case 166: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy536); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy136); } break; case 168: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy536); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy136); } break; case 169: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy345, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy497, yymsp[0].minor.yy656); } break; case 170: /* cmd ::= ALTER TABLE alter_table_clause */ case 405: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==405); case 406: /* cmd ::= insert_query */ yytestcase(yyruleno==406); -{ pCxt->pRootNode = yymsp[0].minor.yy360; } +{ pCxt->pRootNode = yymsp[0].minor.yy656; } break; case 171: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy360); } +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy656); } break; case 172: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy360 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy360, yymsp[0].minor.yy360); } - yymsp[-1].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy656, yymsp[0].minor.yy656); } + yymsp[-1].minor.yy656 = yylhsminor.yy656; break; case 173: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy360 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy360, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy929, yymsp[0].minor.yy912); } - yymsp[-4].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy656, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy665, yymsp[0].minor.yy256); } + yymsp[-4].minor.yy656 = yylhsminor.yy656; break; case 174: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy360 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy360, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy929); } - yymsp[-3].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy656, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy665); } + yymsp[-3].minor.yy656 = yylhsminor.yy656; break; case 175: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy360 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy360, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy929, yymsp[0].minor.yy912); } - yymsp[-4].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy656, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy665, yymsp[0].minor.yy256); } + yymsp[-4].minor.yy656 = yylhsminor.yy656; break; case 176: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy360 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy360, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy929, &yymsp[0].minor.yy929); } - yymsp[-4].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy656, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy665, &yymsp[0].minor.yy665); } + yymsp[-4].minor.yy656 = yylhsminor.yy656; break; case 177: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy360 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy360, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy929, yymsp[0].minor.yy912); } - yymsp[-4].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy656, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy665, yymsp[0].minor.yy256); } + yymsp[-4].minor.yy656 = yylhsminor.yy656; break; case 178: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy360 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy360, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy929); } - yymsp[-3].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy656, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy665); } + yymsp[-3].minor.yy656 = yylhsminor.yy656; break; case 179: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy360 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy360, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy929, yymsp[0].minor.yy912); } - yymsp[-4].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy656, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy665, yymsp[0].minor.yy256); } + yymsp[-4].minor.yy656 = yylhsminor.yy656; break; case 180: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy360 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy360, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy929, &yymsp[0].minor.yy929); } - yymsp[-4].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy656, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy665, &yymsp[0].minor.yy665); } + yymsp[-4].minor.yy656 = yylhsminor.yy656; break; - case 181: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy360 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy360, &yymsp[-2].minor.yy929, yymsp[0].minor.yy360); } - yymsp[-5].minor.yy360 = yylhsminor.yy360; + case 181: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal */ +{ yylhsminor.yy656 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy656, &yymsp[-2].minor.yy665, yymsp[0].minor.yy656); } + yymsp[-5].minor.yy656 = yylhsminor.yy656; break; case 183: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 510: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==510); -{ yylhsminor.yy536 = addNodeToList(pCxt, yymsp[-1].minor.yy536, yymsp[0].minor.yy360); } - yymsp[-1].minor.yy536 = yylhsminor.yy536; + case 531: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==531); +{ yylhsminor.yy136 = addNodeToList(pCxt, yymsp[-1].minor.yy136, yymsp[0].minor.yy656); } + yymsp[-1].minor.yy136 = yylhsminor.yy136; break; - case 184: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ -{ yylhsminor.yy360 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy345, yymsp[-8].minor.yy360, yymsp[-6].minor.yy360, yymsp[-5].minor.yy536, yymsp[-2].minor.yy536, yymsp[0].minor.yy360); } - yymsp[-9].minor.yy360 = yylhsminor.yy360; + case 184: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP tags_literal_list NK_RP table_options */ +{ yylhsminor.yy656 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy497, yymsp[-8].minor.yy656, yymsp[-6].minor.yy656, yymsp[-5].minor.yy136, yymsp[-2].minor.yy136, yymsp[0].minor.yy656); } + yymsp[-9].minor.yy656 = yylhsminor.yy656; break; case 187: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy360 = createDropTableClause(pCxt, yymsp[-1].minor.yy345, yymsp[0].minor.yy360); } - yymsp[-1].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createDropTableClause(pCxt, yymsp[-1].minor.yy497, yymsp[0].minor.yy656); } + yymsp[-1].minor.yy656 = yylhsminor.yy656; break; case 189: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ case 374: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==374); -{ yymsp[-2].minor.yy536 = yymsp[-1].minor.yy536; } +{ yymsp[-2].minor.yy136 = yymsp[-1].minor.yy136; } break; case 190: /* full_table_name ::= table_name */ -{ yylhsminor.yy360 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy929, NULL); } - yymsp[0].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy665, NULL); } + yymsp[0].minor.yy656 = yylhsminor.yy656; break; case 191: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy360 = createRealTableNode(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929, NULL); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createRealTableNode(pCxt, &yymsp[-2].minor.yy665, &yymsp[0].minor.yy665, NULL); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 194: /* column_def ::= column_name type_name */ -{ yylhsminor.yy360 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy929, yymsp[0].minor.yy912, NULL); } - yymsp[-1].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy665, yymsp[0].minor.yy256, NULL); } + yymsp[-1].minor.yy656 = yylhsminor.yy656; break; case 195: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 196: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 197: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 198: /* type_name ::= INT */ case 199: /* type_name ::= INTEGER */ yytestcase(yyruleno==199); -{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_INT); } break; case 200: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 201: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 202: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 203: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy912 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy256 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 204: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 205: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy912 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy256 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 206: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy912 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy256 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 207: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy912 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy256 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 208: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy912 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy256 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 209: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy912 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy256 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 210: /* type_name ::= JSON */ -{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 211: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy912 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy256 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 212: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 213: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 214: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy912 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy256 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 215: /* type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy912 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy256 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } break; case 216: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy256 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 217: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy912 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy256 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 218: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy912 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy256 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 221: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ case 377: /* tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ yytestcase(yyruleno==377); -{ yymsp[-3].minor.yy536 = yymsp[-1].minor.yy536; } +{ yymsp[-3].minor.yy136 = yymsp[-1].minor.yy136; } break; case 222: /* table_options ::= */ -{ yymsp[1].minor.yy360 = createDefaultTableOptions(pCxt); } +{ yymsp[1].minor.yy656 = createDefaultTableOptions(pCxt); } break; case 223: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy360 = setTableOption(pCxt, yymsp[-2].minor.yy360, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setTableOption(pCxt, yymsp[-2].minor.yy656, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 224: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy360 = setTableOption(pCxt, yymsp[-2].minor.yy360, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy536); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setTableOption(pCxt, yymsp[-2].minor.yy656, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy136); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 225: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy360 = setTableOption(pCxt, yymsp[-2].minor.yy360, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy536); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setTableOption(pCxt, yymsp[-2].minor.yy656, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy136); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 226: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy360 = setTableOption(pCxt, yymsp[-4].minor.yy360, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy536); } - yymsp[-4].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setTableOption(pCxt, yymsp[-4].minor.yy656, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy136); } + yymsp[-4].minor.yy656 = yylhsminor.yy656; break; case 227: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy360 = setTableOption(pCxt, yymsp[-2].minor.yy360, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setTableOption(pCxt, yymsp[-2].minor.yy656, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 228: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy360 = setTableOption(pCxt, yymsp[-4].minor.yy360, TABLE_OPTION_SMA, yymsp[-1].minor.yy536); } - yymsp[-4].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setTableOption(pCxt, yymsp[-4].minor.yy656, TABLE_OPTION_SMA, yymsp[-1].minor.yy136); } + yymsp[-4].minor.yy656 = yylhsminor.yy656; break; case 229: /* table_options ::= table_options DELETE_MARK duration_list */ -{ yylhsminor.yy360 = setTableOption(pCxt, yymsp[-2].minor.yy360, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy536); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setTableOption(pCxt, yymsp[-2].minor.yy656, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy136); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 230: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy360 = createAlterTableOptions(pCxt); yylhsminor.yy360 = setTableOption(pCxt, yylhsminor.yy360, yymsp[0].minor.yy797.type, &yymsp[0].minor.yy797.val); } - yymsp[0].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createAlterTableOptions(pCxt); yylhsminor.yy656 = setTableOption(pCxt, yylhsminor.yy656, yymsp[0].minor.yy749.type, &yymsp[0].minor.yy749.val); } + yymsp[0].minor.yy656 = yylhsminor.yy656; break; case 231: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy360 = setTableOption(pCxt, yymsp[-1].minor.yy360, yymsp[0].minor.yy797.type, &yymsp[0].minor.yy797.val); } - yymsp[-1].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setTableOption(pCxt, yymsp[-1].minor.yy656, yymsp[0].minor.yy749.type, &yymsp[0].minor.yy749.val); } + yymsp[-1].minor.yy656 = yylhsminor.yy656; break; case 232: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy797.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy749.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy749.val = yymsp[0].minor.yy0; } break; case 233: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy797.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy749.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy749.val = yymsp[0].minor.yy0; } break; case 234: /* duration_list ::= duration_literal */ - case 464: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==464); -{ yylhsminor.yy536 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy360)); } - yymsp[0].minor.yy536 = yylhsminor.yy536; + case 484: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==484); +{ yylhsminor.yy136 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy656)); } + yymsp[0].minor.yy136 = yylhsminor.yy136; break; case 235: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 465: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==465); -{ yylhsminor.yy536 = addNodeToList(pCxt, yymsp[-2].minor.yy536, releaseRawExprNode(pCxt, yymsp[0].minor.yy360)); } - yymsp[-2].minor.yy536 = yylhsminor.yy536; + case 485: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==485); +{ yylhsminor.yy136 = addNodeToList(pCxt, yymsp[-2].minor.yy136, releaseRawExprNode(pCxt, yymsp[0].minor.yy656)); } + yymsp[-2].minor.yy136 = yylhsminor.yy136; break; case 238: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy360 = createFunctionNode(pCxt, &yymsp[0].minor.yy929, NULL); } - yymsp[0].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createFunctionNode(pCxt, &yymsp[0].minor.yy665, NULL); } + yymsp[0].minor.yy656 = yylhsminor.yy656; break; case 239: /* rollup_func_name ::= FIRST */ case 240: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==240); case 311: /* tag_item ::= QTAGS */ yytestcase(yyruleno==311); -{ yylhsminor.yy360 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy656 = yylhsminor.yy656; break; case 243: /* col_name ::= column_name */ case 312: /* tag_item ::= column_name */ yytestcase(yyruleno==312); -{ yylhsminor.yy360 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy929); } - yymsp[0].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy665); } + yymsp[0].minor.yy656 = yylhsminor.yy656; break; case 244: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } @@ -5878,19 +5660,19 @@ static YYACTIONTYPE yy_reduce( case 247: /* cmd ::= SHOW db_kind_opt DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); - setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy321); + setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy633); } break; case 248: /* cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ { - pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy1005, yymsp[0].minor.yy360, OP_TYPE_LIKE); + pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy493, yymsp[0].minor.yy656, OP_TYPE_LIKE); } break; case 249: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy360, yymsp[0].minor.yy360, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy656, yymsp[0].minor.yy656, OP_TYPE_LIKE); } break; case 250: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy360, NULL, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy656, NULL, OP_TYPE_LIKE); } break; case 251: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } @@ -5902,10 +5684,10 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; case 254: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy360, yymsp[-1].minor.yy360, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy656, yymsp[-1].minor.yy656, OP_TYPE_EQUAL); } break; case 255: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy929), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy929), OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy665), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy665), OP_TYPE_EQUAL); } break; case 256: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } @@ -5933,13 +5715,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT); } break; case 265: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy929); } +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy665); } break; case 266: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy656); } break; case 267: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy656); } break; case 268: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } @@ -5958,7 +5740,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } break; case 274: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy656); } break; case 275: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } @@ -5973,7 +5755,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; case 279: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy656); } break; case 280: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } @@ -5982,16 +5764,16 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; case 282: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy360, yymsp[-1].minor.yy360, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy656, yymsp[-1].minor.yy656, OP_TYPE_EQUAL); } break; case 283: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy929), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy929), OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy665), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy665), OP_TYPE_EQUAL); } break; case 284: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy360, yymsp[0].minor.yy360, yymsp[-3].minor.yy536); } +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy656, yymsp[0].minor.yy656, yymsp[-3].minor.yy136); } break; case 285: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy929), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy929), yymsp[-4].minor.yy536); } +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy665), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy665), yymsp[-4].minor.yy136); } break; case 286: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } @@ -6000,16 +5782,16 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, NULL); } break; case 288: /* cmd ::= SHOW db_name_cond_opt ALIVE */ -{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy360, QUERY_NODE_SHOW_DB_ALIVE_STMT); } +{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy656, QUERY_NODE_SHOW_DB_ALIVE_STMT); } break; case 289: /* cmd ::= SHOW CLUSTER ALIVE */ { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } break; case 290: /* cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-2].minor.yy360, yymsp[0].minor.yy360, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-2].minor.yy656, yymsp[0].minor.yy656, OP_TYPE_LIKE); } break; case 291: /* cmd ::= SHOW CREATE VIEW full_table_name */ -{ pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy656); } break; case 292: /* cmd ::= SHOW COMPACTS */ { pCxt->pRootNode = createShowCompactsStmt(pCxt, QUERY_NODE_SHOW_COMPACTS_STMT); } @@ -6018,232 +5800,232 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowCompactDetailsStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; case 294: /* table_kind_db_name_cond_opt ::= */ -{ yymsp[1].minor.yy1005.kind = SHOW_KIND_ALL; yymsp[1].minor.yy1005.dbName = nil_token; } +{ yymsp[1].minor.yy493.kind = SHOW_KIND_ALL; yymsp[1].minor.yy493.dbName = nil_token; } break; case 295: /* table_kind_db_name_cond_opt ::= table_kind */ -{ yylhsminor.yy1005.kind = yymsp[0].minor.yy321; yylhsminor.yy1005.dbName = nil_token; } - yymsp[0].minor.yy1005 = yylhsminor.yy1005; +{ yylhsminor.yy493.kind = yymsp[0].minor.yy633; yylhsminor.yy493.dbName = nil_token; } + yymsp[0].minor.yy493 = yylhsminor.yy493; break; case 296: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy1005.kind = SHOW_KIND_ALL; yylhsminor.yy1005.dbName = yymsp[-1].minor.yy929; } - yymsp[-1].minor.yy1005 = yylhsminor.yy1005; +{ yylhsminor.yy493.kind = SHOW_KIND_ALL; yylhsminor.yy493.dbName = yymsp[-1].minor.yy665; } + yymsp[-1].minor.yy493 = yylhsminor.yy493; break; case 297: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ -{ yylhsminor.yy1005.kind = yymsp[-2].minor.yy321; yylhsminor.yy1005.dbName = yymsp[-1].minor.yy929; } - yymsp[-2].minor.yy1005 = yylhsminor.yy1005; +{ yylhsminor.yy493.kind = yymsp[-2].minor.yy633; yylhsminor.yy493.dbName = yymsp[-1].minor.yy665; } + yymsp[-2].minor.yy493 = yylhsminor.yy493; break; case 298: /* table_kind ::= NORMAL */ -{ yymsp[0].minor.yy321 = SHOW_KIND_TABLES_NORMAL; } +{ yymsp[0].minor.yy633 = SHOW_KIND_TABLES_NORMAL; } break; case 299: /* table_kind ::= CHILD */ -{ yymsp[0].minor.yy321 = SHOW_KIND_TABLES_CHILD; } +{ yymsp[0].minor.yy633 = SHOW_KIND_TABLES_CHILD; } break; case 300: /* db_name_cond_opt ::= */ case 305: /* from_db_opt ::= */ yytestcase(yyruleno==305); -{ yymsp[1].minor.yy360 = createDefaultDatabaseCondValue(pCxt); } +{ yymsp[1].minor.yy656 = createDefaultDatabaseCondValue(pCxt); } break; case 301: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy360 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy929); } - yymsp[-1].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy665); } + yymsp[-1].minor.yy656 = yylhsminor.yy656; break; case 303: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy656 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; case 304: /* table_name_cond ::= table_name */ -{ yylhsminor.yy360 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy929); } - yymsp[0].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy665); } + yymsp[0].minor.yy656 = yylhsminor.yy656; break; case 306: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy360 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy929); } +{ yymsp[-1].minor.yy656 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy665); } break; case 310: /* tag_item ::= TBNAME */ -{ yylhsminor.yy360 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } - yymsp[0].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } + yymsp[0].minor.yy656 = yylhsminor.yy656; break; case 313: /* tag_item ::= column_name column_alias */ -{ yylhsminor.yy360 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy929), &yymsp[0].minor.yy929); } - yymsp[-1].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy665), &yymsp[0].minor.yy665); } + yymsp[-1].minor.yy656 = yylhsminor.yy656; break; case 314: /* tag_item ::= column_name AS column_alias */ -{ yylhsminor.yy360 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy929), &yymsp[0].minor.yy929); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy665), &yymsp[0].minor.yy665); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 315: /* db_kind_opt ::= */ -{ yymsp[1].minor.yy321 = SHOW_KIND_ALL; } +{ yymsp[1].minor.yy633 = SHOW_KIND_ALL; } break; case 316: /* db_kind_opt ::= USER */ -{ yymsp[0].minor.yy321 = SHOW_KIND_DATABASES_USER; } +{ yymsp[0].minor.yy633 = SHOW_KIND_DATABASES_USER; } break; case 317: /* db_kind_opt ::= SYSTEM */ -{ yymsp[0].minor.yy321 = SHOW_KIND_DATABASES_SYSTEM; } +{ yymsp[0].minor.yy633 = SHOW_KIND_DATABASES_SYSTEM; } break; case 318: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy345, yymsp[-3].minor.yy360, yymsp[-1].minor.yy360, NULL, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy497, yymsp[-3].minor.yy656, yymsp[-1].minor.yy656, NULL, yymsp[0].minor.yy656); } break; case 319: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy345, yymsp[-5].minor.yy360, yymsp[-3].minor.yy360, yymsp[-1].minor.yy536, NULL); } +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy497, yymsp[-5].minor.yy656, yymsp[-3].minor.yy656, yymsp[-1].minor.yy136, NULL); } break; case 320: /* cmd ::= DROP INDEX exists_opt full_index_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy345, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy497, yymsp[0].minor.yy656); } break; case 321: /* full_index_name ::= index_name */ -{ yylhsminor.yy360 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy929); } - yymsp[0].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy665); } + yymsp[0].minor.yy656 = yylhsminor.yy656; break; case 322: /* full_index_name ::= db_name NK_DOT index_name */ -{ yylhsminor.yy360 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy665, &yymsp[0].minor.yy665); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 323: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy360 = createIndexOption(pCxt, yymsp[-7].minor.yy536, releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), NULL, yymsp[-1].minor.yy360, yymsp[0].minor.yy360); } +{ yymsp[-9].minor.yy656 = createIndexOption(pCxt, yymsp[-7].minor.yy136, releaseRawExprNode(pCxt, yymsp[-3].minor.yy656), NULL, yymsp[-1].minor.yy656, yymsp[0].minor.yy656); } break; case 324: /* 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.yy360 = createIndexOption(pCxt, yymsp[-9].minor.yy536, releaseRawExprNode(pCxt, yymsp[-5].minor.yy360), releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), yymsp[-1].minor.yy360, yymsp[0].minor.yy360); } +{ yymsp[-11].minor.yy656 = createIndexOption(pCxt, yymsp[-9].minor.yy136, releaseRawExprNode(pCxt, yymsp[-5].minor.yy656), releaseRawExprNode(pCxt, yymsp[-3].minor.yy656), yymsp[-1].minor.yy656, yymsp[0].minor.yy656); } break; case 327: /* func ::= sma_func_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy360 = createFunctionNode(pCxt, &yymsp[-3].minor.yy929, yymsp[-1].minor.yy536); } - yymsp[-3].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createFunctionNode(pCxt, &yymsp[-3].minor.yy665, yymsp[-1].minor.yy136); } + yymsp[-3].minor.yy656 = yylhsminor.yy656; break; case 328: /* sma_func_name ::= function_name */ - case 553: /* alias_opt ::= table_alias */ yytestcase(yyruleno==553); -{ yylhsminor.yy929 = yymsp[0].minor.yy929; } - yymsp[0].minor.yy929 = yylhsminor.yy929; + case 574: /* alias_opt ::= table_alias */ yytestcase(yyruleno==574); +{ yylhsminor.yy665 = yymsp[0].minor.yy665; } + yymsp[0].minor.yy665 = yylhsminor.yy665; break; case 333: /* sma_stream_opt ::= */ case 378: /* stream_options ::= */ yytestcase(yyruleno==378); -{ yymsp[1].minor.yy360 = createStreamOptions(pCxt); } +{ yymsp[1].minor.yy656 = createStreamOptions(pCxt); } break; case 334: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy360)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy360); yylhsminor.yy360 = yymsp[-2].minor.yy360; } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ ((SStreamOptions*)yymsp[-2].minor.yy656)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy656); yylhsminor.yy656 = yymsp[-2].minor.yy656; } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 335: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy360)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy360); yylhsminor.yy360 = yymsp[-2].minor.yy360; } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ ((SStreamOptions*)yymsp[-2].minor.yy656)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy656); yylhsminor.yy656 = yymsp[-2].minor.yy656; } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 336: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy360)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy360); yylhsminor.yy360 = yymsp[-2].minor.yy360; } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ ((SStreamOptions*)yymsp[-2].minor.yy656)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy656); yylhsminor.yy656 = yymsp[-2].minor.yy656; } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 337: /* with_meta ::= AS */ -{ yymsp[0].minor.yy580 = 0; } +{ yymsp[0].minor.yy676 = 0; } break; case 338: /* with_meta ::= WITH META AS */ -{ yymsp[-2].minor.yy580 = 1; } +{ yymsp[-2].minor.yy676 = 1; } break; case 339: /* with_meta ::= ONLY META AS */ -{ yymsp[-2].minor.yy580 = 2; } +{ yymsp[-2].minor.yy676 = 2; } break; case 340: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy345, &yymsp[-2].minor.yy929, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy497, &yymsp[-2].minor.yy665, yymsp[0].minor.yy656); } break; case 341: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy345, &yymsp[-3].minor.yy929, &yymsp[0].minor.yy929, yymsp[-2].minor.yy580); } +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy497, &yymsp[-3].minor.yy665, &yymsp[0].minor.yy665, yymsp[-2].minor.yy676); } break; case 342: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy345, &yymsp[-4].minor.yy929, yymsp[-1].minor.yy360, yymsp[-3].minor.yy580, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy497, &yymsp[-4].minor.yy665, yymsp[-1].minor.yy656, yymsp[-3].minor.yy676, yymsp[0].minor.yy656); } break; case 343: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy345, &yymsp[0].minor.yy929); } +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy497, &yymsp[0].minor.yy665); } break; case 344: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy345, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929); } +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy497, &yymsp[-2].minor.yy665, &yymsp[0].minor.yy665); } break; case 345: /* cmd ::= DESC full_table_name */ case 346: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==346); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy656); } break; case 347: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; case 348: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ case 349: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==349); -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy345, yymsp[-1].minor.yy360, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy497, yymsp[-1].minor.yy656, yymsp[0].minor.yy656); } break; case 352: /* explain_options ::= */ -{ yymsp[1].minor.yy360 = createDefaultExplainOptions(pCxt); } +{ yymsp[1].minor.yy656 = createDefaultExplainOptions(pCxt); } break; case 353: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy360 = setExplainVerbose(pCxt, yymsp[-2].minor.yy360, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setExplainVerbose(pCxt, yymsp[-2].minor.yy656, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 354: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy360 = setExplainRatio(pCxt, yymsp[-2].minor.yy360, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setExplainRatio(pCxt, yymsp[-2].minor.yy656, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 355: /* cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy345, yymsp[-9].minor.yy345, &yymsp[-6].minor.yy929, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy912, yymsp[-1].minor.yy580, &yymsp[0].minor.yy929, yymsp[-10].minor.yy345); } +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy497, yymsp[-9].minor.yy497, &yymsp[-6].minor.yy665, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy256, yymsp[-1].minor.yy676, &yymsp[0].minor.yy665, yymsp[-10].minor.yy497); } break; case 356: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy345, &yymsp[0].minor.yy929); } +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy497, &yymsp[0].minor.yy665); } break; case 361: /* language_opt ::= */ case 400: /* on_vgroup_id ::= */ yytestcase(yyruleno==400); -{ yymsp[1].minor.yy929 = nil_token; } +{ yymsp[1].minor.yy665 = nil_token; } break; case 362: /* language_opt ::= LANGUAGE NK_STRING */ case 401: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==401); -{ yymsp[-1].minor.yy929 = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy665 = yymsp[0].minor.yy0; } break; case 365: /* cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy345, yymsp[-2].minor.yy360, &yymsp[-1].minor.yy0, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy497, yymsp[-2].minor.yy656, &yymsp[-1].minor.yy0, yymsp[0].minor.yy656); } break; case 366: /* cmd ::= DROP VIEW exists_opt full_view_name */ -{ pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy345, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy497, yymsp[0].minor.yy656); } break; case 367: /* full_view_name ::= view_name */ -{ yylhsminor.yy360 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy929); } - yymsp[0].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy665); } + yymsp[0].minor.yy656 = yylhsminor.yy656; break; case 368: /* full_view_name ::= db_name NK_DOT view_name */ -{ yylhsminor.yy360 = createViewNode(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = createViewNode(pCxt, &yymsp[-2].minor.yy665, &yymsp[0].minor.yy665); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 369: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy345, &yymsp[-8].minor.yy929, yymsp[-5].minor.yy360, yymsp[-7].minor.yy360, yymsp[-3].minor.yy536, yymsp[-2].minor.yy360, yymsp[0].minor.yy360, yymsp[-4].minor.yy536); } +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy497, &yymsp[-8].minor.yy665, yymsp[-5].minor.yy656, yymsp[-7].minor.yy656, yymsp[-3].minor.yy136, yymsp[-2].minor.yy656, yymsp[0].minor.yy656, yymsp[-4].minor.yy136); } break; case 370: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy345, &yymsp[0].minor.yy929); } +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy497, &yymsp[0].minor.yy665); } break; case 371: /* cmd ::= PAUSE STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy345, &yymsp[0].minor.yy929); } +{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy497, &yymsp[0].minor.yy665); } break; case 372: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ -{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy345, yymsp[-1].minor.yy345, &yymsp[0].minor.yy929); } +{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy497, yymsp[-1].minor.yy497, &yymsp[0].minor.yy665); } break; case 379: /* stream_options ::= stream_options TRIGGER AT_ONCE */ case 380: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==380); -{ yylhsminor.yy360 = setStreamOptions(pCxt, yymsp[-2].minor.yy360, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setStreamOptions(pCxt, yymsp[-2].minor.yy656, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 381: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ yylhsminor.yy360 = setStreamOptions(pCxt, yymsp[-3].minor.yy360, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy360)); } - yymsp[-3].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setStreamOptions(pCxt, yymsp[-3].minor.yy656, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy656)); } + yymsp[-3].minor.yy656 = yylhsminor.yy656; break; case 382: /* stream_options ::= stream_options WATERMARK duration_literal */ -{ yylhsminor.yy360 = setStreamOptions(pCxt, yymsp[-2].minor.yy360, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy360)); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setStreamOptions(pCxt, yymsp[-2].minor.yy656, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy656)); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 383: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -{ yylhsminor.yy360 = setStreamOptions(pCxt, yymsp[-3].minor.yy360, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-3].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setStreamOptions(pCxt, yymsp[-3].minor.yy656, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-3].minor.yy656 = yylhsminor.yy656; break; case 384: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ -{ yylhsminor.yy360 = setStreamOptions(pCxt, yymsp[-2].minor.yy360, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setStreamOptions(pCxt, yymsp[-2].minor.yy656, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 385: /* stream_options ::= stream_options DELETE_MARK duration_literal */ -{ yylhsminor.yy360 = setStreamOptions(pCxt, yymsp[-2].minor.yy360, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy360)); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setStreamOptions(pCxt, yymsp[-2].minor.yy656, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy656)); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; case 386: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ -{ yylhsminor.yy360 = setStreamOptions(pCxt, yymsp[-3].minor.yy360, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-3].minor.yy360 = yylhsminor.yy360; +{ yylhsminor.yy656 = setStreamOptions(pCxt, yymsp[-3].minor.yy656, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-3].minor.yy656 = yylhsminor.yy656; break; case 388: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 593: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==593); - case 617: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==617); -{ yymsp[-3].minor.yy360 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy360); } + case 614: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==614); + case 638: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==638); +{ yymsp[-3].minor.yy656 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy656); } break; case 391: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } @@ -6261,604 +6043,663 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; case 396: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ -{ pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy929); } +{ pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy665); } break; case 397: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; case 398: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy536); } +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy136); } break; case 399: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; case 402: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy536 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +{ yymsp[-1].minor.yy136 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; case 404: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy360, yymsp[0].minor.yy360); } +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy656, yymsp[0].minor.yy656); } break; case 407: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -{ yymsp[-6].minor.yy360 = createInsertStmt(pCxt, yymsp[-4].minor.yy360, yymsp[-2].minor.yy536, yymsp[0].minor.yy360); } +{ yymsp[-6].minor.yy656 = createInsertStmt(pCxt, yymsp[-4].minor.yy656, yymsp[-2].minor.yy136, yymsp[0].minor.yy656); } break; case 408: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ -{ yymsp[-3].minor.yy360 = createInsertStmt(pCxt, yymsp[-1].minor.yy360, NULL, yymsp[0].minor.yy360); } +{ yymsp[-3].minor.yy656 = createInsertStmt(pCxt, yymsp[-1].minor.yy656, NULL, yymsp[0].minor.yy656); } break; - case 409: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy360 = yylhsminor.yy360; + case 409: /* tags_literal ::= NK_INTEGER */ + case 415: /* tags_literal ::= NK_BIN */ yytestcase(yyruleno==415); + case 418: /* tags_literal ::= NK_HEX */ yytestcase(yyruleno==418); +{ yylhsminor.yy656 = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy656 = yylhsminor.yy656; break; - case 410: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy360 = yylhsminor.yy360; - break; - case 411: /* literal ::= NK_STRING */ -{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy360 = yylhsminor.yy360; - break; - case 412: /* literal ::= NK_BOOL */ -{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy360 = yylhsminor.yy360; - break; - case 413: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy360 = yylhsminor.yy360; - break; - case 414: /* literal ::= duration_literal */ - case 424: /* signed_literal ::= signed */ yytestcase(yyruleno==424); - case 447: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==447); - case 448: /* expression ::= literal */ yytestcase(yyruleno==448); - case 450: /* expression ::= column_reference */ yytestcase(yyruleno==450); - case 451: /* expression ::= function_expression */ yytestcase(yyruleno==451); - case 452: /* expression ::= case_when_expression */ yytestcase(yyruleno==452); - case 485: /* function_expression ::= literal_func */ yytestcase(yyruleno==485); - case 534: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==534); - case 538: /* boolean_primary ::= predicate */ yytestcase(yyruleno==538); - case 540: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==540); - case 541: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==541); - case 544: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==544); - case 546: /* table_reference ::= table_primary */ yytestcase(yyruleno==546); - case 547: /* table_reference ::= joined_table */ yytestcase(yyruleno==547); - case 551: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==551); - case 619: /* query_simple ::= query_specification */ yytestcase(yyruleno==619); - case 620: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==620); - case 623: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==623); - case 625: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==625); -{ yylhsminor.yy360 = yymsp[0].minor.yy360; } - yymsp[0].minor.yy360 = yylhsminor.yy360; - break; - case 415: /* literal ::= NULL */ -{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy360 = yylhsminor.yy360; - break; - case 416: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy360 = yylhsminor.yy360; - break; - case 417: /* duration_literal ::= NK_VARIABLE */ - case 594: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==594); - case 595: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==595); - case 596: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==596); -{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy360 = yylhsminor.yy360; - break; - case 418: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy360 = yylhsminor.yy360; - break; - case 419: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - break; - case 420: /* signed ::= NK_MINUS NK_INTEGER */ + case 410: /* tags_literal ::= NK_PLUS NK_INTEGER */ + case 411: /* tags_literal ::= NK_MINUS NK_INTEGER */ yytestcase(yyruleno==411); + case 416: /* tags_literal ::= NK_PLUS NK_BIN */ yytestcase(yyruleno==416); + case 417: /* tags_literal ::= NK_MINUS NK_BIN */ yytestcase(yyruleno==417); + case 419: /* tags_literal ::= NK_PLUS NK_HEX */ yytestcase(yyruleno==419); + case 420: /* tags_literal ::= NK_MINUS NK_HEX */ yytestcase(yyruleno==420); { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy656 = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); } - yymsp[-1].minor.yy360 = yylhsminor.yy360; + yymsp[-1].minor.yy656 = yylhsminor.yy656; break; - case 421: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy360 = yylhsminor.yy360; + case 412: /* tags_literal ::= NK_FLOAT */ +{ yylhsminor.yy656 = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy656 = yylhsminor.yy656; break; - case 422: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - break; - case 423: /* signed ::= NK_MINUS NK_FLOAT */ + case 413: /* tags_literal ::= NK_PLUS NK_FLOAT */ + case 414: /* tags_literal ::= NK_MINUS NK_FLOAT */ yytestcase(yyruleno==414); { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy656 = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t, NULL); } - yymsp[-1].minor.yy360 = yylhsminor.yy360; + yymsp[-1].minor.yy656 = yylhsminor.yy656; break; - case 425: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy360 = yylhsminor.yy360; + case 421: /* tags_literal ::= NK_STRING */ +{ yylhsminor.yy656 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy656 = yylhsminor.yy656; break; - case 426: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy360 = yylhsminor.yy360; + case 422: /* tags_literal ::= NK_BOOL */ +{ yylhsminor.yy656 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy656 = yylhsminor.yy656; break; - case 427: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 423: /* tags_literal ::= NULL */ +{ yylhsminor.yy656 = createRawValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy656 = yylhsminor.yy656; break; - case 428: /* signed_literal ::= duration_literal */ - case 430: /* signed_literal ::= literal_func */ yytestcase(yyruleno==430); - case 505: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==505); - case 571: /* select_item ::= common_expression */ yytestcase(yyruleno==571); - case 581: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==581); - case 624: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==624); - case 626: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==626); - case 639: /* search_condition ::= common_expression */ yytestcase(yyruleno==639); -{ yylhsminor.yy360 = releaseRawExprNode(pCxt, yymsp[0].minor.yy360); } - yymsp[0].minor.yy360 = yylhsminor.yy360; + case 424: /* tags_literal ::= literal_func */ +{ yylhsminor.yy656 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, NULL, yymsp[0].minor.yy656); } + yymsp[0].minor.yy656 = yylhsminor.yy656; break; - case 429: /* signed_literal ::= NULL */ -{ yylhsminor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy360 = yylhsminor.yy360; - break; - case 431: /* signed_literal ::= NK_QUESTION */ -{ yylhsminor.yy360 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy360 = yylhsminor.yy360; - break; - case 449: /* expression ::= pseudo_column */ -{ yylhsminor.yy360 = yymsp[0].minor.yy360; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy360, true); } - yymsp[0].minor.yy360 = yylhsminor.yy360; - break; - case 453: /* expression ::= NK_LP expression NK_RP */ - case 539: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==539); - case 638: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==638); -{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy360)); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; - break; - case 454: /* expression ::= NK_PLUS expr_or_subquery */ + case 425: /* tags_literal ::= literal_func NK_PLUS duration_literal */ + case 426: /* tags_literal ::= literal_func NK_MINUS duration_literal */ yytestcase(yyruleno==426); { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy360)); + SToken l = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy656); + SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy656); + l.n = (r.z + r.n) - l.z; + yylhsminor.yy656 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, yymsp[-2].minor.yy656, yymsp[0].minor.yy656); } - yymsp[-1].minor.yy360 = yylhsminor.yy360; + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; - case 455: /* expression ::= NK_MINUS expr_or_subquery */ + case 429: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy656 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 430: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy656 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 431: /* literal ::= NK_STRING */ +{ yylhsminor.yy656 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 432: /* literal ::= NK_BOOL */ +{ yylhsminor.yy656 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 433: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy656 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy656 = yylhsminor.yy656; + break; + case 434: /* literal ::= duration_literal */ + case 444: /* signed_literal ::= signed */ yytestcase(yyruleno==444); + case 467: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==467); + case 468: /* expression ::= literal */ yytestcase(yyruleno==468); + case 470: /* expression ::= column_reference */ yytestcase(yyruleno==470); + case 471: /* expression ::= function_expression */ yytestcase(yyruleno==471); + case 472: /* expression ::= case_when_expression */ yytestcase(yyruleno==472); + case 505: /* function_expression ::= literal_func */ yytestcase(yyruleno==505); + case 555: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==555); + case 559: /* boolean_primary ::= predicate */ yytestcase(yyruleno==559); + case 561: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==561); + case 562: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==562); + case 565: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==565); + case 567: /* table_reference ::= table_primary */ yytestcase(yyruleno==567); + case 568: /* table_reference ::= joined_table */ yytestcase(yyruleno==568); + case 572: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==572); + case 640: /* query_simple ::= query_specification */ yytestcase(yyruleno==640); + case 641: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==641); + case 644: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==644); + case 646: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==646); +{ yylhsminor.yy656 = yymsp[0].minor.yy656; } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 435: /* literal ::= NULL */ +{ yylhsminor.yy656 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 436: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy656 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 437: /* duration_literal ::= NK_VARIABLE */ + case 615: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==615); + case 616: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==616); + case 617: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==617); +{ yylhsminor.yy656 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 438: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy656 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 439: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy656 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + break; + case 440: /* signed ::= NK_MINUS NK_INTEGER */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy360), NULL)); + SToken t = yymsp[-1].minor.yy0; + t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; + yylhsminor.yy656 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy360 = yylhsminor.yy360; + yymsp[-1].minor.yy656 = yylhsminor.yy656; break; - case 456: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + case 441: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy656 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 442: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy656 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + break; + case 443: /* signed ::= NK_MINUS NK_FLOAT */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); + SToken t = yymsp[-1].minor.yy0; + t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; + yylhsminor.yy656 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; + yymsp[-1].minor.yy656 = yylhsminor.yy656; break; - case 457: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + case 445: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy656 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 446: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy656 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 447: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy656 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + break; + case 448: /* signed_literal ::= duration_literal */ + case 450: /* signed_literal ::= literal_func */ yytestcase(yyruleno==450); + case 526: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==526); + case 592: /* select_item ::= common_expression */ yytestcase(yyruleno==592); + case 602: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==602); + case 645: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==645); + case 647: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==647); + case 660: /* search_condition ::= common_expression */ yytestcase(yyruleno==660); +{ yylhsminor.yy656 = releaseRawExprNode(pCxt, yymsp[0].minor.yy656); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 449: /* signed_literal ::= NULL */ +{ yylhsminor.yy656 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 451: /* signed_literal ::= NK_QUESTION */ +{ yylhsminor.yy656 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 469: /* expression ::= pseudo_column */ +{ yylhsminor.yy656 = yymsp[0].minor.yy656; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy656, true); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 473: /* expression ::= NK_LP expression NK_RP */ + case 560: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==560); + case 659: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==659); +{ yylhsminor.yy656 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy656)); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; + break; + case 474: /* expression ::= NK_PLUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy656)); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; + yymsp[-1].minor.yy656 = yylhsminor.yy656; break; - case 458: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + case 475: /* expression ::= NK_MINUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy656), NULL)); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; + yymsp[-1].minor.yy656 = yylhsminor.yy656; break; - case 459: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + case 476: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy656); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), releaseRawExprNode(pCxt, yymsp[0].minor.yy656))); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; - case 460: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ + case 477: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy656); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), releaseRawExprNode(pCxt, yymsp[0].minor.yy656))); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; - case 461: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 478: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy656); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), releaseRawExprNode(pCxt, yymsp[0].minor.yy656))); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; - case 462: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + case 479: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy656); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), releaseRawExprNode(pCxt, yymsp[0].minor.yy656))); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; - case 463: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + case 480: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy656); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), releaseRawExprNode(pCxt, yymsp[0].minor.yy656))); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; - case 466: /* column_reference ::= column_name */ -{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy929, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy929)); } - yymsp[0].minor.yy360 = yylhsminor.yy360; - break; - case 467: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929, createColumnNode(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929)); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; - break; - case 468: /* column_reference ::= NK_ALIAS */ -{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy360 = yylhsminor.yy360; - break; - case 469: /* column_reference ::= table_name NK_DOT NK_ALIAS */ -{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; - break; - case 470: /* pseudo_column ::= ROWTS */ - case 471: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==471); - case 473: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==473); - case 474: /* pseudo_column ::= QEND */ yytestcase(yyruleno==474); - case 475: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==475); - case 476: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==476); - case 477: /* pseudo_column ::= WEND */ yytestcase(yyruleno==477); - case 478: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==478); - case 479: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==479); - case 480: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==480); - case 481: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==481); - case 487: /* literal_func ::= NOW */ yytestcase(yyruleno==487); -{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy360 = yylhsminor.yy360; - break; - case 472: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy929)))); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; - break; - case 482: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 483: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==483); -{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy929, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy929, yymsp[-1].minor.yy536)); } - yymsp[-3].minor.yy360 = yylhsminor.yy360; - break; - case 484: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ -{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), yymsp[-1].minor.yy912)); } - yymsp[-5].minor.yy360 = yylhsminor.yy360; - break; - case 486: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy929, NULL)); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; - break; - case 501: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy536 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy536 = yylhsminor.yy536; - break; - case 506: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 574: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==574); -{ yylhsminor.yy360 = createColumnNode(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; - break; - case 507: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy536, yymsp[-1].minor.yy360)); } - yymsp[-3].minor.yy360 = yylhsminor.yy360; - break; - case 508: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), yymsp[-2].minor.yy536, yymsp[-1].minor.yy360)); } - yymsp[-4].minor.yy360 = yylhsminor.yy360; - break; - case 511: /* when_then_expr ::= WHEN common_expression THEN common_expression */ -{ yymsp[-3].minor.yy360 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360)); } - break; - case 513: /* case_when_else_opt ::= ELSE common_expression */ -{ yymsp[-1].minor.yy360 = releaseRawExprNode(pCxt, yymsp[0].minor.yy360); } - break; - case 514: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 519: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==519); + case 481: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy252, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; - case 515: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + case 482: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy360); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy360), releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy656); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), releaseRawExprNode(pCxt, yymsp[0].minor.yy656))); } - yymsp[-4].minor.yy360 = yylhsminor.yy360; + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; - case 516: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + case 483: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy360); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy360), releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy656); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), releaseRawExprNode(pCxt, yymsp[0].minor.yy656))); } - yymsp[-5].minor.yy360 = yylhsminor.yy360; + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; - case 517: /* predicate ::= expr_or_subquery IS NULL */ + case 486: /* column_reference ::= column_name */ +{ yylhsminor.yy656 = createRawExprNode(pCxt, &yymsp[0].minor.yy665, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy665)); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 487: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy656 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy665, &yymsp[0].minor.yy665, createColumnNode(pCxt, &yymsp[-2].minor.yy665, &yymsp[0].minor.yy665)); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; + break; + case 488: /* column_reference ::= NK_ALIAS */ +{ yylhsminor.yy656 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 489: /* column_reference ::= table_name NK_DOT NK_ALIAS */ +{ yylhsminor.yy656 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy665, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy665, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; + break; + case 490: /* pseudo_column ::= ROWTS */ + case 491: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==491); + case 493: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==493); + case 494: /* pseudo_column ::= QEND */ yytestcase(yyruleno==494); + case 495: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==495); + case 496: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==496); + case 497: /* pseudo_column ::= WEND */ yytestcase(yyruleno==497); + case 498: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==498); + case 499: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==499); + case 500: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==500); + case 501: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==501); + case 507: /* literal_func ::= NOW */ yytestcase(yyruleno==507); + case 508: /* literal_func ::= TODAY */ yytestcase(yyruleno==508); +{ yylhsminor.yy656 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 492: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy656 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy665, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy665)))); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; + break; + case 502: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 503: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==503); +{ yylhsminor.yy656 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy665, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy665, yymsp[-1].minor.yy136)); } + yymsp[-3].minor.yy656 = yylhsminor.yy656; + break; + case 504: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ +{ yylhsminor.yy656 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy656), yymsp[-1].minor.yy256)); } + yymsp[-5].minor.yy656 = yylhsminor.yy656; + break; + case 506: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy656 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy665, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy665, NULL)); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; + break; + case 522: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy136 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy136 = yylhsminor.yy136; + break; + case 527: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 595: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==595); +{ yylhsminor.yy656 = createColumnNode(pCxt, &yymsp[-2].minor.yy665, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; + break; + case 528: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ +{ yylhsminor.yy656 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy136, yymsp[-1].minor.yy656)); } + yymsp[-3].minor.yy656 = yylhsminor.yy656; + break; + case 529: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ +{ yylhsminor.yy656 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy656), yymsp[-2].minor.yy136, yymsp[-1].minor.yy656)); } + yymsp[-4].minor.yy656 = yylhsminor.yy656; + break; + case 532: /* when_then_expr ::= WHEN common_expression THEN common_expression */ +{ yymsp[-3].minor.yy656 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), releaseRawExprNode(pCxt, yymsp[0].minor.yy656)); } + break; + case 534: /* case_when_else_opt ::= ELSE common_expression */ +{ yymsp[-1].minor.yy656 = releaseRawExprNode(pCxt, yymsp[0].minor.yy656); } + break; + case 535: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 540: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==540); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy656); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy836, releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), releaseRawExprNode(pCxt, yymsp[0].minor.yy656))); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; - case 518: /* predicate ::= expr_or_subquery IS NOT NULL */ + case 536: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy656); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy656), releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), releaseRawExprNode(pCxt, yymsp[0].minor.yy656))); } - yymsp[-3].minor.yy360 = yylhsminor.yy360; + yymsp[-4].minor.yy656 = yylhsminor.yy656; break; - case 520: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy252 = OP_TYPE_LOWER_THAN; } - break; - case 521: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy252 = OP_TYPE_GREATER_THAN; } - break; - case 522: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy252 = OP_TYPE_LOWER_EQUAL; } - break; - case 523: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy252 = OP_TYPE_GREATER_EQUAL; } - break; - case 524: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy252 = OP_TYPE_NOT_EQUAL; } - break; - case 525: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy252 = OP_TYPE_EQUAL; } - break; - case 526: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy252 = OP_TYPE_LIKE; } - break; - case 527: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy252 = OP_TYPE_NOT_LIKE; } - break; - case 528: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy252 = OP_TYPE_MATCH; } - break; - case 529: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy252 = OP_TYPE_NMATCH; } - break; - case 530: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy252 = OP_TYPE_JSON_CONTAINS; } - break; - case 531: /* in_op ::= IN */ -{ yymsp[0].minor.yy252 = OP_TYPE_IN; } - break; - case 532: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy252 = OP_TYPE_NOT_IN; } - break; - case 533: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy536)); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; - break; - case 535: /* boolean_value_expression ::= NOT boolean_primary */ + case 537: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy360), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy656); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy656), releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), releaseRawExprNode(pCxt, yymsp[0].minor.yy656))); } - yymsp[-1].minor.yy360 = yylhsminor.yy360; + yymsp[-5].minor.yy656 = yylhsminor.yy656; break; - case 536: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 538: /* predicate ::= expr_or_subquery IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), NULL)); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; - case 537: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 539: /* predicate ::= expr_or_subquery IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); - yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy656), NULL)); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; + yymsp[-3].minor.yy656 = yylhsminor.yy656; break; - case 545: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy360 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy360, yymsp[0].minor.yy360, NULL); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; + case 541: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy836 = OP_TYPE_LOWER_THAN; } break; - case 548: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy360 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy929, &yymsp[0].minor.yy929); } - yymsp[-1].minor.yy360 = yylhsminor.yy360; + case 542: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy836 = OP_TYPE_GREATER_THAN; } break; - case 549: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy360 = createRealTableNode(pCxt, &yymsp[-3].minor.yy929, &yymsp[-1].minor.yy929, &yymsp[0].minor.yy929); } - yymsp[-3].minor.yy360 = yylhsminor.yy360; + case 543: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy836 = OP_TYPE_LOWER_EQUAL; } break; - case 550: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy360 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy360), &yymsp[0].minor.yy929); } - yymsp[-1].minor.yy360 = yylhsminor.yy360; + case 544: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy836 = OP_TYPE_GREATER_EQUAL; } break; - case 552: /* alias_opt ::= */ -{ yymsp[1].minor.yy929 = nil_token; } + case 545: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy836 = OP_TYPE_NOT_EQUAL; } break; - case 554: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy929 = yymsp[0].minor.yy929; } + case 546: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy836 = OP_TYPE_EQUAL; } break; - case 555: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 556: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==556); -{ yymsp[-2].minor.yy360 = yymsp[-1].minor.yy360; } + case 547: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy836 = OP_TYPE_LIKE; } break; - case 557: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy360 = createJoinTableNode(pCxt, yymsp[-4].minor.yy596, yymsp[-5].minor.yy360, yymsp[-2].minor.yy360, yymsp[0].minor.yy360); } - yymsp[-5].minor.yy360 = yylhsminor.yy360; + case 548: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy836 = OP_TYPE_NOT_LIKE; } break; - case 558: /* join_type ::= */ -{ yymsp[1].minor.yy596 = JOIN_TYPE_INNER; } + case 549: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy836 = OP_TYPE_MATCH; } break; - case 559: /* join_type ::= INNER */ -{ yymsp[0].minor.yy596 = JOIN_TYPE_INNER; } + case 550: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy836 = OP_TYPE_NMATCH; } break; - case 560: /* query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_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 551: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy836 = OP_TYPE_JSON_CONTAINS; } + break; + case 552: /* in_op ::= IN */ +{ yymsp[0].minor.yy836 = OP_TYPE_IN; } + break; + case 553: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy836 = OP_TYPE_NOT_IN; } + break; + case 554: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +{ yylhsminor.yy656 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy136)); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; + break; + case 556: /* boolean_value_expression ::= NOT boolean_primary */ { - yymsp[-13].minor.yy360 = createSelectStmt(pCxt, yymsp[-11].minor.yy345, yymsp[-9].minor.yy536, yymsp[-8].minor.yy360, yymsp[-12].minor.yy536); - yymsp[-13].minor.yy360 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy360, yymsp[-10].minor.yy345); - yymsp[-13].minor.yy360 = addWhereClause(pCxt, yymsp[-13].minor.yy360, yymsp[-7].minor.yy360); - yymsp[-13].minor.yy360 = addPartitionByClause(pCxt, yymsp[-13].minor.yy360, yymsp[-6].minor.yy536); - yymsp[-13].minor.yy360 = addWindowClauseClause(pCxt, yymsp[-13].minor.yy360, yymsp[-2].minor.yy360); - yymsp[-13].minor.yy360 = addGroupByClause(pCxt, yymsp[-13].minor.yy360, yymsp[-1].minor.yy536); - yymsp[-13].minor.yy360 = addHavingClause(pCxt, yymsp[-13].minor.yy360, yymsp[0].minor.yy360); - yymsp[-13].minor.yy360 = addRangeClause(pCxt, yymsp[-13].minor.yy360, yymsp[-5].minor.yy360); - yymsp[-13].minor.yy360 = addEveryClause(pCxt, yymsp[-13].minor.yy360, yymsp[-4].minor.yy360); - yymsp[-13].minor.yy360 = addFillClause(pCxt, yymsp[-13].minor.yy360, yymsp[-3].minor.yy360); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy656), NULL)); } + yymsp[-1].minor.yy656 = yylhsminor.yy656; break; - case 561: /* hint_list ::= */ -{ yymsp[1].minor.yy536 = createHintNodeList(pCxt, NULL); } - break; - case 562: /* hint_list ::= NK_HINT */ -{ yylhsminor.yy536 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy536 = yylhsminor.yy536; - break; - case 567: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy345 = false; } - break; - case 570: /* select_item ::= NK_STAR */ -{ yylhsminor.yy360 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy360 = yylhsminor.yy360; - break; - case 572: /* select_item ::= common_expression column_alias */ - case 582: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==582); -{ yylhsminor.yy360 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy360), &yymsp[0].minor.yy929); } - yymsp[-1].minor.yy360 = yylhsminor.yy360; - break; - case 573: /* select_item ::= common_expression AS column_alias */ - case 583: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==583); -{ yylhsminor.yy360 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), &yymsp[0].minor.yy929); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; - break; - case 578: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 608: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==608); - case 628: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==628); -{ yymsp[-2].minor.yy536 = yymsp[0].minor.yy536; } - break; - case 585: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ -{ yymsp[-5].minor.yy360 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), releaseRawExprNode(pCxt, yymsp[-1].minor.yy360)); } - break; - case 586: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy360 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy360)); } - break; - case 587: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy360 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), NULL, yymsp[-1].minor.yy360, yymsp[0].minor.yy360); } - break; - case 588: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy360 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy360), releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), yymsp[-1].minor.yy360, yymsp[0].minor.yy360); } - break; - case 589: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ -{ yymsp[-6].minor.yy360 = createEventWindowNode(pCxt, yymsp[-3].minor.yy360, yymsp[0].minor.yy360); } - break; - case 590: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy360 = createCountWindowNode(pCxt, &yymsp[-1].minor.yy0, &yymsp[-1].minor.yy0); } - break; - case 591: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy360 = createCountWindowNode(pCxt, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0); } - break; - case 598: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy360 = createFillNode(pCxt, yymsp[-1].minor.yy358, NULL); } - break; - case 599: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ -{ yymsp[-5].minor.yy360 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy536)); } - break; - case 600: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ -{ yymsp[-5].minor.yy360 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy536)); } - break; - case 601: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy358 = FILL_MODE_NONE; } - break; - case 602: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy358 = FILL_MODE_PREV; } - break; - case 603: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy358 = FILL_MODE_NULL; } - break; - case 604: /* fill_mode ::= NULL_F */ -{ yymsp[0].minor.yy358 = FILL_MODE_NULL_F; } - break; - case 605: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy358 = FILL_MODE_LINEAR; } - break; - case 606: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy358 = FILL_MODE_NEXT; } - break; - case 609: /* group_by_list ::= expr_or_subquery */ -{ yylhsminor.yy536 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); } - yymsp[0].minor.yy536 = yylhsminor.yy536; - break; - case 610: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -{ yylhsminor.yy536 = addNodeToList(pCxt, yymsp[-2].minor.yy536, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); } - yymsp[-2].minor.yy536 = yylhsminor.yy536; - break; - case 614: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -{ yymsp[-5].minor.yy360 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), releaseRawExprNode(pCxt, yymsp[-1].minor.yy360)); } - break; - case 615: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy360 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy360)); } - break; - case 618: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 557: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - yylhsminor.yy360 = addOrderByClause(pCxt, yymsp[-3].minor.yy360, yymsp[-2].minor.yy536); - yylhsminor.yy360 = addSlimitClause(pCxt, yylhsminor.yy360, yymsp[-1].minor.yy360); - yylhsminor.yy360 = addLimitClause(pCxt, yylhsminor.yy360, yymsp[0].minor.yy360); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy656); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), releaseRawExprNode(pCxt, yymsp[0].minor.yy656))); } - yymsp[-3].minor.yy360 = yylhsminor.yy360; + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; - case 621: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -{ yylhsminor.yy360 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy360, yymsp[0].minor.yy360); } - yymsp[-3].minor.yy360 = yylhsminor.yy360; + case 558: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy656); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy656); + yylhsminor.yy656 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), releaseRawExprNode(pCxt, yymsp[0].minor.yy656))); + } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; - case 622: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -{ yylhsminor.yy360 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy360, yymsp[0].minor.yy360); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; + case 566: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy656 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy656, yymsp[0].minor.yy656, NULL); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; break; - case 630: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 634: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==634); -{ yymsp[-1].minor.yy360 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 569: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy656 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy665, &yymsp[0].minor.yy665); } + yymsp[-1].minor.yy656 = yylhsminor.yy656; break; - case 631: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 635: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==635); -{ yymsp[-3].minor.yy360 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 570: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy656 = createRealTableNode(pCxt, &yymsp[-3].minor.yy665, &yymsp[-1].minor.yy665, &yymsp[0].minor.yy665); } + yymsp[-3].minor.yy656 = yylhsminor.yy656; break; - case 632: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 636: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==636); -{ yymsp[-3].minor.yy360 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 571: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy656 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy656), &yymsp[0].minor.yy665); } + yymsp[-1].minor.yy656 = yylhsminor.yy656; break; - case 637: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy360); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; + case 573: /* alias_opt ::= */ +{ yymsp[1].minor.yy665 = nil_token; } break; - case 642: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy360 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), yymsp[-1].minor.yy642, yymsp[0].minor.yy585); } - yymsp[-2].minor.yy360 = yylhsminor.yy360; + case 575: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy665 = yymsp[0].minor.yy665; } break; - case 643: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy642 = ORDER_ASC; } + case 576: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 577: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==577); +{ yymsp[-2].minor.yy656 = yymsp[-1].minor.yy656; } break; - case 644: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy642 = ORDER_ASC; } + case 578: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy656 = createJoinTableNode(pCxt, yymsp[-4].minor.yy660, yymsp[-5].minor.yy656, yymsp[-2].minor.yy656, yymsp[0].minor.yy656); } + yymsp[-5].minor.yy656 = yylhsminor.yy656; break; - case 645: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy642 = ORDER_DESC; } + case 579: /* join_type ::= */ +{ yymsp[1].minor.yy660 = JOIN_TYPE_INNER; } break; - case 646: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy585 = NULL_ORDER_DEFAULT; } + case 580: /* join_type ::= INNER */ +{ yymsp[0].minor.yy660 = JOIN_TYPE_INNER; } break; - case 647: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy585 = NULL_ORDER_FIRST; } + case 581: /* query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_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[-13].minor.yy656 = createSelectStmt(pCxt, yymsp[-11].minor.yy497, yymsp[-9].minor.yy136, yymsp[-8].minor.yy656, yymsp[-12].minor.yy136); + yymsp[-13].minor.yy656 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy656, yymsp[-10].minor.yy497); + yymsp[-13].minor.yy656 = addWhereClause(pCxt, yymsp[-13].minor.yy656, yymsp[-7].minor.yy656); + yymsp[-13].minor.yy656 = addPartitionByClause(pCxt, yymsp[-13].minor.yy656, yymsp[-6].minor.yy136); + yymsp[-13].minor.yy656 = addWindowClauseClause(pCxt, yymsp[-13].minor.yy656, yymsp[-2].minor.yy656); + yymsp[-13].minor.yy656 = addGroupByClause(pCxt, yymsp[-13].minor.yy656, yymsp[-1].minor.yy136); + yymsp[-13].minor.yy656 = addHavingClause(pCxt, yymsp[-13].minor.yy656, yymsp[0].minor.yy656); + yymsp[-13].minor.yy656 = addRangeClause(pCxt, yymsp[-13].minor.yy656, yymsp[-5].minor.yy656); + yymsp[-13].minor.yy656 = addEveryClause(pCxt, yymsp[-13].minor.yy656, yymsp[-4].minor.yy656); + yymsp[-13].minor.yy656 = addFillClause(pCxt, yymsp[-13].minor.yy656, yymsp[-3].minor.yy656); + } break; - case 648: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy585 = NULL_ORDER_LAST; } + case 582: /* hint_list ::= */ +{ yymsp[1].minor.yy136 = createHintNodeList(pCxt, NULL); } + break; + case 583: /* hint_list ::= NK_HINT */ +{ yylhsminor.yy136 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy136 = yylhsminor.yy136; + break; + case 588: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy497 = false; } + break; + case 591: /* select_item ::= NK_STAR */ +{ yylhsminor.yy656 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy656 = yylhsminor.yy656; + break; + case 593: /* select_item ::= common_expression column_alias */ + case 603: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==603); +{ yylhsminor.yy656 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy656), &yymsp[0].minor.yy665); } + yymsp[-1].minor.yy656 = yylhsminor.yy656; + break; + case 594: /* select_item ::= common_expression AS column_alias */ + case 604: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==604); +{ yylhsminor.yy656 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), &yymsp[0].minor.yy665); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; + break; + case 599: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 629: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==629); + case 649: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==649); +{ yymsp[-2].minor.yy136 = yymsp[0].minor.yy136; } + break; + case 606: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ +{ yymsp[-5].minor.yy656 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy656), releaseRawExprNode(pCxt, yymsp[-1].minor.yy656)); } + break; + case 607: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ +{ yymsp[-3].minor.yy656 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy656)); } + break; + case 608: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy656 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy656), NULL, yymsp[-1].minor.yy656, yymsp[0].minor.yy656); } + break; + case 609: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy656 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy656), releaseRawExprNode(pCxt, yymsp[-3].minor.yy656), yymsp[-1].minor.yy656, yymsp[0].minor.yy656); } + break; + case 610: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ +{ yymsp[-6].minor.yy656 = createEventWindowNode(pCxt, yymsp[-3].minor.yy656, yymsp[0].minor.yy656); } + break; + case 611: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy656 = createCountWindowNode(pCxt, &yymsp[-1].minor.yy0, &yymsp[-1].minor.yy0); } + break; + case 612: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy656 = createCountWindowNode(pCxt, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0); } + break; + case 619: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy656 = createFillNode(pCxt, yymsp[-1].minor.yy822, NULL); } + break; + case 620: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ +{ yymsp[-5].minor.yy656 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy136)); } + break; + case 621: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ +{ yymsp[-5].minor.yy656 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy136)); } + break; + case 622: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy822 = FILL_MODE_NONE; } + break; + case 623: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy822 = FILL_MODE_PREV; } + break; + case 624: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy822 = FILL_MODE_NULL; } + break; + case 625: /* fill_mode ::= NULL_F */ +{ yymsp[0].minor.yy822 = FILL_MODE_NULL_F; } + break; + case 626: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy822 = FILL_MODE_LINEAR; } + break; + case 627: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy822 = FILL_MODE_NEXT; } + break; + case 630: /* group_by_list ::= expr_or_subquery */ +{ yylhsminor.yy136 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy656))); } + yymsp[0].minor.yy136 = yylhsminor.yy136; + break; + case 631: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ +{ yylhsminor.yy136 = addNodeToList(pCxt, yymsp[-2].minor.yy136, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy656))); } + yymsp[-2].minor.yy136 = yylhsminor.yy136; + break; + case 635: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +{ yymsp[-5].minor.yy656 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy656), releaseRawExprNode(pCxt, yymsp[-1].minor.yy656)); } + break; + case 636: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ +{ yymsp[-3].minor.yy656 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy656)); } + break; + case 639: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ +{ + yylhsminor.yy656 = addOrderByClause(pCxt, yymsp[-3].minor.yy656, yymsp[-2].minor.yy136); + yylhsminor.yy656 = addSlimitClause(pCxt, yylhsminor.yy656, yymsp[-1].minor.yy656); + yylhsminor.yy656 = addLimitClause(pCxt, yylhsminor.yy656, yymsp[0].minor.yy656); + } + yymsp[-3].minor.yy656 = yylhsminor.yy656; + break; + case 642: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +{ yylhsminor.yy656 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy656, yymsp[0].minor.yy656); } + yymsp[-3].minor.yy656 = yylhsminor.yy656; + break; + case 643: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +{ yylhsminor.yy656 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy656, yymsp[0].minor.yy656); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; + break; + case 651: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 655: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==655); +{ yymsp[-1].minor.yy656 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + break; + case 652: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 656: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==656); +{ yymsp[-3].minor.yy656 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + break; + case 653: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 657: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==657); +{ yymsp[-3].minor.yy656 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + break; + case 658: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy656 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy656); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; + break; + case 663: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy656 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy656), yymsp[-1].minor.yy674, yymsp[0].minor.yy73); } + yymsp[-2].minor.yy656 = yylhsminor.yy656; + break; + case 664: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy674 = ORDER_ASC; } + break; + case 665: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy674 = ORDER_ASC; } + break; + case 666: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy674 = ORDER_DESC; } + break; + case 667: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy73 = NULL_ORDER_DEFAULT; } + break; + case 668: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy73 = NULL_ORDER_FIRST; } + break; + case 669: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy73 = NULL_ORDER_LAST; } break; default: break; @@ -7015,56 +6856,12 @@ void Parse( } #endif - while(1){ /* Exit by "break" */ - assert( yypParser->yytos>=yypParser->yystack ); + do{ assert( yyact==yypParser->yytos->stateno ); yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); if( yyact >= YY_MIN_REDUCE ){ - unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */ -#ifndef NDEBUG - assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); - if( yyTraceFILE ){ - int yysize = yyRuleInfoNRhs[yyruleno]; - if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", - yyTracePrompt, - yyruleno, yyRuleName[yyruleno], - yyrulenoyytos[yysize].stateno); - }else{ - fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n", - yyTracePrompt, yyruleno, yyRuleName[yyruleno], - yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ - yypParser->yyhwm++; - assert( yypParser->yyhwm == - (int)(yypParser->yytos - yypParser->yystack)); - } -#endif -#if YYSTACKDEPTH>0 - if( yypParser->yytos>=yypParser->yystackEnd ){ - yyStackOverflow(yypParser); - break; - } -#else - if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ - if( yyGrowStack(yypParser) ){ - yyStackOverflow(yypParser); - break; - } - } -#endif - } - yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor ParseCTX_PARAM); + yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor, + yyminor ParseCTX_PARAM); }else if( yyact <= YY_MAX_SHIFTREDUCE ){ yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); #ifndef YYNOERRORRECOVERY @@ -7120,13 +6917,14 @@ void Parse( yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); yymajor = YYNOCODE; }else{ - while( yypParser->yytos > yypParser->yystack ){ - yyact = yy_find_reduce_action(yypParser->yytos->stateno, - YYERRORSYMBOL); - if( yyact<=YY_MAX_SHIFTREDUCE ) break; + while( yypParser->yytos >= yypParser->yystack + && (yyact = yy_find_reduce_action( + yypParser->yytos->stateno, + YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE + ){ yy_pop_parser_stack(yypParser); } - if( yypParser->yytos <= yypParser->yystack || yymajor==0 ){ + if( yypParser->yytos < yypParser->yystack || yymajor==0 ){ yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yy_parse_failed(yypParser); #ifndef YYNOERRORRECOVERY @@ -7176,7 +6974,7 @@ void Parse( break; #endif } - } + }while( yypParser->yytos>yypParser->yystack ); #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; diff --git a/source/libs/parser/test/parAlterToBalanceTest.cpp b/source/libs/parser/test/parAlterToBalanceTest.cpp index 1cf132a632..bac5574f18 100644 --- a/source/libs/parser/test/parAlterToBalanceTest.cpp +++ b/source/libs/parser/test/parAlterToBalanceTest.cpp @@ -784,7 +784,7 @@ TEST_F(ParserInitialATest, alterTableSemanticCheck) { run("ALTER TABLE st1s1 DROP TAG tag1", TSDB_CODE_PAR_INVALID_ALTER_TABLE); run("ALTER TABLE st1s1 MODIFY TAG tag2 VARCHAR(30)", TSDB_CODE_PAR_INVALID_ALTER_TABLE); run("ALTER TABLE st1s1 RENAME TAG tag1 tag11", TSDB_CODE_PAR_INVALID_ALTER_TABLE); - run("ALTER TABLE st1s1 SET TAG tag2 = '123456789012345678901'", TSDB_CODE_PAR_WRONG_VALUE_TYPE); + run("ALTER TABLE st1s1 SET TAG tag2 = '123456789012345678901'", TSDB_CODE_PAR_VALUE_TOO_LONG); } /* diff --git a/source/libs/planner/inc/planInt.h b/source/libs/planner/inc/planInt.h index fcccdcf23e..3f1cb0fbd3 100644 --- a/source/libs/planner/inc/planInt.h +++ b/source/libs/planner/inc/planInt.h @@ -47,7 +47,8 @@ int32_t validateQueryPlan(SPlanContext* pCxt, SQueryPlan* pPlan); bool getBatchScanOptionFromHint(SNodeList* pList); bool getSortForGroupOptHint(SNodeList* pList); -bool getparaTablesSortOptHint(SNodeList* pList); +bool getParaTablesSortOptHint(SNodeList* pList); +bool getSmallDataTsSortOptHint(SNodeList* pList); bool getOptHint(SNodeList* pList, EHintOption hint); SLogicNode* getLogicNodeRootNode(SLogicNode* pCurr); int32_t collectTableAliasFromNodes(SNode* pNode, SSHashObj** ppRes); diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 37cdc31ae0..c34d8ac64f 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -502,7 +502,8 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect } else { nodesDestroyNode((SNode*)pScan); } - pScan->paraTablesSort = getparaTablesSortOptHint(pSelect->pHint); + pScan->paraTablesSort = getParaTablesSortOptHint(pSelect->pHint); + pScan->smallDataTsSort = getSmallDataTsSortOptHint(pSelect->pHint); pCxt->hasScan = true; return code; diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index baef39144c..8748cc7c17 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -527,7 +527,10 @@ static int32_t createSimpleScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSub if (NULL == pScan) { return TSDB_CODE_OUT_OF_MEMORY; } - vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode); + + if (pScanLogicNode->pVgroupList) { + vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode); + } return createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, pScan, pPhyNode); } @@ -538,8 +541,9 @@ static int32_t createTagScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubpla if (NULL == pScan) { return TSDB_CODE_OUT_OF_MEMORY; } - vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode); - + if (pScanLogicNode->pVgroupList) { + vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode); + } pScan->onlyMetaCtbIdx = pScanLogicNode->onlyMetaCtbIdx; return createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pScan, pPhyNode); @@ -563,8 +567,9 @@ static int32_t createLastRowScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSu pScan->groupSort = pScanLogicNode->groupSort; pScan->ignoreNull = pScanLogicNode->igLastNull; - vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode); - + if (pScanLogicNode->pVgroupList) { + vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode); + } int32_t code = createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pScan, pPhyNode); if (TSDB_CODE_SUCCESS == code && pScanLogicNode->pFuncTypes != NULL) { @@ -609,8 +614,9 @@ static int32_t createTableCountScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* } pScan->groupSort = pScanLogicNode->groupSort; - vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode); - + if (pScanLogicNode->pVgroupList) { + vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode); + } return createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pScan, pPhyNode); } @@ -652,6 +658,7 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp pTableScan->filesetDelimited = pScanLogicNode->filesetDelimited; pTableScan->needCountEmptyTable = pScanLogicNode->isCountByTag; pTableScan->paraTablesSort = pScanLogicNode->paraTablesSort; + pTableScan->smallDataTsSort = pScanLogicNode->smallDataTsSort; int32_t code = createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode); if (TSDB_CODE_SUCCESS == code) { @@ -680,7 +687,9 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* if (0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_TABLES) || 0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_TAGS) || 0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_COLS)) { - vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode); + if (pScanLogicNode->pVgroupList) { + vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode); + } } else { pSubplan->execNode.nodeId = MNODE_HANDLE; pSubplan->execNode.epSet = pCxt->pPlanCxt->mgmtEpSet; @@ -2216,11 +2225,12 @@ static int32_t createQueryInserter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNod pInserter->stableId = pModify->stableId; pInserter->tableType = pModify->tableType; strcpy(pInserter->tableName, pModify->tableName); - pInserter->vgId = pModify->pVgroupList->vgroups[0].vgId; - pInserter->epSet = pModify->pVgroupList->vgroups[0].epSet; pInserter->explain = (QUERY_NODE_EXPLAIN_STMT == nodeType(pCxt->pPlanCxt->pAstRoot) ? true : false); - vgroupInfoToNodeAddr(pModify->pVgroupList->vgroups, &pSubplan->execNode); - + if (pModify->pVgroupList) { + pInserter->vgId = pModify->pVgroupList->vgroups[0].vgId; + pInserter->epSet = pModify->pVgroupList->vgroups[0].epSet; + vgroupInfoToNodeAddr(pModify->pVgroupList->vgroups, &pSubplan->execNode); + } int32_t code = setListSlotId(pCxt, pSubplan->pNode->pOutputDataBlockDesc->dataBlockId, -1, pModify->pInsertCols, &pInserter->pCols); if (TSDB_CODE_SUCCESS == code) { diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 9664be1da2..34be489333 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -1320,7 +1320,11 @@ static int32_t stbSplSplitScanNodeWithPartTags(SSplitContext* pCxt, SStableSplit SLogicNode* pSplitNode = NULL; int32_t code = stbSplGetSplitNodeForScan(pInfo, &pSplitNode); if (TSDB_CODE_SUCCESS == code) { - code = stbSplCreateMergeNode(pCxt, pInfo->pSubplan, pSplitNode, NULL, pSplitNode, true, true); + bool needSort = true; + if (QUERY_NODE_LOGIC_PLAN_PROJECT == nodeType(pSplitNode) && !pSplitNode->pLimit && !pSplitNode->pSlimit) { + needSort = !((SProjectLogicNode*)pSplitNode)->ignoreGroupId; + } + code = stbSplCreateMergeNode(pCxt, pInfo->pSubplan, pSplitNode, NULL, pSplitNode, needSort, needSort); } if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, diff --git a/source/libs/planner/src/planUtil.c b/source/libs/planner/src/planUtil.c index f31bf23bc9..a6109cdacb 100644 --- a/source/libs/planner/src/planUtil.c +++ b/source/libs/planner/src/planUtil.c @@ -466,7 +466,7 @@ bool getOptHint(SNodeList* pList, EHintOption hint) { return false; } -bool getparaTablesSortOptHint(SNodeList* pList) { +bool getParaTablesSortOptHint(SNodeList* pList) { if (!pList) return false; SNode* pNode; FOREACH(pNode, pList) { @@ -478,6 +478,18 @@ bool getparaTablesSortOptHint(SNodeList* pList) { return false; } +bool getSmallDataTsSortOptHint(SNodeList* pList) { + if (!pList) return false; + SNode* pNode; + FOREACH(pNode, pList) { + SHintNode* pHint = (SHintNode*)pNode; + if (pHint->option == HINT_SMALLDATA_TS_SORT) { + return true; + } + } + return false; +} + int32_t collectTableAliasFromNodes(SNode* pNode, SSHashObj** ppRes) { int32_t code = TSDB_CODE_SUCCESS; SLogicNode* pCurr = (SLogicNode*)pNode; diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index 43ea418851..aa33d6f2fc 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -892,7 +892,7 @@ int32_t schCloneCallbackParam(SSchCallbackParamHeader *pSrc, SSchCallbackParamHe int32_t schCloneSMsgSendInfo(void *src, void **dst) { SMsgSendInfo *pSrc = src; int32_t code = 0; - SMsgSendInfo *pDst = taosMemoryMalloc(sizeof(*pSrc)); + SMsgSendInfo *pDst = taosMemoryCalloc(1, sizeof(*pSrc)); if (NULL == pDst) { qError("malloc SMsgSendInfo for rpcCtx failed, len:%d", (int32_t)sizeof(*pSrc)); SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index fa1b508e23..24d1bf7603 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -353,7 +353,8 @@ int32_t streamTransferStateDoPrepare(SStreamTask* pTask) { if (pStreamTask->info.taskLevel == TASK_LEVEL__SOURCE) { ASSERT(status == TASK_STATUS__HALT || status == TASK_STATUS__DROPPING || status == TASK_STATUS__STOP); } else { - ASSERT(status == TASK_STATUS__READY || status == TASK_STATUS__DROPPING || status == TASK_STATUS__STOP); + ASSERT(status == TASK_STATUS__READY || status == TASK_STATUS__PAUSE || status == TASK_STATUS__DROPPING || + status == TASK_STATUS__STOP); int32_t code = streamTaskHandleEvent(pStreamTask->status.pSM, TASK_EVENT_HALT); if (code != TSDB_CODE_SUCCESS) { stError("s-task:%s halt stream task:%s failed, code:%s not transfer state to stream task", id, diff --git a/source/libs/stream/src/streamSessionState.c b/source/libs/stream/src/streamSessionState.c index 723f04c499..295132a4f5 100644 --- a/source/libs/stream/src/streamSessionState.c +++ b/source/libs/stream/src/streamSessionState.c @@ -310,7 +310,7 @@ int32_t allocSessioncWinBuffByNextPosition(SStreamFileState* pFileState, SStream int32_t size = taosArrayGetSize(pWinStates); if (pCur->buffIndex >= 0) { if (pCur->buffIndex >= size) { - pNewPos = insertNewSessionWindow(pFileState, pWinStates, pWinKey, size); + pNewPos = addNewSessionWindow(pFileState, pWinStates, pWinKey); goto _end; } pNewPos = insertNewSessionWindow(pFileState, pWinStates, pWinKey, pCur->buffIndex); @@ -327,12 +327,12 @@ int32_t allocSessioncWinBuffByNextPosition(SStreamFileState* pFileState, SStream } } pNewPos = getNewRowPosForWrite(pFileState); + memcpy(pNewPos->pKey, pWinKey, sizeof(SSessionKey)); pNewPos->needFree = true; pNewPos->beFlushed = true; } _end: - memcpy(pNewPos->pKey, pWinKey, sizeof(SSessionKey)); (*ppVal) = pNewPos; return TSDB_CODE_SUCCESS; } diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 2e35aecd08..ac45f1eef6 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -322,7 +322,7 @@ static void cliReleaseUnfinishedMsg(SCliConn* conn) { if (msg != NULL && msg->ctx != NULL && msg->ctx->ahandle != (void*)0x9527) { if (conn->ctx.freeFunc != NULL && msg->ctx->ahandle != NULL) { conn->ctx.freeFunc(msg->ctx->ahandle); - } else if (msg->ctx->ahandle != NULL && pThrd->destroyAhandleFp != NULL) { + } else if (msg->msg.info.notFreeAhandle == 0 && msg->ctx->ahandle != NULL && pThrd->destroyAhandleFp != NULL) { tDebug("%s conn %p destroy unfinished ahandle %p", CONN_GET_INST_LABEL(conn), conn, msg->ctx->ahandle); pThrd->destroyAhandleFp(msg->ctx->ahandle); } diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index e6491639dc..bdd43fe9fa 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -1404,3 +1404,35 @@ int32_t taosLinkFile(char *src, char *dst) { #endif return 0; } + +FILE* taosOpenCFile(const char* filename, const char* mode) { + return fopen(filename, mode); +} + +int taosSeekCFile(FILE* file, int64_t offset, int whence) { +#ifdef WINDOWS + return _fseeki64(file, offset, whence); +#else + return fseeko(file, offset, whence); +#endif +} + +size_t taosReadFromCFile(void *buffer, size_t size, size_t count, FILE *stream ) { + return fread(buffer, size, count, stream); +} + +size_t taosWriteToCFile(const void* ptr, size_t size, size_t nitems, FILE* stream) { + return fwrite(ptr, size, nitems, stream); +} + +int taosCloseCFile(FILE *f) { + return fclose(f); +} + +int taosSetAutoDelFile(char* path) { +#ifdef WINDOWS + return SetFileAttributes(path, FILE_ATTRIBUTE_TEMPORARY); +#else + return unlink(path); +#endif +} \ No newline at end of file diff --git a/source/os/src/osString.c b/source/os/src/osString.c index 9119c1d470..8c6c0e0d7c 100644 --- a/source/os/src/osString.c +++ b/source/os/src/osString.c @@ -485,7 +485,7 @@ bool isHex(const char* z, uint32_t n){ } bool isValidateHex(const char* z, uint32_t n){ - if(n % 2 != 0) return false; + if((n & 1) != 0) return false; for(size_t i = HEX_PREFIX_LEN; i < n; i++){ if(isxdigit(z[i]) == 0){ return false; @@ -494,13 +494,16 @@ bool isValidateHex(const char* z, uint32_t n){ return true; } -int32_t taosHex2Ascii(const char *z, uint32_t n, void** data, uint32_t* size){ - n -= HEX_PREFIX_LEN; // remove 0x +int32_t taosHex2Ascii(const char *z, uint32_t n, void **data, uint32_t *size) { + n -= HEX_PREFIX_LEN; // remove 0x z += HEX_PREFIX_LEN; *size = n / HEX_PREFIX_LEN; - if(*size == 0) return 0; - uint8_t* tmp = (uint8_t*)taosMemoryCalloc(*size, 1); - if(tmp == NULL) return -1; + if (*size == 0) { + if (!(*data = taosStrdup(""))) return -1; + return 0; + } + uint8_t *tmp = (uint8_t *)taosMemoryCalloc(*size, 1); + if (tmp == NULL) return -1; int8_t num = 0; uint8_t *byte = tmp + *size - 1; diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index ad3c766510..8fdc2654c5 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -449,6 +449,15 @@ static int32_t cfgAddItem(SConfig *pCfg, SConfigItem *pItem, const char *name) { return -1; } + int size = pCfg->array->size; + for (int32_t i = 0; i < size; ++i) { + SConfigItem *existItem = taosArrayGet(pCfg->array, i); + if (existItem != NULL && strcmp(existItem->name, pItem->name) == 0) { + taosMemoryFree(pItem->name); + return TSDB_CODE_INVALID_CFG; + } + } + int32_t len = strlen(name); char lowcaseName[CFG_NAME_MAX_LEN + 1] = {0}; strntolower(lowcaseName, name, TMIN(CFG_NAME_MAX_LEN, len)); @@ -457,6 +466,7 @@ static int32_t cfgAddItem(SConfig *pCfg, SConfigItem *pItem, const char *name) { if (pItem->dtype == CFG_DTYPE_STRING) { taosMemoryFree(pItem->str); } + taosMemoryFree(pItem->name); terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 1f3aaa3835..877e1f776a 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -613,7 +613,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_GET_META_ERROR, "Fail to get table i TAOS_DEFINE_ERROR(TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS, "Not unique table/alias") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_SYSTABLE_NOT_ALLOWED_FUNC, "System table not allowed") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_SYSTABLE_NOT_ALLOWED, "System table not allowed") -TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_VARBINARY, "Invalidate varbinary value") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_VARBINARY, "Invalid varbinary value") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_IP_RANGE, "Invalid IPV4 address ranges") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTERNAL_ERROR, "Parser internal error") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Invalid stream query") diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index a2348bdedd..851fe2679b 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -229,6 +229,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dataFromTsdbNWal.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dataFromTsdbNWal-multiCtb.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_taosx.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_ts4563.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_replay.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqSeekAndCommit.py ,,n,system-test,python3 ./test.py -f 7-tmq/tmq_offset.py @@ -327,6 +328,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/db_tb_name_check.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/InsertFuturets.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/insert_wide_column.py +,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/insert_column_value.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_benchmark.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k.py -R @@ -1056,6 +1058,13 @@ ,,y,script,./test.sh -f tsim/parser/columnValue_smallint.sim ,,y,script,./test.sh -f tsim/parser/columnValue_tinyint.sim ,,y,script,./test.sh -f tsim/parser/columnValue_unsign.sim +,,y,script,./test.sh -f tsim/parser/columnValue_uint.sim +,,y,script,./test.sh -f tsim/parser/columnValue_timestamp.sim +,,y,script,./test.sh -f tsim/parser/columnValue_varchar.sim +,,y,script,./test.sh -f tsim/parser/columnValue_nchar.sim +,,y,script,./test.sh -f tsim/parser/columnValue_varbinary.sim +,,y,script,./test.sh -f tsim/parser/columnValue_json.sim +,,y,script,./test.sh -f tsim/parser/columnValue_geometry.sim ,,y,script,./test.sh -f tsim/parser/condition.sim ,,y,script,./test.sh -f tsim/parser/condition_scl.sim ,,y,script,./test.sh -f tsim/parser/constCol.sim diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index 9af2525c74..c6bd78336c 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -113,11 +113,11 @@ echo "firstEp ${HOSTNAME}:7100" >> $TAOS_CFG echo "secondEp ${HOSTNAME}:7200" >> $TAOS_CFG echo "fqdn ${HOSTNAME}" >> $TAOS_CFG echo "serverPort ${NODE}" >> $TAOS_CFG -echo "supportVnodes 1024" >> $TAOS_CFG +echo "supportVnodes 1024" >> $TAOS_CFG echo "statusInterval 1" >> $TAOS_CFG echo "dataDir $DATA_DIR" >> $TAOS_CFG echo "logDir $LOG_DIR" >> $TAOS_CFG -echo "debugFlag 135" >> $TAOS_CFG +echo "debugFlag 135" >> $TAOS_CFG echo "tmrDebugFlag 131" >> $TAOS_CFG echo "uDebugFlag 143" >> $TAOS_CFG echo "rpcDebugFlag 143" >> $TAOS_CFG @@ -143,4 +143,5 @@ echo "asyncLog 0" >> $TAOS_CFG echo "locale en_US.UTF-8" >> $TAOS_CFG echo "telemetryReporting 0" >> $TAOS_CFG echo "querySmaOptimize 1" >> $TAOS_CFG +echo "checkpointInterval 60" >> $TAOS_CFG echo " " >> $TAOS_CFG diff --git a/tests/script/sh/stop_dnodes.sh b/tests/script/sh/stop_dnodes.sh index c63d6daf8a..b447a7325e 100755 --- a/tests/script/sh/stop_dnodes.sh +++ b/tests/script/sh/stop_dnodes.sh @@ -15,42 +15,42 @@ fi PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` while [ -n "$PID" ]; do - echo kill -9 $PID - #pkill -9 taosd - kill -9 $PID + echo kill -15 $PID + #pkill -15 taosd + kill -15 $PID echo "Killing taosd processes" if [ "$OS_TYPE" != "Darwin" ]; then fuser -k -n tcp 6030 else - lsof -nti:6030 | xargs kill -9 + lsof -nti:6030 | xargs kill -15 fi PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` done PID=`ps -ef|grep -w taos | grep -v grep | awk '{print $2}'` while [ -n "$PID" ]; do - echo kill -9 $PID + echo kill -15 $PID #pkill -9 taos - kill -9 $PID + kill -15 $PID echo "Killing taos processes" if [ "$OS_TYPE" != "Darwin" ]; then fuser -k -n tcp 6030 else - lsof -nti:6030 | xargs kill -9 + lsof -nti:6030 | xargs kill -15 fi PID=`ps -ef|grep -w taos | grep -v grep | awk '{print $2}'` done PID=`ps -ef|grep -w tmq_sim | grep -v grep | awk '{print $2}'` while [ -n "$PID" ]; do - echo kill -9 $PID - #pkill -9 tmq_sim - kill -9 $PID + echo kill -15 $PID + #pkill -15 tmq_sim + kill -15 $PID echo "Killing tmq_sim processes" if [ "$OS_TYPE" != "Darwin" ]; then fuser -k -n tcp 6030 else - lsof -nti:6030 | xargs kill -9 + lsof -nti:6030 | xargs kill -15 fi PID=`ps -ef|grep -w tmq_sim | grep -v grep | awk '{print $2}'` -done +done \ No newline at end of file diff --git a/tests/script/tsim/parser/columnValue_bigint.sim b/tests/script/tsim/parser/columnValue_bigint.sim index 056855eea2..e4d1a6b6e3 100644 --- a/tests/script/tsim/parser/columnValue_bigint.sim +++ b/tests/script/tsim/parser/columnValue_bigint.sim @@ -28,10 +28,26 @@ if $data05 != NULL then return -1 endi -sql_error create table st_bigint_2 using mt_bigint tags ('NULL') -sql_error create table st_bigint_3 using mt_bigint tags ('NULL') -sql_error create table st_bigint_4 using mt_bigint tags ("NULL") -sql_error create table st_bigint_5 using mt_bigint tags ("NULL") +sql create table st_bigint_2 using mt_bigint tags ('NULL') +sql show tags from st_bigint_2 +if $data05 != NULL then + return -1 +endi +sql create table st_bigint_3 using mt_bigint tags ('NULL') +sql show tags from st_bigint_3 +if $data05 != NULL then + return -1 +endi +sql create table st_bigint_4 using mt_bigint tags ("NULL") +sql show tags from st_bigint_4 +if $data05 != NULL then + return -1 +endi +sql create table st_bigint_5 using mt_bigint tags ("NULL") +sql show tags from st_bigint_5 +if $data05 != NULL then + return -1 +endi sql create table st_bigint_6 using mt_bigint tags (-9223372036854775807) sql show tags from st_bigint_6 @@ -97,6 +113,39 @@ if $data01 != NULL then return -1 endi +sql insert into st_bigint_2 values (now, NULL) +sql select * from st_bigint_2 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_3 values (now, NULL) +sql select * from st_bigint_3 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_4 values (now, NULL) +sql select * from st_bigint_4 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_5 values (now, NULL) +sql select * from st_bigint_5 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + sql insert into st_bigint_6 values (now, 9223372036854775807) sql select * from st_bigint_6 if $rows != 1 then @@ -348,7 +397,7 @@ sql_error create table st_bigint_e0 using mt_bigint tags ("123abc") sql_error create table st_bigint_e0 using mt_bigint tags (abc) sql_error create table st_bigint_e0 using mt_bigint tags ("abc") sql_error create table st_bigint_e0 using mt_bigint tags (" ") -sql create table st_bigint_e0_error using mt_bigint tags ('') +sql_error create table st_bigint_e0_error using mt_bigint tags ('') sql create table st_bigint_e0 using mt_bigint tags (123) sql create table st_bigint_e1 using mt_bigint tags (123) @@ -401,7 +450,7 @@ sql_error insert into st_bigint_e20 using mt_bigint tags ("123abc") values (now, sql_error insert into st_bigint_e22 using mt_bigint tags (abc) values (now, -033) sql_error insert into st_bigint_e23 using mt_bigint tags ("abc") values (now, -033) sql_error insert into st_bigint_e24 using mt_bigint tags (" ") values (now, -033) -sql insert into st_bigint_e25 using mt_bigint tags ('') values (now, -033) +sql_error insert into st_bigint_e25 using mt_bigint tags ('') values (now, -033) sql insert into st_bigint_e13 using mt_bigint tags (033) values (now, 00062) sql insert into st_bigint_e14 using mt_bigint tags (033) values (now, 00062) @@ -417,15 +466,17 @@ sql insert into st_bigint_e23 using mt_bigint tags (033) values (now, 00062) sql insert into st_bigint_e24 using mt_bigint tags (033) values (now, 00062) sql insert into st_bigint_e25 using mt_bigint tags (033) values (now, 00062) -#sql alter table st_bigint_e13 set tag tagname=9223372036854775808 -#sql_error alter table st_bigint_e14 set tag tagname=-9223372036854775808 -#sql alter table st_bigint_e15 set tag tagname=92233720368547758080 -#sql_error alter table st_bigint_e16 set tag tagname=-92233720368547758080 -#sql_error alter table st_bigint_e19 set tag tagname=123abc -#sql_error alter table st_bigint_e20 set tag tagname="123abc" -#sql_error alter table st_bigint_e22 set tag tagname=abc -#sql_error alter table st_bigint_e23 set tag tagname="abc" -#sql_error alter table st_bigint_e24 set tag tagname=" " -#sql_error alter table st_bigint_e25 set tag tagname='' +sql_error alter table st_bigint_e13 set tag tagname=9223372036854775808 +sql alter table st_bigint_e13 set tag tagname=9223372036854775807 +sql_error alter table st_bigint_e14 set tag tagname=-9223372036854775809 +sql alter table st_bigint_e14 set tag tagname=-9223372036854775808 +sql_error alter table st_bigint_e15 set tag tagname=92233720368547758080 +sql_error alter table st_bigint_e16 set tag tagname=-92233720368547758080 +sql_error alter table st_bigint_e19 set tag tagname=123abc +sql_error alter table st_bigint_e20 set tag tagname="123abc" +sql_error alter table st_bigint_e22 set tag tagname=abc +sql_error alter table st_bigint_e23 set tag tagname="abc" +sql_error alter table st_bigint_e24 set tag tagname=" " +sql_error alter table st_bigint_e25 set tag tagname='' system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_bool.sim b/tests/script/tsim/parser/columnValue_bool.sim index 2553e6805a..db89db4256 100644 --- a/tests/script/tsim/parser/columnValue_bool.sim +++ b/tests/script/tsim/parser/columnValue_bool.sim @@ -31,26 +31,26 @@ if $data05 != NULL then endi sql create table st_bool_2 using mt_bool tags ('NULL') sql show tags from st_bool_2 -if $data05 != false then - print ==3== expect: false, actually: $data05 +if $data05 != NULL then + print ==3== expect: NULL, actually: $data05 return -1 endi sql create table st_bool_3 using mt_bool tags ('NULL') sql show tags from st_bool_3 -if $data05 != false then - print ==4== expect: false, actually: $data05 +if $data05 != NULL then + print ==4== expect: NULL, actually: $data05 return -1 endi sql create table st_bool_4 using mt_bool tags ("NULL") sql show tags from st_bool_4 -if $data05 != false then - print ==5== expect: false, actually: $data05 +if $data05 != NULL then + print ==5== expect: NULL, actually: $data05 return -1 endi sql create table st_bool_5 using mt_bool tags ("NULL") sql show tags from st_bool_5 -if $data05 != false then - print ==6== expect: false, actually: $data05 +if $data05 != NULL then + print ==6== expect: NULL, actually: $data05 return -1 endi sql create table st_bool_6 using mt_bool tags ("true") @@ -113,16 +113,94 @@ if $data05 != true then print ==16== expect: 1, actually: $data00 return -1 endi -sql create table st_bool_15_0 using mt_bool tags (+300) -sql show tags from st_bool_15_0 +sql create table st_bool_16 using mt_bool tags (+300) +sql show tags from st_bool_16 if $data05 != true then - print ==16== expect: 1, actually: $data00 return -1 endi -sql create table st_bool_15_1 using mt_bool tags (-8.03) -sql show tags from st_bool_15_1 +sql create table st_bool_17 using mt_bool tags (-8.03) +sql show tags from st_bool_17 if $data05 != true then - print ==16== expect: 1, actually: $data00 + return -1 +endi +sql create table st_bool_18 using mt_bool tags ("-8.03") +sql show tags from st_bool_18 +if $data05 != true then + return -1 +endi +sql create table st_bool_19 using mt_bool tags ("+300") +sql show tags from st_bool_19 +if $data05 != true then + return -1 +endi +sql create table st_bool_20 using mt_bool tags ("-8e+2") +sql show tags from st_bool_20 +if $data05 != true then + return -1 +endi +sql create table st_bool_21 using mt_bool tags ("0x01") +sql show tags from st_bool_21 +if $data05 != true then + return -1 +endi +sql create table st_bool_22 using mt_bool tags ("0b01") +sql show tags from st_bool_22 +if $data05 != true then + return -1 +endi +sql create table st_bool_23 using mt_bool tags ("+0x01") +sql show tags from st_bool_23 +if $data05 != true then + return -1 +endi +sql create table st_bool_24 using mt_bool tags ("-0b00") +sql show tags from st_bool_24 +if $data05 != false then + return -1 +endi +sql create table st_bool_26 using mt_bool tags ("-0.11e-30") +sql show tags from st_bool_26 +if $data05 != true then + return -1 +endi +sql create table st_bool_27 using mt_bool tags ("-1.0e-307") +sql show tags from st_bool_27 +if $data05 != true then + return -1 +endi +sql create table st_bool_28 using mt_bool tags ( -1e-1 ) +sql show tags from st_bool_28 +if $data05 != true then + return -1 +endi +sql create table st_bool_29 using mt_bool tags (-0.11e-30) +sql show tags from st_bool_29 +if $data05 != true then + return -1 +endi +sql create table st_bool_30 using mt_bool tags (-1.1e-307) +sql show tags from st_bool_30 +if $data05 != true then + return -1 +endi +sql create table st_bool_31 using mt_bool tags ( 0x01) +sql show tags from st_bool_31 +if $data05 != true then + return -1 +endi +sql create table st_bool_32 using mt_bool tags (0b01 ) +sql show tags from st_bool_32 +if $data05 != true then + return -1 +endi +sql create table st_bool_33 using mt_bool tags (+0x01) +sql show tags from st_bool_33 +if $data05 != true then + return -1 +endi +sql create table st_bool_34 using mt_bool tags ( -0b00 ) +sql show tags from st_bool_34 +if $data05 != false then return -1 endi @@ -271,8 +349,8 @@ if $data01 != 1 then print ==32== expect: true, actually: $data01 return -1 endi -sql insert into st_bool_15_0 values (now, +300) -sql select * from st_bool_15_0 +sql insert into st_bool_16 values (now, +300) +sql select * from st_bool_16 if $rows != 1 then return -1 endi @@ -280,8 +358,8 @@ if $data01 != 1 then print ==32== expect: true, actually: $data01 return -1 endi -sql insert into st_bool_15_1 values (now, -3.15) -sql select * from st_bool_15_1 +sql insert into st_bool_17 values (now, -3.15) +sql select * from st_bool_17 if $rows != 1 then return -1 endi @@ -289,304 +367,529 @@ if $data01 != 1 then print ==32== expect: true, actually: $data01 return -1 endi +sql insert into st_bool_18 values(now,"-8.03") +sql select * from st_bool_18 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_19 values(now,"+300") +sql select * from st_bool_19 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_20 values(now,"-8e+2") +sql select * from st_bool_20 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_21 values(now,"0x01") +sql select * from st_bool_21 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_22 values(now,"0b01") +sql select * from st_bool_22 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_23 values(now,"+0x01") +sql select * from st_bool_23 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_24 values(now,"-0b00") +sql select * from st_bool_24 +if $data01 != 0 then + return -1 +endi +sql insert into st_bool_26 values(now,"-0.11e-30") +sql select * from st_bool_26 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_27 values(now,"-1.0e-307") +sql select * from st_bool_27 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_28 values(now, -1e-1 ) +sql select * from st_bool_28 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_29 values(now,-0.11e-30) +sql select * from st_bool_29 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_30 values(now,-1.1e-307) +sql select * from st_bool_30 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_31 values(now, 0x01) +sql select * from st_bool_31 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_32 values(now,0b01 ) +sql select * from st_bool_32 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_33 values(now,+0x01) +sql select * from st_bool_33 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_34 values(now, -0b00 ) +sql select * from st_bool_34 +if $data01 != 0 then + return -1 +endi ## case 02: dynamic create table for test tag values -sql insert into st_bool_16 using mt_bool tags (NULL) values (now, NULL) -sql show create table st_bool_16 -sql show tags from st_bool_16 +sql insert into st_bool_116 using mt_bool tags (NULL) values (now, NULL) +sql show create table st_bool_116 +sql show tags from st_bool_116 if $data05 != NULL then print ==33== expect: NULL, actually: $data00 return -1 endi -sql select * from st_bool_16 +sql select * from st_bool_116 if $data01 != NULL then print ==34== expect: NULL, actually: $data01 return -1 endi -sql insert into st_bool_17 using mt_bool tags (NULL) values (now, NULL) -sql show tags from st_bool_17 +sql insert into st_bool_117 using mt_bool tags (NULL) values (now, NULL) +sql show tags from st_bool_117 if $data05 != NULL then print ==35== expect: NULL, actually: $data00 return -1 endi -sql select * from st_bool_17 +sql select * from st_bool_117 if $data01 != NULL then print ==36== expect: NULL, actually: $data01 return -1 endi -sql insert into st_bool_18 using mt_bool tags ('NULL') values (now, 'NULL') -sql show tags from st_bool_18 +sql insert into st_bool_118 using mt_bool tags ('NULL') values (now, 'NULL') +sql show tags from st_bool_118 if $data05 != NULL then print ==37== expect: NULL, actually: $data00 return -1 endi -sql select * from st_bool_18 +sql select * from st_bool_118 if $data01 != NULL then print ==38== expect: NULL, actually: $data01 return -1 endi -sql insert into st_bool_19 using mt_bool tags ('NULL') values (now, 'NULL') -sql show tags from st_bool_19 +sql insert into st_bool_119 using mt_bool tags ('NULL') values (now, 'NULL') +sql show tags from st_bool_119 if $data05 != NULL then print ==39== expect: NULL, actually: $data00 return -1 endi -sql select * from st_bool_19 +sql select * from st_bool_119 if $data01 != NULL then print ==40== expect: NULL, actually: $data01 return -1 endi -sql insert into st_bool_20 using mt_bool tags ("NULL") values (now, "NULL") -sql show tags from st_bool_20 +sql insert into st_bool_120 using mt_bool tags ("NULL") values (now, "NULL") +sql show tags from st_bool_120 if $data05 != NULL then print ==41== expect: NULL, actually: $data00 return -1 endi -sql select * from st_bool_20 +sql select * from st_bool_120 if $data01 != NULL then print ==42== expect: NULL, actually: $data01 return -1 endi -sql insert into st_bool_21 using mt_bool tags ("NULL") values (now, "NULL") -sql show tags from st_bool_21 +sql insert into st_bool_121 using mt_bool tags ("NULL") values (now, "NULL") +sql show tags from st_bool_121 if $data05 != NULL then print ==43== expect: NULL, actually: $data00 return -1 endi -sql select * from st_bool_21 +sql select * from st_bool_121 if $data01 != NULL then print ==44== expect: NULL, actually: $data01 return -1 endi -sql insert into st_bool_22 using mt_bool tags ("true") values (now, "true") -sql show tags from st_bool_22 +sql insert into st_bool_122 using mt_bool tags ("true") values (now, "true") +sql show tags from st_bool_122 if $data05 != true then print ==45== expect: 1, actually: $data00 return -1 endi -sql select * from st_bool_22 +sql select * from st_bool_122 if $data01 != 1 then print ==46== expect: 1, actually: $data01 return -1 endi -sql insert into st_bool_23 using mt_bool tags ('true') values (now, 'true') -sql show tags from st_bool_23 +sql insert into st_bool_123 using mt_bool tags ('true') values (now, 'true') +sql show tags from st_bool_123 if $data05 != true then print ==47== expect: 1, actually: $data00 return -1 endi -sql select * from st_bool_23 +sql select * from st_bool_123 if $data01 != 1 then print ==48== expect: 1, actually: $data01 return -1 endi -sql insert into st_bool_24 using mt_bool tags (true) values (now, true) -sql show tags from st_bool_24 +sql insert into st_bool_124 using mt_bool tags (true) values (now, true) +sql show tags from st_bool_124 if $data05 != true then print ==49== expect: 1, actually: $data00 return -1 endi -sql select * from st_bool_24 +sql select * from st_bool_124 if $data01 != 1 then print ==50== expect: 1, actually: $data01 return -1 endi -sql insert into st_bool_25 using mt_bool tags ("false") values (now, "false") -sql show tags from st_bool_25 +sql insert into st_bool_125 using mt_bool tags ("false") values (now, "false") +sql show tags from st_bool_125 if $data05 != false then print ==51== expect: 0, actually: $data00 return -1 endi -sql select * from st_bool_25 +sql select * from st_bool_125 if $data01 != 0 then print ==52== expect: 0, actually: $data01 return -1 endi -sql insert into st_bool_26 using mt_bool tags ('false') values (now, 'false') -sql show tags from st_bool_26 +sql insert into st_bool_126 using mt_bool tags ('false') values (now, 'false') +sql show tags from st_bool_126 if $data05 != false then print ==53== expect: 0, actually: $data00 return -1 endi -sql select * from st_bool_26 +sql select * from st_bool_126 if $data01 != 0 then print ==54== expect: 0, actually: $data01 return -1 endi -sql insert into st_bool_27 using mt_bool tags (false) values (now, false) -sql show tags from st_bool_27 +sql insert into st_bool_127 using mt_bool tags (false) values (now, false) +sql show tags from st_bool_127 if $data05 != false then print ==55== expect: 0, actually: $data00 return -1 endi -sql select * from st_bool_27 +sql select * from st_bool_127 if $data01 != 0 then print ==56== expect: 0, actually: $data01 return -1 endi -sql insert into st_bool_28 using mt_bool tags (0) values (now, 0) -sql show tags from st_bool_28 +sql insert into st_bool_128 using mt_bool tags (0) values (now, 0) +sql show tags from st_bool_128 if $data05 != false then print ==57== expect: 0, actually: $data00 return -1 endi -sql select * from st_bool_28 +sql select * from st_bool_128 if $data01 != 0 then print ==58== expect: 0, actually: $data01 return -1 endi -sql insert into st_bool_29 using mt_bool tags (1) values (now, 1) -sql show tags from st_bool_29 +sql insert into st_bool_129 using mt_bool tags (1) values (now, 1) +sql show tags from st_bool_129 if $data05 != true then print ==59== expect: 1, actually: $data00 return -1 endi -sql select * from st_bool_29 +sql select * from st_bool_129 if $data01 != 1 then print ==60== expect: 1, actually: $data01 return -1 endi -sql insert into st_bool_30 using mt_bool tags (6.9) values (now, 6.9) -sql show tags from st_bool_30 +sql insert into st_bool_130 using mt_bool tags (6.9) values (now, 6.9) +sql show tags from st_bool_130 if $data05 != true then print ==61== expect: 1, actually: $data00 return -1 endi -sql select * from st_bool_30 +sql select * from st_bool_130 if $data01 != 1 then print ==62== expect: 1, actually: $data01 return -1 endi -sql insert into st_bool_31 using mt_bool tags (-3) values (now, -3) -sql show tags from st_bool_31 +sql insert into st_bool_131 using mt_bool tags (-3) values (now, -3) +sql show tags from st_bool_131 if $data05 != true then print ==63== expect: 1, actually: $data00 return -1 endi -sql select * from st_bool_31 +sql select * from st_bool_131 if $data01 != 1 then print ==64== expect: 1, actually: $data01 return -1 endi -sql insert into st_bool_32 using mt_bool tags (+300) values (now, +300) -sql show tags from st_bool_32 +sql insert into st_bool_132 using mt_bool tags (+300) values (now, +300) +sql show tags from st_bool_132 if $data05 != true then print ==63== expect: 1, actually: $data00 return -1 endi -sql select * from st_bool_32 +sql select * from st_bool_132 if $data01 != 1 then print ==64== expect: 1, actually: $data01 return -1 endi -sql insert into st_bool_33 using mt_bool tags (+30.890) values (now, +30.890) -sql show tags from st_bool_33 +sql insert into st_bool_133 using mt_bool tags (+30.890) values (now, +30.890) +sql show tags from st_bool_133 if $data05 != true then print ==63== expect: 1, actually: $data00 return -1 endi -sql select * from st_bool_33 +sql select * from st_bool_133 if $data01 != 1 then print ==64== expect: 1, actually: $data01 return -1 endi - - - - - +sql insert into st_bool_218 using mt_bool tags ("-8.03") values (now,"-8.03") +sql show tags from st_bool_218 +if $data05 != true then + return -1 +endi +sql select * from st_bool_218 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_219 using mt_bool tags ("+300") values (now,"+300") +sql show tags from st_bool_219 +if $data05 != true then + return -1 +endi +sql select * from st_bool_219 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_220 using mt_bool tags ("-8e+2") values (now,"-8e+2") +sql show tags from st_bool_220 +if $data05 != true then + return -1 +endi +sql select * from st_bool_220 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_221 using mt_bool tags ("0x01") values (now,"0x01") +sql show tags from st_bool_221 +if $data05 != true then + return -1 +endi +sql select * from st_bool_221 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_222 using mt_bool tags ("0b01") values (now,"0b01") +sql show tags from st_bool_222 +if $data05 != true then + return -1 +endi +sql select * from st_bool_222 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_223 using mt_bool tags ("+0x01") values (now,"+0x01") +sql show tags from st_bool_223 +if $data05 != true then + return -1 +endi +sql select * from st_bool_223 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_224 using mt_bool tags ("-0b00") values (now,"-0b00") +sql show tags from st_bool_224 +if $data05 != false then + return -1 +endi +sql select * from st_bool_224 +if $data01 != 0 then + return -1 +endi +sql insert into st_bool_226 using mt_bool tags ("-0.11e-30") values (now,"-0.11e-30") +sql show tags from st_bool_226 +if $data05 != true then + return -1 +endi +sql select * from st_bool_226 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_227 using mt_bool tags ("-1.0e-307") values (now,"-1.0e-307") +sql show tags from st_bool_227 +if $data05 != true then + return -1 +endi +sql select * from st_bool_227 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_228 using mt_bool tags ( -1e-1 ) values (now, -1e-1 ) +sql show tags from st_bool_228 +if $data05 != true then + return -1 +endi +sql select * from st_bool_228 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_229 using mt_bool tags (-0.11e-30) values (now,-0.11e-30) +sql show tags from st_bool_229 +if $data05 != true then + return -1 +endi +sql select * from st_bool_229 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_230 using mt_bool tags (-1.1e-307) values (now,-1.1e-307) +sql show tags from st_bool_230 +if $data05 != true then + return -1 +endi +sql select * from st_bool_230 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_231 using mt_bool tags ( 0x01) values (now, 0x01) +sql show tags from st_bool_231 +if $data05 != true then + return -1 +endi +sql select * from st_bool_231 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_232 using mt_bool tags (0b01 ) values (now, 0b01) +sql show tags from st_bool_232 +if $data05 != true then + return -1 +endi +sql select * from st_bool_232 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_233 using mt_bool tags (+0x01) values (now,+0x01) +sql show tags from st_bool_233 +if $data05 != true then + return -1 +endi +sql insert into st_bool_234 using mt_bool tags ( -0b00 ) values (now, -0b00) +sql show tags from st_bool_234 +if $data05 != false then + return -1 +endi +sql select * from st_bool_234 +if $data01 != 0 then + return -1 +endi ## case 03: alter tag values -#sql alter table st_bool_0 set tag tagname=true -#sql show tags from st_bool_0 -#if $data00 != true then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname=NULL -#sql show tags from st_bool_0 -#if $data00 != NULL then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname=false -#sql show tags from st_bool_0 -#if $data00 != false then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname=NULL -#sql show tags from st_bool_0 -#if $data00 != NULL then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname='true' -#sql show tags from st_bool_0 -#if $data00 != true then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname='NULL' -#sql show tags from st_bool_0 -#if $data00 != NULL then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname='false' -#sql show tags from st_bool_0 -#if $data00 != false then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname='NULL' -#sql show tags from st_bool_0 -#if $data00 != NULL then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname="true" -#sql show tags from st_bool_0 -#if $data00 != true then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname="NULL" -#sql show tags from st_bool_0 -#if $data00 != NULL then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname="false" -#sql show tags from st_bool_0 -#if $data00 != false then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname="NULL" -#sql show tags from st_bool_0 -#if $data00 != NULL then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname=1 -#sql show tags from st_bool_0 -#if $data00 != true then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname=0 -#sql show tags from st_bool_0 -#if $data00 != false then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname=6.9 -#sql show tags from st_bool_0 -#if $data00 != true then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname=-3 -#sql show tags from st_bool_0 -#if $data00 != true then -# return -1 -#endi +sql alter table st_bool_16 set tag tagname=+300 +sql show tags from st_bool_16 +if $data05 != true then + return -1 +endi +sql alter table st_bool_17 set tag tagname=-8.03 +sql show tags from st_bool_17 +if $data05 != true then + return -1 +endi +sql alter table st_bool_18 set tag tagname="-8.03" +sql show tags from st_bool_18 +if $data05 != true then + return -1 +endi +sql alter table st_bool_19 set tag tagname="+300" +sql show tags from st_bool_19 +if $data05 != true then + return -1 +endi +sql alter table st_bool_20 set tag tagname="-8e+2" +sql show tags from st_bool_20 +if $data05 != true then + return -1 +endi +sql alter table st_bool_21 set tag tagname="0x01" +sql show tags from st_bool_21 +if $data05 != true then + return -1 +endi +sql alter table st_bool_22 set tag tagname="0b01" +sql show tags from st_bool_22 +if $data05 != true then + return -1 +endi +sql alter table st_bool_23 set tag tagname="+0x01" +sql show tags from st_bool_23 +if $data05 != true then + return -1 +endi +sql alter table st_bool_24 set tag tagname="-0b00" +sql show tags from st_bool_24 +if $data05 != false then + return -1 +endi +sql alter table st_bool_26 set tag tagname="-0.11e-30" +sql show tags from st_bool_26 +if $data05 != true then + return -1 +endi +sql alter table st_bool_27 set tag tagname="-1.0e-307" +sql show tags from st_bool_27 +if $data05 != true then + return -1 +endi +sql alter table st_bool_28 set tag tagname= -1e-1 +sql show tags from st_bool_28 +if $data05 != true then + return -1 +endi +sql alter table st_bool_29 set tag tagname=-0.11e-30 +sql show tags from st_bool_29 +if $data05 != true then + return -1 +endi +sql alter table st_bool_30 set tag tagname=-1.1e-307 +sql show tags from st_bool_30 +if $data05 != true then + return -1 +endi +sql alter table st_bool_31 set tag tagname= 0x01 +sql show tags from st_bool_31 +if $data05 != true then + return -1 +endi +sql alter table st_bool_32 set tag tagname=0b01 +sql show tags from st_bool_32 +if $data05 != true then + return -1 +endi +sql alter table st_bool_33 set tag tagname=+0x01 +sql show tags from st_bool_33 +if $data05 != true then + return -1 +endi +sql alter table st_bool_34 set tag tagname= -0b00 +sql show tags from st_bool_34 +if $data05 != false then + return -1 +endi # case 04: illegal input sql_error create table st_bool_e0 using mt_bool tags (123abc) -sql create table st_bool_e1 using mt_bool tags ("123abc") +sql_error create table st_bool_e1 using mt_bool tags ("123abc") sql create table st_bool_e2 using mt_bool tags ("123") sql_error create table st_bool_e3 using mt_bool tags (abc) -sql create table st_bool_e4 using mt_bool tags ("abc") -sql create table st_bool_e5 using mt_bool tags (" ") -sql create table st_bool_e6 using mt_bool tags ('') +sql_error create table st_bool_e4 using mt_bool tags ("abc") +sql_error create table st_bool_e5 using mt_bool tags (" ") +sql_error create table st_bool_e6 using mt_bool tags ('') sql create table st_bool_f0 using mt_bool tags (true) sql create table st_bool_f1 using mt_bool tags (true) @@ -598,7 +901,7 @@ sql create table st_bool_f6 using mt_bool tags (true) sql_error insert into st_bool_g0 values (now, 123abc) sql_error insert into st_bool_g1 values (now, "123abc") -sql_error insert into st_bool_g2 values (now, "123") +sql insert into st_bool_f2 values (now, "123") sql_error insert into st_bool_g3 values (now, abc) sql_error insert into st_bool_g4 values (now, "abc") sql_error insert into st_bool_g5 values (now, " ") @@ -606,7 +909,7 @@ sql_error insert into st_bool_g6 values (now, '') sql_error insert into st_bool_h0 using mt_bool tags (123abc) values (now, 1) sql_error insert into st_bool_h1 using mt_bool tags ("123abc") values (now, 1) -sql_error insert into st_bool_h2 using mt_bool tags ("123") values (now, 1) +sql insert into st_bool_h2 using mt_bool tags ("123") values (now, 1) sql_error insert into st_bool_h3 using mt_bool tags (abc) values (now, 1) sql_error insert into st_bool_h4 using mt_bool tags ("abc") values (now, 1) sql_error insert into st_bool_h5 using mt_bool tags (" ") values (now, 1) @@ -614,7 +917,7 @@ sql_error insert into st_bool_h6 using mt_bool tags ('') values (now, 1) sql_error insert into st_bool_h0 using mt_bool tags (1) values (now, 123abc) sql_error insert into st_bool_h1 using mt_bool tags (1) values (now, "123abc") -sql_error insert into st_bool_h2 using mt_bool tags (1) values (now, "123") +sql insert into st_bool_h2 using mt_bool tags (1) values (now, "123") sql_error insert into st_bool_h3 using mt_bool tags (1) values (now, abc) sql_error insert into st_bool_h4 using mt_bool tags (1) values (now, "abc") sql_error insert into st_bool_h5 using mt_bool tags (1) values (now, " ") @@ -629,11 +932,11 @@ sql insert into st_bool_i5 using mt_bool tags (1) values (now, 1) sql insert into st_bool_i6 using mt_bool tags (1) values (now, 1) sql_error alter table st_bool_i0 set tag tagname=123abc -sql alter table st_bool_i1 set tag tagname="123abc" -sql alter table st_bool_i2 set tag tagname="123" +sql_error alter table st_bool_i1 set tag tagname="123abc" +sql alter table st_bool_i2 set tag tagname="123" sql_error alter table st_bool_i3 set tag tagname=abc -sql alter table st_bool_i4 set tag tagname="abc" -sql alter table st_bool_i5 set tag tagname=" " -sql alter table st_bool_i6 set tag tagname='' +sql_error alter table st_bool_i4 set tag tagname="abc" +sql_error alter table st_bool_i5 set tag tagname=" " +sql_error alter table st_bool_i6 set tag tagname='' system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_double.sim b/tests/script/tsim/parser/columnValue_double.sim index bfcf338fac..2b1178106f 100644 --- a/tests/script/tsim/parser/columnValue_double.sim +++ b/tests/script/tsim/parser/columnValue_double.sim @@ -28,22 +28,22 @@ if $data05 != NULL then endi sql create table st_double_2 using mt_double tags ('NULL') sql show tags from st_double_2 -if $data05 != 0.000000000 then +if $data05 != NULL then return -1 endi sql create table st_double_3 using mt_double tags ('NULL') sql show tags from st_double_3 -if $data05 != 0.000000000 then +if $data05 != NULL then return -1 endi sql create table st_double_4 using mt_double tags ("NULL") sql show tags from st_double_4 -if $data05 != 0.000000000 then +if $data05 != NULL then return -1 endi sql create table st_double_5 using mt_double tags ("NULL") sql show tags from st_double_5 -if $data05 != 0.000000000 then +if $data05 != NULL then return -1 endi sql create table st_double_6 using mt_double tags (-123.321) @@ -148,6 +148,46 @@ sql show tags from st_double_16_0 #if $data05 != 0.001500000 then # return -1 #endi +sql create table st_double_100 using mt_double tags ("0x01") +sql show tags from st_double_100 +if $data05 != 1.000000000 then + return -1 +endi +sql create table st_double_101 using mt_double tags ("0b01") +sql show tags from st_double_101 +if $data05 != 1.000000000 then + return -1 +endi +sql create table st_double_102 using mt_double tags ("+0x01") +sql show tags from st_double_102 +if $data05 != 1.000000000 then + return -1 +endi +sql create table st_double_103 using mt_double tags ("-0b01") +sql show tags from st_double_103 +if $data05 != -1.000000000 then + return -1 +endi +sql create table st_double_200 using mt_double tags ( 0x01) +sql show tags from st_double_200 +if $data05 != 1.000000000 then + return -1 +endi +sql create table st_double_201 using mt_double tags (0b01 ) +sql show tags from st_double_201 +if $data05 != 1.000000000 then + return -1 +endi +sql create table st_double_202 using mt_double tags (+0x01) +sql show tags from st_double_202 +if $data05 != 1.000000000 then + return -1 +endi +sql create table st_double_203 using mt_double tags ( -0b01 ) +sql show tags from st_double_203 +if $data05 != -1.000000000 then + return -1 +endi ## case 01: insert values for test column values sql insert into st_double_0 values (now, NULL ) @@ -274,6 +314,70 @@ endi #if $data01 != -56 then # return -1 #endi +sql insert into st_double_100 values(now, "0x01") +sql select * from st_double_100 +if $rows != 1 then + return -1 +endi +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_101 values(now, "0b01") +sql select * from st_double_101 +if $rows != 1 then + return -1 +endi +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_102 values(now, "+0x01") +sql select * from st_double_102 +if $rows != 1 then + return -1 +endi +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_103 values(now, "-0b01") +sql select * from st_double_103 +if $rows != 1 then + return -1 +endi +if $data01 != -1.000000000 then + return -1 +endi +sql insert into st_double_200 values(now, 0x01) +sql select * from st_double_200 +if $rows != 1 then + return -1 +endi +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_201 values(now, 0b01 ) +sql select * from st_double_201 +if $rows != 1 then + return -1 +endi +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_202 values(now, +0x01) +sql select * from st_double_202 +if $rows != 1 then + return -1 +endi +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_203 values(now, -0b01 ) +sql select * from st_double_203 +if $rows != 1 then + return -1 +endi +if $data01 != -1.000000000 then + return -1 +endi ## case 02: dynamic create table for test tag values sql insert into st_double_16 using mt_double tags (NULL ) values (now, NULL ) @@ -394,6 +498,78 @@ sql select * from st_double_28 #if $data01 != -56 then # return -1 #endi +sql insert into st_double_100 using mt_double tags ("0x01") values (now, "0x01") +sql show tags from st_double_100 +if $data05 != 1.000000000 then + return -1 +endi +sql select * from st_double_100 +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_101 using mt_double tags ("0b01") values (now, "0b01") +sql show tags from st_double_101 +if $data05 != 1.000000000 then + return -1 +endi +sql select * from st_double_101 +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_102 using mt_double tags ("+0x01") values (now, "+0x01") +sql show tags from st_double_102 +if $data05 != 1.000000000 then + return -1 +endi +sql select * from st_double_102 +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_103 using mt_double tags ("-0b01") values (now, "-0b01") +sql show tags from st_double_103 +if $data05 != -1.000000000 then + return -1 +endi +sql select * from st_double_103 +if $data01 != -1.000000000 then + return -1 +endi +sql insert into st_double_200 using mt_double tags ( 0x01) values (now, 0x01) +sql show tags from st_double_200 +if $data05 != 1.000000000 then + return -1 +endi +sql select * from st_double_200 +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_201 using mt_double tags (0b01 ) values (now, 0b01) +sql show tags from st_double_201 +if $data05 != 1.000000000 then + return -1 +endi +sql select * from st_double_201 +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_202 using mt_double tags (+0x01) values (now, +0x01) +sql show tags from st_double_202 +if $data05 != 1.000000000 then + return -1 +endi +sql select * from st_double_202 +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_203 using mt_double tags ( -0b01 ) values (now, -0b01) +sql show tags from st_double_203 +if $data05 != -1.000000000 then + return -1 +endi +sql select * from st_double_203 +if $data01 != -1.000000000 then + return -1 +endi ### case 03: alter tag values #sql alter table st_double_0 set tag tagname=1.7976931348623157e+308 @@ -436,6 +612,46 @@ sql select * from st_double_28 ##if $data05 != -63 then ## return -1 ##endi +sql alter table st_double_100 set tag tagname="0x01" +sql show tags from st_double_100 +if $data05 != 1.000000000 then + return -1 +endi +sql alter table st_double_101 set tag tagname="0b01" +sql show tags from st_double_101 +if $data05 != 1.000000000 then + return -1 +endi +sql alter table st_double_102 set tag tagname="+0x01" +sql show tags from st_double_102 +if $data05 != 1.000000000 then + return -1 +endi +sql alter table st_double_103 set tag tagname="-0b01" +sql show tags from st_double_103 +if $data05 != -1.000000000 then + return -1 +endi +sql alter table st_double_200 set tag tagname= 0x01 +sql show tags from st_double_200 +if $data05 != 1.000000000 then + return -1 +endi +sql alter table st_double_201 set tag tagname=0b01 +sql show tags from st_double_201 +if $data05 != 1.000000000 then + return -1 +endi +sql alter table st_double_202 set tag tagname=+0x01 +sql show tags from st_double_202 +if $data05 != 1.000000000 then + return -1 +endi +sql alter table st_double_203 set tag tagname= -0b01 +sql show tags from st_double_203 +if $data05 != -1.000000000 then + return -1 +endi ## case 04: illegal input sql_error create table st_double_e0 using mt_double tags (1.8976931348623157e+308) @@ -445,11 +661,11 @@ sql_error create table st_double_e0 using mt_double tags (-31.7976931348623157e+ #sql_error create table st_double_e0 using mt_double tags (12.80) truncate integer part #sql_error create table st_double_e0 using mt_double tags (-11.80) sql_error create table st_double_e0 using mt_double tags (123abc) -sql create table st_double_e0_1 using mt_double tags ("123abc") +sql_error create table st_double_e0_1 using mt_double tags ("123abc") sql_error create table st_double_e0 using mt_double tags (abc) -sql create table st_double_e0_2 using mt_double tags ("abc") -sql create table st_double_e0_3 using mt_double tags (" ") -sql create table st_double_e0_4 using mt_double tags ('') +sql_error create table st_double_e0_2 using mt_double tags ("abc") +sql_error create table st_double_e0_3 using mt_double tags (" ") +sql_error create table st_double_e0_4 using mt_double tags ('') sql create table st_double_e0 using mt_double tags (123) sql create table st_double_e1 using mt_double tags (123) @@ -502,7 +718,8 @@ sql_error insert into st_double_e20 using mt_double tags ("123abc") values (now, sql_error insert into st_double_e22 using mt_double tags (abc) values (now, -033) sql_error insert into st_double_e23 using mt_double tags ("abc") values (now, -033) sql_error insert into st_double_e24 using mt_double tags (" ") values (now, -033) -sql insert into st_double_e25 using mt_double tags ('') values (now, -033) +sql_error insert into st_double_e25 using mt_double tags ('') values (now, -033) +sql insert into st_double_e20 using mt_double tags ("123") values (now, -033) sql insert into st_double_e13 using mt_double tags (033) values (now, 00062) sql insert into st_double_e14 using mt_double tags (033) values (now, 00062) @@ -523,10 +740,11 @@ sql_error alter table st_double_e14 set tag tagname=-1.8976931348623157e+308 sql_error alter table st_double_e15 set tag tagname=131.7976931348623157e+308 sql_error alter table st_double_e16 set tag tagname=-131.7976931348623157e+308 sql_error alter table st_double_e19 set tag tagname=123abc -sql alter table st_double_e20 set tag tagname="123abc" +sql_error alter table st_double_e20 set tag tagname="123abc" sql_error alter table st_double_e22 set tag tagname=abc -sql alter table st_double_e23 set tag tagname="abc" -sql alter table st_double_e24 set tag tagname=" " -sql alter table st_double_e25 set tag tagname='' +sql_error alter table st_double_e23 set tag tagname="abc" +sql_error alter table st_double_e24 set tag tagname=" " +sql_error alter table st_double_e25 set tag tagname='' +sql alter table st_double_e25 set tag tagname='123' system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_float.sim b/tests/script/tsim/parser/columnValue_float.sim index 4dcda33224..facb2f1b79 100644 --- a/tests/script/tsim/parser/columnValue_float.sim +++ b/tests/script/tsim/parser/columnValue_float.sim @@ -29,22 +29,22 @@ if $data05 != NULL then endi sql create table st_float_2 using mt_float tags ('NULL') sql show tags from st_float_2 -if $data05 != 0.00000 then +if $data05 != NULL then return -1 endi sql create table st_float_3 using mt_float tags ('NULL') sql show tags from st_float_3 -if $data05 != 0.00000 then +if $data05 != NULL then return -1 endi sql create table st_float_4 using mt_float tags ("NULL") sql show tags from st_float_4 -if $data05 != 0.00000 then +if $data05 != NULL then return -1 endi sql create table st_float_5 using mt_float tags ("NULL") sql show tags from st_float_5 -if $data05 != 0.00000 then +if $data05 != NULL then return -1 endi sql create table st_float_6 using mt_float tags (-123.321) @@ -156,16 +156,62 @@ if $data05 != 0.00150 then print expect 0.00150, actual: $data05 return -1 endi -#sql create table st_float_15_0 using mt_float tags (3.40282347e+38) -#sql show tags from st_float_15_0 -#if $data05 != 0.001500 then -# return -1 -#endi -#sql create table st_float_16_0 using mt_float tags (-3.40282347e+38) -#sql show tags from st_float_16_0 -#if $data05 != 0.001500 then -# return -1 -#endi +sql create table st_float_15_0 using mt_float tags (3.40282346638528859811704183484516925e+38) +sql show tags from st_float_15_0 +if $data05 < 340282346638528859811704183484516925000 then + return -1 +endi +if $data05 > 340282346638528859811704183484516925900 then + return -1 +endi +sql create table st_float_16_0 using mt_float tags (-3.40282346638528859811704183484516925e+38) +sql show tags from st_float_16_0 +if $data05 < -340282346638528859811704183484516925900 then + return -1 +endi +if $data05 > -340282346638528859811704183484516925000 then + return -1 +endi +sql create table st_float_100 using mt_float tags ("0x01") +sql show tags from st_float_100 +if $data05 != 1.00000 then + return -1 +endi +sql create table st_float_101 using mt_float tags ("0b01") +sql show tags from st_float_101 +if $data05 != 1.00000 then + return -1 +endi +sql create table st_float_102 using mt_float tags ("+0x01") +sql show tags from st_float_102 +if $data05 != 1.00000 then + return -1 +endi +sql create table st_float_103 using mt_float tags ("-0b01") +sql show tags from st_float_103 +if $data05 != -1.00000 then + return -1 +endi +sql create table st_float_200 using mt_float tags ( 0x01) +sql show tags from st_float_200 +if $data05 != 1.00000 then + return -1 +endi +sql create table st_float_201 using mt_float tags (0b01 ) +sql show tags from st_float_201 +if $data05 != 1.00000 then + return -1 +endi +sql create table st_float_202 using mt_float tags (+0x01) +sql show tags from st_float_202 +if $data05 != 1.00000 then + return -1 +endi +sql create table st_float_203 using mt_float tags ( -0b01 ) +sql show tags from st_float_203 +if $data05 != -1.00000 then + return -1 +endi ## case 01: insert values for test column values sql insert into st_float_0 values (now, NULL) @@ -216,6 +262,70 @@ endi if $data01 != NULL then return -1 endi +sql insert into st_float_100 values(now, "0x01") +sql select * from st_float_100 +if $rows != 1 then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_101 values(now, "0b01") +sql select * from st_float_101 +if $rows != 1 then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_102 values(now, "+0x01") +sql select * from st_float_102 +if $rows != 1 then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_103 values(now, "-0b01") +sql select * from st_float_103 +if $rows != 1 then + return -1 +endi +if $data01 != -1.00000 then + return -1 +endi +sql insert into st_float_200 values(now, 0x01) +sql select * from st_float_200 +if $rows != 1 then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_201 values(now, 0b01 ) +sql select * from st_float_201 +if $rows != 1 then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_202 values(now, +0x01) +sql select * from st_float_202 +if $rows != 1 then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_203 values(now, -0b01 ) +sql select * from st_float_203 +if $rows != 1 then + return -1 +endi +if $data01 != -1.00000 then + return -1 +endi sql_error insert into st_float_6 values (now, 3.40282347e+38) sql_error insert into st_float_6 values (now, -3.40282347e+38) @@ -425,6 +535,78 @@ sql select * from st_float_28 if $data01 != -5.60000 then return -1 endi +sql insert into st_float_100 using mt_float tags ("0x01") values (now, "0x01") +sql show tags from st_float_100 +if $data05 != 1.00000 then + return -1 +endi +sql select * from st_float_100 +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_101 using mt_float tags ("0b01") values (now, "0b01") +sql show tags from st_float_101 +if $data05 != 1.00000 then + return -1 +endi +sql select * from st_float_101 +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_102 using mt_float tags ("+0x01") values (now, "+0x01") +sql show tags from st_float_102 +if $data05 != 1.00000 then + return -1 +endi +sql select * from st_float_102 +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_103 using mt_float tags ("-0b01") values (now, "-0b01") +sql show tags from st_float_103 +if $data05 != -1.00000 then + return -1 +endi +sql select * from st_float_103 +if $data01 != -1.00000 then + return -1 +endi +sql insert into st_float_200 using mt_float tags ( 0x01) values (now, 0x01) +sql show tags from st_float_200 +if $data05 != 1.00000 then + return -1 +endi +sql select * from st_float_200 +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_201 using mt_float tags (0b01 ) values (now, 0b01) +sql show tags from st_float_201 +if $data05 != 1.00000 then + return -1 +endi +sql select * from st_float_201 +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_202 using mt_float tags (+0x01) values (now, +0x01) +sql show tags from st_float_202 +if $data05 != 1.00000 then + return -1 +endi +sql select * from st_float_202 +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_203 using mt_float tags ( -0b01 ) values (now, -0b01) +sql show tags from st_float_203 +if $data05 != -1.00000 then + return -1 +endi +sql select * from st_float_203 +if $data01 != -1.00000 then + return -1 +endi ### case 03: alter tag values sql alter table st_float_0 set tag tagname=340282346638528859811704183484516925440.00000 @@ -468,6 +650,46 @@ sql show tags from st_float_0 if $data05 != -63.58200 then return -1 endi +sql alter table st_float_100 set tag tagname="0x01" +sql show tags from st_float_100 +if $data05 != 1.00000 then + return -1 +endi +sql alter table st_float_101 set tag tagname="0b01" +sql show tags from st_float_101 +if $data05 != 1.00000 then + return -1 +endi +sql alter table st_float_102 set tag tagname="+0x01" +sql show tags from st_float_102 +if $data05 != 1.00000 then + return -1 +endi +sql alter table st_float_103 set tag tagname="-0b01" +sql show tags from st_float_103 +if $data05 != -1.00000 then + return -1 +endi +sql alter table st_float_200 set tag tagname= 0x01 +sql show tags from st_float_200 +if $data05 != 1.00000 then + return -1 +endi +sql alter table st_float_201 set tag tagname=0b01 +sql show tags from st_float_201 +if $data05 != 1.00000 then + return -1 +endi +sql alter table st_float_202 set tag tagname=+0x01 +sql show tags from st_float_202 +if $data05 != 1.00000 then + return -1 +endi +sql alter table st_float_203 set tag tagname= -0b01 +sql show tags from st_float_203 +if $data05 != -1.00000 then + return -1 +endi ## case 04: illegal input sql_error create table st_float_e0 using mt_float tags (3.50282347e+38) @@ -477,11 +699,11 @@ sql_error create table st_float_e0 using mt_float tags (-333.40282347e+38) #sql_error create table st_float_e0 using mt_float tags (12.80) truncate integer part #sql_error create table st_float_e0 using mt_float tags (-11.80) sql_error create table st_float_e0 using mt_float tags (123abc) -sql create table st_float_e0_1 using mt_float tags ("123abc") +sql_error create table st_float_e0_1 using mt_float tags ("123abc") sql_error create table st_float_e0 using mt_float tags (abc) -sql create table st_float_e0_2 using mt_float tags ("abc") -sql create table st_float_e0_3 using mt_float tags (" ") -sql create table st_float_e0_4 using mt_float tags ('') +sql_error create table st_float_e0_2 using mt_float tags ("abc") +sql_error create table st_float_e0_3 using mt_float tags (" ") +sql_error create table st_float_e0_4 using mt_float tags ('') sql create table st_float_e0 using mt_float tags (123) sql create table st_float_e1 using mt_float tags (123) @@ -534,7 +756,7 @@ sql_error insert into st_float_e20 using mt_float tags ("123abc") values (now, - sql_error insert into st_float_e22 using mt_float tags (abc) values (now, -033) sql_error insert into st_float_e23 using mt_float tags ("abc") values (now, -033) sql_error insert into st_float_e24 using mt_float tags (" ") values (now, -033) -sql insert into st_float_e25_3 using mt_float tags ('') values (now, -033) +sql_error insert into st_float_e25_3 using mt_float tags ('') values (now, -033) sql insert into st_float_e13 using mt_float tags (033) values (now, 00062) sql insert into st_float_e14 using mt_float tags (033) values (now, 00062) @@ -555,10 +777,10 @@ sql_error alter table st_float_e14 set tag tagname=-3.50282347e+38 sql_error alter table st_float_e15 set tag tagname=13.40282347e+38 sql_error alter table st_float_e16 set tag tagname=-13.40282347e+38 sql_error alter table st_float_e19 set tag tagname=123abc -sql alter table st_float_e20 set tag tagname="123abc" +sql_error alter table st_float_e20 set tag tagname="123abc" sql_error alter table st_float_e22 set tag tagname=abc -sql alter table st_float_e23 set tag tagname="abc" -sql alter table st_float_e24 set tag tagname=" " -sql alter table st_float_e25 set tag tagname='' +sql_error alter table st_float_e23 set tag tagname="abc" +sql_error alter table st_float_e24 set tag tagname=" " +sql_error alter table st_float_e25 set tag tagname='' system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_geometry.sim b/tests/script/tsim/parser/columnValue_geometry.sim new file mode 100644 index 0000000000..6b3c3a4390 --- /dev/null +++ b/tests/script/tsim/parser/columnValue_geometry.sim @@ -0,0 +1,277 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: geometry +print ========== geometry +sql create table mt_geometry (ts timestamp, c geometry(128)) tags(tagname geometry(128)) + +## case 00: static create table for test tag values +sql create table st_geometry_0 using mt_geometry tags(NULL) +sql show tags from st_geometry_0 +if $data05 != NULL then + return -1 +endi +sql create table st_geometry_1 using mt_geometry tags(NULL) +sql show tags from st_geometry_1 +if $data05 != NULL then + return -1 +endi +sql create table st_geometry_2 using mt_geometry tags('NULL') +sql show tags from st_geometry_2 +if $data05 != NULL then + return -1 +endi +sql create table st_geometry_3 using mt_geometry tags('NULL') +sql show tags from st_geometry_3 +if $data05 != NULL then + return -1 +endi +sql create table st_geometry_4 using mt_geometry tags("NULL") +sql show tags from st_geometry_4 +if $data05 != NULL then + return -1 +endi +sql create table st_geometry_5 using mt_geometry tags("NULL") +sql show tags from st_geometry_5 +if $data05 != NULL then + return -1 +endi +sql create table st_geometry_6 using mt_geometry tags("POINT(1.0 1.0)") +sql show tags from st_geometry_6 +if $data05 != @POINT (1.000000 1.000000)@ then + print $data05 + return -1 +endi +sql create table st_geometry_7 using mt_geometry tags(" LINESTRING(1.0 1.0, 2.0 2.0)") +sql show tags from st_geometry_7 +if $data05 != @LINESTRING (1.000000 1.000000, 2.000000 2.000000)@ then + print $data05 + return -1 +endi +sql create table st_geometry_8 using mt_geometry tags("POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))") +sql show tags from st_geometry_8 +if $data05 != @POLYGON ((1.000000 1.000000, -2.000000 2.000000, 1.000000 1.000000))@ then + print $data05 + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_geometry_0 values(now, NULL) +sql select *from st_geometry_0 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_1 values(now, NULL) +sql select *from st_geometry_1 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_2 values(now, 'NULL') +sql select *from st_geometry_2 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_3 values(now, 'NULL') +sql select *from st_geometry_3 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_4 values(now, "NULL") +sql select *from st_geometry_4 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_5 values(now, "NULL") +sql select *from st_geometry_5 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_6 values(now, "POINT(1.0 1.0)") +sql select *from st_geometry_6 +if $data01 != @POINT (1.000000 1.000000)@ then +# return -1 +endi +sql insert into st_geometry_7 values(now, " LINESTRING(1.0 1.0, 2.0 2.0)") +sql select *from st_geometry_7 +if $data01 != @LINESTRING (1.000000 1.000000, 2.000000 2.000000)@ then +# return -1 +endi +sql insert into st_geometry_8 values(now, "POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))") +sql select *from st_geometry_8 +if $data01 != @POLYGON ((1.000000 1.000000, -2.000000 2.000000, 1.000000 1.000000))@ then +# return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_geometry_100 using mt_geometry tags(NULL) values(now, NULL) +sql show tags from st_geometry_100 +if $data05 != NULL then + return -1 +endi +sql select *from st_geometry_100 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_101 using mt_geometry tags(NULL) values(now, NULL) +sql show tags from st_geometry_101 +if $data05 != NULL then + return -1 +endi +sql select *from st_geometry_100 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_102 using mt_geometry tags('NULL') values(now, 'NULL') +sql show tags from st_geometry_102 +if $data05 != NULL then + return -1 +endi +sql select *from st_geometry_100 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_103 using mt_geometry tags('NULL') values(now, 'NULL') +sql show tags from st_geometry_103 +if $data05 != NULL then + return -1 +endi +sql select *from st_geometry_100 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_104 using mt_geometry tags("NULL") values(now, "NULL") +sql show tags from st_geometry_104 +if $data05 != NULL then + return -1 +endi +sql select *from st_geometry_100 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_105 using mt_geometry tags("NULL") values(now, "NULL") +sql show tags from st_geometry_105 +if $data05 != NULL then + return -1 +endi +sql select *from st_geometry_100 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_106 using mt_geometry tags("POINT(1.0 1.0)") values(now, "POINT(1.0 1.0)") +sql show tags from st_geometry_106 +if $data05 != @POINT (1.000000 1.000000)@ then + return -1 +endi +sql select *from st_geometry_106 +if $data01 != @POINT (1.000000 1.000000)@ then +# return -1 +endi +sql insert into st_geometry_107 using mt_geometry tags(" LINESTRING(1.0 1.0, 2.0 2.0)") values(now, "LINESTRING(1.0 1.0, 2.0 2.0)") +sql show tags from st_geometry_107 +if $data05 != @LINESTRING (1.000000 1.000000, 2.000000 2.000000)@ then + return -1 +endi +sql select *from st_geometry_107 +if $data01 != @LINESTRING (1.000000 1.000000, 2.000000 2.000000)@ then +# return -1 +endi +sql insert into st_geometry_108 using mt_geometry tags("POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))") values(now, "POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))") +sql show tags from st_geometry_108 +if $data05 != @POLYGON ((1.000000 1.000000, -2.000000 2.000000, 1.000000 1.000000))@ then + return -1 +endi +sql select *from st_geometry_108 +if $data01 != @POLYGON ((1.000000 1.000000, -2.000000 2.000000, 1.000000 1.000000))@ then +# return -1 +endi + +## case 03: alter tag values +sql alter table st_geometry_0 set tag tagname=NULL +sql show tags from st_geometry_0 +if $data05 != NULL then + return -1 +endi +sql alter table st_geometry_1 set tag tagname=NULL +sql show tags from st_geometry_1 +if $data05 != NULL then + return -1 +endi +sql alter table st_geometry_2 set tag tagname='NULL' +sql show tags from st_geometry_2 +if $data05 != NULL then + return -1 +endi +sql alter table st_geometry_3 set tag tagname='NULL' +sql show tags from st_geometry_3 +if $data05 != NULL then + return -1 +endi +sql alter table st_geometry_4 set tag tagname="NULL" +sql show tags from st_geometry_4 +if $data05 != NULL then + return -1 +endi +sql alter table st_geometry_5 set tag tagname="NULL" +sql show tags from st_geometry_5 +if $data05 != NULL then + return -1 +endi +sql alter table st_geometry_6 set tag tagname="POINT(1.0 1.0)" +sql show tags from st_geometry_6 +if $data05 != @POINT (1.000000 1.000000)@ then + return -1 +endi +sql alter table st_geometry_7 set tag tagname=" LINESTRING(1.0 1.0, 2.0 2.0)" +sql show tags from st_geometry_7 +if $data05 != @LINESTRING (1.000000 1.000000, 2.000000 2.000000)@ then + return -1 +endi +sql alter table st_geometry_8 set tag tagname="POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))" +sql show tags from st_geometry_8 +if $data05 != @POLYGON ((1.000000 1.000000, -2.000000 2.000000, 1.000000 1.000000))@ then + return -1 +endi + +# case 04: illegal input +sql_error create table st_geometry_206 using mt_geometry tags(+0123) +sql_error create table st_geometry_207 using mt_geometry tags(-01.23) +sql_error create table st_geometry_208 using mt_geometry tags(+0x01) +sql_error create table st_geometry_209 using mt_geometry tags(-0b01) +sql_error create table st_geometry_2010 using mt_geometry tags(-0.1e-10) +sql_error create table st_geometry_2011 using mt_geometry tags(+0.1E+2) +sql_error create table st_geometry_2012 using mt_geometry tags(tRue) +sql_error create table st_geometry_2013 using mt_geometry tags(FalsE) +sql_error create table st_geometry_2014 using mt_geometry tags(noW) +sql_error create table st_geometry_2015 using mt_geometry tags(toDay) +sql_error insert into st_geometry_206 using mt_geometry tags(+0123) values(now, NULL); +sql_error insert into st_geometry_207 using mt_geometry tags(-01.23) values(now, NULL); +sql_error insert into st_geometry_208 using mt_geometry tags(+0x01) values(now, NULL); +sql_error insert into st_geometry_209 using mt_geometry tags(-0b01) values(now, NULL); +sql_error insert into st_geometry_2010 using mt_geometry tags(-0.1e-10) values(now, NULL); +sql_error insert into st_geometry_2011 using mt_geometry tags(+0.1E+2) values(now, NULL); +sql_error insert into st_geometry_2012 using mt_geometry tags(tRue) values(now, NULL); +sql_error insert into st_geometry_2013 using mt_geometry tags(FalsE) values(now, NULL); +sql_error insert into st_geometry_2014 using mt_geometry tags(noW) values(now, NULL); +sql_error insert into st_geometry_2015 using mt_geometry tags(toDay) values(now, NULL); +sql_error insert into st_geometry_106 using mt_varbinary tags(NULL) values(now(), +0123) +sql_error insert into st_geometry_107 using mt_varbinary tags(NULL) values(now(), -01.23) +sql_error insert into st_geometry_108 using mt_varbinary tags(NULL) values(now(), +0x01) +sql_error insert into st_geometry_109 using mt_varbinary tags(NULL) values(now(), -0b01) +sql_error insert into st_geometry_1010 using mt_varbinary tags(NULL) values(now(), -0.1e-10) +sql_error insert into st_geometry_1011 using mt_varbinary tags(NULL) values(now(), +0.1E+2) +sql_error insert into st_geometry_1012 using mt_varbinary tags(NULL) values(now(), tRue) +sql_error insert into st_geometry_1013 using mt_varbinary tags(NULL) values(now(), FalsE) +sql_error insert into st_geometry_1014 using mt_varbinary tags(NULL) values(now(), noW) +sql_error insert into st_geometry_1015 using mt_varbinary tags(NULL) values(now(), toDay) + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_int.sim b/tests/script/tsim/parser/columnValue_int.sim index e68ae6f13f..f03a576ae3 100644 --- a/tests/script/tsim/parser/columnValue_int.sim +++ b/tests/script/tsim/parser/columnValue_int.sim @@ -28,10 +28,26 @@ if $data05 != NULL then return -1 endi -sql_error create table st_int_2 using mt_int tags ('NULL') -sql_error create table st_int_3 using mt_int tags ('NULL') -sql_error create table st_int_4 using mt_int tags ("NULL") -sql_error create table st_int_5 using mt_int tags ("NULL") +sql create table st_int_2 using mt_int tags ('NULL') +sql show tags from st_int_2 +if $data05 != NULL then + return -1 +endi +sql create table st_int_3 using mt_int tags ('NULL') +sql show tags from st_int_3 +if $data05 != NULL then + return -1 +endi +sql create table st_int_4 using mt_int tags ("NULL") +sql show tags from st_int_4 +if $data05 != NULL then + return -1 +endi +sql create table st_int_5 using mt_int tags ("NULL") +sql show tags from st_int_5 +if $data05 != NULL then + return -1 +endi sql create table st_int_6 using mt_int tags (-2147483647) sql show tags from st_int_6 @@ -78,6 +94,103 @@ sql show tags from st_int_14 if $data05 != -78 then return -1 endi +sql create table st_int_100 using mt_int tags ("0x01") +sql show tags from st_int_100 +if $data05 != 1 then + return -1 +endi +sql create table st_int_101 using mt_int tags ("0b01") +sql show tags from st_int_101 +if $data05 != 1 then + return -1 +endi +sql create table st_int_102 using mt_int tags ("+0x01") +sql show tags from st_int_102 +if $data05 != 1 then + return -1 +endi +sql create table st_int_103 using mt_int tags ("-0b01") +sql show tags from st_int_103 +if $data05 != -1 then + return -1 +endi +sql create table st_int_104 using mt_int tags ("-123.1") +sql show tags from st_int_104 +if $data05 != -123 then + return -1 +endi +sql create table st_int_105 using mt_int tags ("+123.5") +sql show tags from st_int_105 +if $data05 != 124 then + return -1 +endi +sql create table st_int_106 using mt_int tags ("-1e-1") +sql show tags from st_int_106 +if $data05 != 0 then + return -1 +endi +sql create table st_int_107 using mt_int tags ("+0.1235e3") +sql show tags from st_int_107 +if $data05 != 124 then + print $data05 != 124 + return -1 +endi +sql create table st_int_108 using mt_int tags ("-0.11e-30") +sql show tags from st_int_108 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql create table st_int_109 using mt_int tags ("-1.1e-307") +sql show tags from st_int_109 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql create table st_int_110 using mt_int tags ( -1e-1 ) +sql show tags from st_int_110 +if $data05 != 0 then + return -1 +endi +sql create table st_int_111 using mt_int tags ( +0.1235e3 ) +sql show tags from st_int_111 +if $data05 != 124 then + print $data05 != 124 + return -1 +endi +sql create table st_int_112 using mt_int tags (-0.11e-30) +sql show tags from st_int_112 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql create table st_int_113 using mt_int tags (-1.1e-307) +sql show tags from st_int_113 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql create table st_int_200 using mt_int tags ( 0x01) +sql show tags from st_int_200 +if $data05 != 1 then + return -1 +endi +sql create table st_int_201 using mt_int tags (0b01 ) +sql show tags from st_int_201 +if $data05 != 1 then + return -1 +endi +sql create table st_int_202 using mt_int tags (+0x01) +sql show tags from st_int_202 +if $data05 != 1 then + return -1 +endi + +sql create table st_int_203 using mt_int tags ( -0b01 ) +sql show tags from st_int_203 +if $data05 != -1 then + return -1 +endi ## case 01: insert values for test column values sql insert into st_int_0 values (now, NULL) @@ -171,6 +284,122 @@ if $data01 != -56 then return -1 endi +sql insert into st_int_100 values (now, "0x01") +sql select * from st_int_100 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_int_101 values (now, "0b01") +sql select * from st_int_101 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_int_102 values (now, "+0x01") +sql select * from st_int_102 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_int_103 values (now, "-0b01") +sql select * from st_int_103 +if $data01 != -1 then + return -1 +endi +sql insert into st_int_104 values (now, "-123.1") +sql select * from st_int_104 +if $data01 != -123 then + return -1 +endi +sql insert into st_int_105 values (now, "+123.5") +sql select * from st_int_105 +if $data01 != 124 then + return -1 +endi +sql insert into st_int_106 values (now, "-1e-1") +sql select * from st_int_106 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_107 values (now, "+0.1235e3") +sql select * from st_int_107 +if $data01 != 124 then + print $data05 != 124 + return -1 +endi +sql insert into st_int_108 values (now, "-0.11e-30") +sql select * from st_int_108 +if $data01 != 0 then + print $data05 != 0 + return -1 +endi +sql insert into st_int_109 values (now, "-1.1e-307") +sql select * from st_int_109 +if $data01 != 0 then + print $data05 != 0 + return -1 +endi +sql insert into st_int_110 values (now, -1e-1 ) +sql select * from st_int_110 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_111 values (now, +0.1235e3 ) +sql select * from st_int_111 +if $data01 != 124 then + print $data05 != 124 + return -1 +endi +sql insert into st_int_112 values (now, -0.11e-30) +sql select * from st_int_112 +if $data01 != 0 then + print $data05 != 0 + return -1 +endi +sql insert into st_int_113 values (now, -1.1e-307) +sql select * from st_int_113 +if $data01 != 0 then + print $data05 != 0 + return -1 +endi +sql insert into st_int_200 values (now, 0x01) +sql select * from st_int_200 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_int_201 values (now, 0b01 ) +sql select * from st_int_201 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_int_202 values (now, +0x01) +sql select * from st_int_202 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql insert into st_int_203 values (now, -0b01 ) +sql select * from st_int_203 +if $data01 != -1 then + return -1 +endi + ## case 02: dynamic create table for test tag values sql insert into st_int_16 using mt_int tags (NULL) values (now, NULL) sql show create table st_int_16 @@ -291,52 +520,308 @@ sql select * from st_int_28 if $data01 != -56 then return -1 endi +sql insert into st_int_1100 using mt_int tags ("0x01") values(now, "0x01"); +sql show tags from st_int_1100 +if $data05 != 1 then + return -1 +endi +sql select * from st_int_1100 +if $data01 != 1 then + return -1 +endi +sql insert into st_int_1101 using mt_int tags ("0b01") values(now, "0b01"); +sql show tags from st_int_1101 +if $data05 != 1 then + return -1 +endi +sql select * from st_int_1101 +if $data01 != 1 then + return -1 +endi +sql insert into st_int_1102 using mt_int tags ("+0x01") values(now, "+0x01"); +sql show tags from st_int_1102 +if $data05 != 1 then + return -1 +endi +sql select * from st_int_1102 +if $data01 != 1 then + return -1 +endi +sql insert into st_int_1103 using mt_int tags ("-0b01") values(now, "-0b01"); +sql show tags from st_int_1103 +if $data05 != -1 then + return -1 +endi +sql select * from st_int_1103 +if $data01 != -1 then + return -1 +endi +sql insert into st_int_1104 using mt_int tags ("-123.1") values(now, "-123.1"); +sql show tags from st_int_1104 +if $data05 != -123 then + return -1 +endi +sql select * from st_int_1104 +if $data01 != -123 then + return -1 +endi +sql insert into st_int_1105 using mt_int tags ("+123.5") values(now, "+123.5"); +sql show tags from st_int_1105 +if $data05 != 124 then + return -1 +endi +sql select * from st_int_1105 +if $data01 != 124 then + return -1 +endi +sql insert into st_int_1106 using mt_int tags ("-1e-1") values(now, "-1e-1"); +sql show tags from st_int_1106 +if $data05 != 0 then + return -1 +endi +sql select * from st_int_1106 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_1107 using mt_int tags ("+0.1235e3") values(now, "+0.1235e3"); +sql show tags from st_int_1107 +if $data05 != 124 then + return -1 +endi +sql insert into st_int_1108 using mt_int tags ("-0.11e-30") values(now, "-0.11e-30"); +sql show tags from st_int_1108 +if $data05 != 0 then + return -1 +endi +sql select * from st_int_1108 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_1109 using mt_int tags ("-1.1e-307") values(now, "-1.1e-307"); +sql show tags from st_int_1109 +if $data05 != 0 then + return -1 +endi +sql select * from st_int_1109 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_1110 using mt_int tags ( -1e-1 ) values(now, -1e-1); +sql show tags from st_int_1110 +if $data05 != 0 then + return -1 +endi +sql select * from st_int_1110 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_1111 using mt_int tags ( +0.1235e3 ) values(now, +0.1235e3); +sql show tags from st_int_1111 +if $data05 != 124 then + return -1 +endi +sql select * from st_int_1111 +if $data01 != 124 then + return -1 +endi +sql insert into st_int_1112 using mt_int tags (-0.11e-30) values(now, -0.11e-30); +sql show tags from st_int_1112 +if $data05 != 0 then + return -1 +endi +sql select * from st_int_1112 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_1113 using mt_int tags (-1.1e-307) values(now, -1.1e-307); +sql show tags from st_int_1113 +if $data05 != 0 then + return -1 +endi +sql select * from st_int_1113 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_1200 using mt_int tags ( 0x01) values(now, 0x01); +sql show tags from st_int_1200 +if $data05 != 1 then + return -1 +endi +sql select * from st_int_1200 +if $data01 != 1 then + return -1 +endi +sql insert into st_int_1201 using mt_int tags (0b01 ) values(now, 0b01); +sql show tags from st_int_1201 +if $data05 != 1 then + return -1 +endi +sql select * from st_int_1201 +if $data01 != 1 then + return -1 +endi +sql insert into st_int_1202 using mt_int tags (+0x01) values(now, +0x01); +sql show tags from st_int_1202 +if $data05 != 1 then + return -1 +endi +sql select * from st_int_1202 +if $data01 != 1 then + return -1 +endi + +sql insert into st_int_1203 using mt_int tags ( -0b01 ) values(now, -0b01); +sql show tags from st_int_1203 +if $data05 != -1 then + return -1 +endi +sql select * from st_int_1203 +if $data01 != -1 then + return -1 +endi ### case 03: alter tag values -#sql alter table st_int_0 set tag tagname=2147483647 -#sql show tags from st_int_0 -#if $data05 != 2147483647 then -# return -1 -#endi -#sql alter table st_int_0 set tag tagname=-2147483647 -#sql show tags from st_int_0 -#if $data05 != -2147483647 then -# return -1 -#endi -#sql alter table st_int_0 set tag tagname=+100 -#sql show tags from st_int_0 -#if $data05 != 100 then -# return -1 -#endi -#sql alter table st_int_0 set tag tagname=-33 -#sql show tags from st_int_0 -#if $data05 != -33 then -# return -1 -#endi -#sql alter table st_int_0 set tag tagname='+98' -#sql show tags from st_int_0 -#if $data05 != 98 then -# return -1 -#endi -#sql alter table st_int_0 set tag tagname='-076' -#sql show tags from st_int_0 -#if $data05 != -76 then -# return -1 -#endi -#sql alter table st_int_0 set tag tagname=+0012 -#sql show tags from st_int_0 -#if $data05 != 12 then -# return -1 -#endi -#sql alter table st_int_0 set tag tagname=-00063 -#sql show tags from st_int_0 -#if $data05 != -63 then -# return -1 -#endi +sql alter table st_int_0 set tag tagname=2147483647 +sql show tags from st_int_0 +if $data05 != 2147483647 then + return -1 +endi +sql alter table st_int_0 set tag tagname=-2147483647 +sql show tags from st_int_0 +if $data05 != -2147483647 then + return -1 +endi +sql alter table st_int_0 set tag tagname=+100 +sql show tags from st_int_0 +if $data05 != 100 then + return -1 +endi +sql alter table st_int_0 set tag tagname=-33 +sql show tags from st_int_0 +if $data05 != -33 then + return -1 +endi +sql alter table st_int_0 set tag tagname='+98' +sql show tags from st_int_0 +if $data05 != 98 then + return -1 +endi +sql alter table st_int_0 set tag tagname='-076' +sql show tags from st_int_0 +if $data05 != -76 then + return -1 +endi +sql alter table st_int_0 set tag tagname=+0012 +sql show tags from st_int_0 +if $data05 != 12 then + return -1 +endi +sql alter table st_int_0 set tag tagname=-00063 +sql show tags from st_int_0 +if $data05 != -63 then + return -1 +endi +sql alter table st_int_100 set tag tagname="0x01" +sql show tags from st_int_100 +if $data05 != 1 then + return -1 +endi +sql alter table st_int_101 set tag tagname="0b01" +sql show tags from st_int_101 +if $data05 != 1 then + return -1 +endi +sql alter table st_int_102 set tag tagname="+0x01" +sql show tags from st_int_102 +if $data05 != 1 then + return -1 +endi +sql alter table st_int_103 set tag tagname="-0b01" +sql show tags from st_int_103 +if $data05 != -1 then + return -1 +endi +sql alter table st_int_104 set tag tagname="-123.1" +sql show tags from st_int_104 +if $data05 != -123 then + return -1 +endi +sql alter table st_int_105 set tag tagname="+123.5" +sql show tags from st_int_105 +if $data05 != 124 then + return -1 +endi +sql alter table st_int_106 set tag tagname="-1e-1" +sql show tags from st_int_106 +if $data05 != 0 then + return -1 +endi +sql alter table st_int_107 set tag tagname="+0.1235e3" +sql show tags from st_int_107 +if $data05 != 124 then + print $data05 != 124 + return -1 +endi +sql alter table st_int_108 set tag tagname="-0.11e-30" +sql show tags from st_int_108 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql alter table st_int_109 set tag tagname="-1.1e-307" +sql show tags from st_int_109 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql alter table st_int_110 set tag tagname= -1e-1 +sql show tags from st_int_110 +if $data05 != 0 then + return -1 +endi +sql alter table st_int_111 set tag tagname= +0.1235e3 +sql show tags from st_int_111 +if $data05 != 124 then + print $data05 != 124 + return -1 +endi +sql alter table st_int_112 set tag tagname=-0.11e-30 +sql show tags from st_int_112 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql alter table st_int_113 set tag tagname=-1.1e-307 +sql show tags from st_int_113 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql alter table st_int_200 set tag tagname= 0x01 +sql show tags from st_int_200 +if $data05 != 1 then + return -1 +endi +sql alter table st_int_201 set tag tagname=0b01 +sql show tags from st_int_201 +if $data05 != 1 then + return -1 +endi +sql alter table st_int_202 set tag tagname=+0x01 +sql show tags from st_int_202 +if $data05 != 1 then + return -1 +endi +sql alter table st_int_203 set tag tagname= -0b01 +sql show tags from st_int_203 +if $data05 != -1 then + return -1 +endi ## case 04: illegal input sql_error create table st_int_e0 using mt_int tags (2147483648) sql create table st_int_e0_err1 using mt_int tags (-2147483648) +sql_error create table st_int_e0_err2 using mt_int tags (-2147483649) sql_error create table st_int_e0 using mt_int tags (214748364800) sql_error create table st_int_e0 using mt_int tags (-214748364800) #sql_error create table st_int_e0 using mt_int tags (12.80) truncate integer part @@ -346,7 +831,7 @@ sql_error create table st_int_e0 using mt_int tags ("123abc") sql_error create table st_int_e0 using mt_int tags (abc) sql_error create table st_int_e0 using mt_int tags ("abc") sql_error create table st_int_e0 using mt_int tags (" ") -sql create table st_int_e0_err2 using mt_int tags ('') +sql_error create table st_int_e0_err2 using mt_int tags ('') sql create table st_int_e0 using mt_int tags (123) sql create table st_int_e1 using mt_int tags (123) @@ -399,7 +884,10 @@ sql_error insert into st_int_e20 using mt_int tags ("123abc") values (now, -033) sql_error insert into st_int_e22 using mt_int tags (abc) values (now, -033) sql_error insert into st_int_e23 using mt_int tags ("abc") values (now, -033) sql_error insert into st_int_e24 using mt_int tags (" ") values (now, -033) -sql insert into st_int_e25_1 using mt_int tags ('') values (now, -033) +sql_error insert into st_int_e25_1 using mt_int tags ('') values (now, -033) +sql insert into st_int_e26_1 using mt_int tags ('123') values (now, -033) +sql insert into st_int_e27_1 using mt_int tags ('12.80') values (now, -033) +sql insert into st_int_e28_1 using mt_int tags ('-11.80') values (now, -033) sql insert into st_int_e13 using mt_int tags (033) values (now, 00062) sql insert into st_int_e14 using mt_int tags (033) values (now, 00062) @@ -415,8 +903,10 @@ sql insert into st_int_e23 using mt_int tags (033) values (now, 00062) sql insert into st_int_e24 using mt_int tags (033) values (now, 00062) sql insert into st_int_e25 using mt_int tags (033) values (now, 00062) +sql alter table st_int_e13 set tag tagname=2147483647 sql_error alter table st_int_e13 set tag tagname=2147483648 sql alter table st_int_e14 set tag tagname=-2147483648 +sql_error alter table st_int_e14 set tag tagname=2147483649 sql_error alter table st_int_e15 set tag tagname=12147483648 sql_error alter table st_int_e16 set tag tagname=-3147483648 sql_error alter table st_int_e19 set tag tagname=123abc @@ -424,6 +914,9 @@ sql_error alter table st_int_e20 set tag tagname="123abc" sql_error alter table st_int_e22 set tag tagname=abc sql_error alter table st_int_e23 set tag tagname="abc" sql_error alter table st_int_e24 set tag tagname=" " -sql alter table st_int_e25 set tag tagname='' +sql_error alter table st_int_e25 set tag tagname='' +sql alter table st_int_e26_1 set tag tagname='123' +sql alter table st_int_e27_1 set tag tagname='12.80' +sql alter table st_int_e28_1 set tag tagname='-11.80' system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_json.sim b/tests/script/tsim/parser/columnValue_json.sim new file mode 100644 index 0000000000..002f71b290 --- /dev/null +++ b/tests/script/tsim/parser/columnValue_json.sim @@ -0,0 +1,220 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: json +print ========== json +sql create table mt_json (ts timestamp, c varchar(50)) tags(tagname json) + +## case 00: static create table for test tag values +sql create table st_json_0 using mt_json tags(NULL) +sql show tags from st_json_0 +if $data05 != NULL then + return -1 +endi +sql create table st_json_1 using mt_json tags(NULL) +sql show tags from st_json_1 +if $data05 != NULL then + return -1 +endi +sql create table st_json_2 using mt_json tags('NULL') +sql show tags from st_json_2 +if $data05 != NULL then + return -1 +endi +sql create table st_json_3 using mt_json tags('NULL') +sql show tags from st_json_3 +if $data05 != NULL then + return -1 +endi +sql create table st_json_4 using mt_json tags("NULL") +sql show tags from st_json_4 +if $data05 != NULL then + return -1 +endi +sql create table st_json_5 using mt_json tags("NULL") +sql show tags from st_json_5 +if $data05 != NULL then + return -1 +endi +sql create table st_json_6 using mt_json tags("") +sql show tags from st_json_6 +if $data05 != NULL then + return -1 +endi +sql create table st_json_7 using mt_json tags(" ") +sql show tags from st_json_7 +if $data05 != NULL then + return -1 +endi +sql create table st_json_8 using mt_json tags("{\"k1\":\"v1\",\"k2\":\"v2\"}") +sql show tags from st_json_8 +if $data05 != {"k1":"v1","k2":"v2"} then + return -1 +endi + +## case 01: insert values for test column values + +## case 02: dynamic create table for test tag values +sql insert into st_json_100 using mt_json tags(NULL) values(now,NULL) +sql show tags from st_json_100 +if $data05 != NULL then + return -1 +endi +sql select * from st_json_100 +if $data01 != NULL then + return -1 +endi +sql insert into st_json_101 using mt_json tags(NULL) values(now,NULL) +sql show tags from st_json_101 +if $data05 != NULL then + return -1 +endi +sql select * from st_json_101 +if $data01 != NULL then + return -1 +endi +sql insert into st_json_102 using mt_json tags('NULL') values(now,'NULL') +sql show tags from st_json_102 +if $data05 != NULL then + return -1 +endi +sql select * from st_json_102 +if $data01 != NULL then + return -1 +endi +sql insert into st_json_103 using mt_json tags('NULL') values(now,'NULL') +sql show tags from st_json_103 +if $data05 != NULL then + return -1 +endi +sql select * from st_json_103 +if $data01 != NULL then + return -1 +endi +sql insert into st_json_104 using mt_json tags("NULL") values(now,"NULL") +sql show tags from st_json_104 +if $data05 != NULL then + return -1 +endi +sql select * from st_json_104 +if $data01 != NULL then + return -1 +endi +sql insert into st_json_105 using mt_json tags("NULL") values(now,"NULL") +sql show tags from st_json_105 +if $data05 != NULL then + return -1 +endi +sql select * from st_json_105 +if $data01 != NULL then + return -1 +endi +sql insert into st_json_106 using mt_json tags("") values(now,"vc") +sql show tags from st_json_106 +if $data05 != NULL then + return -1 +endi +sql select * from st_json_106 +if $data01 != vc then + return -1 +endi +sql insert into st_json_107 using mt_json tags(" ") values(now,"vc") +sql show tags from st_json_107 +if $data05 != NULL then + return -1 +endi +sql select * from st_json_107 +if $data01 != vc then + return -1 +endi +sql insert into st_json_108 using mt_json tags("{\"k1\":\"v1\",\"k2\":\"v2\"} ") values(now,"vc") +sql show tags from st_json_108 +if $data05 != {"k1":"v1","k2":"v2"} then + return -1 +endi +sql select * from st_json_108 +if $data01 != vc then + return -1 +endi + +## case 03: alter tag values +sql alter table st_json_100 set tag tagname=NULL +sql show tags from st_json_100 +if $data05 != NULL then + return -1 +endi +sql alter table st_json_101 set tag tagname=NULL +sql show tags from st_json_101 +if $data05 != NULL then + return -1 +endi +sql alter table st_json_102 set tag tagname='NULL' +sql show tags from st_json_102 +if $data05 != NULL then + return -1 +endi +sql alter table st_json_103 set tag tagname='NULL' +sql show tags from st_json_103 +if $data05 != NULL then + return -1 +endi +sql alter table st_json_104 set tag tagname="NULL" +sql show tags from st_json_104 +if $data05 != NULL then + return -1 +endi +sql alter table st_json_105 set tag tagname="NULL" +sql show tags from st_json_105 +if $data05 != NULL then + return -1 +endi +sql alter table st_json_106 set tag tagname="" +sql show tags from st_json_106 +if $data05 != NULL then + return -1 +endi +sql alter table st_json_107 set tag tagname=" " +sql show tags from st_json_107 +if $data05 != NULL then + return -1 +endi +sql alter table st_json_108 set tag tagname="{\"k1\":\"v1\",\"k2\":\"v2\"}" +sql show tags from st_json_108 +if $data05 != {"k1":"v1","k2":"v2"} then + return -1 +endi + + +# case 04: illegal input +sql_error create table st_json_206 using mt_json tags(+0123) +sql_error create table st_json_207 using mt_json tags(-01.23) +sql_error create table st_json_208 using mt_json tags(+0x01) +sql_error create table st_json_209 using mt_json tags(-0b01) +sql_error create table st_json_2010 using mt_json tags(-0.1e-10) +sql_error create table st_json_2011 using mt_json tags(+0.1E+2) +sql_error create table st_json_2012 using mt_json tags(tRue) +sql_error create table st_json_2013 using mt_json tags(FalsE) +sql_error create table st_json_2014 using mt_json tags(noW) +sql_error create table st_json_2015 using mt_json tags(toDay) +sql_error insert into st_json_206 using mt_json tags(+0123) values(now, NULL); +sql_error insert into st_json_207 using mt_json tags(-01.23) values(now, NULL); +sql_error insert into st_json_208 using mt_json tags(+0x01) values(now, NULL); +sql_error insert into st_json_209 using mt_json tags(-0b01) values(now, NULL); +sql_error insert into st_json_2010 using mt_json tags(-0.1e-10) values(now, NULL); +sql_error insert into st_json_2011 using mt_json tags(+0.1E+2) values(now, NULL); +sql_error insert into st_json_2012 using mt_json tags(tRue) values(now, NULL); +sql_error insert into st_json_2013 using mt_json tags(FalsE) values(now, NULL); +sql_error insert into st_json_2014 using mt_json tags(noW) values(now, NULL); +sql_error insert into st_json_2015 using mt_json tags(toDay) values(now, NULL); + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_nchar.sim b/tests/script/tsim/parser/columnValue_nchar.sim new file mode 100644 index 0000000000..0b5de82d57 --- /dev/null +++ b/tests/script/tsim/parser/columnValue_nchar.sim @@ -0,0 +1,415 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: nchar +print ========== nchar +sql create table mt_nchar (ts timestamp, c nchar(50)) tags (tagname nchar(50)) + +## case 00: static create table for test tag values +sql create table st_nchar_0 using mt_nchar tags (NULL) +sql show create table st_nchar_0 +sql show tags from st_nchar_0 +if $data05 != NULL then + return -1 +endi +sql create table st_nchar_1 using mt_nchar tags (NULL) +sql show tags from st_nchar_1 +if $data05 != NULL then + return -1 +endi +sql create table st_nchar_2 using mt_nchar tags ('NULL') +sql show tags from st_nchar_2 +if $data05 != NULL then + return -1 +endi +sql create table st_nchar_3 using mt_nchar tags ('NULL') +sql show tags from st_nchar_3 +if $data05 != NULL then + return -1 +endi +sql create table st_nchar_4 using mt_nchar tags ("NULL") +sql show tags from st_nchar_4 +if $data05 != NULL then + return -1 +endi +sql create table st_nchar_5 using mt_nchar tags ("NULL") +sql show tags from st_nchar_5 +if $data05 != NULL then + return -1 +endi +sql create table st_nchar_6 using mt_nchar tags (+0123) +sql show tags from st_nchar_6 +if $data05 != +0123 then + return -1 +endi +sql create table st_nchar_7 using mt_nchar tags (-01.23) +sql show tags from st_nchar_7 +if $data05 != -01.23 then + return -1 +endi +sql create table st_nchar_8 using mt_nchar tags (+0x01) +sql show tags from st_nchar_8 +if $data05 != +0x01 then + return -1 +endi +sql create table st_nchar_9 using mt_nchar tags (-0b01) +sql show tags from st_nchar_9 +if $data05 != -0b01 then + return -1 +endi +sql create table st_nchar_10 using mt_nchar tags (-0.1e-10) +sql show tags from st_nchar_10 +if $data05 != -0.1e-10 then + return -1 +endi +sql create table st_nchar_11 using mt_nchar tags (+0.1E+2) +sql show tags from st_nchar_11 +if $data05 != +0.1e+2 then + return -1 +endi +sql create table st_nchar_12 using mt_nchar tags (tRue) +sql show tags from st_nchar_12 +if $data05 != true then + return -1 +endi +sql create table st_nchar_13 using mt_nchar tags (FalsE) +sql show tags from st_nchar_13 +if $data05 != false then + return -1 +endi +sql create table st_nchar_14 using mt_nchar tags (noW) +sql show tags from st_nchar_14 +if $data05 != now then + return -1 +endi +sql create table st_nchar_15 using mt_nchar tags (toDay) +sql show tags from st_nchar_15 +if $data05 != today then + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_nchar_0 values(now, NULL) +sql select * from st_nchar_0 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_1 values(now, NULL) +sql select * from st_nchar_1 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_2 values(now, 'NULL') +sql select * from st_nchar_2 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_3 values(now, 'NULL') +sql select * from st_nchar_3 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_4 values(now, "NULL") +sql select * from st_nchar_4 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_5 values(now, "NULL") +sql select * from st_nchar_5 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_6 values(now, +0123) +sql select * from st_nchar_6 +if $data01 != +0123 then + return -1 +endi +sql insert into st_nchar_7 values(now, -01.23) +sql select * from st_nchar_7 +if $data01 != -01.23 then + return -1 +endi +sql insert into st_nchar_8 values(now, +0x01) +sql select * from st_nchar_8 +if $data01 != +0x01 then + return -1 +endi +sql insert into st_nchar_9 values(now, -0b01) +sql select * from st_nchar_9 +if $data01 != -0b01 then + return -1 +endi +sql insert into st_nchar_10 values(now, -0.1e-10) +sql select * from st_nchar_10 +if $data01 != -0.1e-10 then + return -1 +endi +sql insert into st_nchar_11 values(now, +0.1E+2) +sql select * from st_nchar_11 +if $data01 != +0.1e+2 then + return -1 +endi +sql insert into st_nchar_12 values(now, tRue) +sql select * from st_nchar_12 +if $data01 != true then + return -1 +endi +sql insert into st_nchar_13 values(now, FalsE) +sql select * from st_nchar_13 +if $data01 != false then + return -1 +endi +sql insert into st_nchar_14 values(now, noW) +sql select * from st_nchar_14 +if $data01 != now then + return -1 +endi +sql insert into st_nchar_15 values(now, toDay) +sql select * from st_nchar_15 +if $data01 != today then + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_nchar_0 using mt_nchar tags (NULL) values(now, NULL) +sql show tags from st_nchar_0 +if $data05 != NULL then + return -1 +endi +sql select * from st_nchar_0 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_1 using mt_nchar tags (NULL) values(now, NULL) +sql show tags from st_nchar_1 +if $data05 != NULL then + return -1 +endi +sql select * from st_nchar_1 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_2 using mt_nchar tags ('NULL') values(now, 'NULL') +sql show tags from st_nchar_2 +if $data05 != NULL then + return -1 +endi +sql select * from st_nchar_2 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_3 using mt_nchar tags ('NULL') values(now, 'NULL') +sql show tags from st_nchar_3 +if $data05 != NULL then + return -1 +endi +sql select * from st_nchar_3 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_4 using mt_nchar tags ("NULL") values(now, "NULL") +sql show tags from st_nchar_4 +if $data05 != NULL then + return -1 +endi +sql select * from st_nchar_4 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_5 using mt_nchar tags ("NULL") values(now, "NULL") +sql show tags from st_nchar_5 +if $data05 != NULL then + return -1 +endi +sql select * from st_nchar_5 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_6 using mt_nchar tags (+0123) values(now, +0123) +sql show tags from st_nchar_6 +if $data05 != +0123 then + return -1 +endi +sql select * from st_nchar_6 +if $data01 != +0123 then + return -1 +endi +sql insert into st_nchar_7 using mt_nchar tags (-01.23) values(now, -01.23) +sql show tags from st_nchar_7 +if $data05 != -01.23 then + return -1 +endi +sql select * from st_nchar_7 +if $data01 != -01.23 then + return -1 +endi +sql insert into st_nchar_8 using mt_nchar tags (+0x01) values(now, +0x01) +sql show tags from st_nchar_8 +if $data05 != +0x01 then + return -1 +endi +sql select * from st_nchar_8 +if $data01 != +0x01 then + return -1 +endi +sql insert into st_nchar_9 using mt_nchar tags (-0b01) values(now, -0b01) +sql show tags from st_nchar_9 +if $data05 != -0b01 then + return -1 +endi +sql select * from st_nchar_9 +if $data01 != -0b01 then + return -1 +endi +sql insert into st_nchar_10 using mt_nchar tags (-0.1e-10) values(now, -0.1e-10) +sql show tags from st_nchar_10 +if $data05 != -0.1e-10 then + return -1 +endi +sql select * from st_nchar_10 +if $data01 != -0.1e-10 then + return -1 +endi +sql insert into st_nchar_11 using mt_nchar tags (+0.1E+2) values(now, +0.1E+2) +sql show tags from st_nchar_11 +if $data05 != +0.1e+2 then + return -1 +endi +sql select * from st_nchar_11 +if $data01 != +0.1e+2 then + return -1 +endi +sql insert into st_nchar_12 using mt_nchar tags (tRue) values(now, tRue) +sql show tags from st_nchar_12 +if $data05 != true then + return -1 +endi +sql select * from st_nchar_12 +if $data01 != true then + return -1 +endi +sql insert into st_nchar_13 using mt_nchar tags (FalsE) values(now, FalsE) +sql show tags from st_nchar_13 +if $data05 != false then + return -1 +endi +sql select * from st_nchar_13 +if $data01 != false then + return -1 +endi +sql insert into st_nchar_14 using mt_nchar tags (noW) values(now, noW) +sql show tags from st_nchar_14 +if $data05 != now then + return -1 +endi +sql select * from st_nchar_14 +if $data01 != now then + return -1 +endi +sql insert into st_nchar_15 using mt_nchar tags (toDay) values(now, toDay) +sql show tags from st_nchar_15 +if $data05 != today then + return -1 +endi +sql select * from st_nchar_15 +if $data01 != today then + return -1 +endi + +## case 03: alter tag values +sql alter table st_nchar_0 set tag tagname=NULL +sql show tags from st_nchar_0 +if $data05 != NULL then + return -1 +endi +sql alter table st_nchar_1 set tag tagname=NULL +sql show tags from st_nchar_1 +if $data05 != NULL then + return -1 +endi +sql alter table st_nchar_2 set tag tagname='NULL' +sql show tags from st_nchar_2 +if $data05 != NULL then + return -1 +endi +sql alter table st_nchar_3 set tag tagname='NULL' +sql show tags from st_nchar_3 +if $data05 != NULL then + return -1 +endi +sql alter table st_nchar_4 set tag tagname="NULL" +sql show tags from st_nchar_4 +if $data05 != NULL then + return -1 +endi +sql alter table st_nchar_5 set tag tagname="NULL" +sql show tags from st_nchar_5 +if $data05 != NULL then + return -1 +endi +sql alter table st_nchar_6 set tag tagname=+0123 +sql show tags from st_nchar_6 +if $data05 != +0123 then + return -1 +endi +sql alter table st_nchar_7 set tag tagname=-01.23 +sql show tags from st_nchar_7 +if $data05 != -01.23 then + return -1 +endi +sql alter table st_nchar_8 set tag tagname=+0x01 +sql show tags from st_nchar_8 +if $data05 != +0x01 then + return -1 +endi +sql alter table st_nchar_9 set tag tagname=-0b01 +sql show tags from st_nchar_9 +if $data05 != -0b01 then + return -1 +endi +sql alter table st_nchar_10 set tag tagname=-0.1e-10 +sql show tags from st_nchar_10 +if $data05 != -0.1e-10 then + return -1 +endi +sql alter table st_nchar_11 set tag tagname=+0.1E+2 +sql show tags from st_nchar_11 +if $data05 != +0.1e+2 then + return -1 +endi +sql alter table st_nchar_12 set tag tagname=tRue +sql show tags from st_nchar_12 +if $data05 != true then + return -1 +endi +sql alter table st_nchar_13 set tag tagname=FalsE +sql show tags from st_nchar_13 +if $data05 != false then + return -1 +endi +sql alter table st_nchar_14 set tag tagname=noW +sql show tags from st_nchar_14 +if $data05 != now then + return -1 +endi +sql alter table st_nchar_15 set tag tagname=toDay +sql show tags from st_nchar_15 +if $data05 != today then + return -1 +endi + + +# case 04: illegal input + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_smallint.sim b/tests/script/tsim/parser/columnValue_smallint.sim index f9be6ebd52..8b9be73ca0 100644 --- a/tests/script/tsim/parser/columnValue_smallint.sim +++ b/tests/script/tsim/parser/columnValue_smallint.sim @@ -31,10 +31,27 @@ if $data05 != NULL then return -1 endi -sql_error create table st_smallint_2 using mt_smallint tags ('NULL') -sql_error create table st_smallint_3 using mt_smallint tags ('NULL') -sql_error create table st_smallint_4 using mt_smallint tags ("NULL") -sql_error create table st_smallint_5 using mt_smallint tags ("NULL") + +sql create table st_smallint_2 using mt_smallint tags ('NULL') +sql show tags from st_smallint_2 +if $data05 != NULL then + return -1 +endi +sql create table st_smallint_3 using mt_smallint tags ('NULL') +sql show tags from st_smallint_3 +if $data05 != NULL then + return -1 +endi +sql create table st_smallint_4 using mt_smallint tags ("NULL") +sql show tags from st_smallint_4 +if $data05 != NULL then + return -1 +endi +sql create table st_smallint_5 using mt_smallint tags ("NULL") +sql show tags from st_smallint_5 +if $data05 != NULL then + return -1 +endi sql create table st_smallint_6 using mt_smallint tags (-32767) sql show tags from st_smallint_6 @@ -349,7 +366,8 @@ sql_error create table st_smallint_e0 using mt_smallint tags ("123abc") sql_error create table st_smallint_e0 using mt_smallint tags (abc) sql_error create table st_smallint_e0 using mt_smallint tags ("abc") sql_error create table st_smallint_e0 using mt_smallint tags (" ") -sql create table st_smallint_e0_1 using mt_smallint tags ('') +sql_error create table st_smallint_e0_1 using mt_smallint tags ('') +sql create table st_smallint_e0_2 using mt_smallint tags ('123') sql create table st_smallint_e0 using mt_smallint tags (123) sql create table st_smallint_e1 using mt_smallint tags (123) @@ -402,7 +420,8 @@ sql_error insert into st_smallint_e20 using mt_smallint tags ("123abc") values ( sql_error insert into st_smallint_e22 using mt_smallint tags (abc) values (now, -033) sql_error insert into st_smallint_e23 using mt_smallint tags ("abc") values (now, -033) sql_error insert into st_smallint_e24 using mt_smallint tags (" ") values (now, -033) -sql insert into st_smallint_e25 using mt_smallint tags ('') values (now, -033) +sql_error insert into st_smallint_e25 using mt_smallint tags ('') values (now, -033) +sql insert into st_smallint_e26 using mt_smallint tags ('123') values (now, -033) sql insert into st_smallint_e13 using mt_smallint tags (033) values (now, 00062) sql insert into st_smallint_e14 using mt_smallint tags (033) values (now, 00062) @@ -427,6 +446,7 @@ sql_error alter table st_smallint_e20 set tag tagname="123abc" sql_error alter table st_smallint_e22 set tag tagname=abc sql_error alter table st_smallint_e23 set tag tagname="abc" sql_error alter table st_smallint_e24 set tag tagname=" " -sql alter table st_smallint_e25 set tag tagname='' +sql_error alter table st_smallint_e25 set tag tagname='' +sql alter table st_smallint_e26 set tag tagname='123' system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_timestamp.sim b/tests/script/tsim/parser/columnValue_timestamp.sim new file mode 100644 index 0000000000..1f457dbd7c --- /dev/null +++ b/tests/script/tsim/parser/columnValue_timestamp.sim @@ -0,0 +1,594 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: timestamp +print ========== timestamp +sql create table mt_timestamp (ts timestamp, c timestamp) tags (tagname timestamp) + +## case 00: static create table for test tag values +sql create table st_timestamp_0 using mt_timestamp tags (NULL) +sql show create table st_timestamp_0 +sql show tags from st_timestamp_0 +if $data05 != NULL then + return -1 +endi +sql create table st_timestamp_1 using mt_timestamp tags (NULL) +sql show tags from st_timestamp_1 +if $data05 != NULL then + return -1 +endi +sql create table st_timestamp_2 using mt_timestamp tags ('NULL') +sql show tags from st_timestamp_2 +if $data05 != NULL then + return -1 +endi +sql create table st_timestamp_3 using mt_timestamp tags ('NULL') +sql show tags from st_timestamp_3 +if $data05 != NULL then + return -1 +endi +sql create table st_timestamp_4 using mt_timestamp tags ("NULL") +sql show tags from st_timestamp_4 +if $data05 != NULL then + return -1 +endi +sql create table st_timestamp_5 using mt_timestamp tags ("NULL") +sql show tags from st_timestamp_5 +if $data05 != NULL then + return -1 +endi +sql create table st_timestamp_6 using mt_timestamp tags (-2147483647) +sql show tags from st_timestamp_6 +if $data05 != -2147483647 then + return -1 +endi +sql create table st_timestamp_7 using mt_timestamp tags (2147483647) +sql show tags from st_timestamp_7 +if $data05 != 2147483647 then + return -1 +endi +sql create table st_timestamp_8 using mt_timestamp tags (37) +sql show tags from st_timestamp_8 +if $data05 != 37 then + return -1 +endi +sql create table st_timestamp_9 using mt_timestamp tags (-100) +sql show tags from st_timestamp_9 +if $data05 != -100 then + return -1 +endi +sql create table st_timestamp_10 using mt_timestamp tags (+113) +sql show tags from st_timestamp_10 +if $data05 != 113 then + return -1 +endi +sql create table st_timestamp_11 using mt_timestamp tags ('-100') +sql show tags from st_timestamp_11 +if $data05 != -100 then + return -1 +endi +sql create table st_timestamp_12 using mt_timestamp tags ("-0") +sql show tags from st_timestamp_12 +if $data05 != 0 then + return -1 +endi +sql create table st_timestamp_13 using mt_timestamp tags (+0078) +sql show tags from st_timestamp_13 +if $data05 != 78 then + return -1 +endi +sql create table st_timestamp_14 using mt_timestamp tags (-00078) +sql show tags from st_timestamp_14 +if $data05 != -78 then + return -1 +endi +sql create table st_timestamp_15 using mt_timestamp tags ("0x01") +sql show tags from st_timestamp_15 +if $data05 != 1 then + return -1 +endi +sql create table st_timestamp_16 using mt_timestamp tags ("0b01") +sql show tags from st_timestamp_16 +if $data05 != 1 then + return -1 +endi +sql create table st_timestamp_17 using mt_timestamp tags ("+0x01") +sql show tags from st_timestamp_17 +if $data05 != 1 then + return -1 +endi +sql create table st_timestamp_18 using mt_timestamp tags ("-0b01") +sql show tags from st_timestamp_18 +if $data05 != -1 then + return -1 +endi +sql create table st_timestamp_19 using mt_timestamp tags ( 0x01) +sql show tags from st_timestamp_19 +if $data05 != 1 then + return -1 +endi +sql create table st_timestamp_20 using mt_timestamp tags (0b01 ) +sql show tags from st_timestamp_20 +if $data05 != 1 then + return -1 +endi +sql create table st_timestamp_21 using mt_timestamp tags (+0x01) +sql show tags from st_timestamp_21 +if $data05 != 1 then + return -1 +endi +sql create table st_timestamp_22 using mt_timestamp tags ( -0b01 ) +sql show tags from st_timestamp_22 +if $data05 != -1 then + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_timestamp_0 values(now,NULL) +sql select * from st_timestamp_0 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_1 values(now,NULL) +sql select * from st_timestamp_1 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_2 values(now,'NULL') +sql select * from st_timestamp_2 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_3 values(now,'NULL') +sql select * from st_timestamp_3 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_4 values(now,"NULL") +sql select * from st_timestamp_4 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_5 values(now,"NULL") +sql select * from st_timestamp_5 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_6 values(now,-2147483647) +sql select ts, cast(c as bigint) from st_timestamp_6 +if $data01 != -2147483647 then + return -1 +endi +sql insert into st_timestamp_7 values(now,2147483647) +sql select ts, cast(c as bigint) from st_timestamp_7 +if $data01 != 2147483647 then + return -1 +endi +sql insert into st_timestamp_8 values(now,37) +sql select ts, cast(c as bigint) from st_timestamp_8 +if $data01 != 37 then + return -1 +endi +sql insert into st_timestamp_9 values(now,-100) +sql select ts, cast(c as bigint) from st_timestamp_9 +if $data01 != -100 then + return -1 +endi +sql insert into st_timestamp_10 values(now,+113) +sql select ts, cast(c as bigint) from st_timestamp_10 +if $data01 != 113 then + return -1 +endi +sql insert into st_timestamp_11 values(now,'-100') +sql select ts, cast(c as bigint) from st_timestamp_11 +if $data01 != -100 then + return -1 +endi +sql insert into st_timestamp_12 values(now,"-0") +sql select ts, cast(c as bigint) from st_timestamp_12 +if $data01 != 0 then + return -1 +endi +sql insert into st_timestamp_13 values(now,+0078) +sql select ts, cast(c as bigint) from st_timestamp_13 +if $data01 != 78 then + return -1 +endi +sql insert into st_timestamp_14 values(now,-00078) +sql select ts, cast(c as bigint) from st_timestamp_14 +if $data01 != -78 then + return -1 +endi +sql insert into st_timestamp_15 values(now,"0x01") +sql select ts, cast(c as bigint) from st_timestamp_15 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_16 values(now,"0b01") +sql select ts, cast(c as bigint) from st_timestamp_16 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_17 values(now,"+0x01") +sql select ts, cast(c as bigint) from st_timestamp_17 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_18 values(now,"-0b01") +sql select ts, cast(c as bigint) from st_timestamp_18 +if $data01 != -1 then + return -1 +endi +sql insert into st_timestamp_19 values(now, 0x01) +sql select ts, cast(c as bigint) from st_timestamp_19 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_20 values(now,0b01 ) +sql select ts, cast(c as bigint) from st_timestamp_20 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_21 values(now,+0x01) +sql select ts, cast(c as bigint) from st_timestamp_21 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_22 values(now, -0b01 ) +sql select ts, cast(c as bigint) from st_timestamp_22 +if $data01 != -1 then + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_timestamp_100 using mt_timestamp tags(NULL) values(now, NULL) +sql show tags from st_timestamp_100 +if $data05 != NULL then + return -1 +endi +sql select * from st_timestamp_100 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_101 using mt_timestamp tags(NULL) values(now, NULL) +sql show tags from st_timestamp_101 +if $data05 != NULL then + return -1 +endi +sql select * from st_timestamp_101 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_102 using mt_timestamp tags('NULL') values(now, 'NULL') +sql show tags from st_timestamp_102 +if $data05 != NULL then + return -1 +endi +sql select * from st_timestamp_102 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_103 using mt_timestamp tags('NULL') values(now, 'NULL') +sql show tags from st_timestamp_103 +if $data05 != NULL then + return -1 +endi +sql select * from st_timestamp_103 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_104 using mt_timestamp tags("NULL") values(now, "NULL") +sql show tags from st_timestamp_104 +if $data05 != NULL then + return -1 +endi +sql select * from st_timestamp_104 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_105 using mt_timestamp tags("NULL") values(now, "NULL") +sql show tags from st_timestamp_105 +if $data05 != NULL then + return -1 +endi +sql select * from st_timestamp_105 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_106 using mt_timestamp tags(-2147483647) values(now, -2147483647) +sql show tags from st_timestamp_106 +if $data05 != -2147483647 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_106 +if $data01 != -2147483647 then + return -1 +endi +sql insert into st_timestamp_107 using mt_timestamp tags(2147483647) values(now, 2147483647) +sql show tags from st_timestamp_107 +if $data05 != 2147483647 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_107 +if $data01 != 2147483647 then + return -1 +endi +sql insert into st_timestamp_108 using mt_timestamp tags(37) values(now, 37) +sql show tags from st_timestamp_108 +if $data05 != 37 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_108 +if $data01 != 37 then + return -1 +endi +sql insert into st_timestamp_109 using mt_timestamp tags(-100) values(now, -100) +sql show tags from st_timestamp_109 +if $data05 != -100 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_109 +if $data01 != -100 then + return -1 +endi +sql insert into st_timestamp_1010 using mt_timestamp tags(+113) values(now, +113) +sql show tags from st_timestamp_1010 +if $data05 != 113 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1010 +if $data01 != 113 then + return -1 +endi +sql insert into st_timestamp_1011 using mt_timestamp tags('-100') values(now, '-100') +sql show tags from st_timestamp_1011 +if $data05 != -100 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1011 +if $data01 != -100 then + return -1 +endi +sql insert into st_timestamp_1012 using mt_timestamp tags("-0") values(now, "-0") +sql show tags from st_timestamp_1012 +if $data05 != 0 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1012 +if $data01 != 0 then + return -1 +endi +sql insert into st_timestamp_1013 using mt_timestamp tags(+0078) values(now, +0078) +sql show tags from st_timestamp_1013 +if $data05 != 78 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1013 +if $data01 != 78 then + return -1 +endi +sql insert into st_timestamp_1014 using mt_timestamp tags(-00078) values(now, -00078) +sql show tags from st_timestamp_1014 +if $data05 != -78 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1014 +if $data01 != -78 then + return -1 +endi +sql insert into st_timestamp_1015 using mt_timestamp tags("0x01") values(now, "0x01") +sql show tags from st_timestamp_1015 +if $data05 != 1 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1015 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_1016 using mt_timestamp tags("0b01") values(now, "0b01") +sql show tags from st_timestamp_1016 +if $data05 != 1 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1016 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_1017 using mt_timestamp tags("+0x01") values(now, "+0x01") +sql show tags from st_timestamp_1017 +if $data05 != 1 then + return -1 +endi +sql insert into st_timestamp_1018 using mt_timestamp tags("-0b01") values(now, "-0b01") +sql show tags from st_timestamp_1018 +if $data05 != -1 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1018 +if $data01 != -1 then + return -1 +endi +sql insert into st_timestamp_1019 using mt_timestamp tags( 0x01) values(now, 0x01) +sql show tags from st_timestamp_1019 +if $data05 != 1 then + return -1 +endi +sql insert into st_timestamp_1020 using mt_timestamp tags(0b01 ) values(now, 0b01 ) +sql show tags from st_timestamp_1020 +if $data05 != 1 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1020 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_1021 using mt_timestamp tags(+0x01) values(now, +0x01) +sql show tags from st_timestamp_1021 +if $data05 != 1 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1021 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_1022 using mt_timestamp tags( -0b01 ) values(now, -0b01) +sql show tags from st_timestamp_1022 +if $data05 != -1 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1022 +if $data01 != -1 then + return -1 +endi + +### case 03: alter tag values +sql alter table st_timestamp_0 set tag tagname=NULL +sql show tags from st_timestamp_0 +if $data05 != NULL then + return -1 +endi +sql alter table st_timestamp_1 set tag tagname=NULL +sql show tags from st_timestamp_1 +if $data05 != NULL then + return -1 +endi +sql alter table st_timestamp_2 set tag tagname='NULL' +sql show tags from st_timestamp_2 +if $data05 != NULL then + return -1 +endi +sql alter table st_timestamp_3 set tag tagname='NULL' +sql show tags from st_timestamp_3 +if $data05 != NULL then + return -1 +endi +sql alter table st_timestamp_4 set tag tagname="NULL" +sql show tags from st_timestamp_4 +if $data05 != NULL then + return -1 +endi +sql alter table st_timestamp_5 set tag tagname="NULL" +sql show tags from st_timestamp_5 +if $data05 != NULL then + return -1 +endi +sql alter table st_timestamp_6 set tag tagname=-2147483647 +sql show tags from st_timestamp_6 +if $data05 != -2147483647 then + return -1 +endi +sql alter table st_timestamp_7 set tag tagname=2147483647 +sql show tags from st_timestamp_7 +if $data05 != 2147483647 then + return -1 +endi +sql alter table st_timestamp_8 set tag tagname=37 +sql show tags from st_timestamp_8 +if $data05 != 37 then + return -1 +endi +sql alter table st_timestamp_9 set tag tagname=-100 +sql show tags from st_timestamp_9 +if $data05 != -100 then + return -1 +endi +sql alter table st_timestamp_10 set tag tagname=+113 +sql show tags from st_timestamp_10 +if $data05 != 113 then + return -1 +endi +sql alter table st_timestamp_11 set tag tagname='-100' +sql show tags from st_timestamp_11 +if $data05 != -100 then + return -1 +endi +sql alter table st_timestamp_12 set tag tagname="-0" +sql show tags from st_timestamp_12 +if $data05 != 0 then + return -1 +endi +sql alter table st_timestamp_13 set tag tagname=+0078 +sql show tags from st_timestamp_13 +if $data05 != 78 then + return -1 +endi +sql alter table st_timestamp_14 set tag tagname=-00078 +sql show tags from st_timestamp_14 +if $data05 != -78 then + return -1 +endi +sql alter table st_timestamp_15 set tag tagname="0x01" +sql show tags from st_timestamp_15 +if $data05 != 1 then + return -1 +endi +sql alter table st_timestamp_16 set tag tagname="0b01" +sql show tags from st_timestamp_16 +if $data05 != 1 then + return -1 +endi +sql alter table st_timestamp_17 set tag tagname="+0x01" +sql show tags from st_timestamp_17 +if $data05 != 1 then + return -1 +endi +sql alter table st_timestamp_18 set tag tagname="-0b01" +sql show tags from st_timestamp_18 +if $data05 != -1 then + return -1 +endi +sql alter table st_timestamp_19 set tag tagname= 0x01 +sql show tags from st_timestamp_19 +if $data05 != 1 then + return -1 +endi +sql alter table st_timestamp_20 set tag tagname=0b01 +sql show tags from st_timestamp_20 +if $data05 != 1 then + return -1 +endi +sql alter table st_timestamp_21 set tag tagname=+0x01 +sql show tags from st_timestamp_21 +if $data05 != 1 then + return -1 +endi +sql alter table st_timestamp_22 set tag tagname= -0b01 +sql show tags from st_timestamp_22 +if $data05 != -1 then + return -1 +endi + +## case 04: illegal input +sql_error create table st_timestamp_e0 using mt_timestamp tags (123abc) +sql_error create table st_timestamp_e0 using mt_timestamp tags ("123abc") +sql_error create table st_timestamp_e0 using mt_timestamp tags (abc) +sql_error create table st_timestamp_e0 using mt_timestamp tags ("abc") +sql_error create table st_timestamp_e0 using mt_timestamp tags (" ") +sql_error create table st_timestamp_e0 using mt_timestamp tags ('') +sql_error create table st_timestamp_104 using mt_timestamp tags ("-123.1") +sql_error create table st_timestamp_105 using mt_timestamp tags ("+123.5") +sql_error create table st_timestamp_106 using mt_timestamp tags ("-1e-1") +sql_error create table st_timestamp_107 using mt_timestamp tags ("+0.1235e3") +sql_error create table st_timestamp_108 using mt_timestamp tags ("-0.11e-30") +sql_error create table st_timestamp_109 using mt_timestamp tags ("-1.1e-307") +sql_error create table st_timestamp_110 using mt_timestamp tags ( -1e-1 ) +sql_error create table st_timestamp_111 using mt_timestamp tags ( +0.1235e3 ) +sql_error create table st_timestamp_112 using mt_timestamp tags (-0.11e-30) +sql_error create table st_timestamp_113 using mt_timestamp tags (-1.1e-307) +sql create table st_timestamp_114 using mt_timestamp tags (9223372036854775807) +sql_error create table st_timestamp_115 using mt_timestamp tags (9223372036854775808) +sql create table st_timestamp_116 using mt_timestamp tags (-9223372036854775808) +sql_error create table st_timestamp_117 using mt_timestamp tags (-9223372036854775809) +sql_error insert into st_timestamp_118 using mt_timestamp tags(9223372036854775807) values(9223372036854775807, 9223372036854775807) + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_tinyint.sim b/tests/script/tsim/parser/columnValue_tinyint.sim index 7d0f10a30d..5076280872 100644 --- a/tests/script/tsim/parser/columnValue_tinyint.sim +++ b/tests/script/tsim/parser/columnValue_tinyint.sim @@ -29,10 +29,26 @@ if $data05 != NULL then return -1 endi -sql_error create table st_tinyint_2 using mt_tinyint tags ('NULL') -sql_error create table st_tinyint_3 using mt_tinyint tags ('NULL') -sql_error create table st_tinyint_4 using mt_tinyint tags ("NULL") -sql_error create table st_tinyint_5 using mt_tinyint tags ("NULL") +sql create table st_tinyint_2 using mt_tinyint tags ('NULL') +sql show tags from st_tinyint_2 +if $data05 != NULL then + return -1 +endi +sql create table st_tinyint_3 using mt_tinyint tags ('NULL') +sql show tags from st_tinyint_3 +if $data05 != NULL then + return -1 +endi +sql create table st_tinyint_4 using mt_tinyint tags ("NULL") +sql show tags from st_tinyint_4 +if $data05 != NULL then + return -1 +endi +sql create table st_tinyint_5 using mt_tinyint tags ("NULL") +sql show tags from st_tinyint_5 +if $data05 != NULL then + return -1 +endi sql create table st_tinyint_6 using mt_tinyint tags (-127) sql show tags from st_tinyint_6 @@ -97,6 +113,40 @@ endi if $data01 != NULL then return -1 endi + +sql insert into st_tinyint_2 values (now, NULL) +sql select * from st_tinyint_2 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_3 values (now, NULL) +sql select * from st_tinyint_3 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_4 values (now, NULL) +sql select * from st_tinyint_4 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_5 values (now, NULL) +sql select * from st_tinyint_5 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + sql insert into st_tinyint_6 values (now, 127) sql select * from st_tinyint_6 if $rows != 1 then @@ -347,7 +397,7 @@ sql_error create table st_tinyint_e0 using mt_tinyint tags ("123abc") sql_error create table st_tinyint_e0 using mt_tinyint tags (abc) sql_error create table st_tinyint_e0 using mt_tinyint tags ("abc") sql_error create table st_tinyint_e0 using mt_tinyint tags (" ") -sql create table st_tinyint_e0_2 using mt_tinyint tags ('') +sql_error create table st_tinyint_e0_2 using mt_tinyint tags ('') sql create table st_tinyint_e0 using mt_tinyint tags (123) sql create table st_tinyint_e1 using mt_tinyint tags (123) @@ -400,7 +450,7 @@ sql_error insert into st_tinyint_e20 using mt_tinyint tags ("123abc") values (no sql_error insert into st_tinyint_e22 using mt_tinyint tags (abc) values (now, -033) sql_error insert into st_tinyint_e23 using mt_tinyint tags ("abc") values (now, -033) sql_error insert into st_tinyint_e24 using mt_tinyint tags (" ") values (now, -033) -sql insert into st_tinyint_e25 using mt_tinyint tags ('') values (now, -033) +sql_error insert into st_tinyint_e25 using mt_tinyint tags ('') values (now, -033) sql insert into st_tinyint_e13 using mt_tinyint tags (033) values (now, 00062) sql insert into st_tinyint_e14 using mt_tinyint tags (033) values (now, 00062) @@ -425,6 +475,6 @@ sql_error alter table st_tinyint_e20 set tag tagname="123abc" sql_error alter table st_tinyint_e22 set tag tagname=abc sql_error alter table st_tinyint_e23 set tag tagname="abc" sql_error alter table st_tinyint_e24 set tag tagname=" " -sql alter table st_tinyint_e25 set tag tagname='' +sql_error alter table st_tinyint_e25 set tag tagname='' system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_uint.sim b/tests/script/tsim/parser/columnValue_uint.sim new file mode 100644 index 0000000000..a2707bbf17 --- /dev/null +++ b/tests/script/tsim/parser/columnValue_uint.sim @@ -0,0 +1,904 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: uint +print ========== uint +sql create table mt_uint (ts timestamp, c int unsigned) tags (tagname int unsigned) + +## case 00: static create table for test tag values +sql create table st_uint_0 using mt_uint tags (NULL) +sql show create table st_uint_0 +sql show tags from st_uint_0 +if $data05 != NULL then + return -1 +endi +sql create table st_uint_1 using mt_uint tags (NULL) +sql show tags from st_uint_1 +if $data05 != NULL then + return -1 +endi + +sql create table st_uint_2 using mt_uint tags ('NULL') +sql show tags from st_uint_2 +if $data05 != NULL then + return -1 +endi +sql create table st_uint_3 using mt_uint tags ('NULL') +sql show tags from st_uint_3 +if $data05 != NULL then + return -1 +endi +sql create table st_uint_4 using mt_uint tags ("NULL") +sql show tags from st_uint_4 +if $data05 != NULL then + return -1 +endi +sql create table st_uint_5 using mt_uint tags ("-0") +sql show tags from st_uint_5 +if $data05 != 0 then + return -1 +endi +sql create table st_uint_6 using mt_uint tags (-0 ) +sql show tags from st_uint_6 +if $data05 != 0 then + return -1 +endi +sql create table st_uint_7 using mt_uint tags (2147483647) +sql show tags from st_uint_7 +if $data05 != 2147483647 then + return -1 +endi +sql create table st_uint_8 using mt_uint tags (37) +sql show tags from st_uint_8 +if $data05 != 37 then + return -1 +endi +sql create table st_uint_9 using mt_uint tags (098) +sql show tags from st_uint_9 +if $data05 != 98 then + return -1 +endi +sql create table st_uint_10 using mt_uint tags (+113) +sql show tags from st_uint_10 +if $data05 != 113 then + return -1 +endi +sql create table st_uint_11 using mt_uint tags (+000.000) +sql show tags from st_uint_11 +if $data05 != 0 then + return -1 +endi +sql create table st_uint_12 using mt_uint tags ("+78") +sql show tags from st_uint_12 +if $data05 != 78 then + return -1 +endi +sql create table st_uint_13 using mt_uint tags (+0078) +sql show tags from st_uint_13 +if $data05 != 78 then + return -1 +endi +sql create table st_uint_14 using mt_uint tags (00078) +sql show tags from st_uint_14 +if $data05 != 78 then + return -1 +endi +sql create table st_uint_100 using mt_uint tags ("0x01") +sql show tags from st_uint_100 +if $data05 != 1 then + return -1 +endi +sql create table st_uint_101 using mt_uint tags ("0b01") +sql show tags from st_uint_101 +if $data05 != 1 then + return -1 +endi +sql create table st_uint_102 using mt_uint tags ("+0x01") +sql show tags from st_uint_102 +if $data05 != 1 then + return -1 +endi +sql create table st_uint_103 using mt_uint tags ("-0b00") +sql show tags from st_uint_103 +if $data05 != 0 then + return -1 +endi +sql create table st_uint_104 using mt_uint tags ("123.1") +sql show tags from st_uint_104 +if $data05 != 123 then + return -1 +endi +sql create table st_uint_105 using mt_uint tags ("+123.5") +sql show tags from st_uint_105 +if $data05 != 124 then + return -1 +endi +sql create table st_uint_106 using mt_uint tags ("-1e-1") +sql show tags from st_uint_106 +if $data05 != 0 then + return -1 +endi +sql create table st_uint_107 using mt_uint tags ("+0.1235e3") +sql show tags from st_uint_107 +if $data05 != 124 then + print $data05 != 124 + return -1 +endi +sql create table st_uint_108 using mt_uint tags ("-0.11e-30") +sql show tags from st_uint_108 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql create table st_uint_109 using mt_uint tags ("-1.1e-307") +sql show tags from st_uint_109 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql create table st_uint_110 using mt_uint tags ( -1e-1 ) +sql show tags from st_uint_110 +if $data05 != 0 then + return -1 +endi +sql create table st_uint_111 using mt_uint tags ( +0.1235e3 ) +sql show tags from st_uint_111 +if $data05 != 124 then + print $data05 != 124 + return -1 +endi +sql create table st_uint_112 using mt_uint tags (-0.11e-30) +sql show tags from st_uint_112 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql create table st_uint_113 using mt_uint tags (-1.1e-307) +sql show tags from st_uint_113 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql create table st_uint_200 using mt_uint tags ( 0x01) +sql show tags from st_uint_200 +if $data05 != 1 then + return -1 +endi +sql create table st_uint_201 using mt_uint tags (0b01 ) +sql show tags from st_uint_201 +if $data05 != 1 then + return -1 +endi +sql create table st_uint_202 using mt_uint tags (+0x01) +sql show tags from st_uint_202 +if $data05 != 1 then + return -1 +endi +sql create table st_uint_203 using mt_uint tags ( -0b00 ) +sql show tags from st_uint_203 +if $data05 != 0 then + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_uint_0 values (now, NULL) +sql select * from st_uint_0 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_uint_1 values (now, "-0") +sql select * from st_uint_1 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_6 values (now, 2147483647) +sql select * from st_uint_6 +if $rows != 1 then + return -1 +endi +if $data01 != 2147483647 then + return -1 +endi +sql insert into st_uint_7 values (now, -0) +sql select * from st_uint_7 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_8 values (now, +100) +sql select * from st_uint_8 +if $rows != 1 then + return -1 +endi +if $data01 != 100 then + return -1 +endi +sql insert into st_uint_9 values (now, "098") +sql select * from st_uint_9 +if $rows != 1 then + return -1 +endi +if $data01 != 98 then + return -1 +endi +sql insert into st_uint_10 values (now, '0') +sql select * from st_uint_10 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_11 values (now, +000.000) +sql select * from st_uint_11 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_12 values (now, "+056") +sql select * from st_uint_12 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_uint_13 values (now, +056) +sql select * from st_uint_13 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_uint_14 values (now, 056) +sql select * from st_uint_14 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_uint_100 values (now, "0x01") +sql select * from st_uint_100 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_101 values (now, "0b01") +sql select * from st_uint_101 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_102 values (now, "+0x01") +sql select * from st_uint_102 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_103 values (now, "-0b00") +sql select * from st_uint_103 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_104 values (now, "123.1") +sql select * from st_uint_104 +if $data01 != 123 then + return -1 +endi +sql insert into st_uint_105 values (now, "+123.5") +sql select * from st_uint_105 +if $data01 != 124 then + return -1 +endi +sql insert into st_uint_106 values (now, "-1e-1") +sql select * from st_uint_106 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_107 values (now, "+0.1235e3") +sql select * from st_uint_107 +if $data01 != 124 then + print $data05 != 124 + return -1 +endi +sql insert into st_uint_108 values (now, "-0.11e-30") +sql select * from st_uint_108 +if $data01 != 0 then + print $data05 != 0 + return -1 +endi +sql insert into st_uint_109 values (now, "-1.1e-307") +sql select * from st_uint_109 +if $data01 != 0 then + print $data05 != 0 + return -1 +endi +sql insert into st_uint_110 values (now, -1e-1 ) +sql select * from st_uint_110 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_111 values (now, +0.1235e3 ) +sql select * from st_uint_111 +if $data01 != 124 then + print $data05 != 124 + return -1 +endi +sql insert into st_uint_112 values (now, -0.11e-30) +sql select * from st_uint_112 +if $data01 != 0 then + print $data05 != 0 + return -1 +endi +sql insert into st_uint_113 values (now, -1.1e-307) +sql select * from st_uint_113 +if $data01 != 0 then + print $data05 != 0 + return -1 +endi +sql insert into st_uint_200 values (now, 0x01) +sql select * from st_uint_200 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_201 values (now, 0b01 ) +sql select * from st_uint_201 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_202 values (now, +0x01) +sql select * from st_uint_202 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql insert into st_uint_203 values (now, -0b00 ) +sql select * from st_uint_203 +if $data01 != 0 then + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_uint_16 using mt_uint tags (NULL) values (now, NULL) +sql show create table st_uint_16 +sql show tags from st_uint_16 +if $data05 != NULL then + return -1 +endi +sql select * from st_uint_16 +if $data01 != NULL then + return -1 +endi + +sql insert into st_uint_17 using mt_uint tags (NULL) values (now, NULL) +sql show tags from st_uint_17 +if $data05 != NULL then + return -1 +endi +sql select * from st_uint_17 +if $data01 != NULL then + return -1 +endi +sql insert into st_uint_18 using mt_uint tags ('NULL') values (now, 'NULL') +sql show tags from st_uint_18 +if $data05 != NULL then + return -1 +endi +sql select * from st_uint_18 +if $data01 != NULL then + return -1 +endi +sql insert into st_uint_19 using mt_uint tags ('NULL') values (now, 'NULL') +sql show tags from st_uint_19 +if $data05 != NULL then + return -1 +endi +sql select * from st_uint_19 +if $data01 != NULL then + return -1 +endi +sql insert into st_uint_20 using mt_uint tags ("NULL") values (now, "NULL") +sql show tags from st_uint_20 +if $data05 != NULL then + return -1 +endi +sql select * from st_uint_20 +if $data01 != NULL then + return -1 +endi +sql insert into st_uint_21 using mt_uint tags ("-0") values (now, "-0") +sql show tags from st_uint_21 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_21 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_22 using mt_uint tags (2147483647) values (now, 2147483647) +sql show tags from st_uint_22 +if $data05 != 2147483647 then + return -1 +endi +sql select * from st_uint_22 +if $data01 != 2147483647 then + return -1 +endi +sql insert into st_uint_23 using mt_uint tags (-0) values (now, -0) +sql show tags from st_uint_23 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_23 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_24 using mt_uint tags (10) values (now, 10) +sql show tags from st_uint_24 +if $data05 != 10 then + return -1 +endi +sql select * from st_uint_24 +if $data01 != 10 then + return -1 +endi +sql insert into st_uint_25 using mt_uint tags ("-0") values (now, "-0") +sql show tags from st_uint_25 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_25 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_26 using mt_uint tags ('123') values (now, '123') +sql show tags from st_uint_26 +if $data05 != 123 then + return -1 +endi +sql select * from st_uint_26 +if $data01 != 123 then + return -1 +endi +sql insert into st_uint_27 using mt_uint tags (+056) values (now, +00056) +sql show tags from st_uint_27 +if $data05 != 56 then + return -1 +endi +sql select * from st_uint_27 +if $data01 != 56 then + return -1 +endi +sql insert into st_uint_28 using mt_uint tags (056) values (now, 0056) +sql show tags from st_uint_28 +if $data05 != 56 then + return -1 +endi +sql select * from st_uint_28 +if $data01 != 56 then + return -1 +endi +sql insert into st_uint_1100 using mt_uint tags ("0x01") values(now, "0x01"); +sql show tags from st_uint_1100 +if $data05 != 1 then + return -1 +endi +sql select * from st_uint_1100 +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_1101 using mt_uint tags ("0b01") values(now, "0b01"); +sql show tags from st_uint_1101 +if $data05 != 1 then + return -1 +endi +sql select * from st_uint_1101 +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_1102 using mt_uint tags ("+0x01") values(now, "+0x01"); +sql show tags from st_uint_1102 +if $data05 != 1 then + return -1 +endi +sql select * from st_uint_1102 +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_1103 using mt_uint tags ("-0b00") values(now, "-0b000"); +sql show tags from st_uint_1103 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_1103 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_1104 using mt_uint tags ("123.1") values(now, "123.1"); +sql show tags from st_uint_1104 +if $data05 != 123 then + return -1 +endi +sql select * from st_uint_1104 +if $data01 != 123 then + return -1 +endi +sql insert into st_uint_1105 using mt_uint tags ("+123.5") values(now, "+123.5"); +sql show tags from st_uint_1105 +if $data05 != 124 then + return -1 +endi +sql select * from st_uint_1105 +if $data01 != 124 then + return -1 +endi +sql insert into st_uint_1106 using mt_uint tags ("-1e-1") values(now, "-1e-1"); +sql show tags from st_uint_1106 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_1106 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_1107 using mt_uint tags ("+0.1235e3") values(now, "+0.1235e3"); +sql show tags from st_uint_1107 +if $data05 != 124 then + return -1 +endi +sql insert into st_uint_1108 using mt_uint tags ("-0.11e-30") values(now, "-0.11e-30"); +sql show tags from st_uint_1108 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_1108 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_1109 using mt_uint tags ("-1.1e-307") values(now, "-1.1e-307"); +sql show tags from st_uint_1109 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_1109 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_1110 using mt_uint tags ( -1e-1 ) values(now, -1e-1); +sql show tags from st_uint_1110 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_1110 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_1111 using mt_uint tags ( +0.1235e3 ) values(now, +0.1235e3); +sql show tags from st_uint_1111 +if $data05 != 124 then + return -1 +endi +sql select * from st_uint_1111 +if $data01 != 124 then + return -1 +endi +sql insert into st_uint_1112 using mt_uint tags (-0.11e-30) values(now, -0.11e-30); +sql show tags from st_uint_1112 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_1112 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_1113 using mt_uint tags (-1.1e-307) values(now, -1.1e-307); +sql show tags from st_uint_1113 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_1113 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_1200 using mt_uint tags ( 0x01) values(now, 0x01); +sql show tags from st_uint_1200 +if $data05 != 1 then + return -1 +endi +sql select * from st_uint_1200 +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_1201 using mt_uint tags (0b01 ) values(now, 0b01); +sql show tags from st_uint_1201 +if $data05 != 1 then + return -1 +endi +sql select * from st_uint_1201 +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_1202 using mt_uint tags (+0x01) values(now, +0x01); +sql show tags from st_uint_1202 +if $data05 != 1 then + return -1 +endi +sql select * from st_uint_1202 +if $data01 != 1 then + return -1 +endi + +sql insert into st_uint_1203 using mt_uint tags ( 0b000000 ) values(now, -0b0000); +sql show tags from st_uint_1203 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_1203 +if $data01 != 0 then + return -1 +endi + +### case 03: alter tag values +sql alter table st_uint_0 set tag tagname=2147483647 +sql show tags from st_uint_0 +if $data05 != 2147483647 then + return -1 +endi +sql alter table st_uint_0 set tag tagname=-0 +sql show tags from st_uint_0 +if $data05 != 0 then + return -1 +endi +sql alter table st_uint_0 set tag tagname=+100 +sql show tags from st_uint_0 +if $data05 != 100 then + return -1 +endi +sql alter table st_uint_0 set tag tagname=+33.333 +sql show tags from st_uint_0 +if $data05 != 33 then + return -1 +endi +sql alter table st_uint_0 set tag tagname='+98' +sql show tags from st_uint_0 +if $data05 != 98 then + return -1 +endi +sql alter table st_uint_0 set tag tagname='076' +sql show tags from st_uint_0 +if $data05 != 76 then + return -1 +endi +sql alter table st_uint_0 set tag tagname=+0012 +sql show tags from st_uint_0 +if $data05 != 12 then + return -1 +endi +sql alter table st_uint_0 set tag tagname=00063 +sql show tags from st_uint_0 +if $data05 != 63 then + return -1 +endi +sql alter table st_uint_100 set tag tagname="0x01" +sql show tags from st_uint_100 +if $data05 != 1 then + return -1 +endi +sql alter table st_uint_101 set tag tagname="0b01" +sql show tags from st_uint_101 +if $data05 != 1 then + return -1 +endi +sql alter table st_uint_102 set tag tagname="+0x01" +sql show tags from st_uint_102 +if $data05 != 1 then + return -1 +endi +sql alter table st_uint_103 set tag tagname="-0b00" +sql show tags from st_uint_103 +if $data05 != 0 then + return -1 +endi +sql alter table st_uint_104 set tag tagname="123.1" +sql show tags from st_uint_104 +if $data05 != 123 then + return -1 +endi +sql alter table st_uint_105 set tag tagname="+123.5" +sql show tags from st_uint_105 +if $data05 != 124 then + return -1 +endi +sql alter table st_uint_106 set tag tagname="-1e-1" +sql show tags from st_uint_106 +if $data05 != 0 then + return -1 +endi +sql alter table st_uint_107 set tag tagname="+0.1235e3" +sql show tags from st_uint_107 +if $data05 != 124 then + print $data05 != 124 + return -1 +endi +sql alter table st_uint_108 set tag tagname="-0.11e-30" +sql show tags from st_uint_108 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql alter table st_uint_109 set tag tagname="-1.1e-307" +sql show tags from st_uint_109 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql alter table st_uint_110 set tag tagname= -1e-1 +sql show tags from st_uint_110 +if $data05 != 0 then + return -1 +endi +sql alter table st_uint_111 set tag tagname= +0.1235e3 +sql show tags from st_uint_111 +if $data05 != 124 then + print $data05 != 124 + return -1 +endi +sql alter table st_uint_112 set tag tagname=-0.11e-30 +sql show tags from st_uint_112 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql alter table st_uint_113 set tag tagname=-1.1e-307 +sql show tags from st_uint_113 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql alter table st_uint_200 set tag tagname= 0x01 +sql show tags from st_uint_200 +if $data05 != 1 then + return -1 +endi +sql alter table st_uint_201 set tag tagname=0b00 +sql show tags from st_uint_201 +if $data05 != 0 then + return -1 +endi +sql alter table st_uint_202 set tag tagname=+0x01 +sql show tags from st_uint_202 +if $data05 != 1 then + return -1 +endi +sql alter table st_uint_203 set tag tagname= -0b0 +sql show tags from st_uint_203 +if $data05 != 0 then + return -1 +endi + +## case 04: illegal input +sql_error create table st_uint_e0_err0 using mt_uint tags (4294967296) +sql_error create table st_uint_e0_err1 using mt_uint tags (-4294967297) +sql_error create table st_uint_e0_err2 using mt_uint tags (-214748364800) +sql_error create table st_uint_e0_err3 using mt_uint tags (123abc) +sql_error create table st_uint_e0_err4 using mt_uint tags ("123abc") +sql_error create table st_uint_e0_err5 using mt_uint tags (abc) +sql_error create table st_uint_e0_err6 using mt_uint tags ("abc") +sql_error create table st_uint_e0_err7 using mt_uint tags (" ") +sql_error create table st_uint_e0_err8 using mt_uint tags ('') + +sql create table st_uint_e0 using mt_uint tags (123) +sql create table st_uint_e1 using mt_uint tags (123) +sql create table st_uint_e2 using mt_uint tags (123) +sql create table st_uint_e3 using mt_uint tags (123) +sql create table st_uint_e4 using mt_uint tags (123) +sql create table st_uint_e5 using mt_uint tags (123) +sql create table st_uint_e6 using mt_uint tags (123) +sql create table st_uint_e7 using mt_uint tags (123) +sql create table st_uint_e8 using mt_uint tags (123) +sql create table st_uint_e9 using mt_uint tags (123) +sql create table st_uint_e10 using mt_uint tags (123) +sql create table st_uint_e11 using mt_uint tags (123) +sql create table st_uint_e12 using mt_uint tags (123) + +sql_error insert into st_uint_e0 values (now, 4294967296) +sql_error insert into st_uint_e1 values (now, -4294967297) +sql_error insert into st_uint_e3 values (now, -21474836481) +sql_error insert into st_uint_e6 values (now, 123abc) +sql_error insert into st_uint_e7 values (now, "123abc") +sql_error insert into st_uint_e9 values (now, abc) +sql_error insert into st_uint_e10 values (now, "abc") +sql_error insert into st_uint_e11 values (now, " ") +sql_error insert into st_uint_e12 values (now, '') + +sql_error insert into st_uint_e13 using mt_uint tags (033) values (now, 4294967296) +sql_error insert into st_uint_e14 using mt_uint tags (033) values (now, -4294967297) +sql_error insert into st_uint_e16 using mt_uint tags (033) values (now, -21474836481) +sql_error insert into st_uint_e19 using mt_uint tags (033) values (now, 123abc) +sql_error insert into st_uint_e20 using mt_uint tags (033) values (now, "123abc") +sql_error insert into st_uint_e22 using mt_uint tags (033) values (now, abc) +sql_error insert into st_uint_e23 using mt_uint tags (033) values (now, "abc") +sql_error insert into st_uint_e24 using mt_uint tags (033) values (now, " ") +sql_error insert into st_uint_e25 using mt_uint tags (033) values (now, '') + +sql_error insert into st_uint_e13 using mt_uint tags (21474294967296483648) values (now, -033) +sql_error insert into st_uint_e14_1 using mt_uint tags (-2147483648) values (now, -033) +sql_error insert into st_uint_e16 using mt_uint tags (-2147483649) values (now, -033) +sql_error insert into st_uint_e19 using mt_uint tags (123abc) values (now, -033) +sql_error insert into st_uint_e20 using mt_uint tags ("123abc") values (now, -033) +sql_error insert into st_uint_e22 using mt_uint tags (abc) values (now, -033) +sql_error insert into st_uint_e23 using mt_uint tags ("abc") values (now, -033) +sql_error insert into st_uint_e24 using mt_uint tags (" ") values (now, -033) +sql_error insert into st_uint_e25_1 using mt_uint tags ('') values (now, -033) +sql insert into st_uint_e26_1 using mt_uint tags ('123') values (now, 033) +sql insert into st_uint_e27_1 using mt_uint tags ('12.80') values (now, 033) +sql_error insert into st_uint_e28_1 using mt_uint tags ('-11.80') values (now, 033) + +sql insert into st_uint_e13 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e14 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e15 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e16 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e17 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e18 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e19 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e20 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e21 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e22 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e23 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e24 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e25 using mt_uint tags (033) values (now, 00062) + +sql_error alter table st_uint_e13 set tag tagname=4294967296 +sql_error alter table st_uint_e14 set tag tagname=-4294967297 +sql_error alter table st_uint_e16 set tag tagname=-3147483648 +sql_error alter table st_uint_e19 set tag tagname=123abc +sql_error alter table st_uint_e20 set tag tagname="123abc" +sql_error alter table st_uint_e22 set tag tagname=abc +sql_error alter table st_uint_e23 set tag tagname="abc" +sql_error alter table st_uint_e24 set tag tagname=" " +sql_error alter table st_uint_e25 set tag tagname='' +sql alter table st_uint_e26_1 set tag tagname='123' +sql alter table st_uint_e27_1 set tag tagname='12.80' +sql_error alter table st_uint_e28_1 set tag tagname='-11.80' + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_varbinary.sim b/tests/script/tsim/parser/columnValue_varbinary.sim new file mode 100644 index 0000000000..1db1054646 --- /dev/null +++ b/tests/script/tsim/parser/columnValue_varbinary.sim @@ -0,0 +1,323 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: varbinary +print ========== varbinary +sql create table mt_varbinary (ts timestamp, c varbinary(50)) tags(tagname varbinary(50)) + +## case 00: static create table for test tag values +sql create table st_varbinary_0 using mt_varbinary tags(NULL) +sql show tags from st_varbinary_0 +if $data05 != NULL then + return -1 +endi +sql create table st_varbinary_1 using mt_varbinary tags(NULL) +sql show tags from st_varbinary_1 +if $data05 != NULL then + return -1 +endi +sql create table st_varbinary_2 using mt_varbinary tags('NULL') +sql show tags from st_varbinary_2 +if $data05 != \x4E554C4C then + return -1 +endi +sql create table st_varbinary_3 using mt_varbinary tags('NULL') +sql show tags from st_varbinary_3 +if $data05 != \x4E554C4C then + return -1 +endi +sql create table st_varbinary_4 using mt_varbinary tags("NULL") +sql show tags from st_varbinary_4 +if $data05 != \x4E554C4C then + return -1 +endi +sql create table st_varbinary_5 using mt_varbinary tags("NULL") +sql show tags from st_varbinary_5 +if $data05 != \x4E554C4C then + return -1 +endi +sql create table st_varbinary_6 using mt_varbinary tags("") +sql show tags from st_varbinary_6 +if $data05 != \x then + return -1 +endi +sql create table st_varbinary_7 using mt_varbinary tags(" ") +sql show tags from st_varbinary_7 +if $data05 != \x20 then + return -1 +endi +sql create table st_varbinary_8 using mt_varbinary tags("\x") +sql show tags from st_varbinary_8 +if $data05 != \x then + return -1 +endi +sql create table st_varbinary_9 using mt_varbinary tags("\xaB") +sql show tags from st_varbinary_9 +if $data05 != \xAB then + return -1 +endi +sql create table st_varbinary_10 using mt_varbinary tags("aB") +sql show tags from st_varbinary_10 +if $data05 != \x6142 then + return -1 +endi + + +## case 01: insert values for test column values +sql insert into st_varbinary_0 values(now, NULL) +sql select * from st_varbinary_0 +if $data01 != NULL then + return -1 +endi +sql insert into st_varbinary_1 values(now, NULL) +sql select * from st_varbinary_1 +if $data01 != NULL then + return -1 +endi +sql insert into st_varbinary_2 values(now, 'NULL') +sql select * from st_varbinary_2 +if $data01 != \x4E554C4C then +# return -1 +endi +sql insert into st_varbinary_3 values(now, 'NULL') +sql select * from st_varbinary_3 +if $data01 != \x4E554C4C then +# return -1 +endi +sql insert into st_varbinary_4 values(now, "NULL") +sql select * from st_varbinary_4 +if $data01 != \x4E554C4C then +# return -1 +endi +sql insert into st_varbinary_5 values(now, "NULL") +sql select * from st_varbinary_5 +if $data01 != \x4E554C4C then +# return -1 +endi +sql insert into st_varbinary_6 values(now, "") +sql select * from st_varbinary_6 +if $data01 != \x then +# return -1 +endi +sql insert into st_varbinary_7 values(now, " ") +sql select * from st_varbinary_7 +if $data01 != \x20 then +# return -1 +endi +sql insert into st_varbinary_8 values(now, "\x") +sql select * from st_varbinary_8 +if $data01 != \x then +# return -1 +endi +sql insert into st_varbinary_9 values(now, "\xaB") +sql select * from st_varbinary_9 +if $data01 != \xAB then +# return -1 +endi +sql insert into st_varbinary_10 values(now, "aB") +sql select * from st_varbinary_10 +if $data01 != \x6142 then +# return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_varbinary_100 using mt_varbinary tags(NULL) values(now,NULL) +sql show tags from st_varbinary_100 +if $data05 != NULL then + return -1 +endi +sql select * from st_varbinary_100 +if $data01 != NULL then +# return -1 +endi +sql insert into st_varbinary_101 using mt_varbinary tags(NULL) values(now,NULL) +sql show tags from st_varbinary_101 +if $data05 != NULL then + return -1 +endi +sql select * from st_varbinary_101 +if $data01 != NULL then +# return -1 +endi +sql insert into st_varbinary_102 using mt_varbinary tags('NULL') values(now,'NULL') +sql show tags from st_varbinary_102 +if $data05 != \x4E554C4C then + return -1 +endi +sql select * from st_varbinary_102 +if $data01 != \x4E554C4C then +# return -1 +endi +sql insert into st_varbinary_103 using mt_varbinary tags('NULL') values(now,'NULL') +sql show tags from st_varbinary_103 +if $data05 != \x4E554C4C then + return -1 +endi +sql select * from st_varbinary_103 +if $data01 != \x4E554C4C then +# return -1 +endi +sql insert into st_varbinary_104 using mt_varbinary tags("NULL") values(now,"NULL") +sql show tags from st_varbinary_104 +if $data05 != \x4E554C4C then + return -1 +endi +sql select * from st_varbinary_104 +if $data01 != \x4E554C4C then +# return -1 +endi +sql insert into st_varbinary_105 using mt_varbinary tags("NULL") values(now,"NULL") +sql show tags from st_varbinary_105 +if $data05 != \x4E554C4C then + return -1 +endi +sql select * from st_varbinary_105 +if $data01 != \x4E554C4C then +# return -1 +endi +sql insert into st_varbinary_106 using mt_varbinary tags("") values(now,"") +sql show tags from st_varbinary_106 +if $data05 != \x then + return -1 +endi +sql select * from st_varbinary_106 +if $data01 != \x then +# return -1 +endi +sql insert into st_varbinary_107 using mt_varbinary tags(" ") values(now," ") +sql show tags from st_varbinary_107 +if $data05 != \x20 then + return -1 +endi +sql select * from st_varbinary_107 +if $data01 != \x20 then +# return -1 +endi +sql insert into st_varbinary_108 using mt_varbinary tags("\x") values(now,"\x") +sql show tags from st_varbinary_108 +if $data05 != \x then + return -1 +endi +sql select * from st_varbinary_108 +if $data01 != \x then +# return -1 +endi +sql insert into st_varbinary_109 using mt_varbinary tags("\xaB") values(now,"\xaB") +sql show tags from st_varbinary_109 +if $data05 != \xAB then + return -1 +endi +sql select * from st_varbinary_109 +if $data01 != \xAB then +# return -1 +endi +sql insert into st_varbinary_1010 using mt_varbinary tags("aB") values(now,"aB") +sql show tags from st_varbinary_1010 +if $data05 != \x6142 then + return -1 +endi +sql select * from st_varbinary_1010 +if $data01 != \x6142 then +# return -1 +endi + +## case 03: alter tag values +sql alter table st_varbinary_100 set tag tagname=NULL +sql show tags from st_varbinary_100 +if $data05 != NULL then + return -1 +endi +sql alter table st_varbinary_101 set tag tagname=NULL +sql show tags from st_varbinary_101 +if $data05 != NULL then + return -1 +endi +sql alter table st_varbinary_102 set tag tagname='NULL' +sql show tags from st_varbinary_102 +if $data05 != \x4E554C4C then + return -1 +endi +sql alter table st_varbinary_103 set tag tagname='NULL' +sql show tags from st_varbinary_103 +if $data05 != \x4E554C4C then + return -1 +endi +sql alter table st_varbinary_104 set tag tagname="NULL" +sql show tags from st_varbinary_104 +if $data05 != \x4E554C4C then + return -1 +endi +sql alter table st_varbinary_105 set tag tagname="NULL" +sql show tags from st_varbinary_105 +if $data05 != \x4E554C4C then + return -1 +endi +sql alter table st_varbinary_106 set tag tagname="" +sql show tags from st_varbinary_106 +if $data05 != \x then + return -1 +endi +sql alter table st_varbinary_107 set tag tagname=" " +sql show tags from st_varbinary_107 +if $data05 != \x20 then + return -1 +endi +sql alter table st_varbinary_108 set tag tagname="\x" +sql show tags from st_varbinary_108 +if $data05 != \x then + return -1 +endi +sql alter table st_varbinary_109 set tag tagname="\xaB" +sql show tags from st_varbinary_109 +if $data05 != \xAB then + return -1 +endi +sql alter table st_varbinary_1010 set tag tagname="aB" +sql show tags from st_varbinary_1010 +if $data05 != \x6142 then + return -1 +endi + +# case 04: illegal input +sql_error create table st_varbinary_106 using mt_varbinary tags(+0123) +sql_error create table st_varbinary_107 using mt_varbinary tags(-01.23) +sql_error create table st_varbinary_108 using mt_varbinary tags(+0x01) +sql_error create table st_varbinary_109 using mt_varbinary tags(-0b01) +sql_error create table st_varbinary_1010 using mt_varbinary tags(-0.1e-10) +sql_error create table st_varbinary_1011 using mt_varbinary tags(+0.1E+2) +sql_error create table st_varbinary_1012 using mt_varbinary tags(tRue) +sql_error create table st_varbinary_1013 using mt_varbinary tags(FalsE) +sql_error create table st_varbinary_1014 using mt_varbinary tags(noW) +sql_error create table st_varbinary_1015 using mt_varbinary tags(toDay) +sql_error insert into st_varbinary_106 using mt_varbinary tags(+0123) values(now, NULL); +sql_error insert into st_varbinary_107 using mt_varbinary tags(-01.23) values(now, NULL); +sql_error insert into st_varbinary_108 using mt_varbinary tags(+0x01) values(now, NULL); +sql_error insert into st_varbinary_109 using mt_varbinary tags(-0b01) values(now, NULL); +sql_error insert into st_varbinary_1010 using mt_varbinary tags(-0.1e-10) values(now, NULL); +sql_error insert into st_varbinary_1011 using mt_varbinary tags(+0.1E+2) values(now, NULL); +sql_error insert into st_varbinary_1012 using mt_varbinary tags(tRue) values(now, NULL); +sql_error insert into st_varbinary_1013 using mt_varbinary tags(FalsE) values(now, NULL); +sql_error insert into st_varbinary_1014 using mt_varbinary tags(noW) values(now, NULL); +sql_error insert into st_varbinary_1015 using mt_varbinary tags(toDay) values(now, NULL); +sql_error insert into st_varbinary_106 using mt_varbinary tags(NULL) values(now(), +0123) +sql_error insert into st_varbinary_107 using mt_varbinary tags(NULL) values(now(), -01.23) +sql_error insert into st_varbinary_108 using mt_varbinary tags(NULL) values(now(), +0x01) +sql_error insert into st_varbinary_109 using mt_varbinary tags(NULL) values(now(), -0b01) +sql_error insert into st_varbinary_1010 using mt_varbinary tags(NULL) values(now(), -0.1e-10) +sql_error insert into st_varbinary_1011 using mt_varbinary tags(NULL) values(now(), +0.1E+2) +sql_error insert into st_varbinary_1012 using mt_varbinary tags(NULL) values(now(), tRue) +sql_error insert into st_varbinary_1013 using mt_varbinary tags(NULL) values(now(), FalsE) +sql_error insert into st_varbinary_1014 using mt_varbinary tags(NULL) values(now(), noW) +sql_error insert into st_varbinary_1015 using mt_varbinary tags(NULL) values(now(), toDay) + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_varchar.sim b/tests/script/tsim/parser/columnValue_varchar.sim new file mode 100644 index 0000000000..5edfe5ed24 --- /dev/null +++ b/tests/script/tsim/parser/columnValue_varchar.sim @@ -0,0 +1,415 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: varchar +print ========== varchar +sql create table mt_varchar (ts timestamp, c varchar(50)) tags (tagname varchar(50)) + +## case 00: static create table for test tag values +sql create table st_varchar_0 using mt_varchar tags (NULL) +sql show create table st_varchar_0 +sql show tags from st_varchar_0 +if $data05 != NULL then + return -1 +endi +sql create table st_varchar_1 using mt_varchar tags (NULL) +sql show tags from st_varchar_1 +if $data05 != NULL then + return -1 +endi +sql create table st_varchar_2 using mt_varchar tags ('NULL') +sql show tags from st_varchar_2 +if $data05 != NULL then + return -1 +endi +sql create table st_varchar_3 using mt_varchar tags ('NULL') +sql show tags from st_varchar_3 +if $data05 != NULL then + return -1 +endi +sql create table st_varchar_4 using mt_varchar tags ("NULL") +sql show tags from st_varchar_4 +if $data05 != NULL then + return -1 +endi +sql create table st_varchar_5 using mt_varchar tags ("NULL") +sql show tags from st_varchar_5 +if $data05 != NULL then + return -1 +endi +sql create table st_varchar_6 using mt_varchar tags (+0123) +sql show tags from st_varchar_6 +if $data05 != +0123 then + return -1 +endi +sql create table st_varchar_7 using mt_varchar tags (-01.23) +sql show tags from st_varchar_7 +if $data05 != -01.23 then + return -1 +endi +sql create table st_varchar_8 using mt_varchar tags (+0x01) +sql show tags from st_varchar_8 +if $data05 != +0x01 then + return -1 +endi +sql create table st_varchar_9 using mt_varchar tags (-0b01) +sql show tags from st_varchar_9 +if $data05 != -0b01 then + return -1 +endi +sql create table st_varchar_10 using mt_varchar tags (-0.1e-10) +sql show tags from st_varchar_10 +if $data05 != -0.1e-10 then + return -1 +endi +sql create table st_varchar_11 using mt_varchar tags (+0.1E+2) +sql show tags from st_varchar_11 +if $data05 != +0.1e+2 then + return -1 +endi +sql create table st_varchar_12 using mt_varchar tags (tRue) +sql show tags from st_varchar_12 +if $data05 != true then + return -1 +endi +sql create table st_varchar_13 using mt_varchar tags (FalsE) +sql show tags from st_varchar_13 +if $data05 != false then + return -1 +endi +sql create table st_varchar_14 using mt_varchar tags (noW) +sql show tags from st_varchar_14 +if $data05 != now then + return -1 +endi +sql create table st_varchar_15 using mt_varchar tags (toDay) +sql show tags from st_varchar_15 +if $data05 != today then + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_varchar_0 values(now, NULL) +sql select * from st_varchar_0 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_1 values(now, NULL) +sql select * from st_varchar_1 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_2 values(now, 'NULL') +sql select * from st_varchar_2 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_3 values(now, 'NULL') +sql select * from st_varchar_3 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_4 values(now, "NULL") +sql select * from st_varchar_4 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_5 values(now, "NULL") +sql select * from st_varchar_5 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_6 values(now, +0123) +sql select * from st_varchar_6 +if $data01 != +0123 then + return -1 +endi +sql insert into st_varchar_7 values(now, -01.23) +sql select * from st_varchar_7 +if $data01 != -01.23 then + return -1 +endi +sql insert into st_varchar_8 values(now, +0x01) +sql select * from st_varchar_8 +if $data01 != +0x01 then + return -1 +endi +sql insert into st_varchar_9 values(now, -0b01) +sql select * from st_varchar_9 +if $data01 != -0b01 then + return -1 +endi +sql insert into st_varchar_10 values(now, -0.1e-10) +sql select * from st_varchar_10 +if $data01 != -0.1e-10 then + return -1 +endi +sql insert into st_varchar_11 values(now, +0.1E+2) +sql select * from st_varchar_11 +if $data01 != +0.1e+2 then + return -1 +endi +sql insert into st_varchar_12 values(now, tRue) +sql select * from st_varchar_12 +if $data01 != true then + return -1 +endi +sql insert into st_varchar_13 values(now, FalsE) +sql select * from st_varchar_13 +if $data01 != false then + return -1 +endi +sql insert into st_varchar_14 values(now, noW) +sql select * from st_varchar_14 +if $data01 != now then + return -1 +endi +sql insert into st_varchar_15 values(now, toDay) +sql select * from st_varchar_15 +if $data01 != today then + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_varchar_0 using mt_varchar tags (NULL) values(now, NULL) +sql show tags from st_varchar_0 +if $data05 != NULL then + return -1 +endi +sql select * from st_varchar_0 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_1 using mt_varchar tags (NULL) values(now, NULL) +sql show tags from st_varchar_1 +if $data05 != NULL then + return -1 +endi +sql select * from st_varchar_1 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_2 using mt_varchar tags ('NULL') values(now, 'NULL') +sql show tags from st_varchar_2 +if $data05 != NULL then + return -1 +endi +sql select * from st_varchar_2 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_3 using mt_varchar tags ('NULL') values(now, 'NULL') +sql show tags from st_varchar_3 +if $data05 != NULL then + return -1 +endi +sql select * from st_varchar_3 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_4 using mt_varchar tags ("NULL") values(now, "NULL") +sql show tags from st_varchar_4 +if $data05 != NULL then + return -1 +endi +sql select * from st_varchar_4 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_5 using mt_varchar tags ("NULL") values(now, "NULL") +sql show tags from st_varchar_5 +if $data05 != NULL then + return -1 +endi +sql select * from st_varchar_5 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_6 using mt_varchar tags (+0123) values(now, +0123) +sql show tags from st_varchar_6 +if $data05 != +0123 then + return -1 +endi +sql select * from st_varchar_6 +if $data01 != +0123 then + return -1 +endi +sql insert into st_varchar_7 using mt_varchar tags (-01.23) values(now, -01.23) +sql show tags from st_varchar_7 +if $data05 != -01.23 then + return -1 +endi +sql select * from st_varchar_7 +if $data01 != -01.23 then + return -1 +endi +sql insert into st_varchar_8 using mt_varchar tags (+0x01) values(now, +0x01) +sql show tags from st_varchar_8 +if $data05 != +0x01 then + return -1 +endi +sql select * from st_varchar_8 +if $data01 != +0x01 then + return -1 +endi +sql insert into st_varchar_9 using mt_varchar tags (-0b01) values(now, -0b01) +sql show tags from st_varchar_9 +if $data05 != -0b01 then + return -1 +endi +sql select * from st_varchar_9 +if $data01 != -0b01 then + return -1 +endi +sql insert into st_varchar_10 using mt_varchar tags (-0.1e-10) values(now, -0.1e-10) +sql show tags from st_varchar_10 +if $data05 != -0.1e-10 then + return -1 +endi +sql select * from st_varchar_10 +if $data01 != -0.1e-10 then + return -1 +endi +sql insert into st_varchar_11 using mt_varchar tags (+0.1E+2) values(now, +0.1E+2) +sql show tags from st_varchar_11 +if $data05 != +0.1e+2 then + return -1 +endi +sql select * from st_varchar_11 +if $data01 != +0.1e+2 then + return -1 +endi +sql insert into st_varchar_12 using mt_varchar tags (tRue) values(now, tRue) +sql show tags from st_varchar_12 +if $data05 != true then + return -1 +endi +sql select * from st_varchar_12 +if $data01 != true then + return -1 +endi +sql insert into st_varchar_13 using mt_varchar tags (FalsE) values(now, FalsE) +sql show tags from st_varchar_13 +if $data05 != false then + return -1 +endi +sql select * from st_varchar_13 +if $data01 != false then + return -1 +endi +sql insert into st_varchar_14 using mt_varchar tags (noW) values(now, noW) +sql show tags from st_varchar_14 +if $data05 != now then + return -1 +endi +sql select * from st_varchar_14 +if $data01 != now then + return -1 +endi +sql insert into st_varchar_15 using mt_varchar tags (toDay) values(now, toDay) +sql show tags from st_varchar_15 +if $data05 != today then + return -1 +endi +sql select * from st_varchar_15 +if $data01 != today then + return -1 +endi + +## case 03: alter tag values +sql alter table st_varchar_0 set tag tagname=NULL +sql show tags from st_varchar_0 +if $data05 != NULL then + return -1 +endi +sql alter table st_varchar_1 set tag tagname=NULL +sql show tags from st_varchar_1 +if $data05 != NULL then + return -1 +endi +sql alter table st_varchar_2 set tag tagname='NULL' +sql show tags from st_varchar_2 +if $data05 != NULL then + return -1 +endi +sql alter table st_varchar_3 set tag tagname='NULL' +sql show tags from st_varchar_3 +if $data05 != NULL then + return -1 +endi +sql alter table st_varchar_4 set tag tagname="NULL" +sql show tags from st_varchar_4 +if $data05 != NULL then + return -1 +endi +sql alter table st_varchar_5 set tag tagname="NULL" +sql show tags from st_varchar_5 +if $data05 != NULL then + return -1 +endi +sql alter table st_varchar_6 set tag tagname=+0123 +sql show tags from st_varchar_6 +if $data05 != +0123 then + return -1 +endi +sql alter table st_varchar_7 set tag tagname=-01.23 +sql show tags from st_varchar_7 +if $data05 != -01.23 then + return -1 +endi +sql alter table st_varchar_8 set tag tagname=+0x01 +sql show tags from st_varchar_8 +if $data05 != +0x01 then + return -1 +endi +sql alter table st_varchar_9 set tag tagname=-0b01 +sql show tags from st_varchar_9 +if $data05 != -0b01 then + return -1 +endi +sql alter table st_varchar_10 set tag tagname=-0.1e-10 +sql show tags from st_varchar_10 +if $data05 != -0.1e-10 then + return -1 +endi +sql alter table st_varchar_11 set tag tagname=+0.1E+2 +sql show tags from st_varchar_11 +if $data05 != +0.1e+2 then + return -1 +endi +sql alter table st_varchar_12 set tag tagname=tRue +sql show tags from st_varchar_12 +if $data05 != true then + return -1 +endi +sql alter table st_varchar_13 set tag tagname=FalsE +sql show tags from st_varchar_13 +if $data05 != false then + return -1 +endi +sql alter table st_varchar_14 set tag tagname=noW +sql show tags from st_varchar_14 +if $data05 != now then + return -1 +endi +sql alter table st_varchar_15 set tag tagname=toDay +sql show tags from st_varchar_15 +if $data05 != today then + return -1 +endi + + +# case 04: illegal input + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/create_mt.sim b/tests/script/tsim/parser/create_mt.sim index dd2a7834c4..57647b3c7e 100644 --- a/tests/script/tsim/parser/create_mt.sim +++ b/tests/script/tsim/parser/create_mt.sim @@ -187,7 +187,7 @@ sql_error create table $tb using $mt tags (abc) sql_error create table $tb using $mt tags ('abc') sql drop table if exists $tb sql reset query cache -sql_error create table $tb using $mt tags (1e1) +sql create table $tb using $mt tags (1e1) sql_error create table $tb using $mt tags ('1e1') sql_error create table $tb using $mt tags (2147483649) diff --git a/tests/script/tsim/parser/null_char.sim b/tests/script/tsim/parser/null_char.sim index 9d476b5227..3bac92334b 100644 --- a/tests/script/tsim/parser/null_char.sim +++ b/tests/script/tsim/parser/null_char.sim @@ -140,7 +140,7 @@ endi ### bool: sql create table stx using mt2 tags ('NULL', '123aBc', 104, '123') -sql create table sty using mt2 tags ('NULL', '123aBc', 104, 'xtz') +sql_error create table sty using mt2 tags ('NULL', '123aBc', 104, 'xtz') sql create table st4 using mt2 tags ('NULL', '123aBc', 104, 'NULL') sql insert into st4 (ts, col1) values(now, 1) sql select tag1,tag2,tag3,tag5 from st4 @@ -156,7 +156,7 @@ endi if $data02 != 104 then return -1 endi -if $data03 != 0 then +if $data03 != NULL then print ==6== expect: NULL, actually: $data03 return -1 endi @@ -182,7 +182,7 @@ endi #### case 2: dynamic create table using super table when insert into sql create table mt3 (ts timestamp, col1 int, col3 float, col5 binary(8), col6 bool, col9 nchar(8)) tags (tag1 binary(8), tag2 nchar(8), tag3 int, tag5 bool) -sql_error insert into st31 using mt3 tags (NULL, 'NULL', 102, 'true') values (now+1s, 31, 31, 'bin_31', '123', 'nchar_31') +sql insert into st31 using mt3 tags (NULL, 'NULL', 102, 'true') values (now+1s, 31, 31, 'bin_31', '123', 'nchar_31') sql_error insert into st32 using mt3 tags (NULL, 'ABC', 103, 'FALSE') values (now+2s, 32, 32.12345, 'bin_32', 'abc', 'nchar_32') sql_error insert into st33 using mt3 tags ('NULL', '123aBc', 104, 'NULL') values (now+3s, 33, 33, 'bin_33', 'false123', 'nchar_33') sql_error insert into st34 using mt3 tags ('NULL', '123aBc', 105, NULL) values (now+4s, 34, 34.12345, 'bin_34', 'true123', 'nchar_34') @@ -306,8 +306,8 @@ if $data02 != NULL then print ==10== expect: NULL, actually: $data02 return -1 endi -sql_error alter table st41 set tag tag_int = 'NULL' -sql alter table st41 set tag tag_int = '' +sql alter table st41 set tag tag_int = 'NULL' +sql_error alter table st41 set tag tag_int = '' sql_error alter table st41 set tag tag_int = abc379 ################### bool @@ -333,8 +333,8 @@ if $data03 != 1 then endi sql alter table st41 set tag tag_bool = 'NULL' sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 -if $data03 != 0 then - print ==14== expect: 0, actually: $data03 +if $data03 != NULL then + print ==14== expect: NULL, actually: $data03 return -1 endi sql alter table st41 set tag tag_bool = NULL @@ -344,7 +344,7 @@ if $data03 != NULL then endi sql alter table st41 set tag tag_bool = '123' -sql alter table st41 set tag tag_bool = '' +sql_error alter table st41 set tag tag_bool = '' sql_error alter table st41 set tag tag_bool = abc379 ################### float @@ -380,8 +380,8 @@ if $data04 != NULL then endi sql alter table st41 set tag tag_float = 'NULL' sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 -if $data04 != 0.00000 then - print ==17== expect: 0.00000, actually : $data04 +if $data04 != NULL then + print ==17== expect: NULL, actually : $data04 return -1 endi sql alter table st41 set tag tag_float = '54.123456' @@ -396,10 +396,10 @@ if $data04 != -54.12346 then print ==19== expect: -54.12346, actually : $data04 return -1 endi -sql alter table st41 set tag tag_float = '' +sql_error alter table st41 set tag tag_float = '' -sql alter table st41 set tag tag_float = 'abc' -sql alter table st41 set tag tag_float = '123abc' +sql_error alter table st41 set tag tag_float = 'abc' +sql_error alter table st41 set tag tag_float = '123abc' sql_error alter table st41 set tag tag_float = abc ################### double @@ -428,14 +428,15 @@ if $data05 != NULL then endi sql alter table st41 set tag tag_double = 'NULL' sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 -if $data05 != 0.000000000 then - print ==20== expect: 0.000000000, actually : $data05 +if $data05 != NULL then + print ==20== expect: NULL, actually : $data05 return -1 endi -sql alter table st41 set tag tag_double = '' -sql alter table st41 set tag tag_double = 'abc' -sql alter table st41 set tag tag_double = '123abc' +sql_error alter table st41 set tag tag_double = '' +sql alter table st41 set tag tag_double = '123' +sql_error alter table st41 set tag tag_double = 'abc' +sql_error alter table st41 set tag tag_double = '123abc' sql_error alter table st41 set tag tag_double = abc ################### bigint smallint tinyint @@ -459,8 +460,8 @@ if $data00 != -9223372036854775807 then endi sql alter table st51 set tag tag_bigint = -9223372036854775808 -sql_error alter table st51 set tag tag_bigint = 'NULL' -sql alter table st51 set tag tag_bigint = '' +sql alter table st51 set tag tag_bigint = 'NULL' +sql_error alter table st51 set tag tag_bigint = '' sql_error alter table st51 set tag tag_bigint = abc379 #### @@ -480,8 +481,8 @@ if $data01 != -32767 then endi sql alter table st51 set tag tag_smallint = -32768 -sql_error alter table st51 set tag tag_smallint = 'NULL' -sql alter table st51 set tag tag_smallint = '' +sql alter table st51 set tag tag_smallint = 'NULL' +sql_error alter table st51 set tag tag_smallint = '' sql_error alter table st51 set tag tag_smallint = abc379 #### @@ -499,8 +500,8 @@ if $data02 != -127 then endi sql alter table st51 set tag tag_tinyint = '-128' sql_error alter table st51 set tag tag_tinyint = 128 -sql_error alter table st51 set tag tag_tinyint = 'NULL' -sql alter table st51 set tag tag_tinyint = '' +sql alter table st51 set tag tag_tinyint = 'NULL' +sql_error alter table st51 set tag tag_tinyint = '' sql_error alter table st51 set tag tag_tinyint = abc379 # test end diff --git a/tests/script/tsim/query/interval.sim b/tests/script/tsim/query/interval.sim index 135fcc8591..7f950ea69c 100644 --- a/tests/script/tsim/query/interval.sim +++ b/tests/script/tsim/query/interval.sim @@ -226,4 +226,135 @@ print =============== clear # return -1 #endi +print ================= step12 + +sql create database test2 vgroups 4; +sql use test2; +sql create stable stb (ts timestamp, c1 int) tags (t1 int); +sql create table t1 using stb tags (1); +sql create table t2 using stb tags (2); +sql create table t3 using stb tags (3); +sql create table t4 using stb tags (4); +sql create table t5 using stb tags (4); +sql create table t6 using stb tags (4); +sql insert into t1 values ("2024-03-01 14:29:07.051", 11); +sql insert into t2 values ("2024-03-01 14:29:07.051", 21); +sql insert into t3 values ("2024-03-01 14:29:07.051", 31); +sql insert into t4 values ("2024-03-01 14:29:07.051", 41); +sql insert into t5 values ("2024-03-01 14:29:07.051", 51); +sql insert into t6 values ("2024-03-01 14:29:07.051", 61); +sql insert into t1 values ("2024-03-01 14:30:07.051", 12); +sql insert into t2 values ("2024-03-01 14:30:07.051", 22); +sql insert into t3 values ("2024-03-01 14:30:07.051", 32); +sql insert into t4 values ("2024-03-01 14:30:07.051", 42); +sql insert into t5 values ("2024-03-01 14:30:07.051", 52); +sql insert into t6 values ("2024-03-01 14:30:07.051", 62); +sql insert into t1 values ("2024-03-01 14:31:07.051", 13); +sql insert into t2 values ("2024-03-01 14:31:07.051", 23); +sql insert into t3 values ("2024-03-01 14:31:07.051", 33); +sql insert into t4 values ("2024-03-01 14:31:07.051", 43); +sql insert into t5 values ("2024-03-01 14:31:07.051", 53); +sql insert into t6 values ("2024-03-01 14:31:07.051", 63); +sql insert into t1 values ("2024-03-01 14:32:07.051", 14); +sql insert into t2 values ("2024-03-01 14:32:07.051", 24); +sql insert into t3 values ("2024-03-01 14:32:07.051", 34); +sql insert into t4 values ("2024-03-01 14:32:07.051", 44); +sql insert into t5 values ("2024-03-01 14:32:07.051", 54); +sql insert into t6 values ("2024-03-01 14:32:07.051", 64); +sql insert into t1 values ("2024-03-01 14:33:07.051", 15); +sql insert into t2 values ("2024-03-01 14:33:07.051", 25); +sql insert into t3 values ("2024-03-01 14:33:07.051", 35); +sql insert into t4 values ("2024-03-01 14:33:07.051", 45); +sql insert into t5 values ("2024-03-01 14:33:07.051", 55); +sql insert into t6 values ("2024-03-01 14:33:07.051", 65); +sql insert into t1 values ("2024-03-01 14:34:07.051", 16); +sql insert into t2 values ("2024-03-01 14:34:07.051", 26); +sql insert into t3 values ("2024-03-01 14:34:07.051", 36); +sql insert into t4 values ("2024-03-01 14:34:07.051", 46); +sql insert into t5 values ("2024-03-01 14:34:07.051", 56); +sql insert into t6 values ("2024-03-01 14:34:07.051", 66); + +sleep 300 + +sql select _wstart, count(*) from (select * from stb partition by tbname) interval(2s); + +print $data00,$data01 +print $data10,$data11 +print $data20,$data21 +print $data30,$data31 +print $data40,$data41 +print $data50,$data51 +print $data60,$data61 +print $data70,$data71 + +if $rows != 6 then + print $rows + return -1 +endi + +if $data01 != 6 then + print $data01 +endi + +if $data11 != 6 then + print $data11 +endi + +if $data21 != 6 then + print $data21 +endi + +if $data31 != 6 then + print $data31 +endi + +if $data41 != 6 then + print $data41 +endi + +if $data51 != 6 then + print $data51 +endi + + +sql select _wstart, count(*) from (select * from stb partition by tbname slimit 2) interval(2s); + +print $data00,$data01 +print $data10,$data11 +print $data20,$data21 +print $data30,$data31 +print $data40,$data41 +print $data50,$data51 +print $data60,$data61 +print $data70,$data71 + +if $rows != 6 then + print $rows then + return -1 +endi + +if $data01 != 2 then + print $data01 +endi + +if $data11 != 2 then + print $data11 +endi + +if $data21 != 2 then + print $data21 +endi + +if $data31 != 2 then + print $data31 +endi + +if $data41 != 2 then + print $data41 +endi + +if $data51 != 2 then + print $data51 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/pauseAndResume.sim b/tests/script/tsim/stream/pauseAndResume.sim index 5eb9eef010..9a05e645c2 100644 --- a/tests/script/tsim/stream/pauseAndResume.sim +++ b/tests/script/tsim/stream/pauseAndResume.sim @@ -8,16 +8,19 @@ sql connect print ===== step1 sql drop stream if exists streams1; sql drop database if exists test; -sql create database test vgroups 10; +sql create database test vgroups 3; sql use test; sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); sql create table ts1 using st tags(1,1,1); sql create table ts2 using st tags(2,2,2); sql create table ts3 using st tags(3,2,2); sql create table ts4 using st tags(4,2,2); + sql create stream streams1 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 watermark 1d into streamt1 as select _wstart, count(*) c1, sum(a) c3 from st interval(10s); sleep 2000 +sql_error create stream stream1_same_dst into streamt1 as select _wstart, count(*) c1, sum(a) c3 from st interval(10s); + sql pause stream streams1; sql insert into ts1 values(1648791213001,1,12,3,1.0); @@ -102,6 +105,11 @@ if $data11 != 4 then goto loop1 endi +print ===== idle for 70 sec for checkpoint gen +sleep 70000 + +print ===== idle 60 sec completed , continue + print ===== step 1 over print ===== step2 @@ -113,6 +121,12 @@ sql create table t1(ts timestamp, a int, b int , c int, d double); sql create stream streams2 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 watermark 1d into streamt2 as select _wstart, count(*) c1, sum(a) c3 from t1 interval(10s); +# duplicate stream +sql_error create stream streams2 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 watermark 1d into streamt2 as select _wstart, count(*) c1, sum(a) c3 from t1 interval(10s); +sql create stream if not exists streams2 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 watermark 1d into streamt2 as select _wstart, count(*) c1, sum(a) c3 from t1 interval(10s); + +sleep 1000 + sql pause stream streams2; sql insert into t1 values(1648791213001,1,12,3,1.0); @@ -237,8 +251,9 @@ print ===== step 2 over print ===== step3 sql drop stream if exists streams3; sql drop database if exists test3; -sql create database test3 vgroups 10; +sql create database test3 vgroups 3; sql use test3; + sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); sql create table ts1 using st tags(1,1,1); sql create table ts2 using st tags(2,2,2); @@ -259,7 +274,7 @@ sql insert into ts4 values(1648791213001,1,12,3,1.0); $loop_count = 0 -loop3: +loop4: $loop_count = $loop_count + 1 if $loop_count == 20 then @@ -276,7 +291,7 @@ if $rows != 1 then print $data00 $data01 $data02 print $data10 $data11 $data12 print $data20 $data21 $data22 - goto loop3 + goto loop4 endi print 2 select * from streamt5; @@ -287,7 +302,7 @@ if $rows != 1 then print $data00 $data01 $data02 print $data10 $data11 $data12 print $data20 $data21 $data22 - goto loop3 + goto loop4 endi print 3 select * from streamt3; diff --git a/tests/script/tsim/tag/add.sim b/tests/script/tsim/tag/add.sim index 2b528c0255..0e0755111d 100644 --- a/tests/script/tsim/tag/add.sim +++ b/tests/script/tsim/tag/add.sim @@ -409,7 +409,7 @@ endi if $data03 != 5 then return -1 endi -if $data04 != 0 then +if $data04 != 1 then return -1 endi diff --git a/tests/script/win-test-file b/tests/script/win-test-file index b9f250927f..d51de0a61b 100644 --- a/tests/script/win-test-file +++ b/tests/script/win-test-file @@ -113,6 +113,13 @@ ./test.sh -f tsim/parser/columnValue_smallint.sim ./test.sh -f tsim/parser/columnValue_tinyint.sim ./test.sh -f tsim/parser/columnValue_unsign.sim +./test.sh -f tsim/parser/columnValue_uint.sim +./test.sh -f tsim/parser/columnValue_timestamp.sim +./test.sh -f tsim/parser/columnValue_varchar.sim +./test.sh -f tsim/parser/columnValue_nchar.sim +./test.sh -f tsim/parser/columnValue_varbinary.sim +./test.sh -f tsim/parser/columnValue_json.sim +./test.sh -f tsim/parser/columnValue_geometry.sim ./test.sh -f tsim/parser/condition.sim ./test.sh -f tsim/parser/condition_scl.sim ./test.sh -f tsim/parser/constCol.sim diff --git a/tests/system-test/1-insert/insert_column_value.py b/tests/system-test/1-insert/insert_column_value.py new file mode 100644 index 0000000000..49b77f4199 --- /dev/null +++ b/tests/system-test/1-insert/insert_column_value.py @@ -0,0 +1,353 @@ +import datetime +from enum import Enum +from util.log import * +from util.sql import * +from util.cases import * +from util.common import * +from util.dnodes import * +from util.sqlset import * + + +DBNAME = "db" + +class TDDataType(Enum): + NULL = 0 + BOOL = 1 + TINYINT = 2 + SMALLINT = 3 + INT = 4 + BIGINT = 5 + FLOAT = 6 + DOUBLE = 7 + VARCHAR = 8 + TIMESTAMP = 9 + NCHAR = 10 + UTINYINT = 11 + USMALLINT = 12 + UINT = 13 + UBIGINT = 14 + JSON = 15 + VARBINARY = 16 + DECIMAL = 17 + BLOB = 18 + MEDIUMBLOB = 19 + BINARY = 8 + GEOMETRY = 20 + MAX = 21 + + +class TDTestCase: + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + self.TIMESTAMP_MIN = -1000 + self.TIMESTAMP_BASE = 1706716800 + tdSql.init(conn.cursor()) + tdSql.execute(f'drop database if exists db') + tdSql.execute(f'create database if not exists db vgroups 1') + + def __create_tb(self, dbname="db"): + CREATE_STB_LIST = [ f"create table {dbname}.stb_vc (ts timestamp, c0 binary(50), c1 varchar(50)) tags(t0 varchar(50), t1 binary(50));", + f"create table {dbname}.stb_nc (ts timestamp, c0 nchar(50), c1 nchar(50)) tags(t0 nchar(50), t1 nchar(50));", + f"create table {dbname}.stb_ts (ts timestamp, c0 timestamp, c1 timestamp) tags(t0 timestamp, t1 timestamp);", + f"create table {dbname}.stb_bo (ts timestamp, c0 bool, c1 bool) tags(t0 bool, t1 bool);", + f"create table {dbname}.stb_vb (ts timestamp, c0 varbinary(50), c1 varbinary(50)) tags(t0 varbinary(50), t1 varbinary(50));", + f"create table {dbname}.stb_in (ts timestamp, c0 int, c1 smallint) tags(t0 bigint, t1 tinyint);", + f"create table {dbname}.stb_ui (ts timestamp, c0 int unsigned, c1 smallint unsigned) tags(t0 bigint unsigned, t1 tinyint unsigned);", + f"create table {dbname}.stb_fl (ts timestamp, c0 float, c1 float) tags(t0 float, t1 float);", + f"create table {dbname}.stb_db (ts timestamp, c0 float, c1 float) tags(t0 float, t1 float);", + f"create table {dbname}.stb_ge (ts timestamp, c0 geometry(512), c1 geometry(512)) tags(t0 geometry(512), t1 geometry(512));", + f"create table {dbname}.stb_js (ts timestamp, c0 int) tags(t0 json);" ] + for _stb in CREATE_STB_LIST: + tdSql.execute(_stb) + tdSql.query(f'show {dbname}.stables') + tdSql.checkRows(len(CREATE_STB_LIST)) + + def _query_check_varchar(self, result, okv, nv, row = 0, col = 0): + for i in range(row): + for j in range(1, col): + check_result = False + check_item = result[i][j] + if result[i][j] == None: + check_item = 'null' + if check_item == okv or check_item == nv: + check_result = True + if check_result == False and (okv[0:1] == '\'' or okv[0:1] == '\"'): + if check_item == okv[1:-1]: + check_result = True + if check_result == False and (nv[0:1] == '\'' or nv[0:1] == '\"'): + if check_item == nv[1:-1]: + check_result = True + if check_result == False: + if check_item == nv.strip().lower(): + check_result = True + tdSql.checkEqual(check_result, True) + + def _query_check_int(self, result, okv, nv, row = 0, col = 0): + for i in range(row): + for j in range(1, col): + check_result = False + check_item = result[i][j] + if result[i][j] == None: + check_item = 'null' + if check_item == okv or check_item == nv: + check_result = True + if check_item == nv.strip().lower(): + check_result = True + if check_result == False and (okv.find('1') != -1 or okv.find('2') != -1): + if check_item != 0: + check_result = True + if check_result == False and (nv.find('1') != -1 or nv.find('2') != -1): + if check_item != 0: + check_result = True + if check_item == 0: + check_result = True + tdSql.checkEqual(check_result, True) + + def _query_check_bool(self, result, okv, nv, row = 0, col = 0): + for i in range(row): + for j in range(1, col): + check_result = False + check_item = result[i][j] + if result[i][j] == None: + check_item = 'null' + elif result[i][j] == True: + check_item = "true" + else: + check_item = "false" + if check_item == okv.strip().lower() or check_item == nv.strip().lower(): + check_result = True + if check_result == False and (nv[0:1] == '\'' or nv[0:1] == '\"'): + if check_item == nv[1:-1].strip().lower(): + check_result = True + if check_result == False and (nv.find('1') != -1 or nv.find('2') != -1): # char 1 or 2 exist for non-zero values + if check_item == "true": + check_result = True + else: + if check_item == "false": + check_result = True + tdSql.checkEqual(check_result, True) + + def _query_check_timestamp(self, result, okv, nv, row = 0, col = 0): + for i in range(row): + for j in range(1, col): + check_result = False + check_item = result[i][j] + if result[i][j] == None: + check_item = 'null' + if nv.lower().find(check_item) != -1: + check_result = True + else: + check_item = int(result[i][j].timestamp()) + if check_result == False and nv.lower().find("now") != -1 or nv.lower().find("today") != -1 or nv.lower().find("now") != -1 or nv.lower().find("today") != -1: + if check_item > self.TIMESTAMP_BASE: + check_result = True + if check_result == False and check_item > self.TIMESTAMP_MIN: + check_result = True + tdSql.checkEqual(check_result, True) + + + def _query_check(self, dbname="db", stbname="", ctbname="", nRows = 0, okv = None, nv = None, dtype = TDDataType.NULL): + result = None + if dtype != TDDataType.GEOMETRY: # geometry query by py connector need to be supported + tdSql.query(f'select * from {dbname}.{stbname}') + tdSql.checkRows(nRows) + result = tdSql.queryResult + + if dtype == TDDataType.VARCHAR or dtype == TDDataType.NCHAR: + self._query_check_varchar(result, okv, nv, nRows, 4) + elif dtype == TDDataType.TIMESTAMP: + self._query_check_timestamp(result, okv, nv, nRows, 4) + elif dtype == TDDataType.BOOL: + self._query_check_bool(result, okv, nv, nRows, 4) + elif dtype == TDDataType.VARBINARY: + pass + elif dtype == TDDataType.INT: + self._query_check_int(result, okv, nv, nRows, 4) + elif dtype == TDDataType.UINT: + self._query_check_int(result, okv, nv, nRows, 4) + elif dtype == TDDataType.FLOAT or dtype == TDDataType.DOUBLE: + self._query_check_int(result, okv, nv, nRows, 4) + elif dtype == TDDataType.GEOMETRY: + pass + else: + tdLog.info(f"unknown data type %s" % (dtype)) + + if ctbname != "": + tdSql.execute(f'drop table {dbname}.{ctbname}') + + def __insert_query_common(self, dbname="db", stbname="", ctbname="", oklist=[], kolist=[], okv=None, dtype = TDDataType.NULL): + tdLog.info(f'{dbname}.{stbname} {ctbname}, oklist:%d, kolist:%d'%(len(oklist), len(kolist))) + tdSql.checkEqual(34, len(oklist) + len(kolist)) + + for _l in kolist: + for _e in _l: + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv})' %(_e)) + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, %s)' %(_e)) + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, %s)' %(_e, _e)) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, %s) values(now, {okv}, {okv})' %(_e)) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv}) values(now, {okv}, {okv})' %(_e)) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, %s, {okv})' %(_e)) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, {okv}, %s)' %(_e)) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, %s, %s)' %(_e, _e)) + tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, {okv}, {okv})') + self._query_check(dbname,stbname, "", 1, okv, _e, dtype) + tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = {okv}') + tdSql.error(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e)) + tdSql.error(f'alter table {dbname}.{ctbname} set tag t1 = %s' %(_e)) + tdSql.execute(f'drop table {dbname}.{ctbname}') + for _l in oklist: + for _e in _l: + tdLog.info(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv})' %(_e)) + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv})' %(_e)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now + 0s, %s, {okv})' %(_e)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now + 1s, {okv}, %s)' %(_e)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now + 2s, %s, %s)' %(_e, _e)) + tdLog.info(f'insert into {dbname}.{ctbname} values(now + 0s, %s, {okv})' %(_e)) + tdLog.info(f'insert into {dbname}.{ctbname} values(now + 1s, {okv}, %s)' %(_e)) + tdLog.info(f'insert into {dbname}.{ctbname} values(now + 2s, %s, %s)' %(_e, _e)) + tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e)) + tdSql.execute(f'alter table {dbname}.{ctbname} set tag t1 = %s' %(_e)) + self._query_check(dbname,stbname, ctbname, 3, okv, _e, dtype) + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, %s)' %(_e, _e)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now, %s, %s)' %(_e, _e)) + self._query_check(dbname,stbname, ctbname, 1, okv, _e, dtype) + tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv}) values(now, %s, {okv})' %(_e, _e)) + self._query_check(dbname,stbname, ctbname, 1, okv, _e, dtype) + tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, %s) values(now, {okv}, %s)' %(_e, _e)) + self._query_check(dbname,stbname, ctbname, 1, okv, _e, dtype) + tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, %s) values(now, %s, %s)' %(_e, _e, _e, _e)) + self._query_check(dbname,stbname, ctbname, 1, okv, _e, dtype) + + def __insert_query_json(self, dbname="db", stbname="", ctbname="", oklist=[], kolist=[], okv=None): + tdLog.info(f'{dbname}.{stbname} {ctbname}, oklist:%d, kolist:%d'%(len(oklist), len(kolist))) + tdSql.checkEqual(34, len(oklist) + len(kolist)) + + for _l in kolist: + for _e in _l: + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s)' %(_e)) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s) values(now, 1)' %(_e)) + tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}) values(now, 1)') + tdSql.query(f'select * from {dbname}.{stbname}') + tdSql.checkRows(1) + tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = {okv}') + tdSql.error(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e)) + tdSql.execute(f'drop table {dbname}.{ctbname}') + for _l in oklist: + for _e in _l: + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s)' %(_e)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now, 1)') + tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e)) + tdSql.query(f'select * from {dbname}.{stbname}') + tdSql.checkRows(1) + tdSql.execute(f'drop table {dbname}.{ctbname}') + + def __insert_query_exec(self): + STR_EMPTY = ['\'\'', "\"\"", '\' \'', "\" \""] + STR_INTEGER_P = ["\"42\"", '\'+42\'', '\'+0\'', '\'-0\'', '\'0x2A\'', '\'-0X0\'', '\'+0x0\'', '\'0B00101010\'', '\'-0b00\''] + STR_INTEGER_M = ['\'-128\'', '\'-0X1\'', '\"-0x34\"', '\'-0b01\'', '\'-0B00101010\''] + STR_FLOAT_P = ['\'42.1\'', "\"+0.003\"", "\'-0.0\'"] + STR_FLOAT_M = ["\"-32.001\""] + STR_FLOAT_E_P = ['\'1e1\'', "\"3e-2\"", "\"-3e-5\""] + STR_FLOAT_E_M = ["\"-0.3E+1\""] + STR_MISC = ["\"123ab\"", '\'123d\'', '\'-12s\'', '\'\x012\'', '\'x12\'', '\'x\'', '\'NULL \'', '\' NULL\'', '\'True \'', '\' False\'', + '\'0B0101 \'', '\' 0B0101\'', '\' -0x01 \'', '\'-0x02 \''] + STR_OPTR = ['\'1*10\'', '\'1+2\'', '\'-2-0\'','\'1%2\'', '\'2/0\'', '\'1&31\''] + STR_TSK = ['\'now\'', '\'today\''] + STR_TSK_MISC = ['\'now+1s\'', '\' now\'', '\'today \'', '\'today+1m\'', '\'today-1w\''] + STR_TSKP = ['\'now()\'', '\'today()\''] + STR_TSKP_MISC = ['\'now()+1s\'', '\' now()\'', '\'now( )\'', '\'today() \'', '\'today())\'', '\'today()+1m\'', '\'today()-1w\''] + STR_BOOL = ['\'true\'', '\'false\'', '\'TRUE\'', '\'FALSE\'', '\'tRuE\'', '\'falsE\''] + STR_TS = ["\"2024-02-01 00:00:01.001-08:00\"", "\'2024-02-01T00:00:01.001+09:00\'", "\"2024-02-01\"", "\'2024-02-02 00:00:01\'", "\'2024-02-02 00:00:01.009\'"] + STR_VARBIN = ['\'\\x12\'', '\'\\x13\'', '\' \\x14 \'', '\'\\x12ab\''] + STR_JSON_O = ['\'{\"k1\":\"v1\"}\'', '\' {} \''] + STR_JSON_A = ['\'[]\''] + STR_GEO = ['\' POINT(1.0 1.0)\'', '\'LINESTRING(1.00 +2.0, 2.1 -3.2, 5.00 5.01) \'', '\'POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))\'' ] + STR_NULL = ['\'NuLl\'', '\'null\'', '\'NULL\''] + + RAW_INTEGER_P = [' 42 ', '+042 ', ' +0', '0 ', '-0', '0', ' 0X2A', ' -0x0 ', '+0x0 ', ' 0B00101010', ' -0b00'] + RAW_INTEGER_M = [' -42 ', ' -0128',' -0x1', ' -0X2A', '-0b01 ', ' -0B00101010 '] + RAW_FLOAT_P = [' 123.012', ' 0.0', ' +0.0', ' -0.0 '] + RAW_FLOAT_M = ['-128.001 '] + RAW_FLOAT_E_P = [' 1e-100', ' +0.1E+2', ' -0.1E-10'] + RAW_FLOAT_E_M = [" -1E2 "] + RAW_MISC = ['123abc', "123c", '-123d', '+', '-', ' *', ' /', '% ', '&', "|", "^", "&&", "||", "!", " =", ' None ', 'NONE', 'now+1 s', 'now-1','now-1y','now+2 d', + 'today+1 s', 'today-1','today-1y','today+2 d', 'now()+1 s', 'now()-1','now()-1y','now()+2 d', 'today()+1 s', 'today()-1','today()-1y','today()+2 d'] + RAW_OPTR = ['1*10', '1+2', '-2-0','1%2', '2/0', '1&31'] + RAW_TSK = [' now ', 'today '] + RAW_TSK_OPTR = [' now +1s', 'today + 2d'] + RAW_TSKP = ['now( ) ', ' toDay() '] + RAW_TSKP_OPTR = [' noW ( ) + 1s', 'nOw( ) + 2D', 'NOW () + 000s', ' today()+1M', 'today( ) - 1w ', 'TodaY ( ) - 1U '] + RAW_BOOL = ['true', 'false', ' TRUE ', 'FALSE ', ' tRuE', ' falsE '] + RAW_NULL = ['NuLl', 'null ', ' NULL', ' NULL '] + + OK_VC = [STR_EMPTY, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, + STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, STR_NULL, RAW_INTEGER_P, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M, + RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_TSK, RAW_BOOL, RAW_NULL] + KO_VC = [RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR] + OK_NC = OK_VC + KO_NC = KO_VC + OK_TS = [STR_TSK, STR_INTEGER_P, STR_INTEGER_M, STR_TSKP, STR_TS, STR_NULL, RAW_INTEGER_P, RAW_INTEGER_M, RAW_TSK, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, RAW_NULL] + KO_TS = [STR_EMPTY, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_MISC, STR_OPTR, STR_TSK_MISC, STR_TSKP_MISC, STR_BOOL, STR_VARBIN, + STR_JSON_O, STR_JSON_A, STR_GEO, RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_MISC, RAW_OPTR, RAW_BOOL] + OK_BO = [STR_BOOL, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M,RAW_BOOL, STR_NULL, RAW_INTEGER_P, RAW_INTEGER_M, + RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_NULL] + KO_BO = [STR_EMPTY, STR_TSK, STR_TSKP, STR_TS, STR_MISC, STR_OPTR, STR_TSK_MISC, STR_TSKP_MISC, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK, + RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, RAW_MISC, RAW_OPTR] + OK_VB = [STR_EMPTY, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, + STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, STR_NULL, RAW_NULL] + KO_VB = [RAW_INTEGER_P, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_TSK, RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR] + OK_IN = [STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_NULL, RAW_INTEGER_P, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M, + RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_NULL] + KO_IN = [STR_EMPTY, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK, + RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR] + OK_UI = [STR_INTEGER_P, STR_FLOAT_P, STR_FLOAT_E_P, STR_NULL, RAW_INTEGER_P, RAW_FLOAT_P, RAW_FLOAT_E_P, RAW_NULL] + KO_UI = [STR_EMPTY, STR_MISC, STR_INTEGER_M, STR_FLOAT_M, STR_FLOAT_E_M, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, + STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK, RAW_BOOL, RAW_INTEGER_M, RAW_FLOAT_M, RAW_FLOAT_E_M, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR] + OK_FL = [RAW_INTEGER_P, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_NULL, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M, + RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_NULL] + KO_FL = [STR_EMPTY, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK, + RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR] + OK_DB = OK_FL + KO_DB = KO_FL + OK_GE = [STR_GEO, STR_NULL, RAW_NULL] + KO_GE = [STR_EMPTY, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_JSON_O, STR_JSON_A, STR_VARBIN, RAW_TSK, RAW_BOOL, RAW_MISC, + RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, RAW_INTEGER_P, RAW_INTEGER_M, + RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M] + OK_JS = [STR_EMPTY, STR_JSON_O, STR_NULL, RAW_NULL] + KO_JS = [STR_JSON_A, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_GEO, STR_VARBIN, RAW_TSK, RAW_BOOL, RAW_MISC, RAW_OPTR, + RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, RAW_INTEGER_P, RAW_INTEGER_M, + RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M] + + PARAM_LIST = [ + ["db", "stb_vc", "ctb_vc", OK_VC, KO_VC, "\'vc\'", TDDataType.VARCHAR], + ["db", "stb_nc", "ctb_nc", OK_NC, KO_NC, "\'nc\'", TDDataType.NCHAR], + ["db", "stb_ts", "ctb_ts", OK_TS, KO_TS, "now", TDDataType.TIMESTAMP], + ["db", "stb_bo", "ctb_bo", OK_BO, KO_BO, "true", TDDataType.BOOL], + ["db", "stb_vb", "ctb_vb", OK_VB, KO_VB, "\'\\x12\'", TDDataType.VARBINARY], + ["db", "stb_in", "ctb_in", OK_IN, KO_IN, "-1", TDDataType.UINT], + ["db", "stb_ui", "ctb_ui", OK_UI, KO_UI, "1", TDDataType.UINT], + ["db", "stb_fl", "ctb_fl", OK_FL, KO_FL, "1.0", TDDataType.FLOAT], + ["db", "stb_db", "ctb_db", OK_DB, KO_DB, "1.0", TDDataType.DOUBLE], + ["db", "stb_ge", "ctb_ge", OK_GE, KO_GE, "\'POINT(1.0 1.0)\'", TDDataType.GEOMETRY] + ] + + # check with common function + for _pl in PARAM_LIST: + self.__insert_query_common(_pl[0], _pl[1], _pl[2], _pl[3], _pl[4], _pl[5], _pl[6]) + # check json + self.__insert_query_json("db", "stb_js", "ctb_js", OK_JS, KO_JS, "\'{\"k1\":\"v1\",\"k2\":\"v2\"}\'") + + + def run(self): + tdLog.printNoPrefix("==========step1:create table") + self.__create_tb() + self.__insert_query_exec() + + + 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/2-query/count_partition.py b/tests/system-test/2-query/count_partition.py index e970b00cec..3077f5bb13 100644 --- a/tests/system-test/2-query/count_partition.py +++ b/tests/system-test/2-query/count_partition.py @@ -22,7 +22,7 @@ class TDTestCase: for i in range(tb_nums): tbname = f"{dbname}.sub_{stb_name}_{i}" ts = self.ts + i*10000 - tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )") + tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , %d , %f , %f , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )"%(i*10,i*1.0,i*1.0)) for row in range(row_nums): ts = self.ts + row*1000 diff --git a/tests/system-test/2-query/group_partition.py b/tests/system-test/2-query/group_partition.py index a20b124c33..36e3afd3ca 100644 --- a/tests/system-test/2-query/group_partition.py +++ b/tests/system-test/2-query/group_partition.py @@ -24,7 +24,7 @@ class TDTestCase: for i in range(self.tb_nums): tbname = f"{self.dbname}.sub_{self.stable}_{i}" ts = self.ts + i*10000 - tdSql.execute(f"create table {tbname} using {self.dbname}.{self.stable} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )") + tdSql.execute(f"create table {tbname} using {self.dbname}.{self.stable} tags ({ts} , {i} , %d ,%d , %f , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )"%(i*10,i*1.0,i*1.0)) def insert_db(self, tb_nums, row_nums): for i in range(tb_nums): diff --git a/tests/system-test/2-query/max_partition.py b/tests/system-test/2-query/max_partition.py index fbd3488aab..7e43597948 100644 --- a/tests/system-test/2-query/max_partition.py +++ b/tests/system-test/2-query/max_partition.py @@ -21,7 +21,7 @@ class TDTestCase: for i in range(tb_nums): tbname = f"{dbname}.sub_{stb_name}_{i}" ts = self.ts + i*1000*120 - tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )") + tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , %d , %f , %f , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )"%(i*10,i*1.0,i*1.0)) for row in range(row_nums): ts = ts + row*1000 diff --git a/tests/system-test/2-query/tagFilter.py b/tests/system-test/2-query/tagFilter.py index b03776c31b..a8106a7051 100644 --- a/tests/system-test/2-query/tagFilter.py +++ b/tests/system-test/2-query/tagFilter.py @@ -1,3 +1,4 @@ +import datetime from util.log import * from util.sql import * from util.cases import * @@ -52,6 +53,202 @@ class TDTestCase: ) tdSql.checkRows(0) + def __ts4421(self, dbname="db", stbname='stb4421', ctbname='ctb4421'): + TAG_BIND = [True, False] + TAG_TYPE = ['varchar', 'nchar'] + TAG_LEN = [2, 8, 200] + TAG_VAL_INT = [0, -200, 123456789] + TAG_VAL_STR = ["noW()", "now", "'now'", "todAy()", "today", "\"today\"" ] + TAG_VAL_BOOL_INT = [ -1, 1, 0, -0] + TAG_VAL_BOOL_STR = ["TrUe", "\"true\"","fALse", "'FALSE'"] + TAG_VAL_TIMESTAMP = ["now()", "NoW", "'now'", "\"now()\"", "toDay()", "toDaY", "'today'", "\"today()\"", "\"2200-01-01 08:00:00\"", "'2200-01-02'","\"2200-01-02T00:00:00.000Z\"", "'2200-01-02T00:00:00.000'", "2200-01-01 08:00:00", "\"2200-01-02'", "2200-01-02T00:00:00.000Z"] + TAG_RESULT_INT = [True,False,False,True,True,False,True,True,True,True,False,False,True,True,False,True,True,True] + TAG_RESULT_STR = [False,False,False,False,False,False,False,True,True,False,True,True,False,True,True,False,True,True,False,False,False,False,False,False,False,True,True,False,True,True,False,True,True,False,True,True] + TAG_RESULT_BOOL = ["True","True","False","False"] + TAG_RESULT_TIMESTAMP = [True, True, True, True, True, True, True, True, True, True, True, True, False, False, False] + + # check int for vartype(one tag) + nTagCtb = 0 + for tagType in TAG_TYPE: + for tagLen in TAG_LEN: + tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 %s(%d))'%(tagType,tagLen)) + for tagVal in TAG_VAL_INT: + for tagBind in TAG_BIND: + if tagBind == True: + bindStr = "(t1)" + else: + bindStr = "" + tdLog.info(f'nTagCtb={nTagCtb}, tagType={tagType}, tagLen = {tagLen}, tagVal = {tagVal}, tagBind={tagBind}') + if TAG_RESULT_INT[nTagCtb] == False: + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d)'%(bindStr,tagVal)) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d) values(now,1)'%(bindStr,tagVal)) + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d")'%(bindStr,tagVal)) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d") values(now,1)'%(bindStr,tagVal)) + tdSql.error(f"create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d')"%(bindStr,tagVal)) + tdSql.error(f"insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d') values(now,1)"%(bindStr,tagVal)) + else: + # integer as tag value + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d)'%(bindStr,tagVal)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)') + tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%d) values(now,1)'%(bindStr,tagVal)) + tdSql.query(f'select * from {dbname}.{stbname} where t1="%d"'%(tagVal)) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + # string as tag value + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d")'%(bindStr,tagVal)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)') + tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags("%d") values(now,1)'%(bindStr,tagVal)) + tdSql.query(f'select * from {dbname}.{stbname} where t1="%d"'%(tagVal)) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + tdSql.execute(f"create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d')"%(bindStr,tagVal)) + tdSql.execute(f"insert into {dbname}.{ctbname} values(now,1)") + tdSql.execute(f"insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags('%d') values(now,1)"%(bindStr,tagVal)) + tdSql.query(f"select * from {dbname}.{stbname} where t1='%d'"%(tagVal)) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + nTagCtb += 1 + tdSql.execute(f'drop table {dbname}.{stbname}') + + # check int for vartype(two tags/bind tags) + nTagCtb = 0 + for tagType in TAG_TYPE: + for tagLen in TAG_LEN: + tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 %s(%d),t2 %s(%d) )'%(tagType,tagLen,tagType,tagLen)) + for tagVal in TAG_VAL_INT: + for tagBind in TAG_BIND: + if tagBind == True: + bindStr = "(t1,t2)" + else: + bindStr = "" + if TAG_RESULT_INT[nTagCtb] == False: + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d,%d)'%(bindStr,tagVal,tagVal)) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d,%d) values(now,1)'%(bindStr,tagVal,tagVal)) + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d","%d")'%(bindStr,tagVal,tagVal)) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d","%d") values(now,1)'%(bindStr,tagVal,tagVal)) + tdSql.error(f"create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d','%d')"%(bindStr,tagVal,tagVal)) + tdSql.error(f"insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d','%d') values(now,1)"%(bindStr,tagVal,tagVal)) + else: + # integer as tag value + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d,%d)'%(bindStr,tagVal,tagVal)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)') + tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%d,%d) values(now,1)'%(bindStr,tagVal,tagVal)) + tdSql.query(f"select * from {dbname}.{stbname} where t1='%d' and t2='%d'"%(tagVal,tagVal)) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + # string as tag value + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d","%d")'%(bindStr,tagVal,tagVal)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)') + tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags("%d","%d") values(now,1)'%(bindStr,tagVal,tagVal)) + tdSql.query(f'select * from {dbname}.{stbname} where t1="%d" and t2="%d"'%(tagVal,tagVal)) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + tdSql.execute(f"create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d','%d')"%(bindStr,tagVal,tagVal)) + tdSql.execute(f"insert into {dbname}.{ctbname} values(now,1)") + tdSql.execute(f"insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags('%d','%d') values(now,1)"%(bindStr,tagVal,tagVal)) + tdSql.query(f"select * from {dbname}.{stbname} where t1='%d' and t2='%d'"%(tagVal,tagVal)) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + nTagCtb += 1 + tdSql.execute(f'drop table {dbname}.{stbname}') + + # check now/today for vartype + nTagCtb = 0 + for tagType in TAG_TYPE: + for tagLen in TAG_LEN: + tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 %s(%d))'%(tagType,tagLen)) + for tagVal in TAG_VAL_STR: + for tagBind in TAG_BIND: + if tagBind == True: + bindStr = "(t1)" + else: + bindStr = "" + if TAG_RESULT_STR[nTagCtb] == False: + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s)'%(bindStr,tagVal)) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s) values(now,1)'%(bindStr,tagVal)) + else: + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s)'%(bindStr,tagVal)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)') + tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%s) values(now,1)'%(bindStr,tagVal)) + if tagVal.startswith("'") or tagVal.startswith("\""): + tdSql.query(f'select * from {dbname}.{stbname} where t1=%s'%(tagVal)) + else: + tdSql.query(f'select * from {dbname}.{stbname} where t1=\"%s\"'%(tagVal)) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + nTagCtb += 1 + tdSql.execute(f'drop table {dbname}.{stbname}') + + # check int for bool + nTagCtb = 0 + tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 bool)') + for tagVal in TAG_VAL_BOOL_INT: + for tagBind in TAG_BIND: + if tagBind == True: + bindStr = "(t1)" + else: + bindStr = "" + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d)'%(bindStr,tagVal)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)') + tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%d) values(now,1)'%(bindStr,tagVal)) + tdSql.query(f'select * from {dbname}.{stbname} where t1=%s'%(TAG_RESULT_BOOL[nTagCtb])) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + nTagCtb += 1 + tdSql.execute(f'drop table {dbname}.{stbname}') + + # check str for bool + nTagCtb = 0 + tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 bool)') + for tagVal in TAG_VAL_BOOL_STR: + for tagBind in TAG_BIND: + if tagBind == True: + bindStr = "(t1)" + else: + bindStr = "" + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s)'%(bindStr,tagVal)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)') + tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%s) values(now,1)'%(bindStr,tagVal)) + tdSql.query(f'select * from {dbname}.{stbname} where t1=%s'%(TAG_RESULT_BOOL[nTagCtb])) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + nTagCtb += 1 + tdSql.execute(f'drop table {dbname}.{stbname}') + + # check misc for timestamp + nTagCtb = 0 + tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 timestamp)') + checkTS = datetime.datetime.today() - datetime.timedelta(days=1) + for tagVal in TAG_VAL_TIMESTAMP: + for tagBind in TAG_BIND: + if tagBind == True: + bindStr = "(t1)" + else: + bindStr = "" + if TAG_RESULT_TIMESTAMP[nTagCtb] == False: + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s)'%(bindStr,tagVal)) + tdSql.error(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%s) values(now,1)'%(bindStr,tagVal)) + else: + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s)'%(bindStr,tagVal)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)') + tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%s) values(now,1)'%(bindStr,tagVal)) + tdSql.query(f'select * from {dbname}.{stbname} where t1>"{checkTS}"') + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + nTagCtb += 1 + tdSql.execute(f'drop table {dbname}.{stbname}') + + def run(self): tdLog.printNoPrefix("==========step1:create table") self.__create_tb() @@ -59,9 +256,12 @@ class TDTestCase: tdLog.printNoPrefix("==========step2:query data") self.__query_data(10) + tdLog.printNoPrefix("==========step3:check ts4421") + self.__ts4421() + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/2-query/tsbsQuery.py b/tests/system-test/2-query/tsbsQuery.py index 5a49f653ec..60e710e4f1 100644 --- a/tests/system-test/2-query/tsbsQuery.py +++ b/tests/system-test/2-query/tsbsQuery.py @@ -33,7 +33,7 @@ class TDTestCase: for i in range(ctbNum): tagValue = 'beijing' if (i % 10 == 0): - sql += f" {dbName}.%s%d using %s (name,fleet,driver,device_version,load_capacity,fuel_capacity,nominal_fuel_consumption) tags('truck_%d', 'South%d','Trish%d','v2.%d', 1500+%d*20, 150+%d*2, 5+%d)"%(ctbPrefix,i,stbName,i,i,i,i,(1500+i*20),(150+i*2),(5+i)) + sql += f" {dbName}.%s%d using %s (name,fleet,driver,device_version,load_capacity,fuel_capacity,nominal_fuel_consumption) tags('truck_%d', 'South%d','Trish%d','v2.%d', %d, %d, %d)"%(ctbPrefix,i,stbName,i,i,i,i,1500+(1500+i*20)*20,150+(150+i*2)*2,5+(5+i)) else: model = 'H-%d'%i sql += f" {dbName}.%s%d using %s tags('truck_%d', 'South%d','Trish%d','%s','v2.%d', %d, %d,%d)"%(ctbPrefix,i,stbName,i,i,i,model,i,(1500+i*20),(150+i*2),(5+i)) diff --git a/tests/system-test/7-tmq/tmqParamsTest.py b/tests/system-test/7-tmq/tmqParamsTest.py index 82a5d42b47..b25f23ef11 100644 --- a/tests/system-test/7-tmq/tmqParamsTest.py +++ b/tests/system-test/7-tmq/tmqParamsTest.py @@ -164,7 +164,7 @@ class TDTestCase: offset_value_list = list(map(lambda x: (x[-2].replace("wal:", "").replace("earliest", "0").replace("latest", "0").replace(offset_value, "0")), subscription_info)) offset_value_list1 = list(map(lambda x: int(x.split("/")[0]), offset_value_list)) offset_value_list2 = list(map(lambda x: int(x.split("/")[1]), offset_value_list)) - tdSql.checkEqual(offset_value_list1 == offset_value_list2, True) + tdSql.checkEqual(offset_value_list1 <= offset_value_list2, True) tdSql.checkEqual(sum(offset_value_list1) >= 0, True) rows_value_list = list(map(lambda x: int(x[-1]), subscription_info)) tdSql.checkEqual(sum(rows_value_list), expected_res) @@ -187,4 +187,4 @@ class TDTestCase: event = threading.Event() tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/7-tmq/tmq_taosx.py b/tests/system-test/7-tmq/tmq_taosx.py index b8f3c944b0..94e9babf3c 100644 --- a/tests/system-test/7-tmq/tmq_taosx.py +++ b/tests/system-test/7-tmq/tmq_taosx.py @@ -16,6 +16,7 @@ sys.path.append("./7-tmq") from tmqCommon import * class TDTestCase: + updatecfgDict = {'debugFlag': 135, 'asynclog': 0} def init(self, conn, logSql, replicaVar=1): self.replicaVar = int(replicaVar) tdLog.debug(f"start to excute {__file__}") @@ -359,6 +360,44 @@ class TDTestCase: finally: consumer.close() + def consume_TS_4540_Test(self): + tdSql.execute(f'create database if not exists test') + tdSql.execute(f'use test') + tdSql.execute(f'CREATE STABLE `test`.`b` ( `time` TIMESTAMP , `task_id` NCHAR(1000) ) TAGS( `key` NCHAR(1000))') + tdSql.execute(f"insert into `test`.b1 using `test`.`b`(`key`) tags('1') (time, task_id) values ('2024-03-04 12:50:01.000', '32') `test`.b2 using `test`.`b`(`key`) tags('2') (time, task_id) values ('2024-03-04 12:50:01.000', '43') `test`.b3 using `test`.`b`(`key`) tags('3') (time, task_id) values ('2024-03-04 12:50:01.000', '123456')") + + tdSql.execute(f'create topic tt as select tbname,task_id,`key` from b') + + consumer_dict = { + "group.id": "g1", + "td.connect.user": "root", + "td.connect.pass": "taosdata", + "auto.offset.reset": "earliest", + } + consumer = Consumer(consumer_dict) + + try: + consumer.subscribe(["tt"]) + except TmqError: + tdLog.exit(f"subscribe error") + + try: + while True: + res = consumer.poll(1) + if not res: + break + val = res.value() + if val is None: + continue + for block in val: + data = block.fetchall() + print(data) + if data != [('b1', '32', '1')] and data != [('b2', '43', '2')] and data != [('b3', '123456', '3')]: + tdLog.exit(f"index = 0 table b1 error") + + finally: + consumer.close() + def consume_ts_4544(self): tdSql.execute(f'create database if not exists d1') tdSql.execute(f'use d1') @@ -369,6 +408,7 @@ class TDTestCase: tdSql.execute(f'insert into tt1 using stt tags(1) values(now+5s, 11) (now+10s, 12)') tdSql.execute(f'create topic topic_in as select * from stt where tbname in ("tt2")') + consumer_dict = { "group.id": "g1", "td.connect.user": "root", @@ -384,9 +424,37 @@ class TDTestCase: consumer.close() + def consume_ts_4551(self): + tdSql.execute(f'use d1') + + tdSql.execute(f'create topic topic_stable as stable stt where tbname like "t%"') + consumer_dict = { + "group.id": "g1", + "td.connect.user": "root", + "td.connect.pass": "taosdata", + "auto.offset.reset": "earliest", + } + consumer = Consumer(consumer_dict) + + try: + consumer.subscribe(["topic_stable"]) + except TmqError: + tdLog.exit(f"subscribe error") + + try: + while True: + res = consumer.poll(1) + if not res: + break + finally: + consumer.close() + print("consume_ts_4551 ok") + def run(self): self.consumeTest() self.consume_ts_4544() + self.consume_ts_4551() + self.consume_TS_4540_Test() tdSql.prepare() self.checkWal1VgroupOnlyMeta() diff --git a/tests/system-test/7-tmq/tmq_ts4563.py b/tests/system-test/7-tmq/tmq_ts4563.py new file mode 100644 index 0000000000..fc1cc259ce --- /dev/null +++ b/tests/system-test/7-tmq/tmq_ts4563.py @@ -0,0 +1,149 @@ + +import taos +import sys +import time +import socket +import os +import threading + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * +from taos.tmq import * +from taos import * + +sys.path.append("./7-tmq") +from tmqCommon import * + +class TDTestCase: + updatecfgDict = {'debugFlag': 143, 'asynclog': 0} + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + #tdSql.init(conn.cursor(), logSql) # output sql.txt file + + def consumeTest_TS_4563(self): + tdSql.execute(f'use db_stmt') + + tdSql.query("select ts,k from st") + tdSql.checkRows(2) + + tdSql.execute(f'create topic t_unorder_data as select ts,k from st') + consumer_dict = { + "group.id": "g1", + "td.connect.user": "root", + "td.connect.pass": "taosdata", + "auto.offset.reset": "earliest", + } + consumer = Consumer(consumer_dict) + + try: + consumer.subscribe(["t_unorder_data"]) + except TmqError: + tdLog.exit(f"subscribe error") + + cnt = 0 + try: + while True: + res = consumer.poll(1) + print(res) + if not res: + if cnt == 0: + tdLog.exit("consume error") + break + val = res.value() + if val is None: + continue + for block in val: + cnt += len(block.fetchall()) + + if cnt != 2: + tdLog.exit("consume error") + + finally: + consumer.close() + + 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 or "taosd.exe" 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 newcon(self,host,cfg): + user = "root" + password = "taosdata" + port =6030 + con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) + print(con) + return con + + def test_stmt_insert_multi(self,conn): + # type: (TaosConnection) -> None + + dbname = "db_stmt" + try: + conn.execute("drop database if exists %s" % dbname) + conn.execute("create database if not exists %s" % dbname) + conn.select_db(dbname) + + conn.execute( + "create table st(ts timestamp, i int, j int, k int)", + ) + # conn.load_table_info("log") + tdLog.debug("statement start") + start = datetime.now() + stmt = conn.statement("insert into st(ts,j) values(?, ?)") + + params = new_multi_binds(2) + params[0].timestamp((1626861392589, 1626861392590)) + params[1].int([3, None]) + + # print(type(stmt)) + tdLog.debug("bind_param_batch start") + stmt.bind_param_batch(params) + tdLog.debug("bind_param_batch end") + stmt.execute() + tdLog.debug("execute end") + end = datetime.now() + print("elapsed time: ", end - start) + assert stmt.affected_rows == 2 + tdLog.debug("close start") + + stmt.close() + + # conn.execute("drop database if exists %s" % dbname) + conn.close() + + except Exception as err: + # conn.execute("drop database if exists %s" % dbname) + conn.close() + raise err + + def run(self): + buildPath = self.getBuildPath() + config = buildPath+ "../sim/dnode1/cfg/" + host="localhost" + connectstmt=self.newcon(host,config) + self.test_stmt_insert_multi(connectstmt) + self.consumeTest_TS_4563() + + + 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/runAllOne.sh b/tests/system-test/runAllOne.sh index 6d4c80c388..099ae1bbd3 100644 --- a/tests/system-test/runAllOne.sh +++ b/tests/system-test/runAllOne.sh @@ -22,6 +22,7 @@ python3 ./test.py -f 1-insert/update_data_muti_rows.py -P python3 ./test.py -f 1-insert/db_tb_name_check.py -P python3 ./test.py -f 1-insert/InsertFuturets.py -P python3 ./test.py -f 1-insert/insert_wide_column.py -P +python3 ./test.py -f 1-insert/insert_column_value.py python3 ./test.py -f 2-query/nestedQuery.py -P python3 ./test.py -f 2-query/nestedQuery_str.py -P python3 ./test.py -f 2-query/nestedQuery_math.py -P diff --git a/tests/system-test/win-test-file b/tests/system-test/win-test-file index 1ab0fee7bf..96f9452827 100644 --- a/tests/system-test/win-test-file +++ b/tests/system-test/win-test-file @@ -233,6 +233,7 @@ python3 ./test.py -f 1-insert/update_data_muti_rows.py python3 ./test.py -f 1-insert/db_tb_name_check.py python3 ./test.py -f 1-insert/InsertFuturets.py python3 ./test.py -f 1-insert/insert_wide_column.py +python3 ./test.py -f 1-insert/insert_column_value.py python3 ./test.py -f 1-insert/rowlength64k_benchmark.py python3 ./test.py -f 1-insert/rowlength64k.py python3 ./test.py -f 1-insert/rowlength64k.py -R diff --git a/tools/shell/inc/shellAuto.h b/tools/shell/inc/shellAuto.h index 6a317fe5c9..bcf500fefc 100644 --- a/tools/shell/inc/shellAuto.h +++ b/tools/shell/inc/shellAuto.h @@ -39,7 +39,10 @@ void shellAutoExit(); void callbackAutoTab(char* sqlstr, TAOS* pSql, bool usedb); // introduction -void printfIntroduction(); +void printfIntroduction(bool community); + +// show enterprise AD at start or end +void showAD(bool end); // show all commands help void showHelp(); diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 847bbcf4be..6c3716519b 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -400,27 +400,41 @@ SMatch* lastMatch = NULL; // save last match result int cntDel = 0; // delete byte count after next press tab // show auto tab introduction -void printfIntroduction() { - printf(" ******************************** Tab Completion ************************************\n"); +void printfIntroduction(bool community) { + printf(" ********************************* Tab Completion *************************************\n"); char secondLine[160] = "\0"; sprintf(secondLine, " * The %s CLI supports tab completion for a variety of items, ", shell.info.cusName); printf("%s", secondLine); int secondLineLen = strlen(secondLine); - while (87 - (secondLineLen++) > 0) { + while (89 - (secondLineLen++) > 0) { printf(" "); } printf("*\n"); - printf(" * including database names, table names, function names and keywords. *\n"); - printf(" * The full list of shortcut keys is as follows: *\n"); - printf(" * [ TAB ] ...... complete the current word *\n"); - printf(" * ...... if used on a blank line, display all supported commands *\n"); - printf(" * [ Ctrl + A ] ...... move cursor to the st[A]rt of the line *\n"); - printf(" * [ Ctrl + E ] ...... move cursor to the [E]nd of the line *\n"); - printf(" * [ Ctrl + W ] ...... move cursor to the middle of the line *\n"); - printf(" * [ Ctrl + L ] ...... clear the entire screen *\n"); - printf(" * [ Ctrl + K ] ...... clear the screen after the cursor *\n"); - printf(" * [ Ctrl + U ] ...... clear the screen before the cursor *\n"); - printf(" **************************************************************************************\n\n"); + printf(" * including database names, table names, function names and keywords. *\n"); + printf(" * The full list of shortcut keys is as follows: *\n"); + printf(" * [ TAB ] ...... complete the current word *\n"); + printf(" * ...... if used on a blank line, display all supported commands *\n"); + printf(" * [ Ctrl + A ] ...... move cursor to the st[A]rt of the line *\n"); + printf(" * [ Ctrl + E ] ...... move cursor to the [E]nd of the line *\n"); + printf(" * [ Ctrl + W ] ...... move cursor to the middle of the line *\n"); + printf(" * [ Ctrl + L ] ...... clear the entire screen *\n"); + printf(" * [ Ctrl + K ] ...... clear the screen after the cursor *\n"); + printf(" * [ Ctrl + U ] ...... clear the screen before the cursor *\n"); + if(community) { + printf(" * ------------------------------------------------------------------------------------ *\n"); + printf(" * You are using TDengine OSS. To experience advanced features, like backup/restore, *\n"); + printf(" * privilege control and more, or receive 7x24 technical support, try TDengine *\n"); + printf(" * Enterprise or Free Cloud Trial. Learn more at https://tdengine.com *\n"); + } + printf(" ****************************************************************************************\n\n"); +} + +// show enterprise AD +void showAD(bool end) { + printf(" You are using TDengine OSS. To experience advanced features, like backup/restore, \n"); + printf(" privilege control and more, or receive 7x24 technical support, try TDengine Enterprise \n"); + printf(" or Free Cloud Trial. Learn more at https://tdengine.com \n"); + printf(" \n"); } void showHelp() { @@ -1852,6 +1866,9 @@ _return: // main key press tab void pressTabKey(SShellCmd* cmd) { +#ifdef WINDOWS + return ; +#endif // check empty tab key if (cmd->commandSize == 0) { // have multi line tab key @@ -1895,6 +1912,10 @@ void pressTabKey(SShellCmd* cmd) { // press othr key void pressOtherKey(char c) { +#ifdef WINDOWS + return ; +#endif + // reset global variant firstMatchIndex = -1; lastMatchIndex = -1; diff --git a/tools/shell/src/shellCommand.c b/tools/shell/src/shellCommand.c index c6459c4590..265dc4530f 100644 --- a/tools/shell/src/shellCommand.c +++ b/tools/shell/src/shellCommand.c @@ -445,7 +445,7 @@ char taosGetConsoleChar() { static char mbStr[5]; static unsigned long bufLen = 0; static uint16_t bufIndex = 0, mbStrIndex = 0, mbStrLen = 0; - CONSOLE_READCONSOLE_CONTROL inputControl={ sizeof(CONSOLE_READCONSOLE_CONTROL), 0, 1< 0 && buf[0] == 0) bufLen = 0; @@ -500,13 +500,11 @@ int32_t shellReadCommand(char *command) { } shellInsertChar(&cmd, utf8_array, count); pressOtherKey(c); -#ifndef WINDOWS } else if (c == TAB_KEY) { // press TAB key pressTabKey(&cmd); -#endif } else if (c < '\033') { - pressOtherKey(c); + pressOtherKey(c); // Ctrl keys. TODO: Implement ctrl combinations switch (c) { case 0: diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 995d3d04ec..8c78a94de6 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -56,7 +56,7 @@ static void shellWriteHistory(); static void shellPrintError(TAOS_RES *tres, int64_t st); static bool shellIsCommentLine(char *line); static void shellSourceFile(const char *file); -static void shellGetGrantInfo(); +static bool shellGetGrantInfo(); static void shellCleanup(void *arg); static void *shellCancelHandler(void *arg); @@ -1150,8 +1150,9 @@ void shellSourceFile(const char *file) { taosCloseFile(&pFile); } -void shellGetGrantInfo() { - char sinfo[1024] = {0}; +bool shellGetGrantInfo(char* buf) { + bool community = true; + char sinfo[256] = {0}; tstrncpy(sinfo, taos_get_server_info(shell.conn), sizeof(sinfo)); strtok(sinfo, "\r\n"); @@ -1165,7 +1166,7 @@ void shellGetGrantInfo() { code != TSDB_CODE_PAR_PERMISSION_DENIED) { fprintf(stderr, "Failed to check Server Edition, Reason:0x%04x:%s\r\n\r\n", code, taos_errstr(tres)); } - return; + return community; } int32_t num_fields = taos_field_count(tres); @@ -1194,11 +1195,13 @@ void shellGetGrantInfo() { memcpy(expired, row[2], fields[2].bytes); if (strcmp(serverVersion, "community") == 0) { - fprintf(stdout, "Server is Community Edition.\r\n"); + community = true; } else if (strcmp(expiretime, "unlimited") == 0) { - fprintf(stdout, "Server is Enterprise %s Edition, %s and will never expire.\r\n", serverVersion, sinfo); + community = false; + sprintf(buf, "Server is Enterprise %s Edition, %s and will never expire.\r\n", serverVersion, sinfo); } else { - fprintf(stdout, "Server is Enterprise %s Edition, %s and will expire at %s.\r\n", serverVersion, sinfo, + community = false; + sprintf(buf, "Server is Enterprise %s Edition, %s and will expire at %s.\r\n", serverVersion, sinfo, expiretime); } @@ -1206,6 +1209,7 @@ void shellGetGrantInfo() { } fprintf(stdout, "\r\n"); + return community; } #ifdef WINDOWS @@ -1364,10 +1368,23 @@ int32_t shellExecute() { #ifdef WEBSOCKET if (!shell.args.restful && !shell.args.cloud) { #endif +char* buf = taosMemoryMalloc(512); +bool community = shellGetGrantInfo(buf); #ifndef WINDOWS - printfIntroduction(); + printfIntroduction(community); +#else +#ifndef WEBSOCKET + if(community) { + showAD(false); + } +#endif #endif - shellGetGrantInfo(); +// printf version +if(!community) { + printf("%s\n", buf); +} +taosMemoryFree(buf); + #ifdef WEBSOCKET } #endif @@ -1380,6 +1397,13 @@ int32_t shellExecute() { break; } } +#ifndef WEBSOCKET + // commnuity + if (community) { + showAD(true); + } +#endif + taosThreadJoin(spid, NULL); shellCleanupHistory(); diff --git a/tools/shell/src/shellWebsocket.c b/tools/shell/src/shellWebsocket.c index 2d3aa27a3b..fc7c914c21 100644 --- a/tools/shell/src/shellWebsocket.c +++ b/tools/shell/src/shellWebsocket.c @@ -77,7 +77,7 @@ int shell_conn_ws_server(bool first) { } fprintf(stdout, "successfully connected to %s\n", host); } else { - fprintf(stdout, "successfully connected to cloud service\n"); + fprintf(stdout, "successfully connected to service\n"); } } fflush(stdout);