diff --git a/.github/workflows/taoskeeper-ci.yml b/.github/workflows/taoskeeper-ci.yml index 38dfb6d43c0..fbc662ffb21 100644 --- a/.github/workflows/taoskeeper-ci.yml +++ b/.github/workflows/taoskeeper-ci.yml @@ -28,7 +28,7 @@ jobs: run: | mkdir debug cd debug - cmake .. -DBUILD_HTTP=false -DBUILD_JDBC=false -DBUILD_TOOLS=false -DBUILD_TEST=off -DBUILD_KEEPER=true + cmake .. -DBUILD_HTTP=false -DBUILD_JDBC=false -DBUILD_TOOLS=false -DBUILD_TEST=off -DBUILD_KEEPER=true -DBUILD_DEPENDENCY_TESTS=false make -j 4 sudo make install which taosd @@ -48,7 +48,7 @@ jobs: working-directory: tools/keeper run: | go mod tidy - go test -v -coverpkg=./... -coverprofile=coverage.out ./... + sudo go test -v -ldflags="-X 'github.com/taosdata/taoskeeper/version.IsEnterprise=true'" -coverpkg=./... -coverprofile=coverage.out ./... go tool cover -func=coverage.out - name: Clean up diff --git a/cmake/cmake.define b/cmake/cmake.define index 3fa99a7c932..ff582261b30 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -191,48 +191,11 @@ ELSE() SET(COMPILER_SUPPORT_AVX512VL false) ELSE() CHECK_C_COMPILER_FLAG("-mfma" COMPILER_SUPPORT_FMA) + CHECK_C_COMPILER_FLAG("-mavx" COMPILER_SUPPORT_AVX) + CHECK_C_COMPILER_FLAG("-mavx2" COMPILER_SUPPORT_AVX2) CHECK_C_COMPILER_FLAG("-mavx512f" COMPILER_SUPPORT_AVX512F) CHECK_C_COMPILER_FLAG("-mavx512vbmi" COMPILER_SUPPORT_AVX512BMI) CHECK_C_COMPILER_FLAG("-mavx512vl" COMPILER_SUPPORT_AVX512VL) - - INCLUDE(CheckCSourceRuns) - SET(CMAKE_REQUIRED_FLAGS "-mavx") - check_c_source_runs(" - #include - int main() { - __m256d a, b, c; - double buf[4] = {0}; - a = _mm256_loadu_pd(buf); - b = _mm256_loadu_pd(buf); - c = _mm256_add_pd(a, b); - _mm256_storeu_pd(buf, c); - for (int i = 0; i < sizeof(buf) / sizeof(buf[0]); ++i) { - IF (buf[i] != 0) { - return 1; - } - } - return 0; - } - " COMPILER_SUPPORT_AVX) - - SET(CMAKE_REQUIRED_FLAGS "-mavx2") - check_c_source_runs(" - #include - int main() { - __m256i a, b, c; - int buf[8] = {0}; - a = _mm256_loadu_si256((__m256i *)buf); - b = _mm256_loadu_si256((__m256i *)buf); - c = _mm256_and_si256(a, b); - _mm256_storeu_si256((__m256i *)buf, c); - for (int i = 0; i < sizeof(buf) / sizeof(buf[0]); ++i) { - IF (buf[i] != 0) { - return 1; - } - } - return 0; - } - " COMPILER_SUPPORT_AVX2) ENDIF() IF(COMPILER_SUPPORT_SSE42) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index eae697560b6..a9e51b7249f 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -261,11 +261,19 @@ if(${TD_DARWIN}) endif(${TD_DARWIN}) add_subdirectory(zlib EXCLUDE_FROM_ALL) + +if(${TD_DARWIN}) + target_compile_options(zlibstatic PRIVATE -Wno-error=deprecated-non-prototype) +endif() target_include_directories( zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/zlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/zlib ) + +if(${TD_DARWIN}) + target_compile_options(zlib PRIVATE -Wno-error=deprecated-non-prototype) +endif() target_include_directories( zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/zlib diff --git a/docs/en/03-intro.md b/docs/en/03-intro.md index 4e0089950a6..853e96704fc 100644 --- a/docs/en/03-intro.md +++ b/docs/en/03-intro.md @@ -46,7 +46,7 @@ For more details on features, please read through the entire documentation. By making full use of [characteristics of time series data](https://tdengine.com/characteristics-of-time-series-data/), TDengine differentiates itself from other time series databases with the following advantages. -- **[High-Performance](https://tdengine.com/high-performance/)**: TDengine is the only time-series database to solve the high cardinality issue to support billions of data collection points while out performing other time-series databases for data ingestion, querying and data compression. +- **[High-Performance](https://tdengine.com/high-performance/)**: TDengine is the only time-series database to solve the high cardinality issue to support billions of data collection points while outperforming other time-series databases for data ingestion, querying and data compression. - **[Simplified Solution](https://tdengine.com/comprehensive-industrial-data-solution/)**: Through built-in caching, stream processing and data subscription features, TDengine provides a simplified solution for time-series data processing. It reduces system design complexity and operation costs significantly. diff --git a/docs/en/14-reference/03-taos-sql/10-function.md b/docs/en/14-reference/03-taos-sql/10-function.md index 2ba3c416fdf..d2efd668b00 100644 --- a/docs/en/14-reference/03-taos-sql/10-function.md +++ b/docs/en/14-reference/03-taos-sql/10-function.md @@ -1187,7 +1187,7 @@ CSUM(expr) ### DERIVATIVE ```sql -DERIVATIVE(expr, time_inerval, ignore_negative) +DERIVATIVE(expr, time_interval, ignore_negative) ignore_negative: { 0 diff --git a/docs/en/14-reference/03-taos-sql/31-compress.md b/docs/en/14-reference/03-taos-sql/31-compress.md index 10a06a4c91c..39abfe69bd7 100644 --- a/docs/en/14-reference/03-taos-sql/31-compress.md +++ b/docs/en/14-reference/03-taos-sql/31-compress.md @@ -41,7 +41,7 @@ In this article, it specifically refers to the level within the secondary compre ### Create Table with Compression ```sql -CREATE [dbname.]tabname (colName colType [ENCODE 'encode_type'] [COMPRESS 'compress_type' [LEVEL 'level'], [, other cerate_definition]...]) +CREATE [dbname.]tabname (colName colType [ENCODE 'encode_type'] [COMPRESS 'compress_type' [LEVEL 'level'], [, other create_definition]...]) ``` **Parameter Description** @@ -58,7 +58,7 @@ CREATE [dbname.]tabname (colName colType [ENCODE 'encode_type'] [COMPRESS 'compr ### Change Compression Method ```sql -ALTER TABLE [db_name.]tabName MODIFY COLUMN colName [ENCODE 'ecode_type'] [COMPRESS 'compress_type'] [LEVEL "high"] +ALTER TABLE [db_name.]tabName MODIFY COLUMN colName [ENCODE 'encode_type'] [COMPRESS 'compress_type'] [LEVEL "high"] ``` **Parameter Description** diff --git a/docs/en/14-reference/05-connectors/60-rest-api.mdx b/docs/en/14-reference/05-connectors/60-rest-api.mdx index 2c3cd21f414..a29751e951a 100644 --- a/docs/en/14-reference/05-connectors/60-rest-api.mdx +++ b/docs/en/14-reference/05-connectors/60-rest-api.mdx @@ -125,7 +125,7 @@ where `TOKEN` is the string after Base64 encoding of `{username}:{password}`, e. Starting from `TDengine 3.0.3.0`, `taosAdapter` provides a configuration parameter `httpCodeServerError` to set whether to return a non-200 http status code when the C interface returns an error | **Description** | **httpCodeServerError false** | **httpCodeServerError true** | -|--------------------|---------------------------- ------|---------------------------------------| +|--------------------|----------------------------------|---------------------------------------| | taos_errno() returns 0 | 200 | 200 | | taos_errno() returns non-0 | 200 (except authentication error) | 500 (except authentication error and 400/502 error) | | Parameter error | 400 (only handle HTTP request URL parameter error) | 400 (handle HTTP request URL parameter error and taosd return error) | diff --git a/docs/en/14-reference/12-config/index.md b/docs/en/14-reference/12-config/index.md index 14a1a0fb9d9..77d183a5ef7 100755 --- a/docs/en/14-reference/12-config/index.md +++ b/docs/en/14-reference/12-config/index.md @@ -701,15 +701,6 @@ The charset that takes effect is UTF-8. | Type | String | | Default Value | _tag_null | -### smlDataFormat - -| Attribute | Description | -| ----------- | ----------------------------------------------------------------------------------- | -| Applicable | Client only | -| Meaning | Whether schemaless columns are consistently ordered, depat, discarded since 3.0.3.0 | -| Value Range | 0: not consistent; 1: consistent. | -| Default | 0 | - ### smlTsDefaultName | Attribute | Description | @@ -719,6 +710,16 @@ The charset that takes effect is UTF-8. | Type | String | | Default Value | _ts | +### smlDot2Underline + +| Attribute | Description | +| -------- | -------------------------------------------------------- | +| Applicable | Client only | +| Meaning | Convert the dot in the supertable name to an underscore | +| Type | Bool | +| Default Value | true | + + ## Compress Parameters ### compressMsgSize diff --git a/docs/en/26-tdinternal/04-load-balance.md b/docs/en/26-tdinternal/04-load-balance.md index 474272c46d2..c7aca23cc9d 100644 --- a/docs/en/26-tdinternal/04-load-balance.md +++ b/docs/en/26-tdinternal/04-load-balance.md @@ -4,7 +4,7 @@ sidebar_label: Load Balance description: This document describes how TDengine implements load balancing. --- -The load balance in TDengine is mainly about processing data series data. TDengine employes builtin hash algorithm to distribute all the tables, sub-tables and their data of a database across all the vgroups that belongs to the database. Each table or sub-table can only be handled by a single vgroup, while each vgroup can process multiple table or sub-table. +The load balance in TDengine is mainly about processing data series data. TDengine employs builtin hash algorithm to distribute all the tables, sub-tables and their data of a database across all the vgroups that belongs to the database. Each table or sub-table can only be handled by a single vgroup, while each vgroup can process multiple table or sub-table. The number of vgroup can be specified when creating a database, using the parameter `vgroups`. @@ -12,10 +12,10 @@ The number of vgroup can be specified when creating a database, using the parame create database db0 vgroups 100; ``` -The proper value of `vgroups` depends on available system resources. Assuming there is only one database to be created in the system, then the number of `vgroups` is determined by the available resources from all dnodes. In principle more vgroups can be created if you have more CPU and memory. Disk I/O is another important factor to consider. Once the bottleneck shows on disk I/O, more vgroups may downgrad the system performance significantly. If multiple databases are to be created in the system, then the total number of `vroups` of all the databases are dependent on the available system resources. It needs to be careful to distribute vgroups among these databases, you need to consider the number of tables, data writing frequency, size of each data row for all these databases. A recommended practice is to firstly choose a starting number for `vgroups`, for example double of the number of CPU cores, then try to adjust and optimize system configurations to find the best setting for `vgroups`, then distribute these vgroups among databases. +The proper value of `vgroups` depends on available system resources. Assuming there is only one database to be created in the system, then the number of `vgroups` is determined by the available resources from all dnodes. In principle more vgroups can be created if you have more CPU and memory. Disk I/O is another important factor to consider. Once the bottleneck shows on disk I/O, more vgroups may degrade the system performance significantly. If multiple databases are to be created in the system, then the total number of `vgroups` of all the databases are dependent on the available system resources. It needs to be careful to distribute vgroups among these databases, you need to consider the number of tables, data writing frequency, size of each data row for all these databases. A recommended practice is to firstly choose a starting number for `vgroups`, for example double of the number of CPU cores, then try to adjust and optimize system configurations to find the best setting for `vgroups`, then distribute these vgroups among databases. -Furthermode, TDengine distributes the vgroups of each database equally among all dnodes. In case of replica 3, the distribution is even more complex, TDengine tries its best to prevent any dnode from becoming a bottleneck. +Furthermore, TDengine distributes the vgroups of each database equally among all dnodes. In case of replica 3, the distribution is even more complex, TDengine tries its best to prevent any dnode from becoming a bottleneck. -TDegnine utilizes the above ways to achieve load balance in a cluster, and finally achieve higher throughput. +TDengine utilizes the above ways to achieve load balance in a cluster, and finally achieve higher throughput. Once the load balance is achieved, after some operations like deleting tables or dropping databases, the load across all dnodes may become imbalanced, the method of rebalance will be provided in later versions. However, even without explicit rebalancing, TDengine will try its best to achieve new balance without manual interfering when a new database is created. diff --git a/docs/examples/JDBC/taosdemo/readme.md b/docs/examples/JDBC/taosdemo/readme.md index 141391d1f61..82aba4d9c1c 100644 --- a/docs/examples/JDBC/taosdemo/readme.md +++ b/docs/examples/JDBC/taosdemo/readme.md @@ -7,8 +7,4 @@ java -jar target/taosdemo-2.0.1-jar-with-dependencies.jar -host -data java -jar target/taosdemo-2.0.1-jar-with-dependencies.jar -host -database -doCreateTable false -superTableSQL "create table weather(ts timestamp, f1 int) tags(t1 nchar(4))" -numOfTables 1000 -numOfRowsPerTable 100000000 -numOfThreadsForInsert 10 -numOfTablesPerSQL 10 -numOfValuesPerSQL 100 ``` -如果发生错误 Exception in thread "main" java.lang.UnsatisfiedLinkError: no taos in java.library.path -请检查是否安装 TDengine 客户端安装包或编译 TDengine 安装。如果确定已经安装过还出现这个错误,可以在命令行 java 后加 -Djava.library.path=/usr/lib 来指定寻找共享库的路径。 - - If you encounter the error Exception in thread "main" `java.lang.UnsatisfiedLinkError: no taos in java.library.path`, please check whether the TDengine client package is installed or TDengine is compiled and installed. If you are sure it is installed and still encounter this error, you can add `-Djava.library.path=/usr/lib` after the `java` command to specify the path to the shared library. diff --git a/docs/examples/node/package.json b/docs/examples/node/package.json index 3f5f54e9d7c..14303c8f374 100644 --- a/docs/examples/node/package.json +++ b/docs/examples/node/package.json @@ -4,6 +4,6 @@ "main": "index.js", "license": "MIT", "dependencies": { - "@tdengine/websocket": "^3.1.0" + "@tdengine/websocket": "^3.1.1" } } diff --git a/docs/examples/node/websocketexample/sql_example.js b/docs/examples/node/websocketexample/sql_example.js index 0a09228d970..c120b84d99f 100644 --- a/docs/examples/node/websocketexample/sql_example.js +++ b/docs/examples/node/websocketexample/sql_example.js @@ -3,7 +3,6 @@ const taos = require("@tdengine/websocket"); let dsn = 'ws://localhost:6041'; async function createConnect() { - try { let conf = new taos.WSConfig(dsn); conf.setUser('root'); diff --git a/docs/examples/node/websocketexample/tmq_seek_example.js b/docs/examples/node/websocketexample/tmq_seek_example.js index f676efe36f6..be4d8ddfa4a 100644 --- a/docs/examples/node/websocketexample/tmq_seek_example.js +++ b/docs/examples/node/websocketexample/tmq_seek_example.js @@ -10,7 +10,6 @@ const groupId = "group1"; const clientId = "client1"; async function createConsumer() { - let groupId = "group1"; let clientId = "client1"; let configMap = new Map([ diff --git a/docs/zh/05-basic/03-query.md b/docs/zh/05-basic/03-query.md index 6afdba0997b..b6f172829ae 100644 --- a/docs/zh/05-basic/03-query.md +++ b/docs/zh/05-basic/03-query.md @@ -8,7 +8,7 @@ toc_max_heading_level: 4 ## 基本查询 -为了更好的介绍 TDengine 数据查询,使用 如下 taosBenchmark 命令,生成本章内容需要的时序数据。 +为了更好的介绍 TDengine 数据查询,使用如下 taosBenchmark 命令,生成本章内容需要的时序数据。 ```shell taosBenchmark --start-timestamp=1600000000000 --tables=100 --records=10000000 --time-step=10000 @@ -20,21 +20,22 @@ taosBenchmark --start-timestamp=1600000000000 --tables=100 --records=10000000 -- ```sql SELECT * FROM meters -WHERE voltage > 10 +WHERE voltage > 230 ORDER BY ts DESC -LIMIT 5 +LIMIT 5; ``` -上面的 SQL,从超级表 `meters` 中查询出电压 `voltage` 大于 10 的记录,按时间降序排列,且仅输出前 5 行。查询结果如下: +上面的 SQL,从超级表 `meters` 中查询出电压 `voltage` 大于 230V 的记录,按时间降序排列,且仅输出前 5 行。查询结果如下: ```text - ts | current | voltage | phase | groupid | location | -========================================================================================================== -2023-11-14 22:13:10.000 | 1.1294620 | 18 | 0.3531540 | 8 | California.MountainView | -2023-11-14 22:13:10.000 | 1.0294620 | 12 | 0.3631540 | 2 | California.Campbell | -2023-11-14 22:13:10.000 | 1.0294620 | 16 | 0.3531540 | 1 | California.Campbell | -2023-11-14 22:13:10.000 | 1.1294620 | 18 | 0.3531540 | 2 | California.Campbell | -2023-11-14 22:13:10.000 | 1.1294620 | 16 | 0.3431540 | 7 | California.PaloAlto | + ts | current | voltage | phase | groupid | location | +=================================================================================================== +2023-11-15 06:13:10.000 | 14.0601978 | 232 | 146.5000000 | 10 | California.Sunnyvale | +2023-11-15 06:13:10.000 | 14.0601978 | 232 | 146.5000000 | 1 | California.LosAngles | +2023-11-15 06:13:10.000 | 14.0601978 | 232 | 146.5000000 | 10 | California.Sunnyvale | +2023-11-15 06:13:10.000 | 14.0601978 | 232 | 146.5000000 | 5 | California.Cupertino | +2023-11-15 06:13:10.000 | 14.0601978 | 232 | 146.5000000 | 4 | California.SanFrancisco | +Query OK, 5 row(s) in set (0.145403s) ``` ## 聚合查询 @@ -48,28 +49,28 @@ TDengine 支持通过 GROUP BY 子句,对数据进行聚合查询。SQL 语句 group by 子句用于对数据进行分组,并为每个分组返回一行汇总信息。在 group by 子句中,可以使用表或视图中的任何列作为分组依据,这些列不需要出现在 select 列表中。此外,用户可以直接在超级表上执行聚合查询,无须预先创建子表。以智能电表的数据模型为例,使用 group by 子句的 SQL 如下: ```sql -SELECT groupid,avg(voltage) +SELECT groupid, avg(voltage) FROM meters WHERE ts >= "2022-01-01T00:00:00+08:00" AND ts < "2023-01-01T00:00:00+08:00" -GROUP BY groupid +GROUP BY groupid; ``` 上面的 SQL,查询超级表 `meters` 中,时间戳大于等于 `2022-01-01T00:00:00+08:00`,且时间戳小于 `2023-01-01T00:00:00+08:00` 的数据,按照 `groupid` 进行分组,求每组的平均电压。查询结果如下: ```text - groupid | avg(voltage) | -========================================== - 8 | 9.104040404040404 | - 5 | 9.078333333333333 | - 1 | 9.087037037037037 | - 7 | 8.991414141414142 | - 9 | 8.789814814814815 | - 6 | 9.051010101010101 | - 4 | 9.135353535353536 | - 10 | 9.213131313131314 | - 2 | 9.008888888888889 | - 3 | 8.783888888888889 | + groupid | avg(voltage) | +====================================== + 8 | 243.961981544901079 | + 5 | 243.961981544901079 | + 1 | 243.961981544901079 | + 7 | 243.961981544901079 | + 9 | 243.961981544901079 | + 6 | 243.961981544901079 | + 4 | 243.961981544901079 | + 10 | 243.961981544901079 | + 2 | 243.961981544901079 | + 3 | 243.961981544901079 | Query OK, 10 row(s) in set (0.042446s) ``` @@ -110,24 +111,24 @@ TDengine 按如下方式处理数据切分子句。 ```sql SELECT location, avg(voltage) FROM meters -PARTITION BY location +PARTITION BY location; ``` 上面的示例 SQL 查询超级表 `meters`,将数据按标签 `location` 进行分组,每个分组计算电压的平均值。查询结果如下: ```text - location | avg(voltage) | -========================================================= - California.SantaClara | 8.793334320000000 | - California.SanFrancisco | 9.017645882352941 | - California.SanJose | 9.156112940000000 | - California.LosAngles | 9.036753507692307 | - California.SanDiego | 8.967037053333334 | - California.Sunnyvale | 8.978572085714285 | - California.PaloAlto | 8.936665800000000 | - California.Cupertino | 8.987654066666666 | - California.MountainView | 9.046297266666667 | - California.Campbell | 9.149999028571429 | + location | avg(voltage) | +====================================================== + California.SantaClara | 243.962050000000005 | + California.SanFrancisco | 243.962050000000005 | + California.SanJose | 243.962050000000005 | + California.LosAngles | 243.962050000000005 | + California.SanDiego | 243.962050000000005 | + California.Sunnyvale | 243.962050000000005 | + California.PaloAlto | 243.962050000000005 | + California.Cupertino | 243.962050000000005 | + California.MountainView | 243.962050000000005 | + California.Campbell | 243.962050000000005 | Query OK, 10 row(s) in set (2.415961s) ``` @@ -200,20 +201,20 @@ SLIMIT 2; 上面的 SQL,查询超级表 `meters` 中,时间戳大于等于 `2022-01-01T00:00:00+08:00`,且时间戳小于 `2022-01-01T00:05:00+08:00` 的数据;数据首先按照子表名 `tbname` 进行数据切分,再按照每 1 分钟的时间窗口进行切分,且每个时间窗口向后偏移 5 秒;最后,仅取前 2 个分片的数据作为结果。查询结果如下: ```text - tbname | _wstart | _wend | avg(voltage) | -========================================================================================== - d40 | 2021-12-31 15:59:05.000 | 2021-12-31 16:00:05.000 | 4.000000000000000 | - d40 | 2021-12-31 16:00:05.000 | 2021-12-31 16:01:05.000 | 5.000000000000000 | - d40 | 2021-12-31 16:01:05.000 | 2021-12-31 16:02:05.000 | 8.000000000000000 | - d40 | 2021-12-31 16:02:05.000 | 2021-12-31 16:03:05.000 | 7.666666666666667 | - d40 | 2021-12-31 16:03:05.000 | 2021-12-31 16:04:05.000 | 9.666666666666666 | - d40 | 2021-12-31 16:04:05.000 | 2021-12-31 16:05:05.000 | 15.199999999999999 | - d41 | 2021-12-31 15:59:05.000 | 2021-12-31 16:00:05.000 | 4.000000000000000 | - d41 | 2021-12-31 16:00:05.000 | 2021-12-31 16:01:05.000 | 7.000000000000000 | - d41 | 2021-12-31 16:01:05.000 | 2021-12-31 16:02:05.000 | 9.000000000000000 | - d41 | 2021-12-31 16:02:05.000 | 2021-12-31 16:03:05.000 | 10.666666666666666 | - d41 | 2021-12-31 16:03:05.000 | 2021-12-31 16:04:05.000 | 8.333333333333334 | - d41 | 2021-12-31 16:04:05.000 | 2021-12-31 16:05:05.000 | 9.600000000000000 | + tbname | _wstart | _wend | avg(voltage) | +====================================================================================== + d2 | 2021-12-31 23:59:05.000 | 2022-01-01 00:00:05.000 | 253.000000000000000 | + d2 | 2022-01-01 00:00:05.000 | 2022-01-01 00:01:05.000 | 244.166666666666657 | + d2 | 2022-01-01 00:01:05.000 | 2022-01-01 00:02:05.000 | 241.833333333333343 | + d2 | 2022-01-01 00:02:05.000 | 2022-01-01 00:03:05.000 | 243.166666666666657 | + d2 | 2022-01-01 00:03:05.000 | 2022-01-01 00:04:05.000 | 240.833333333333343 | + d2 | 2022-01-01 00:04:05.000 | 2022-01-01 00:05:05.000 | 244.800000000000011 | + d26 | 2021-12-31 23:59:05.000 | 2022-01-01 00:00:05.000 | 253.000000000000000 | + d26 | 2022-01-01 00:00:05.000 | 2022-01-01 00:01:05.000 | 244.166666666666657 | + d26 | 2022-01-01 00:01:05.000 | 2022-01-01 00:02:05.000 | 241.833333333333343 | + d26 | 2022-01-01 00:02:05.000 | 2022-01-01 00:03:05.000 | 243.166666666666657 | + d26 | 2022-01-01 00:03:05.000 | 2022-01-01 00:04:05.000 | 240.833333333333343 | + d26 | 2022-01-01 00:04:05.000 | 2022-01-01 00:05:05.000 | 244.800000000000011 | Query OK, 12 row(s) in set (0.021265s) ``` @@ -255,19 +256,19 @@ SLIMIT 1; 上面的 SQL,查询超级表 `meters` 中,时间戳大于等于 `2022-01-01T00:00:00+08:00`,且时间戳小于 `2022-01-01T00:05:00+08:00` 的数据,数据首先按照子表名 `tbname` 进行数据切分,再按照每 1 分钟的时间窗口进行切分,且时间窗口按照 30 秒进行滑动;最后,仅取前 1 个分片的数据作为结果。查询结果如下: ```text - tbname | _wstart | avg(voltage) | -================================================================ - d40 | 2021-12-31 15:59:30.000 | 4.000000000000000 | - d40 | 2021-12-31 16:00:00.000 | 5.666666666666667 | - d40 | 2021-12-31 16:00:30.000 | 4.333333333333333 | - d40 | 2021-12-31 16:01:00.000 | 5.000000000000000 | - d40 | 2021-12-31 16:01:30.000 | 9.333333333333334 | - d40 | 2021-12-31 16:02:00.000 | 9.666666666666666 | - d40 | 2021-12-31 16:02:30.000 | 10.000000000000000 | - d40 | 2021-12-31 16:03:00.000 | 10.333333333333334 | - d40 | 2021-12-31 16:03:30.000 | 10.333333333333334 | - d40 | 2021-12-31 16:04:00.000 | 13.000000000000000 | - d40 | 2021-12-31 16:04:30.000 | 15.333333333333334 | + tbname | _wstart | avg(voltage) | +============================================================= + d2 | 2021-12-31 23:59:30.000 | 248.333333333333343 | + d2 | 2022-01-01 00:00:00.000 | 246.000000000000000 | + d2 | 2022-01-01 00:00:30.000 | 244.666666666666657 | + d2 | 2022-01-01 00:01:00.000 | 240.833333333333343 | + d2 | 2022-01-01 00:01:30.000 | 239.500000000000000 | + d2 | 2022-01-01 00:02:00.000 | 243.833333333333343 | + d2 | 2022-01-01 00:02:30.000 | 243.833333333333343 | + d2 | 2022-01-01 00:03:00.000 | 241.333333333333343 | + d2 | 2022-01-01 00:03:30.000 | 241.666666666666657 | + d2 | 2022-01-01 00:04:00.000 | 244.166666666666657 | + d2 | 2022-01-01 00:04:30.000 | 244.666666666666657 | Query OK, 11 row(s) in set (0.013153s) ``` @@ -290,13 +291,13 @@ SLIMIT 1; 上面的 SQL,查询超级表 `meters` 中,时间戳大于等于 `2022-01-01T00:00:00+08:00`,且时间戳小于 `2022-01-01T00:05:00+08:00` 的数据,数据首先按照子表名 `tbname` 进行数据切分,再按照每 1 分钟的时间窗口进行切分,且时间窗口按照 1 分钟进行切分;最后,仅取前 1 个分片的数据作为结果。查询结果如下: ```text - tbname | _wstart | _wend | avg(voltage) | -================================================================================================================= - d28 | 2021-12-31 16:00:00.000 | 2021-12-31 16:01:00.000 | 7.333333333333333 | - d28 | 2021-12-31 16:01:00.000 | 2021-12-31 16:02:00.000 | 8.000000000000000 | - d28 | 2021-12-31 16:02:00.000 | 2021-12-31 16:03:00.000 | 11.000000000000000 | - d28 | 2021-12-31 16:03:00.000 | 2021-12-31 16:04:00.000 | 6.666666666666667 | - d28 | 2021-12-31 16:04:00.000 | 2021-12-31 16:05:00.000 | 10.000000000000000 | + tbname | _wstart | _wend | avg(voltage) | +====================================================================================== + d2 | 2022-01-01 00:00:00.000 | 2022-01-01 00:01:00.000 | 246.000000000000000 | + d2 | 2022-01-01 00:01:00.000 | 2022-01-01 00:02:00.000 | 240.833333333333343 | + d2 | 2022-01-01 00:02:00.000 | 2022-01-01 00:03:00.000 | 243.833333333333343 | + d2 | 2022-01-01 00:03:00.000 | 2022-01-01 00:04:00.000 | 241.333333333333343 | + d2 | 2022-01-01 00:04:00.000 | 2022-01-01 00:05:00.000 | 244.166666666666657 | Query OK, 5 row(s) in set (0.016812s) ``` @@ -342,53 +343,65 @@ SLIMIT 2; 上面的 SQL,查询超级表 `meters` 中,时间戳大于等于 `2022-01-01T00:00:00+08:00`,且时间戳小于 `2022-01-01T00:05:00+08:00` 的数据;数据首先按照子表名 `tbname` 进行数据切分,再按照每 1 分钟的时间窗口进行切分,如果窗口内的数据出现缺失,则使用使用前一个非 NULL 值填充数据;最后,仅取前 2 个分片的数据作为结果。查询结果如下: ```text - tbname | _wstart | _wend | avg(voltage) | -================================================================================================================= - d40 | 2021-12-31 16:00:00.000 | 2021-12-31 16:01:00.000 | 5.666666666666667 | - d40 | 2021-12-31 16:01:00.000 | 2021-12-31 16:02:00.000 | 5.000000000000000 | - d40 | 2021-12-31 16:02:00.000 | 2021-12-31 16:03:00.000 | 9.666666666666666 | - d40 | 2021-12-31 16:03:00.000 | 2021-12-31 16:04:00.000 | 10.333333333333334 | - d40 | 2021-12-31 16:04:00.000 | 2021-12-31 16:05:00.000 | 13.000000000000000 | - d41 | 2021-12-31 16:00:00.000 | 2021-12-31 16:01:00.000 | 5.666666666666667 | - d41 | 2021-12-31 16:01:00.000 | 2021-12-31 16:02:00.000 | 9.333333333333334 | - d41 | 2021-12-31 16:02:00.000 | 2021-12-31 16:03:00.000 | 11.000000000000000 | - d41 | 2021-12-31 16:03:00.000 | 2021-12-31 16:04:00.000 | 7.666666666666667 | - d41 | 2021-12-31 16:04:00.000 | 2021-12-31 16:05:00.000 | 10.000000000000000 | + tbname | _wstart | _wend | avg(voltage) | +======================================================================================= + d2 | 2022-01-01 00:00:00.000 | 2022-01-01 00:01:00.000 | 246.000000000000000 | + d2 | 2022-01-01 00:01:00.000 | 2022-01-01 00:02:00.000 | 240.833333333333343 | + d2 | 2022-01-01 00:02:00.000 | 2022-01-01 00:03:00.000 | 243.833333333333343 | + d2 | 2022-01-01 00:03:00.000 | 2022-01-01 00:04:00.000 | 241.333333333333343 | + d2 | 2022-01-01 00:04:00.000 | 2022-01-01 00:05:00.000 | 244.166666666666657 | + d26 | 2022-01-01 00:00:00.000 | 2022-01-01 00:01:00.000 | 246.000000000000000 | + d26 | 2022-01-01 00:01:00.000 | 2022-01-01 00:02:00.000 | 240.833333333333343 | + d26 | 2022-01-01 00:02:00.000 | 2022-01-01 00:03:00.000 | 243.833333333333343 | + d26 | 2022-01-01 00:03:00.000 | 2022-01-01 00:04:00.000 | 241.333333333333343 | + d26 | 2022-01-01 00:04:00.000 | 2022-01-01 00:05:00.000 | 244.166666666666657 | Query OK, 10 row(s) in set (0.022866s) ``` ### 状态窗口 -使用整数(布尔值)或字符串来标识产生记录时候设备的状态量。产生的记录如果具有相同的状态量数值则归属于同一个状态窗口,数值改变后该窗口关闭。TDengine 还支持将 CASE 表达式用在状态量,可以表达某个状态的开始是由满足某个条件而触发,这个状态的结束是由另外一个条件满足而触发的语义。以智能电表为例,电压正常范围是 205V 到 235V,那么可以通过监控电压来判断电路是否正常。 +使用整数(布尔值)或字符串来标识产生记录时候设备的状态量。产生的记录如果具有相同的状态量数值则归属于同一个状态窗口,数值改变后该窗口关闭。TDengine 还支持将 CASE 表达式用在状态量,可以表达某个状态的开始是由满足某个条件而触发,这个状态的结束是由另外一个条件满足而触发的语义。以智能电表为例,电压正常范围是 225V 到 235V,那么可以通过监控电压来判断电路是否正常。 ```sql -SELECT tbname, _wstart, _wend,_wduration, CASE WHEN voltage >= 205 and voltage <= 235 THEN 1 ELSE 0 END status +SELECT tbname, _wstart, _wend,_wduration, CASE WHEN voltage >= 225 and voltage <= 235 THEN 1 ELSE 0 END status FROM meters WHERE ts >= "2022-01-01T00:00:00+08:00" AND ts < "2022-01-01T00:05:00+08:00" PARTITION BY tbname STATE_WINDOW( - CASE WHEN voltage >= 205 and voltage <= 235 THEN 1 ELSE 0 END + CASE WHEN voltage >= 225 and voltage <= 235 THEN 1 ELSE 0 END ) -SLIMIT 10; +SLIMIT 2; ``` -以上 SQL,查询超级表 meters 中,时间戳大于等于 2022-01-01T00:00:00+08:00,且时间戳小于 2022-01-01T00:05:00+08:00的数据;数据首先按照子表名 tbname 进行数据切分;根据电压是否在正常范围内进行状态窗口的划分;最后,取前 10 个分片的数据作为结果。查询结果如下: +以上 SQL,查询超级表 meters 中,时间戳大于等于 2022-01-01T00:00:00+08:00,且时间戳小于 2022-01-01T00:05:00+08:00的数据;数据首先按照子表名 tbname 进行数据切分;根据电压是否在正常范围内进行状态窗口的划分;最后,取前 2 个分片的数据作为结果。查询结果如下:(由于数据是随机生成,结果集包含的数据条数会有不同) ```text - tbname | _wstart | _wend | _wduration | status | -===================================================================================================================================== - d76 | 2021-12-31 16:00:00.000 | 2021-12-31 16:04:50.000 | 290000 | 0 | - d47 | 2021-12-31 16:00:00.000 | 2021-12-31 16:04:50.000 | 290000 | 0 | - d37 | 2021-12-31 16:00:00.000 | 2021-12-31 16:04:50.000 | 290000 | 0 | - d87 | 2021-12-31 16:00:00.000 | 2021-12-31 16:04:50.000 | 290000 | 0 | - d64 | 2021-12-31 16:00:00.000 | 2021-12-31 16:04:50.000 | 290000 | 0 | - d35 | 2021-12-31 16:00:00.000 | 2021-12-31 16:04:50.000 | 290000 | 0 | - d83 | 2021-12-31 16:00:00.000 | 2021-12-31 16:04:50.000 | 290000 | 0 | - d51 | 2021-12-31 16:00:00.000 | 2021-12-31 16:04:50.000 | 290000 | 0 | - d63 | 2021-12-31 16:00:00.000 | 2021-12-31 16:04:50.000 | 290000 | 0 | - d0 | 2021-12-31 16:00:00.000 | 2021-12-31 16:04:50.000 | 290000 | 0 | -Query OK, 10 row(s) in set (0.040495s) + tbname | _wstart | _wend | _wduration | status | +=============================================================================================== + d2 | 2022-01-01 00:00:00.000 | 2022-01-01 00:01:20.000 | 80000 | 0 | + d2 | 2022-01-01 00:01:30.000 | 2022-01-01 00:01:30.000 | 0 | 1 | + d2 | 2022-01-01 00:01:40.000 | 2022-01-01 00:01:40.000 | 0 | 0 | + d2 | 2022-01-01 00:01:50.000 | 2022-01-01 00:01:50.000 | 0 | 1 | + d2 | 2022-01-01 00:02:00.000 | 2022-01-01 00:02:20.000 | 20000 | 0 | + d2 | 2022-01-01 00:02:30.000 | 2022-01-01 00:02:30.000 | 0 | 1 | + d2 | 2022-01-01 00:02:40.000 | 2022-01-01 00:03:00.000 | 20000 | 0 | + d2 | 2022-01-01 00:03:10.000 | 2022-01-01 00:03:10.000 | 0 | 1 | + d2 | 2022-01-01 00:03:20.000 | 2022-01-01 00:03:40.000 | 20000 | 0 | + d2 | 2022-01-01 00:03:50.000 | 2022-01-01 00:03:50.000 | 0 | 1 | + d2 | 2022-01-01 00:04:00.000 | 2022-01-01 00:04:50.000 | 50000 | 0 | + d26 | 2022-01-01 00:00:00.000 | 2022-01-01 00:01:20.000 | 80000 | 0 | + d26 | 2022-01-01 00:01:30.000 | 2022-01-01 00:01:30.000 | 0 | 1 | + d26 | 2022-01-01 00:01:40.000 | 2022-01-01 00:01:40.000 | 0 | 0 | + d26 | 2022-01-01 00:01:50.000 | 2022-01-01 00:01:50.000 | 0 | 1 | + d26 | 2022-01-01 00:02:00.000 | 2022-01-01 00:02:20.000 | 20000 | 0 | + d26 | 2022-01-01 00:02:30.000 | 2022-01-01 00:02:30.000 | 0 | 1 | + d26 | 2022-01-01 00:02:40.000 | 2022-01-01 00:03:00.000 | 20000 | 0 | + d26 | 2022-01-01 00:03:10.000 | 2022-01-01 00:03:10.000 | 0 | 1 | + d26 | 2022-01-01 00:03:20.000 | 2022-01-01 00:03:40.000 | 20000 | 0 | + d26 | 2022-01-01 00:03:50.000 | 2022-01-01 00:03:50.000 | 0 | 1 | + d26 | 2022-01-01 00:04:00.000 | 2022-01-01 00:04:50.000 | 50000 | 0 | +Query OK, 22 row(s) in set (0.153403s) ``` ### 会话窗口 @@ -417,18 +430,18 @@ SLIMIT 10; 上面的 SQL,查询超级表 meters 中,时间戳大于等于 2022-01-01T00:00:00+08:00,且时间戳小于 2022-01-01T00:10:00+08:00的数据;数据先按照子表名 tbname 进行数据切分,再根据 10 分钟的会话窗口进行切分;最后,取前 10 个分片的数据作为结果,返回子表名、窗口开始时间、窗口结束时间、窗口宽度、窗口内数据条数。查询结果如下: ```text - tbname | _wstart | _wend | _wduration | count(*) | -===================================================================================================================================== - d76 | 2021-12-31 16:00:00.000 | 2021-12-31 16:09:50.000 | 590000 | 60 | - d47 | 2021-12-31 16:00:00.000 | 2021-12-31 16:09:50.000 | 590000 | 60 | - d37 | 2021-12-31 16:00:00.000 | 2021-12-31 16:09:50.000 | 590000 | 60 | - d87 | 2021-12-31 16:00:00.000 | 2021-12-31 16:09:50.000 | 590000 | 60 | - d64 | 2021-12-31 16:00:00.000 | 2021-12-31 16:09:50.000 | 590000 | 60 | - d35 | 2021-12-31 16:00:00.000 | 2021-12-31 16:09:50.000 | 590000 | 60 | - d83 | 2021-12-31 16:00:00.000 | 2021-12-31 16:09:50.000 | 590000 | 60 | - d51 | 2021-12-31 16:00:00.000 | 2021-12-31 16:09:50.000 | 590000 | 60 | - d63 | 2021-12-31 16:00:00.000 | 2021-12-31 16:09:50.000 | 590000 | 60 | - d0 | 2021-12-31 16:00:00.000 | 2021-12-31 16:09:50.000 | 590000 | 60 | + tbname | _wstart | _wend | _wduration | count(*) | +=============================================================================================== + d2 | 2022-01-01 00:00:00.000 | 2022-01-01 00:09:50.000 | 590000 | 60 | + d26 | 2022-01-01 00:00:00.000 | 2022-01-01 00:09:50.000 | 590000 | 60 | + d52 | 2022-01-01 00:00:00.000 | 2022-01-01 00:09:50.000 | 590000 | 60 | + d64 | 2022-01-01 00:00:00.000 | 2022-01-01 00:09:50.000 | 590000 | 60 | + d76 | 2022-01-01 00:00:00.000 | 2022-01-01 00:09:50.000 | 590000 | 60 | + d28 | 2022-01-01 00:00:00.000 | 2022-01-01 00:09:50.000 | 590000 | 60 | + d4 | 2022-01-01 00:00:00.000 | 2022-01-01 00:09:50.000 | 590000 | 60 | + d88 | 2022-01-01 00:00:00.000 | 2022-01-01 00:09:50.000 | 590000 | 60 | + d77 | 2022-01-01 00:00:00.000 | 2022-01-01 00:09:50.000 | 590000 | 60 | + d54 | 2022-01-01 00:00:00.000 | 2022-01-01 00:09:50.000 | 590000 | 60 | Query OK, 10 row(s) in set (0.043489s) ``` @@ -458,26 +471,26 @@ FROM meters WHERE ts >= "2022-01-01T00:00:00+08:00" AND ts < "2022-01-01T00:10:00+08:00" PARTITION BY tbname -EVENT_WINDOW START WITH voltage >= 10 END WITH voltage < 20 -LIMIT 10; +EVENT_WINDOW START WITH voltage >= 225 END WITH voltage < 235 +LIMIT 5; ``` -上面的 SQL,查询超级表meters中,时间戳大于等于2022-01-01T00:00:00+08:00,且时间戳小于2022-01-01T00:10:00+08:00的数据;数据先按照子表名tbname进行数据切分,再根据事件窗口条件:电压大于等于 10V,且小于 20V 进行切分;最后,取前 10 行的数据作为结果,返回子表名、窗口开始时间、窗口结束时间、窗口宽度、窗口内数据条数。查询结果如下: +上面的 SQL,查询超级表meters中,时间戳大于等于2022-01-01T00:00:00+08:00,且时间戳小于2022-01-01T00:10:00+08:00的数据;数据先按照子表名tbname进行数据切分,再根据事件窗口条件:电压大于等于 225V,且小于 235V 进行切分;最后,取每个分片的前 5 行的数据作为结果,返回子表名、窗口开始时间、窗口结束时间、窗口宽度、窗口内数据条数。查询结果如下: ```text - tbname | _wstart | _wend | _wduration | count(*) | -===================================================================================================================================== - d0 | 2021-12-31 16:00:00.000 | 2021-12-31 16:00:00.000 | 0 | 1 | - d0 | 2021-12-31 16:00:30.000 | 2021-12-31 16:00:30.000 | 0 | 1 | - d0 | 2021-12-31 16:00:40.000 | 2021-12-31 16:00:40.000 | 0 | 1 | - d0 | 2021-12-31 16:01:20.000 | 2021-12-31 16:01:20.000 | 0 | 1 | - d0 | 2021-12-31 16:02:20.000 | 2021-12-31 16:02:20.000 | 0 | 1 | - d0 | 2021-12-31 16:02:30.000 | 2021-12-31 16:02:30.000 | 0 | 1 | - d0 | 2021-12-31 16:03:10.000 | 2021-12-31 16:03:10.000 | 0 | 1 | - d0 | 2021-12-31 16:03:30.000 | 2021-12-31 16:03:30.000 | 0 | 1 | - d0 | 2021-12-31 16:03:40.000 | 2021-12-31 16:03:40.000 | 0 | 1 | - d0 | 2021-12-31 16:03:50.000 | 2021-12-31 16:03:50.000 | 0 | 1 | -Query OK, 10 row(s) in set (0.034127s) + tbname | _wstart | _wend | _wduration | count(*) | +============================================================================================== + d0 | 2022-01-01 00:00:00.000 | 2022-01-01 00:01:30.000 | 90000 | 10 | + d0 | 2022-01-01 00:01:40.000 | 2022-01-01 00:02:30.000 | 50000 | 6 | + d0 | 2022-01-01 00:02:40.000 | 2022-01-01 00:03:10.000 | 30000 | 4 | + d0 | 2022-01-01 00:03:20.000 | 2022-01-01 00:07:10.000 | 230000 | 24 | + d0 | 2022-01-01 00:07:20.000 | 2022-01-01 00:07:50.000 | 30000 | 4 | + d1 | 2022-01-01 00:00:00.000 | 2022-01-01 00:01:30.000 | 90000 | 10 | + d1 | 2022-01-01 00:01:40.000 | 2022-01-01 00:02:30.000 | 50000 | 6 | + d1 | 2022-01-01 00:02:40.000 | 2022-01-01 00:03:10.000 | 30000 | 4 | + d1 | 2022-01-01 00:03:20.000 | 2022-01-01 00:07:10.000 | 230000 | 24 | +…… +Query OK, 500 row(s) in set (0.328557s) ``` ### 计数窗口 @@ -492,17 +505,25 @@ sliding_val 是一个常量,表示窗口滑动的数量,类似于 interval select _wstart, _wend, count(*) from meters where ts >= "2022-01-01T00:00:00+08:00" and ts < "2022-01-01T00:30:00+08:00" -count_window(10); +count_window(1000); ``` -上面的 SQL 查询超级表 meters 中时间戳大于等于 2022-01-01T00:00:00+08:00 且时间戳小于 2022-01-01T00:10:00+08:00 的数据。以每 10 条数据为一组,返回每组的开始时间、结束时间和分组条数。查询结果如下。 +上面的 SQL 查询超级表 meters 中时间戳大于等于 2022-01-01T00:00:00+08:00 且时间戳小于 2022-01-01T00:10:00+08:00 的数据。以每 1000 条数据为一组,返回每组的开始时间、结束时间和分组条数。查询结果如下: ```text -_wstart | _wend |count(*)| -=========================================================== -2021-12-31 16:00:00.000 | 2021-12-31 16:10:00.000 | 10 | -2021-12-31 16:10:00.000 | 2021-12-31 16:20:00.000 | 10 | -2021-12-31 16:20:00.000 | 2021-12-31 16:30:00.000 | 10 | + _wstart | _wend | count(*) | +===================================================================== + 2022-01-01 00:00:00.000 | 2022-01-01 00:01:30.000 | 1000 | + 2022-01-01 00:01:40.000 | 2022-01-01 00:03:10.000 | 1000 | + 2022-01-01 00:03:20.000 | 2022-01-01 00:04:50.000 | 1000 | + 2022-01-01 00:05:00.000 | 2022-01-01 00:06:30.000 | 1000 | + 2022-01-01 00:06:40.000 | 2022-01-01 00:08:10.000 | 1000 | + 2022-01-01 00:08:20.000 | 2022-01-01 00:09:50.000 | 1000 | + 2022-01-01 00:10:00.000 | 2022-01-01 00:11:30.000 | 1000 | + 2022-01-01 00:11:40.000 | 2022-01-01 00:13:10.000 | 1000 | + 2022-01-01 00:13:20.000 | 2022-01-01 00:14:50.000 | 1000 | + 2022-01-01 00:15:00.000 | 2022-01-01 00:16:30.000 | 1000 | +Query OK, 10 row(s) in set (0.062794s) ``` ## 时序数据特有函数 @@ -563,14 +584,14 @@ UNION ALL 上面的 SQL,分别查询:子表 d1 的 1 条数据,子表 d11 的 2 条数据,子表 d21 的 3 条数据,并将结果合并。返回的结果如下: ```text - tbname | ts | current | voltage | phase | -================================================================================================= - d11 | 2020-09-13 12:26:40.000 | 1.0260611 | 6 | 0.3620200 | - d11 | 2020-09-13 12:26:50.000 | 2.9544230 | 8 | 1.0048079 | - d21 | 2020-09-13 12:26:40.000 | 1.0260611 | 2 | 0.3520200 | - d21 | 2020-09-13 12:26:50.000 | 2.9544230 | 2 | 0.9948080 | - d21 | 2020-09-13 12:27:00.000 | -0.0000430 | 12 | 0.0099860 | - d1 | 2020-09-13 12:26:40.000 | 1.0260611 | 10 | 0.3520200 | + tbname | ts | current | voltage | phase | +==================================================================================== + d11 | 2020-09-13 20:26:40.000 | 11.5680809 | 247 | 146.5000000 | + d11 | 2020-09-13 20:26:50.000 | 14.2392311 | 234 | 148.0000000 | + d1 | 2020-09-13 20:26:40.000 | 11.5680809 | 247 | 146.5000000 | + d21 | 2020-09-13 20:26:40.000 | 11.5680809 | 247 | 146.5000000 | + d21 | 2020-09-13 20:26:50.000 | 14.2392311 | 234 | 148.0000000 | + d21 | 2020-09-13 20:27:00.000 | 10.0999422 | 251 | 146.0000000 | Query OK, 6 row(s) in set (0.006438s) ``` diff --git a/docs/zh/06-advanced/02-cache.md b/docs/zh/06-advanced/02-cache.md index b83509c2dd5..065adbf50ae 100644 --- a/docs/zh/06-advanced/02-cache.md +++ b/docs/zh/06-advanced/02-cache.md @@ -54,10 +54,10 @@ TDengine 利用这些日志文件实现故障前的状态恢复。在写入 WAL 数据库参数 wal_level 和 wal_fsync_period 共同决定了 WAL 的保存行为。。 - wal_level:此参数控制 WAL 的保存级别。级别 1 表示仅将数据写入 WAL,但不立即执行 fsync 函数;级别 2 则表示在写入 WAL 的同时执行 fsync 函数。默认情况下,wal_level 设为 1。虽然执行 fsync 函数可以提高数据的持久性,但相应地也会降低写入性能。 -- wal_fsync_period:当 wal_level 设置为 1 时,这个参数控制执行 fsync 的频率。设置为 0 表示每次写入后立即执行 fsync,这可以确保数据的安全性,但可能会牺牲一些性能。当设置为大于 0 的数值时,表示 fsync 周期,默认为 3000,范围是[1, 180000],单位毫秒。 +- wal_fsync_period:当 wal_level 设置为 2 时,这个参数控制执行 fsync 的频率。设置为 0 表示每次写入后立即执行 fsync,这可以确保数据的安全性,但可能会牺牲一些性能。当设置为大于 0 的数值时,表示 fsync 周期,默认为 3000,范围是[1, 180000],单位毫秒。 ```sql -CREATE DATABASE POWER WAL_LEVEL 1 WAL_FSYNC_PERIOD 3000; +CREATE DATABASE POWER WAL_LEVEL 2 WAL_FSYNC_PERIOD 3000; ``` 在创建数据库时可以选择不同的参数类型,来选择性能优先或者可靠性优先。 diff --git a/docs/zh/06-advanced/06-data-analysis/01-arima.md b/docs/zh/06-advanced/06-data-analysis/01-arima.md index 1668da453c1..6799d488871 100644 --- a/docs/zh/06-advanced/06-data-analysis/01-arima.md +++ b/docs/zh/06-advanced/06-data-analysis/01-arima.md @@ -3,8 +3,52 @@ title: "ARIMA" sidebar_label: "ARIMA" --- -本节讲述如何 ARIMA 算法的使用方法。 +本节讲述 ARIMA 算法模型的使用方法。 ## 功能概述 -…… \ No newline at end of file +ARIMA 即自回归移动平均模型(Autoregressive Integrated Moving Average, ARIMA),也记作 ARIMA(p,d,q),是统计模型中最常见的一种用来进行时间序列预测的模型。 +ARIMA模型是一种自回归模型,只需要自变量即可预测后续的值。ARIMA模型要求时序数据是**平稳**,或经过差分处理后平稳,如果是不平稳的数据,**无法**获得正确的结果。 + +>平稳的时间序列:其性质不随观测时间的变化而变化。具有趋势或季节性的时间序列不是平稳时间序列——趋势和季节性使得时间序列在不同时段呈现不同性质。 + +以下参数可以动态输入控制预测过程中生成 合适的 ARIMA 的模型。 + +- p= 自回归模型阶数 +- d= 差分阶数 +- q= 移动平均模型阶数 + + +### 参数 +分析平台中使用自动化的 ARIMA 模型进行计算,因此每次计算的时候会根据输入的数据自动拟合最合适的模型,然后根据该模型进行预测输出结果。 +|参数名称|说明|必填项| +|---|---|---| +|period|输入时间序列数据每个周期包含的数据点个数。如果不设置该参数或则该参数设置为 0, 将使用非季节性/周期性的 ARIMA 模型预测。|选填| +|start_p| 自回归模型阶数的 起始值,0 开始的整数,不推荐大于 10 |选填| +|max_p| 自回归模型阶数的 结束值,0 开始的整数,不推荐大于 10 |选填| +|start_q| 移动平均模型阶数的起始值, 0 开始的整数,不推荐大于 10 |选填| +|max_q| 移动平均模型阶数的结束值, 0 开始的整数,不推荐大于 10 |选填| +|d| 差分阶数|选填| + +`start_p`、`max_p` `start_q` `max_q` 四个参数约束了模型在多大的范围内去搜寻合适的最优解。相同输入数据的条件下,参数范围越大,消耗的资源越多,系统响应的时间越长。 + +### 示例及结果 +针对 i32 列进行数据预测,输入列 i32 每 10 个点是一个周期,start_p 起始是 1, 最大拟合是 5,start_q是1,最大值是5,预测结果中返回 95% 置信区间范围边界。 +``` +FORECAST(i32, "algo=arima,alpha=95,period=10, start_p=1, max_p=5, start_q=1, max_q=5") +``` + +```json5 +{ +"rows": fc_rows, // 预测结果的行数 +"period": period, // 返回结果的周期性,同输入 +"alpha": alpha, // 返回结果的置信区间,同输入 +"algo": "arima", // 返回结果使用的算法 +"mse":mse, // 拟合输入时序数据时候生成模型的最小均方误差(MSE) +"res": res // 列模式的结果 +} +``` + +### 参考文献 +- https://en.wikipedia.org/wiki/Autoregressive_moving-average_model +- https://baike.baidu.com/item/%E8%87%AA%E5%9B%9E%E5%BD%92%E6%BB%91%E5%8A%A8%E5%B9%B3%E5%9D%87%E6%A8%A1%E5%9E%8B/5023931?fromtitle=ARMA%E6%A8%A1%E5%9E%8B&fromid=8048415 diff --git a/docs/zh/06-advanced/06-data-analysis/02-holtwinters.md b/docs/zh/06-advanced/06-data-analysis/02-holtwinters.md new file mode 100644 index 00000000000..470ef462539 --- /dev/null +++ b/docs/zh/06-advanced/06-data-analysis/02-holtwinters.md @@ -0,0 +1,43 @@ +--- +title: "HoltWinters" +sidebar_label: "HoltWinters" +--- + +本节讲述 HoltWinters 算法模型的使用方法。 + +## 功能概述 +HoltWinters模型又称为多次指数平滑模型(EMA)。对含有线性趋势和周期波动的非平稳序列适用,利用指数平滑法让模型参数不断适应非平稳序列的变化,并对未来趋势进行**短期**预测。 +HoltWinters有两种不同的季节性组成部分,当季节变化在该时间序列中大致保持不变时,通常选择**加法模型**;而当季节变化与时间序列的水平成比例变化时,通常选择**乘法模型**。 +该模型对于返回数据也不提供计算的置信区间范围结果。在 95% 置信区间的上下界结果与预测结果相同。 + + +### 参数 + +分析平台中使用自动化的 ARIMA 模型进行计算,因此每次计算的时候会根据输入的数据自动拟合最合适的模型,然后根据该模型进行预测输出结果。 +|参数名称|说明|必填项| +|---|---|---| +|period| 输入时间序列数据每个周期包含的数据点个数。如果不设置该参数或则该参数设置为 0, 将使用一次(简单)指数平滑方式进行数据拟合,并据此进行未来数据的预测|选填| +|trend| 趋势模型使用加法模型还是乘法模型|选填| +|seasonal| 季节性采用加法模型还是乘法模型|选填| + +参数 `trend` 和 `seasonal`的均可以选择 `add` (加法模型)或 `mul`(乘法模型)。 + +### 示例及结果 +针对 i32 列进行数据预测,输入列 i32 每 10 个点是一个周期,趋势采用乘法模型,季节采用乘法模型 +``` +FORECAST(i32, "algo=holtwinters,period=10,trend=mul,seasonal=mul") +``` + +```json5 +{ +"rows": rows, // 结果的行数 +"period": period, // 返回结果的周期性, 该结果与输入的周期性相同,如果没有周期性,该值为 0 +"algo": 'holtwinters' // 返回结果使用的计算模型 +"mse":mse, // 最小均方误差(minmum square error) +"res": res // 具体的结果,按照列形式返回的结果。一般意义上包含了 两列[timestamp][fc_results]。 +} +``` + +### 参考文献 +- https://en.wikipedia.org/wiki/Exponential_smoothing +- https://orangematter.solarwinds.com/2019/12/15/holt-winters-forecasting-simplified/ diff --git a/docs/zh/06-advanced/06-data-analysis/03-anomaly-detection.md b/docs/zh/06-advanced/06-data-analysis/03-anomaly-detection.md new file mode 100644 index 00000000000..8f1e1f064a7 --- /dev/null +++ b/docs/zh/06-advanced/06-data-analysis/03-anomaly-detection.md @@ -0,0 +1,46 @@ +--- +title: "Anomaly-detection" +sidebar_label: "Anomaly-detection" +--- + +本节讲述 异常检测 算法模型的使用方法。 + +## 概述 +分析平台提供了 6 种异常检查模型,6 种异常检查模型分为 3 个类别,分别属于基于统计的异常检测模型、基于数据密度的检测模型、基于深度学习的异常检测模型。在不指定异常检测使用的方法的情况下,默认调用 iqr 的方法进行计算。 + + +### 统计学异常检测方法 + +- k-sigma[1]: 即 ***68–95–99.7 rule*** 。***k***值默认为3, 即序列均值的 3 倍标准差范围为边界,超过边界的是异常值。KSigma 要求数据整体上服从正态分布,如果一个点偏离均值K倍标准差,则该点被视为异常点. + +|参数名称|说明|是否必选|默认值| +|---|---|---|---| +|k|标准差倍数|选填|3| + + +- IQR[2]:四分位距 (Interquartile range, IQR) 是一种衡量变异性的方法. 四分位数将一个按等级排序的数据集划分为四个相等的部分。即 Q1(第 1 个四分位数)、Q2(第 2 个四分位数)和 Q3(第 3 个四分位数)。IQR 定义为 Q3–Q1,位于 Q3+1.5 。无输入参数。 + +- Grubbs[3]: 又称为 Grubbs' test,即最大标准残差测试。Grubbs 通常用作检验最大值、最小值偏离均值的程度是否为异常,该单变量数据集遵循近似标准正态分布。非正态分布数据集不能使用该方法。无输入参数。 + +- SHESD[4]: 带有季节性的 ESD 检测算法。ESD 可以检测时间序列数据的多异常点。需要指定异常点比例的上界***k***,最差的情况是至多49.9%。数据集的异常比例一般不超过5% + +|参数名称|说明|是否必选|默认值| +|---|---|---|---| +|k|异常点在输入数据集中占比,范围是$`1\le K \le 49.9`$ |选填|5| + + +### 基于数据密度的检测方法 +LOF[5]: 局部离群因子(LOF,又叫局部异常因子)算法是Breunig于2000年提出的一种基于密度的局部离群点检测算法,该方法适用于不同类簇密度分散情况迥异的数据。根据数据点周围的数据密集情况,首先计算每个数据点的一个局部可达密度,然后通过局部可达密度进一步计算得到每个数据点的一个离群因子,该离群因子即标识了一个数据点的离群程度,因子值越大,表示离群程度越高,因子值越小,表示离群程度越低。最后,输出离群程度最大的top(n)个点。 + + +### 基于深度学习的检测方法 +使用自动编码器的异常检测模型。可以对具有周期性的数据具有较好的检测结果。但是使用该模型需要针对输入的时序数据进行训练,同时将训练完成的模型部署到服务目录中,才能够运行与使用。 + + +### 参考文献 +1. https://en.wikipedia.org/wiki/68%E2%80%9395%E2%80%9399.7_rule +2. https://en.wikipedia.org/wiki/Interquartile_range +3. Adikaram, K. K. L. B.; Hussein, M. A.; Effenberger, M.; Becker, T. (2015-01-14). "Data Transformation Technique to Improve the Outlier Detection Power of Grubbs's Test for Data Expected to Follow Linear Relation". Journal of Applied Mathematics. 2015: 1–9. doi:10.1155/2015/708948. +4. Hochenbaum, O. S. Vallis, and A. Kejariwal. 2017. Automatic Anomaly Detection in the Cloud Via Statistical Learning. arXiv preprint arXiv:1704.07706 (2017). +5. Breunig, M. M.; Kriegel, H.-P.; Ng, R. T.; Sander, J. (2000). LOF: Identifying Density-based Local Outliers (PDF). Proceedings of the 2000 ACM SIGMOD International Conference on Management of Data. SIGMOD. pp. 93–104. doi:10.1145/335191.335388. ISBN 1-58113-217-4. + diff --git a/docs/zh/06-advanced/06-data-analysis/addins.md b/docs/zh/06-advanced/06-data-analysis/addins.md new file mode 100644 index 00000000000..8b50c93d85b --- /dev/null +++ b/docs/zh/06-advanced/06-data-analysis/addins.md @@ -0,0 +1,167 @@ +--- +title: "addins" +sidebar_label: "addins" +--- + +本节说明如何将自己开发的新预测算法和异常检测算法整合到 TDengine 分析平台, 并能够通过 SQL 语句进行调用。 + +## 目录结构 + +![数据分析功能架构图](./pic/dir.png) + +|目录|说明| +|---|---| +|taos|Python 源代码目录,其下包含了算法具体保存目录 algo,放置杂项目录 misc, 单元测试和集成测试目录 test。 algo目录下 ad 放置异常检测算法代码, fc 放置预测算法代码| +|script|是安装脚本和发布脚本放置目录| +|model|放置针对数据集完成的训练模型| +|cfg| 配置文件目录| + +## 约定与限制 + +定义异常检测算法的 Python 代码文件 需放在 /taos/algo/ad 目录中,预测算法 Python 代码文件需要放在 /taos/algo/fc 目录中,以确保系统启动的时候能够正常加载对应目录下的 Python 文件。 + + +### 类命名规范 + +算法类的名称需要 以下划线开始,以 Service 结尾。例如:_KsigmaService 是 KSigma 异常检测算法的实现类。 + +### 类继承约定 + +异常检测算法需要从 `AbstractAnomalyDetectionService` 继承,并实现其核心抽象方法 `execute`. +预测算法需要从 `AbstractForecastService` 继承,同样需要实现其核心抽象方法 `execute`。 + +### 类属性初始化 +每个算法实现的类需要静态初始化两个类属性,分别是 + +`name`: 的触发调用关键词,全小写英文字母。 +`desc`:该算法的描述信息。 + +### 核心方法输入与输出约定 + +`execute` 是算法处理的核心方法。调用该方法的时候, `self.list` 已经设置好输入数组。 +异常检测输出结果 + +`execute` 的返回值是长度与 `self.list` 相同的数组,数组位置为 -1 的即为异常值点。例如:输入数组是 [2, 2, 2, 2, 100], 如果 100 是异常点,那么返回值是 [1, 1, 1, 1, -1]。 +预测输出结果 + +对于预测算法, `AbstractForecastService` 的对象属性说明如下: + +|属性名称|说明|默认值| +|---|---|---| +|period|输入时序数据的周期性,多少个数据点表示一个完整的周期。如果没有周期性,那么设置为 0 即可。| 0| +|start_ts|预测数据的开始时间| 0| +|time_step|预测结果的两个数据点之间时间间隔|0 | +|fc_rows|预测结果数量| 0 | +|return_conf|返回结果中是否包含执行区间范围,如果算法计算结果不包含置信区间,那么上界和下界与自身相同| 1| +|conf|执行区间分位数 0.05| + + +预测返回结果如下: +```python +return { + "rows": self.fc_rows, # 预测数据行数 + "period": self.period, # 数据周期性,同输入 + "algo": "holtwinters", # 预测使用的算法 + "mse": mse, # 预测算法的 mse + "res": res # 结果数组 [时间戳数组, 预测结果数组, 预测结果执行区间下界数组,预测结果执行区间上界数组] +} +``` + + +## 示例代码 + +```python +import numpy as np +from service import AbstractAnomalyDetectionService + +# 算法实现类名称 需要以下划线 "_" 开始,并以 Service 结束,如下 _IqrService 是 IQR 异常检测算法的实现类。 +class _IqrService(AbstractAnomalyDetectionService): + """ IQR algorithm 定义类,从 AbstractAnomalyDetectionService 继承,并实现 AbstractAnomalyDetectionService类的抽象函数 """ + + # 定义算法调用关键词,全小写ASCII码(必须添加) + name = 'iqr' + + # 该算法的描述信息(建议添加) + desc = """found the anomaly data according to the inter-quartile range""" + + def __init__(self): + super().__init__() + + def execute(self): + """ execute 是算法实现逻辑的核心实现,直接修改该实现即可 """ + + # self.list 是输入数值列,list 类型,例如:[1,2,3,4,5]。设置 self.list 的方法在父类中已经进行了定义。实现自己的算法,修改该文件即可,以下代码使用自己的实现替换即可。 + #lower = np.quantile(self.list, 0.25) + #upper = np.quantile(self.list, 0.75) + + #min_val = lower - 1.5 * (upper - lower) + #max_val = upper + 1.5 * (upper - lower) + #threshold = [min_val, max_val] + + # 返回值是与输入数值列长度相同的数据列,异常值对应位置是 -1。例如上述输入数据列,返回数值列是 [1, 1, 1, 1, -1],表示 [5] 是异常值。 + return [-1 if k < threshold[0] or k > threshold[1] else 1 for k in self.list] + + + def set_params(self, params): + """该算法无需任何输入参数,直接重载父类该函数,不处理算法参数设置逻辑""" + pass +``` + + +## 单元测试 + +在测试文件目录中的 anomaly_test.py 中增加单元测试用例。 +```python +def test_iqr(self): + """ 测试 _IqrService 类 """ + s = loader.get_service("iqr") + + # 设置需要进行检测的输入数据 + s.set_input_list(AnomalyDetectionTest.input_list) + + # 测试 set_params 的处理逻辑 + try: + s.set_params({"k": 2}) + except ValueError as e: + self.assertEqual(1, 0) + + r = s.execute() + + # 绘制异常检测结果 + draw_ad_results(AnomalyDetectionTest.input_list, r, "iqr") + + # 检查结果 + self.assertEqual(r[-1], -1) + self.assertEqual(len(r), len(AnomalyDetectionTest.input_list)) +``` + +## 需要模型的算法 + +针对特定数据集,进行模型训练的算法,在训练完成后。需要将训练得到的模型保存在 model 目录中。需要注意的是,针对每个算法,需要建立独立的文件夹。例如 auto_encoder 的训练算法在 model 目录下建立了, autoencoder的目录,使用该算法针对不同数据集训练得到的模型,均需要放置在该目录下。 + +训练完成后的模型,使用 joblib 进行保存。 + +并在 model 目录下建立对应的文件夹存放该模型。 + +保存模型的调用,可参考 encoder.py 的方式,用户通过调用 set_params 方法,并指定参数 `{"model": "ad_encoder_keras"}` 的方式,可以调用该模型进行计算。 + +具体的调用方式如下: + +```python +def test_autoencoder_ad(self): + # 获取特定的算法服务 + s = loader.get_service("ac") + data = self.__load_remote_data_for_ad() + + # 设置异常检查的输入数据 + s.set_input_list(data) + + # 指定调用的模型,该模型是之前针对该数据集进行训练获得 + s.set_params({"model": "ad_encoder_keras"}) + # 执行检查动作,并返回结果 + r = s.execute() + + num_of_error = -(sum(filter(lambda x: x == -1, r))) + self.assertEqual(num_of_error, 109) +``` + diff --git a/docs/zh/06-advanced/06-data-analysis/index.md b/docs/zh/06-advanced/06-data-analysis/index.md index a1ca53d7d0c..e3bf2f4158f 100644 --- a/docs/zh/06-advanced/06-data-analysis/index.md +++ b/docs/zh/06-advanced/06-data-analysis/index.md @@ -5,9 +5,314 @@ title: 数据分析功能 ## 概述 -TDengine 提供数据分析功能的扩展组件,通过引入 ANode,TDengine 能够支持时间序列的机器学习分析 - -下图展示了数据分析的技术架构。 +TDengine 通过 ANode(AnalysisNode) 是提供数据分析功能的扩展组件,通过 Restful 接口提供分析服务,从而拓展 TDengine 的功能,支持时间序列高级分析功能。 +ANode 是无状态的数据分析节点,集群中可以存在多个 ANode节点,相互之间没有关联。将 ANode 注册到 TDengine 集群以后,通过 SQL 语句即可调用并完成时序分析任务。 +下图是数据分析的技术架构示意图。 ![数据分析功能架构图](./pic/data-analysis.png) +## 安装部署 +### 环境准备 +ANode 的要求节点上准备有 Python 3.10 及以上版本以及相应的Python包自动安装组件 Pip ,同时请确保能够正常连接互联网。 + +### 安装及卸载 +使用专门的 ANode 安装包 TDengine-enterprise-anode-1.x.x.tar.gz 进行 ANode 的安装部署工作,安装过程与 TDengien 的安装流程一致。 + +```bash +tar -xzvf TDengine-enterprise-anode-1.0.0.tar.gz +cd TDengine-enterprise-anode-1.0.0 +sudo ./install.sh +``` + +卸载 ANode,执行命令 `rmtaosanode` 即可。 + +### 其他 +为了避免 ANode 安装后影响目标节点现有的 Python 库。 ANode 使用 Python 虚拟环境运行,安装后的默认 Python 目录处于 `/var/lib/taos/taosanode/venv/`。为了避免反复安装虚拟环境带来的开销,卸载 ANode 并不会自动删除该虚拟环境,如果您确认不需要 Python 的虚拟环境,可以手动删除。 + +## 启动及停止服务 +安装 ANode 以后,可以使用`systemctl`来管理 ANode 的服务。使用如下命令可以启动/停止/检查状态。 + +```bash +systemctl start taosanoded +systemctl stop taosanoded +systemctl status taosanoded +``` + +## 目录及配置说明 +|目录/文件|说明| +|---------------|------| +|/usr/local/taos/taosanode/bin|可执行文件目录| +|/usr/local/taos/taosanode/resource|资源文件目录,链接到文件夹 /var/lib/taos/taosanode/resource/| +|/usr/local/taos/taosanode/lib|库文件目录| +|/var/lib/taos/taosanode/model/|模型文件目录,链接到文件夹 /var/lib/taos/taosanode/model| +|/var/log/taos/taosanode/|日志文件目录| +|/etc/taos/taosanode.ini|配置文件| + +### 配置说明 + +Anode 提供的 RestFul 服务使用 uWSGI 驱动,因此 ANode 的配置和 uWSGI 的配置在同一个配置文件中,具体如下: + +```ini +[uwsgi] +# charset +env=LC_ALL=en_US.UTF-8 + +# ip:port +http = 127.0.0.1:6050 + +# the local unix socket file than communicate to Nginx +#socket = 127.0.0.1:8001 +#socket-timeout=10 + +# base directory +chdir = /usr/local/taos/taosanode/lib + +# initialize python file +wsgi-file = /usr/local/taos/taosanode/lib/app.py + +# invoke app model +callable = app + +# auto remove unix Socket and pid file when stopping +vacuum = true + +# socket exec model +#chmod-socket = 664 + +# uWSGI pid +uid=root + +# uWSGI gid +gid=root + +# main process +master = true + +# the number of worker processes +processes = 2 + +# pid file +pidfile = /usr/local/taos/taosanode/uwsgi.pid + +# enable threads +enable-threads=true + +# the number of threads for each process +threads=2 + +# memory useage report +memory-report = true +reload-mercy = 10 + +# conflict with systemctl, so do NOT uncomment this +# daemonize = /var/log/taos/taosanode/taosanode.log + +# set log +logto = /var/log/taos/taosanode/taosanode.log + +# monitor server +stats = 127.0.0.1:8387 + +# python virtual environment directory +virtualenv = /usr/local/taos/taosanode/venv/ + +[taosanode] +# default app log file +app-log = /var/log/taos/taosanode/taosanode.app.log + +# model storage directory +model-dir=/usr/local/taos/taosanode/model/ + +# default log level +log-level = DEBUG +``` + +**提示** +请勿设置 `daemonize` 参数,该参数会导致 uWSGI 与 systemctl 冲突,从而无法正常启动。 + + +## ANode 基本操作 +### 管理 ANode +#### 创建 ANode +```sql +CREATE ANODE {node_url} +``` +node_url 是提供服务的 ANode 的 IP 和 PORT, 例如:`create anode 'http://localhost:6050'`。启动 ANode 以后如果不注册到 TDengine 集群中,无法提供正常的服务。不建议 ANode 注册到两个或多个集群中。 + +#### 查看 ANode +列出集群中所有的数据分析节点,包括其 `FQDN`, `PORT`, `STATUS`。 +```sql +SHOW ANODES; +``` + +#### 查看提供的时序数据分析服务 + +```SQL +SHOW ANODES FULL; +``` + +#### 强制刷新 TDengine 集群中分析算法缓存 +```SQL +UPDATE ANODE {node_id} +UPDATE ALL ANODES +``` + +#### 删除 ANode +```sql +DROP ANODE {anode_id} +``` +删除 ANode 只是将 ANode 从 TDengine 集群中删除,管理 ANode 的启停仍然需要使用`systemctl`命令。 + +### 时序数据分析功能 + +#### 白噪声检查 + +平台提供 Restful的服务检测输入时间序列是否是白噪声时间序列(White Noise Data, WND),白噪声时间序列及随机数序列。 +此外,分析平台要求输入的数据不能是 , 因此针对的所有数据均默认进行 白噪声检查。当前白噪声检查采用通行的 `Ljung-Box`检验,`Ljung-Box` 统计量检查过程需要遍历整个输入序列并进行计算。 +如果用户能够明确输入序列一定不是白噪声序列,那么可以通过输入参数,指定预测之前忽略该检查,从而节省分析过程的 CPU 计算资源。 +同时支持独立地针对输入序列进行白噪声检测(该检测功能暂不独立对外开放)。 + + +#### 数据重采样和时间戳对齐 + +数据分析平台支持将输入的数据进行重采样的预处理,从而确保输出结果按照用户指定的等间隔进行处理。处理过程分为两种类别: + +- 数据时间戳对齐。由于真实数据时间可能并非严格按照查询指定的时间戳输入。此时数据平台将自动将数据的时间间隔按照指定的时间间隔进行对齐。例如有输入时间序列:[11, 22, 29, 41],用户指定时间间隔为 10,那么该序列将被对齐重整为以下序列 [10, 20, 30, 40]。 +- 数据时间重采样。用户输入的时间序列其采样频率超过了指定的查询需要获得结果的时间间隔,例如输入原始数据是 5, 但是输出结果的频率是 10. [0, 5, 10, 15, 20, 25, 30],那么该输入数据列将重采用为间隔 为 10 的输入序列,其结果如下 [0, 10, 20,30]。[5, 15, 25] 处的数据将被丢弃。 + +需要注意的是,数据输入平台不支持缺失数据补齐后进行的预测分析,如果输入时间序列数据[11, 22, 29, 49],并且用户要求的时间间隔为 10, 重整对齐后的序列是 [10, 20, 30, 50] 那么该序列进行预测分析将返回错误。 + + +#### 时序数据异常检测 +异常检测是针对输入的时序数据,使用预设或用户指定的算法确定时间序列中**可能**出现异常时间序列点,对于时间序列中若干个连续的异常点,将自动合并成为一个连续的(闭区间)异常窗口。对于只有单个点的场景,异常窗口窗口退化成为一个起始时间和结束时间相同的点。 +异常检测生成的异常窗口受检测算法和算法参数的共同影响,对于异常窗口范围内的数据,可以应用 TDengine 提供的聚合和标量函数进行查询或变换处理。 +对于输入时间序列 (1, 20), (2, 22), (3, 91), (4, 120), (5, 18), (6, 19)。系统检测到 (3, 91), (4, 120) 为异常点,那么返回的异常窗口是闭区间 [3, 4]。 + + +##### 语法 + +```SQL +ANOMALY_WINDOW(column_name, option_expr) + +option_expr: {" +algo=expr1 +[,wncheck=1|0] +[,expr2] +"} +``` + +1. `column`:进行时序数据异常检测的输入数据列,当前只支持单列输入,且只能是数值类型,不能是字符类型(例如:`NCHAR` `VARCHAR` `VARBINARY`等类型),**不支持函数表达式**。 +2. `options`:字符串。其中使用 K/V 调用异常检测的算法,及与算法相关的参数。采用 逗号分隔的K/V字符串表示,其中的字符串不需要使用单引号、双引号、或转意号等符号,不能使用中文及其他宽字符。例如:`algo=ksigma, k=2` 表示进行异常检测的算法是 ksigma,该算法接受的输入参数是 2。 +3. 异常检测的结果可以作为外层查询的子查询输入,在 `SELECT` 子句中使用的聚合函数或标量函数与其他类型的窗口查询相同。 +4. 输入数据默认进行白噪声检查,如果检查结果是输入数据是白噪声,将不会有任何(异常)窗口信息返回。 + +**参数说明** +|参数|含义|默认值| +|---|---|---| +|algo|异常检测调用的算法|iqr| +|wncheck|对输入数据列是否进行白噪声检查|取值为0或者1,默认值为 1,表示进行白噪声检查| + +异常检测的返回结果以窗口的形式呈现,因此窗口查询相关的伪列在这种场景下仍然可用。可以使用的伪列如下: +1. `_WSTART`: 异常窗口开始时间戳 +2. `_WEND`:异常窗口结束时间戳 +3. `_WDURATION`:异常窗口持续时间 + +**示例** +```SQL +--- 使用 iqr 算法进行异常检测,检测列 i32 列。 +SELECT _wstart, _wend, SUM(i32) +FROM ai.atb +ANOMALY_WINDOW(i32, "algo=iqr"); + +--- 使用 ksigma 算法进行异常检测,输入参数 k 值为 2,检测列 i32 列 +SELECT _wstart, _wend, SUM(i32) +FROM ai.atb +ANOMALY_WINDOW(i32, "algo=ksigma,k=2"); +``` + +``` +taos> SELECT _wstart, _wend, count(*) FROM ai.atb ANOMAYL_WINDOW(i32); + _wstart | _wend | count(*) | +============================================================================ + 2020-01-01 00:00:16.000 | 2020-01-01 00:00:16.001 | 1 | +Query OK, 1 row(s) in set (0.028946s) +``` + + +**可用异常检测算法** +- iqr +- ksigma +- grubbs +- lof +- shesd +- tac + + +#### 时序数据预测 +数据预测以一段训练数据作为输入,预测接下来一个连续时间区间内,时序数据的趋势。 + +##### 语法 +```SQL +FORECAST(column_expr, option_expr) + +option_expr: {" +algo=expr1 +[,wncheck=1|0] +[,conf=conf_val] +[,every=every_val] +[,rows=rows_val] +[,start=start_ts_val] +[,expr2] +"} + +``` +1. `column_expr`:预测的时序数据列。与异常检测相同,只支持数值类型输入。 +2. `options`:异常检测函数的参数,使用规则与 anomaly_window 相同。预测还支持`conf`, `every`, `rows`, `start`, `rows` 几个参数,其含义如下: + +**参数说明** + +|参数|含义|默认值| +|---|---|---| +|algo|预测分析使用的算法|holtwinters| +|wncheck|白噪声(white noise data)检查|默认值为 1,0 表示不进行检查| +|conf|预测数据的置信区间范围 ,取值范围[0, 100]|95| +|every|预测数据的采样间隔|输入数据的采样间隔| +|start|预测结果的开始时间戳|输入数据最后一个时间戳加上一个采样时间段| +|rows|预测结果的记录数|10| + +1. 预测查询结果新增了三个伪列,具体如下: `_FROWTS`:预测结果的时间戳、`_FLOW`:置信区间下界、`_FHIGH`:置信区间上界, 对于没有置信区间的预测算法,其置信区间同预测结果 +2. 更改参数 `START`:返回预测结果的起始时间,改变这个起始时间不会影响返回的预测数值,只影响起始时间。 +3. `EVERY`:可以与输入数据的采样频率不同。采样频率只能低于或等于输入数据采样频率,不能**高于**输入数据的采样频率。 +4. 对于某些不需要计算置信区间的算法,即使指定了置信区间,返回的结果中其上下界退化成为一个点。 + +**示例** + +```SQL +--- 使用 arima 算法进行预测,预测结果是 10 条记录(默认值),数据进行白噪声检查,默认置信区间 95%. +SELECT _flow, _fhigh, _frowts, FORECAST(i32, "algo=arima") +FROM ai.ftb; + +--- 使用 arima 算法进行预测,输入数据的是周期数据,每10个采样点是一个周期。返回置信区间是 95%. +SELECT _flow, _fhigh, _frowts, FORECAST(i32, "algo=arima,alpha=95,period=10") +FROM ai.ftb; +``` +``` +taos> select _flow, _fhigh, _frowts, forecast(i32) from ai.ftb; + _flow | _fhigh | _frowts | forecast(i32) | +======================================================================================== + 10.5286684 | 41.8038254 | 2020-01-01 00:01:35.001 | 26 | + -21.9861946 | 83.3938904 | 2020-01-01 00:01:36.001 | 30 | + -78.5686035 | 144.6729126 | 2020-01-01 00:01:37.001 | 33 | + -154.9797363 | 230.3057709 | 2020-01-01 00:01:38.001 | 37 | + -253.9852905 | 337.6083984 | 2020-01-01 00:01:39.001 | 41 | + -375.7857971 | 466.4594727 | 2020-01-01 00:01:40.001 | 45 | + -514.8043823 | 622.4426270 | 2020-01-01 00:01:41.001 | 53 | + -680.6343994 | 796.2861328 | 2020-01-01 00:01:42.001 | 57 | + -868.4956665 | 992.8603516 | 2020-01-01 00:01:43.001 | 62 | + -1076.1566162 | 1214.4498291 | 2020-01-01 00:01:44.001 | 69 | +``` + + +**可用预测算法** +- arima +- holtwinters diff --git a/docs/zh/06-advanced/06-data-analysis/pic/data-analysis.png b/docs/zh/06-advanced/06-data-analysis/pic/data-analysis.png index 1598238f2cc..44fd82832f3 100644 Binary files a/docs/zh/06-advanced/06-data-analysis/pic/data-analysis.png and b/docs/zh/06-advanced/06-data-analysis/pic/data-analysis.png differ diff --git a/docs/zh/06-advanced/06-data-analysis/pic/dir.png b/docs/zh/06-advanced/06-data-analysis/pic/dir.png new file mode 100644 index 00000000000..d5aafb44274 Binary files /dev/null and b/docs/zh/06-advanced/06-data-analysis/pic/dir.png differ diff --git a/docs/zh/14-reference/01-components/01-taosd.md b/docs/zh/14-reference/01-components/01-taosd.md index f11321c84f1..89a97b108d0 100644 --- a/docs/zh/14-reference/01-components/01-taosd.md +++ b/docs/zh/14-reference/01-components/01-taosd.md @@ -156,8 +156,8 @@ charset 的有效值是 UTF-8。 ### 内存相关 | 参数名称 | 参数说明 | | :----------------: | :---------------------------------------------: | -| rpcQueueMemoryAllowed | 一个 dnode 允许的 rpc 消息占用的内存最大值,单位 bytes,取值范围:10485760-INT64_MAX,缺省值:服务器内存的 1/10 | -| syncLogBufferMemoryAllowed | 一个 dnode 允许的 sync 日志缓存消息占用的内存最大值,单位 bytes,取值范围:10485760-INT64_MAX,缺省值:服务器内存的 1/10,3.1.3.2/3.3.2.13 版本开始生效 | +| rpcQueueMemoryAllowed | 一个 dnode 允许的 rpc 消息占用的内存最大值,单位 bytes,取值范围:104857600-INT64_MAX,缺省值:服务器内存的 1/10 | +| syncLogBufferMemoryAllowed | 一个 dnode 允许的 sync 日志缓存消息占用的内存最大值,单位 bytes,取值范围:104857600-INT64_MAX,缺省值:服务器内存的 1/10,3.1.3.2/3.3.2.13 版本开始生效 | ### 性能调优 @@ -180,6 +180,7 @@ charset 的有效值是 UTF-8。 | tmrDebugFlag | 定时器模块的日志开关,取值范围同上 | | uDebugFlag | 共用功能模块的日志开关,取值范围同上 | | rpcDebugFlag | rpc 模块的日志开关,取值范围同上 | +| cDebugFlag | 客户端模块的日志开关,取值范围同上 | | jniDebugFlag | jni 模块的日志开关,取值范围同上 | | qDebugFlag | query 模块的日志开关,取值范围同上 | | dDebugFlag | dnode 模块的日志开关,取值范围同上,缺省值 135 | diff --git a/docs/zh/14-reference/01-components/02-taosc.md b/docs/zh/14-reference/01-components/02-taosc.md index d9f36a2df77..bd1e700041e 100755 --- a/docs/zh/14-reference/01-components/02-taosc.md +++ b/docs/zh/14-reference/01-components/02-taosc.md @@ -35,6 +35,7 @@ TDengine 客户端驱动提供了应用编程所需要的全部 API,并且在 |smlAutoChildTableNameDelimiter | schemaless tag之间的连接符,连起来作为子表名,无缺省值 | |smlTagName | schemaless tag 为空时默认的 tag 名字, 缺省值 "_tag_null" | |smlTsDefaultName | schemaless自动建表的时间列名字通过该配置设置, 缺省值 "_ts" | +|smlDot2Underline | schemaless 把超级表名中的 dot 转成下划线 | |enableCoreFile | crash 时是否生成 core 文件,0: 不生成, 1: 生成;缺省值:1 | |enableScience | 是否开启科学计数法显示浮点数; 0: 不开始, 1: 开启;缺省值:1 | |compressMsgSize | 是否对 RPC 消息进行压缩; -1: 所有消息都不压缩; 0: 所有消息都压缩; N (N>0): 只有大于 N 个字节的消息才压缩; 缺省值 -1| diff --git a/docs/zh/14-reference/02-tools/10-taosbenchmark.md b/docs/zh/14-reference/02-tools/10-taosbenchmark.md index 303cfaa395c..d6552905778 100644 --- a/docs/zh/14-reference/02-tools/10-taosbenchmark.md +++ b/docs/zh/14-reference/02-tools/10-taosbenchmark.md @@ -364,7 +364,7 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\) - **max** : 数据类型的 列/标签 的最大值。生成的值将小于最小值。 -- **scalingFactor** : 浮点数精度增强因子,仅当数据类型是float/double时生效,有效值范围为1至1000000的正整数。用于增强生成浮点数的精度,特别是在min或max值较小的情况下。此属性按10的幂次增强小数点后的精度:scalingFactor为10表示增强1位小数精度,100表示增强2位,依此类推。 +- **scalingFactor** : 浮点数精度增强因子,仅当数据类型是 float/double 时生效,有效值范围为 1 至 1000000 的正整数。用于增强生成浮点数的精度,特别是在 min 或 max 值较小的情况下。此属性按 10 的幂次增强小数点后的精度:scalingFactor 为 10 表示增强 1 位小数精度,100 表示增强 2 位,依此类推。 - **fun** : 此列数据以函数填充,目前只支持 sin 和 cos 两函数,输入参数为时间戳换算成角度值,换算公式: 角度 x = 输入的时间列ts值 % 360。同时支持系数调节,随机波动因子调节,以固定格式的表达式展现,如 fun=“10\*sin(x)+100\*random(5)” , x 表示角度,取值 0 ~ 360度,增长步长与时间列步长一致。10 表示乘的系数,100 表示加或减的系数,5 表示波动幅度在 5% 的随机范围内。目前支持的数据类型为 int, bigint, float, double 四种数据类型。注意:表达式为固定模式,不可前后颠倒。 diff --git a/docs/zh/14-reference/03-taos-sql/02-database.md b/docs/zh/14-reference/03-taos-sql/02-database.md index 7d040a2c44f..24eca979522 100644 --- a/docs/zh/14-reference/03-taos-sql/02-database.md +++ b/docs/zh/14-reference/03-taos-sql/02-database.md @@ -30,6 +30,7 @@ database_option: { | SINGLE_STABLE {0 | 1} | TABLE_PREFIX value | TABLE_SUFFIX value + | DNODES value | TSDB_PAGESIZE value | WAL_LEVEL {1 | 2} | WAL_FSYNC_PERIOD value @@ -63,19 +64,20 @@ database_option: { - MAXROWS:文件块中记录的最大条数,默认为 4096 条。 - MINROWS:文件块中记录的最小条数,默认为 100 条。 - KEEP:表示数据文件保存的天数,缺省值为 3650,取值范围 [1, 365000],且必须大于或等于3倍的 DURATION 参数值。数据库会自动删除保存时间超过 KEEP 值的数据。KEEP 可以使用加单位的表示形式,如 KEEP 100h、KEEP 10d 等,支持 m(分钟)、h(小时)和 d(天)三个单位。也可以不写单位,如 KEEP 50,此时默认单位为天。企业版支持[多级存储](https://docs.taosdata.com/tdinternal/arch/#%E5%A4%9A%E7%BA%A7%E5%AD%98%E5%82%A8)功能, 因此, 可以设置多个保存时间(多个以英文逗号分隔,最多 3 个,满足 keep 0 \<= keep 1 \<= keep 2,如 KEEP 100h,100d,3650d); 社区版不支持多级存储功能(即使配置了多个保存时间, 也不会生效, KEEP 会取最大的保存时间)。 -- STT_TRIGGER:表示落盘文件触发文件合并的个数。默认为 1,范围 1 到 16。对于少表高频场景,此参数建议使用默认配置,或较小的值;而对于多表低频场景,此参数建议配置较大的值。 +- STT_TRIGGER:表示落盘文件触发文件合并的个数。开源版本固定为 1,企业版本可设置范围为 1 到 16。对于少表高频写入场景,此参数建议使用默认配置;而对于多表低频写入场景,此参数建议配置较大的值。 - SINGLE_STABLE:表示此数据库中是否只可以创建一个超级表,用于超级表列非常多的情况。 - 0:表示可以创建多张超级表。 - 1:表示只可以创建一张超级表。 - TABLE_PREFIX:当其为正值时,在决定把一个表分配到哪个 vgroup 时要忽略表名中指定长度的前缀;当其为负值时,在决定把一个表分配到哪个 vgroup 时只使用表名中指定长度的前缀;例如,假定表名为 "v30001",当 TSDB_PREFIX = 2 时 使用 "0001" 来决定分配到哪个 vgroup ,当 TSDB_PREFIX = -2 时使用 "v3" 来决定分配到哪个 vgroup - TABLE_SUFFIX:当其为正值时,在决定把一个表分配到哪个 vgroup 时要忽略表名中指定长度的后缀;当其为负值时,在决定把一个表分配到哪个 vgroup 时只使用表名中指定长度的后缀;例如,假定表名为 "v30001",当 TSDB_SUFFIX = 2 时 使用 "v300" 来决定分配到哪个 vgroup ,当 TSDB_SUFFIX = -2 时使用 "01" 来决定分配到哪个 vgroup。 - TSDB_PAGESIZE:一个 VNODE 中时序数据存储引擎的页大小,单位为 KB,默认为 4 KB。范围为 1 到 16384,即 1 KB到 16 MB。 +- DNODES:指定 VNODE 所在的 DNODE 列表,如 '1,2,3',以逗号区分且字符间不能有空格,仅企业版支持。 - WAL_LEVEL:WAL 级别,默认为 1。 - 1:写 WAL,但不执行 fsync。 - 2:写 WAL,而且执行 fsync。 - WAL_FSYNC_PERIOD:当 WAL_LEVEL 参数设置为 2 时,用于设置落盘的周期。默认为 3000,单位毫秒。最小为 0,表示每次写入立即落盘;最大为 180000,即三分钟。 -- WAL_RETENTION_PERIOD: 为了数据订阅消费,需要WAL日志文件额外保留的最大时长策略。WAL日志清理,不受订阅客户端消费状态影响。单位为 s。默认为 3600,表示在 WAL 保留最近 3600 秒的数据,请根据数据订阅的需要修改这个参数为适当值。 -- WAL_RETENTION_SIZE:为了数据订阅消费,需要WAL日志文件额外保留的最大累计大小策略。单位为 KB。默认为 0,表示累计大小无上限。 +- WAL_RETENTION_PERIOD: 为了数据订阅消费,需要 WAL 日志文件额外保留的最大时长策略。WAL 日志清理,不受订阅客户端消费状态影响。单位为 s。默认为 3600,表示在 WAL 保留最近 3600 秒的数据,请根据数据订阅的需要修改这个参数为适当值。 +- WAL_RETENTION_SIZE:为了数据订阅消费,需要 WAL 日志文件额外保留的最大累计大小策略。单位为 KB。默认为 0,表示累计大小无上限。 ### 创建数据库示例 ```sql diff --git a/docs/zh/14-reference/03-taos-sql/03-table.md b/docs/zh/14-reference/03-taos-sql/03-table.md index 9e4cc66eaf5..81ad60e3d23 100644 --- a/docs/zh/14-reference/03-taos-sql/03-table.md +++ b/docs/zh/14-reference/03-taos-sql/03-table.md @@ -42,12 +42,12 @@ table_option: { **使用说明** 1. 表(列)名命名规则参见[名称命名规则](./19-limit.md#名称命名规则)。 -1. 表名最大长度为 192。 -1. 表的第一个字段必须是 TIMESTAMP,并且系统自动将其设为主键。 -1. 除时间戳主键列之外,还可以通过 PRIMARY KEY 关键字指定第二列为额外的主键列。被指定为主键列的第二列必须为整型或字符串类型(varchar)。 -1. 表的每行长度不能超过 48KB(从 3.0.5.0 版本开始为 64KB);(注意:每个 BINARY/NCHAR/GEOMETRY 类型的列还会额外占用 2 个字节的存储位置)。 -1. 使用数据类型 BINARY/NCHAR/GEOMETRY,需指定其最长的字节数,如 BINARY(20),表示 20 字节。 -1. 关于 `ENCODE` 和 `COMPRESS` 的使用,请参考[按列压缩](../compress) +2. 表名最大长度为 192。 +3. 表的第一个字段必须是 TIMESTAMP,并且系统自动将其设为主键。 +4. 除时间戳主键列之外,还可以通过 PRIMARY KEY 关键字指定第二列为额外的主键列。被指定为主键列的第二列必须为整型或字符串类型(VARCHAR)。 +5. 表的每行长度不能超过 48KB(从 3.0.5.0 版本开始为 64KB);(注意:每个 VARCHAR/NCHAR/GEOMETRY 类型的列还会额外占用 2 个字节的存储位置)。 +6. 使用数据类型 VARCHAR/NCHAR/GEOMETRY,需指定其最长的字节数,如 VARCHAR(20),表示 20 字节。 +7. 关于 `ENCODE` 和 `COMPRESS` 的使用,请参考[按列压缩](../compress) **参数说明** diff --git a/docs/zh/14-reference/03-taos-sql/07-tag-index.md b/docs/zh/14-reference/03-taos-sql/07-tag-index.md index 383c5b2a1f0..364d465ba39 100644 --- a/docs/zh/14-reference/03-taos-sql/07-tag-index.md +++ b/docs/zh/14-reference/03-taos-sql/07-tag-index.md @@ -11,7 +11,7 @@ description: 使用标签索引提升查询性能 创建索引的语法如下 ```sql -CREATE INDEX index_name ON tbl_name (tagColName) +CREATE INDEX index_name ON tbl_name (tagColName) ``` 其中 `index_name` 为索引名称, `tbl_name` 为超级表名称,`tagColName` 为要在其上建立索引的 tag 列的名称。`tagColName` 的类型不受限制,即任何类型的 tag 列都可以建立索引。 diff --git a/docs/zh/14-reference/03-taos-sql/14-stream.md b/docs/zh/14-reference/03-taos-sql/14-stream.md index 6baad76e232..dc0f404fcfd 100644 --- a/docs/zh/14-reference/03-taos-sql/14-stream.md +++ b/docs/zh/14-reference/03-taos-sql/14-stream.md @@ -291,3 +291,4 @@ RESUME STREAM [IF EXISTS] [IGNORE UNTREATED] stream_name; CREATE SNODE ON DNODE [id] ``` 其中的 id 是集群中的 dnode 的序号。请注意选择的dnode,流计算的中间状态将自动在其上进行备份。 +从 3.3.4.0 版本开始,在多副本环境中创建流会进行 snode 的**存在性检查**,要求首先创建 snode。如果 snode 不存在,无法创建流。 diff --git a/docs/zh/14-reference/05-connector/35-node.mdx b/docs/zh/14-reference/05-connector/35-node.mdx index 6ac34d24717..d9512eae78d 100644 --- a/docs/zh/14-reference/05-connector/35-node.mdx +++ b/docs/zh/14-reference/05-connector/35-node.mdx @@ -26,6 +26,7 @@ Node.js 连接器目前仅支持 WebSocket 连接器, 其通过 taosAdapter | Node.js 连接器 版本 | 主要变化 | TDengine 版本 | | :------------------: | :----------------------: | :----------------: | +| 3.1.1 | 优化了数据传输性能 | 3.3.2.0 及更高版本 | | 3.1.0 | 新版本发布,支持 WebSocket 连接 | 3.2.0.0 及更高版本 | ## 处理异常 diff --git a/docs/zh/14-reference/05-connector/index.md b/docs/zh/14-reference/05-connector/index.md index bd2cff6a3d2..4142d111e01 100644 --- a/docs/zh/14-reference/05-connector/index.md +++ b/docs/zh/14-reference/05-connector/index.md @@ -34,8 +34,8 @@ TDengine 版本更新往往会增加新的功能特性,列表中的连接器 | **3.0.0.0 及以上** | 3.0.2以上 | 当前版本 | 3.0 分支 | 3.0.0 | 3.1.0 | 当前版本 | 与 TDengine 相同版本 | | **2.4.0.14 及以上** | 2.0.38 | 当前版本 | develop 分支 | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | 当前版本 | 与 TDengine 相同版本 | | **2.4.0.4 - 2.4.0.13** | 2.0.37 | 当前版本 | develop 分支 | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | 当前版本 | 与 TDengine 相同版本 | -| **2.2.x.x ** | 2.0.36 | 当前版本 | master 分支 | n/a | 2.0.7 - 2.0.9 | 当前版本 | 与 TDengine 相同版本 | -| **2.0.x.x ** | 2.0.34 | 当前版本 | master 分支 | n/a | 2.0.1 - 2.0.6 | 当前版本 | 与 TDengine 相同版本 | +| **2.2.x.x** | 2.0.36 | 当前版本 | master 分支 | n/a | 2.0.7 - 2.0.9 | 当前版本 | 与 TDengine 相同版本 | +| **2.0.x.x** | 2.0.34 | 当前版本 | master 分支 | n/a | 2.0.1 - 2.0.6 | 当前版本 | 与 TDengine 相同版本 | ## 功能特性 diff --git a/include/client/taos.h b/include/client/taos.h index 80dbe27c471..924d0ff66e4 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -81,6 +81,13 @@ typedef enum { TSDB_SML_TIMESTAMP_NANO_SECONDS, } TSDB_SML_TIMESTAMP_TYPE; +typedef enum TAOS_FIELD_T { + TAOS_FIELD_COL = 1, + TAOS_FIELD_TAG, + TAOS_FIELD_QUERY, + TAOS_FIELD_TBNAME, +} TAOS_FIELD_T; + typedef struct taosField { char name[65]; int8_t type; @@ -95,6 +102,15 @@ typedef struct TAOS_FIELD_E { int32_t bytes; } TAOS_FIELD_E; +typedef struct TAOS_FIELD_STB { + char name[65]; + int8_t type; + uint8_t precision; + uint8_t scale; + int32_t bytes; + TAOS_FIELD_T field_type; +} TAOS_FIELD_STB; + #ifdef WINDOWS #define DLL_EXPORT __declspec(dllexport) #else @@ -195,13 +211,6 @@ DLL_EXPORT int taos_stmt_affected_rows_once(TAOS_STMT *stmt); typedef void TAOS_STMT2; -typedef enum TAOS_FIELD_T { - TAOS_FIELD_COL = 1, - TAOS_FIELD_TAG, - TAOS_FIELD_QUERY, - TAOS_FIELD_TBNAME, -} TAOS_FIELD_T; - typedef struct TAOS_STMT2_OPTION { int64_t reqid; bool singleStbInsert; @@ -232,7 +241,9 @@ DLL_EXPORT int taos_stmt2_exec(TAOS_STMT2 *stmt, int *affected_rows); DLL_EXPORT int taos_stmt2_close(TAOS_STMT2 *stmt); DLL_EXPORT int taos_stmt2_is_insert(TAOS_STMT2 *stmt, int *insert); DLL_EXPORT int taos_stmt2_get_fields(TAOS_STMT2 *stmt, TAOS_FIELD_T field_type, int *count, TAOS_FIELD_E **fields); +DLL_EXPORT int taos_stmt2_get_stb_fields(TAOS_STMT2 *stmt, int *count, TAOS_FIELD_STB **fields); DLL_EXPORT void taos_stmt2_free_fields(TAOS_STMT2 *stmt, TAOS_FIELD_E *fields); +DLL_EXPORT void taos_stmt2_free_stb_fields(TAOS_STMT2 *stmt, TAOS_FIELD_STB *fields); DLL_EXPORT TAOS_RES *taos_stmt2_result(TAOS_STMT2 *stmt); DLL_EXPORT char *taos_stmt2_error(TAOS_STMT2 *stmt); @@ -251,17 +262,17 @@ DLL_EXPORT int64_t taos_affected_rows64(TAOS_RES *res); DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res); DLL_EXPORT int taos_select_db(TAOS *taos, const char *db); DLL_EXPORT int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields); -DLL_EXPORT int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD *fields, int num_fields); -DLL_EXPORT void taos_stop_query(TAOS_RES *res); -DLL_EXPORT bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col); -DLL_EXPORT int taos_is_null_by_column(TAOS_RES *res, int columnIndex, bool result[], int *rows); -DLL_EXPORT bool taos_is_update_query(TAOS_RES *res); -DLL_EXPORT int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows); -DLL_EXPORT int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows); -DLL_EXPORT int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData); -DLL_EXPORT int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex); -DLL_EXPORT int taos_validate_sql(TAOS *taos, const char *sql); -DLL_EXPORT void taos_reset_current_db(TAOS *taos); +DLL_EXPORT int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD *fields, int num_fields); +DLL_EXPORT void taos_stop_query(TAOS_RES *res); +DLL_EXPORT bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col); +DLL_EXPORT int taos_is_null_by_column(TAOS_RES *res, int columnIndex, bool result[], int *rows); +DLL_EXPORT bool taos_is_update_query(TAOS_RES *res); +DLL_EXPORT int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows); +DLL_EXPORT int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows); +DLL_EXPORT int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData); +DLL_EXPORT int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex); +DLL_EXPORT int taos_validate_sql(TAOS *taos, const char *sql); +DLL_EXPORT void taos_reset_current_db(TAOS *taos); DLL_EXPORT int *taos_fetch_lengths(TAOS_RES *res); DLL_EXPORT TAOS_ROW *taos_result_block(TAOS_RES *res); diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 41fb692e42e..fc47166a606 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -194,10 +194,10 @@ extern int32_t tsMinIntervalTime; extern int32_t tsMaxInsertBatchRows; // build info -extern char version[]; -extern char compatible_version[]; -extern char gitinfo[]; -extern char buildinfo[]; +extern char td_version[]; +extern char td_compatible_version[]; +extern char td_gitinfo[]; +extern char td_buildinfo[]; // lossy extern char tsLossyColumns[]; diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 739d257d86e..cdcbb84462b 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -421,7 +421,7 @@ typedef enum ENodeType { // physical plan node QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN = 1100, QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN, - QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN, + QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN, // INACTIVE QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN, @@ -435,7 +435,7 @@ typedef enum ENodeType { QUERY_NODE_PHYSICAL_PLAN_SORT, QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT, QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL, - QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL, + QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL, // INACTIVE QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL, QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL, QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL, @@ -1337,6 +1337,7 @@ typedef struct { char* sql; int8_t withArbitrator; int8_t encryptAlgorithm; + char dnodeListStr[TSDB_DNODE_LIST_LEN]; } SCreateDbReq; int32_t tSerializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq); diff --git a/include/common/ttypes.h b/include/common/ttypes.h index 3934553b1c0..0ef47cdd12e 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -238,12 +238,26 @@ typedef struct { case TSDB_DATA_TYPE_UBIGINT: \ snprintf(_output, (int32_t)(_outputBytes), "%" PRIu64, *(uint64_t *)(_input)); \ break; \ - case TSDB_DATA_TYPE_FLOAT: \ - snprintf(_output, (int32_t)(_outputBytes), "%f", *(float *)(_input)); \ + case TSDB_DATA_TYPE_FLOAT: { \ + int32_t n = snprintf(_output, (int32_t)(_outputBytes), "%f", *(float *)(_input)); \ + if (n >= (_outputBytes)) { \ + n = snprintf(_output, (int32_t)(_outputBytes), "%.7e", *(float *)(_input)); \ + if (n >= (_outputBytes)) { \ + snprintf(_output, (int32_t)(_outputBytes), "%f", *(float *)(_input)); \ + } \ + } \ break; \ - case TSDB_DATA_TYPE_DOUBLE: \ - snprintf(_output, (int32_t)(_outputBytes), "%f", *(double *)(_input)); \ + } \ + case TSDB_DATA_TYPE_DOUBLE: { \ + int32_t n = snprintf(_output, (int32_t)(_outputBytes), "%f", *(double *)(_input)); \ + if (n >= (_outputBytes)) { \ + snprintf(_output, (int32_t)(_outputBytes), "%.15e", *(double *)(_input)); \ + if (n >= (_outputBytes)) { \ + snprintf(_output, (int32_t)(_outputBytes), "%f", *(double *)(_input)); \ + } \ + } \ break; \ + } \ case TSDB_DATA_TYPE_UINT: \ snprintf(_output, (int32_t)(_outputBytes), "%u", *(uint32_t *)(_input)); \ break; \ diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index e5bacf85b29..3b5201aa1e2 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -26,6 +26,8 @@ extern "C" { #define FUNC_AGGREGATE_UDF_ID 5001 #define FUNC_SCALAR_UDF_ID 5002 +extern const int32_t funcMgtBuiltinsNum; + typedef enum EFunctionType { // aggregate function FUNCTION_TYPE_APERCENTILE = 1, diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index bbf28892898..514eddbc249 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -72,6 +72,7 @@ typedef struct SDatabaseOptions { int8_t compressionLevel; int8_t encryptAlgorithm; int32_t daysPerFile; + char dnodeListStr[TSDB_DNODE_LIST_LEN]; char encryptAlgorithmStr[TSDB_ENCRYPT_ALGO_STR_LEN]; SValueNode* pDaysPerFile; int32_t fsyncPeriod; diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index a05211ece3c..6d09ef6d88a 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -788,9 +788,9 @@ typedef struct SDataDeleterNode { char tableFName[TSDB_TABLE_NAME_LEN]; char tsColName[TSDB_COL_NAME_LEN]; STimeWindow deleteTimeRange; - SNode* pAffectedRows; - SNode* pStartTs; - SNode* pEndTs; + SNode* pAffectedRows; // usless + SNode* pStartTs; // usless + SNode* pEndTs; // usless } SDataDeleterNode; typedef struct SSubplan { diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index 832e4f8863e..0fb6261ac83 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -65,7 +65,7 @@ typedef struct SParseCsvCxt { const char* pLastSqlPos; // the location of the last parsed sql } SParseCsvCxt; -typedef void(*setQueryFn)(int64_t); +typedef void (*setQueryFn)(int64_t); typedef struct SParseContext { uint64_t requestId; @@ -147,6 +147,7 @@ int32_t qBindStmtColsValue(void* pBlock, SArray* pCols, TAOS_MULTI_BIND* bind, c int32_t qBindStmtSingleColValue(void* pBlock, SArray* pCols, TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen, int32_t colIdx, int32_t rowNum); int32_t qBuildStmtColFields(void* pDataBlock, int32_t* fieldNum, TAOS_FIELD_E** fields); +int32_t qBuildStmtStbColFields(void* pBlock, int32_t* fieldNum, TAOS_FIELD_STB** fields); int32_t qBuildStmtTagFields(void* pBlock, void* boundTags, int32_t* fieldNum, TAOS_FIELD_E** fields); int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const char* sTableName, char* tName, TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen); diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index 81a39524631..d2f714f4008 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -364,7 +364,7 @@ void* getTaskPoolWorkerCb(); #define NEED_CLIENT_REFRESH_VG_ERROR(_code) \ ((_code) == TSDB_CODE_VND_HASH_MISMATCH || (_code) == TSDB_CODE_VND_INVALID_VGROUP_ID) #define NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code) \ - ((_code) == TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER || (_code) == TSDB_CODE_MND_INVALID_SCHEMA_VER) + ((_code) == TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER || (_code) == TSDB_CODE_MND_INVALID_SCHEMA_VER || (_code) == TSDB_CODE_SCH_DATA_SRC_EP_MISS) #define NEED_CLIENT_HANDLE_ERROR(_code) \ (NEED_CLIENT_RM_TBLMETA_ERROR(_code) || NEED_CLIENT_REFRESH_VG_ERROR(_code) || \ NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code)) diff --git a/include/libs/scheduler/scheduler.h b/include/libs/scheduler/scheduler.h index b98170f1685..af8deff1a02 100644 --- a/include/libs/scheduler/scheduler.h +++ b/include/libs/scheduler/scheduler.h @@ -76,8 +76,6 @@ int32_t schedulerExecJob(SSchedulerReq* pReq, int64_t* pJob); int32_t schedulerFetchRows(int64_t jobId, SSchedulerReq* pReq); -void schedulerFetchRowsA(int64_t job, schedulerFetchFp fp, void* param); - int32_t schedulerGetTasksStatus(int64_t job, SArray* pSub); void schedulerStopQueryHb(void* pTrans); @@ -100,6 +98,8 @@ void schedulerFreeJob(int64_t* job, int32_t errCode); void schedulerDestroy(void); +int32_t schedulerValidatePlan(SQueryPlan* pPlan); + #ifdef __cplusplus } #endif diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index a189cee0bbb..81be70e35f7 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -70,7 +70,8 @@ typedef struct SActiveCheckpointInfo SActiveCheckpointInfo; #define SSTREAM_TASK_NEED_CONVERT_VER 2 #define SSTREAM_TASK_SUBTABLE_CHANGED_VER 3 -extern int32_t streamMetaId; +extern int32_t streamMetaRefPool; +extern int32_t streamTaskRefPool; enum { STREAM_STATUS__NORMAL = 0, @@ -258,6 +259,7 @@ typedef struct STaskId { typedef struct SStreamTaskId { int64_t streamId; int32_t taskId; + int64_t refId; const char* idStr; } SStreamTaskId; @@ -291,7 +293,6 @@ typedef struct SStreamStatus { int8_t schedStatus; int8_t statusBackup; int32_t schedIdleTime; // idle time before invoke again - int32_t timerActive; // timer is active int64_t lastExecTs; // last exec time stamp int32_t inScanHistorySentinel; bool appendTranstateBlock; // has append the transfer state data block already @@ -454,7 +455,6 @@ struct SStreamTask { // the followings attributes don't be serialized SScanhistorySchedInfo schedHistoryInfo; - int32_t refCnt; int32_t transferStateAlignCnt; struct SStreamMeta* pMeta; SSHashObj* pNameMap; @@ -546,7 +546,7 @@ typedef int32_t (*__state_trans_user_fn)(SStreamTask*, void* param); int32_t tNewStreamTask(int64_t streamId, int8_t taskLevel, SEpSet* pEpset, bool fillHistory, int64_t triggerParam, SArray* pTaskList, bool hasFillhistory, int8_t subtableWithoutMd5, SStreamTask** pTask); -void tFreeStreamTask(SStreamTask* pTask); +void tFreeStreamTask(void* pTask); int32_t tEncodeStreamTask(SEncoder* pEncoder, const SStreamTask* pTask); int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask); int32_t streamTaskInit(SStreamTask* pTask, SStreamMeta* pMeta, SMsgCb* pMsgCb, int64_t ver); @@ -664,6 +664,8 @@ void streamTaskResetStatus(SStreamTask* pTask); void streamTaskSetStatusReady(SStreamTask* pTask); ETaskStatus streamTaskGetPrevStatus(const SStreamTask* pTask); const char* streamTaskGetExecType(int32_t type); +int32_t streamTaskAllocRefId(SStreamTask* pTask, int64_t** pRefId); +void streamTaskFreeRefId(int64_t* pRefId); bool streamTaskUpdateEpsetInfo(SStreamTask* pTask, SArray* pNodeList); void streamTaskResetUpstreamStageInfo(SStreamTask* pTask); @@ -752,16 +754,15 @@ int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTa int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId); int32_t streamMetaGetNumOfTasks(SStreamMeta* pMeta); int32_t streamMetaAcquireTaskNoLock(SStreamMeta* pMeta, int64_t streamId, int32_t taskId, SStreamTask** pTask); +int32_t streamMetaAcquireTaskUnsafe(SStreamMeta* pMeta, STaskId* pId, SStreamTask** pTask); int32_t streamMetaAcquireTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId, SStreamTask** pTask); void streamMetaReleaseTask(SStreamMeta* pMeta, SStreamTask* pTask); -int32_t streamMetaAcquireOneTask(SStreamTask* pTask); void streamMetaClear(SStreamMeta* pMeta); void streamMetaInitBackend(SStreamMeta* pMeta); int32_t streamMetaCommit(SStreamMeta* pMeta); int64_t streamMetaGetLatestCheckpointId(SStreamMeta* pMeta); void streamMetaNotifyClose(SStreamMeta* pMeta); void streamMetaStartHb(SStreamMeta* pMeta); -bool streamMetaTaskInTimer(SStreamMeta* pMeta); int32_t streamMetaAddTaskLaunchResult(SStreamMeta* pMeta, int64_t streamId, int32_t taskId, int64_t startTs, int64_t endTs, bool ready); int32_t streamMetaInitStartInfo(STaskStartInfo* pStartInfo); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index a53923b904b..9a8b39b84c9 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -352,6 +352,8 @@ int32_t taosGetErrSize(); #define TSDB_CODE_MND_INVALID_SYS_TABLENAME TAOS_DEF_ERROR_CODE(0, 0x039A) #define TSDB_CODE_MND_ENCRYPT_NOT_ALLOW_CHANGE TAOS_DEF_ERROR_CODE(0, 0x039B) #define TSDB_CODE_MND_INVALID_WAL_LEVEL TAOS_DEF_ERROR_CODE(0, 0x039C) +#define TSDB_CODE_MND_INVALID_DNODE_LIST_FMT TAOS_DEF_ERROR_CODE(0, 0x039D) +#define TSDB_CODE_MND_DNODE_LIST_REPEAT TAOS_DEF_ERROR_CODE(0, 0x039E) // mnode-node #define TSDB_CODE_MND_MNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A0) @@ -771,6 +773,7 @@ int32_t taosGetErrSize(); #define TSDB_CODE_SCH_TIMEOUT_ERROR TAOS_DEF_ERROR_CODE(0, 0x2504) #define TSDB_CODE_SCH_JOB_IS_DROPPING TAOS_DEF_ERROR_CODE(0, 0x2505) #define TSDB_CODE_SCH_JOB_NOT_EXISTS TAOS_DEF_ERROR_CODE(0, 0x2506) +#define TSDB_CODE_SCH_DATA_SRC_EP_MISS TAOS_DEF_ERROR_CODE(0, 0x2507) //parser #define TSDB_CODE_PAR_SYNTAX_ERROR TAOS_DEF_ERROR_CODE(0, 0x2600) diff --git a/include/util/tcompression.h b/include/util/tcompression.h index 1f09b750cbe..140b7fe392a 100644 --- a/include/util/tcompression.h +++ b/include/util/tcompression.h @@ -152,15 +152,12 @@ int32_t tsDecompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int // for internal usage int32_t getWordLength(char type); -#ifdef __AVX2__ int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements, char *const output, const char type); int32_t tsDecompressFloatImpAvx2(const char *input, int32_t nelements, char *output); int32_t tsDecompressDoubleImpAvx2(const char *input, int32_t nelements, char *output); -#endif -#ifdef __AVX512VL__ -void tsDecompressTimestampAvx2(const char *input, int32_t nelements, char *output, bool bigEndian); -void tsDecompressTimestampAvx512(const char *const input, const int32_t nelements, char *const output, bool bigEndian); -#endif +int32_t tsDecompressTimestampAvx2(const char *input, int32_t nelements, char *output, bool bigEndian); +int32_t tsDecompressTimestampAvx512(const char *const input, const int32_t nelements, char *const output, + bool bigEndian); /************************************************************************* * REGULAR COMPRESSION 2 diff --git a/include/util/tdef.h b/include/util/tdef.h index b924b377dad..7ef01f9752f 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -41,6 +41,7 @@ extern const int32_t TYPE_BYTES[21]; #define FLOAT_BYTES sizeof(float) #define DOUBLE_BYTES sizeof(double) #define POINTER_BYTES sizeof(void *) +#define M256_BYTES 32 #define TSDB_KEYSIZE sizeof(TSKEY) #define TSDB_NCHAR_SIZE sizeof(TdUcs4) @@ -188,6 +189,47 @@ typedef enum EOperatorType { OP_TYPE_ASSIGN = 200 } EOperatorType; +static const EOperatorType OPERATOR_ARRAY[] = { + OP_TYPE_ADD, + OP_TYPE_SUB, + OP_TYPE_MULTI, + OP_TYPE_DIV, + OP_TYPE_REM, + + OP_TYPE_MINUS, + + OP_TYPE_BIT_AND, + OP_TYPE_BIT_OR, + + OP_TYPE_GREATER_THAN, + OP_TYPE_GREATER_EQUAL, + OP_TYPE_LOWER_THAN, + OP_TYPE_LOWER_EQUAL, + OP_TYPE_EQUAL, + OP_TYPE_NOT_EQUAL, + OP_TYPE_IN, + OP_TYPE_NOT_IN, + OP_TYPE_LIKE, + OP_TYPE_NOT_LIKE, + OP_TYPE_MATCH, + OP_TYPE_NMATCH, + + OP_TYPE_IS_NULL, + OP_TYPE_IS_NOT_NULL, + OP_TYPE_IS_TRUE, + OP_TYPE_IS_FALSE, + OP_TYPE_IS_UNKNOWN, + OP_TYPE_IS_NOT_TRUE, + OP_TYPE_IS_NOT_FALSE, + OP_TYPE_IS_NOT_UNKNOWN, + //OP_TYPE_COMPARE_MAX_VALUE, + + OP_TYPE_JSON_GET_VALUE, + OP_TYPE_JSON_CONTAINS, + + OP_TYPE_ASSIGN +}; + #define OP_TYPE_CALC_MAX OP_TYPE_BIT_OR typedef enum ELogicConditionType { @@ -411,6 +453,7 @@ typedef enum ELogicConditionType { #define TSDB_CACHE_MODEL_LAST_ROW 1 #define TSDB_CACHE_MODEL_LAST_VALUE 2 #define TSDB_CACHE_MODEL_BOTH 3 +#define TSDB_DNODE_LIST_LEN 256 #define TSDB_ENCRYPT_ALGO_STR_LEN 16 #define TSDB_ENCRYPT_ALGO_NONE_STR "none" #define TSDB_ENCRYPT_ALGO_SM4_STR "sm4" diff --git a/include/util/version.h b/include/util/version.h index b241dd248b9..7b62914a332 100644 --- a/include/util/version.h +++ b/include/util/version.h @@ -20,11 +20,11 @@ extern "C" { #endif -extern char version[]; -extern char compatible_version[]; -extern char gitinfo[]; -extern char gitinfoOfInternal[]; -extern char buildinfo[]; +extern char td_version[]; +extern char td_compatible_version[]; +extern char td_gitinfo[]; +extern char td_gitinfoOfInternal[]; +extern char td_buildinfo[]; #ifdef __cplusplus } diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index bbd18892abd..6d5f0065172 100644 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -10,6 +10,10 @@ else() add_library(taos SHARED ${CLIENT_SRC}) endif() +if(${TD_DARWIN}) + target_compile_options(taos PRIVATE -Wno-error=deprecated-non-prototype) +endif() + INCLUDE_DIRECTORIES(jni) target_include_directories( @@ -46,6 +50,11 @@ set_target_properties( ) add_library(taos_static STATIC ${CLIENT_SRC}) + +if(${TD_DARWIN}) + target_compile_options(taos_static PRIVATE -Wno-error=deprecated-non-prototype) +endif() + target_include_directories( taos_static PUBLIC "${TD_SOURCE_DIR}/include/client" diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 8d45e8b4a81..114bc00125d 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -58,6 +58,8 @@ enum { #define TD_RES_TMQ_METADATA(res) (*(int8_t*)(res) == RES_TYPE__TMQ_METADATA) #define TD_RES_TMQ_BATCH_META(res) (*(int8_t*)(res) == RES_TYPE__TMQ_BATCH_META) +#define TSC_MAX_SUBPLAN_CAPACITY_NUM 1000 + typedef struct SAppInstInfo SAppInstInfo; typedef struct { diff --git a/source/client/inc/clientStmt2.h b/source/client/inc/clientStmt2.h index 4e9a09c0820..64abf31bc1b 100644 --- a/source/client/inc/clientStmt2.h +++ b/source/client/inc/clientStmt2.h @@ -222,6 +222,7 @@ int stmtSetTbTags2(TAOS_STMT2 *stmt, TAOS_STMT2_BIND *tags); int stmtBindBatch2(TAOS_STMT2 *stmt, TAOS_STMT2_BIND *bind, int32_t colIdx); int stmtGetTagFields2(TAOS_STMT2 *stmt, int *nums, TAOS_FIELD_E **fields); int stmtGetColFields2(TAOS_STMT2 *stmt, int *nums, TAOS_FIELD_E **fields); +int stmtGetStbColFields2(TAOS_STMT2 *stmt, int *nums, TAOS_FIELD_STB **fields); int stmtGetParamNum2(TAOS_STMT2 *stmt, int *nums); int stmtGetParamTbName(TAOS_STMT2 *stmt, int *nums); int stmtIsInsert2(TAOS_STMT2 *stmt, int *insert); diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index f892575f0a2..dae6a93d86f 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -375,7 +375,7 @@ int32_t openTransporter(const char *user, const char *auth, int32_t numOfThread, rpcInit.startReadTimer = 1; rpcInit.readTimeout = tsReadTimeout; - int32_t code = taosVersionStrToInt(version, &(rpcInit.compatibilityVer)); + int32_t code = taosVersionStrToInt(td_version, &rpcInit.compatibilityVer); if (TSDB_CODE_SUCCESS != code) { tscError("invalid version string."); return code; diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 9131d29f30a..3531d979123 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1250,6 +1250,7 @@ void schedulerExecCb(SExecResult* pResult, void* param, int32_t code) { void launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQuery, void** res) { int32_t code = 0; + int32_t subplanNum = 0; if (pQuery->pRoot) { pRequest->stmtType = pQuery->pRoot->type; @@ -1405,6 +1406,7 @@ static int32_t asyncExecSchQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaDat if (TSDB_CODE_SUCCESS == code) { code = schedulerExecJob(&req, &pRequest->body.queryJob); } + taosArrayDestroy(pNodeList); } else { qDestroyQueryPlan(pDag); @@ -1698,7 +1700,7 @@ static int32_t buildConnectMsg(SRequestObj* pRequest, SMsgSendInfo** pMsgSendInf tstrncpy(connectReq.app, appInfo.appName, sizeof(connectReq.app)); tstrncpy(connectReq.user, pObj->user, sizeof(connectReq.user)); tstrncpy(connectReq.passwd, pObj->pass, sizeof(connectReq.passwd)); - tstrncpy(connectReq.sVer, version, sizeof(connectReq.sVer)); + tstrncpy(connectReq.sVer, td_version, sizeof(connectReq.sVer)); int32_t contLen = tSerializeSConnectReq(NULL, 0, &connectReq); void* pReq = taosMemoryMalloc(contLen); @@ -1768,19 +1770,15 @@ void updateTargetEpSet(SMsgSendInfo* pSendInfo, STscObj* pTscObj, SRpcMsg* pMsg, } } -int32_t doProcessMsgFromServer(void* param) { - AsyncArg* arg = (AsyncArg*)param; - SRpcMsg* pMsg = &arg->msg; - SEpSet* pEpSet = arg->pEpset; - +int32_t doProcessMsgFromServerImpl(SRpcMsg* pMsg, SEpSet* pEpSet) { SMsgSendInfo* pSendInfo = (SMsgSendInfo*)pMsg->info.ahandle; if (pMsg->info.ahandle == NULL) { tscError("doProcessMsgFromServer pMsg->info.ahandle == NULL"); - taosMemoryFree(arg->pEpset); rpcFreeCont(pMsg->pCont); - taosMemoryFree(arg); + taosMemoryFree(pEpSet); return TSDB_CODE_TSC_INTERNAL_ERROR; } + STscObj* pTscObj = NULL; STraceId* trace = &pMsg->info.traceId; @@ -1800,10 +1798,9 @@ int32_t doProcessMsgFromServer(void* param) { if (TSDB_CODE_SUCCESS != taosReleaseRef(clientReqRefPool, pSendInfo->requestObjRefId)) { tscError("doProcessMsgFromServer taosReleaseRef failed"); } - taosMemoryFree(arg->pEpset); rpcFreeCont(pMsg->pCont); + taosMemoryFree(pEpSet); destroySendMsgInfo(pSendInfo); - taosMemoryFree(arg); return TSDB_CODE_TSC_INTERNAL_ERROR; } pTscObj = pRequest->pTscObj; @@ -1842,20 +1839,24 @@ int32_t doProcessMsgFromServer(void* param) { rpcFreeCont(pMsg->pCont); destroySendMsgInfo(pSendInfo); - - taosMemoryFree(arg); return TSDB_CODE_SUCCESS; } +int32_t doProcessMsgFromServer(void* param) { + AsyncArg* arg = (AsyncArg*)param; + int32_t code = doProcessMsgFromServerImpl(&arg->msg, arg->pEpset); + taosMemoryFree(arg); + return code; +} void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { + int32_t code = 0; SEpSet* tEpSet = NULL; if (pEpSet != NULL) { tEpSet = taosMemoryCalloc(1, sizeof(SEpSet)); if (NULL == tEpSet) { - pMsg->code = TSDB_CODE_OUT_OF_MEMORY; - rpcFreeCont(pMsg->pCont); - destroySendMsgInfo(pMsg->info.ahandle); - return; + code = terrno; + pMsg->code = terrno; + goto _exit; } (void)memcpy((void*)tEpSet, (void*)pEpSet, sizeof(SEpSet)); } @@ -1877,21 +1878,25 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { AsyncArg* arg = taosMemoryCalloc(1, sizeof(AsyncArg)); if (NULL == arg) { - pMsg->code = TSDB_CODE_OUT_OF_MEMORY; - taosMemoryFree(tEpSet); - rpcFreeCont(pMsg->pCont); - destroySendMsgInfo(pMsg->info.ahandle); - return; + code = terrno; + pMsg->code = code; + goto _exit; } + arg->msg = *pMsg; arg->pEpset = tEpSet; - if (0 != taosAsyncExec(doProcessMsgFromServer, arg, NULL)) { - tscError("failed to sched msg to tsc, tsc ready to quit"); - rpcFreeCont(pMsg->pCont); - taosMemoryFree(arg->pEpset); - destroySendMsgInfo(pMsg->info.ahandle); + if ((code = taosAsyncExec(doProcessMsgFromServer, arg, NULL)) != 0) { + pMsg->code = code; taosMemoryFree(arg); + goto _exit; + } + return; +_exit: + tscError("failed to sched msg to tsc since %s", tstrerror(code)); + code = doProcessMsgFromServerImpl(pMsg, tEpSet); + if (code != 0) { + tscError("failed to sched msg to tsc, tsc ready quit"); } } @@ -2571,7 +2576,7 @@ TSDB_SERVER_STATUS taos_check_server_status(const char* fqdn, int port, char* de rpcInit.connLimitNum = connLimitNum; rpcInit.timeToGetConn = tsTimeToGetAvailableConn; rpcInit.readTimeout = tsReadTimeout; - if (TSDB_CODE_SUCCESS != taosVersionStrToInt(version, &(rpcInit.compatibilityVer))) { + if (TSDB_CODE_SUCCESS != taosVersionStrToInt(td_version, &rpcInit.compatibilityVer)) { tscError("faild to convert taos version from str to int, errcode:%s", terrstr()); goto _OVER; } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 64631fd7545..4a719373f25 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -84,7 +84,7 @@ void taos_cleanup(void) { taosCloseRef(id); nodesDestroyAllocatorSet(); -// cleanupAppInfo(); + // cleanupAppInfo(); rpcCleanup(); tscDebug("rpc cleanup"); @@ -388,7 +388,6 @@ void taos_free_result(TAOS_RES *res) { tDeleteMqBatchMetaRsp(&pRsp->batchMetaRsp); } taosMemoryFree(pRsp); - } void taos_kill_query(TAOS *taos) { @@ -484,7 +483,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) { int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) { return taos_print_row_with_size(str, INT32_MAX, row, fields, num_fields); } -int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD *fields, int num_fields){ +int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) { int32_t len = 0; for (int i = 0; i < num_fields; ++i) { if (i > 0 && len < size - 1) { @@ -589,7 +588,7 @@ int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD break; } } - if (len < size){ + if (len < size) { str[len] = 0; } @@ -670,7 +669,7 @@ const char *taos_data_type(int type) { } } -const char *taos_get_client_info() { return version; } +const char *taos_get_client_info() { return td_version; } // return int32_t int taos_affected_rows(TAOS_RES *res) { @@ -2082,7 +2081,7 @@ int taos_stmt2_is_insert(TAOS_STMT2 *stmt, int *insert) { } int taos_stmt2_get_fields(TAOS_STMT2 *stmt, TAOS_FIELD_T field_type, int *count, TAOS_FIELD_E **fields) { - if (stmt == NULL || NULL == count) { + if (stmt == NULL || count == NULL) { tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; @@ -2103,12 +2102,28 @@ int taos_stmt2_get_fields(TAOS_STMT2 *stmt, TAOS_FIELD_T field_type, int *count, } } +int taos_stmt2_get_stb_fields(TAOS_STMT2 *stmt, int *count, TAOS_FIELD_STB **fields) { + if (stmt == NULL || count == NULL) { + tscError("NULL parameter for %s", __FUNCTION__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtGetStbColFields2(stmt, count, fields); +} + void taos_stmt2_free_fields(TAOS_STMT2 *stmt, TAOS_FIELD_E *fields) { (void)stmt; if (!fields) return; taosMemoryFree(fields); } +DLL_EXPORT void taos_stmt2_free_stb_fields(TAOS_STMT2 *stmt, TAOS_FIELD_STB *fields) { + (void)stmt; + if (!fields) return; + taosMemoryFree(fields); +} + TAOS_RES *taos_stmt2_result(TAOS_STMT2 *stmt) { if (stmt == NULL) { tscError("NULL parameter for %s", __FUNCTION__); @@ -2144,4 +2159,4 @@ int taos_set_conn_mode(TAOS *taos, int mode, int value) { return 0; } -char *getBuildInfo() { return buildinfo; } +char *getBuildInfo() { return td_buildinfo; } diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index aef3cef1c5d..c3d11b7a405 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -80,8 +80,8 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { goto End; } - if ((code = taosCheckVersionCompatibleFromStr(version, connectRsp.sVer, 3)) != 0) { - tscError("version not compatible. client version: %s, server version: %s", version, connectRsp.sVer); + if ((code = taosCheckVersionCompatibleFromStr(td_version, connectRsp.sVer, 3)) != 0) { + tscError("version not compatible. client version: %s, server version: %s", td_version, connectRsp.sVer); goto End; } diff --git a/source/client/src/clientStmt2.c b/source/client/src/clientStmt2.c index 2f046b61d62..4bbfc6afaa7 100644 --- a/source/client/src/clientStmt2.c +++ b/source/client/src/clientStmt2.c @@ -1068,6 +1068,34 @@ static int stmtFetchColFields2(STscStmt2* pStmt, int32_t* fieldNum, TAOS_FIELD_E return TSDB_CODE_SUCCESS; } + +static int stmtFetchStbColFields2(STscStmt2* pStmt, int32_t* fieldNum, TAOS_FIELD_STB** fields) { + if (pStmt->errCode != TSDB_CODE_SUCCESS) { + return pStmt->errCode; + } + + if (STMT_TYPE_QUERY == pStmt->sql.type) { + tscError("invalid operation to get query column fileds"); + STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR); + } + + STableDataCxt** pDataBlock = NULL; + + if (pStmt->sql.stbInterlaceMode) { + pDataBlock = &pStmt->sql.siInfo.pDataCtx; + } else { + pDataBlock = + (STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName)); + if (NULL == pDataBlock) { + tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName); + STMT_ERR_RET(TSDB_CODE_APP_ERROR); + } + } + + STMT_ERR_RET(qBuildStmtStbColFields(*pDataBlock, fieldNum, fields)); + + return TSDB_CODE_SUCCESS; +} /* SArray* stmtGetFreeCol(STscStmt2* pStmt, int32_t* idx) { while (true) { @@ -1808,7 +1836,7 @@ int stmtGetTagFields2(TAOS_STMT2* stmt, int* nums, TAOS_FIELD_E** fields) { return code; } -int stmtGetColFields2(TAOS_STMT2* stmt, int* nums, TAOS_FIELD_E** fields) { +int stmtParseColFields2(TAOS_STMT2* stmt) { int32_t code = 0; STscStmt2* pStmt = (STscStmt2*)stmt; int32_t preCode = pStmt->errCode; @@ -1842,8 +1870,6 @@ int stmtGetColFields2(TAOS_STMT2* stmt, int* nums, TAOS_FIELD_E** fields) { STMT_ERRI_JRET(stmtParseSql(pStmt)); } - STMT_ERRI_JRET(stmtFetchColFields2(stmt, nums, fields)); - _return: pStmt->errCode = preCode; @@ -1851,6 +1877,24 @@ int stmtGetColFields2(TAOS_STMT2* stmt, int* nums, TAOS_FIELD_E** fields) { return code; } +int stmtGetColFields2(TAOS_STMT2* stmt, int* nums, TAOS_FIELD_E** fields) { + int32_t code = stmtParseColFields2(stmt); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + return stmtFetchColFields2(stmt, nums, fields); +} + +int stmtGetStbColFields2(TAOS_STMT2* stmt, int* nums, TAOS_FIELD_STB** fields) { + int32_t code = stmtParseColFields2(stmt); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + return stmtFetchStbColFields2(stmt, nums, fields); +} + int stmtGetParamNum2(TAOS_STMT2* stmt, int* nums) { STscStmt2* pStmt = (STscStmt2*)stmt; diff --git a/source/common/src/tcol.c b/source/common/src/tcol.c index 84027c25b6b..923aab12ca0 100644 --- a/source/common/src/tcol.c +++ b/source/common/src/tcol.c @@ -363,6 +363,9 @@ int8_t validColEncode(uint8_t type, uint8_t l1) { if (l1 == TSDB_COLVAL_ENCODE_NOCHANGE) { return 1; } + if (l1 == TSDB_COLVAL_ENCODE_DISABLED) { + return 1; + } if (type == TSDB_DATA_TYPE_BOOL) { return TSDB_COLVAL_ENCODE_RLE == l1 ? 1 : 0; } else if (type >= TSDB_DATA_TYPE_TINYINT && type <= TSDB_DATA_TYPE_INT) { diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 7ea6b01bf34..f3890b62763 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -675,10 +675,10 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) { TAOS_CHECK_RETURN(cfgAddString(pCfg, "os version", info.version, CFG_SCOPE_BOTH, CFG_DYN_NONE)); TAOS_CHECK_RETURN(cfgAddString(pCfg, "os machine", info.machine, CFG_SCOPE_BOTH, CFG_DYN_NONE)); - TAOS_CHECK_RETURN(cfgAddString(pCfg, "version", version, CFG_SCOPE_BOTH, CFG_DYN_NONE)); - TAOS_CHECK_RETURN(cfgAddString(pCfg, "compatible_version", compatible_version, CFG_SCOPE_BOTH, CFG_DYN_NONE)); - TAOS_CHECK_RETURN(cfgAddString(pCfg, "gitinfo", gitinfo, CFG_SCOPE_BOTH, CFG_DYN_NONE)); - TAOS_CHECK_RETURN(cfgAddString(pCfg, "buildinfo", buildinfo, CFG_SCOPE_BOTH, CFG_DYN_NONE)); + TAOS_CHECK_RETURN(cfgAddString(pCfg, "version", td_version, CFG_SCOPE_BOTH, CFG_DYN_NONE)); + TAOS_CHECK_RETURN(cfgAddString(pCfg, "compatible_version", td_compatible_version, CFG_SCOPE_BOTH, CFG_DYN_NONE)); + TAOS_CHECK_RETURN(cfgAddString(pCfg, "gitinfo", td_gitinfo, CFG_SCOPE_BOTH, CFG_DYN_NONE)); + TAOS_CHECK_RETURN(cfgAddString(pCfg, "buildinfo", td_buildinfo, CFG_SCOPE_BOTH, CFG_DYN_NONE)); TAOS_RETURN(TSDB_CODE_SUCCESS); } @@ -1646,6 +1646,9 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "checkpointInterval"); tsStreamCheckpointInterval = pItem->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "concurrentCheckpoint"); + tsMaxConcurrentCheckpoint = pItem->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "streamSinkDataRate"); tsSinkDataRate = pItem->fval; @@ -2346,8 +2349,13 @@ static void taosCheckAndSetDebugFlag(int32_t *pFlagPtr, char *name, int32_t flag if (noNeedToSetVars != NULL && taosArraySearch(noNeedToSetVars, name, taosLogVarComp, TD_EQ) != NULL) { return; } - if (taosSetDebugFlag(pFlagPtr, name, flag) != 0) { - uError("failed to set flag %s to %d", name, flag); + int32_t code = 0; + if ((code = taosSetDebugFlag(pFlagPtr, name, flag)) != 0) { + if (code != TSDB_CODE_CFG_NOT_FOUND) { + uError("failed to set flag %s to %d, since:%s", name, flag, tstrerror(code)); + } else { + uDebug("failed to set flag %s to %d, since:%s", name, flag, tstrerror(code)); + } } return; } diff --git a/source/common/src/tmisce.c b/source/common/src/tmisce.c index 10375ba8574..4df458c2bb7 100644 --- a/source/common/src/tmisce.c +++ b/source/common/src/tmisce.c @@ -221,10 +221,9 @@ int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t } TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "memory", tmp), NULL, _exit); - TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "version", version), NULL, _exit); - TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "buildInfo", buildinfo), NULL, _exit); - - TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "gitInfo", gitinfo), NULL, _exit); + TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "version", td_version), NULL, _exit); + TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "buildInfo", td_buildinfo), NULL, _exit); + TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "gitInfo", td_gitinfo), NULL, _exit); TAOS_CHECK_GOTO(tjsonAddIntegerToObject(pJson, "crashSig", signum), NULL, _exit); TAOS_CHECK_GOTO(tjsonAddIntegerToObject(pJson, "crashTs", taosGetTimestampUs()), NULL, _exit); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 9c8544fcd46..9b54da2c308 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -3874,6 +3874,7 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) { TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->s3ChunkSize)); TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->s3KeepLocal)); TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->s3Compact)); + TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->dnodeListStr)); tEndEncode(&encoder); @@ -3962,6 +3963,10 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->s3Compact)); } + if (!tDecodeIsEnd(&decoder)) { + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->dnodeListStr)); + } + tEndDecode(&decoder); _exit: diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index f94b9e2d73c..ade5e168943 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -297,12 +297,13 @@ static void dmPrintArgs(int32_t argc, char const *argv[]) { static void dmGenerateGrant() { mndGenerateMachineCode(); } static void dmPrintVersion() { - printf("%s\n%sd version: %s compatible_version: %s\n", TD_PRODUCT_NAME, CUS_PROMPT, version, compatible_version); - printf("git: %s\n", gitinfo); + printf("%s\n%sd version: %s compatible_version: %s\n", TD_PRODUCT_NAME, CUS_PROMPT, td_version, + td_compatible_version); + printf("git: %s\n", td_gitinfo); #ifdef TD_ENTERPRISE - printf("gitOfInternal: %s\n", gitinfoOfInternal); + printf("gitOfInternal: %s\n", td_gitinfoOfInternal); #endif - printf("build: %s\n", buildinfo); + printf("build: %s\n", td_buildinfo); } static void dmPrintHelp() { diff --git a/source/dnode/mgmt/mgmt_snode/CMakeLists.txt b/source/dnode/mgmt/mgmt_snode/CMakeLists.txt index 62dc41a0aec..8ebeafcbfbc 100644 --- a/source/dnode/mgmt/mgmt_snode/CMakeLists.txt +++ b/source/dnode/mgmt/mgmt_snode/CMakeLists.txt @@ -1,5 +1,10 @@ aux_source_directory(src MGMT_SNODE) add_library(mgmt_snode STATIC ${MGMT_SNODE}) + +if(${TD_DARWIN}) + target_compile_options(mgmt_snode PRIVATE -Wno-error=deprecated-non-prototype) +endif() + target_include_directories( mgmt_snode PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" diff --git a/source/dnode/mgmt/mgmt_vnode/CMakeLists.txt b/source/dnode/mgmt/mgmt_vnode/CMakeLists.txt index 15b822ad92e..bb433def6c9 100644 --- a/source/dnode/mgmt/mgmt_vnode/CMakeLists.txt +++ b/source/dnode/mgmt/mgmt_vnode/CMakeLists.txt @@ -1,5 +1,10 @@ aux_source_directory(src MGMT_VNODE) add_library(mgmt_vnode STATIC ${MGMT_VNODE}) + +if(${TD_DARWIN}) + target_compile_options(mgmt_vnode PRIVATE -Wno-error=deprecated-non-prototype) +endif() + target_include_directories( mgmt_vnode PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index 8a8dcc74a5b..006f44b349c 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -741,7 +741,7 @@ int32_t vmProcessAlterVnodeReplicaReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { int32_t vgId = alterReq.vgId; dInfo( - "vgId:%d,vnode management handle msgType:%s, start to alter vnode replica:%d selfIndex:%d leanerReplica:%d " + "vgId:%d, vnode management handle msgType:%s, start to alter vnode replica:%d selfIndex:%d leanerReplica:%d " "learnerSelfIndex:%d strict:%d changeVersion:%d", vgId, TMSG_INFO(pMsg->msgType), alterReq.replica, alterReq.selfIndex, alterReq.learnerReplica, alterReq.learnerSelfIndex, alterReq.strict, alterReq.changeVersion); diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index c151529aea5..5a276de251b 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -138,9 +138,9 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) { pRpc->info.handle, pRpc->contLen, pRpc->code, pRpc->info.ahandle, pRpc->info.refId); int32_t svrVer = 0; - code = taosVersionStrToInt(version, &svrVer); + code = taosVersionStrToInt(td_version, &svrVer); if (code != 0) { - dError("failed to convert version string:%s to int, code:%d", version, code); + dError("failed to convert version string:%s to int, code:%d", td_version, code); goto _OVER; } if ((code = taosCheckVersionCompatible(pRpc->info.cliVer, svrVer, 3)) != 0) { @@ -434,8 +434,8 @@ int32_t dmInitClient(SDnode *pDnode) { rpcInit.startReadTimer = 1; rpcInit.readTimeout = tsReadTimeout; - if (taosVersionStrToInt(version, &(rpcInit.compatibilityVer)) != 0) { - dError("failed to convert version string:%s to int", version); + if (taosVersionStrToInt(td_version, &rpcInit.compatibilityVer) != 0) { + dError("failed to convert version string:%s to int", td_version); } pTrans->clientRpc = rpcOpen(&rpcInit); @@ -483,8 +483,8 @@ int32_t dmInitStatusClient(SDnode *pDnode) { rpcInit.startReadTimer = 0; rpcInit.readTimeout = 0; - if (taosVersionStrToInt(version, &(rpcInit.compatibilityVer)) != 0) { - dError("failed to convert version string:%s to int", version); + if (taosVersionStrToInt(td_version, &rpcInit.compatibilityVer) != 0) { + dError("failed to convert version string:%s to int", td_version); } pTrans->statusRpc = rpcOpen(&rpcInit); @@ -533,8 +533,8 @@ int32_t dmInitSyncClient(SDnode *pDnode) { rpcInit.startReadTimer = 1; rpcInit.readTimeout = tsReadTimeout; - if (taosVersionStrToInt(version, &(rpcInit.compatibilityVer)) != 0) { - dError("failed to convert version string:%s to int", version); + if (taosVersionStrToInt(td_version, &rpcInit.compatibilityVer) != 0) { + dError("failed to convert version string:%s to int", td_version); } pTrans->syncRpc = rpcOpen(&rpcInit); @@ -588,8 +588,8 @@ int32_t dmInitServer(SDnode *pDnode) { rpcInit.compressSize = tsCompressMsgSize; rpcInit.shareConnLimit = tsShareConnLimit * 16; - if (taosVersionStrToInt(version, &(rpcInit.compatibilityVer)) != 0) { - dError("failed to convert version string:%s to int", version); + if (taosVersionStrToInt(td_version, &rpcInit.compatibilityVer) != 0) { + dError("failed to convert version string:%s to int", td_version); } pTrans->serverRpc = rpcOpen(&rpcInit); diff --git a/source/dnode/mgmt/test/sut/src/client.cpp b/source/dnode/mgmt/test/sut/src/client.cpp index 95eea2359d0..6f8b1eb2b44 100644 --- a/source/dnode/mgmt/test/sut/src/client.cpp +++ b/source/dnode/mgmt/test/sut/src/client.cpp @@ -54,7 +54,7 @@ void TestClient::DoInit() { rpcInit.parent = this; // rpcInit.secret = (char*)secretEncrypt; // rpcInit.spi = 1; - taosVersionStrToInt(version, &(rpcInit.compatibilityVer)); + taosVersionStrToInt(td_version, &rpcInit.compatibilityVer); clientRpc = rpcOpen(&rpcInit); ASSERT(clientRpc); diff --git a/source/dnode/mnode/impl/inc/mndArbGroup.h b/source/dnode/mnode/impl/inc/mndArbGroup.h index 779d64c7e2b..66ef3f766be 100644 --- a/source/dnode/mnode/impl/inc/mndArbGroup.h +++ b/source/dnode/mnode/impl/inc/mndArbGroup.h @@ -47,6 +47,15 @@ bool mndUpdateArbGroupBySetAssignedLeader(SArbGroup *pGroup, int32_t vgId, char int32_t mndGetArbGroupSize(SMnode *pMnode); +typedef enum { + CHECK_SYNC_NONE = 0, + CHECK_SYNC_SET_ASSIGNED_LEADER = 1, + CHECK_SYNC_CHECK_SYNC = 2, + CHECK_SYNC_UPDATE = 3 +} ECheckSyncOp; + +void mndArbCheckSync(SArbGroup *pArbGroup, int64_t nowMs, ECheckSyncOp *pOp, SArbGroup *pNewGroup); + #ifdef __cplusplus } #endif diff --git a/source/dnode/mnode/impl/inc/mndDb.h b/source/dnode/mnode/impl/inc/mndDb.h index b72d1386c1b..fdb6b5a80b9 100644 --- a/source/dnode/mnode/impl/inc/mndDb.h +++ b/source/dnode/mnode/impl/inc/mndDb.h @@ -37,6 +37,7 @@ const char *mndGetDbStr(const char *src); const char *mndGetStableStr(const char *src); int32_t mndProcessCompactDbReq(SRpcMsg *pReq); +int32_t mndCheckDbDnodeList(SMnode *pMnode, char *db, char *dnodeListStr, SArray *dnodeList); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 742db8f450a..d2d9b2e8eb2 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -70,7 +70,7 @@ typedef enum { MND_OPER_WRITE_DB, MND_OPER_READ_DB, MND_OPER_READ_OR_WRITE_DB, - MND_OPER_SHOW_VARIBALES, + MND_OPER_SHOW_VARIABLES, MND_OPER_SUBSCRIBE, MND_OPER_CREATE_TOPIC, MND_OPER_DROP_TOPIC, diff --git a/source/dnode/mnode/impl/inc/mndStream.h b/source/dnode/mnode/impl/inc/mndStream.h index b97eaf31d1a..c9155f536c9 100644 --- a/source/dnode/mnode/impl/inc/mndStream.h +++ b/source/dnode/mnode/impl/inc/mndStream.h @@ -133,6 +133,7 @@ int32_t mndStreamSetUpdateEpsetAction(SMnode *pMnode, SStreamObj *pStream, SVgr int32_t mndGetStreamObj(SMnode *pMnode, int64_t streamId, SStreamObj** pStream); bool mndStreamNodeIsUpdated(SMnode *pMnode); +int32_t mndCheckForSnode(SMnode *pMnode, SDbObj *pSrcDb); int32_t extractNodeEpset(SMnode *pMnode, SEpSet *pEpSet, bool *hasEpset, int32_t taskId, int32_t nodeId); int32_t mndProcessStreamHb(SRpcMsg *pReq); diff --git a/source/dnode/mnode/impl/inc/mndVgroup.h b/source/dnode/mnode/impl/inc/mndVgroup.h index 682a51a6878..a8a806e497b 100644 --- a/source/dnode/mnode/impl/inc/mndVgroup.h +++ b/source/dnode/mnode/impl/inc/mndVgroup.h @@ -35,9 +35,9 @@ void mndSortVnodeGid(SVgObj *pVgroup); int64_t mndGetVnodesMemory(SMnode *pMnode, int32_t dnodeId); int64_t mndGetVgroupMemory(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup); -SArray *mndBuildDnodesArray(SMnode *, int32_t exceptDnodeId); +SArray *mndBuildDnodesArray(SMnode *, int32_t exceptDnodeId, SArray *dnodeList); int32_t mndAllocSmaVgroup(SMnode *, SDbObj *pDb, SVgObj *pVgroup); -int32_t mndAllocVgroup(SMnode *, SDbObj *pDb, SVgObj **ppVgroups); +int32_t mndAllocVgroup(SMnode *, SDbObj *pDb, SVgObj **ppVgroups, SArray *dnodeList); int32_t mndAddNewVgPrepareAction(SMnode *, STrans *pTrans, SVgObj *pVg); int32_t mndAddCreateVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid); int32_t mndAddAlterVnodeConfirmAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup); diff --git a/source/dnode/mnode/impl/src/mndArbGroup.c b/source/dnode/mnode/impl/src/mndArbGroup.c index 1dd21900e3f..0192044e67c 100644 --- a/source/dnode/mnode/impl/src/mndArbGroup.c +++ b/source/dnode/mnode/impl/src/mndArbGroup.c @@ -250,6 +250,12 @@ static int32_t mndArbGroupActionUpdate(SSdb *pSdb, SArbGroup *pOld, SArbGroup *p pOld->assignedLeader.acked = pNew->assignedLeader.acked; pOld->version++; + mInfo( + "arbgroup:%d, perform update action. members[0].token:%s, members[1].token:%s, isSync:%d, as-dnodeid:%d, " + "as-token:%s, as-acked:%d, version:%" PRId64, + pOld->vgId, pOld->members[0].state.token, pOld->members[1].state.token, pOld->isSync, + pOld->assignedLeader.dnodeId, pOld->assignedLeader.token, pOld->assignedLeader.acked, pOld->version); + _OVER: (void)taosThreadMutexUnlock(&pOld->mutex); @@ -577,19 +583,77 @@ static int32_t mndSendArbSetAssignedLeaderReq(SMnode *pMnode, int32_t dnodeId, i return code; } +void mndArbCheckSync(SArbGroup *pArbGroup, int64_t nowMs, ECheckSyncOp *pOp, SArbGroup *pNewGroup) { + *pOp = CHECK_SYNC_NONE; + int32_t code = 0; + + int32_t vgId = pArbGroup->vgId; + + bool member0IsTimeout = mndCheckArbMemberHbTimeout(pArbGroup, 0, nowMs); + bool member1IsTimeout = mndCheckArbMemberHbTimeout(pArbGroup, 1, nowMs); + SArbAssignedLeader *pAssignedLeader = &pArbGroup->assignedLeader; + int32_t currentAssignedDnodeId = pAssignedLeader->dnodeId; + + // 1. has assigned && no response => send req + if (currentAssignedDnodeId != 0 && pAssignedLeader->acked == false) { + *pOp = CHECK_SYNC_SET_ASSIGNED_LEADER; + return; + } + + // 2. both of the two members are timeout => skip + if (member0IsTimeout && member1IsTimeout) { + return; + } + + // 3. no member is timeout => check sync + if (member0IsTimeout == false && member1IsTimeout == false) { + // no assigned leader and not sync + if (currentAssignedDnodeId == 0 && !pArbGroup->isSync) { + *pOp = CHECK_SYNC_CHECK_SYNC; + } + return; + } + + // 4. one of the members is timeout => set assigned leader + int32_t candidateIndex = member0IsTimeout ? 1 : 0; + SArbGroupMember *pMember = &pArbGroup->members[candidateIndex]; + + // has assigned leader and dnodeId not match => skip + if (currentAssignedDnodeId != 0 && currentAssignedDnodeId != pMember->info.dnodeId) { + mInfo("arb skip to set assigned leader to vgId:%d dnodeId:%d, assigned leader has been set to dnodeId:%d", vgId, + pMember->info.dnodeId, currentAssignedDnodeId); + return; + } + + // not sync => skip + if (pArbGroup->isSync == false) { + if (currentAssignedDnodeId == pMember->info.dnodeId) { + mDebug("arb skip to set assigned leader to vgId:%d dnodeId:%d, arb group is not sync", vgId, + pMember->info.dnodeId); + } else { + mInfo("arb skip to set assigned leader to vgId:%d dnodeId:%d, arb group is not sync", vgId, + pMember->info.dnodeId); + } + return; + } + + // is sync && no assigned leader => write to sdb + mndArbGroupDupObj(pArbGroup, pNewGroup); + mndArbGroupSetAssignedLeader(pNewGroup, candidateIndex); + *pOp = CHECK_SYNC_UPDATE; +} + static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq) { - int32_t code = 0; + int32_t code = 0, lino = 0; SMnode *pMnode = pReq->info.node; SSdb *pSdb = pMnode->pSdb; SArbGroup *pArbGroup = NULL; - SArbGroup arbGroupDup = {0}; void *pIter = NULL; + SArray *pUpdateArray = NULL; char arbToken[TSDB_ARB_TOKEN_SIZE]; - if ((code = mndGetArbToken(pMnode, arbToken)) != 0) { - mError("failed to get arb token for arb-check-sync timer"); - TAOS_RETURN(code); - } + TAOS_CHECK_EXIT(mndGetArbToken(pMnode, arbToken)); + int64_t term = mndGetTerm(pMnode); if (term < 0) { mError("arb failed to get term since %s", terrstr()); @@ -606,88 +670,64 @@ static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq) { return 0; } - SArray *pUpdateArray = taosArrayInit(16, sizeof(SArbGroup)); - while (1) { pIter = sdbFetch(pSdb, SDB_ARBGROUP, pIter, (void **)&pArbGroup); if (pIter == NULL) break; + SArbGroup arbGroupDup = {0}; + (void)taosThreadMutexLock(&pArbGroup->mutex); mndArbGroupDupObj(pArbGroup, &arbGroupDup); (void)taosThreadMutexUnlock(&pArbGroup->mutex); - int32_t vgId = arbGroupDup.vgId; - - bool member0IsTimeout = mndCheckArbMemberHbTimeout(&arbGroupDup, 0, nowMs); - bool member1IsTimeout = mndCheckArbMemberHbTimeout(&arbGroupDup, 1, nowMs); - SArbAssignedLeader *pAssignedLeader = &arbGroupDup.assignedLeader; - int32_t currentAssignedDnodeId = pAssignedLeader->dnodeId; - - // 1. has assigned && is sync && no response => send req - if (currentAssignedDnodeId != 0 && arbGroupDup.isSync == true && pAssignedLeader->acked == false) { - (void)mndSendArbSetAssignedLeaderReq(pMnode, currentAssignedDnodeId, vgId, arbToken, term, - pAssignedLeader->token); - mInfo("vgId:%d, arb send set assigned leader to dnodeId:%d", vgId, currentAssignedDnodeId); - sdbRelease(pSdb, pArbGroup); - continue; - } - - // 2. both of the two members are timeout => skip - if (member0IsTimeout && member1IsTimeout) { - sdbRelease(pSdb, pArbGroup); - continue; - } + sdbRelease(pSdb, pArbGroup); - // 3. no member is timeout => check sync - if (member0IsTimeout == false && member1IsTimeout == false) { - // no assigned leader and not sync - if (currentAssignedDnodeId == 0 && !arbGroupDup.isSync) { - (void)mndSendArbCheckSyncReq(pMnode, arbGroupDup.vgId, arbToken, term, arbGroupDup.members[0].state.token, + ECheckSyncOp op = CHECK_SYNC_NONE; + SArbGroup newGroup = {0}; + mndArbCheckSync(&arbGroupDup, nowMs, &op, &newGroup); + + int32_t vgId = arbGroupDup.vgId; + SArbAssignedLeader *pAssgndLeader = &arbGroupDup.assignedLeader; + int32_t assgndDnodeId = pAssgndLeader->dnodeId; + + switch (op) { + case CHECK_SYNC_NONE: + mTrace("vgId:%d, arb skip to send msg by check sync", vgId); + break; + case CHECK_SYNC_SET_ASSIGNED_LEADER: + (void)mndSendArbSetAssignedLeaderReq(pMnode, assgndDnodeId, vgId, arbToken, term, pAssgndLeader->token); + mInfo("vgId:%d, arb send set assigned leader to dnodeId:%d", vgId, assgndDnodeId); + break; + case CHECK_SYNC_CHECK_SYNC: + (void)mndSendArbCheckSyncReq(pMnode, vgId, arbToken, term, arbGroupDup.members[0].state.token, arbGroupDup.members[1].state.token); - } - sdbRelease(pSdb, pArbGroup); - continue; - } - - // 4. one of the members is timeout => set assigned leader - int32_t candidateIndex = member0IsTimeout ? 1 : 0; - SArbGroupMember *pMember = &arbGroupDup.members[candidateIndex]; - - // has assigned leader and dnodeId not match => skip - if (currentAssignedDnodeId != 0 && currentAssignedDnodeId != pMember->info.dnodeId) { - mInfo("arb skip to set assigned leader to vgId:%d dnodeId:%d, assigned leader has been set to dnodeId:%d", vgId, - pMember->info.dnodeId, currentAssignedDnodeId); - sdbRelease(pSdb, pArbGroup); - continue; - } + mInfo("vgId:%d, arb send check sync request", vgId); + break; + case CHECK_SYNC_UPDATE: + if (!pUpdateArray) { + pUpdateArray = taosArrayInit(16, sizeof(SArbGroup)); + if (!pUpdateArray) { + TAOS_CHECK_EXIT(TSDB_CODE_OUT_OF_MEMORY); + } + } - // not sync => skip - if (arbGroupDup.isSync == false) { - if (currentAssignedDnodeId == pMember->info.dnodeId) { - mDebug("arb skip to set assigned leader to vgId:%d dnodeId:%d, arb group is not sync", vgId, - pMember->info.dnodeId); - } else { - mInfo("arb skip to set assigned leader to vgId:%d dnodeId:%d, arb group is not sync", vgId, - pMember->info.dnodeId); - } - sdbRelease(pSdb, pArbGroup); - continue; + if (taosArrayPush(pUpdateArray, &newGroup) == NULL) { + TAOS_CHECK_EXIT(terrno); + } + break; + default: + mError("vgId:%d, arb unknown check sync op:%d", vgId, op); + break; } + } - // is sync && no assigned leader => write to sdb - SArbGroup newGroup = {0}; - mndArbGroupDupObj(&arbGroupDup, &newGroup); - mndArbGroupSetAssignedLeader(&newGroup, candidateIndex); - if (taosArrayPush(pUpdateArray, &newGroup) == NULL) { - taosArrayDestroy(pUpdateArray); - return terrno; - } + TAOS_CHECK_EXIT(mndPullupArbUpdateGroupBatch(pMnode, pUpdateArray)); - sdbRelease(pSdb, pArbGroup); +_exit: + if (code != 0) { + mError("failed to check sync at line %d since %s", lino, terrstr()); } - TAOS_CHECK_RETURN(mndPullupArbUpdateGroupBatch(pMnode, pUpdateArray)); - taosArrayDestroy(pUpdateArray); return 0; } diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index b16cfe410af..f3baa04f9ba 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -462,8 +462,8 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) { if (pCfg->cacheLast < TSDB_CACHE_MODEL_NONE || pCfg->cacheLast > TSDB_CACHE_MODEL_BOTH) return code; if (pCfg->hashMethod != 1) return code; if (pCfg->replications > mndGetDnodeSize(pMnode)) { - terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES; - return code; + code = TSDB_CODE_MND_NO_ENOUGH_DNODES; + TAOS_RETURN(code); } if (pCfg->walRetentionPeriod < TSDB_DB_MIN_WAL_RETENTION_PERIOD) return code; if (pCfg->walRetentionSize < TSDB_DB_MIN_WAL_RETENTION_SIZE) return code; @@ -746,7 +746,7 @@ static int32_t mndSetCreateDbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj TAOS_RETURN(code); } -static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate, SUserObj *pUser) { +static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate, SUserObj *pUser, SArray *dnodeList) { int32_t code = 0; SUserObj newUserObj = {0}; SDbObj dbObj = {0}; @@ -823,7 +823,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate, } SVgObj *pVgroups = NULL; - if ((code = mndAllocVgroup(pMnode, &dbObj, &pVgroups)) != 0) { + if ((code = mndAllocVgroup(pMnode, &dbObj, &pVgroups, dnodeList)) != 0) { mError("db:%s, failed to create, alloc vgroup failed, since %s", pCreate->db, terrstr()); TAOS_RETURN(code); } @@ -925,6 +925,17 @@ static int32_t mndCheckDbEncryptKey(SMnode *pMnode, SCreateDbReq *pReq) { TAOS_RETURN(code); } +#ifndef TD_ENTERPRISE +int32_t mndCheckDbDnodeList(SMnode *pMnode, char *db, char *dnodeListStr, SArray *dnodeList) { + if (dnodeListStr[0] != 0) { + terrno = TSDB_CODE_OPS_NOT_SUPPORT; + return terrno; + } else { + return 0; + } +} +#endif + static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; int32_t code = -1; @@ -932,6 +943,10 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) { SDbObj *pDb = NULL; SUserObj *pUser = NULL; SCreateDbReq createReq = {0}; + SArray *dnodeList = NULL; + + dnodeList = taosArrayInit(mndGetDnodeSize(pMnode), sizeof(int32_t)); + TSDB_CHECK_NULL(dnodeList, code, lino, _OVER, TSDB_CODE_OUT_OF_MEMORY); TAOS_CHECK_GOTO(tDeserializeSCreateDbReq(pReq->pCont, pReq->contLen, &createReq), NULL, _OVER); #ifdef WINDOWS @@ -975,9 +990,11 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) { TAOS_CHECK_GOTO(mndCheckDbEncryptKey(pMnode, &createReq), &lino, _OVER); + TAOS_CHECK_GOTO(mndCheckDbDnodeList(pMnode, createReq.db, createReq.dnodeListStr, dnodeList), &lino, _OVER); + TAOS_CHECK_GOTO(mndAcquireUser(pMnode, pReq->info.conn.user, &pUser), &lino, _OVER); - TAOS_CHECK_GOTO(mndCreateDb(pMnode, pReq, &createReq, pUser), &lino, _OVER); + TAOS_CHECK_GOTO(mndCreateDb(pMnode, pReq, &createReq, pUser, dnodeList), &lino, _OVER); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; SName name = {0}; @@ -994,6 +1011,7 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) { mndReleaseDb(pMnode, pDb); mndReleaseUser(pMnode, pUser); tFreeSCreateDbReq(&createReq); + taosArrayDestroy(dnodeList); TAOS_RETURN(code); } @@ -1168,7 +1186,9 @@ static int32_t mndSetAlterDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj * SSdb *pSdb = pMnode->pSdb; void *pIter = NULL; SVgObj *pVgroup = NULL; - SArray *pArray = mndBuildDnodesArray(pMnode, 0); + SArray *pArray = mndBuildDnodesArray(pMnode, 0, NULL); + + TSDB_CHECK_NULL(pArray, code, lino, _err, TSDB_CODE_OUT_OF_MEMORY); while (1) { pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 5e10583a0a6..2a1689854b8 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -1068,7 +1068,7 @@ static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) { SShowVariablesRsp rsp = {0}; int32_t code = -1; - if (mndCheckOperPrivilege(pReq->info.node, pReq->info.conn.user, MND_OPER_SHOW_VARIBALES) != 0) { + if (mndCheckOperPrivilege(pReq->info.node, pReq->info.conn.user, MND_OPER_SHOW_VARIABLES) != 0) { goto _OVER; } diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index 08ebf52ec62..6c30193ea76 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -1021,7 +1021,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr } // cluster info - tstrncpy(pClusterInfo->version, version, sizeof(pClusterInfo->version)); + tstrncpy(pClusterInfo->version, td_version, sizeof(pClusterInfo->version)); pClusterInfo->monitor_interval = tsMonitorInterval; pClusterInfo->connections_total = mndGetNumOfConnections(pMnode); pClusterInfo->dbs_total = sdbGetSize(pSdb, SDB_DB); diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index a1ffee9b06a..91df640bce3 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -239,8 +239,8 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { goto _OVER; } - if ((code = taosCheckVersionCompatibleFromStr(connReq.sVer, version, 3)) != 0) { - mGError("version not compatible. client version: %s, server version: %s", connReq.sVer, version); + if ((code = taosCheckVersionCompatibleFromStr(connReq.sVer, td_version, 3)) != 0) { + mGError("version not compatible. client version: %s, server version: %s", connReq.sVer, td_version); goto _OVER; } @@ -308,9 +308,9 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { tstrncpy(connectRsp.monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb, TSDB_DB_NAME_LEN); connectRsp.whiteListVer = pUser->ipWhiteListVer; - (void)strcpy(connectRsp.sVer, version); - (void)snprintf(connectRsp.sDetailVer, sizeof(connectRsp.sDetailVer), "ver:%s\nbuild:%s\ngitinfo:%s", version, - buildinfo, gitinfo); + tstrncpy(connectRsp.sVer, td_version, sizeof(connectRsp.sVer)); + (void)snprintf(connectRsp.sDetailVer, sizeof(connectRsp.sDetailVer), "ver:%s\nbuild:%s\ngitinfo:%s", td_version, + td_buildinfo, td_gitinfo); mndGetMnodeEpSet(pMnode, &connectRsp.epSet); int32_t contLen = tSerializeSConnectRsp(NULL, 0, &connectRsp); @@ -813,7 +813,7 @@ static int32_t mndProcessSvrVerReq(SRpcMsg *pReq) { int32_t code = 0; int32_t lino = 0; SServerVerRsp rsp = {0}; - tstrncpy(rsp.ver, version, sizeof(rsp.ver)); + tstrncpy(rsp.ver, td_version, sizeof(rsp.ver)); int32_t contLen = tSerializeSServerVerRsp(NULL, 0, &rsp); if (contLen < 0) { diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index 4f72b26a5ef..8d33e61733b 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -248,7 +248,7 @@ static int32_t doAddSinkTask(SStreamObj* pStream, SMnode* pMnode, SVgObj* pVgrou return code; } - mDebug("doAddSinkTask taskId:%s, vgId:%d, isFillHistory:%d", pTask->id.idStr, pVgroup->vgId, isFillhistory); + mDebug("doAddSinkTask taskId:%s, %p vgId:%d, isFillHistory:%d", pTask->id.idStr, pTask, pVgroup->vgId, isFillhistory); pTask->info.nodeId = pVgroup->vgId; pTask->info.epSet = mndGetVgroupEpset(pMnode, pVgroup); @@ -364,12 +364,13 @@ static int32_t buildSourceTask(SStreamObj* pStream, SEpSet* pEpset, bool isFillh static void addNewTaskList(SStreamObj* pStream) { SArray* pTaskList = taosArrayInit(0, POINTER_BYTES); if (taosArrayPush(pStream->tasks, &pTaskList) == NULL) { - mError("failed to put array"); + mError("failed to put into array"); } + if (pStream->conf.fillHistory) { pTaskList = taosArrayInit(0, POINTER_BYTES); if (taosArrayPush(pStream->pHTasksList, &pTaskList) == NULL) { - mError("failed to put array"); + mError("failed to put into array"); } } } @@ -402,7 +403,8 @@ static int32_t doAddSourceTask(SMnode* pMnode, SSubplan* plan, SStreamObj* pStre return code; } - mDebug("doAddSourceTask taskId:%s, vgId:%d, isFillHistory:%d", pTask->id.idStr, pVgroup->vgId, isFillhistory); + mDebug("doAddSourceTask taskId:%s, %p vgId:%d, isFillHistory:%d", pTask->id.idStr, pTask, pVgroup->vgId, + isFillhistory); if (pStream->conf.fillHistory) { haltInitialTaskStatus(pTask, plan, isFillhistory); @@ -512,19 +514,20 @@ static int32_t doAddAggTask(SStreamObj* pStream, SMnode* pMnode, SSubplan* plan, SSnodeObj* pSnode, bool isFillhistory, bool useTriggerParam) { int32_t code = 0; SStreamTask* pTask = NULL; + const char* id = NULL; code = buildAggTask(pStream, pEpset, isFillhistory, useTriggerParam, &pTask); if (code != TSDB_CODE_SUCCESS) { return code; } + id = pTask->id.idStr; if (pSnode != NULL) { code = mndAssignStreamTaskToSnode(pMnode, pTask, plan, pSnode); - mDebug("doAddAggTask taskId:%s, snode id:%d, isFillHistory:%d", pTask->id.idStr, pSnode->id, isFillhistory); - + mDebug("doAddAggTask taskId:%s, %p snode id:%d, isFillHistory:%d", id, pTask, pSnode->id, isFillhistory); } else { code = mndAssignStreamTaskToVgroup(pMnode, pTask, plan, pVgroup); - mDebug("doAddAggTask taskId:%s, vgId:%d, isFillHistory:%d", pTask->id.idStr, pVgroup->vgId, isFillhistory); + mDebug("doAddAggTask taskId:%s, %p vgId:%d, isFillHistory:%d", id, pTask, pVgroup->vgId, isFillhistory); } return code; } @@ -678,7 +681,7 @@ static int32_t doScheduleStream(SStreamObj* pStream, SMnode* pMnode, SQueryPlan* if (numOfPlanLevel > 1 || externalTargetDB || multiTarget || pStream->fixedSinkVgId) { // add extra sink hasExtraSink = true; - int32_t code = addSinkTask(pMnode, pStream, pEpset); + code = addSinkTask(pMnode, pStream, pEpset); if (code != TSDB_CODE_SUCCESS) { return code; } diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index a4327b777fc..8abe739f25f 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -795,12 +795,22 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { } if (createReq.sql != NULL) { - sqlLen = strlen(createReq.sql); - sql = taosMemoryMalloc(sqlLen + 1); + sql = taosStrdup(createReq.sql); TSDB_CHECK_NULL(sql, code, lino, _OVER, terrno); + } + + SDbObj *pSourceDb = mndAcquireDb(pMnode, createReq.sourceDB); + if (pSourceDb == NULL) { + code = terrno; + mInfo("stream:%s failed to create, acquire source db %s failed, code:%s", createReq.name, createReq.sourceDB, + tstrerror(code)); + goto _OVER; + } - memset(sql, 0, sqlLen + 1); - memcpy(sql, createReq.sql, sqlLen); + code = mndCheckForSnode(pMnode, pSourceDb); + mndReleaseDb(pMnode, pSourceDb); + if (code != 0) { + goto _OVER; } // build stream obj from request @@ -1284,9 +1294,10 @@ static int32_t mndProcessStreamCheckpoint(SRpcMsg *pReq) { void* p = taosArrayPush(pList, &in); if (p) { int32_t currentSize = taosArrayGetSize(pList); - mDebug("stream:%s (uid:0x%" PRIx64 ") checkpoint interval beyond threshold: %ds(%" PRId64 - "s) beyond concurrently launch threshold:%d", - pStream->name, pStream->uid, tsStreamCheckpointInterval, duration / 1000, currentSize); + mDebug("stream:%s (uid:0x%" PRIx64 ") total %d stream(s) beyond chpt interval threshold: %ds(%" PRId64 + "s), concurrently launch threshold:%d", + pStream->name, pStream->uid, currentSize, tsStreamCheckpointInterval, duration / 1000, + tsMaxConcurrentCheckpoint); } else { mError("failed to record the checkpoint interval info, stream:0x%" PRIx64, pStream->uid); } @@ -1338,7 +1349,7 @@ static int32_t mndProcessStreamCheckpoint(SRpcMsg *pReq) { code = mndProcessStreamCheckpointTrans(pMnode, p, checkpointId, 1, true); sdbRelease(pSdb, p); - if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { + if (code == 0 || code == TSDB_CODE_ACTION_IN_PROGRESS) { started += 1; if (started >= capacity) { @@ -1346,6 +1357,8 @@ static int32_t mndProcessStreamCheckpoint(SRpcMsg *pReq) { (started + numOfCheckpointTrans)); break; } + } else { + mError("failed to start checkpoint trans, code:%s", tstrerror(code)); } } } diff --git a/source/dnode/mnode/impl/src/mndStreamUtil.c b/source/dnode/mnode/impl/src/mndStreamUtil.c index 6e48c58b30f..423d9df4b6f 100644 --- a/source/dnode/mnode/impl/src/mndStreamUtil.c +++ b/source/dnode/mnode/impl/src/mndStreamUtil.c @@ -1497,6 +1497,30 @@ bool mndStreamNodeIsUpdated(SMnode *pMnode) { return updated; } +int32_t mndCheckForSnode(SMnode *pMnode, SDbObj *pSrcDb) { + SSdb *pSdb = pMnode->pSdb; + void *pIter = NULL; + SSnodeObj *pObj = NULL; + + if (pSrcDb->cfg.replications == 1) { + return TSDB_CODE_SUCCESS; + } else { + while (1) { + pIter = sdbFetch(pSdb, SDB_SNODE, pIter, (void **)&pObj); + if (pIter == NULL) { + break; + } + + sdbRelease(pSdb, pObj); + sdbCancelFetch(pSdb, pIter); + return TSDB_CODE_SUCCESS; + } + + mError("snode not existed when trying to create stream in db with multiple replica"); + return TSDB_CODE_SNODE_NOT_DEPLOYED; + } +} + uint32_t seed = 0; static SRpcMsg createRpcMsg(STransAction* pAction, int64_t traceId, int64_t signature) { SRpcMsg rpcMsg = {.msgType = pAction->msgType, .contLen = pAction->contLen, .info.ahandle = (void *)signature}; diff --git a/source/dnode/mnode/impl/src/mndTelem.c b/source/dnode/mnode/impl/src/mndTelem.c index 0022aee6198..810c71b7c58 100644 --- a/source/dnode/mnode/impl/src/mndTelem.c +++ b/source/dnode/mnode/impl/src/mndTelem.c @@ -115,9 +115,9 @@ static char* mndBuildTelemetryReport(SMnode* pMnode) { snprintf(tmp, sizeof(tmp), "%" PRId64 " kB", tsTotalMemoryKB); TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "memory", tmp), &lino, _OVER); - TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "version", version), &lino, _OVER); - TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "buildInfo", buildinfo), &lino, _OVER); - TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "gitInfo", gitinfo), &lino, _OVER); + TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "version", td_version), &lino, _OVER); + TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "buildInfo", td_buildinfo), &lino, _OVER); + TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "gitInfo", td_gitinfo), &lino, _OVER); TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "email", pMgmt->email), &lino, _OVER); mndBuildRuntimeInfo(pMnode, pJson); diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 4152232396a..544db76a49d 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -717,11 +717,28 @@ static bool mndBuildDnodesArrayFp(SMnode *pMnode, void *pObj, void *p1, void *p2 SDnodeObj *pDnode = pObj; SArray *pArray = p1; int32_t exceptDnodeId = *(int32_t *)p2; + SArray *dnodeList = p3; if (exceptDnodeId == pDnode->id) { return true; } + if (dnodeList != NULL) { + int32_t dnodeListSize = taosArrayGetSize(dnodeList); + if (dnodeListSize > 0) { + bool inDnodeList = false; + for (int32_t index = 0; index < dnodeListSize; ++index) { + int32_t dnodeId = *(int32_t *)taosArrayGet(dnodeList, index); + if (pDnode->id == dnodeId) { + inDnodeList = true; + } + } + if (!inDnodeList) { + return true; + } + } + } + int64_t curMs = taosGetTimestampMs(); bool online = mndIsDnodeOnline(pDnode, curMs); bool isMnode = mndIsMnode(pMnode, pDnode->id); @@ -741,7 +758,7 @@ static bool mndBuildDnodesArrayFp(SMnode *pMnode, void *pObj, void *p1, void *p2 return true; } -SArray *mndBuildDnodesArray(SMnode *pMnode, int32_t exceptDnodeId) { +SArray *mndBuildDnodesArray(SMnode *pMnode, int32_t exceptDnodeId, SArray *dnodeList) { SSdb *pSdb = pMnode->pSdb; int32_t numOfDnodes = mndGetDnodeSize(pMnode); @@ -752,7 +769,7 @@ SArray *mndBuildDnodesArray(SMnode *pMnode, int32_t exceptDnodeId) { } sdbTraverse(pSdb, SDB_DNODE, mndResetDnodesArrayFp, NULL, NULL, NULL); - sdbTraverse(pSdb, SDB_DNODE, mndBuildDnodesArrayFp, pArray, &exceptDnodeId, NULL); + sdbTraverse(pSdb, SDB_DNODE, mndBuildDnodesArrayFp, pArray, &exceptDnodeId, dnodeList); mDebug("build %d dnodes array", (int32_t)taosArrayGetSize(pArray)); for (int32_t i = 0; i < (int32_t)taosArrayGetSize(pArray); ++i) { @@ -845,7 +862,7 @@ static int32_t mndGetAvailableDnode(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup int32_t mndAllocSmaVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup) { int32_t code = 0; - SArray *pArray = mndBuildDnodesArray(pMnode, 0); + SArray *pArray = mndBuildDnodesArray(pMnode, 0, NULL); if (pArray == NULL) { code = TSDB_CODE_MND_RETURN_VALUE_NULL; if (terrno != 0) code = terrno; @@ -868,7 +885,7 @@ int32_t mndAllocSmaVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup) { return 0; } -int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) { +int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups, SArray *dnodeList) { int32_t code = -1; SArray *pArray = NULL; SVgObj *pVgroups = NULL; @@ -879,7 +896,7 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) { goto _OVER; } - pArray = mndBuildDnodesArray(pMnode, 0); + pArray = mndBuildDnodesArray(pMnode, 0, dnodeList); if (pArray == NULL) { code = TSDB_CODE_MND_RETURN_VALUE_NULL; if (terrno != 0) code = terrno; @@ -2062,7 +2079,7 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, int32_t mndSetMoveVgroupsInfoToTrans(SMnode *pMnode, STrans *pTrans, int32_t delDnodeId, bool force, bool unsafe) { int32_t code = 0; - SArray *pArray = mndBuildDnodesArray(pMnode, delDnodeId); + SArray *pArray = mndBuildDnodesArray(pMnode, delDnodeId, NULL); if (pArray == NULL) { code = TSDB_CODE_MND_RETURN_VALUE_NULL; if (terrno != 0) code = terrno; @@ -3140,7 +3157,7 @@ int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj *pVgro int32_t code = -1; STrans *pTrans = NULL; SDbObj dbObj = {0}; - SArray *pArray = mndBuildDnodesArray(pMnode, 0); + SArray *pArray = mndBuildDnodesArray(pMnode, 0, NULL); int32_t numOfStreams = 0; if ((code = mndGetNumOfStreams(pMnode, pDb->name, &numOfStreams)) != 0) { @@ -3508,7 +3525,7 @@ static int32_t mndProcessBalanceVgroupMsg(SRpcMsg *pReq) { sdbRelease(pMnode->pSdb, pDnode); } - pArray = mndBuildDnodesArray(pMnode, 0); + pArray = mndBuildDnodesArray(pMnode, 0, NULL); if (pArray == NULL) { code = TSDB_CODE_MND_RETURN_VALUE_NULL; if (terrno != 0) code = terrno; diff --git a/source/dnode/mnode/impl/test/arbgroup/arbgroup.cpp b/source/dnode/mnode/impl/test/arbgroup/arbgroup.cpp index fdfc560d54f..d5ca0194202 100644 --- a/source/dnode/mnode/impl/test/arbgroup/arbgroup.cpp +++ b/source/dnode/mnode/impl/test/arbgroup/arbgroup.cpp @@ -80,17 +80,17 @@ TEST_F(ArbgroupTest, 01_encode_decode_sdb) { SArbGroup* pNewGroup = (SArbGroup*)sdbGetRowObj(pRow); - EXPECT_EQ(group.vgId, pNewGroup->vgId); - EXPECT_EQ(group.dbUid, pNewGroup->dbUid); - EXPECT_EQ(group.members[0].info.dnodeId, pNewGroup->members[0].info.dnodeId); - EXPECT_EQ(group.members[1].info.dnodeId, pNewGroup->members[1].info.dnodeId); - EXPECT_EQ(group.isSync, pNewGroup->isSync); - EXPECT_EQ(group.assignedLeader.dnodeId, pNewGroup->assignedLeader.dnodeId); - - EXPECT_EQ(std::string(group.members[0].state.token), std::string(pNewGroup->members[0].state.token)); - EXPECT_EQ(std::string(group.members[1].state.token), std::string(pNewGroup->members[1].state.token)); - EXPECT_EQ(std::string(group.assignedLeader.token), std::string(pNewGroup->assignedLeader.token)); - EXPECT_EQ(group.version, pNewGroup->version); + ASSERT_EQ(group.vgId, pNewGroup->vgId); + ASSERT_EQ(group.dbUid, pNewGroup->dbUid); + ASSERT_EQ(group.members[0].info.dnodeId, pNewGroup->members[0].info.dnodeId); + ASSERT_EQ(group.members[1].info.dnodeId, pNewGroup->members[1].info.dnodeId); + ASSERT_EQ(group.isSync, pNewGroup->isSync); + ASSERT_EQ(group.assignedLeader.dnodeId, pNewGroup->assignedLeader.dnodeId); + + ASSERT_EQ(std::string(group.members[0].state.token), std::string(pNewGroup->members[0].state.token)); + ASSERT_EQ(std::string(group.members[1].state.token), std::string(pNewGroup->members[1].state.token)); + ASSERT_EQ(std::string(group.assignedLeader.token), std::string(pNewGroup->assignedLeader.token)); + ASSERT_EQ(group.version, pNewGroup->version); taosMemoryFree(pRow); taosMemoryFree(pRaw); @@ -129,9 +129,9 @@ TEST_F(ArbgroupTest, 02_process_heart_beat_rsp) { SArbGroup newGroup = {0}; bool updateToken = mndUpdateArbGroupByHeartBeat(&group, &rspMember, nowMs, dnodeId, &newGroup); - EXPECT_FALSE(updateToken); - EXPECT_NE(group.members[0].state.responsedHbSeq, rspMember.hbSeq); - EXPECT_NE(group.members[0].state.lastHbMs, nowMs); + ASSERT_EQ(updateToken, false); + ASSERT_NE(group.members[0].state.responsedHbSeq, rspMember.hbSeq); + ASSERT_NE(group.members[0].state.lastHbMs, nowMs); } { // old token @@ -144,9 +144,9 @@ TEST_F(ArbgroupTest, 02_process_heart_beat_rsp) { SArbGroup newGroup = {0}; bool updateToken = mndUpdateArbGroupByHeartBeat(&group, &rspMember, nowMs, dnodeId, &newGroup); - EXPECT_FALSE(updateToken); - EXPECT_EQ(group.members[0].state.responsedHbSeq, rspMember.hbSeq); - EXPECT_EQ(group.members[0].state.lastHbMs, nowMs); + ASSERT_EQ(updateToken, false); + ASSERT_EQ(group.members[0].state.responsedHbSeq, rspMember.hbSeq); + ASSERT_EQ(group.members[0].state.lastHbMs, nowMs); } { // new token @@ -159,14 +159,14 @@ TEST_F(ArbgroupTest, 02_process_heart_beat_rsp) { SArbGroup newGroup = {0}; bool updateToken = mndUpdateArbGroupByHeartBeat(&group, &rspMember, nowMs, dnodeId, &newGroup); - EXPECT_TRUE(updateToken); - EXPECT_EQ(group.members[0].state.responsedHbSeq, rspMember.hbSeq); - EXPECT_EQ(group.members[0].state.lastHbMs, nowMs); + ASSERT_EQ(updateToken, true); + ASSERT_EQ(group.members[0].state.responsedHbSeq, rspMember.hbSeq); + ASSERT_EQ(group.members[0].state.lastHbMs, nowMs); - EXPECT_EQ(std::string(newGroup.members[0].state.token), std::string(rspMember.memberToken)); - EXPECT_FALSE(newGroup.isSync); - EXPECT_EQ(newGroup.assignedLeader.dnodeId, 0); - EXPECT_EQ(std::string(newGroup.assignedLeader.token).size(), 0); + ASSERT_EQ(std::string(newGroup.members[0].state.token), std::string(rspMember.memberToken)); + ASSERT_EQ(newGroup.isSync, false); + ASSERT_EQ(newGroup.assignedLeader.dnodeId, 0); + ASSERT_EQ(std::string(newGroup.assignedLeader.token).size(), 0); } taosThreadMutexDestroy(&group.mutex); @@ -203,7 +203,7 @@ TEST_F(ArbgroupTest, 03_process_check_sync_rsp) { SArbGroup newGroup = {0}; bool updateIsSync = mndUpdateArbGroupByCheckSync(&group, vgId, member0Token, member1Token, newIsSync, &newGroup); - EXPECT_FALSE(updateIsSync); + ASSERT_EQ(updateIsSync, false); } { // newIsSync @@ -216,8 +216,8 @@ TEST_F(ArbgroupTest, 03_process_check_sync_rsp) { SArbGroup newGroup = {0}; bool updateIsSync = mndUpdateArbGroupByCheckSync(&group, vgId, member0Token, member1Token, newIsSync, &newGroup); - EXPECT_TRUE(updateIsSync); - EXPECT_TRUE(newGroup.isSync); + ASSERT_EQ(updateIsSync, true); + ASSERT_EQ(newGroup.isSync, true); } taosThreadMutexDestroy(&group.mutex); @@ -254,7 +254,7 @@ TEST_F(ArbgroupTest, 04_process_set_assigned_leader){ SArbGroup newGroup = {0}; bool updateAssigned = mndUpdateArbGroupBySetAssignedLeader(&group, vgId, memberToken, errcode, &newGroup); - EXPECT_FALSE(updateAssigned); + ASSERT_EQ(updateAssigned, false); } { // errcode != TSDB_CODE_SUCCESS @@ -265,7 +265,7 @@ TEST_F(ArbgroupTest, 04_process_set_assigned_leader){ SArbGroup newGroup = {0}; bool updateAssigned = mndUpdateArbGroupBySetAssignedLeader(&group, vgId, memberToken, errcode, &newGroup); - EXPECT_FALSE(updateAssigned); + ASSERT_EQ(updateAssigned, false); } { // errcode == TSDB_CODE_SUCCESS @@ -276,11 +276,81 @@ TEST_F(ArbgroupTest, 04_process_set_assigned_leader){ SArbGroup newGroup = {0}; bool updateAssigned = mndUpdateArbGroupBySetAssignedLeader(&group, vgId, memberToken, errcode, &newGroup); - EXPECT_TRUE(updateAssigned); - EXPECT_FALSE(newGroup.isSync); + ASSERT_EQ(updateAssigned, true); + ASSERT_EQ(newGroup.isSync, false); } taosThreadMutexDestroy(&group.mutex); } +TEST_F(ArbgroupTest, 05_check_sync_timer) { + const int32_t assgndDnodeId = 1; + const int32_t vgId = 5; + const int64_t nowMs = 173044838300; + + SArbGroup group = {0}; + group.vgId = vgId; + group.dbUid = 1234; + group.members[0].info.dnodeId = assgndDnodeId; + group.members[0].state.lastHbMs = nowMs - 10; + + group.members[1].info.dnodeId = 2; + group.members[1].state.lastHbMs = nowMs - 10; + + group.isSync = 1; + taosThreadMutexInit(&group.mutex, NULL); + + SArbAssignedLeader assgnedLeader = {0}; + assgnedLeader.dnodeId = assgndDnodeId; + assgnedLeader.acked = false; + strncpy(assgnedLeader.token, group.members[0].state.token, TSDB_ARB_TOKEN_SIZE); + + SArbAssignedLeader noneAsgndLeader = {0}; + noneAsgndLeader.dnodeId = 0; + noneAsgndLeader.acked = false; + + ECheckSyncOp op = CHECK_SYNC_NONE; + SArbGroup newGroup = {0}; + + // 1. asgnd,sync,noAck --> send set assigned + group.assignedLeader = assgnedLeader; + group.assignedLeader.acked = false; + group.isSync = true; + mndArbCheckSync(&group, nowMs, &op, &newGroup); + + ASSERT_EQ(op, CHECK_SYNC_SET_ASSIGNED_LEADER); + + // 2. asgnd,notSync,noAck --> send set assgnd + newGroup = {0}; + group.assignedLeader = assgnedLeader; + group.isSync = false; + group.assignedLeader.acked = false; + mndArbCheckSync(&group, nowMs, &op, &newGroup); + + ASSERT_EQ(op, CHECK_SYNC_SET_ASSIGNED_LEADER); + + // 3. noAsgnd,notSync,noAck(init) --> check sync + newGroup = {0}; + group.assignedLeader = noneAsgndLeader; + group.isSync = false; + group.assignedLeader.acked = false; + mndArbCheckSync(&group, nowMs, &op, &newGroup); + + ASSERT_EQ(op, CHECK_SYNC_CHECK_SYNC); + + // 4. noAsgnd,sync,noAck,one timeout--> update arbgroup (asgnd,sync,noAck) + newGroup = {0}; + group.assignedLeader = noneAsgndLeader; + group.isSync = true; + group.assignedLeader.acked = false; + group.members[1].state.lastHbMs = nowMs - 2 * tsArbSetAssignedTimeoutSec * 1000; // member1 timeout + mndArbCheckSync(&group, nowMs, &op, &newGroup); + + ASSERT_EQ(op, CHECK_SYNC_UPDATE); + ASSERT_EQ(newGroup.assignedLeader.dnodeId, assgndDnodeId); + ASSERT_EQ(std::string(newGroup.assignedLeader.token), std::string(group.members[0].state.token)); + ASSERT_EQ(newGroup.isSync, true); + ASSERT_EQ(newGroup.assignedLeader.acked, false); +} + #pragma GCC diagnostic pop diff --git a/source/dnode/mnode/impl/test/profile/profile.cpp b/source/dnode/mnode/impl/test/profile/profile.cpp index b1b94c65fb5..bfd8909a76c 100644 --- a/source/dnode/mnode/impl/test/profile/profile.cpp +++ b/source/dnode/mnode/impl/test/profile/profile.cpp @@ -39,7 +39,7 @@ TEST_F(MndTestProfile, 01_ConnectMsg) { strcpy(connectReq.db, ""); strcpy(connectReq.user, "root"); strcpy(connectReq.passwd, secretEncrypt); - strcpy(connectReq.sVer, version); + strcpy(connectReq.sVer, td_version); int32_t contLen = tSerializeSConnectReq(NULL, 0, &connectReq); void* pReq = rpcMallocCont(contLen); @@ -76,7 +76,7 @@ TEST_F(MndTestProfile, 02_ConnectMsg_NotExistDB) { strcpy(connectReq.db, "not_exist_db"); strcpy(connectReq.user, "root"); strcpy(connectReq.passwd, secretEncrypt); - strcpy(connectReq.sVer, version); + strcpy(connectReq.sVer, td_version); int32_t contLen = tSerializeSConnectReq(NULL, 0, &connectReq); void* pReq = rpcMallocCont(contLen); diff --git a/source/dnode/mnode/impl/test/show/show.cpp b/source/dnode/mnode/impl/test/show/show.cpp index 2e67ffa946d..92b914a8dc9 100644 --- a/source/dnode/mnode/impl/test/show/show.cpp +++ b/source/dnode/mnode/impl/test/show/show.cpp @@ -64,7 +64,7 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) { strcpy(connectReq.db, ""); strcpy(connectReq.user, "root"); strcpy(connectReq.passwd, secretEncrypt); - strcpy(connectReq.sVer, version); + strcpy(connectReq.sVer, td_version); int32_t contLen = tSerializeSConnectReq(NULL, 0, &connectReq); void* pReq = rpcMallocCont(contLen); diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index d61f3d80d34..6eee8c510be 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -38,24 +38,23 @@ int32_t sndBuildStreamTask(SSnode *pSnode, SStreamTask *pTask, int64_t nextProce streamTaskOpenAllUpstreamInput(pTask); streamTaskResetUpstreamStageInfo(pTask); - streamSetupScheduleTrigger(pTask); SCheckpointInfo *pChkInfo = &pTask->chkInfo; tqSetRestoreVersionInfo(pTask); char *p = streamTaskGetStatus(pTask).name; if (pTask->info.fillHistory) { - sndInfo("vgId:%d build stream task, s-task:%s, checkpointId:%" PRId64 " checkpointVer:%" PRId64 + sndInfo("vgId:%d build stream task, s-task:%s, %p checkpointId:%" PRId64 " checkpointVer:%" PRId64 " nextProcessVer:%" PRId64 " child id:%d, level:%d, status:%s fill-history:%d, related stream task:0x%x trigger:%" PRId64 " ms", - SNODE_HANDLE, pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer, + SNODE_HANDLE, pTask->id.idStr, pTask, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer, pTask->info.selfChildId, pTask->info.taskLevel, p, pTask->info.fillHistory, (int32_t)pTask->streamTaskId.taskId, pTask->info.delaySchedParam); } else { - sndInfo("vgId:%d build stream task, s-task:%s, checkpointId:%" PRId64 " checkpointVer:%" PRId64 + sndInfo("vgId:%d build stream task, s-task:%s, %p checkpointId:%" PRId64 " checkpointVer:%" PRId64 " nextProcessVer:%" PRId64 " child id:%d, level:%d, status:%s fill-history:%d, related fill-task:0x%x trigger:%" PRId64 " ms", - SNODE_HANDLE, pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer, + SNODE_HANDLE, pTask->id.idStr, pTask, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer, pTask->info.selfChildId, pTask->info.taskLevel, p, pTask->info.fillHistory, (int32_t)pTask->hTaskInfo.id.taskId, pTask->info.delaySchedParam); } diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index ed8f99ec753..c1123db7a33 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -342,7 +342,10 @@ typedef struct { rocksdb_writeoptions_t *writeoptions; rocksdb_readoptions_t *readoptions; rocksdb_writebatch_t *writebatch; - TdThreadMutex writeBatchMutex; + TdThreadMutex writeBatchMutex; + int32_t sver; + tb_uid_t suid; + tb_uid_t uid; STSchema *pTSchema; } SRocksCache; diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 54efa0314b2..512e0884286 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -222,6 +222,7 @@ int32_t tsdbCacheNewSTableColumn(STsdb* pTsdb, SArray* uids, int16_t cid, int8_t int32_t tsdbCacheDropSTableColumn(STsdb* pTsdb, SArray* uids, int16_t cid, bool hasPrimayKey); int32_t tsdbCacheNewNTableColumn(STsdb* pTsdb, int64_t uid, int16_t cid, int8_t col_type); int32_t tsdbCacheDropNTableColumn(STsdb* pTsdb, int64_t uid, int16_t cid, bool hasPrimayKey); +void tsdbCacheInvalidateSchema(STsdb* pTsdb, tb_uid_t suid, tb_uid_t uid, int32_t sver); int tsdbScanAndConvertSubmitMsg(STsdb* pTsdb, SSubmitReq2* pMsg); int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq2* pMsg, SSubmitRsp2* pRsp); int32_t tsdbInsertTableData(STsdb* pTsdb, int64_t version, SSubmitTbData* pSubmitTbData, int32_t* affectedRows); diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 21d12ef77de..5c3516a962e 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -620,6 +620,8 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { } } if (uids) taosArrayDestroy(uids); + + tsdbCacheInvalidateSchema(pTsdb, pReq->suid, -1, pReq->schemaRow.version); } metaWLock(pMeta); @@ -1945,6 +1947,10 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl break; } + if (!TSDB_CACHE_NO(pMeta->pVnode->config)) { + tsdbCacheInvalidateSchema(pMeta->pVnode->pTsdb, 0, entry.uid, pSchema->version); + } + entry.version = version; // do actual write diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 4fdf299e50d..80c04a32765 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -238,13 +238,18 @@ int32_t tdFetchTbUidList(SSma *pSma, STbUidStore **ppStore, tb_uid_t suid, tb_ui } static void tdRSmaTaskInit(SStreamMeta *pMeta, SRSmaInfoItem *pItem, SStreamTaskId *pId) { - STaskId id = {.streamId = pId->streamId, .taskId = pId->taskId}; + STaskId id = {.streamId = pId->streamId, .taskId = pId->taskId}; + SStreamTask *pTask = NULL; + streamMetaRLock(pMeta); - SStreamTask **ppTask = (SStreamTask **)taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); - if (ppTask && *ppTask) { - pItem->submitReqVer = (*ppTask)->chkInfo.checkpointVer; - pItem->fetchResultVer = (*ppTask)->info.delaySchedParam; + + int32_t code = streamMetaAcquireTaskUnsafe(pMeta, &id, &pTask); + if (code == 0) { + pItem->submitReqVer = pTask->chkInfo.checkpointVer; + pItem->fetchResultVer = pTask->info.delaySchedParam; + streamMetaReleaseTask(pMeta, pTask); } + streamMetaRUnLock(pMeta); } diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index b75baea08d1..ec7ac1054c9 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -765,7 +765,6 @@ int32_t tqBuildStreamTask(void* pTqObj, SStreamTask* pTask, int64_t nextProcessV } streamTaskResetUpstreamStageInfo(pTask); - streamSetupScheduleTrigger(pTask); SCheckpointInfo* pChkInfo = &pTask->chkInfo; tqSetRestoreVersionInfo(pTask); @@ -774,19 +773,19 @@ int32_t tqBuildStreamTask(void* pTqObj, SStreamTask* pTask, int64_t nextProcessV const char* pNext = streamTaskGetStatusStr(pTask->status.taskStatus); if (pTask->info.fillHistory) { - tqInfo("vgId:%d build stream task, s-task:%s, checkpointId:%" PRId64 " checkpointVer:%" PRId64 + tqInfo("vgId:%d build stream task, s-task:%s, %p checkpointId:%" PRId64 " checkpointVer:%" PRId64 " nextProcessVer:%" PRId64 " child id:%d, level:%d, cur-status:%s, next-status:%s fill-history:%d, related stream task:0x%x " "delaySched:%" PRId64 " ms, inputVer:%" PRId64, - vgId, pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer, + vgId, pTask->id.idStr, pTask, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer, pTask->info.selfChildId, pTask->info.taskLevel, p, pNext, pTask->info.fillHistory, (int32_t)pTask->streamTaskId.taskId, pTask->info.delaySchedParam, nextProcessVer); } else { - tqInfo("vgId:%d build stream task, s-task:%s, checkpointId:%" PRId64 " checkpointVer:%" PRId64 + tqInfo("vgId:%d build stream task, s-task:%s, %p checkpointId:%" PRId64 " checkpointVer:%" PRId64 " nextProcessVer:%" PRId64 " child id:%d, level:%d, cur-status:%s next-status:%s fill-history:%d, related fill-task:0x%x " "delaySched:%" PRId64 " ms, inputVer:%" PRId64, - vgId, pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer, + vgId, pTask->id.idStr, pTask, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer, pTask->info.selfChildId, pTask->info.taskLevel, p, pNext, pTask->info.fillHistory, (int32_t)pTask->hTaskInfo.id.taskId, pTask->info.delaySchedParam, nextProcessVer); diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index fedcc0e82dc..95955e579ff 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -1113,12 +1113,20 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) { break; } - SStreamTask* pTask = *(SStreamTask**)pIter; - if ((pTask->info.taskLevel == TASK_LEVEL__SOURCE) && (pTask->exec.pExecutor != NULL)) { - int32_t code = qUpdateTableListForStreamScanner(pTask->exec.pExecutor, tbUidList, isAdd); - if (code != 0) { - tqError("vgId:%d, s-task:%s update qualified table error for stream task", vgId, pTask->id.idStr); - continue; + int64_t refId = *(int64_t*)pIter; + SStreamTask* pTask = taosAcquireRef(streamTaskRefPool, refId); + if (pTask != NULL) { + int32_t taskId = pTask->id.taskId; + + if ((pTask->info.taskLevel == TASK_LEVEL__SOURCE) && (pTask->exec.pExecutor != NULL)) { + int32_t code = qUpdateTableListForStreamScanner(pTask->exec.pExecutor, tbUidList, isAdd); + if (code != 0) { + tqError("vgId:%d, s-task:0x%x update qualified table error for stream task", vgId, taskId); + } + } + int32_t ret = taosReleaseRef(streamTaskRefPool, refId); + if (ret) { + tqError("vgId:%d release task refId failed, refId:%" PRId64, vgId, refId); } } } diff --git a/source/dnode/vnode/src/tq/tqStreamTask.c b/source/dnode/vnode/src/tq/tqStreamTask.c index 3ec269ec220..24c892de8bf 100644 --- a/source/dnode/vnode/src/tq/tqStreamTask.c +++ b/source/dnode/vnode/src/tq/tqStreamTask.c @@ -79,7 +79,7 @@ static void doStartScanWal(void* param, void* tmrId) { SBuildScanWalMsgParam* pParam = (SBuildScanWalMsgParam*)param; - SStreamMeta* pMeta = taosAcquireRef(streamMetaId, pParam->metaId); + SStreamMeta* pMeta = taosAcquireRef(streamMetaRefPool, pParam->metaId); if (pMeta == NULL) { tqError("metaRid:%" PRId64 " not valid now, stream meta has been freed", pParam->metaId); taosMemoryFree(pParam); @@ -97,7 +97,7 @@ static void doStartScanWal(void* param, void* tmrId) { tqError("vgId:%d failed sched task to scan wal, code:%s", vgId, tstrerror(code)); } - code = taosReleaseRef(streamMetaId, pParam->metaId); + code = taosReleaseRef(streamMetaRefPool, pParam->metaId); if (code) { tqError("vgId:%d failed to release ref for streamMeta, rid:%" PRId64 " code:%s", vgId, pParam->metaId, tstrerror(code)); diff --git a/source/dnode/vnode/src/tq/tqUtil.c b/source/dnode/vnode/src/tq/tqUtil.c index 3f119374632..6d3188ec866 100644 --- a/source/dnode/vnode/src/tq/tqUtil.c +++ b/source/dnode/vnode/src/tq/tqUtil.c @@ -685,19 +685,21 @@ int32_t tqGetStreamExecInfo(SVnode* pVnode, int64_t streamId, int64_t* pDelay, b continue; } - STaskId id = {.streamId = pId->streamId, .taskId = pId->taskId}; - SStreamTask** ppTask = taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); - if (ppTask == NULL) { + STaskId id = {.streamId = pId->streamId, .taskId = pId->taskId}; + SStreamTask* pTask = NULL; + + code = streamMetaAcquireTaskUnsafe(pMeta, &id, &pTask); + if (code != 0) { tqError("vgId:%d failed to acquire task:0x%x in retrieving progress", pMeta->vgId, pId->taskId); continue; } - if ((*ppTask)->info.taskLevel != TASK_LEVEL__SOURCE) { + if (pTask->info.taskLevel != TASK_LEVEL__SOURCE) { + streamMetaReleaseTask(pMeta, pTask); continue; } // here we get the required stream source task - SStreamTask* pTask = *ppTask; *fhFinished = !HAS_RELATED_FILLHISTORY_TASK(pTask); int64_t ver = walReaderGetCurrentVer(pTask->exec.pWalReader); @@ -713,6 +715,7 @@ int32_t tqGetStreamExecInfo(SVnode* pVnode, int64_t streamId, int64_t* pDelay, b SWalReader* pReader = walOpenReader(pTask->exec.pWalReader->pWal, NULL, 0); if (pReader == NULL) { tqError("failed to open wal reader to extract exec progress, vgId:%d", pMeta->vgId); + streamMetaReleaseTask(pMeta, pTask); continue; } @@ -738,6 +741,7 @@ int32_t tqGetStreamExecInfo(SVnode* pVnode, int64_t streamId, int64_t* pDelay, b } walCloseReader(pReader); + streamMetaReleaseTask(pMeta, pTask); } streamMetaRUnLock(pMeta); diff --git a/source/dnode/vnode/src/tqCommon/tqCommon.c b/source/dnode/vnode/src/tqCommon/tqCommon.c index a00e92997c0..59e739d1ffb 100644 --- a/source/dnode/vnode/src/tqCommon/tqCommon.c +++ b/source/dnode/vnode/src/tqCommon/tqCommon.c @@ -138,13 +138,15 @@ int32_t tqStreamStartOneTaskAsync(SStreamMeta* pMeta, SMsgCb* cb, int64_t stream // this is to process request from transaction, always return true. int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pMsg, bool restored) { - int32_t vgId = pMeta->vgId; - char* msg = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); - int32_t len = pMsg->contLen - sizeof(SMsgHead); - SRpcMsg rsp = {.info = pMsg->info, .code = TSDB_CODE_SUCCESS}; - int64_t st = taosGetTimestampMs(); - bool updated = false; - int32_t code = 0; + int32_t vgId = pMeta->vgId; + char* msg = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); + int32_t len = pMsg->contLen - sizeof(SMsgHead); + SRpcMsg rsp = {.info = pMsg->info, .code = TSDB_CODE_SUCCESS}; + int64_t st = taosGetTimestampMs(); + bool updated = false; + int32_t code = 0; + SStreamTask* pTask = NULL; + SStreamTask* pHTask = NULL; SStreamTaskNodeUpdateMsg req = {0}; @@ -170,9 +172,9 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM streamMetaWLock(pMeta); // the task epset may be updated again and again, when replaying the WAL, the task may be in stop status. - STaskId id = {.streamId = req.streamId, .taskId = req.taskId}; - SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); - if (ppTask == NULL || *ppTask == NULL) { + STaskId id = {.streamId = req.streamId, .taskId = req.taskId}; + code = streamMetaAcquireTaskUnsafe(pMeta, &id, &pTask); + if (code != 0) { tqError("vgId:%d failed to acquire task:0x%x when handling update task epset, it may have been dropped", vgId, req.taskId); rsp.code = TSDB_CODE_SUCCESS; @@ -181,12 +183,13 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM return rsp.code; } - SStreamTask* pTask = *ppTask; - const char* idstr = pTask->id.idStr; + const char* idstr = pTask->id.idStr; if (req.transId <= 0) { tqError("vgId:%d invalid update nodeEp task, transId:%d, discard", vgId, req.taskId); rsp.code = TSDB_CODE_SUCCESS; + + streamMetaReleaseTask(pMeta, pTask); streamMetaWUnLock(pMeta); taosArrayDestroy(req.pNodeList); @@ -197,6 +200,8 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM bool update = streamMetaInitUpdateTaskList(pMeta, req.transId); if (!update) { rsp.code = TSDB_CODE_SUCCESS; + + streamMetaReleaseTask(pMeta, pTask); streamMetaWUnLock(pMeta); taosArrayDestroy(req.pNodeList); @@ -211,7 +216,10 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM tqDebug("s-task:%s (vgId:%d) already update in transId:%d, discard the nodeEp update msg", idstr, vgId, req.transId); rsp.code = TSDB_CODE_SUCCESS; + + streamMetaReleaseTask(pMeta, pTask); streamMetaWUnLock(pMeta); + taosArrayDestroy(req.pNodeList); return rsp.code; } @@ -227,24 +235,23 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM streamTaskStopMonitorCheckRsp(&pTask->taskCheckInfo, pTask->id.idStr); - SStreamTask** ppHTask = NULL; if (HAS_RELATED_FILLHISTORY_TASK(pTask)) { - ppHTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &pTask->hTaskInfo.id, sizeof(pTask->hTaskInfo.id)); - if (ppHTask == NULL || *ppHTask == NULL) { + code = streamMetaAcquireTaskUnsafe(pMeta, &pTask->hTaskInfo.id, &pHTask); + if (code != 0) { tqError( "vgId:%d failed to acquire fill-history task:0x%x when handling update, may have been dropped already, rel " "stream task:0x%x", vgId, (uint32_t)pTask->hTaskInfo.id.taskId, req.taskId); CLEAR_RELATED_FILLHISTORY_TASK(pTask); } else { - tqDebug("s-task:%s fill-history task update nodeEp along with stream task", (*ppHTask)->id.idStr); - bool updateEpSet = streamTaskUpdateEpsetInfo(*ppHTask, req.pNodeList); + tqDebug("s-task:%s fill-history task update nodeEp along with stream task", pHTask->id.idStr); + bool updateEpSet = streamTaskUpdateEpsetInfo(pHTask, req.pNodeList); if (updateEpSet) { updated = updateEpSet; } - streamTaskResetStatus(*ppHTask); - streamTaskStopMonitorCheckRsp(&(*ppHTask)->taskCheckInfo, (*ppHTask)->id.idStr); + streamTaskResetStatus(pHTask); + streamTaskStopMonitorCheckRsp(&pHTask->taskCheckInfo, pHTask->id.idStr); } } @@ -256,8 +263,8 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM tqError("s-task:%s vgId:%d failed to save task, code:%s", idstr, vgId, tstrerror(code)); } - if (ppHTask != NULL) { - code = streamMetaSaveTask(pMeta, *ppHTask); + if (pHTask != NULL) { + code = streamMetaSaveTask(pMeta, pHTask); if (code) { tqError("s-task:%s vgId:%d failed to save related history task, code:%s", idstr, vgId, tstrerror(code)); } @@ -271,15 +278,17 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM tqError("s-task:%s vgId:%d failed to stop task, code:%s", idstr, vgId, tstrerror(code)); } - if (ppHTask != NULL) { - code = streamTaskStop(*ppHTask); + if (pHTask != NULL) { + code = streamTaskStop(pHTask); if (code) { tqError("s-task:%s vgId:%d failed to stop related history task, code:%s", idstr, vgId, tstrerror(code)); } } // keep info - streamMetaAddIntoUpdateTaskList(pMeta, pTask, (ppHTask != NULL) ? (*ppHTask) : NULL, req.transId, st); + streamMetaAddIntoUpdateTaskList(pMeta, pTask, (pHTask != NULL) ? (pHTask) : NULL, req.transId, st); + streamMetaReleaseTask(pMeta, pTask); + streamMetaReleaseTask(pMeta, pHTask); rsp.code = TSDB_CODE_SUCCESS; @@ -643,7 +652,6 @@ int32_t tqStreamTaskProcessDeployReq(SStreamMeta* pMeta, SMsgCb* cb, int64_t sve if (code < 0) { tqError("failed to add s-task:0x%x into vgId:%d meta, existed:%d, code:%s", vgId, taskId, numOfTasks, tstrerror(code)); - tFreeStreamTask(pTask); return code; } @@ -673,7 +681,6 @@ int32_t tqStreamTaskProcessDeployReq(SStreamMeta* pMeta, SMsgCb* cb, int64_t sve } } else { tqWarn("vgId:%d failed to add s-task:0x%x, since already exists in meta store, total:%d", vgId, taskId, numOfTasks); - tFreeStreamTask(pTask); } return code; @@ -681,25 +688,25 @@ int32_t tqStreamTaskProcessDeployReq(SStreamMeta* pMeta, SMsgCb* cb, int64_t sve int32_t tqStreamTaskProcessDropReq(SStreamMeta* pMeta, char* msg, int32_t msgLen) { SVDropStreamTaskReq* pReq = (SVDropStreamTaskReq*)msg; + int32_t code = 0; + int32_t vgId = pMeta->vgId; + STaskId hTaskId = {0}; + SStreamTask* pTask = NULL; - int32_t code = 0; - int32_t vgId = pMeta->vgId; - STaskId hTaskId = {0}; tqDebug("vgId:%d receive msg to drop s-task:0x%x", vgId, pReq->taskId); streamMetaWLock(pMeta); - STaskId id = {.streamId = pReq->streamId, .taskId = pReq->taskId}; - SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); - if ((ppTask != NULL) && ((*ppTask) != NULL)) { - int32_t unusedRetRef = streamMetaAcquireOneTask(*ppTask); - SStreamTask* pTask = *ppTask; - + STaskId id = {.streamId = pReq->streamId, .taskId = pReq->taskId}; + code = streamMetaAcquireTaskUnsafe(pMeta, &id, &pTask); + if (code == 0) { if (HAS_RELATED_FILLHISTORY_TASK(pTask)) { hTaskId.streamId = pTask->hTaskInfo.id.streamId; hTaskId.taskId = pTask->hTaskInfo.id.taskId; } + // clear the relationship, and then release the stream tasks, to avoid invalid accessing of already freed + // related stream(history) task streamTaskSetRemoveBackendFiles(pTask); code = streamTaskClearHTaskAttr(pTask, pReq->resetRelHalt); streamMetaReleaseTask(pMeta, pTask); @@ -742,18 +749,19 @@ int32_t tqStreamTaskProcessDropReq(SStreamMeta* pMeta, char* msg, int32_t msgLen int32_t tqStreamTaskProcessUpdateCheckpointReq(SStreamMeta* pMeta, bool restored, char* msg) { SVUpdateCheckpointInfoReq* pReq = (SVUpdateCheckpointInfoReq*)msg; + int32_t code = 0; + int32_t vgId = pMeta->vgId; + SStreamTask* pTask = NULL; - int32_t code = 0; - int32_t vgId = pMeta->vgId; tqDebug("vgId:%d receive msg to update-checkpoint-info for s-task:0x%x", vgId, pReq->taskId); streamMetaWLock(pMeta); - STaskId id = {.streamId = pReq->streamId, .taskId = pReq->taskId}; - SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); - - if (ppTask != NULL && (*ppTask) != NULL) { - code = streamTaskUpdateTaskCheckpointInfo(*ppTask, restored, pReq); + STaskId id = {.streamId = pReq->streamId, .taskId = pReq->taskId}; + code = streamMetaAcquireTaskUnsafe(pMeta, &id, &pTask); + if (code == 0) { + code = streamTaskUpdateTaskCheckpointInfo(pTask, restored, pReq); + streamMetaReleaseTask(pMeta, pTask); } else { // failed to get the task. int32_t numOfTasks = streamMetaGetNumOfTasks(pMeta); tqError( @@ -763,7 +771,6 @@ int32_t tqStreamTaskProcessUpdateCheckpointReq(SStreamMeta* pMeta, bool restored } streamMetaWUnLock(pMeta); - // always return success when handling the requirement issued by mnode during transaction. return TSDB_CODE_SUCCESS; } @@ -789,11 +796,6 @@ static int32_t restartStreamTasks(SStreamMeta* pMeta, bool isLeader) { tqInfo("vgId:%d tasks are all updated and stopped, restart all tasks, triggered by transId:%d, ts:%" PRId64, vgId, pMeta->updateInfo.completeTransId, pMeta->updateInfo.completeTs); - while (streamMetaTaskInTimer(pMeta)) { - tqDebug("vgId:%d some tasks in timer, wait for 100ms and recheck", pMeta->vgId); - taosMsleep(100); - } - streamMetaWLock(pMeta); streamMetaClear(pMeta); diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index cbb4f9e873d..2cef541cdba 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -221,7 +221,7 @@ static int32_t tsdbOpenRocksCache(STsdb *pTsdb) { rocksdb_writebatch_t *writebatch = rocksdb_writebatch_create(); - TAOS_CHECK_GOTO(taosThreadMutexInit(&pTsdb->rCache.writeBatchMutex, NULL), &lino, _err6) ; + TAOS_CHECK_GOTO(taosThreadMutexInit(&pTsdb->rCache.writeBatchMutex, NULL), &lino, _err6); pTsdb->rCache.writebatch = writebatch; pTsdb->rCache.my_comparator = cmp; @@ -230,6 +230,9 @@ static int32_t tsdbOpenRocksCache(STsdb *pTsdb) { pTsdb->rCache.readoptions = readoptions; pTsdb->rCache.flushoptions = flushoptions; pTsdb->rCache.db = db; + pTsdb->rCache.sver = -1; + pTsdb->rCache.suid = -1; + pTsdb->rCache.uid = -1; pTsdb->rCache.pTSchema = NULL; TAOS_RETURN(code); @@ -1132,19 +1135,17 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray (void)taosThreadMutexLock(&pTsdb->lruMutex); for (int i = 0; i < num_keys; ++i) { - SLastUpdateCtx *updCtx = (SLastUpdateCtx *)taosArrayGet(updCtxArray, i); - - int8_t lflag = updCtx->lflag; - SRowKey *pRowKey = &updCtx->tsdbRowKey.key; - SColVal *pColVal = &updCtx->colVal; + SLastUpdateCtx *updCtx = &((SLastUpdateCtx *)TARRAY_DATA(updCtxArray))[i]; + int8_t lflag = updCtx->lflag; + SRowKey *pRowKey = &updCtx->tsdbRowKey.key; + SColVal *pColVal = &updCtx->colVal; if (lflag == LFLAG_LAST && !COL_VAL_IS_VALUE(pColVal)) { continue; } SLastKey *key = &(SLastKey){.lflag = lflag, .uid = uid, .cid = pColVal->cid}; - size_t klen = ROCKS_KEY_LEN; - LRUHandle *h = taosLRUCacheLookup(pCache, key, klen); + LRUHandle *h = taosLRUCacheLookup(pCache, key, ROCKS_KEY_LEN); if (h) { SLastCol *pLastCol = (SLastCol *)taosLRUCacheValue(pCache, h); if (pLastCol->cacheStatus != TSDB_LAST_CACHE_NO_CACHE) { @@ -1299,53 +1300,94 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray TAOS_RETURN(code); } +void tsdbCacheInvalidateSchema(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, int32_t sver) { + SRocksCache *pRCache = &pTsdb->rCache; + if (!pRCache->pTSchema || sver <= pTsdb->rCache.sver) return; + + if (suid > 0 && suid == pRCache->suid) { + pRCache->sver = -1; + pRCache->suid = -1; + } + if (suid == 0 && uid == pRCache->uid) { + pRCache->sver = -1; + pRCache->uid = -1; + } +} + +static int32_t tsdbUpdateSkm(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, int32_t sver) { + SRocksCache *pRCache = &pTsdb->rCache; + if (pRCache->pTSchema && sver == pRCache->sver) { + if (suid > 0 && suid == pRCache->suid) { + return 0; + } + if (suid == 0 && uid == pRCache->uid) { + return 0; + } + } + + pRCache->suid = suid; + pRCache->uid = uid; + pRCache->sver = sver; + tDestroyTSchema(pRCache->pTSchema); + return metaGetTbTSchemaEx(pTsdb->pVnode->pMeta, suid, uid, -1, &pRCache->pTSchema); +} + int32_t tsdbCacheRowFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, int64_t version, int32_t nRow, SRow **aRow) { int32_t code = 0, lino = 0; // 1. prepare last - TSDBROW lRow = {.type = TSDBROW_ROW_FMT, .pTSRow = aRow[nRow - 1], .version = version}; - + TSDBROW lRow = {.type = TSDBROW_ROW_FMT, .pTSRow = aRow[nRow - 1], .version = version}; STSchema *pTSchema = NULL; int32_t sver = TSDBROW_SVERSION(&lRow); SArray *ctxArray = NULL; SSHashObj *iColHash = NULL; - TAOS_CHECK_GOTO(metaGetTbTSchemaEx(pTsdb->pVnode->pMeta, suid, uid, sver, &pTSchema), &lino, _exit); + TAOS_CHECK_GOTO(tsdbUpdateSkm(pTsdb, suid, uid, sver), &lino, _exit); + pTSchema = pTsdb->rCache.pTSchema; TSDBROW tRow = {.type = TSDBROW_ROW_FMT, .version = version}; int32_t nCol = pTSchema->numOfCols; - ctxArray = taosArrayInit(nCol, sizeof(SLastUpdateCtx)); - iColHash = tSimpleHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT)); + ctxArray = taosArrayInit(nCol * 2, sizeof(SLastUpdateCtx)); + if (ctxArray == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _exit); + } // 1. prepare by lrow STsdbRowKey tsdbRowKey = {0}; tsdbRowGetKey(&lRow, &tsdbRowKey); STSDBRowIter iter = {0}; - code = tsdbRowIterOpen(&iter, &lRow, pTSchema); - if (code != TSDB_CODE_SUCCESS) { - tsdbError("vgId:%d, %s tsdbRowIterOpen failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, - tstrerror(code)); - TAOS_CHECK_GOTO(code, &lino, _exit); - } + TAOS_CHECK_GOTO(tsdbRowIterOpen(&iter, &lRow, pTSchema), &lino, _exit); + int32_t iCol = 0; for (SColVal *pColVal = tsdbRowIterNext(&iter); pColVal && iCol < nCol; pColVal = tsdbRowIterNext(&iter), iCol++) { SLastUpdateCtx updateCtx = {.lflag = LFLAG_LAST_ROW, .tsdbRowKey = tsdbRowKey, .colVal = *pColVal}; if (!taosArrayPush(ctxArray, &updateCtx)) { + tsdbRowClose(&iter); TAOS_CHECK_GOTO(terrno, &lino, _exit); } - if (!COL_VAL_IS_VALUE(pColVal)) { + if (COL_VAL_IS_VALUE(pColVal)) { + updateCtx.lflag = LFLAG_LAST; + if (!taosArrayPush(ctxArray, &updateCtx)) { + tsdbRowClose(&iter); + TAOS_CHECK_GOTO(terrno, &lino, _exit); + } + } else { + if (!iColHash) { + iColHash = tSimpleHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT)); + if (iColHash == NULL) { + tsdbRowClose(&iter); + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _exit); + } + } + if (tSimpleHashPut(iColHash, &iCol, sizeof(iCol), NULL, 0)) { + tsdbRowClose(&iter); TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _exit); } - continue; - } - updateCtx.lflag = LFLAG_LAST; - if (!taosArrayPush(ctxArray, &updateCtx)) { - TAOS_CHECK_GOTO(terrno, &lino, _exit); } } tsdbRowClose(&iter); @@ -1390,7 +1432,10 @@ int32_t tsdbCacheRowFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, int6 } _exit: - taosMemoryFreeClear(pTSchema); + if (code) { + tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, tstrerror(code)); + } + taosArrayDestroy(ctxArray); tSimpleHashCleanup(iColHash); diff --git a/source/libs/executor/inc/executorInt.h b/source/libs/executor/inc/executorInt.h index 572ff88be90..98d3fefada4 100644 --- a/source/libs/executor/inc/executorInt.h +++ b/source/libs/executor/inc/executorInt.h @@ -553,6 +553,7 @@ typedef struct SIntervalAggOperatorInfo { EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] STimeWindowAggSupp twAggSup; SArray* pPrevValues; // SArray used to keep the previous not null value for interpolation. + bool cleanGroupResInfo; struct SOperatorInfo* pOperator; // for limit optimization bool limited; @@ -831,8 +832,10 @@ void cleanupExprSupp(SExprSupp* pSup); void cleanupResultInfoInStream(SExecTaskInfo* pTaskInfo, void* pState, SExprSupp* pSup, SGroupResInfo* pGroupResInfo); -void cleanupResultInfo(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SDiskbasedBuf* pBuf, - SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap); +void cleanupResultInfoInHashMap(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SDiskbasedBuf* pBuf, + SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap); +void cleanupResultInfo(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SGroupResInfo* pGroupResInfo, + SAggSupporter *pAggSup, bool cleanHashmap); void cleanupResultInfoWithoutHash(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo); diff --git a/source/libs/executor/inc/operator.h b/source/libs/executor/inc/operator.h index 7dfc7080d65..b2035ecfde8 100644 --- a/source/libs/executor/inc/operator.h +++ b/source/libs/executor/inc/operator.h @@ -85,6 +85,8 @@ int32_t createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNo int32_t createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, STableListInfo* pTableList, SExecTaskInfo* pTaskInfo, SOperatorInfo** pInfo); +int32_t createTableSeqScanOperatorInfo(void* pReadHandle, SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo); + int32_t createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo, SOperatorInfo** pInfo); int32_t createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, STableListInfo* pTableListInfo, SNode* pTagCond, SNode*pTagIndexCond, SExecTaskInfo* pTaskInfo, SOperatorInfo** pInfo); diff --git a/source/libs/executor/src/aggregateoperator.c b/source/libs/executor/src/aggregateoperator.c index 91b435fbec3..829ca6da509 100644 --- a/source/libs/executor/src/aggregateoperator.c +++ b/source/libs/executor/src/aggregateoperator.c @@ -49,6 +49,7 @@ typedef struct SAggOperatorInfo { SSDataBlock* pNewGroupBlock; bool hasCountFunc; SOperatorInfo* pOperator; + bool cleanGroupResInfo; } SAggOperatorInfo; static void destroyAggOperatorInfo(void* param); @@ -121,6 +122,7 @@ int32_t createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode* pA pInfo->binfo.outputTsOrder = pAggNode->node.outputTsOrder; pInfo->hasCountFunc = pAggNode->hasCountLikeFunc; pInfo->pOperator = pOperator; + pInfo->cleanGroupResInfo = false; setOperatorInfo(pOperator, "TableAggregate", QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, !pAggNode->node.forceCreateNonBlockingOptr, OP_NOT_OPENED, pInfo, pTaskInfo); @@ -159,8 +161,8 @@ void destroyAggOperatorInfo(void* param) { cleanupBasicInfo(&pInfo->binfo); if (pInfo->pOperator) { - cleanupResultInfoWithoutHash(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, pInfo->aggSup.pResultBuf, - &pInfo->groupResInfo); + cleanupResultInfo(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, &pInfo->groupResInfo, &pInfo->aggSup, + pInfo->cleanGroupResInfo); pInfo->pOperator = NULL; } cleanupAggSup(&pInfo->aggSup); @@ -191,6 +193,7 @@ static bool nextGroupedResult(SOperatorInfo* pOperator) { int32_t order = pAggInfo->binfo.inputTsOrder; SSDataBlock* pBlock = pAggInfo->pNewGroupBlock; + pAggInfo->cleanGroupResInfo = false; if (pBlock) { pAggInfo->pNewGroupBlock = NULL; tSimpleHashClear(pAggInfo->aggSup.pResultRowHashTable); @@ -263,6 +266,7 @@ static bool nextGroupedResult(SOperatorInfo* pOperator) { code = initGroupedResultInfo(&pAggInfo->groupResInfo, pAggInfo->aggSup.pResultRowHashTable, 0); QUERY_CHECK_CODE(code, lino, _end); + pAggInfo->cleanGroupResInfo = true; _end: if (code != TSDB_CODE_SUCCESS) { @@ -627,7 +631,7 @@ void cleanupResultInfoInStream(SExecTaskInfo* pTaskInfo, void* pState, SExprSupp } } -void cleanupResultInfoWithoutHash(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SDiskbasedBuf* pBuf, +void cleanupResultInfoInGroupResInfo(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo) { int32_t numOfExprs = pSup->numOfExprs; int32_t* rowEntryOffset = pSup->rowEntryInfoOffset; @@ -663,7 +667,7 @@ void cleanupResultInfoWithoutHash(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SDi } } -void cleanupResultInfo(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SDiskbasedBuf* pBuf, +void cleanupResultInfoInHashMap(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap) { int32_t numOfExprs = pSup->numOfExprs; int32_t* rowEntryOffset = pSup->rowEntryInfoOffset; @@ -701,6 +705,14 @@ void cleanupResultInfo(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SDiskbasedBuf* } } +void cleanupResultInfo(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SGroupResInfo* pGroupResInfo, + SAggSupporter *pAggSup, bool cleanGroupResInfo) { + if (cleanGroupResInfo) { + cleanupResultInfoInGroupResInfo(pTaskInfo, pSup, pAggSup->pResultBuf, pGroupResInfo); + } else { + cleanupResultInfoInHashMap(pTaskInfo, pSup, pAggSup->pResultBuf, pGroupResInfo, pAggSup->pResultRowHashTable); + } +} void cleanupAggSup(SAggSupporter* pAggSup) { taosMemoryFreeClear(pAggSup->keyBuf); tSimpleHashCleanup(pAggSup->pResultRowHashTable); diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 9cf2a3ea176..e4db766a6a6 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -88,8 +88,8 @@ static void destroyGroupOperatorInfo(void* param) { cleanupExprSupp(&pInfo->scalarSup); if (pInfo->pOperator != NULL) { - cleanupResultInfo(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, pInfo->aggSup.pResultBuf, - &pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable); + cleanupResultInfo(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, &pInfo->groupResInfo, &pInfo->aggSup, + false); pInfo->pOperator = NULL; } @@ -1263,7 +1263,10 @@ static SSDataBlock* buildStreamPartitionResult(SOperatorInfo* pOperator) { QUERY_CHECK_CONDITION((hasRemainPartion(pInfo)), code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR); SPartitionDataInfo* pParInfo = (SPartitionDataInfo*)pInfo->parIte; blockDataCleanup(pDest); - int32_t rows = taosArrayGetSize(pParInfo->rowIds); + int32_t rows = taosArrayGetSize(pParInfo->rowIds); + code = blockDataEnsureCapacity(pDest, rows); + QUERY_CHECK_CODE(code, lino, _end); + SSDataBlock* pSrc = pInfo->pInputDataBlock; for (int32_t i = 0; i < rows; i++) { int32_t rowIndex = *(int32_t*)taosArrayGet(pParInfo->rowIds, i); diff --git a/source/libs/executor/src/streamtimewindowoperator.c b/source/libs/executor/src/streamtimewindowoperator.c index 67ec976ee94..a7f8934c036 100644 --- a/source/libs/executor/src/streamtimewindowoperator.c +++ b/source/libs/executor/src/streamtimewindowoperator.c @@ -474,8 +474,8 @@ void destroyStreamFinalIntervalOperatorInfo(void* param) { SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)param; cleanupBasicInfo(&pInfo->binfo); if (pInfo->pOperator) { - cleanupResultInfo(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, pInfo->aggSup.pResultBuf, - &pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable); + cleanupResultInfo(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, &pInfo->groupResInfo, &pInfo->aggSup, + false); pInfo->pOperator = NULL; } cleanupAggSup(&pInfo->aggSup); diff --git a/source/libs/executor/src/timesliceoperator.c b/source/libs/executor/src/timesliceoperator.c index 6803f40da41..88c16426541 100644 --- a/source/libs/executor/src/timesliceoperator.c +++ b/source/libs/executor/src/timesliceoperator.c @@ -42,7 +42,7 @@ typedef struct STimeSliceOperatorInfo { SRowKey prevKey; bool prevTsSet; uint64_t groupId; - SGroupKeys* pPrevGroupKey; + SArray* pPrevGroupKeys; SSDataBlock* pNextGroupRes; SSDataBlock* pRemainRes; // save block unfinished processing int32_t remainIndex; // the remaining index in the block to be processed @@ -288,6 +288,7 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp // output the result int32_t fillColIndex = 0; + int32_t groupKeyIndex = 0; bool hasInterp = true; for (int32_t j = 0; j < pExprSup->numOfExprs; ++j) { SExprInfo* pExprInfo = &pExprSup->pExprInfo[j]; @@ -320,7 +321,9 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp QUERY_CHECK_CODE(code, lino, _end); } else if (!isSelectGroupConstValueFunc(pExprInfo)) { // use stored group key - SGroupKeys* pkey = pSliceInfo->pPrevGroupKey; + SGroupKeys *pkey = taosArrayGet(pSliceInfo->pPrevGroupKeys, groupKeyIndex); + QUERY_CHECK_NULL(pkey, code, lino, _end, terrno); + groupKeyIndex++; if (pkey->isNull == false) { code = colDataSetVal(pDst, rows, pkey->pData, false); QUERY_CHECK_CODE(code, lino, _end); @@ -645,13 +648,20 @@ static int32_t initFillLinearInfo(STimeSliceOperatorInfo* pInfo, SSDataBlock* pB return code; } +static void destroyGroupKey(void* pKey) { + SGroupKeys* key = (SGroupKeys*)pKey; + if (key->pData != NULL) { + taosMemoryFreeClear(key->pData); + } +} + static int32_t initGroupKeyKeeper(STimeSliceOperatorInfo* pInfo, SExprSupp* pExprSup) { - if (pInfo->pPrevGroupKey != NULL) { + if (pInfo->pPrevGroupKeys != NULL) { return TSDB_CODE_SUCCESS; } - pInfo->pPrevGroupKey = taosMemoryCalloc(1, sizeof(SGroupKeys)); - if (pInfo->pPrevGroupKey == NULL) { + pInfo->pPrevGroupKeys = taosArrayInit(pExprSup->numOfExprs, sizeof(SGroupKeys)); + if (pInfo->pPrevGroupKeys == NULL) { return terrno; } @@ -659,11 +669,19 @@ static int32_t initGroupKeyKeeper(STimeSliceOperatorInfo* pInfo, SExprSupp* pExp SExprInfo* pExprInfo = &pExprSup->pExprInfo[i]; if (isGroupKeyFunc(pExprInfo)) { - pInfo->pPrevGroupKey->bytes = pExprInfo->base.resSchema.bytes; - pInfo->pPrevGroupKey->type = pExprInfo->base.resSchema.type; - pInfo->pPrevGroupKey->isNull = false; - pInfo->pPrevGroupKey->pData = taosMemoryCalloc(1, pInfo->pPrevGroupKey->bytes); - if (!pInfo->pPrevGroupKey->pData) { + SGroupKeys key = {.bytes = pExprInfo->base.resSchema.bytes, + .type = pExprInfo->base.resSchema.type, + .isNull = false, + .pData = taosMemoryCalloc(1, pExprInfo->base.resSchema.bytes)}; + if (!key.pData) { + taosArrayDestroyEx(pInfo->pPrevGroupKeys, destroyGroupKey); + pInfo->pPrevGroupKeys = NULL; + return terrno; + } + if (NULL == taosArrayPush(pInfo->pPrevGroupKeys, &key)) { + taosMemoryFree(key.pData); + taosArrayDestroyEx(pInfo->pPrevGroupKeys, destroyGroupKey); + pInfo->pPrevGroupKeys = NULL; return terrno; } } @@ -910,7 +928,7 @@ static void genInterpAfterDataBlock(STimeSliceOperatorInfo* pSliceInfo, SOperato SInterval* pInterval = &pSliceInfo->interval; if (pSliceInfo->fillType == TSDB_FILL_NEXT || pSliceInfo->fillType == TSDB_FILL_LINEAR || - pSliceInfo->pPrevGroupKey == NULL) { + pSliceInfo->pPrevGroupKeys == NULL) { return; } @@ -921,12 +939,18 @@ static void genInterpAfterDataBlock(STimeSliceOperatorInfo* pSliceInfo, SOperato } } -static void copyPrevGroupKey(SExprSupp* pExprSup, SGroupKeys* pGroupKey, SSDataBlock* pSrcBlock) { +static int32_t copyPrevGroupKey(SExprSupp* pExprSup, SArray * pGroupKeys, SSDataBlock* pSrcBlock) { + int32_t groupKeyIdx = 0; for (int32_t j = 0; j < pExprSup->numOfExprs; ++j) { SExprInfo* pExprInfo = &pExprSup->pExprInfo[j]; if (isGroupKeyFunc(pExprInfo)) { int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId; + SGroupKeys *pGroupKey = taosArrayGet(pGroupKeys, groupKeyIdx); + if (pGroupKey == NULL) { + return terrno; + } + groupKeyIdx++; SColumnInfoData* pSrc = taosArrayGet(pSrcBlock->pDataBlock, srcSlot); if (colDataIsNull_s(pSrc, 0)) { @@ -942,9 +966,9 @@ static void copyPrevGroupKey(SExprSupp* pExprSup, SGroupKeys* pGroupKey, SSDataB } pGroupKey->isNull = false; - break; } } + return TSDB_CODE_SUCCESS; } static void resetTimesliceInfo(STimeSliceOperatorInfo* pSliceInfo) { @@ -986,7 +1010,11 @@ static void doHandleTimeslice(SOperatorInfo* pOperator, SSDataBlock* pBlock) { T_LONG_JMP(pTaskInfo->env, code); } doTimesliceImpl(pOperator, pSliceInfo, pBlock, pTaskInfo, ignoreNull); - copyPrevGroupKey(&pOperator->exprSupp, pSliceInfo->pPrevGroupKey, pBlock); + code = copyPrevGroupKey(&pOperator->exprSupp, pSliceInfo->pPrevGroupKeys, pBlock); + if (code != TSDB_CODE_SUCCESS) { + qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code)); + T_LONG_JMP(pTaskInfo->env, code); + } } static int32_t doTimesliceNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) { @@ -1160,7 +1188,7 @@ int32_t createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyN pInfo->prevTsSet = false; pInfo->prevKey.ts = INT64_MIN; pInfo->groupId = 0; - pInfo->pPrevGroupKey = NULL; + pInfo->pPrevGroupKeys = NULL; pInfo->pNextGroupRes = NULL; pInfo->pRemainRes = NULL; pInfo->remainIndex = 0; @@ -1233,9 +1261,9 @@ void destroyTimeSliceOperatorInfo(void* param) { } taosArrayDestroy(pInfo->pLinearInfo); - if (pInfo->pPrevGroupKey) { - taosMemoryFree(pInfo->pPrevGroupKey->pData); - taosMemoryFree(pInfo->pPrevGroupKey); + if (pInfo->pPrevGroupKeys) { + taosArrayDestroyEx(pInfo->pPrevGroupKeys, destroyGroupKey); + pInfo->pPrevGroupKeys = NULL; } if (pInfo->hasPk && IS_VAR_DATA_TYPE(pInfo->pkCol.type)) { taosMemoryFreeClear(pInfo->prevKey.pks[0].pData); diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 8c5f6280349..667deee4c65 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -38,6 +38,7 @@ typedef struct SSessionAggOperatorInfo { int32_t tsSlotId; // primary timestamp slot id STimeWindowAggSupp twAggSup; SOperatorInfo* pOperator; + bool cleanGroupResInfo; } SSessionAggOperatorInfo; typedef struct SStateWindowOperatorInfo { @@ -52,6 +53,7 @@ typedef struct SStateWindowOperatorInfo { int32_t tsSlotId; // primary timestamp column slot id STimeWindowAggSupp twAggSup; SOperatorInfo* pOperator; + bool cleanGroupResInfo; } SStateWindowOperatorInfo; typedef enum SResultTsInterpType { @@ -943,6 +945,7 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) { int32_t scanFlag = MAIN_SCAN; int64_t st = taosGetTimestampUs(); + pInfo->cleanGroupResInfo = false; while (1) { SSDataBlock* pBlock = getNextBlockFromDownstream(pOperator, 0); if (pBlock == NULL) { @@ -965,6 +968,7 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) { code = initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, pInfo->binfo.outputTsOrder); QUERY_CHECK_CODE(code, lino, _end); + pInfo->cleanGroupResInfo = true; OPTR_SET_OPENED(pOperator); @@ -1092,6 +1096,7 @@ static int32_t openStateWindowAggOptr(SOperatorInfo* pOperator) { int64_t st = taosGetTimestampUs(); SOperatorInfo* downstream = pOperator->pDownstream[0]; + pInfo->cleanGroupResInfo = false; while (1) { SSDataBlock* pBlock = getNextBlockFromDownstream(pOperator, 0); if (pBlock == NULL) { @@ -1120,7 +1125,7 @@ static int32_t openStateWindowAggOptr(SOperatorInfo* pOperator) { pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0; code = initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, TSDB_ORDER_ASC); QUERY_CHECK_CODE(code, lino, _end); - + pInfo->cleanGroupResInfo = true; pOperator->status = OP_RES_TO_RETURN; _end: @@ -1230,8 +1235,8 @@ static void destroyStateWindowOperatorInfo(void* param) { cleanupBasicInfo(&pInfo->binfo); taosMemoryFreeClear(pInfo->stateKey.pData); if (pInfo->pOperator) { - cleanupResultInfoWithoutHash(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, pInfo->aggSup.pResultBuf, - &pInfo->groupResInfo); + cleanupResultInfo(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, &pInfo->groupResInfo, &pInfo->aggSup, + pInfo->cleanGroupResInfo); pInfo->pOperator = NULL; } @@ -1257,8 +1262,8 @@ void destroyIntervalOperatorInfo(void* param) { cleanupBasicInfo(&pInfo->binfo); if (pInfo->pOperator) { - cleanupResultInfoWithoutHash(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, pInfo->aggSup.pResultBuf, - &pInfo->groupResInfo); + cleanupResultInfo(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, &pInfo->groupResInfo, &pInfo->aggSup, + pInfo->cleanGroupResInfo); pInfo->pOperator = NULL; } @@ -1452,6 +1457,7 @@ int32_t createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPhysiNode } pInfo->pOperator = pOperator; + pInfo->cleanGroupResInfo = false; initResultRowInfo(&pInfo->binfo.resultRowInfo); setOperatorInfo(pOperator, "TimeIntervalAggOperator", QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL, true, OP_NOT_OPENED, pInfo, pTaskInfo); @@ -1573,6 +1579,7 @@ static int32_t doSessionWindowAggNext(SOperatorInfo* pOperator, SSDataBlock** pp SOptrBasicInfo* pBInfo = &pInfo->binfo; SExprSupp* pSup = &pOperator->exprSupp; + pInfo->cleanGroupResInfo = false; if (pOperator->status == OP_RES_TO_RETURN) { while (1) { doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); @@ -1628,6 +1635,7 @@ static int32_t doSessionWindowAggNext(SOperatorInfo* pOperator, SSDataBlock** pp code = initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, TSDB_ORDER_ASC); QUERY_CHECK_CODE(code, lino, _end); + pInfo->cleanGroupResInfo = true; code = blockDataEnsureCapacity(pBInfo->pRes, pOperator->resultInfo.capacity); QUERY_CHECK_CODE(code, lino, _end); @@ -1731,6 +1739,7 @@ int32_t createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWinodwPhy pInfo->tsSlotId = tsSlotId; pInfo->pOperator = pOperator; + pInfo->cleanGroupResInfo = false; setOperatorInfo(pOperator, "StateWindowOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE, true, OP_NOT_OPENED, pInfo, pTaskInfo); pOperator->fpSet = createOperatorFpSet(openStateWindowAggOptr, doStateWindowAggNext, NULL, destroyStateWindowOperatorInfo, @@ -1763,8 +1772,8 @@ void destroySWindowOperatorInfo(void* param) { cleanupBasicInfo(&pInfo->binfo); colDataDestroy(&pInfo->twAggSup.timeWindowData); if (pInfo->pOperator) { - cleanupResultInfoWithoutHash(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, pInfo->aggSup.pResultBuf, - &pInfo->groupResInfo); + cleanupResultInfo(pInfo->pOperator->pTaskInfo, &pInfo->pOperator->exprSupp, &pInfo->groupResInfo, &pInfo->aggSup, + pInfo->cleanGroupResInfo); pInfo->pOperator = NULL; } @@ -1835,6 +1844,7 @@ int32_t createSessionAggOperatorInfo(SOperatorInfo* downstream, SSessionWinodwPh QUERY_CHECK_CODE(code, lino, _error); pInfo->pOperator = pOperator; + pInfo->cleanGroupResInfo = false; setOperatorInfo(pOperator, "SessionWindowAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION, true, OP_NOT_OPENED, pInfo, pTaskInfo); pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doSessionWindowAggNext, NULL, destroySWindowOperatorInfo, diff --git a/source/libs/executor/test/CMakeLists.txt b/source/libs/executor/test/CMakeLists.txt index ebf7131aa5e..c75de23c32b 100644 --- a/source/libs/executor/test/CMakeLists.txt +++ b/source/libs/executor/test/CMakeLists.txt @@ -2,23 +2,22 @@ MESSAGE(STATUS "build parser unit test") # IF(NOT TD_DARWIN) -# # GoogleTest requires at least C++11 -# SET(CMAKE_CXX_STANDARD 11) -# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) -# -# ADD_EXECUTABLE(executorTest ${SOURCE_LIST}) -# TARGET_LINK_LIBRARIES( -# executorTest -# PRIVATE os util common transport gtest taos_static qcom executor function planner scalar nodes vnode -# ) -# -# TARGET_INCLUDE_DIRECTORIES( -# executorTest -# PUBLIC "${TD_SOURCE_DIR}/include/libs/executor/" -# PRIVATE "${TD_SOURCE_DIR}/source/libs/executor/inc" -# ) +# # GoogleTest requires at least C++11 +# SET(CMAKE_CXX_STANDARD 11) +# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) +# +# ADD_EXECUTABLE(executorTest ${SOURCE_LIST}) +# TARGET_LINK_LIBRARIES( +# executorTest +# PRIVATE os util common transport gtest taos_static qcom executor function planner scalar nodes vnode +# ) +# +# TARGET_INCLUDE_DIRECTORIES( +# executorTest +# PUBLIC "${TD_SOURCE_DIR}/include/libs/executor/" +# PRIVATE "${TD_SOURCE_DIR}/source/libs/executor/inc" +# ) # ENDIF () - SET(CMAKE_CXX_STANDARD 11) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) @@ -33,3 +32,15 @@ TARGET_INCLUDE_DIRECTORIES( PUBLIC "${TD_SOURCE_DIR}/include/common" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) + +ADD_EXECUTABLE(queryPlanTests queryPlanTests.cpp) +TARGET_LINK_LIBRARIES( + queryPlanTests + PRIVATE os util common executor gtest_main qcom function planner scalar nodes vnode +) + +TARGET_INCLUDE_DIRECTORIES( + queryPlanTests + PUBLIC "${TD_SOURCE_DIR}/include/common" + PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) diff --git a/source/libs/executor/test/queryPlanTests.cpp b/source/libs/executor/test/queryPlanTests.cpp new file mode 100755 index 00000000000..2b0c0e11188 --- /dev/null +++ b/source/libs/executor/test/queryPlanTests.cpp @@ -0,0 +1,3414 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include +#include + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wwrite-strings" +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wformat" +#include + + +#ifdef WINDOWS +#define TD_USE_WINSOCK +#endif + +#include "os.h" + +#include "executor.h" +#include "executorInt.h" +#include "function.h" +#include "operator.h" +#include "taos.h" +#include "tdatablock.h" +#include "tdef.h" +#include "tvariant.h" +#include "stub.h" +#include "querytask.h" +#include "functionMgt.h" +#include "ttime.h" +#include "scheduler.h" + +namespace { + +#define QPT_MAX_LOOP 100000 +#define QPT_MAX_LEVEL_SUBPLAN_NUM 10 +#define QPT_MAX_SUBPLAN_LEVEL 2 +#define QPT_MAX_SUBPLAN_GROUP 5 +#define QPT_MAX_WHEN_THEN_NUM 10 +#define QPT_MAX_NODE_LEVEL 5 +#define QPT_MAX_STRING_LEN 1048576 +#define QPT_MAX_FUNC_PARAM 5 +#define QPT_MAX_LOGIC_PARAM 5 +#define QPT_MAX_NODE_LIST_NUM 5 +#define QPT_DEFAULT_VNODE_NUM 5 +#define QPT_MAX_DS_SRC_NUM 10 +#define QPT_MAX_ORDER_BY_NUM 10 +#define QPT_MAX_COLUMN_NUM 6 //8192 + +#define QPT_QUERY_NODE_COL 10000 + +typedef enum { + QPT_NODE_COLUMN, + QPT_NODE_EXPR, + QPT_NODE_FUNCTION, + QPT_NODE_VALUE, + QPT_NODE_SUBPLAN, + QPT_NODE_MAX_VALUE +} QPT_NODE_TYPE; + +enum { + QPT_PLAN_PHYSIC = 1, + QPT_PLAN_SINK, + QPT_PLAN_SUBPLAN, + QPT_PLAN_PLAN +}; + +typedef SNode* (*planBuildFunc)(int32_t); + + +typedef struct { + ENodeType type; + void* param; +} SQPTNodeParam; + +typedef struct { + bool singlePhysiNode; + uint64_t queryId; + uint64_t taskId; + int32_t subplanMaxLevel; + int32_t subplanType[QPT_MAX_SUBPLAN_LEVEL]; + int32_t subplanIdx[QPT_MAX_SUBPLAN_LEVEL]; + int32_t physiNodeParamNum; + SQPTNodeParam* physicNodeParam; +} SQPTPlanParam; + +typedef struct { + uint8_t precision; + char dbName[TSDB_DB_NAME_LEN]; +} SQPTDbParam; + + +typedef struct { + int32_t vnodeNum; + int32_t vgId; + SEpSet epSet; +} SQPTVnodeParam; + +typedef struct { + int32_t type; + char name[TSDB_COL_NAME_LEN]; + int32_t dtype; + int32_t len; + int8_t inUse; + bool hasIndex; + bool isPrimTs; + bool isPk; + EColumnType colType; +} SQPTCol; + +typedef struct { + int64_t uid; + int64_t suid; + int8_t tblType; + int32_t colNum; + int32_t tagNum; + int16_t pkNum; + char tblName[TSDB_TABLE_NAME_LEN]; + char tblAlias[TSDB_TABLE_NAME_LEN]; + SNodeList* pColList; + SNodeList* pTagList; + SNodeList* pColTagList; +} SQPTTblParam; + + +typedef struct { + bool correctExpected; + uint64_t schedulerId; + char userName[TSDB_USER_LEN]; + SQPTPlanParam plan; + SQPTDbParam db; + SQPTVnodeParam vnode; + SQPTTblParam tbl; +} SQPTParam; + + +typedef struct { + SPhysiNode* pCurr; + int32_t childrenNum; + SPhysiNode* pChild; // current child + SPhysiNode* pLeftChild; + SPhysiNode* pRightChild; + EOrder currTsOrder; + int16_t nextBlockId; + int32_t primaryTsSlotId; + int32_t nextSubplanId; + SExecTaskInfo* pCurrTask; +} SQPTBuildPlanCtx; + +typedef struct { + int32_t nodeLevel; + bool fromTable; + bool onlyTag; + bool onlyCol; + int16_t inputBlockId; + SNodeList* pInputList; +} SQPTMakeNodeCtx; + +typedef struct { + int64_t startTsUs; + int32_t code; + int64_t succeedTimes; + int64_t failedTimes; +} SQPTExecResult; + +typedef struct { + int32_t loopIdx; + char caseName[128]; + SQPTParam param; + SQPTBuildPlanCtx buildCtx; + SQPTMakeNodeCtx makeCtx; + SQPTMakeNodeCtx makeCtxBak; + SQPTExecResult result; +} SQPTCtx; + +typedef struct { + bool printTestInfo; + bool printInputRow; + bool printResRow; + bool logHistory; + bool noKeepResRows; +} SQPTCtrl; + +typedef struct { + int32_t type; + int32_t classify; + char* name; + planBuildFunc buildFunc; +} SQPTPlan; + +SNode* qptCreateTagScanPhysiNode(int32_t nodeType); +SNode* qptCreateTableScanPhysiNode(int32_t nodeType); +SNode* qptCreateTableSeqScanPhysiNode(int32_t nodeType); +SNode* qptCreateTableMergeScanPhysiNode(int32_t nodeType); +SNode* qptCreateStreamScanPhysiNode(int32_t nodeType); +SNode* qptCreateSysTableScanPhysiNode(int32_t nodeType); +SNode* qptCreateBlockDistScanPhysiNode(int32_t nodeType); +SNode* qptCreateLastRowScanPhysiNode(int32_t nodeType); +SNode* qptCreateTableCountScanPhysiNode(int32_t nodeType); + +SNode* qptCreateProjectPhysiNode(int32_t nodeType); +SNode* qptCreateMergeJoinPhysiNode(int32_t nodeType); +SNode* qptCreateHashAggPhysiNode(int32_t nodeType); +SNode* qptCreateExchangePhysiNode(int32_t nodeType); +SNode* qptCreateMergePhysiNode(int32_t nodeType); +SNode* qptCreateSortPhysiNode(int32_t nodeType); +SNode* qptCreateGroupSortPhysiNode(int32_t nodeType); +SNode* qptCreateIntervalPhysiNode(int32_t nodeType); +SNode* qptCreateMergeIntervalPhysiNode(int32_t nodeType); +SNode* qptCreateMergeAlignedIntervalPhysiNode(int32_t nodeType); +SNode* qptCreateStreamIntervalPhysiNode(int32_t nodeType); +SNode* qptCreateStreamFinalIntervalPhysiNode(int32_t nodeType); +SNode* qptCreateStreamSemiIntervalPhysiNode(int32_t nodeType); +SNode* qptCreateStreamMidIntervalPhysiNode(int32_t nodeType); +SNode* qptCreateFillPhysiNode(int32_t nodeType); +SNode* qptCreateStreamFillPhysiNode(int32_t nodeType); +SNode* qptCreateSessionPhysiNode(int32_t nodeType); +SNode* qptCreateStreamSessionPhysiNode(int32_t nodeType); +SNode* qptCreateStreamSemiSessionPhysiNode(int32_t nodeType); +SNode* qptCreateStreamFinalSessionPhysiNode(int32_t nodeType); +SNode* qptCreateStateWindowPhysiNode(int32_t nodeType); +SNode* qptCreateStreamStatePhysiNode(int32_t nodeType); +SNode* qptCreatePartitionPhysiNode(int32_t nodeType); +SNode* qptCreateStreamPartitionPhysiNode(int32_t nodeType); +SNode* qptCreateIndefRowsFuncPhysiNode(int32_t nodeType); +SNode* qptCreateInterpFuncPhysiNode(int32_t nodeType); +SNode* qptCreateMergeEventPhysiNode(int32_t nodeType); +SNode* qptCreateStreamEventPhysiNode(int32_t nodeType); +SNode* qptCreateCountWindowPhysiNode(int32_t nodeType); +SNode* qptCreateStreamCountWindowPhysiNode(int32_t nodeType); +SNode* qptCreateHashJoinPhysiNode(int32_t nodeType); +SNode* qptCreateGroupCachePhysiNode(int32_t nodeType); +SNode* qptCreateDynQueryCtrlPhysiNode(int32_t nodeType); +SNode* qptCreateDataDispatchPhysiNode(int32_t nodeType); +SNode* qptCreateDataInsertPhysiNode(int32_t nodeType); +SNode* qptCreateDataQueryInsertPhysiNode(int32_t nodeType); +SNode* qptCreateDataDeletePhysiNode(int32_t nodeType); +SNode* qptCreatePhysicalPlanNode(int32_t nodeIdx); +void qptCreatePhysiNodesTree(SPhysiNode** ppRes, SPhysiNode* pParent, int32_t level); +SNode* qptCreateQueryPlanNode(int32_t nodeType); +SNode* qptCreateSubplanNode(int32_t nodeType); + + +SQPTPlan qptPlans[] = { + {QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN, QPT_PLAN_PHYSIC, "tagScan", qptCreateTagScanPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN, QPT_PLAN_PHYSIC, "tableScan", qptCreateTableScanPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN, QPT_PLAN_PHYSIC, "tableSeqScan", qptCreateTableSeqScanPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN, QPT_PLAN_PHYSIC, "tableMergeScan", qptCreateTableMergeScanPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, QPT_PLAN_PHYSIC, "streamScan", qptCreateStreamScanPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN, QPT_PLAN_PHYSIC, "sysTableScan", qptCreateSysTableScanPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN, QPT_PLAN_PHYSIC, "blockDistScan", qptCreateBlockDistScanPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN, QPT_PLAN_PHYSIC, "lastRowScan", qptCreateLastRowScanPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_PROJECT, QPT_PLAN_PHYSIC, "project", qptCreateProjectPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN, QPT_PLAN_PHYSIC, "mergeJoin", qptCreateMergeJoinPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, QPT_PLAN_PHYSIC, "hashAgg", qptCreateHashAggPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_EXCHANGE, QPT_PLAN_PHYSIC, "exchange", qptCreateExchangePhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_MERGE, QPT_PLAN_PHYSIC, "merge", qptCreateMergePhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_SORT, QPT_PLAN_PHYSIC, "sort", qptCreateSortPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT, QPT_PLAN_PHYSIC, "groupSort", qptCreateGroupSortPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL, QPT_PLAN_PHYSIC, "interval", qptCreateIntervalPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL, QPT_PLAN_PHYSIC, "mergeInterval", qptCreateMergeIntervalPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL, QPT_PLAN_PHYSIC, "mergeAlignedInterval", qptCreateMergeAlignedIntervalPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL, QPT_PLAN_PHYSIC, "streamInterval", qptCreateStreamIntervalPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL, QPT_PLAN_PHYSIC, "streamFinalInterval", qptCreateStreamFinalIntervalPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL, QPT_PLAN_PHYSIC, "streamSemiInterval", qptCreateStreamSemiIntervalPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_FILL, QPT_PLAN_PHYSIC, "fill", qptCreateFillPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL, QPT_PLAN_PHYSIC, "streamFill", qptCreateStreamFillPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION, QPT_PLAN_PHYSIC, "sessionWindow", qptCreateSessionPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION, QPT_PLAN_PHYSIC, "streamSession", qptCreateStreamSessionPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION, QPT_PLAN_PHYSIC, "streamSemiSession", qptCreateStreamSemiSessionPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION, QPT_PLAN_PHYSIC, "streamFinalSession", qptCreateStreamFinalSessionPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE, QPT_PLAN_PHYSIC, "stateWindow", qptCreateStateWindowPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE, QPT_PLAN_PHYSIC, "streamState", qptCreateStreamStatePhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_PARTITION, QPT_PLAN_PHYSIC, "partition", qptCreatePartitionPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION, QPT_PLAN_PHYSIC, "streamPartition", qptCreateStreamPartitionPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC, QPT_PLAN_PHYSIC, "indefRowsFunc", qptCreateIndefRowsFuncPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC, QPT_PLAN_PHYSIC, "interpFunc", qptCreateInterpFuncPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_DISPATCH, QPT_PLAN_SINK, "dataDispatch", qptCreateDataDispatchPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_INSERT, QPT_PLAN_SINK, "dataInseret", qptCreateDataInsertPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT, QPT_PLAN_SINK, "dataQueryInsert", qptCreateDataQueryInsertPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_DELETE, QPT_PLAN_SINK, "dataDelete", qptCreateDataDeletePhysiNode}, + {QUERY_NODE_PHYSICAL_SUBPLAN, QPT_PLAN_SUBPLAN, "subplan", qptCreateSubplanNode}, + {QUERY_NODE_PHYSICAL_PLAN, QPT_PLAN_PLAN, "plan", qptCreateQueryPlanNode}, + {QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN, QPT_PLAN_PHYSIC, "tableCountScan", qptCreateTableCountScanPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_MERGE_EVENT, QPT_PLAN_PHYSIC, "eventWindow", qptCreateMergeEventPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT, QPT_PLAN_PHYSIC, "streamEventWindow", qptCreateStreamEventPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_HASH_JOIN, QPT_PLAN_PHYSIC, "hashJoin", qptCreateHashJoinPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_GROUP_CACHE, QPT_PLAN_PHYSIC, "groupCache", qptCreateGroupCachePhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_DYN_QUERY_CTRL, QPT_PLAN_PHYSIC, "dynQueryCtrl", qptCreateDynQueryCtrlPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT, QPT_PLAN_PHYSIC, "countWindow", qptCreateCountWindowPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT, QPT_PLAN_PHYSIC, "streamCountWindow", qptCreateStreamCountWindowPhysiNode}, + {QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL, QPT_PLAN_PHYSIC, "streamMidInterval", qptCreateStreamMidIntervalPhysiNode} +}; + + +#define QPT_PHYSIC_NODE_NUM() (sizeof(qptPlans)/sizeof(qptPlans[0])) +#define QPT_RAND_BOOL_V ((taosRand() % 2) ? true : false) +#define QPT_RAND_ORDER_V (QPT_RAND_BOOL_V ? ORDER_ASC : ORDER_DESC) +#define QPT_RAND_INT_V (taosRand() * (QPT_RAND_BOOL_V ? 1 : -1)) +#define QPT_LOW_PROB() ((taosRand() % 11) == 0) +#define QPT_MID_PROB() ((taosRand() % 11) <= 1) +#define QPT_HIGH_PROB() ((taosRand() % 11) <= 7) + +#define QPT_CORRECT_HIGH_PROB() (qptCtx.param.correctExpected || QPT_HIGH_PROB()) +#define QPT_NCORRECT_LOW_PROB() (!qptCtx.param.correctExpected && QPT_LOW_PROB()) + +#define QPT_VALID_DESC(_desc) ((_desc) && (QUERY_NODE_DATABLOCK_DESC == nodeType(_desc))) + +SQPTCtx qptCtx = {0}; +SQPTCtrl qptCtrl = {1, 0, 0, 0, 0}; +bool qptErrorRerun = false; +bool qptInRerun = false; +int32_t qptSink[] = {QUERY_NODE_PHYSICAL_PLAN_DISPATCH, QUERY_NODE_PHYSICAL_PLAN_INSERT, QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT, QUERY_NODE_PHYSICAL_PLAN_DELETE}; + + +SNode* qptMakeExprNode(SNode** ppNode); +void qptMakeNodeList(QPT_NODE_TYPE nodeType, SNodeList** ppList); + +int32_t qptGetSpecificPlanIndex(int32_t type) { + int32_t planNum = sizeof(qptPlans) / sizeof(qptPlans[0]); + for (int32_t i = 0; i < planNum; ++i) { + if (qptPlans[i].type == type) { + return i; + } + } + + return -1; +} + +int32_t qptGetColumnRandLen(int32_t colType) { + switch (colType) { + case TSDB_DATA_TYPE_NULL: + case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_DOUBLE: + case TSDB_DATA_TYPE_UTINYINT: + case TSDB_DATA_TYPE_USMALLINT: + case TSDB_DATA_TYPE_UINT: + case TSDB_DATA_TYPE_UBIGINT: + return tDataTypes[colType].bytes; + case TSDB_DATA_TYPE_VARCHAR: + case TSDB_DATA_TYPE_GEOMETRY: + case TSDB_DATA_TYPE_JSON: + case TSDB_DATA_TYPE_VARBINARY: + case TSDB_DATA_TYPE_DECIMAL: + case TSDB_DATA_TYPE_BLOB: + case TSDB_DATA_TYPE_MEDIUMBLOB: + case TSDB_DATA_TYPE_NCHAR: + return taosRand() % TSDB_MAX_BINARY_LEN; + default: + assert(0); + break; + } + + return 0; +} + + +void qptInitSingleTableCol(SQPTCol* pCol, int32_t idx, EColumnType colType) { + if (COLUMN_TYPE_COLUMN == colType && 0 == idx) { + sprintf(pCol->name, "primts%d", idx); + pCol->dtype = TSDB_DATA_TYPE_TIMESTAMP; + pCol->len = qptGetColumnRandLen(pCol->dtype); + pCol->inUse = 0; + pCol->hasIndex = false; + pCol->isPrimTs = true; + pCol->isPk = false; + pCol->colType = colType; + + return; + } + + sprintf(pCol->name, "%s%d", COLUMN_TYPE_COLUMN == colType ? "col" : "tag", idx); + pCol->dtype = taosRand() % TSDB_DATA_TYPE_MAX; + pCol->len = qptGetColumnRandLen(pCol->dtype); + pCol->inUse = 0; + pCol->hasIndex = COLUMN_TYPE_COLUMN == colType ? false : QPT_RAND_BOOL_V; + pCol->isPrimTs = false; + pCol->isPk = COLUMN_TYPE_COLUMN == colType ? QPT_RAND_BOOL_V : false;; + pCol->colType = colType; +} + + +void qptPrintBeginInfo() { + if (!qptCtrl.printTestInfo) { + return; + } + + printf("\n%dth TEST [%s] START\n", qptCtx.loopIdx, qptCtx.caseName); + +/* + char inputStat[4] = {0}; + JT_PRINTF("\n%dth TEST [%s] START\nBasic Info:\n\t asc:%d\n\t filter:%d\n\t maxRows:left-%d right-%d\n\t " + "maxGrpRows:left-%d right-%d\n\t blkRows:%d\n\t colCond:%s\n\t joinType:%s\n\t " + "subType:%s\n\t inputStat:%s\n\t groupJoin:%s\n", jtCtx.loopIdx, caseName, jtCtx.asc, jtCtx.filter, jtCtx.leftMaxRows, jtCtx.rightMaxRows, + jtCtx.leftMaxGrpRows, jtCtx.rightMaxGrpRows, jtCtx.blkRows, jtColCondStr[jtCtx.colCond], jtJoinTypeStr[jtCtx.joinType], + jtSubTypeStr[jtCtx.subType], getInputStatStr(inputStat), jtCtx.grpJoin ? "true" : "false"); + + if (JOIN_STYPE_ASOF == jtCtx.subType) { + JT_PRINTF("\t asofOp:%s\n\t JLimit:%" PRId64 "\n", getAsofOpStr(), jtCtx.jLimit); + } else if (JOIN_STYPE_WIN == jtCtx.subType) { + JT_PRINTF("\t windowOffset:[%" PRId64 ", %" PRId64 "]\n\t JLimit:%" PRId64 "\n", jtCtx.winStartOffset, jtCtx.winEndOffset, jtCtx.jLimit); + } + + JT_PRINTF("Input Info:\n\t totalBlk:left-%d right-%d\n\t totalRows:left-%d right-%d\n\t " + "blkRowSize:%d\n\t inputCols:left-%s %s %s %s right-%s %s %s %s\n", + (int32_t)taosArrayGetSize(jtCtx.leftBlkList), (int32_t)taosArrayGetSize(jtCtx.rightBlkList), + jtCtx.leftTotalRows, jtCtx.rightTotalRows, + jtCtx.blkRowSize, tDataTypes[jtInputColType[0]].name, tDataTypes[jtInputColType[1]].name, + tDataTypes[jtInputColType[2]].name, tDataTypes[jtInputColType[3]].name, tDataTypes[jtInputColType[0]].name, + tDataTypes[jtInputColType[1]].name, tDataTypes[jtInputColType[2]].name, tDataTypes[jtInputColType[3]].name); + + if (jtCtx.colEqNum) { + JT_PRINTF("\t colEqNum:%d\n", jtCtx.colEqNum); + printColList("colEqList", false, jtCtx.colEqList, false, "="); + } + + if (jtCtx.colOnNum) { + JT_PRINTF("\t colOnNum:%d\n", jtCtx.colOnNum); + printColList("colOnList", false, jtCtx.colOnList, false, ">"); + } + + if (jtCtx.leftFilterNum) { + JT_PRINTF("\t leftFilterNum:%d\n", jtCtx.leftFilterNum); + printColList("leftFilterList", true, jtCtx.leftFilterColList, true, ">"); + } + + if (jtCtx.rightFilterNum) { + JT_PRINTF("\t rightFilterNum:%d\n", jtCtx.rightFilterNum); + printColList("rightFilterList", false, jtCtx.rightFilterColList, true, ">"); + } + + JT_PRINTF("\t resColSize:%d\n\t resColNum:%d\n\t resColList:", jtCtx.resColSize, jtCtx.resColNum); + for (int32_t i = 0; i < jtCtx.resColNum; ++i) { + int32_t s = jtCtx.resColInSlot[i]; + int32_t idx = s >= MAX_SLOT_NUM ? s - MAX_SLOT_NUM : s; + JT_PRINTF("%sc%d[%s]\t", s >= MAX_SLOT_NUM ? "r" : "l", s, tDataTypes[jtInputColType[idx]].name); + } + + if (jtCtrl.printInputRow) { + printInputData(); + } +*/ +} + +void qptPrintEndInfo() { + if (!qptCtrl.printTestInfo) { + return; + } + + printf("\n\t%dth TEST [%s] END, result - %s%s\n", qptCtx.loopIdx, qptCtx.caseName, + (0 == qptCtx.result.code) ? "succeed" : "failed with error:", + (0 == qptCtx.result.code) ? "" : tstrerror(qptCtx.result.code)); +} + +void qptPrintStatInfo() { + printf("\n\tAll %d times TEST [%s] END, result - succeed:%" PRId64 " failed:%" PRId64 "\n", qptCtx.loopIdx + 1, qptCtx.caseName, + qptCtx.result.succeedTimes, qptCtx.result.failedTimes); +} + + +bool qptGetDynamicOp() { + if (QPT_NCORRECT_LOW_PROB()) { + return QPT_RAND_BOOL_V; + } + + if (qptCtx.buildCtx.pChild) { + return qptCtx.buildCtx.pChild->dynamicOp; + } + + return QPT_RAND_BOOL_V; +} + +EOrder qptGetCurrTsOrder() { + return QPT_CORRECT_HIGH_PROB() ? qptCtx.buildCtx.currTsOrder : QPT_RAND_ORDER_V; +} + +void qptGetRandValue(uint8_t* pType, int32_t* pLen, void** ppVal) { + if (*pType == (uint8_t)-1 || QPT_NCORRECT_LOW_PROB()) { + int32_t typeMax = TSDB_DATA_TYPE_MAX; + if (QPT_NCORRECT_LOW_PROB()) { + typeMax++; + } + + *pType = taosRand() % typeMax; + } + + switch (*pType) { + case TSDB_DATA_TYPE_NULL: + *pLen = QPT_CORRECT_HIGH_PROB() ? 0 : taosRand(); + if (ppVal) { + *ppVal = NULL; + } + break; + case TSDB_DATA_TYPE_BOOL: + *pLen = QPT_CORRECT_HIGH_PROB() ? tDataTypes[*pType].bytes : taosRand(); + if (ppVal) { + *ppVal = taosMemoryMalloc(tDataTypes[*pType].bytes); + assert(*ppVal); + *(bool*)*ppVal = QPT_RAND_BOOL_V; + } + break; + case TSDB_DATA_TYPE_TINYINT: + *pLen = QPT_CORRECT_HIGH_PROB() ? tDataTypes[*pType].bytes : taosRand(); + if (ppVal) { + *ppVal = taosMemoryMalloc(tDataTypes[*pType].bytes); + assert(*ppVal); + *(int8_t*)*ppVal = taosRand(); + } + break; + case TSDB_DATA_TYPE_SMALLINT: + *pLen = QPT_CORRECT_HIGH_PROB() ? tDataTypes[*pType].bytes : taosRand(); + if (ppVal) { + *ppVal = taosMemoryMalloc(tDataTypes[*pType].bytes); + assert(*ppVal); + *(int16_t*)*ppVal = taosRand(); + } + break; + case TSDB_DATA_TYPE_INT: + *pLen = QPT_CORRECT_HIGH_PROB() ? tDataTypes[*pType].bytes : taosRand(); + if (ppVal) { + *ppVal = taosMemoryMalloc(tDataTypes[*pType].bytes); + assert(*ppVal); + *(int32_t*)*ppVal = taosRand(); + } + break; + case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_TIMESTAMP: + *pLen = QPT_CORRECT_HIGH_PROB() ? tDataTypes[*pType].bytes : taosRand(); + if (ppVal) { + *ppVal = taosMemoryMalloc(tDataTypes[*pType].bytes); + assert(*ppVal); + *(int64_t*)*ppVal = taosRand(); + } + break; + case TSDB_DATA_TYPE_FLOAT: + *pLen = QPT_CORRECT_HIGH_PROB() ? tDataTypes[*pType].bytes : taosRand(); + if (ppVal) { + *ppVal = taosMemoryMalloc(tDataTypes[*pType].bytes); + assert(*ppVal); + *(float*)*ppVal = taosRand(); + } + break; + case TSDB_DATA_TYPE_DOUBLE: + *pLen = QPT_CORRECT_HIGH_PROB() ? tDataTypes[*pType].bytes : taosRand(); + if (ppVal) { + *ppVal = taosMemoryMalloc(tDataTypes[*pType].bytes); + assert(*ppVal); + *(double*)*ppVal = taosRand(); + } + break; + case TSDB_DATA_TYPE_VARCHAR: + case TSDB_DATA_TYPE_GEOMETRY: + case TSDB_DATA_TYPE_JSON: + case TSDB_DATA_TYPE_VARBINARY: + case TSDB_DATA_TYPE_DECIMAL: + case TSDB_DATA_TYPE_BLOB: + case TSDB_DATA_TYPE_MEDIUMBLOB: + *pLen = taosRand() % QPT_MAX_STRING_LEN; + if (ppVal) { + *ppVal = taosMemoryCalloc(1, *pLen + VARSTR_HEADER_SIZE); + assert(*ppVal); + varDataSetLen(*ppVal, *pLen); + memset((char*)*ppVal + VARSTR_HEADER_SIZE, 'A' + taosRand() % 26, *pLen); + } + break; + case TSDB_DATA_TYPE_NCHAR: { + *pLen = taosRand() % QPT_MAX_STRING_LEN; + if (ppVal) { + char* pTmp = (char*)taosMemoryCalloc(1, *pLen + 1); + assert(pTmp); + memset(pTmp, 'A' + taosRand() % 26, *pLen); + *ppVal = taosMemoryCalloc(1, *pLen * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); + assert(*ppVal); + assert(taosMbsToUcs4(pTmp, *pLen, (TdUcs4 *)varDataVal(*ppVal), *pLen * TSDB_NCHAR_SIZE, NULL)); + *pLen *= TSDB_NCHAR_SIZE; + varDataSetLen(*ppVal, *pLen); + taosMemoryFree(pTmp); + } + break; + } + case TSDB_DATA_TYPE_UTINYINT: + *pLen = QPT_CORRECT_HIGH_PROB() ? tDataTypes[*pType].bytes : taosRand(); + if (ppVal) { + *ppVal = taosMemoryMalloc(tDataTypes[*pType].bytes); + assert(*ppVal); + *(uint8_t*)*ppVal = taosRand(); + } + break; + case TSDB_DATA_TYPE_USMALLINT: + *pLen = QPT_CORRECT_HIGH_PROB() ? tDataTypes[*pType].bytes : taosRand(); + if (ppVal) { + *ppVal = taosMemoryMalloc(tDataTypes[*pType].bytes); + assert(*ppVal); + *(uint16_t*)*ppVal = taosRand(); + } + break; + case TSDB_DATA_TYPE_UINT: + *pLen = QPT_CORRECT_HIGH_PROB() ? tDataTypes[*pType].bytes : taosRand(); + if (ppVal) { + *ppVal = taosMemoryMalloc(tDataTypes[*pType].bytes); + assert(*ppVal); + *(uint32_t*)*ppVal = taosRand(); + } + break; + case TSDB_DATA_TYPE_UBIGINT: + *pLen = QPT_CORRECT_HIGH_PROB() ? tDataTypes[*pType].bytes : taosRand(); + if (ppVal) { + *ppVal = taosMemoryMalloc(tDataTypes[*pType].bytes); + assert(*ppVal); + *(uint64_t*)*ppVal = taosRand(); + } + break; + default: + *pLen = taosRand() % QPT_MAX_STRING_LEN; + if (ppVal) { + *ppVal = taosMemoryCalloc(1, *pLen); + assert(*ppVal); + memset((char*)*ppVal, 'a' + taosRand() % 26, *pLen); + } + break; + } +} + +void qptFreeRandValue(int32_t* pType, void* pVal) { + switch (*pType) { + case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_DOUBLE: + case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_UTINYINT: + case TSDB_DATA_TYPE_USMALLINT: + case TSDB_DATA_TYPE_UINT: + case TSDB_DATA_TYPE_UBIGINT: + taosMemoryFree(pVal); + break; + case TSDB_DATA_TYPE_NULL: + case TSDB_DATA_TYPE_VARCHAR: + case TSDB_DATA_TYPE_GEOMETRY: + case TSDB_DATA_TYPE_NCHAR: + case TSDB_DATA_TYPE_JSON: + case TSDB_DATA_TYPE_VARBINARY: + case TSDB_DATA_TYPE_DECIMAL: + case TSDB_DATA_TYPE_BLOB: + case TSDB_DATA_TYPE_MEDIUMBLOB: + break; + default: + assert(0); + break; + } +} + +void qptGetRandRealTableType(int8_t* tableType) { + while (true) { + int8_t tType = taosRand() % TSDB_TABLE_MAX; + switch (tType) { + case TSDB_SUPER_TABLE: + case TSDB_CHILD_TABLE: + case TSDB_NORMAL_TABLE: + case TSDB_SYSTEM_TABLE: + *tableType = tType; + return; + default: + break; + } + } +} + +int32_t qptGetInputSlotId(SDataBlockDescNode* pInput) { + if (pInput && pInput->pSlots && pInput->pSlots->length > 0 && QPT_CORRECT_HIGH_PROB()) { + return taosRand() % pInput->pSlots->length; + } + + return taosRand(); +} + +ENullOrder qptGetRandNullOrder() { + if (QPT_NCORRECT_LOW_PROB()) { + return (ENullOrder)taosRand(); + } + + return (ENullOrder)(taosRand() % NULL_ORDER_LAST + 1); +} + +int8_t qptGetRandTimestampUnit() { + static int8_t units[] = {TIME_UNIT_NANOSECOND, TIME_UNIT_MICROSECOND, TIME_UNIT_MILLISECOND, TIME_UNIT_SECOND, + TIME_UNIT_MINUTE, TIME_UNIT_HOUR, TIME_UNIT_DAY, TIME_UNIT_WEEK, TIME_UNIT_MONTH, TIME_UNIT_YEAR}; + + return units[taosRand() % (sizeof(units) / sizeof(units[0]))]; +} + +int32_t qptGetInputPrimaryTsSlotId() { + if (QPT_CORRECT_HIGH_PROB()) { + return qptCtx.buildCtx.primaryTsSlotId; + } + + return taosRand() % QPT_MAX_COLUMN_NUM; +} + +int32_t qptGetRandSubplanMsgType() { + int32_t msgTypeList[] = {TDMT_VND_DELETE, TDMT_SCH_MERGE_QUERY, TDMT_SCH_QUERY, TDMT_VND_SUBMIT}; + + return QPT_CORRECT_HIGH_PROB() ? msgTypeList[taosRand() % (sizeof(msgTypeList)/sizeof(msgTypeList[0]))] : taosRand(); +} + +void qptNodesCalloc(int32_t num, int32_t size, void** pOut) { + void* p = taosMemoryCalloc(num, size); + assert(p); + *(char*)p = 0; + *pOut = (char*)p + 1; +} + +void qptNodesFree(void* pNode) { + void* p = (char*)pNode - 1; + taosMemoryFree(p); +} + +EFillMode qptGetRandFillMode() { + if (QPT_CORRECT_HIGH_PROB()) { + return (EFillMode)(taosRand() % FILL_MODE_NEXT + 1); + } + + return (EFillMode)(taosRand()); +} + + +void qptGetRandTimeWindow(STimeWindow* pWindow) { + if (QPT_CORRECT_HIGH_PROB()) { + pWindow->skey = taosRand(); + pWindow->ekey = pWindow->skey + taosRand(); + return; + } + + pWindow->skey = taosRand(); + pWindow->ekey = taosRand(); +} + +int32_t qptGetSubplanNum(SNodeList* pList) { + if (QPT_NCORRECT_LOW_PROB()) { + return taosRand(); + } + + int32_t subplanNum = 0; + SNode* pNode = NULL; + FOREACH(pNode, pList) { + if (NULL == pNode || QUERY_NODE_NODE_LIST != nodeType(pNode)) { + continue; + } + + SNodeListNode* pNodeListNode = (SNodeListNode*)pNode; + + if (NULL == pNodeListNode->pNodeList) { + continue; + } + + subplanNum += pNodeListNode->pNodeList->length; + } + + return subplanNum; +} + +int32_t qptNodesListAppend(SNodeList* pList, SNode* pNode) { + SListCell* p = NULL; + qptNodesCalloc(1, sizeof(SListCell), (void**)&p); + + p->pNode = pNode; + if (NULL == pList->pHead) { + pList->pHead = p; + } + if (NULL != pList->pTail) { + pList->pTail->pNext = p; + } + p->pPrev = pList->pTail; + pList->pTail = p; + ++(pList->length); + return TSDB_CODE_SUCCESS; +} + +int32_t qptNodesListStrictAppend(SNodeList* pList, SNode* pNode) { + int32_t code = qptNodesListAppend(pList, pNode); + if (TSDB_CODE_SUCCESS != code) { + nodesDestroyNode(pNode); + } + return code; +} + +int32_t qptNodesListMakeStrictAppend(SNodeList** pList, SNode* pNode) { + if (NULL == *pList) { + int32_t code = nodesMakeList(pList); + if (NULL == *pList) { + return code; + } + } + return qptNodesListStrictAppend(*pList, pNode); +} + +SNode* qptMakeRandNode(SNode** ppNode) { + SNode* pNode = NULL; + nodesMakeNode((ENodeType)taosRand(), ppNode ? ppNode : &pNode); + return ppNode ? *ppNode : pNode; +} + + + +SNode* qptMakeColumnFromTable(int32_t colIdx) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(NULL); + } + + if (colIdx < 0) { + return NULL; + } + + SColumnNode* pCol = NULL; + assert(0 == nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol)); + assert(pCol); + + SQPTCol fakeCol; + fakeCol.type = QPT_QUERY_NODE_COL; + qptInitSingleTableCol(&fakeCol, taosRand(), (EColumnType)(taosRand() % COLUMN_TYPE_GROUP_KEY + 1)); + + SQPTCol* pTbCol = qptCtx.makeCtx.pInputList ? (SQPTCol*)nodesListGetNode(qptCtx.makeCtx.pInputList, colIdx) : &fakeCol; + + int16_t blkId = QPT_CORRECT_HIGH_PROB() ? qptCtx.makeCtx.inputBlockId : taosRand(); + + if (QPT_CORRECT_HIGH_PROB()) { + pCol->node.resType.type = pTbCol->dtype; + pCol->node.resType.bytes = pTbCol->len; + + pCol->tableId = qptCtx.param.tbl.uid; + pCol->tableType = qptCtx.param.tbl.tblType; + pCol->colId = colIdx; + pCol->projIdx = colIdx; + pCol->colType = pTbCol->colType; + pCol->hasIndex = pTbCol->hasIndex; + pCol->isPrimTs = pTbCol->isPrimTs; + strcpy(pCol->dbName, qptCtx.param.db.dbName); + strcpy(pCol->tableName, qptCtx.param.tbl.tblName); + strcpy(pCol->tableAlias, qptCtx.param.tbl.tblAlias); + strcpy(pCol->colName, pTbCol->name); + pCol->dataBlockId = blkId; + pCol->slotId = colIdx; + pCol->numOfPKs = qptCtx.param.tbl.pkNum; + pCol->tableHasPk = qptCtx.param.tbl.pkNum > 0; + pCol->isPk = pTbCol->isPk; + pCol->projRefIdx = 0; + pCol->resIdx = 0; + } else { + qptGetRandValue(&pCol->node.resType.type, &pCol->node.resType.bytes, NULL); + + pCol->tableId = taosRand(); + pCol->tableType = taosRand() % TSDB_TABLE_MAX; + pCol->colId = QPT_RAND_BOOL_V ? taosRand() : colIdx; + pCol->projIdx = taosRand(); + pCol->colType = QPT_RAND_BOOL_V ? pTbCol->colType : (EColumnType)(taosRand() % (COLUMN_TYPE_GROUP_KEY + 1)); + pCol->hasIndex = QPT_RAND_BOOL_V; + pCol->isPrimTs = QPT_RAND_BOOL_V; + if (QPT_RAND_BOOL_V) { + pCol->dbName[0] = 0; + } else { + strcpy(pCol->dbName, qptCtx.param.db.dbName); + } + if (QPT_RAND_BOOL_V) { + pCol->tableName[0] = 0; + } else { + strcpy(pCol->tableName, qptCtx.param.tbl.tblName); + } + if (QPT_RAND_BOOL_V) { + pCol->tableAlias[0] = 0; + } else { + strcpy(pCol->tableAlias, qptCtx.param.tbl.tblAlias); + } + if (QPT_RAND_BOOL_V) { + pCol->colName[0] = 0; + } else { + strcpy(pCol->colName, pTbCol->name); + } + + pCol->dataBlockId = blkId; + pCol->slotId = QPT_RAND_BOOL_V ? taosRand() : colIdx; + pCol->numOfPKs = QPT_RAND_BOOL_V ? taosRand() : qptCtx.param.tbl.pkNum; + pCol->tableHasPk = QPT_RAND_BOOL_V ? QPT_RAND_BOOL_V : (qptCtx.param.tbl.pkNum > 0); + pCol->isPk = QPT_RAND_BOOL_V ? QPT_RAND_BOOL_V : pTbCol->isPk; + pCol->projRefIdx = taosRand(); + pCol->resIdx = taosRand(); + } + + return (SNode*)pCol; +} + + +SNode* qptMakeWhenThenNode(SNode** ppNode) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + assert(0 == nodesMakeNode(QUERY_NODE_WHEN_THEN, ppNode)); + assert(*ppNode); + SWhenThenNode* pWhenThen = (SWhenThenNode*)*ppNode; + + qptMakeExprNode(&pWhenThen->pWhen); + + qptMakeExprNode(&pWhenThen->pThen); + + return *ppNode; +} + + +SNode* qptMakeCaseWhenNode(SNode** ppNode) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + assert(0 == nodesMakeNode(QUERY_NODE_CASE_WHEN, ppNode)); + assert(*ppNode); + + SCaseWhenNode* pCaseWhen = (SCaseWhenNode*)*ppNode; + + qptCtx.makeCtx.nodeLevel++; + + if (QPT_RAND_BOOL_V) { + qptMakeExprNode(&pCaseWhen->pCase); + } + + if (QPT_RAND_BOOL_V) { + qptMakeExprNode(&pCaseWhen->pElse); + } + + int32_t whenNum = taosRand() % QPT_MAX_WHEN_THEN_NUM + (QPT_CORRECT_HIGH_PROB() ? 1 : 0); + for (int32_t i = 0; i < whenNum; ++i) { + SNode* pNode = NULL; + qptMakeWhenThenNode(&pNode); + qptNodesListMakeStrictAppend(&pCaseWhen->pWhenThenList, pNode); + } + + return *ppNode; +} + + +SNode* qptMakeOperatorNode(SNode** ppNode) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + EOperatorType opType = OPERATOR_ARRAY[taosRand() % (sizeof(OPERATOR_ARRAY)/sizeof(OPERATOR_ARRAY[0]))]; + assert(0 == nodesMakeNode(QUERY_NODE_OPERATOR, ppNode)); + + SOperatorNode* pOp = (SOperatorNode*)*ppNode; + pOp->opType = QPT_CORRECT_HIGH_PROB() ? opType : (EOperatorType)(opType + 1); + + qptCtx.makeCtx.nodeLevel++; + + switch (pOp->opType) { + case OP_TYPE_ADD: + case OP_TYPE_SUB: + case OP_TYPE_MULTI: + case OP_TYPE_DIV: + case OP_TYPE_REM: + case OP_TYPE_BIT_AND: + case OP_TYPE_BIT_OR: + case OP_TYPE_GREATER_THAN: + case OP_TYPE_GREATER_EQUAL: + case OP_TYPE_LOWER_THAN: + case OP_TYPE_LOWER_EQUAL: + case OP_TYPE_EQUAL: + case OP_TYPE_NOT_EQUAL: + case OP_TYPE_LIKE: + case OP_TYPE_NOT_LIKE: + case OP_TYPE_MATCH: + case OP_TYPE_NMATCH: + case OP_TYPE_IN: + case OP_TYPE_NOT_IN: + case OP_TYPE_JSON_GET_VALUE: + case OP_TYPE_JSON_CONTAINS: + case OP_TYPE_ASSIGN: + if (QPT_CORRECT_HIGH_PROB()) { + qptMakeExprNode(&pOp->pLeft); + qptMakeExprNode(&pOp->pRight); + } else { + if (QPT_RAND_BOOL_V) { + qptMakeExprNode(&pOp->pLeft); + } + if (QPT_RAND_BOOL_V) { + qptMakeExprNode(&pOp->pRight); + } + } + break; + + case OP_TYPE_IS_NULL: + case OP_TYPE_IS_NOT_NULL: + case OP_TYPE_IS_TRUE: + case OP_TYPE_IS_FALSE: + case OP_TYPE_IS_UNKNOWN: + case OP_TYPE_IS_NOT_TRUE: + case OP_TYPE_IS_NOT_FALSE: + case OP_TYPE_IS_NOT_UNKNOWN: + case OP_TYPE_MINUS: + if (QPT_CORRECT_HIGH_PROB()) { + qptMakeExprNode(&pOp->pLeft); + } else { + if (QPT_RAND_BOOL_V) { + qptMakeExprNode(&pOp->pLeft); + } + if (QPT_RAND_BOOL_V) { + qptMakeExprNode(&pOp->pRight); + } + } + break; + default: + if (QPT_RAND_BOOL_V) { + qptMakeExprNode(&pOp->pLeft); + } + if (QPT_RAND_BOOL_V) { + qptMakeExprNode(&pOp->pRight); + } + break; + } + + return *ppNode; +} + +SNode* qptMakeColumnNode(SNode** ppNode) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + SColumnNode* pCol = NULL; + + if (QPT_CORRECT_HIGH_PROB() && qptCtx.makeCtx.pInputList) { + SNodeList* pColList = qptCtx.makeCtx.pInputList; + int32_t colIdx = taosRand() % pColList->length; + SQPTCol* pNode = (SQPTCol*)nodesListGetNode(pColList, colIdx); + if (pNode) { + switch (pNode->type) { + case QUERY_NODE_SLOT_DESC: { + nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); + SSlotDescNode* pSlot = (SSlotDescNode*)pNode; + pCol->node.resType = pSlot->dataType; + pCol->dataBlockId = qptCtx.makeCtx.inputBlockId; + pCol->slotId = pSlot->slotId; + break; + } + case QPT_QUERY_NODE_COL: { + pCol = (SColumnNode*)qptMakeColumnFromTable(colIdx); + break; + } + default: + break; + } + } + } + + if (NULL == pCol) { + nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); + qptGetRandValue(&pCol->node.resType.type, &pCol->node.resType.bytes, NULL); + pCol->dataBlockId = taosRand(); + pCol->slotId = taosRand(); + } + + *ppNode = (SNode*)pCol; + + return *ppNode; +} + +void qptNodesSetValueNodeValue(SValueNode* pNode, void* value) { + switch (pNode->node.resType.type) { + case TSDB_DATA_TYPE_NULL: + taosMemoryFree(value); + break; + case TSDB_DATA_TYPE_BOOL: + pNode->datum.b = *(bool*)value; + taosMemoryFree(value); + *(bool*)&pNode->typeData = qptCtx.param.correctExpected ? pNode->datum.b : QPT_RAND_BOOL_V; + break; + case TSDB_DATA_TYPE_TINYINT: + pNode->datum.i = *(int8_t*)value; + taosMemoryFree(value); + *(int8_t*)&pNode->typeData = qptCtx.param.correctExpected ? pNode->datum.i : QPT_RAND_INT_V; + break; + case TSDB_DATA_TYPE_SMALLINT: + pNode->datum.i = *(int16_t*)value; + taosMemoryFree(value); + *(int16_t*)&pNode->typeData = qptCtx.param.correctExpected ? pNode->datum.i : QPT_RAND_INT_V; + break; + case TSDB_DATA_TYPE_INT: + pNode->datum.i = *(int32_t*)value; + taosMemoryFree(value); + *(int32_t*)&pNode->typeData = qptCtx.param.correctExpected ? pNode->datum.i : QPT_RAND_INT_V; + break; + case TSDB_DATA_TYPE_BIGINT: + pNode->datum.i = *(int64_t*)value; + taosMemoryFree(value); + *(int64_t*)&pNode->typeData = qptCtx.param.correctExpected ? pNode->datum.i : QPT_RAND_INT_V; + break; + case TSDB_DATA_TYPE_TIMESTAMP: + pNode->datum.i = *(int64_t*)value; + taosMemoryFree(value); + *(int64_t*)&pNode->typeData = qptCtx.param.correctExpected ? pNode->datum.i : QPT_RAND_INT_V; + break; + case TSDB_DATA_TYPE_UTINYINT: + pNode->datum.u = *(int8_t*)value; + taosMemoryFree(value); + *(int8_t*)&pNode->typeData = qptCtx.param.correctExpected ? pNode->datum.u : QPT_RAND_INT_V; + break; + case TSDB_DATA_TYPE_USMALLINT: + pNode->datum.u = *(int16_t*)value; + taosMemoryFree(value); + *(int16_t*)&pNode->typeData = qptCtx.param.correctExpected ? pNode->datum.u : QPT_RAND_INT_V; + break; + case TSDB_DATA_TYPE_UINT: + pNode->datum.u = *(int32_t*)value; + taosMemoryFree(value); + *(int32_t*)&pNode->typeData = qptCtx.param.correctExpected ? pNode->datum.u : QPT_RAND_INT_V; + break; + case TSDB_DATA_TYPE_UBIGINT: + pNode->datum.u = *(uint64_t*)value; + taosMemoryFree(value); + *(uint64_t*)&pNode->typeData = qptCtx.param.correctExpected ? pNode->datum.u : QPT_RAND_INT_V; + break; + case TSDB_DATA_TYPE_FLOAT: + pNode->datum.d = *(float*)value; + taosMemoryFree(value); + *(float*)&pNode->typeData = qptCtx.param.correctExpected ? pNode->datum.d : QPT_RAND_INT_V; + break; + case TSDB_DATA_TYPE_DOUBLE: + pNode->datum.d = *(double*)value; + taosMemoryFree(value); + *(double*)&pNode->typeData = qptCtx.param.correctExpected ? pNode->datum.d : QPT_RAND_INT_V; + break; + case TSDB_DATA_TYPE_NCHAR: + case TSDB_DATA_TYPE_VARCHAR: + case TSDB_DATA_TYPE_VARBINARY: + case TSDB_DATA_TYPE_JSON: + case TSDB_DATA_TYPE_GEOMETRY: + if (qptCtx.param.correctExpected || QPT_MID_PROB()) { + pNode->datum.p = (char*)value; + } else { + } + taosMemoryFree(value); + pNode->datum.p = NULL; + break; + case TSDB_DATA_TYPE_DECIMAL: + case TSDB_DATA_TYPE_BLOB: + case TSDB_DATA_TYPE_MEDIUMBLOB: + taosMemoryFree(value); + pNode->datum.p = NULL; + break; + default: + taosMemoryFree(value); + break; + } +} + + +SNode* qptMakeValueNode(uint8_t valType, SNode** ppNode) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + SValueNode* pVal = NULL; + nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal); + + int32_t valBytes; + void* pValue = NULL; + qptGetRandValue(&valType, &valBytes, &pValue); + + pVal->node.resType.type = valType; + pVal->node.resType.bytes = valBytes; + + qptNodesSetValueNodeValue(pVal, pValue); + + *ppNode = (SNode*)pVal; + + return *ppNode; +} + +SNode* qptMakeFunctionNode(SNode** ppNode) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + SFunctionNode* pFunc = NULL; + nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); + + if (QPT_CORRECT_HIGH_PROB()) { + int32_t funcIdx = taosRand() % funcMgtBuiltinsNum; + char* funcName = fmGetFuncName(funcIdx); + strcpy(pFunc->functionName, funcName); + taosMemoryFree(funcName); + fmGetFuncInfo(pFunc, NULL, 0); + } else { + int32_t funcIdx = taosRand(); + if (QPT_RAND_BOOL_V) { + strcpy(pFunc->functionName, "invalidFuncName"); + } else { + pFunc->functionName[0] = 0; + } + fmGetFuncInfo(pFunc, NULL, 0); + } + + qptCtx.makeCtx.nodeLevel++; + + if (QPT_CORRECT_HIGH_PROB()) { + // TODO + } else { + int32_t paramNum = taosRand() % QPT_MAX_FUNC_PARAM; + for (int32_t i = 0; i < paramNum; ++i) { + SNode* pNode = NULL; + qptMakeExprNode(&pNode); + qptNodesListMakeStrictAppend(&pFunc->pParameterList, pNode); + } + } + + *ppNode = (SNode*)pFunc; + + return *ppNode; +} + + + + +SNode* qptMakeLogicCondNode(SNode** ppNode) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + SLogicConditionNode* pLogic = NULL; + nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, (SNode**)&pLogic); + + if (QPT_CORRECT_HIGH_PROB()) { + pLogic->condType = (taosRand() % 3) ? ((taosRand() % 2) ? LOGIC_COND_TYPE_AND : LOGIC_COND_TYPE_OR) : LOGIC_COND_TYPE_NOT; + } else { + pLogic->condType = (ELogicConditionType)taosRand(); + } + + qptCtx.makeCtx.nodeLevel++; + + int32_t paramNum = QPT_CORRECT_HIGH_PROB() ? (taosRand() % QPT_MAX_LOGIC_PARAM + 1) : (taosRand() % QPT_MAX_LOGIC_PARAM); + for (int32_t i = 0; i < paramNum; ++i) { + SNode* pNode = NULL; + qptMakeExprNode(&pNode); + qptNodesListMakeStrictAppend(&pLogic->pParameterList, pNode); + } + + *ppNode = (SNode*)pLogic; + + return *ppNode; +} + +SNode* qptMakeNodeListNode(QPT_NODE_TYPE nodeType, SNode** ppNode) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + SNode* pTmp = NULL; + if (NULL == ppNode) { + ppNode = &pTmp; + } + + SNodeListNode* pList = NULL; + nodesMakeNode(QUERY_NODE_NODE_LIST, (SNode**)&pList); + + qptCtx.makeCtx.nodeLevel++; + + qptMakeNodeList(nodeType, &pList->pNodeList); + + *ppNode = (SNode*)pList; + + return *ppNode; +} + +SNode* qptMakeTempTableNode(SNode** ppNode) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + STempTableNode* pTemp = NULL; + assert(0 == nodesMakeNode(QUERY_NODE_TEMP_TABLE, (SNode**)&pTemp)); + + if (QPT_CORRECT_HIGH_PROB()) { + // TODO + } + + *ppNode = (SNode*)pTemp; + + return *ppNode; +} + +SNode* qptMakeJoinTableNode(SNode** ppNode) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + SJoinTableNode* pJoin = NULL; + assert(0 == nodesMakeNode(QUERY_NODE_JOIN_TABLE, (SNode**)&pJoin)); + + if (QPT_CORRECT_HIGH_PROB()) { + // TODO + } + + *ppNode = (SNode*)pJoin; + + return *ppNode; +} + +SNode* qptMakeRealTableNode(SNode** ppNode) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + SRealTableNode* pReal = NULL; + assert(0 == nodesMakeNode(QUERY_NODE_REAL_TABLE, (SNode**)&pReal)); + + if (QPT_CORRECT_HIGH_PROB()) { + // TODO + } + + *ppNode = (SNode*)pReal; + + return *ppNode; +} + + + +SNode* qptMakeNonRealTableNode(SNode** ppNode) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + if (QPT_CORRECT_HIGH_PROB()) { + if (QPT_RAND_BOOL_V) { + qptMakeTempTableNode(ppNode); + } else { + qptMakeJoinTableNode(ppNode); + } + } else { + qptMakeRealTableNode(ppNode); + } + + return *ppNode; +} + +SNode* qptMakeExprNode(SNode** ppNode) { + SNode* pNode = NULL; + if (NULL == ppNode) { + ppNode = &pNode; + } + + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + int32_t nodeTypeMaxValue = 9; + if (qptCtx.makeCtx.nodeLevel >= QPT_MAX_NODE_LEVEL) { + nodeTypeMaxValue = 2; + } + + switch (taosRand() % nodeTypeMaxValue) { + case 0: + qptMakeColumnNode(ppNode); + break; + case 1: + qptMakeValueNode(-1, ppNode); + break; + case 2: + qptMakeFunctionNode(ppNode); + break; + case 3: + qptMakeLogicCondNode(ppNode); + break; + case 4: + qptMakeNodeListNode(QPT_NODE_EXPR, ppNode); + break; + case 5: + qptMakeOperatorNode(ppNode); + break; + case 6: + qptMakeNonRealTableNode(ppNode); + break; + case 7: + qptMakeCaseWhenNode(ppNode); + break; + case 8: + qptMakeWhenThenNode(ppNode); + break; + default: + assert(0); + break; + } + + return *ppNode; +} + + +SNode* qptMakeLimitNode(SNode** ppNode) { + SNode* pNode = NULL; + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(&pNode); + } + + assert(0 == nodesMakeNode(QUERY_NODE_LIMIT, &pNode)); + assert(pNode); + + SLimitNode* pLimit = (SLimitNode*)pNode; + + if (!qptCtx.param.correctExpected) { + if (taosRand() % 2) { + pLimit->limit = taosRand() * ((taosRand() % 2) ? 1 : -1); + } + if (taosRand() % 2) { + pLimit->offset = taosRand() * ((taosRand() % 2) ? 1 : -1); + } + } else { + pLimit->limit = taosRand(); + if (taosRand() % 2) { + pLimit->offset = taosRand(); + } + } + + *ppNode = pNode; + + return pNode; +} + + +SNode* qptMakeWindowOffsetNode(SNode** ppNode) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + SNode* pNode = NULL; + assert(0 == nodesMakeNode(QUERY_NODE_WINDOW_OFFSET, &pNode)); + assert(pNode); + + SWindowOffsetNode* pWinOffset = (SWindowOffsetNode*)pNode; + qptMakeValueNode(TSDB_DATA_TYPE_BIGINT, &pWinOffset->pStartOffset); + qptMakeValueNode(TSDB_DATA_TYPE_BIGINT, &pWinOffset->pEndOffset); + + *ppNode = pNode; + + return pNode; +} + +void qptSaveMakeNodeCtx() { + qptCtx.makeCtxBak.nodeLevel = qptCtx.makeCtx.nodeLevel; +} + +void qptRestoreMakeNodeCtx() { + qptCtx.makeCtx.nodeLevel = qptCtx.makeCtxBak.nodeLevel; +} + + +void qptResetTableCols() { + SNode* pTmp = NULL; + FOREACH(pTmp, qptCtx.param.tbl.pColList) { + ((SQPTCol*)pTmp)->inUse = 0; + } + FOREACH(pTmp, qptCtx.param.tbl.pTagList) { + ((SQPTCol*)pTmp)->inUse = 0; + } +} + +void qptResetMakeNodeCtx() { + SQPTMakeNodeCtx* pCtx = &qptCtx.makeCtx; + pCtx->nodeLevel = 1; + + if (pCtx->fromTable) { + qptResetTableCols(); + } +} + +void qptInitMakeNodeCtx(bool fromTable, bool onlyTag, bool onlyCol, int16_t inputBlockId, SNodeList* pInputList) { + SQPTMakeNodeCtx* pCtx = &qptCtx.makeCtx; + + pCtx->onlyTag = onlyTag; + pCtx->fromTable = fromTable; + pCtx->onlyCol = onlyCol; + + if (NULL == pInputList) { + if (fromTable) { + inputBlockId = (qptCtx.buildCtx.pCurr && qptCtx.buildCtx.pCurr->pOutputDataBlockDesc) ? qptCtx.buildCtx.pCurr->pOutputDataBlockDesc->dataBlockId : taosRand(); + pInputList = onlyTag ? qptCtx.param.tbl.pTagList : (onlyCol ? qptCtx.param.tbl.pColList : qptCtx.param.tbl.pColTagList); + } else if (qptCtx.buildCtx.pChild && qptCtx.buildCtx.pChild->pOutputDataBlockDesc) { + inputBlockId = qptCtx.buildCtx.pChild->pOutputDataBlockDesc->dataBlockId; + pInputList = qptCtx.buildCtx.pChild->pOutputDataBlockDesc->pSlots; + } + } + + pCtx->inputBlockId = inputBlockId; + pCtx->pInputList = pInputList; + + qptResetMakeNodeCtx(); +} + +SNode* qptMakeConditionNode() { + SNode* pNode = NULL; + qptMakeExprNode(&pNode); + + return pNode; +} + + +SNode* qptMakeSlotDescNode(const char* pName, const SNode* pNode, int16_t slotId, bool output, bool reserve) { + SSlotDescNode* pSlot = NULL; + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode((SNode**)&pSlot); + } + + assert(0 == nodesMakeNode(QUERY_NODE_SLOT_DESC, (SNode**)&pSlot)); + + QPT_RAND_BOOL_V ? (pSlot->name[0] = 0) : snprintf(pSlot->name, sizeof(pSlot->name), "%s", pName); + pSlot->slotId = QPT_CORRECT_HIGH_PROB() ? slotId : taosRand(); + if (QPT_CORRECT_HIGH_PROB()) { + pSlot->dataType = ((SExprNode*)pNode)->resType; + } else { + qptGetRandValue(&pSlot->dataType.type, &pSlot->dataType.bytes, NULL); + } + + pSlot->reserve = reserve; + pSlot->output = output; + + return (SNode*)pSlot; +} + + +SNode* qptMakeDataBlockDescNode(bool forSink) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(NULL); + } + + SDataBlockDescNode* pDesc = NULL; + assert(0 == nodesMakeNode(QUERY_NODE_DATABLOCK_DESC, (SNode**)&pDesc)); + + pDesc->dataBlockId = QPT_CORRECT_HIGH_PROB() ? (forSink ? (qptCtx.buildCtx.nextBlockId - 1) : qptCtx.buildCtx.nextBlockId++) : QPT_RAND_INT_V; + pDesc->precision = QPT_CORRECT_HIGH_PROB() ? qptCtx.param.db.precision : QPT_RAND_INT_V; + + return (SNode*)pDesc; +} + +SNode* qptMakeDataBlockDescNodeFromNode(bool forSink) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(NULL); + } + + SDataBlockDescNode* pDesc = NULL; + SDataBlockDescNode* pInput = qptCtx.buildCtx.pCurr ? qptCtx.buildCtx.pCurr->pOutputDataBlockDesc : NULL; + SNode* pTmp = NULL, *pTmp2 = NULL; + + if (QPT_VALID_DESC(pInput)) { + if (QPT_CORRECT_HIGH_PROB()) { + nodesCloneNode((SNode*)pInput, (SNode**)&pDesc); + } else { + assert(0 == nodesMakeNode(QUERY_NODE_DATABLOCK_DESC, (SNode**)&pDesc)); + + pDesc->dataBlockId = QPT_CORRECT_HIGH_PROB() ? pInput->dataBlockId : QPT_RAND_INT_V; + pDesc->precision = QPT_CORRECT_HIGH_PROB() ? pInput->precision : QPT_RAND_INT_V; + pDesc->totalRowSize = QPT_CORRECT_HIGH_PROB() ? pInput->totalRowSize : QPT_RAND_INT_V; + pDesc->outputRowSize = QPT_CORRECT_HIGH_PROB() ? pInput->outputRowSize : QPT_RAND_INT_V; + + FOREACH(pTmp, pInput->pSlots) { + if (QPT_RAND_BOOL_V) { + nodesCloneNode(pTmp, &pTmp2); + qptNodesListMakeStrictAppend(&pDesc->pSlots, pTmp2); + } + } + } + } else { + assert(0 == nodesMakeNode(QUERY_NODE_DATABLOCK_DESC, (SNode**)&pDesc)); + + pDesc->dataBlockId = QPT_CORRECT_HIGH_PROB() ? (forSink ? (qptCtx.buildCtx.nextBlockId - 1) : qptCtx.buildCtx.nextBlockId++) : QPT_RAND_INT_V; + pDesc->precision = QPT_CORRECT_HIGH_PROB() ? qptCtx.param.db.precision : QPT_RAND_INT_V; + pDesc->totalRowSize = QPT_RAND_INT_V; + pDesc->outputRowSize = QPT_RAND_INT_V; + + int32_t slotNum = taosRand() % QPT_MAX_COLUMN_NUM; + for (int32_t i = 0; i < slotNum; ++i) { + pTmp2 = qptMakeExprNode(NULL); + if (QPT_CORRECT_HIGH_PROB()) { + pTmp = qptMakeSlotDescNode(NULL, pTmp2, i, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V); + nodesDestroyNode(pTmp2); + } else { + pTmp = pTmp2; + } + + qptNodesListMakeStrictAppend(&pDesc->pSlots, pTmp); + } + } + + return (SNode*)pDesc; +} + + + +SNode* qptMakeTargetNode(SNode* pNode, int16_t dataBlockId, int16_t slotId, SNode** pOutput) { + if (QPT_NCORRECT_LOW_PROB()) { + nodesDestroyNode(pNode); + return qptMakeRandNode(pOutput); + } + + STargetNode* pTarget = NULL; + assert(0 == nodesMakeNode(QUERY_NODE_TARGET, (SNode**)&pTarget)); + + pTarget->dataBlockId = QPT_CORRECT_HIGH_PROB() ? dataBlockId : taosRand(); + pTarget->slotId = QPT_CORRECT_HIGH_PROB() ? slotId : taosRand(); + pTarget->pExpr = QPT_CORRECT_HIGH_PROB() ? pNode : qptMakeRandNode(NULL); + if (pTarget->pExpr != pNode) { + nodesDestroyNode(pNode); + } + + *pOutput = (SNode*)pTarget; + + return *pOutput; +} + +SNode* qptMakeDownstreamSrcNode(SNode** ppNode) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + SDownstreamSourceNode* pDs = NULL; + nodesMakeNode(QUERY_NODE_DOWNSTREAM_SOURCE, (SNode**)&pDs); + + pDs->addr.nodeId = qptCtx.param.vnode.vgId; + memcpy(&pDs->addr.epSet, &qptCtx.param.vnode.epSet, sizeof(pDs->addr.epSet)); + pDs->taskId = (QPT_CORRECT_HIGH_PROB() && qptCtx.buildCtx.pCurrTask) ? qptCtx.buildCtx.pCurrTask->id.taskId : taosRand(); + pDs->schedId = QPT_CORRECT_HIGH_PROB() ? qptCtx.param.schedulerId : taosRand(); + pDs->execId = taosRand(); + pDs->fetchMsgType = QPT_CORRECT_HIGH_PROB() ? (QPT_RAND_BOOL_V ? TDMT_SCH_FETCH : TDMT_SCH_MERGE_FETCH) : taosRand(); + pDs->localExec = QPT_RAND_BOOL_V; + + *ppNode = (SNode*)pDs; + + return *ppNode; +} + +SNode* qptMakeOrderByExprNode(SNode** ppNode) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + SOrderByExprNode* pOrder = NULL; + nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR, (SNode**)&pOrder); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pOrder->pExpr); + + pOrder->order = (EOrder)(QPT_CORRECT_HIGH_PROB() ? (QPT_RAND_BOOL_V ? ORDER_ASC : ORDER_DESC) : taosRand()); + pOrder->nullOrder = qptGetRandNullOrder(); + + *ppNode = (SNode*)pOrder; + + return *ppNode; +} + +SNode* qptMakeSubplanNode(SNode** ppNode) { + if (QPT_NCORRECT_LOW_PROB()) { + return qptMakeRandNode(ppNode); + } + + *ppNode = (SNode*)qptCreateSubplanNode(QUERY_NODE_PHYSICAL_SUBPLAN); + + return *ppNode; +} + + + + +SPhysiNode* qptCreatePhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = NULL; + assert(0 == nodesMakeNode((ENodeType)nodeType, (SNode**)&pPhysiNode)); + assert(pPhysiNode); + + qptCtx.buildCtx.pCurr = pPhysiNode; + + qptMakeLimitNode(&pPhysiNode->pLimit); + qptMakeLimitNode(&pPhysiNode->pSlimit); + pPhysiNode->dynamicOp = qptGetDynamicOp(); + pPhysiNode->inputTsOrder = qptGetCurrTsOrder(); + + pPhysiNode->pOutputDataBlockDesc = (SDataBlockDescNode*)qptMakeDataBlockDescNode(false); + + return pPhysiNode; +} + +void qptPostCreatePhysiNode(SPhysiNode* pPhysiNode) { + pPhysiNode->outputTsOrder = qptGetCurrTsOrder(); + + if (QPT_RAND_BOOL_V) { + qptInitMakeNodeCtx((QPT_CORRECT_HIGH_PROB() && qptCtx.buildCtx.pChild) ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + pPhysiNode->pConditions = qptMakeConditionNode(); + } + +} + +void qptMarkTableInUseCols(int32_t colNum, int32_t totalColNum) { + if (colNum >= totalColNum) { + for (int32_t i = 0; i < totalColNum; ++i) { + SQPTCol* pNode = (SQPTCol*)nodesListGetNode(qptCtx.makeCtx.pInputList, i); + assert(pNode->type == QPT_QUERY_NODE_COL); + pNode->inUse = 1; + } + return; + } + + int32_t colInUse = 0; + do { + int32_t colIdx = taosRand() % totalColNum; + SQPTCol* pNode = (SQPTCol*)nodesListGetNode(qptCtx.makeCtx.pInputList, colIdx); + assert(pNode->type == QPT_QUERY_NODE_COL); + + if (pNode->inUse) { + continue; + } + + pNode->inUse = 1; + colInUse++; + } while (colInUse < colNum); +} + + +void qptMakeTableScanColList( SNodeList** ppCols) { + if (QPT_NCORRECT_LOW_PROB()) { + if (QPT_RAND_BOOL_V) { + nodesMakeList(ppCols); + } else { + *ppCols = NULL; + } + + return; + } + + int32_t colNum = (QPT_CORRECT_HIGH_PROB() && qptCtx.makeCtx.pInputList) ? (taosRand() % qptCtx.makeCtx.pInputList->length + 1) : (taosRand() % QPT_MAX_COLUMN_NUM); + int32_t colAdded = 0; + + if (qptCtx.makeCtx.pInputList) { + if (QPT_CORRECT_HIGH_PROB()) { + qptMarkTableInUseCols(colNum, qptCtx.makeCtx.pInputList->length); + + for (int32_t i = 0; colAdded < colNum; ++i) { + int32_t idx = (i < qptCtx.makeCtx.pInputList->length) ? i : (taosRand() % qptCtx.makeCtx.pInputList->length); + SQPTCol* pNode = (SQPTCol*)nodesListGetNode(qptCtx.makeCtx.pInputList, idx); + assert(pNode->type == QPT_QUERY_NODE_COL); + + if (0 == pNode->inUse) { + continue; + } + + assert(0 == qptNodesListMakeStrictAppend(ppCols, qptMakeColumnFromTable(idx))); + colAdded++; + } + + return; + } + + for (int32_t i = 0; i < colNum; ++i) { + int32_t colIdx = taosRand(); + colIdx = (colIdx >= qptCtx.makeCtx.pInputList->length) ? -1 : colIdx; + + assert(0 == qptNodesListMakeStrictAppend(ppCols, qptMakeColumnFromTable(colIdx))); + } + } else { + for (int32_t i = 0; i < colNum; ++i) { + int32_t colIdx = taosRand(); + assert(0 == qptNodesListMakeStrictAppend(ppCols, qptMakeColumnFromTable(colIdx))); + } + } +} + + +void qptCreateTableScanCols( int16_t blockId, SNodeList** ppList) { + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? true : false, QPT_CORRECT_HIGH_PROB() ? false : true, QPT_CORRECT_HIGH_PROB() ? true : false, 0, NULL); + qptMakeTableScanColList(ppList); +} + +void qptCreateTableScanPseudoCols( int16_t blockId, SNodeList** ppList) { + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? true : false, QPT_CORRECT_HIGH_PROB() ? true : false, QPT_CORRECT_HIGH_PROB() ? false : true, 0, NULL); + qptMakeTableScanColList(ppList); +} + + +void qptAddDataBlockSlots(SNodeList* pList, SDataBlockDescNode* pDataBlockDesc) { + if (NULL == pDataBlockDesc || QUERY_NODE_DATABLOCK_DESC != nodeType(pDataBlockDesc)) { + return; + } + + int16_t nextSlotId = LIST_LENGTH(pDataBlockDesc->pSlots), slotId = 0; + SNode* pNode = NULL; + bool output = QPT_RAND_BOOL_V; + + FOREACH(pNode, pList) { + if (NULL == pNode) { + continue; + } + + SNode* pExpr = QUERY_NODE_ORDER_BY_EXPR == nodeType(pNode) ? ((SOrderByExprNode*)pNode)->pExpr : pNode; + if (QPT_CORRECT_HIGH_PROB()) { + SNode* pDesc = QPT_CORRECT_HIGH_PROB() ? qptMakeSlotDescNode(NULL, pExpr, nextSlotId, output, QPT_RAND_BOOL_V) : qptMakeExprNode(NULL); + assert(0 == qptNodesListMakeStrictAppend(&pDataBlockDesc->pSlots, pDesc)); + pDataBlockDesc->totalRowSize += QPT_CORRECT_HIGH_PROB() ? ((SExprNode*)pExpr)->resType.bytes : taosRand(); + if (output && QPT_RAND_BOOL_V) { + pDataBlockDesc->outputRowSize += QPT_CORRECT_HIGH_PROB() ? ((SExprNode*)pExpr)->resType.bytes : taosRand(); + } + } + + slotId = nextSlotId; + ++nextSlotId; + + if (QPT_CORRECT_HIGH_PROB()) { + SNode* pTarget = NULL; + qptMakeTargetNode(pNode, pDataBlockDesc->dataBlockId, slotId, &pTarget); + REPLACE_NODE(pTarget); + } + } +} + +SNode* qptMakeSpecTypeNode(QPT_NODE_TYPE nodeType, SNode** ppNode) { + switch (nodeType) { + case QPT_NODE_COLUMN: + return qptMakeColumnNode(ppNode); + case QPT_NODE_FUNCTION: + return qptMakeFunctionNode(ppNode); + case QPT_NODE_EXPR: + return qptMakeExprNode(ppNode); + case QPT_NODE_VALUE: + return qptMakeValueNode(-1, ppNode); + default: + break; + } + + return qptMakeRandNode(ppNode); +} + + +void qptMakeRandNodeList(SNodeList** ppList) { + qptSaveMakeNodeCtx(); + + int32_t exprNum = taosRand() % QPT_MAX_COLUMN_NUM + (QPT_CORRECT_HIGH_PROB() ? 1 : 0); + for (int32_t i = 0; i < exprNum; ++i) { + SNode* pNode = NULL; + qptRestoreMakeNodeCtx(); + qptMakeSpecTypeNode((QPT_NODE_TYPE)(taosRand() % (QPT_NODE_MAX_VALUE + 1)), &pNode); + qptNodesListMakeStrictAppend(ppList, pNode); + } +} + + +void qptMakeExprList(SNodeList** ppList) { + qptSaveMakeNodeCtx(); + + int32_t exprNum = taosRand() % QPT_MAX_COLUMN_NUM + (QPT_CORRECT_HIGH_PROB() ? 1 : 0); + for (int32_t i = 0; i < exprNum; ++i) { + SNode* pNode = NULL; + qptRestoreMakeNodeCtx(); + qptMakeExprNode(&pNode); + qptNodesListMakeStrictAppend(ppList, pNode); + } +} + +void qptMakeValueList(SNodeList** ppList) { + qptSaveMakeNodeCtx(); + + int32_t colNum = taosRand() % QPT_MAX_COLUMN_NUM + (QPT_CORRECT_HIGH_PROB() ? 1 : 0); + for (int32_t i = 0; i < colNum; ++i) { + SNode* pNode = NULL; + qptRestoreMakeNodeCtx(); + qptMakeValueNode(-1, &pNode); + qptNodesListMakeStrictAppend(ppList, pNode); + } +} + +void qptMakeColumnList(SNodeList** ppList) { + qptSaveMakeNodeCtx(); + + int32_t colNum = taosRand() % QPT_MAX_COLUMN_NUM + (QPT_CORRECT_HIGH_PROB() ? 1 : 0); + for (int32_t i = 0; i < colNum; ++i) { + SNode* pNode = NULL; + qptRestoreMakeNodeCtx(); + qptMakeColumnNode(&pNode); + qptNodesListMakeStrictAppend(ppList, pNode); + } +} + +void qptMakeTargetList(QPT_NODE_TYPE nodeType, int16_t datablockId, SNodeList** ppList) { + qptSaveMakeNodeCtx(); + + int32_t tarNum = taosRand() % QPT_MAX_COLUMN_NUM + (QPT_CORRECT_HIGH_PROB() ? 1 : 0); + for (int32_t i = 0; i < tarNum; ++i) { + SNode* pNode = NULL, *pExpr = NULL; + qptRestoreMakeNodeCtx(); + qptMakeSpecTypeNode(nodeType, &pExpr); + qptMakeTargetNode(pExpr, datablockId, i, &pNode); + qptNodesListMakeStrictAppend(ppList, pNode); + } +} + +void qptMakeFunctionList(SNodeList** ppList) { + qptSaveMakeNodeCtx(); + + int32_t funcNum = taosRand() % QPT_MAX_COLUMN_NUM + (QPT_CORRECT_HIGH_PROB() ? 1 : 0); + for (int32_t i = 0; i < funcNum; ++i) { + SNode* pNode = NULL; + qptRestoreMakeNodeCtx(); + qptMakeFunctionNode(&pNode); + qptNodesListMakeStrictAppend(ppList, pNode); + } +} + + +void qptMakeDownstreamSrcList(SNodeList** ppList) { + qptSaveMakeNodeCtx(); + + int32_t dsNum = taosRand() % QPT_MAX_DS_SRC_NUM + (QPT_CORRECT_HIGH_PROB() ? 1 : 0); + for (int32_t i = 0; i < dsNum; ++i) { + SNode* pNode = NULL; + qptRestoreMakeNodeCtx(); + qptMakeDownstreamSrcNode(&pNode); + qptNodesListMakeStrictAppend(ppList, pNode); + } +} + + +void qptMakeOrerByExprList(SNodeList** ppList) { + qptSaveMakeNodeCtx(); + + int32_t orderNum = taosRand() % QPT_MAX_ORDER_BY_NUM + (QPT_CORRECT_HIGH_PROB() ? 1 : 0); + for (int32_t i = 0; i < orderNum; ++i) { + SNode* pNode = NULL; + qptRestoreMakeNodeCtx(); + qptMakeOrderByExprNode(&pNode); + qptNodesListMakeStrictAppend(ppList, pNode); + } +} + + +void qptMakeSubplanList(SNodeList** ppList) { + qptSaveMakeNodeCtx(); + + int32_t planNum = taosRand() % QPT_MAX_LEVEL_SUBPLAN_NUM + (QPT_CORRECT_HIGH_PROB() ? 1 : 0); + for (int32_t i = 0; i < planNum; ++i) { + SNode* pNode = NULL; + qptRestoreMakeNodeCtx(); + qptMakeSubplanNode(&pNode); + qptNodesListMakeStrictAppend(ppList, pNode); + } +} + +void qptMakeSpecTypeNodeList(QPT_NODE_TYPE nodeType, SNodeList** ppList) { + switch (nodeType) { + case QPT_NODE_COLUMN: + return qptMakeColumnList(ppList); + case QPT_NODE_FUNCTION: + return qptMakeFunctionList(ppList); + case QPT_NODE_EXPR: + return qptMakeExprList(ppList); + case QPT_NODE_VALUE: + return qptMakeValueList(ppList); + case QPT_NODE_SUBPLAN: + return qptMakeSubplanList(ppList); + default: + break; + } + + return qptMakeRandNodeList(ppList); +} + + +void qptMakeNodeList(QPT_NODE_TYPE nodeType, SNodeList** ppList) { + qptMakeSpecTypeNodeList(nodeType, ppList); +} + + + +void qptMakeAppendToTargetList(SNodeList* pInputList, int16_t blockId, SNodeList** ppOutList) { + SNode* pNode = NULL; + FOREACH(pNode, pInputList) { + if (QPT_CORRECT_HIGH_PROB()) { + SNode* pTarget = NULL; + int16_t slotId = ((*ppOutList) && (*ppOutList)->length) ? (*ppOutList)->length : 0; + qptMakeTargetNode(pNode, blockId, slotId, &pTarget); + qptNodesListMakeStrictAppend(ppOutList, pTarget); + } + } +} + +void qptCreateScanPhysiNodeImpl( SScanPhysiNode* pScan) { + SDataBlockDescNode* pDesc = pScan->node.pOutputDataBlockDesc; + int16_t blockId = (QPT_CORRECT_HIGH_PROB() && QPT_VALID_DESC(pDesc)) ? pDesc->dataBlockId : taosRand(); + qptCreateTableScanCols(blockId, &pScan->pScanCols); + + qptAddDataBlockSlots(pScan->pScanCols, pDesc); + + if (taosRand() % 2) { + blockId = (QPT_CORRECT_HIGH_PROB() && QPT_VALID_DESC(pDesc)) ? pDesc->dataBlockId : taosRand(); + qptCreateTableScanPseudoCols(blockId, &pScan->pScanPseudoCols); + } + + qptAddDataBlockSlots(pScan->pScanPseudoCols, pDesc); + + pScan->uid = QPT_CORRECT_HIGH_PROB() ? qptCtx.param.tbl.uid : taosRand(); + pScan->suid = QPT_CORRECT_HIGH_PROB() ? qptCtx.param.tbl.suid : taosRand(); + pScan->tableType = QPT_CORRECT_HIGH_PROB() ? qptCtx.param.tbl.tblType : taosRand(); + pScan->groupOrderScan = (taosRand() % 2) ? true : false; + + SName tblName = {0}; + toName(1, qptCtx.param.db.dbName, qptCtx.param.tbl.tblName, &tblName); + if (QPT_CORRECT_HIGH_PROB()) { + memcpy(&pScan->tableName, &tblName, sizeof(SName)); + } else { + pScan->tableName.acctId = 0; + pScan->tableName.dbname[0] = 0; + pScan->tableName.tname[0] = 0; + } + + qptCtx.buildCtx.currTsOrder = QPT_CORRECT_HIGH_PROB() ? qptCtx.buildCtx.currTsOrder : QPT_RAND_ORDER_V; +} + + + +SNode* qptCreateTagScanPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + STagScanPhysiNode* pTagScanNode = (STagScanPhysiNode*)pPhysiNode; + pTagScanNode->onlyMetaCtbIdx = (taosRand() % 2) ? true : false; + + qptCreateScanPhysiNodeImpl(&pTagScanNode->scan); + + qptPostCreatePhysiNode(pPhysiNode); + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateTableScanPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhysiNode; + pTableScanNode->scanSeq[0] = taosRand() % 4; + pTableScanNode->scanSeq[1] = taosRand() % 4; + pTableScanNode->scanRange.skey = taosRand(); + pTableScanNode->scanRange.ekey = taosRand(); + pTableScanNode->ratio = taosRand(); + pTableScanNode->dataRequired = taosRand(); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? true : false, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeFunctionList(&pTableScanNode->pDynamicScanFuncs); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? true : false, QPT_CORRECT_HIGH_PROB() ? true : false, QPT_CORRECT_HIGH_PROB() ? false : true, 0, NULL); + qptMakeColumnList(&pTableScanNode->pGroupTags); + + pTableScanNode->groupSort = QPT_RAND_BOOL_V; + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? true : false, QPT_CORRECT_HIGH_PROB() ? true : false, QPT_CORRECT_HIGH_PROB() ? false : true, 0, NULL); + qptMakeExprList(&pTableScanNode->pTags); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? true : false, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pTableScanNode->pSubtable); + pTableScanNode->interval = taosRand(); + pTableScanNode->offset = taosRand(); + pTableScanNode->sliding = taosRand(); + pTableScanNode->intervalUnit = taosRand(); + pTableScanNode->slidingUnit = taosRand(); + pTableScanNode->triggerType = taosRand(); + pTableScanNode->watermark = taosRand(); + pTableScanNode->igExpired = taosRand(); + pTableScanNode->assignBlockUid = QPT_RAND_BOOL_V; + pTableScanNode->igCheckUpdate = taosRand(); + pTableScanNode->filesetDelimited = QPT_RAND_BOOL_V; + pTableScanNode->needCountEmptyTable = QPT_RAND_BOOL_V; + pTableScanNode->paraTablesSort = QPT_RAND_BOOL_V; + pTableScanNode->smallDataTsSort = QPT_RAND_BOOL_V; + + qptCreateScanPhysiNodeImpl(&pTableScanNode->scan); + + qptPostCreatePhysiNode(pPhysiNode); + + return (SNode*)pPhysiNode; +} + + +SNode* qptCreateTableSeqScanPhysiNode(int32_t nodeType) { + return qptCreateTableScanPhysiNode(nodeType); +} + +SNode* qptCreateTableMergeScanPhysiNode(int32_t nodeType) { + return qptCreateTableScanPhysiNode(nodeType); +} + +SNode* qptCreateStreamScanPhysiNode(int32_t nodeType) { + return qptCreateTableScanPhysiNode(nodeType); +} + +SNode* qptCreateSysTableScanPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SSystemTableScanPhysiNode* pSysScanNode = (SSystemTableScanPhysiNode*)pPhysiNode; + + memcpy(&pSysScanNode->mgmtEpSet, &qptCtx.param.vnode.epSet, sizeof(pSysScanNode->mgmtEpSet)); + pSysScanNode->showRewrite = QPT_RAND_BOOL_V; + pSysScanNode->accountId = QPT_CORRECT_HIGH_PROB() ? 1 : taosRand(); + pSysScanNode->sysInfo = QPT_RAND_BOOL_V; + + qptCreateScanPhysiNodeImpl(&pSysScanNode->scan); + + qptPostCreatePhysiNode(pPhysiNode); + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateBlockDistScanPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SBlockDistScanPhysiNode* pBlkScanNode = (SBlockDistScanPhysiNode*)pPhysiNode; + + qptCreateScanPhysiNodeImpl((SScanPhysiNode*)pBlkScanNode); + + qptPostCreatePhysiNode(pPhysiNode); + + return (SNode*)pPhysiNode; +} + + +SNode* qptCreateLastRowScanPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SLastRowScanPhysiNode* pLRScanNode = (SLastRowScanPhysiNode*)pPhysiNode; + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? true : false, QPT_CORRECT_HIGH_PROB() ? true : false, QPT_CORRECT_HIGH_PROB() ? false : true, 0, NULL); + qptMakeColumnList(&pLRScanNode->pGroupTags); + + pLRScanNode->groupSort = QPT_RAND_BOOL_V; + pLRScanNode->ignoreNull = QPT_RAND_BOOL_V; + + if (QPT_CORRECT_HIGH_PROB()) { + int16_t blockId = (QPT_CORRECT_HIGH_PROB() && pPhysiNode->pOutputDataBlockDesc) ? pPhysiNode->pOutputDataBlockDesc->dataBlockId : taosRand(); + qptMakeAppendToTargetList(pLRScanNode->scan.pScanCols, blockId, &pLRScanNode->pTargets); + } + + if (QPT_CORRECT_HIGH_PROB()) { + int16_t blockId = (QPT_CORRECT_HIGH_PROB() && pPhysiNode->pOutputDataBlockDesc) ? pPhysiNode->pOutputDataBlockDesc->dataBlockId : taosRand(); + qptMakeAppendToTargetList(pLRScanNode->scan.pScanPseudoCols, blockId, &pLRScanNode->pTargets); + } + + if (QPT_RAND_BOOL_V) { + int32_t funcNum = taosRand() % QPT_MAX_COLUMN_NUM; + pLRScanNode->pFuncTypes = taosArrayInit(funcNum, sizeof(int32_t)); + assert(pLRScanNode->pFuncTypes); + for (int32_t i = 0; i < funcNum; ++i) { + int32_t funcType = taosRand(); + taosArrayPush(pLRScanNode->pFuncTypes, &funcType); + } + } + + qptCreateScanPhysiNodeImpl(&pLRScanNode->scan); + + qptPostCreatePhysiNode(pPhysiNode); + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateTableCountScanPhysiNode(int32_t nodeType) { + return qptCreateLastRowScanPhysiNode(nodeType); +} + + +SNode* qptCreateProjectPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SProjectPhysiNode* pProject = (SProjectPhysiNode*)pPhysiNode; + + pProject->mergeDataBlock = QPT_RAND_BOOL_V; + pProject->ignoreGroupId = QPT_RAND_BOOL_V; + pProject->inputIgnoreGroup = QPT_RAND_BOOL_V; + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprList(&pProject->pProjections); + + qptAddDataBlockSlots(pProject->pProjections, pProject->node.pOutputDataBlockDesc); + + qptPostCreatePhysiNode(pPhysiNode); + + return (SNode*)pPhysiNode; +} + + +SNode* qptCreateMergeJoinPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SSortMergeJoinPhysiNode* pJoin = (SSortMergeJoinPhysiNode*)pPhysiNode; + + pJoin->joinType = (EJoinType)(taosRand() % JOIN_TYPE_MAX_VALUE + (QPT_CORRECT_HIGH_PROB() ? 0 : 1)); + pJoin->subType = (EJoinSubType)(taosRand() % JOIN_STYPE_MAX_VALUE + (QPT_CORRECT_HIGH_PROB() ? 0 : 1)); + qptMakeWindowOffsetNode(&pJoin->pWindowOffset); + qptMakeLimitNode(&pJoin->pJLimit); + pJoin->asofOpType = OPERATOR_ARRAY[taosRand() % (sizeof(OPERATOR_ARRAY)/sizeof(OPERATOR_ARRAY[0]))] + (QPT_CORRECT_HIGH_PROB() ? 0 : 1); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pJoin->leftPrimExpr); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pJoin->rightPrimExpr); + + pJoin->leftPrimSlotId = qptGetInputSlotId(qptCtx.buildCtx.pChild ? qptCtx.buildCtx.pChild->pOutputDataBlockDesc : NULL); + pJoin->rightPrimSlotId = qptGetInputSlotId(qptCtx.buildCtx.pChild ? qptCtx.buildCtx.pChild->pOutputDataBlockDesc : NULL); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeColumnList(&pJoin->pEqLeft); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeColumnList(&pJoin->pEqRight); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pJoin->pPrimKeyCond); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pJoin->pColEqCond); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pJoin->pColOnCond); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pJoin->pFullOnCond); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + int16_t blockId = (QPT_CORRECT_HIGH_PROB() && pPhysiNode->pOutputDataBlockDesc) ? pPhysiNode->pOutputDataBlockDesc->dataBlockId : taosRand(); + qptMakeTargetList(QPT_NODE_EXPR, blockId, &pJoin->pTargets); + + for (int32_t i = 0; i < 2; i++) { + pJoin->inputStat[i].inputRowNum = taosRand(); + pJoin->inputStat[i].inputRowSize = taosRand(); + } + + pJoin->seqWinGroup = QPT_RAND_BOOL_V; + pJoin->grpJoin = QPT_RAND_BOOL_V; + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateHashAggPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SAggPhysiNode* pAgg = (SAggPhysiNode*)pPhysiNode; + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + int16_t blockId = (QPT_CORRECT_HIGH_PROB() && pPhysiNode->pOutputDataBlockDesc) ? pPhysiNode->pOutputDataBlockDesc->dataBlockId : taosRand(); + qptMakeTargetList(QPT_NODE_EXPR, blockId, &pAgg->pExprs); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + blockId = (QPT_CORRECT_HIGH_PROB() && pPhysiNode->pOutputDataBlockDesc) ? pPhysiNode->pOutputDataBlockDesc->dataBlockId : taosRand(); + qptMakeTargetList(QPT_NODE_EXPR, blockId, &pAgg->pGroupKeys); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + blockId = (QPT_CORRECT_HIGH_PROB() && pPhysiNode->pOutputDataBlockDesc) ? pPhysiNode->pOutputDataBlockDesc->dataBlockId : taosRand(); + qptMakeTargetList(QPT_NODE_FUNCTION, blockId, &pAgg->pAggFuncs); + + pAgg->mergeDataBlock = QPT_RAND_BOOL_V; + pAgg->groupKeyOptimized = QPT_RAND_BOOL_V; + pAgg->hasCountLikeFunc = QPT_RAND_BOOL_V; + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateExchangePhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SExchangePhysiNode* pExc = (SExchangePhysiNode*)pPhysiNode; + + pExc->srcStartGroupId = taosRand(); + pExc->srcEndGroupId = taosRand(); + pExc->singleChannel = QPT_RAND_BOOL_V; + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeDownstreamSrcList(&pExc->pSrcEndPoints); + + pExc->seqRecvData = QPT_RAND_BOOL_V; + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateMergePhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SMergePhysiNode* pMerge = (SMergePhysiNode*)pPhysiNode; + + pMerge->type = (EMergeType)(QPT_CORRECT_HIGH_PROB() ? (taosRand() % (MERGE_TYPE_MAX_VALUE - 1) + 1) : taosRand()); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeOrerByExprList(&pMerge->pMergeKeys); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + int16_t blockId = (QPT_CORRECT_HIGH_PROB() && pPhysiNode->pOutputDataBlockDesc) ? pPhysiNode->pOutputDataBlockDesc->dataBlockId : taosRand(); + qptMakeTargetList(QPT_NODE_EXPR, blockId, &pMerge->pTargets); + + pMerge->numOfChannels = taosRand(); + pMerge->numOfSubplans = taosRand(); + pMerge->srcGroupId = taosRand(); + pMerge->srcEndGroupId = taosRand(); + pMerge->groupSort = QPT_RAND_BOOL_V; + pMerge->ignoreGroupId = QPT_RAND_BOOL_V; + pMerge->inputWithGroupId = QPT_RAND_BOOL_V; + + return (SNode*)pPhysiNode; +} + + +SNode* qptCreateSortPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SSortPhysiNode* pSort = (SSortPhysiNode*)pPhysiNode; + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprList(&pSort->pExprs); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeOrerByExprList(&pSort->pSortKeys); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + int16_t blockId = (QPT_CORRECT_HIGH_PROB() && pPhysiNode->pOutputDataBlockDesc) ? pPhysiNode->pOutputDataBlockDesc->dataBlockId : taosRand(); + qptMakeTargetList(QPT_NODE_EXPR, blockId, &pSort->pTargets); + + pSort->calcGroupId = QPT_RAND_BOOL_V; + pSort->excludePkCol = QPT_RAND_BOOL_V; + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateGroupSortPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SGroupSortPhysiNode* pSort = (SGroupSortPhysiNode*)pPhysiNode; + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprList(&pSort->pExprs); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeOrerByExprList(&pSort->pSortKeys); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + int16_t blockId = (QPT_CORRECT_HIGH_PROB() && pPhysiNode->pOutputDataBlockDesc) ? pPhysiNode->pOutputDataBlockDesc->dataBlockId : taosRand(); + qptMakeTargetList(QPT_NODE_EXPR, blockId, &pSort->pTargets); + + pSort->calcGroupId = QPT_RAND_BOOL_V; + pSort->excludePkCol = QPT_RAND_BOOL_V; + + return (SNode*)pPhysiNode; +} + +void qptCreateWindowPhysiNode(SWindowPhysiNode* pWindow) { + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprList(&pWindow->pExprs); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeFunctionList(&pWindow->pFuncs); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeColumnNode(&pWindow->pTspk); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeColumnNode(&pWindow->pTsEnd); + + pWindow->triggerType = taosRand(); + pWindow->watermark = taosRand(); + pWindow->deleteMark = taosRand(); + pWindow->igExpired = taosRand(); + pWindow->destHasPrimayKey = taosRand(); + pWindow->mergeDataBlock = QPT_RAND_BOOL_V; +} + +SNode* qptCreateIntervalPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SIntervalPhysiNode* pInterval = (SIntervalPhysiNode*)pPhysiNode; + + qptCreateWindowPhysiNode(&pInterval->window); + + pInterval->interval = taosRand(); + pInterval->offset = taosRand(); + pInterval->sliding = taosRand(); + pInterval->intervalUnit = qptGetRandTimestampUnit(); + pInterval->slidingUnit = qptGetRandTimestampUnit(); + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateMergeIntervalPhysiNode(int32_t nodeType) { + return qptCreateIntervalPhysiNode(nodeType); +} + +SNode* qptCreateMergeAlignedIntervalPhysiNode(int32_t nodeType) { + return qptCreateIntervalPhysiNode(nodeType); +} + +SNode* qptCreateStreamIntervalPhysiNode(int32_t nodeType) { + return qptCreateIntervalPhysiNode(nodeType); +} + +SNode* qptCreateStreamFinalIntervalPhysiNode(int32_t nodeType) { + return qptCreateIntervalPhysiNode(nodeType); +} + +SNode* qptCreateStreamSemiIntervalPhysiNode(int32_t nodeType) { + return qptCreateIntervalPhysiNode(nodeType); +} + + +SNode* qptCreateStreamMidIntervalPhysiNode(int32_t nodeType) { + return qptCreateIntervalPhysiNode(nodeType); +} + + +SNode* qptCreateFillPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SFillPhysiNode* pFill = (SFillPhysiNode*)pPhysiNode; + + pFill->mode = qptGetRandFillMode(); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprList(&pFill->pFillExprs); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprList(&pFill->pNotFillExprs); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeColumnNode(&pFill->pWStartTs); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeNodeListNode(QPT_NODE_VALUE, &pFill->pValues); + + qptGetRandTimeWindow(&pFill->timeRange); + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateStreamFillPhysiNode(int32_t nodeType) { + return qptCreateFillPhysiNode(nodeType); +} + + +SNode* qptCreateSessionPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SSessionWinodwPhysiNode* pSession = (SSessionWinodwPhysiNode*)pPhysiNode; + + qptCreateWindowPhysiNode(&pSession->window); + + pSession->gap = taosRand(); + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateStreamSessionPhysiNode(int32_t nodeType) { + return qptCreateSessionPhysiNode(nodeType); +} + +SNode* qptCreateStreamSemiSessionPhysiNode(int32_t nodeType) { + return qptCreateSessionPhysiNode(nodeType); +} + +SNode* qptCreateStreamFinalSessionPhysiNode(int32_t nodeType) { + return qptCreateSessionPhysiNode(nodeType); +} + +SNode* qptCreateStateWindowPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SStateWinodwPhysiNode* pState = (SStateWinodwPhysiNode*)pPhysiNode; + + qptCreateWindowPhysiNode(&pState->window); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeColumnNode(&pState->pStateKey); + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateStreamStatePhysiNode(int32_t nodeType) { + return qptCreateStateWindowPhysiNode(nodeType); +} + +void qptCreatePartitionPhysiNodeImpl(SPartitionPhysiNode* pPartition) { + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprList(&pPartition->pExprs); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, pPartition->node.pOutputDataBlockDesc ? pPartition->node.pOutputDataBlockDesc->dataBlockId : taosRand(), pPartition->pExprs); + qptMakeColumnList(&pPartition->pPartitionKeys); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeColumnList(&pPartition->pPartitionKeys); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + int16_t blockId = (QPT_CORRECT_HIGH_PROB() && pPartition->node.pOutputDataBlockDesc) ? pPartition->node.pOutputDataBlockDesc->dataBlockId : taosRand(); + qptMakeTargetList(QPT_NODE_EXPR, blockId, &pPartition->pTargets); + + pPartition->needBlockOutputTsOrder = QPT_RAND_BOOL_V; + pPartition->tsSlotId = qptGetInputPrimaryTsSlotId(); +} + +SNode* qptCreatePartitionPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SPartitionPhysiNode* pPartition = (SPartitionPhysiNode*)pPhysiNode; + + qptCreatePartitionPhysiNodeImpl(pPartition); + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateStreamPartitionPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SStreamPartitionPhysiNode* pPartition = (SStreamPartitionPhysiNode*)pPhysiNode; + + qptCreatePartitionPhysiNodeImpl(&pPartition->part); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_CORRECT_HIGH_PROB() ? true : false, QPT_RAND_BOOL_V, 0, NULL); + qptMakeColumnList(&pPartition->pTags); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pPartition->pSubtable); + + return (SNode*)pPhysiNode; +} + + +SNode* qptCreateIndefRowsFuncPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SIndefRowsFuncPhysiNode* pFunc = (SIndefRowsFuncPhysiNode*)pPhysiNode; + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + int16_t blockId = (QPT_CORRECT_HIGH_PROB() && pPhysiNode->pOutputDataBlockDesc) ? pPhysiNode->pOutputDataBlockDesc->dataBlockId : taosRand(); + qptMakeTargetList(QPT_NODE_EXPR, blockId, &pFunc->pExprs); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + blockId = (QPT_CORRECT_HIGH_PROB() && pPhysiNode->pOutputDataBlockDesc) ? pPhysiNode->pOutputDataBlockDesc->dataBlockId : taosRand(); + qptMakeTargetList(QPT_NODE_FUNCTION, blockId, &pFunc->pFuncs); + + return (SNode*)pPhysiNode; +} + + +SNode* qptCreateInterpFuncPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SInterpFuncPhysiNode* pFunc = (SInterpFuncPhysiNode*)pPhysiNode; + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + int16_t blockId = (QPT_CORRECT_HIGH_PROB() && pPhysiNode->pOutputDataBlockDesc) ? pPhysiNode->pOutputDataBlockDesc->dataBlockId : taosRand(); + qptMakeTargetList(QPT_NODE_EXPR, blockId, &pFunc->pExprs); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + blockId = (QPT_CORRECT_HIGH_PROB() && pPhysiNode->pOutputDataBlockDesc) ? pPhysiNode->pOutputDataBlockDesc->dataBlockId : taosRand(); + qptMakeTargetList(QPT_NODE_FUNCTION, blockId, &pFunc->pFuncs); + + qptGetRandTimeWindow(&pFunc->timeRange); + + pFunc->interval = taosRand(); + pFunc->intervalUnit = qptGetRandTimestampUnit(); + + pFunc->fillMode = qptGetRandFillMode(); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeNodeListNode(QPT_NODE_VALUE, &pFunc->pFillValues); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeColumnNode(&pFunc->pTimeSeries); + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateMergeEventPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SEventWinodwPhysiNode* pEvent = (SEventWinodwPhysiNode*)pPhysiNode; + + qptCreateWindowPhysiNode(&pEvent->window); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pEvent->pStartCond); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pEvent->pEndCond); + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateStreamEventPhysiNode(int32_t nodeType) { + return qptCreateMergeEventPhysiNode(nodeType); +} + +SNode* qptCreateCountWindowPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SCountWinodwPhysiNode* pCount = (SCountWinodwPhysiNode*)pPhysiNode; + + qptCreateWindowPhysiNode(&pCount->window); + + pCount->windowCount = taosRand(); + pCount->windowSliding = taosRand(); + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateStreamCountWindowPhysiNode(int32_t nodeType) { + return qptCreateCountWindowPhysiNode(nodeType); +} + +SNode* qptCreateHashJoinPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SHashJoinPhysiNode* pJoin = (SHashJoinPhysiNode*)pPhysiNode; + + pJoin->joinType = (EJoinType)(taosRand() % JOIN_TYPE_MAX_VALUE + (QPT_CORRECT_HIGH_PROB() ? 0 : 1)); + pJoin->subType = (EJoinSubType)(taosRand() % JOIN_STYPE_MAX_VALUE + (QPT_CORRECT_HIGH_PROB() ? 0 : 1)); + qptMakeWindowOffsetNode(&pJoin->pWindowOffset); + qptMakeLimitNode(&pJoin->pJLimit); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeColumnList(&pJoin->pOnLeft); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeColumnList(&pJoin->pOnRight); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pJoin->leftPrimExpr); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pJoin->rightPrimExpr); + + pJoin->leftPrimSlotId = qptGetInputSlotId(qptCtx.buildCtx.pChild ? qptCtx.buildCtx.pChild->pOutputDataBlockDesc : NULL); + pJoin->rightPrimSlotId = qptGetInputSlotId(qptCtx.buildCtx.pChild ? qptCtx.buildCtx.pChild->pOutputDataBlockDesc : NULL); + + pJoin->timeRangeTarget = QPT_CORRECT_HIGH_PROB() ? (taosRand() % 3) : taosRand(); + qptGetRandTimeWindow(&pJoin->timeRange); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pJoin->pLeftOnCond); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pJoin->pRightOnCond); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pJoin->pFullOnCond); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + int16_t blockId = (QPT_CORRECT_HIGH_PROB() && pPhysiNode->pOutputDataBlockDesc) ? pPhysiNode->pOutputDataBlockDesc->dataBlockId : taosRand(); + qptMakeTargetList(QPT_NODE_EXPR, blockId, &pJoin->pTargets); + + for (int32_t i = 0; i < 2; i++) { + pJoin->inputStat[i].inputRowNum = taosRand(); + pJoin->inputStat[i].inputRowSize = taosRand(); + } + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pJoin->pPrimKeyCond); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pJoin->pColEqCond); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_CORRECT_HIGH_PROB() ? true : false, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pJoin->pTagEqCond); + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateGroupCachePhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SGroupCachePhysiNode* pGroup = (SGroupCachePhysiNode*)pPhysiNode; + + pGroup->grpColsMayBeNull = QPT_RAND_BOOL_V; + pGroup->grpByUid = QPT_RAND_BOOL_V; + pGroup->globalGrp = QPT_RAND_BOOL_V; + pGroup->batchFetch = QPT_RAND_BOOL_V; + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeColumnList(&pGroup->pGroupCols); + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateDynQueryCtrlPhysiNode(int32_t nodeType) { + SPhysiNode* pPhysiNode = qptCreatePhysiNode(nodeType); + + SDynQueryCtrlPhysiNode* pDyn = (SDynQueryCtrlPhysiNode*)pPhysiNode; + + pDyn->qType = QPT_CORRECT_HIGH_PROB() ? DYN_QTYPE_STB_HASH : (EDynQueryType)taosRand(); + + SStbJoinDynCtrlBasic* pJoin = &pDyn->stbJoin; + pJoin->batchFetch = QPT_RAND_BOOL_V; + pJoin->vgSlot[0] = taosRand(); + pJoin->vgSlot[1] = taosRand(); + pJoin->uidSlot[0] = taosRand(); + pJoin->uidSlot[1] = taosRand(); + pJoin->srcScan[0] = QPT_RAND_BOOL_V; + pJoin->srcScan[1] = QPT_RAND_BOOL_V; + + return (SNode*)pPhysiNode; +} + +SNode* qptCreateDataSinkNode(int32_t nodeType) { + SDataSinkNode* pSinkNode = NULL; + assert(0 == nodesMakeNode((ENodeType)nodeType, (SNode**)&pSinkNode)); + assert(pSinkNode); + + if (QPT_CORRECT_HIGH_PROB() && qptCtx.buildCtx.pCurr && qptCtx.buildCtx.pCurr->pOutputDataBlockDesc) { + pSinkNode->pInputDataBlockDesc = (SDataBlockDescNode*)qptMakeDataBlockDescNodeFromNode(true); + } else { + pSinkNode->pInputDataBlockDesc = (SDataBlockDescNode*)qptMakeDataBlockDescNode(true); + } + + return (SNode*)pSinkNode; +} + +SNode* qptCreateDataDispatchPhysiNode(int32_t nodeType) { + return (SNode*)qptCreateDataSinkNode(nodeType); +} + +SNode* qptCreateDataInsertPhysiNode(int32_t nodeType) { + SDataInserterNode* pInserter = (SDataInserterNode*)qptCreateDataSinkNode(nodeType); + + pInserter->numOfTables = taosRand(); + pInserter->size = taosRand(); + pInserter->pData = QPT_RAND_BOOL_V ? taosMemoryMalloc(1) : NULL; + + return (SNode*)pInserter; +} + +SNode* qptCreateDataQueryInsertPhysiNode(int32_t nodeType) { + SQueryInserterNode* pInserter = (SQueryInserterNode*)qptCreateDataSinkNode(nodeType); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptMakeColumnList(&pInserter->pCols); + + pInserter->tableId = QPT_CORRECT_HIGH_PROB() ? qptCtx.param.tbl.uid : taosRand(); + pInserter->stableId = QPT_CORRECT_HIGH_PROB() ? qptCtx.param.tbl.suid : taosRand(); + pInserter->tableType = QPT_CORRECT_HIGH_PROB() ? (QPT_RAND_BOOL_V ? TSDB_CHILD_TABLE : TSDB_NORMAL_TABLE) : (taosRand() % TSDB_TABLE_MAX); + if (QPT_CORRECT_HIGH_PROB()) { + strcpy(pInserter->tableName, qptCtx.param.tbl.tblName); + } else { + pInserter->tableName[0] = QPT_RAND_BOOL_V ? 'a' : 0; + } + pInserter->vgId = qptCtx.param.vnode.vgId; + memcpy(&pInserter->epSet, &qptCtx.param.vnode.epSet, sizeof(pInserter->epSet)); + pInserter->explain = QPT_RAND_BOOL_V; + + return (SNode*)pInserter; +} + + +SNode* qptCreateDataDeletePhysiNode(int32_t nodeType) { + SDataDeleterNode* pDeleter = (SDataDeleterNode*)qptCreateDataSinkNode(nodeType); + + pDeleter->tableId = QPT_CORRECT_HIGH_PROB() ? qptCtx.param.tbl.uid : taosRand(); + pDeleter->tableType = QPT_CORRECT_HIGH_PROB() ? (QPT_RAND_BOOL_V ? TSDB_CHILD_TABLE : TSDB_NORMAL_TABLE) : (taosRand() % TSDB_TABLE_MAX); + if (QPT_CORRECT_HIGH_PROB()) { + sprintf(pDeleter->tableFName, "1.%s.%s", qptCtx.param.db.dbName, qptCtx.param.tbl.tblName); + } else { + pDeleter->tableFName[0] = QPT_RAND_BOOL_V ? 'a' : 0; + } + + SQPTCol* pCol = (SQPTCol*)nodesListGetNode(qptCtx.param.tbl.pColList, 0); + if (QPT_CORRECT_HIGH_PROB() && pCol) { + strcpy(pDeleter->tsColName, pCol->name); + } else { + pDeleter->tsColName[0] = QPT_RAND_BOOL_V ? 't' : 0; + } + + qptGetRandTimeWindow(&pDeleter->deleteTimeRange); + + return (SNode*)pDeleter; +} + +void qptBuildSinkIdx(int32_t* pSinkIdx) { + +} + +void qptCreateSubplanDataSink(SDataSinkNode** ppOutput) { + static int32_t sinkIdx[sizeof(qptSink) / sizeof(qptSink[0])] = {-1}; + int32_t nodeIdx = 0; + + if (sinkIdx[0] < 0) { + qptBuildSinkIdx(sinkIdx); + } + + nodeIdx = taosRand() % (sizeof(sinkIdx)/sizeof(sinkIdx[0])); + + *ppOutput = (SDataSinkNode*)qptCreatePhysicalPlanNode(nodeIdx); +} + + +SNode* qptCreateSubplanNode(int32_t nodeType) { + SSubplan* pSubplan = NULL; + assert(0 == nodesMakeNode((ENodeType)nodeType, (SNode**)&pSubplan)); + + pSubplan->id.queryId = qptCtx.param.plan.queryId; + pSubplan->id.groupId = taosRand() % QPT_MAX_SUBPLAN_GROUP; + pSubplan->id.subplanId = qptCtx.buildCtx.nextSubplanId++; + + pSubplan->subplanType = QPT_CORRECT_HIGH_PROB() ? (ESubplanType)(taosRand() % SUBPLAN_TYPE_COMPUTE + 1) : (ESubplanType)taosRand(); + pSubplan->msgType = qptGetRandSubplanMsgType(); + pSubplan->level = taosRand() % QPT_MAX_SUBPLAN_LEVEL; + sprintf(pSubplan->dbFName, "1.%s", qptCtx.param.db.dbName); + strcpy(pSubplan->user, qptCtx.param.userName); + pSubplan->execNode.nodeId = qptCtx.param.vnode.vgId; + memcpy(&pSubplan->execNode.epSet, &qptCtx.param.vnode.epSet, sizeof(pSubplan->execNode.epSet)); + pSubplan->execNodeStat.tableNum = taosRand(); + + qptCreatePhysiNodesTree(&pSubplan->pNode, NULL, 0); + + qptCreateSubplanDataSink(&pSubplan->pDataSink); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_CORRECT_HIGH_PROB() ? true : false, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pSubplan->pTagCond); + + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_CORRECT_HIGH_PROB() ? true : false, QPT_RAND_BOOL_V, 0, NULL); + qptMakeExprNode(&pSubplan->pTagIndexCond); + + pSubplan->showRewrite = QPT_RAND_BOOL_V; + pSubplan->isView = QPT_RAND_BOOL_V; + pSubplan->isAudit = QPT_RAND_BOOL_V; + pSubplan->dynamicRowThreshold = QPT_RAND_BOOL_V; + pSubplan->rowsThreshold = taosRand(); + + return (SNode*)pSubplan; +} + + +SNode* qptCreatePhysicalPlanNode(int32_t nodeIdx) { + if (qptPlans[nodeIdx].buildFunc) { + return (*qptPlans[nodeIdx].buildFunc)(qptPlans[nodeIdx].type); + } + + return NULL; +} + +SNode* qptCreateRealPhysicalPlanNode() { + int32_t nodeIdx = 0; + + do { + nodeIdx = taosRand() % (sizeof(qptPlans) / sizeof(qptPlans[0])); + if (QPT_PLAN_PHYSIC != qptPlans[nodeIdx].classify) { + continue; + } + + return qptCreatePhysicalPlanNode(nodeIdx); + } while (true); +} + +void qptCreatePhysiNodesTree(SPhysiNode** ppRes, SPhysiNode* pParent, int32_t level) { + SPhysiNode* pNew = NULL; + if (level < QPT_MAX_SUBPLAN_LEVEL && (NULL == pParent || QPT_RAND_BOOL_V)) { + pNew = (SPhysiNode*)qptCreateRealPhysicalPlanNode(); + pNew->pParent = pParent; + int32_t childrenNum = taosRand() % QPT_MAX_LEVEL_SUBPLAN_NUM; + for (int32_t i = 0; i < childrenNum; ++i) { + qptCreatePhysiNodesTree(NULL, pNew, level + 1); + } + } else if (QPT_RAND_BOOL_V) { + return; + } + + if (pParent) { + qptNodesListMakeStrictAppend(&pParent->pChildren, (SNode*)pNew); + } else { + *ppRes = pNew; + } +} + +void qptAppendParentsSubplan(SNodeList* pParents, SNodeList* pNew) { + SNode* pNode = NULL; + FOREACH(pNode, pNew) { + if (NULL == pNode || QUERY_NODE_PHYSICAL_SUBPLAN != nodeType(pNode)) { + continue; + } + + qptNodesListMakeStrictAppend(&pParents, pNode); + } +} + +void qptSetSubplansRelation(SNodeList* pParents, SNodeList* pNew) { + int32_t parentIdx = 0; + SNode* pNode = NULL; + SSubplan* pChild = NULL; + SSubplan* pParent = NULL; + FOREACH(pNode, pNew) { + if (QPT_CORRECT_HIGH_PROB()) { + pChild = (SSubplan*)pNode; + parentIdx = taosRand() % pParents->length; + pParent = (SSubplan*)nodesListGetNode(pParents, parentIdx); + qptNodesListMakeStrictAppend(&pParent->pChildren, pNode); + qptNodesListMakeStrictAppend(&pChild->pParents, (SNode*)pParent); + } + } +} + +void qptBuildSubplansRelation(SNodeList* pList) { + SNode* pNode = NULL; + SNodeList* pParents = NULL; + FOREACH(pNode, pList) { + if (NULL == pNode || QUERY_NODE_NODE_LIST != nodeType(pNode)) { + continue; + } + + SNodeListNode* pNodeList = (SNodeListNode*)pNode; + + if (NULL == pParents) { + qptAppendParentsSubplan(pParents, pNodeList->pNodeList); + continue; + } + + qptSetSubplansRelation(pParents, pNodeList->pNodeList); + qptAppendParentsSubplan(pParents, pNodeList->pNodeList); + } +} + +SNode* qptCreateQueryPlanNode(int32_t nodeType) { + SQueryPlan* pPlan = NULL; + assert(0 == nodesMakeNode((ENodeType)nodeType, (SNode**)&pPlan)); + + int32_t subplanNum = 0, subplanLevelNum = taosRand() % QPT_MAX_SUBPLAN_LEVEL; + pPlan->queryId = QPT_CORRECT_HIGH_PROB() ? qptCtx.param.plan.queryId : taosRand(); + + for (int32_t l = 0; l < subplanLevelNum; ++l) { + qptInitMakeNodeCtx(QPT_CORRECT_HIGH_PROB() ? false : true, QPT_RAND_BOOL_V, QPT_RAND_BOOL_V, 0, NULL); + qptNodesListMakeStrictAppend(&pPlan->pSubplans, qptMakeNodeListNode(QPT_NODE_SUBPLAN, NULL)); + } + + pPlan->numOfSubplans = qptGetSubplanNum(pPlan->pSubplans); + qptBuildSubplansRelation(pPlan->pSubplans); + + pPlan->explainInfo.mode = (EExplainMode)(taosRand() % EXPLAIN_MODE_ANALYZE + 1); + pPlan->explainInfo.verbose = QPT_RAND_BOOL_V; + pPlan->explainInfo.ratio = taosRand(); + + pPlan->pPostPlan = QPT_RAND_BOOL_V ? NULL : (void*)0x1; + + return (SNode*)pPlan; +} + + +void qptRerunBlockedHere() { + while (qptInRerun) { + taosSsleep(1); + } +} + +void qptResetForReRun() { + qptCtx.param.plan.taskId = 1; + qptCtx.param.vnode.vgId = 1; + + qptResetTableCols(); + + qptCtx.buildCtx.pCurr = NULL; + qptCtx.buildCtx.pCurrTask = NULL; + + qptCtx.result.code = 0; +} + +void qptSingleTestDone(bool* contLoop) { +/* + if (jtRes.succeed) { + *contLoop = false; + return; + } +*/ + + if (qptErrorRerun) { + *contLoop = false; + return; + } + + qptInRerun = true; +} + + +void qptInitLogFile() { + const char *defaultLogFileNamePrefix = "queryPlanTestlog"; + const int32_t maxLogFileNum = 10; + + tsAsyncLog = 0; + qDebugFlag = 159; + TAOS_STRCPY(tsLogDir, TD_LOG_DIR_PATH); + + if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum, false) < 0) { + printf("failed to open log file in directory:%s\n", tsLogDir); + } +} + + + +void qptInitTest() { + qptInitLogFile(); +} + +void qptHandleTestEnd() { + +} + +void qptExecPlan(SReadHandle* pReadHandle, SNode* pNode, SExecTaskInfo* pTaskInfo, SOperatorInfo** ppOperaotr) { + switch (nodeType(pNode)) { + case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: + qptCtx.result.code = createTagScanOperatorInfo(pReadHandle, (STagScanPhysiNode*)pNode, NULL, NULL, NULL, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: + qptCtx.result.code = createTableScanOperatorInfo((STableScanPhysiNode*)pNode, pReadHandle, NULL, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: + qptCtx.result.code = createTableSeqScanOperatorInfo(pReadHandle, pTaskInfo, ppOperaotr); // usless + break; + case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN: + qptCtx.result.code = createTableMergeScanOperatorInfo((STableScanPhysiNode*)pNode, pReadHandle, NULL, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: + qptCtx.result.code = createStreamScanOperatorInfo(pReadHandle, (STableScanPhysiNode*)pNode, NULL, NULL, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: + qptCtx.result.code = createSysTableScanOperatorInfo(pReadHandle, (SSystemTableScanPhysiNode*)pNode, NULL, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: + qptCtx.result.code = createDataBlockInfoScanOperator(pReadHandle, (SBlockDistScanPhysiNode*)pNode, NULL, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: + qptCtx.result.code = createCacherowsScanOperator((SLastRowScanPhysiNode*)pNode, pReadHandle, NULL, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_PROJECT: + qptCtx.result.code = createProjectOperatorInfo(NULL, (SProjectPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN: + qptCtx.result.code = createMergeJoinOperatorInfo(NULL, 0, (SSortMergeJoinPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_HASH_AGG: { + SAggPhysiNode* pAggNode = (SAggPhysiNode*)pNode; + if (pAggNode->pGroupKeys != NULL) { + qptCtx.result.code = createGroupOperatorInfo(NULL, pAggNode, pTaskInfo, ppOperaotr); + } else { + qptCtx.result.code = createAggregateOperatorInfo(NULL, pAggNode, pTaskInfo, ppOperaotr); + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE: + qptCtx.result.code = createExchangeOperatorInfo(NULL, (SExchangePhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_MERGE: + qptCtx.result.code = createMultiwayMergeOperatorInfo(NULL, 0, (SMergePhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_SORT: + qptCtx.result.code = createSortOperatorInfo(NULL, (SSortPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT: + qptCtx.result.code = createGroupSortOperatorInfo(NULL, (SGroupSortPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: + qptCtx.result.code = createIntervalOperatorInfo(NULL, (SIntervalPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL: + qptCtx.result.code = createMergeIntervalOperatorInfo(NULL, (SMergeIntervalPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: + qptCtx.result.code = createMergeAlignedIntervalOperatorInfo(NULL, (SMergeAlignedIntervalPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: + qptCtx.result.code = createStreamIntervalOperatorInfo(NULL, (SPhysiNode*)pNode, pTaskInfo, pReadHandle, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: + qptCtx.result.code = createStreamFinalIntervalOperatorInfo(NULL, (SPhysiNode*)pNode, pTaskInfo, 0, pReadHandle, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_FILL: + qptCtx.result.code = createFillOperatorInfo(NULL, (SFillPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL: + qptCtx.result.code = createStreamFillOperatorInfo(NULL, (SStreamFillPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION: + qptCtx.result.code = createSessionAggOperatorInfo(NULL, (SSessionWinodwPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION: + qptCtx.result.code = createStreamSessionAggOperatorInfo(NULL, (SPhysiNode*)pNode, pTaskInfo, pReadHandle, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION: + qptCtx.result.code = createStreamFinalSessionAggOperatorInfo(NULL, (SPhysiNode*)pNode, pTaskInfo, 0, pReadHandle, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION: + qptCtx.result.code = createStreamFinalSessionAggOperatorInfo(NULL, (SPhysiNode*)pNode, pTaskInfo, 0, pReadHandle, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE: + qptCtx.result.code = createStatewindowOperatorInfo(NULL, (SStateWinodwPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE: + qptCtx.result.code = createStreamStateAggOperatorInfo(NULL, (SPhysiNode*)pNode, pTaskInfo, pReadHandle, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_PARTITION: + qptCtx.result.code = createPartitionOperatorInfo(NULL, (SPartitionPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: + qptCtx.result.code = createStreamPartitionOperatorInfo(NULL, (SStreamPartitionPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC: + qptCtx.result.code = createIndefinitOutputOperatorInfo(NULL, (SPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC: + qptCtx.result.code = createTimeSliceOperatorInfo(NULL, (SPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_INSERT: + qptCtx.result.code = 0; + break; + case QUERY_NODE_PHYSICAL_PLAN_DISPATCH: + case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT: + case QUERY_NODE_PHYSICAL_PLAN_DELETE: { + DataSinkHandle handle = NULL; + qptCtx.result.code = dsCreateDataSinker(NULL, (SDataSinkNode*)pNode, &handle, NULL, NULL); + dsDestroyDataSinker(handle); + break; + } + case QUERY_NODE_PHYSICAL_SUBPLAN: { + DataSinkHandle handle = NULL; + qptCtx.result.code = qCreateExecTask(pReadHandle, qptCtx.param.vnode.vgId, pTaskInfo->id.taskId, (SSubplan*)pNode, (qTaskInfo_t*)&pTaskInfo, &handle, + QPT_RAND_BOOL_V ? 0 : 1, taosStrdup("sql string"), OPTR_EXEC_MODEL_BATCH); + break; + } + case QUERY_NODE_PHYSICAL_PLAN: { + qptCtx.result.code = schedulerValidatePlan((SQueryPlan*)pNode); + break; + } + case QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN: + qptCtx.result.code = createTableCountScanOperatorInfo(pReadHandle, (STableCountScanPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_MERGE_EVENT: + qptCtx.result.code = createEventwindowOperatorInfo(NULL, (SPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT: + qptCtx.result.code = createStreamEventAggOperatorInfo(NULL, (SPhysiNode*)pNode, pTaskInfo, pReadHandle, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_HASH_JOIN: + qptCtx.result.code = createHashJoinOperatorInfo(NULL, 0, (SHashJoinPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_GROUP_CACHE: + qptCtx.result.code = createGroupCacheOperatorInfo(NULL, 0, (SGroupCachePhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_DYN_QUERY_CTRL: + qptCtx.result.code = createDynQueryCtrlOperatorInfo(NULL, 0, (SDynQueryCtrlPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT: + qptCtx.result.code = createCountwindowOperatorInfo(NULL, (SPhysiNode*)pNode, pTaskInfo, ppOperaotr); + break; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT: + qptCtx.result.code = createStreamCountAggOperatorInfo(NULL, (SPhysiNode*)pNode, pTaskInfo, pReadHandle, ppOperaotr); + break; + default: + assert(0); + } + + if (qptCtx.result.code) { + qptCtx.result.failedTimes++; + } else { + qptCtx.result.succeedTimes++; + } + +} + +void qptRunSingleOpTest() { + SNode* pNode = NULL; + SReadHandle readHandle = {0}; + SOperatorInfo* pOperator = NULL; + SExecTaskInfo* pTaskInfo = NULL; + SStorageAPI storageAPI = {0}; + + qptResetForReRun(); + + doCreateTask(qptCtx.param.plan.queryId, qptCtx.param.plan.taskId, qptCtx.param.vnode.vgId, OPTR_EXEC_MODEL_BATCH, &storageAPI, &pTaskInfo); + qptCtx.buildCtx.pCurrTask = pTaskInfo; + + pNode = (SNode*)qptCreatePhysicalPlanNode(qptCtx.param.plan.subplanIdx[0]); + + qptPrintBeginInfo(); + + qptCtx.result.startTsUs = taosGetTimestampUs(); + + qptExecPlan(&readHandle, pNode, pTaskInfo, &pOperator); + + doDestroyTask(pTaskInfo); + destroyOperator(pOperator); + nodesDestroyNode((SNode*)pNode); + + qptPrintEndInfo(); + + qptHandleTestEnd(); +} + +void qptRunSubplanTest() { + SNode* pNode = NULL; + SReadHandle readHandle = {0}; + SOperatorInfo* pOperator = NULL; + + if (qptCtx.loopIdx > 0) { + qptResetForReRun(); + } + + //pNode = (SNode*)qptCreatePhysicalPlanNode(qptCtx.param.plan.subplanType[0]); + + qptPrintBeginInfo(); + + qptCtx.result.startTsUs = taosGetTimestampUs(); + //qptCtx.result.code = createTagScanOperatorInfo(&readHandle, (STagScanPhysiNode*)pNode, NULL, NULL, NULL, NULL, &pOperator); + //qptCtx.result.code = createProjectOperatorInfo(NULL, (SProjectPhysiNode*)pNode, NULL, &pOperator); + + destroyOperator(pOperator); + nodesDestroyNode((SNode*)pNode); + + qptPrintEndInfo(); + + qptHandleTestEnd(); +} + + +void qptRunPlanTest() { + if (qptCtx.param.plan.singlePhysiNode) { + qptRunSingleOpTest(); + } else { + qptRunSubplanTest(); + } +} + +SQPTNodeParam* qptInitNodeParam(int32_t nodeType) { + return NULL; +} + +void qptInitTableCols(SNodeList** ppList, int32_t colNum, EColumnType colType) { + SQPTCol* pCol = NULL; + int32_t tbnameIdx = -1; + if (QPT_RAND_BOOL_V && COLUMN_TYPE_TAG == colType) { + tbnameIdx = taosRand() % colNum; + } + + for (int32_t i = 0; i < colNum; ++i) { + qptNodesCalloc(1, sizeof(SQPTCol), (void**)&pCol); + pCol->type = QPT_QUERY_NODE_COL; + + if (tbnameIdx >= 0 && i == tbnameIdx) { + strcpy(pCol->name, "tbname"); + pCol->dtype = TSDB_DATA_TYPE_VARCHAR; + pCol->len = qptGetColumnRandLen(pCol->dtype); + pCol->inUse = 0; + pCol->hasIndex = QPT_RAND_BOOL_V; + pCol->isPrimTs = QPT_RAND_BOOL_V; + pCol->isPk = QPT_RAND_BOOL_V; + pCol->colType = COLUMN_TYPE_TBNAME; + + qptNodesListMakeStrictAppend(ppList, (SNode *)pCol); + continue; + } + + qptInitSingleTableCol(pCol, i, colType); + + qptNodesListMakeStrictAppend(ppList, (SNode *)pCol); + } +} + +void qptInitTestCtx(bool correctExpected, bool singleNode, int32_t nodeType, int32_t nodeIdx, int32_t paramNum, SQPTNodeParam* nodeParam) { + qptCtx.param.correctExpected = correctExpected; + qptCtx.param.schedulerId = taosRand(); + strcpy(qptCtx.param.userName, "user1"); + qptCtx.param.plan.singlePhysiNode = singleNode; + + if (singleNode) { + qptCtx.param.plan.subplanMaxLevel = 1; + qptCtx.param.plan.subplanType[0] = nodeType; + qptCtx.param.plan.subplanIdx[0] = nodeIdx; + } else { + qptCtx.param.plan.subplanMaxLevel = taosRand() % QPT_MAX_SUBPLAN_LEVEL + 1; + for (int32_t i = 0; i < qptCtx.param.plan.subplanMaxLevel; ++i) { + nodeIdx = taosRand() % QPT_PHYSIC_NODE_NUM(); + qptCtx.param.plan.subplanType[i] = qptPlans[nodeIdx].type; + qptCtx.param.plan.subplanIdx[i] = nodeIdx; + } + } + + if (paramNum > 0) { + qptCtx.param.plan.physiNodeParamNum = paramNum; + qptCtx.param.plan.physicNodeParam = nodeParam; + } + + qptCtx.param.plan.queryId++; + qptCtx.param.plan.taskId++; + + qptCtx.param.db.precision = TSDB_TIME_PRECISION_MILLI; + strcpy(qptCtx.param.db.dbName, "qptdb1"); + + qptCtx.param.vnode.vnodeNum = QPT_DEFAULT_VNODE_NUM; + qptCtx.param.vnode.vgId = 1; + qptCtx.param.vnode.epSet.numOfEps = 1; + qptCtx.param.vnode.epSet.inUse = 0; + strcpy(qptCtx.param.vnode.epSet.eps[0].fqdn, "127.0.0.1"); + qptCtx.param.vnode.epSet.eps[0].port = 6030; + + qptCtx.param.tbl.uid = 100; + qptCtx.param.tbl.suid = 1; + qptGetRandRealTableType(&qptCtx.param.tbl.tblType); + qptCtx.param.tbl.colNum = taosRand() % 4096 + 1; + qptCtx.param.tbl.tagNum = taosRand() % 128 + 1; + qptCtx.param.tbl.pkNum = taosRand() % 2; + strcpy(qptCtx.param.tbl.tblName, "qpttbl1"); + strcpy(qptCtx.param.tbl.tblName, "tbl1"); + + qptInitTableCols(&qptCtx.param.tbl.pColList, qptCtx.param.tbl.colNum, COLUMN_TYPE_COLUMN); + qptInitTableCols(&qptCtx.param.tbl.pTagList, qptCtx.param.tbl.tagNum, COLUMN_TYPE_TAG); + + SNode* pTmp = NULL; + FOREACH(pTmp, qptCtx.param.tbl.pColList) { + qptNodesListMakeStrictAppend(&qptCtx.param.tbl.pColTagList, pTmp); + } + FOREACH(pTmp, qptCtx.param.tbl.pTagList) { + qptNodesListMakeStrictAppend(&qptCtx.param.tbl.pColTagList, pTmp); + } + + qptCtx.buildCtx.nextBlockId++; + qptCtx.buildCtx.nextSubplanId++; +} + +void qptDestroyTestCtx() { + SNode* pTmp = NULL; + FOREACH(pTmp, qptCtx.param.tbl.pColList) { + qptNodesFree(pTmp); + } + FOREACH(pTmp, qptCtx.param.tbl.pTagList) { + qptNodesFree(pTmp); + } + nodesClearList(qptCtx.param.tbl.pColList); + nodesClearList(qptCtx.param.tbl.pTagList); + nodesClearList(qptCtx.param.tbl.pColTagList); + + qptCtx.param.tbl.pColList = NULL; + qptCtx.param.tbl.pTagList = NULL; + qptCtx.param.tbl.pColTagList = NULL; +} + +} // namespace + +#if 1 +#if 0 +TEST(singleRandNodeTest, loopPlans) { + char* caseType = "singleRandNodeTest:loopPlans"; + + for (qptCtx.loopIdx = 0; qptCtx.loopIdx < QPT_MAX_LOOP; ++qptCtx.loopIdx) { + for (int32_t i = 0; i < sizeof(qptPlans)/sizeof(qptPlans[0]); ++i) { + sprintf(qptCtx.caseName, "%s:%s", caseType, qptPlans[i].name); + qptInitTestCtx(false, true, qptPlans[i].type, i, 0, NULL); + + qptRunPlanTest(); + + qptDestroyTestCtx(); + } + } + + qptPrintStatInfo(); +} +#endif +#if 1 +TEST(singleRandNodeTest, specificPlan) { + char* caseType = "singleRandNodeTest:specificPlan"; + + int32_t idx = qptGetSpecificPlanIndex(QUERY_NODE_PHYSICAL_PLAN); + for (qptCtx.loopIdx = 0; qptCtx.loopIdx < QPT_MAX_LOOP; ++qptCtx.loopIdx) { + sprintf(qptCtx.caseName, "%s:%s", caseType, qptPlans[idx].name); + qptInitTestCtx(false, true, qptPlans[idx].type, idx, 0, NULL); + + qptRunPlanTest(); + + qptDestroyTestCtx(); + } + + qptPrintStatInfo(); +} +#endif + + +#endif + + +int main(int argc, char** argv) { + taosSeedRand(taosGetTimestampSec()); + qptInitTest(); + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} + + + +#pragma GCC diagnosti diff --git a/source/libs/function/CMakeLists.txt b/source/libs/function/CMakeLists.txt index 4164852111c..6891653981d 100644 --- a/source/libs/function/CMakeLists.txt +++ b/source/libs/function/CMakeLists.txt @@ -1,6 +1,10 @@ aux_source_directory(src FUNCTION_SRC) aux_source_directory(src/detail FUNCTION_SRC_DETAIL) list(REMOVE_ITEM FUNCTION_SRC src/udfd.c) +IF(COMPILER_SUPPORT_AVX2) + MESSAGE(STATUS "AVX2 instructions is ACTIVATED") + set_source_files_properties(src/detail/tminmaxavx.c PROPERTIES COMPILE_FLAGS -mavx2) +ENDIF() add_library(function STATIC ${FUNCTION_SRC} ${FUNCTION_SRC_DETAIL}) target_include_directories( function @@ -140,6 +144,11 @@ target_link_libraries( # SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build/bin) add_executable(udfd src/udfd.c) + +if(${TD_DARWIN}) + target_compile_options(udfd PRIVATE -Wno-error=deprecated-non-prototype) +endif() + target_include_directories( udfd PUBLIC diff --git a/source/libs/function/inc/builtinsimpl.h b/source/libs/function/inc/builtinsimpl.h index 36e53d0a80e..a1c82dc58b7 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -25,6 +25,11 @@ extern "C" { #include "functionResInfoInt.h" int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems); +int32_t i8VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFunc, bool signVal, int64_t* res); +int32_t i16VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFunc, bool signVal, int64_t* res); +int32_t i32VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFunc, bool signVal, int64_t* res); +int32_t floatVectorCmpAVX2(const float* pData, int32_t numOfRows, bool isMinFunc, float* res); +int32_t doubleVectorCmpAVX2(const double* pData, int32_t numOfRows, bool isMinFunc, double* res); int32_t saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos); int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos); diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 5e21cd94e81..6837ecbf20c 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1393,6 +1393,11 @@ static int32_t translateRepeat(SFunctionNode* pFunc, char* pErrBuf, int32_t len) } static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList); + if (numOfParams <= 0) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + // The number of parameters has been limited by the syntax definition SExprNode* pPara0 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0); @@ -1550,6 +1555,11 @@ static int32_t translateIn2GeomOutBool(SFunctionNode* pFunc, char* pErrBuf, int3 } static int32_t translateSelectValue(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList); + if (numOfParams <= 0) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + pFunc->node.resType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType; return TSDB_CODE_SUCCESS; } diff --git a/source/libs/function/src/detail/tminmax.c b/source/libs/function/src/detail/tminmax.c index 69c1a8a6ddc..87120960331 100644 --- a/source/libs/function/src/detail/tminmax.c +++ b/source/libs/function/src/detail/tminmax.c @@ -72,173 +72,6 @@ #define GET_INVOKE_INTRINSIC_THRESHOLD(_bits, _bytes) ((_bits) / ((_bytes) << 3u)) -#ifdef __AVX2__ -static void calculateRounds(int32_t numOfRows, int32_t bytes, int32_t* remainder, int32_t* rounds, int32_t* width) { - const int32_t bitWidth = 256; - - *width = (bitWidth >> 3u) / bytes; - *remainder = numOfRows % (*width); - *rounds = numOfRows / (*width); -} - -#define EXTRACT_MAX_VAL(_first, _sec, _width, _remain, _v) \ - __COMPARE_EXTRACT_MAX(0, (_width), (_v), (_first)) \ - __COMPARE_EXTRACT_MAX(0, (_remain), (_v), (_sec)) - -#define EXTRACT_MIN_VAL(_first, _sec, _width, _remain, _v) \ - __COMPARE_EXTRACT_MIN(0, (_width), (_v), (_first)) \ - __COMPARE_EXTRACT_MIN(0, (_remain), (_v), (_sec)) - -#define CMP_TYPE_MIN_MAX(type, cmp) \ - const type* p = pData; \ - __m256i initVal = _mm256_lddqu_si256((__m256i*)p); \ - p += width; \ - for (int32_t i = 1; i < (rounds); ++i) { \ - __m256i next = _mm256_lddqu_si256((__m256i*)p); \ - initVal = CMP_FUNC_##cmp##_##type(initVal, next); \ - p += width; \ - } \ - const type* q = (const type*)&initVal; \ - type* v = (type*)res; \ - EXTRACT_##cmp##_VAL(q, p, width, remain, *v) - -static void i8VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFunc, bool signVal, int64_t* res) { - const int8_t* p = pData; - - int32_t width, remain, rounds; - calculateRounds(numOfRows, sizeof(int8_t), &remain, &rounds, &width); - -#define CMP_FUNC_MIN_int8_t _mm256_min_epi8 -#define CMP_FUNC_MAX_int8_t _mm256_max_epi8 -#define CMP_FUNC_MIN_uint8_t _mm256_min_epu8 -#define CMP_FUNC_MAX_uint8_t _mm256_max_epu8 - - if (!isMinFunc) { // max function - if (signVal) { - CMP_TYPE_MIN_MAX(int8_t, MAX); - } else { - CMP_TYPE_MIN_MAX(uint8_t, MAX); - } - } else { // min function - if (signVal) { - CMP_TYPE_MIN_MAX(int8_t, MIN); - } else { - CMP_TYPE_MIN_MAX(uint8_t, MIN); - } - } -} - -static void i16VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFunc, bool signVal, int64_t* res) { - int32_t width, remain, rounds; - calculateRounds(numOfRows, sizeof(int16_t), &remain, &rounds, &width); - -#define CMP_FUNC_MIN_int16_t _mm256_min_epi16 -#define CMP_FUNC_MAX_int16_t _mm256_max_epi16 -#define CMP_FUNC_MIN_uint16_t _mm256_min_epu16 -#define CMP_FUNC_MAX_uint16_t _mm256_max_epu16 - if (!isMinFunc) { // max function - if (signVal) { - CMP_TYPE_MIN_MAX(int16_t, MAX); - } else { - CMP_TYPE_MIN_MAX(uint16_t, MAX); - } - } else { // min function - if (signVal) { - CMP_TYPE_MIN_MAX(int16_t, MIN); - } else { - CMP_TYPE_MIN_MAX(uint16_t, MIN); - } - } -} - -static void i32VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFunc, bool signVal, int64_t* res) { - int32_t width, remain, rounds; - calculateRounds(numOfRows, sizeof(int32_t), &remain, &rounds, &width); - -#define CMP_FUNC_MIN_int32_t _mm256_min_epi32 -#define CMP_FUNC_MAX_int32_t _mm256_max_epi32 -#define CMP_FUNC_MIN_uint32_t _mm256_min_epu32 -#define CMP_FUNC_MAX_uint32_t _mm256_max_epu32 - if (!isMinFunc) { // max function - if (signVal) { - CMP_TYPE_MIN_MAX(int32_t, MAX); - } else { - CMP_TYPE_MIN_MAX(uint32_t, MAX); - } - } else { // min function - if (signVal) { - CMP_TYPE_MIN_MAX(int32_t, MIN); - } else { - CMP_TYPE_MIN_MAX(uint32_t, MIN); - } - } -} - -static void floatVectorCmpAVX2(const float* pData, int32_t numOfRows, bool isMinFunc, float* res) { - const float* p = pData; - - int32_t width, remain, rounds; - calculateRounds(numOfRows, sizeof(float), &remain, &rounds, &width); - - __m256 next; - __m256 initVal = _mm256_loadu_ps(p); - p += width; - - if (!isMinFunc) { // max function - for (int32_t i = 1; i < rounds; ++i) { - next = _mm256_loadu_ps(p); - initVal = _mm256_max_ps(initVal, next); - p += width; - } - - const float* q = (const float*)&initVal; - EXTRACT_MAX_VAL(q, p, width, remain, *res) - } else { // min function - for (int32_t i = 1; i < rounds; ++i) { - next = _mm256_loadu_ps(p); - initVal = _mm256_min_ps(initVal, next); - p += width; - } - - const float* q = (const float*)&initVal; - EXTRACT_MIN_VAL(q, p, width, remain, *res) - } -} - -static void doubleVectorCmpAVX2(const double* pData, int32_t numOfRows, bool isMinFunc, double* res) { - const double* p = pData; - - int32_t width, remain, rounds; - calculateRounds(numOfRows, sizeof(double), &remain, &rounds, &width); - - __m256d next; - __m256d initVal = _mm256_loadu_pd(p); - p += width; - - if (!isMinFunc) { // max function - for (int32_t i = 1; i < rounds; ++i) { - next = _mm256_loadu_pd(p); - initVal = _mm256_max_pd(initVal, next); - p += width; - } - - // let sum up the final results - const double* q = (const double*)&initVal; - EXTRACT_MAX_VAL(q, p, width, remain, *res) - } else { // min function - for (int32_t i = 1; i < rounds; ++i) { - next = _mm256_loadu_pd(p); - initVal = _mm256_min_pd(initVal, next); - p += width; - } - - // let sum up the final results - const double* q = (const double*)&initVal; - EXTRACT_MIN_VAL(q, p, width, remain, *res) - } -} -#endif - static int32_t findFirstValPosition(const SColumnInfoData* pCol, int32_t start, int32_t numOfRows, bool isStr) { int32_t i = start; @@ -255,31 +88,31 @@ static void handleInt8Col(const void* data, int32_t start, int32_t numOfRows, SM pBuf->v = ((const int8_t*)data)[start]; } -#ifdef __AVX2__ - if (tsAVX2Supported && tsSIMDEnable && numOfRows * sizeof(int8_t) >= sizeof(__m256i)) { - i8VectorCmpAVX2(data + start * sizeof(int8_t), numOfRows, isMinFunc, signVal, &pBuf->v); - } else { -#else - if (true) { -#endif - if (signVal) { - const int8_t* p = (const int8_t*)data; - int8_t* v = (int8_t*)&pBuf->v; - - if (isMinFunc) { - __COMPARE_EXTRACT_MIN(start, start + numOfRows, *v, p); - } else { - __COMPARE_EXTRACT_MAX(start, start + numOfRows, *v, p); - } + if (tsAVX2Supported && tsSIMDEnable && numOfRows * sizeof(int8_t) >= M256_BYTES) { + int32_t code = i8VectorCmpAVX2(((char*)data) + start * sizeof(int8_t), numOfRows, isMinFunc, signVal, &pBuf->v); + if (code == TSDB_CODE_SUCCESS) { + pBuf->assign = true; + return; + } + } + + if (signVal) { + const int8_t* p = (const int8_t*)data; + int8_t* v = (int8_t*)&pBuf->v; + + if (isMinFunc) { + __COMPARE_EXTRACT_MIN(start, start + numOfRows, *v, p); } else { - const uint8_t* p = (const uint8_t*)data; - uint8_t* v = (uint8_t*)&pBuf->v; + __COMPARE_EXTRACT_MAX(start, start + numOfRows, *v, p); + } + } else { + const uint8_t* p = (const uint8_t*)data; + uint8_t* v = (uint8_t*)&pBuf->v; - if (isMinFunc) { - __COMPARE_EXTRACT_MIN(start, start + numOfRows, *v, p); - } else { - __COMPARE_EXTRACT_MAX(start, start + numOfRows, *v, p); - } + if (isMinFunc) { + __COMPARE_EXTRACT_MIN(start, start + numOfRows, *v, p); + } else { + __COMPARE_EXTRACT_MAX(start, start + numOfRows, *v, p); } } @@ -292,31 +125,31 @@ static void handleInt16Col(const void* data, int32_t start, int32_t numOfRows, S pBuf->v = ((const int16_t*)data)[start]; } -#ifdef __AVX2__ - if (tsAVX2Supported && tsSIMDEnable && numOfRows * sizeof(int16_t) >= sizeof(__m256i)) { - i16VectorCmpAVX2(data + start * sizeof(int16_t), numOfRows, isMinFunc, signVal, &pBuf->v); - } else { -#else - if (true) { -#endif - if (signVal) { - const int16_t* p = (const int16_t*)data; - int16_t* v = (int16_t*)&pBuf->v; - - if (isMinFunc) { - __COMPARE_EXTRACT_MIN(start, start + numOfRows, *v, p); - } else { - __COMPARE_EXTRACT_MAX(start, start + numOfRows, *v, p); - } + if (tsAVX2Supported && tsSIMDEnable && numOfRows * sizeof(int16_t) >= M256_BYTES) { + int32_t code = i16VectorCmpAVX2(((char*)data) + start * sizeof(int16_t), numOfRows, isMinFunc, signVal, &pBuf->v); + if (code == TSDB_CODE_SUCCESS) { + pBuf->assign = true; + return; + } + } + + if (signVal) { + const int16_t* p = (const int16_t*)data; + int16_t* v = (int16_t*)&pBuf->v; + + if (isMinFunc) { + __COMPARE_EXTRACT_MIN(start, start + numOfRows, *v, p); } else { - const uint16_t* p = (const uint16_t*)data; - uint16_t* v = (uint16_t*)&pBuf->v; + __COMPARE_EXTRACT_MAX(start, start + numOfRows, *v, p); + } + } else { + const uint16_t* p = (const uint16_t*)data; + uint16_t* v = (uint16_t*)&pBuf->v; - if (isMinFunc) { - __COMPARE_EXTRACT_MIN(start, start + numOfRows, *v, p); - } else { - __COMPARE_EXTRACT_MAX(start, start + numOfRows, *v, p); - } + if (isMinFunc) { + __COMPARE_EXTRACT_MIN(start, start + numOfRows, *v, p); + } else { + __COMPARE_EXTRACT_MAX(start, start + numOfRows, *v, p); } } @@ -329,31 +162,31 @@ static void handleInt32Col(const void* data, int32_t start, int32_t numOfRows, S pBuf->v = ((const int32_t*)data)[start]; } -#ifdef __AVX2__ - if (tsAVX2Supported && tsSIMDEnable && numOfRows * sizeof(int32_t) >= sizeof(__m256i)) { - i32VectorCmpAVX2(data + start * sizeof(int32_t), numOfRows, isMinFunc, signVal, &pBuf->v); - } else { -#else - if (true) { -#endif - if (signVal) { - const int32_t* p = (const int32_t*)data; - int32_t* v = (int32_t*)&pBuf->v; - - if (isMinFunc) { - __COMPARE_EXTRACT_MIN(start, start + numOfRows, *v, p); - } else { - __COMPARE_EXTRACT_MAX(start, start + numOfRows, *v, p); - } + if (tsAVX2Supported && tsSIMDEnable && numOfRows * sizeof(int32_t) >= M256_BYTES) { + int32_t code = i32VectorCmpAVX2(((char*)data) + start * sizeof(int32_t), numOfRows, isMinFunc, signVal, &pBuf->v); + if (code == TSDB_CODE_SUCCESS) { + pBuf->assign = true; + return; + } + } + + if (signVal) { + const int32_t* p = (const int32_t*)data; + int32_t* v = (int32_t*)&pBuf->v; + + if (isMinFunc) { + __COMPARE_EXTRACT_MIN(start, start + numOfRows, *v, p); } else { - const uint32_t* p = (const uint32_t*)data; - uint32_t* v = (uint32_t*)&pBuf->v; + __COMPARE_EXTRACT_MAX(start, start + numOfRows, *v, p); + } + } else { + const uint32_t* p = (const uint32_t*)data; + uint32_t* v = (uint32_t*)&pBuf->v; - if (isMinFunc) { - __COMPARE_EXTRACT_MIN(start, start + numOfRows, *v, p); - } else { - __COMPARE_EXTRACT_MAX(start, start + numOfRows, *v, p); - } + if (isMinFunc) { + __COMPARE_EXTRACT_MIN(start, start + numOfRows, *v, p); + } else { + __COMPARE_EXTRACT_MAX(start, start + numOfRows, *v, p); } } @@ -397,20 +230,20 @@ static void handleFloatCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRo *val = pData[start]; } -#ifdef __AVX2__ - if (tsAVXSupported && tsSIMDEnable && numOfRows * sizeof(float) >= sizeof(__m256i)) { - floatVectorCmpAVX2(pData + start, numOfRows, isMinFunc, val); - } else { -#else - if (true) { -#endif - if (isMinFunc) { // min - __COMPARE_EXTRACT_MIN(start, start + numOfRows, *val, pData); - } else { // max - __COMPARE_EXTRACT_MAX(start, start + numOfRows, *val, pData); + if (tsAVX2Supported && tsSIMDEnable && numOfRows * sizeof(float) >= M256_BYTES) { + int32_t code = floatVectorCmpAVX2(pData + start, numOfRows, isMinFunc, val); + if (code == TSDB_CODE_SUCCESS) { + pBuf->assign = true; + return; } } + if (isMinFunc) { // min + __COMPARE_EXTRACT_MIN(start, start + numOfRows, *val, pData); + } else { // max + __COMPARE_EXTRACT_MAX(start, start + numOfRows, *val, pData); + } + pBuf->assign = true; } @@ -422,20 +255,20 @@ static void handleDoubleCol(SColumnInfoData* pCol, int32_t start, int32_t numOfR *val = pData[start]; } -#ifdef __AVX2__ - if (tsAVXSupported && tsSIMDEnable && numOfRows * sizeof(double) >= sizeof(__m256i)) { - doubleVectorCmpAVX2(pData + start, numOfRows, isMinFunc, val); - } else { -#else - if (true) { -#endif - if (isMinFunc) { // min - __COMPARE_EXTRACT_MIN(start, start + numOfRows, *val, pData); - } else { // max - __COMPARE_EXTRACT_MAX(start, start + numOfRows, *val, pData); + if (tsAVX2Supported && tsSIMDEnable && numOfRows * sizeof(double) >= M256_BYTES) { + int32_t code = doubleVectorCmpAVX2(pData + start, numOfRows, isMinFunc, val); + if (code == TSDB_CODE_SUCCESS) { + pBuf->assign = true; + return; } } + if (isMinFunc) { // min + __COMPARE_EXTRACT_MIN(start, start + numOfRows, *val, pData); + } else { // max + __COMPARE_EXTRACT_MAX(start, start + numOfRows, *val, pData); + } + pBuf->assign = true; } diff --git a/source/libs/function/src/detail/tminmaxavx.c b/source/libs/function/src/detail/tminmaxavx.c new file mode 100644 index 00000000000..8fe6cc5448f --- /dev/null +++ b/source/libs/function/src/detail/tminmaxavx.c @@ -0,0 +1,227 @@ +/* + * 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 "builtinsimpl.h" + +#ifdef __AVX2__ +static void calculateRounds(int32_t numOfRows, int32_t bytes, int32_t* remainder, int32_t* rounds, int32_t* width) { + const int32_t bitWidth = 256; + + *width = (bitWidth >> 3u) / bytes; + *remainder = numOfRows % (*width); + *rounds = numOfRows / (*width); +} + +#define __COMPARE_EXTRACT_MIN(start, end, val, _data) \ + for (int32_t i = (start); i < (end); ++i) { \ + if ((val) > (_data)[i]) { \ + (val) = (_data)[i]; \ + } \ + } + +#define __COMPARE_EXTRACT_MAX(start, end, val, _data) \ + for (int32_t i = (start); i < (end); ++i) { \ + if ((val) < (_data)[i]) { \ + (val) = (_data)[i]; \ + } \ + } + +#define EXTRACT_MAX_VAL(_first, _sec, _width, _remain, _v) \ + __COMPARE_EXTRACT_MAX(0, (_width), (_v), (_first)) \ + __COMPARE_EXTRACT_MAX(0, (_remain), (_v), (_sec)) + +#define EXTRACT_MIN_VAL(_first, _sec, _width, _remain, _v) \ + __COMPARE_EXTRACT_MIN(0, (_width), (_v), (_first)) \ + __COMPARE_EXTRACT_MIN(0, (_remain), (_v), (_sec)) + +#define CMP_TYPE_MIN_MAX(type, cmp) \ + const type* p = pData; \ + __m256i initVal = _mm256_lddqu_si256((__m256i*)p); \ + p += width; \ + for (int32_t i = 1; i < (rounds); ++i) { \ + __m256i next = _mm256_lddqu_si256((__m256i*)p); \ + initVal = CMP_FUNC_##cmp##_##type(initVal, next); \ + p += width; \ + } \ + const type* q = (const type*)&initVal; \ + type* v = (type*)res; \ + EXTRACT_##cmp##_VAL(q, p, width, remain, *v) +#endif + +int32_t i8VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFunc, bool signVal, int64_t* res) { +#ifdef __AVX2__ + const int8_t* p = pData; + + int32_t width, remain, rounds; + calculateRounds(numOfRows, sizeof(int8_t), &remain, &rounds, &width); + +#define CMP_FUNC_MIN_int8_t _mm256_min_epi8 +#define CMP_FUNC_MAX_int8_t _mm256_max_epi8 +#define CMP_FUNC_MIN_uint8_t _mm256_min_epu8 +#define CMP_FUNC_MAX_uint8_t _mm256_max_epu8 + + if (!isMinFunc) { // max function + if (signVal) { + CMP_TYPE_MIN_MAX(int8_t, MAX); + } else { + CMP_TYPE_MIN_MAX(uint8_t, MAX); + } + } else { // min function + if (signVal) { + CMP_TYPE_MIN_MAX(int8_t, MIN); + } else { + CMP_TYPE_MIN_MAX(uint8_t, MIN); + } + } + return TSDB_CODE_SUCCESS; +#else + uError("unable run %s without avx2 instructions", __func__); + return TSDB_CODE_OPS_NOT_SUPPORT; +#endif +} + +int32_t i16VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFunc, bool signVal, int64_t* res) { +#ifdef __AVX2__ + int32_t width, remain, rounds; + calculateRounds(numOfRows, sizeof(int16_t), &remain, &rounds, &width); + +#define CMP_FUNC_MIN_int16_t _mm256_min_epi16 +#define CMP_FUNC_MAX_int16_t _mm256_max_epi16 +#define CMP_FUNC_MIN_uint16_t _mm256_min_epu16 +#define CMP_FUNC_MAX_uint16_t _mm256_max_epu16 + if (!isMinFunc) { // max function + if (signVal) { + CMP_TYPE_MIN_MAX(int16_t, MAX); + } else { + CMP_TYPE_MIN_MAX(uint16_t, MAX); + } + } else { // min function + if (signVal) { + CMP_TYPE_MIN_MAX(int16_t, MIN); + } else { + CMP_TYPE_MIN_MAX(uint16_t, MIN); + } + } + return TSDB_CODE_SUCCESS; +#else + uError("unable run %s without avx2 instructions", __func__); + return TSDB_CODE_OPS_NOT_SUPPORT; +#endif +} + +int32_t i32VectorCmpAVX2(const void* pData, int32_t numOfRows, bool isMinFunc, bool signVal, int64_t* res) { +#ifdef __AVX2__ + int32_t width, remain, rounds; + calculateRounds(numOfRows, sizeof(int32_t), &remain, &rounds, &width); + +#define CMP_FUNC_MIN_int32_t _mm256_min_epi32 +#define CMP_FUNC_MAX_int32_t _mm256_max_epi32 +#define CMP_FUNC_MIN_uint32_t _mm256_min_epu32 +#define CMP_FUNC_MAX_uint32_t _mm256_max_epu32 + if (!isMinFunc) { // max function + if (signVal) { + CMP_TYPE_MIN_MAX(int32_t, MAX); + } else { + CMP_TYPE_MIN_MAX(uint32_t, MAX); + } + } else { // min function + if (signVal) { + CMP_TYPE_MIN_MAX(int32_t, MIN); + } else { + CMP_TYPE_MIN_MAX(uint32_t, MIN); + } + } + return TSDB_CODE_SUCCESS; +#else + uError("unable run %s without avx2 instructions", __func__); + return TSDB_CODE_OPS_NOT_SUPPORT; +#endif +} + +int32_t floatVectorCmpAVX2(const float* pData, int32_t numOfRows, bool isMinFunc, float* res) { +#ifdef __AVX2__ + const float* p = pData; + + int32_t width, remain, rounds; + calculateRounds(numOfRows, sizeof(float), &remain, &rounds, &width); + + __m256 next; + __m256 initVal = _mm256_loadu_ps(p); + p += width; + + if (!isMinFunc) { // max function + for (int32_t i = 1; i < rounds; ++i) { + next = _mm256_loadu_ps(p); + initVal = _mm256_max_ps(initVal, next); + p += width; + } + + const float* q = (const float*)&initVal; + EXTRACT_MAX_VAL(q, p, width, remain, *res) + } else { // min function + for (int32_t i = 1; i < rounds; ++i) { + next = _mm256_loadu_ps(p); + initVal = _mm256_min_ps(initVal, next); + p += width; + } + + const float* q = (const float*)&initVal; + EXTRACT_MIN_VAL(q, p, width, remain, *res) + } + return TSDB_CODE_SUCCESS; +#else + uError("unable run %s without avx2 instructions", __func__); + return TSDB_CODE_OPS_NOT_SUPPORT; +#endif +} + +int32_t doubleVectorCmpAVX2(const double* pData, int32_t numOfRows, bool isMinFunc, double* res) { +#ifdef __AVX2__ + const double* p = pData; + + int32_t width, remain, rounds; + calculateRounds(numOfRows, sizeof(double), &remain, &rounds, &width); + + __m256d next; + __m256d initVal = _mm256_loadu_pd(p); + p += width; + + if (!isMinFunc) { // max function + for (int32_t i = 1; i < rounds; ++i) { + next = _mm256_loadu_pd(p); + initVal = _mm256_max_pd(initVal, next); + p += width; + } + + // let sum up the final results + const double* q = (const double*)&initVal; + EXTRACT_MAX_VAL(q, p, width, remain, *res) + } else { // min function + for (int32_t i = 1; i < rounds; ++i) { + next = _mm256_loadu_pd(p); + initVal = _mm256_min_pd(initVal, next); + p += width; + } + + // let sum up the final results + const double* q = (const double*)&initVal; + EXTRACT_MIN_VAL(q, p, width, remain, *res) + } + return TSDB_CODE_SUCCESS; +#else + uError("unable run %s without avx2 instructions", __func__); + return TSDB_CODE_OPS_NOT_SUPPORT; +#endif +} diff --git a/source/libs/function/src/tpercentile.c b/source/libs/function/src/tpercentile.c index 429ab52a8d4..78c16ec7cb8 100644 --- a/source/libs/function/src/tpercentile.c +++ b/source/libs/function/src/tpercentile.c @@ -224,7 +224,7 @@ int32_t tBucketDoubleHash(tMemBucket *pBucket, const void *value, int32_t *index *index = -1; - if (v > pBucket->range.dMaxVal || v < pBucket->range.dMinVal || isnan(v)) { + if (v > pBucket->range.dMaxVal || v < pBucket->range.dMinVal || isnan(v) || isinf(v)) { return TSDB_CODE_SUCCESS; } @@ -232,6 +232,8 @@ int32_t tBucketDoubleHash(tMemBucket *pBucket, const void *value, int32_t *index double span = pBucket->range.dMaxVal - pBucket->range.dMinVal; if (fabs(span) < DBL_EPSILON) { *index = 0; + } else if (isinf(span)) { + *index = -1; } else { double slotSpan = span / pBucket->numOfSlots; *index = (int32_t)((v - pBucket->range.dMinVal) / slotSpan); diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index 6bc9f84d6d8..a8198a804db 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -40,7 +40,7 @@ typedef struct SUdfdData { #ifdef WINDOWS HANDLE jobHandle; #endif - int spawnErr; + int32_t spawnErr; uv_pipe_t ctrlPipe; uv_async_t stopAsync; int32_t stopCalled; @@ -51,15 +51,17 @@ typedef struct SUdfdData { SUdfdData udfdGlobal = {0}; int32_t udfStartUdfd(int32_t startDnodeId); -void udfStopUdfd(); +void udfStopUdfd(); + +extern char **environ; static int32_t udfSpawnUdfd(SUdfdData *pData); -void udfUdfdExit(uv_process_t *process, int64_t exitStatus, int termSignal); +void udfUdfdExit(uv_process_t *process, int64_t exitStatus, int32_t termSignal); static void udfUdfdCloseWalkCb(uv_handle_t *handle, void *arg); static void udfUdfdStopAsyncCb(uv_async_t *async); static void udfWatchUdfd(void *args); -void udfUdfdExit(uv_process_t *process, int64_t exitStatus, int termSignal) { +void udfUdfdExit(uv_process_t *process, int64_t exitStatus, int32_t termSignal) { fnInfo("udfd process exited with status %" PRId64 ", signal %d", exitStatus, termSignal); SUdfdData *pData = process->data; if (exitStatus == 0 && termSignal == 0 || atomic_load_32(&pData->stopCalled)) { @@ -67,7 +69,7 @@ void udfUdfdExit(uv_process_t *process, int64_t exitStatus, int termSignal) { } else { fnInfo("udfd process restart"); int32_t code = udfSpawnUdfd(pData); - if(code != 0) { + if (code != 0) { fnError("udfd process restart failed with code:%d", code); } } @@ -75,6 +77,8 @@ void udfUdfdExit(uv_process_t *process, int64_t exitStatus, int termSignal) { static int32_t udfSpawnUdfd(SUdfdData *pData) { fnInfo("start to init udfd"); + + int32_t err = 0; uv_process_options_t options = {0}; char path[PATH_MAX] = {0}; @@ -126,17 +130,17 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) { char thrdPoolSizeEnvItem[32] = {0}; snprintf(dnodeIdEnvItem, 32, "%s=%d", "DNODE_ID", pData->dnodeId); - float numCpuCores = 4; + float numCpuCores = 4; int32_t code = taosGetCpuCores(&numCpuCores, false); - if(code != 0) { - fnError("failed to get cpu cores, code:%d", code); + if (code != 0) { + fnError("failed to get cpu cores, code:0x%x", code); } numCpuCores = TMAX(numCpuCores, 2); - snprintf(thrdPoolSizeEnvItem, 32, "%s=%d", "UV_THREADPOOL_SIZE", (int)numCpuCores * 2); + snprintf(thrdPoolSizeEnvItem, 32, "%s=%d", "UV_THREADPOOL_SIZE", (int32_t)numCpuCores * 2); - char pathTaosdLdLib[512] = {0}; - size_t taosdLdLibPathLen = sizeof(pathTaosdLdLib); - int ret = uv_os_getenv("LD_LIBRARY_PATH", pathTaosdLdLib, &taosdLdLibPathLen); + char pathTaosdLdLib[512] = {0}; + size_t taosdLdLibPathLen = sizeof(pathTaosdLdLib); + int32_t ret = uv_os_getenv("LD_LIBRARY_PATH", pathTaosdLdLib, &taosdLdLibPathLen); if (ret != UV_ENOBUFS) { taosdLdLibPathLen = strlen(pathTaosdLdLib); } @@ -158,8 +162,8 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) { char *taosFqdnEnvItem = NULL; char *taosFqdn = getenv("TAOS_FQDN"); if (taosFqdn != NULL) { - int subLen = strlen(taosFqdn); - int len = strlen("TAOS_FQDN=") + subLen + 1; + int32_t subLen = strlen(taosFqdn); + int32_t len = strlen("TAOS_FQDN=") + subLen + 1; taosFqdnEnvItem = taosMemoryMalloc(len); if (taosFqdnEnvItem != NULL) { tstrncpy(taosFqdnEnvItem, "TAOS_FQDN=", len); @@ -171,11 +175,53 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) { } } - char *envUdfd[] = {dnodeIdEnvItem, thrdPoolSizeEnvItem, ldLibPathEnvItem,taosFqdnEnvItem, NULL}; + char *envUdfd[] = {dnodeIdEnvItem, thrdPoolSizeEnvItem, ldLibPathEnvItem, taosFqdnEnvItem, NULL}; + + char **envUdfdWithPEnv = NULL; + if (environ != NULL) { + int32_t lenEnvUdfd = ARRAY_SIZE(envUdfd); + int32_t numEnviron = 0; + while (environ[numEnviron] != NULL) { + numEnviron++; + } + + envUdfdWithPEnv = (char **)taosMemoryCalloc(numEnviron + lenEnvUdfd, sizeof(char *)); + if (envUdfdWithPEnv == NULL) { + err = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + + for (int32_t i = 0; i < numEnviron; i++) { + int32_t len = strlen(environ[i]) + 1; + envUdfdWithPEnv[i] = (char *)taosMemoryCalloc(len, 1); + if (envUdfdWithPEnv[i] == NULL) { + err = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + + tstrncpy(envUdfdWithPEnv[i], environ[i], len); + } - options.env = envUdfd; + for (int32_t i = 0; i < lenEnvUdfd; i++) { + if (envUdfd[i] != NULL) { + int32_t len = strlen(envUdfd[i]) + 1; + envUdfdWithPEnv[numEnviron + i] = (char *)taosMemoryCalloc(len, 1); + if (envUdfdWithPEnv[numEnviron + i] == NULL) { + err = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + + tstrncpy(envUdfdWithPEnv[numEnviron + i], envUdfd[i], len); + } + } + envUdfdWithPEnv[numEnviron + lenEnvUdfd - 1] = NULL; + + options.env = envUdfdWithPEnv; + } else { + options.env = envUdfd; + } - int err = uv_spawn(&pData->loop, &pData->process, &options); + err = uv_spawn(&pData->loop, &pData->process, &options); pData->process.data = (void *)pData; #ifdef WINDOWS @@ -202,7 +248,21 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) { } else { fnInfo("udfd is initialized"); } - if(taosFqdnEnvItem) taosMemoryFree(taosFqdnEnvItem); + +_OVER: + if (taosFqdnEnvItem) { + taosMemoryFree(taosFqdnEnvItem); + } + + if (envUdfdWithPEnv != NULL) { + int32_t i = 0; + while (envUdfdWithPEnv[i] != NULL) { + taosMemoryFree(envUdfdWithPEnv[i]); + i++; + } + taosMemoryFree(envUdfdWithPEnv); + } + return err; } @@ -225,13 +285,13 @@ static void udfWatchUdfd(void *args) { TAOS_UV_CHECK_ERRNO(udfSpawnUdfd(pData)); atomic_store_32(&pData->spawnErr, 0); (void)uv_barrier_wait(&pData->barrier); - int num = uv_run(&pData->loop, UV_RUN_DEFAULT); + int32_t num = uv_run(&pData->loop, UV_RUN_DEFAULT); fnInfo("udfd loop exit with %d active handles, line:%d", num, __LINE__); uv_walk(&pData->loop, udfUdfdCloseWalkCb, NULL); num = uv_run(&pData->loop, UV_RUN_DEFAULT); fnInfo("udfd loop exit with %d active handles, line:%d", num, __LINE__); - if(uv_loop_close(&pData->loop) != 0) { + if (uv_loop_close(&pData->loop) != 0) { fnError("udfd loop close failed, lino:%d", __LINE__); } return; @@ -240,7 +300,7 @@ static void udfWatchUdfd(void *args) { if (terrno != 0) { (void)uv_barrier_wait(&pData->barrier); atomic_store_32(&pData->spawnErr, terrno); - if(uv_loop_close(&pData->loop) != 0) { + if (uv_loop_close(&pData->loop) != 0) { fnError("udfd loop close failed, lino:%d", __LINE__); } fnError("udfd thread exit with code:%d lino:%d", terrno, terrln); @@ -271,10 +331,10 @@ int32_t udfStartUdfd(int32_t startDnodeId) { int32_t err = atomic_load_32(&pData->spawnErr); if (err != 0) { uv_barrier_destroy(&pData->barrier); - if(uv_async_send(&pData->stopAsync) != 0) { + if (uv_async_send(&pData->stopAsync) != 0) { fnError("start udfd: failed to send stop async"); } - if(uv_thread_join(&pData->thread)!= 0) { + if (uv_thread_join(&pData->thread) != 0) { fnError("start udfd: failed to join udfd thread"); } pData->needCleanUp = false; @@ -299,10 +359,10 @@ void udfStopUdfd() { atomic_store_32(&pData->stopCalled, 1); pData->needCleanUp = false; uv_barrier_destroy(&pData->barrier); - if(uv_async_send(&pData->stopAsync) != 0) { + if (uv_async_send(&pData->stopAsync) != 0) { fnError("stop udfd: failed to send stop async"); } - if(uv_thread_join(&pData->thread) != 0) { + if (uv_thread_join(&pData->thread) != 0) { fnError("stop udfd: failed to join udfd thread"); } @@ -341,7 +401,7 @@ typedef void *QUEUE[2]; #define QUEUE_NEXT_PREV(q) (QUEUE_PREV(QUEUE_NEXT(q))) /* Public macros. */ -#define QUEUE_DATA(ptr, type, field) ((type *)((char *)(ptr)-offsetof(type, field))) +#define QUEUE_DATA(ptr, type, field) ((type *)((char *)(ptr) - offsetof(type, field))) /* Important note: mutating the list while QUEUE_FOREACH is * iterating over its elements results in undefined behavior. @@ -434,8 +494,8 @@ typedef struct SUdfcProxy { QUEUE uvProcTaskQueue; uv_mutex_t udfStubsMutex; - SArray *udfStubs; // SUdfcFuncStub - SArray *expiredUdfStubs; //SUdfcFuncStub + SArray *udfStubs; // SUdfcFuncStub + SArray *expiredUdfStubs; // SUdfcFuncStub uv_mutex_t udfcUvMutex; int8_t initialized; @@ -458,7 +518,7 @@ typedef struct SUdfcUvSession { typedef struct SClientUvTaskNode { SUdfcProxy *udfc; int8_t type; - int errCode; + int32_t errCode; uv_pipe_t *pipe; @@ -516,7 +576,7 @@ enum { UDFC_STATE_STOPPING, // stopping after udfcClose }; -void getUdfdPipeName(char *pipeName, int32_t size); +void getUdfdPipeName(char *pipeName, int32_t size); int32_t encodeUdfSetupRequest(void **buf, const SUdfSetupRequest *setup); void *decodeUdfSetupRequest(const void *buf, SUdfSetupRequest *request); int32_t encodeUdfInterBuf(void **buf, const SUdfInterBuf *state); @@ -801,12 +861,12 @@ void *decodeUdfResponse(const void *buf, SUdfResponse *rsp) { buf = decodeUdfTeardownResponse(buf, &rsp->teardownRsp); break; default: - rsp->code = TSDB_CODE_UDF_INTERNAL_ERROR; + rsp->code = TSDB_CODE_UDF_INTERNAL_ERROR; fnError("decode udf response, invalid udf response type %d", rsp->type); break; } - if(buf == NULL) { - rsp->code = terrno; + if (buf == NULL) { + rsp->code = terrno; fnError("decode udf response failed, code:0x%x", rsp->code); } return (void *)buf; @@ -847,12 +907,12 @@ int32_t convertDataBlockToUdfDataBlock(SSDataBlock *block, SUdfDataBlock *udfBlo udfBlock->numOfRows = block->info.rows; udfBlock->numOfCols = taosArrayGetSize(block->pDataBlock); udfBlock->udfCols = taosMemoryCalloc(taosArrayGetSize(block->pDataBlock), sizeof(SUdfColumn *)); - if((udfBlock->udfCols) == NULL) { + if ((udfBlock->udfCols) == NULL) { return terrno; } for (int32_t i = 0; i < udfBlock->numOfCols; ++i) { udfBlock->udfCols[i] = taosMemoryCalloc(1, sizeof(SUdfColumn)); - if(udfBlock->udfCols[i] == NULL) { + if (udfBlock->udfCols[i] == NULL) { return terrno; } SColumnInfoData *col = (SColumnInfoData *)taosArrayGet(block->pDataBlock, i); @@ -866,18 +926,18 @@ int32_t convertDataBlockToUdfDataBlock(SSDataBlock *block, SUdfDataBlock *udfBlo if (IS_VAR_DATA_TYPE(udfCol->colMeta.type)) { udfCol->colData.varLenCol.varOffsetsLen = sizeof(int32_t) * udfBlock->numOfRows; udfCol->colData.varLenCol.varOffsets = taosMemoryMalloc(udfCol->colData.varLenCol.varOffsetsLen); - if(udfCol->colData.varLenCol.varOffsets == NULL) { + if (udfCol->colData.varLenCol.varOffsets == NULL) { return terrno; } memcpy(udfCol->colData.varLenCol.varOffsets, col->varmeta.offset, udfCol->colData.varLenCol.varOffsetsLen); udfCol->colData.varLenCol.payloadLen = colDataGetLength(col, udfBlock->numOfRows); udfCol->colData.varLenCol.payload = taosMemoryMalloc(udfCol->colData.varLenCol.payloadLen); - if(udfCol->colData.varLenCol.payload == NULL) { + if (udfCol->colData.varLenCol.payload == NULL) { return terrno; } if (col->reassigned) { for (int32_t row = 0; row < udfCol->colData.numOfRows; ++row) { - char* pColData = col->pData + col->varmeta.offset[row]; + char *pColData = col->pData + col->varmeta.offset[row]; int32_t colSize = 0; if (col->info.type == TSDB_DATA_TYPE_JSON) { colSize = getJsonValueLen(pColData); @@ -894,7 +954,7 @@ int32_t convertDataBlockToUdfDataBlock(SSDataBlock *block, SUdfDataBlock *udfBlo udfCol->colData.fixLenCol.nullBitmapLen = BitmapLen(udfCol->colData.numOfRows); int32_t bitmapLen = udfCol->colData.fixLenCol.nullBitmapLen; udfCol->colData.fixLenCol.nullBitmap = taosMemoryMalloc(udfCol->colData.fixLenCol.nullBitmapLen); - if(udfCol->colData.fixLenCol.nullBitmap == NULL) { + if (udfCol->colData.fixLenCol.nullBitmap == NULL) { return terrno; } char *bitmap = udfCol->colData.fixLenCol.nullBitmap; @@ -927,11 +987,11 @@ int32_t convertUdfColumnToDataBlock(SUdfColumn *udfCol, SSDataBlock *block) { code = bdGetColumnInfoData(block, 0, &col); TAOS_CHECK_GOTO(code, &lino, _exit); - for (int i = 0; i < udfCol->colData.numOfRows; ++i) { + for (int32_t i = 0; i < udfCol->colData.numOfRows; ++i) { if (udfColDataIsNull(udfCol, i)) { colDataSetNULL(col, i); } else { - char* data = udfColDataGetData(udfCol, i); + char *data = udfColDataGetData(udfCol, i); code = colDataSetVal(col, i, data, false); TAOS_CHECK_GOTO(code, &lino, _exit); } @@ -953,32 +1013,32 @@ int32_t convertScalarParamToDataBlock(SScalarParam *input, int32_t numOfCols, SS } // create the basic block info structure - for(int32_t i = 0; i < numOfCols; ++i) { - SColumnInfoData* pInfo = input[i].columnData; - SColumnInfoData d = {0}; + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData *pInfo = input[i].columnData; + SColumnInfoData d = {0}; d.info = pInfo->info; TAOS_CHECK_GOTO(blockDataAppendColInfo(output, &d), &lino, _exit); } - TAOS_CHECK_GOTO(blockDataEnsureCapacity(output, numOfRows), &lino, _exit); + TAOS_CHECK_GOTO(blockDataEnsureCapacity(output, numOfRows), &lino, _exit); - for(int32_t i = 0; i < numOfCols; ++i) { - SColumnInfoData* pDest = taosArrayGet(output->pDataBlock, i); + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData *pDest = taosArrayGet(output->pDataBlock, i); - SColumnInfoData* pColInfoData = input[i].columnData; + SColumnInfoData *pColInfoData = input[i].columnData; TAOS_CHECK_GOTO(colDataAssign(pDest, pColInfoData, input[i].numOfRows, &output->info), &lino, _exit); if (input[i].numOfRows < numOfRows) { int32_t startRow = input[i].numOfRows; - int expandRows = numOfRows - startRow; - bool isNull = colDataIsNull_s(pColInfoData, (input+i)->numOfRows - 1); + int32_t expandRows = numOfRows - startRow; + bool isNull = colDataIsNull_s(pColInfoData, (input + i)->numOfRows - 1); if (isNull) { colDataSetNNULL(pDest, startRow, expandRows); } else { - char* src = colDataGetData(pColInfoData, (input + i)->numOfRows - 1); - for (int j = 0; j < expandRows; ++j) { - TAOS_CHECK_GOTO(colDataSetVal(pDest, startRow+j, src, false), &lino, _exit); + char *src = colDataGetData(pColInfoData, (input + i)->numOfRows - 1); + for (int32_t j = 0; j < expandRows; ++j) { + TAOS_CHECK_GOTO(colDataSetVal(pDest, startRow + j, src, false), &lino, _exit); } } } @@ -1000,7 +1060,7 @@ int32_t convertDataBlockToScalarParm(SSDataBlock *input, SScalarParam *output) { output->numOfRows = input->info.rows; output->columnData = taosMemoryMalloc(sizeof(SColumnInfoData)); - if(output->columnData == NULL) { + if (output->columnData == NULL) { return terrno; } memcpy(output->columnData, taosArrayGet(input->pDataBlock, 0), sizeof(SColumnInfoData)); @@ -1012,11 +1072,11 @@ int32_t convertDataBlockToScalarParm(SSDataBlock *input, SScalarParam *output) { ////////////////////////////////////////////////////////////////////////////////////////////////////////////// // memory layout |---SUdfAggRes----|-----final result-----|---inter result----| typedef struct SUdfAggRes { - int8_t finalResNum; - int8_t interResNum; + int8_t finalResNum; + int8_t interResNum; int32_t interResBufLen; - char *finalResBuf; - char *interResBuf; + char *finalResBuf; + char *interResBuf; } SUdfAggRes; void onUdfcPipeClose(uv_handle_t *handle); @@ -1026,8 +1086,8 @@ bool isUdfcUvMsgComplete(SClientConnBuf *connBuf); void udfcUvHandleRsp(SClientUvConn *conn); void udfcUvHandleError(SClientUvConn *conn); void onUdfcPipeRead(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf); -void onUdfcPipeWrite(uv_write_t *write, int status); -void onUdfcPipeConnect(uv_connect_t *connect, int status); +void onUdfcPipeWrite(uv_write_t *write, int32_t status); +void onUdfcPipeConnect(uv_connect_t *connect, int32_t status); int32_t udfcInitializeUvTask(SClientUdfTask *task, int8_t uvTaskType, SClientUvTaskNode *uvTask); int32_t udfcQueueUvTask(SClientUvTaskNode *uvTask); int32_t udfcStartUvTask(SClientUvTaskNode *uvTask); @@ -1037,7 +1097,7 @@ void udfStopAsyncCb(uv_async_t *async); void constructUdfService(void *argsThread); int32_t udfcRunUdfUvTask(SClientUdfTask *task, int8_t uvTaskType); int32_t doSetupUdf(char udfName[], UdfcFuncHandle *funcHandle); -int compareUdfcFuncSub(const void *elem1, const void *elem2); +int32_t compareUdfcFuncSub(const void *elem1, const void *elem2); int32_t doTeardownUdf(UdfcFuncHandle handle); int32_t callUdf(UdfcFuncHandle handle, int8_t callType, SSDataBlock *input, SUdfInterBuf *state, SUdfInterBuf *state2, @@ -1062,9 +1122,9 @@ int32_t udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pRes int32_t udfAggProcess(struct SqlFunctionCtx *pCtx); int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock *pBlock); -void cleanupNotExpiredUdfs(); -void cleanupExpiredUdfs(); -int compareUdfcFuncSub(const void *elem1, const void *elem2) { +void cleanupNotExpiredUdfs(); +void cleanupExpiredUdfs(); +int32_t compareUdfcFuncSub(const void *elem1, const void *elem2) { SUdfcFuncStub *stub1 = (SUdfcFuncStub *)elem1; SUdfcFuncStub *stub2 = (SUdfcFuncStub *)elem2; return strcmp(stub1->udfName, stub2->udfName); @@ -1150,21 +1210,22 @@ void releaseUdfFuncHandle(char *udfName, UdfcFuncHandle handle) { void cleanupExpiredUdfs() { int32_t i = 0; SArray *expiredUdfStubs = taosArrayInit(16, sizeof(SUdfcFuncStub)); - if(expiredUdfStubs == NULL) { + if (expiredUdfStubs == NULL) { fnError("cleanupExpiredUdfs: failed to init array"); return; } while (i < taosArrayGetSize(gUdfcProxy.expiredUdfStubs)) { SUdfcFuncStub *stub = taosArrayGet(gUdfcProxy.expiredUdfStubs, i); if (stub->refCount == 0) { - fnInfo("tear down udf. expired. udf name: %s, handle: %p, ref count: %d", stub->udfName, stub->handle, stub->refCount); + fnInfo("tear down udf. expired. udf name: %s, handle: %p, ref count: %d", stub->udfName, stub->handle, + stub->refCount); (void)doTeardownUdf(stub->handle); } else { - fnInfo("udf still in use. expired. udf name: %s, ref count: %d, create time: %" PRId64 ", handle: %p", stub->udfName, - stub->refCount, stub->createTime, stub->handle); + fnInfo("udf still in use. expired. udf name: %s, ref count: %d, create time: %" PRId64 ", handle: %p", + stub->udfName, stub->refCount, stub->createTime, stub->handle); UdfcFuncHandle handle = stub->handle; if (handle != NULL && ((SUdfcUvSession *)handle)->udfUvPipe != NULL) { - if(taosArrayPush(expiredUdfStubs, stub) == NULL) { + if (taosArrayPush(expiredUdfStubs, stub) == NULL) { fnError("cleanupExpiredUdfs: failed to push udf stub to array"); } } else { @@ -1347,7 +1408,8 @@ int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) { return code; } - SUdfInterBuf state = {.buf = udfRes->interResBuf, .bufLen = udfRes->interResBufLen, .numOfResult = udfRes->interResNum}; + SUdfInterBuf state = { + .buf = udfRes->interResBuf, .bufLen = udfRes->interResBufLen, .numOfResult = udfRes->interResNum}; SUdfInterBuf newState = {0}; udfCode = doCallUdfAggProcess(session, inputBlock, &state, &newState); @@ -1391,8 +1453,9 @@ int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock *pBlock) { udfRes->interResBuf = (char *)udfRes + sizeof(SUdfAggRes) + session->bytes; SUdfInterBuf resultBuf = {0}; - SUdfInterBuf state = {.buf = udfRes->interResBuf, .bufLen = udfRes->interResBufLen, .numOfResult = udfRes->interResNum}; - int32_t udfCallCode = 0; + SUdfInterBuf state = { + .buf = udfRes->interResBuf, .bufLen = udfRes->interResBufLen, .numOfResult = udfRes->interResNum}; + int32_t udfCallCode = 0; udfCallCode = doCallUdfAggFinalize(session, &state, &resultBuf); if (udfCallCode != 0) { fnError("udfAggFinalize error. doCallUdfAggFinalize step. udf code:%d", udfCallCode); @@ -1448,7 +1511,7 @@ int32_t udfcGetUdfTaskResultFromUvTask(SClientUdfTask *task, SClientUvTaskNode * SUdfResponse rsp = {0}; void *buf = decodeUdfResponse(uvTask->rspBuf.base, &rsp); code = rsp.code; - if(code != 0) { + if (code != 0) { fnError("udfc get udf task result failure. code: %d", code); } @@ -1474,18 +1537,18 @@ int32_t udfcGetUdfTaskResultFromUvTask(SClientUdfTask *task, SClientUvTaskNode * taosMemoryFree(uvTask->rspBuf.base); } else { code = uvTask->errCode; - if(code != 0) { + if (code != 0) { fnError("udfc get udf task result failure. code: %d, line:%d", code, __LINE__); } } } else if (uvTask->type == UV_TASK_CONNECT) { code = uvTask->errCode; - if(code != 0) { + if (code != 0) { fnError("udfc get udf task result failure. code: %d, line:%d", code, __LINE__); } } else if (uvTask->type == UV_TASK_DISCONNECT) { code = uvTask->errCode; - if(code != 0) { + if (code != 0) { fnError("udfc get udf task result failure. code: %d, line:%d", code, __LINE__); } } @@ -1620,7 +1683,7 @@ void onUdfcPipeRead(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf) { } } -void onUdfcPipeWrite(uv_write_t *write, int status) { +void onUdfcPipeWrite(uv_write_t *write, int32_t status) { SClientUvConn *conn = write->data; if (status < 0) { fnError("udfc client connection %p write failed. status: %d(%s)", conn, status, uv_strerror(status)); @@ -1631,7 +1694,7 @@ void onUdfcPipeWrite(uv_write_t *write, int status) { taosMemoryFree(write); } -void onUdfcPipeConnect(uv_connect_t *connect, int status) { +void onUdfcPipeConnect(uv_connect_t *connect, int32_t status) { SClientUvTaskNode *uvTask = connect->data; if (status != 0) { fnError("client connect error, task seq: %" PRId64 ", code: %s", uvTask->seqNum, uv_strerror(status)); @@ -1639,7 +1702,7 @@ void onUdfcPipeConnect(uv_connect_t *connect, int status) { uvTask->errCode = status; int32_t code = uv_read_start((uv_stream_t *)uvTask->pipe, udfcAllocateBuffer, onUdfcPipeRead); - if(code != 0) { + if (code != 0) { fnError("udfc client connection %p read start failed. code: %d(%s)", uvTask->pipe, code, uv_strerror(code)); uvTask->errCode = code; } @@ -1678,13 +1741,12 @@ int32_t udfcInitializeUvTask(SClientUdfTask *task, int8_t uvTaskType, SClientUvT } request.msgLen = bufLen; void *bufBegin = taosMemoryMalloc(bufLen); - if(bufBegin == NULL) { + if (bufBegin == NULL) { fnError("udfc create uv task, malloc buffer failed. size: %d", bufLen); return terrno; } void *buf = bufBegin; - if(encodeUdfRequest(&buf, &request) <= 0) - { + if (encodeUdfRequest(&buf, &request) <= 0) { fnError("udfc create uv task, encode request failed. size: %d", bufLen); taosMemoryFree(bufBegin); return TSDB_CODE_UDF_UV_EXEC_FAILURE; @@ -1695,9 +1757,8 @@ int32_t udfcInitializeUvTask(SClientUdfTask *task, int8_t uvTaskType, SClientUvT } else if (uvTaskType == UV_TASK_DISCONNECT) { uvTask->pipe = task->session->udfUvPipe; } - if (uv_sem_init(&uvTask->taskSem, 0) != 0) - { - if (uvTaskType == UV_TASK_REQ_RSP) { + if (uv_sem_init(&uvTask->taskSem, 0) != 0) { + if (uvTaskType == UV_TASK_REQ_RSP) { taosMemoryFree(uvTask->reqBuf.base); } fnError("udfc create uv task, init semaphore failed."); @@ -1733,7 +1794,7 @@ int32_t udfcStartUvTask(SClientUvTaskNode *uvTask) { switch (uvTask->type) { case UV_TASK_CONNECT: { uv_pipe_t *pipe = taosMemoryMalloc(sizeof(uv_pipe_t)); - if(pipe == NULL) { + if (pipe == NULL) { fnError("udfc event loop start connect task malloc pipe failed."); return terrno; } @@ -1745,7 +1806,7 @@ int32_t udfcStartUvTask(SClientUvTaskNode *uvTask) { uvTask->pipe = pipe; SClientUvConn *conn = taosMemoryCalloc(1, sizeof(SClientUvConn)); - if(conn == NULL) { + if (conn == NULL) { fnError("udfc event loop start connect task malloc conn failed."); taosMemoryFree(pipe); return terrno; @@ -1760,7 +1821,7 @@ int32_t udfcStartUvTask(SClientUvTaskNode *uvTask) { pipe->data = conn; uv_connect_t *connReq = taosMemoryMalloc(sizeof(uv_connect_t)); - if(connReq == NULL) { + if (connReq == NULL) { fnError("udfc event loop start connect task malloc connReq failed."); taosMemoryFree(pipe); taosMemoryFree(conn); @@ -1777,14 +1838,14 @@ int32_t udfcStartUvTask(SClientUvTaskNode *uvTask) { code = TSDB_CODE_UDF_PIPE_NOT_EXIST; } else { uv_write_t *write = taosMemoryMalloc(sizeof(uv_write_t)); - if(write == NULL) { + if (write == NULL) { fnError("udfc event loop start req_rsp task malloc write failed."); return terrno; } write->data = pipe->data; QUEUE *connTaskQueue = &((SClientUvConn *)pipe->data)->taskQueue; QUEUE_INSERT_TAIL(connTaskQueue, &uvTask->connTaskQueue); - int err = uv_write(write, (uv_stream_t *)pipe, &uvTask->reqBuf, 1, onUdfcPipeWrite); + int32_t err = uv_write(write, (uv_stream_t *)pipe, &uvTask->reqBuf, 1, onUdfcPipeWrite); if (err != 0) { taosMemoryFree(write); fnError("udfc event loop start req_rsp task uv_write failed. uvtask: %p, code: %s", uvTask, uv_strerror(err)); @@ -1874,7 +1935,7 @@ void udfStopAsyncCb(uv_async_t *async) { } void constructUdfService(void *argsThread) { - int32_t code = 0, lino = 0; + int32_t code = 0, lino = 0; SUdfcProxy *udfc = (SUdfcProxy *)argsThread; code = uv_loop_init(&udfc->uvLoop); TAOS_CHECK_GOTO(code, &lino, _exit); @@ -1891,7 +1952,7 @@ void constructUdfService(void *argsThread) { QUEUE_INIT(&udfc->uvProcTaskQueue); (void)uv_barrier_wait(&udfc->initBarrier); // TODO return value of uv_run - int num = uv_run(&udfc->uvLoop, UV_RUN_DEFAULT); + int32_t num = uv_run(&udfc->uvLoop, UV_RUN_DEFAULT); fnInfo("udfc uv loop exit. active handle num: %d", num); (void)uv_loop_close(&udfc->uvLoop); @@ -1909,7 +1970,7 @@ void constructUdfService(void *argsThread) { int32_t udfcOpen() { int32_t code = 0, lino = 0; - int8_t old = atomic_val_compare_exchange_8(&gUdfcProxy.initialized, 0, 1); + int8_t old = atomic_val_compare_exchange_8(&gUdfcProxy.initialized, 0, 1); if (old == 1) { return 0; } @@ -1927,12 +1988,12 @@ int32_t udfcOpen() { code = uv_mutex_init(&proxy->udfStubsMutex); TAOS_CHECK_GOTO(code, &lino, _exit); proxy->udfStubs = taosArrayInit(8, sizeof(SUdfcFuncStub)); - if(proxy->udfStubs == NULL) { + if (proxy->udfStubs == NULL) { fnError("udfc init failed. udfStubs: %p", proxy->udfStubs); return -1; } proxy->expiredUdfStubs = taosArrayInit(8, sizeof(SUdfcFuncStub)); - if(proxy->expiredUdfStubs == NULL) { + if (proxy->expiredUdfStubs == NULL) { taosArrayDestroy(proxy->udfStubs); fnError("udfc init failed. expiredUdfStubs: %p", proxy->expiredUdfStubs); return -1; @@ -1956,10 +2017,10 @@ int32_t udfcClose() { SUdfcProxy *udfc = &gUdfcProxy; udfc->udfcState = UDFC_STATE_STOPPING; - if(uv_async_send(&udfc->loopStopAsync) != 0) { + if (uv_async_send(&udfc->loopStopAsync) != 0) { fnError("udfc close error to send stop async"); } - if(uv_thread_join(&udfc->loopThread) != 0 ) { + if (uv_thread_join(&udfc->loopThread) != 0) { fnError("udfc close errir to join loop thread"); } uv_mutex_destroy(&udfc->taskQueueMutex); @@ -1974,9 +2035,9 @@ int32_t udfcClose() { } int32_t udfcRunUdfUvTask(SClientUdfTask *task, int8_t uvTaskType) { - int32_t code = 0, lino = 0; + int32_t code = 0, lino = 0; SClientUvTaskNode *uvTask = taosMemoryCalloc(1, sizeof(SClientUvTaskNode)); - if(uvTask == NULL) { + if (uvTask == NULL) { fnError("udfc client task: %p failed to allocate memory for uvTask", task); return terrno; } @@ -2006,14 +2067,14 @@ int32_t udfcRunUdfUvTask(SClientUdfTask *task, int8_t uvTaskType) { } int32_t doSetupUdf(char udfName[], UdfcFuncHandle *funcHandle) { - int32_t code = TSDB_CODE_SUCCESS, lino = 0; + int32_t code = TSDB_CODE_SUCCESS, lino = 0; SClientUdfTask *task = taosMemoryCalloc(1, sizeof(SClientUdfTask)); - if(task == NULL) { + if (task == NULL) { fnError("doSetupUdf, failed to allocate memory for task"); return terrno; } task->session = taosMemoryCalloc(1, sizeof(SUdfcUvSession)); - if(task->session == NULL) { + if (task->session == NULL) { fnError("doSetupUdf, failed to allocate memory for session"); taosMemoryFree(task); return terrno; @@ -2059,7 +2120,7 @@ int32_t callUdf(UdfcFuncHandle handle, int8_t callType, SSDataBlock *input, SUdf return TSDB_CODE_UDF_PIPE_NOT_EXIST; } SClientUdfTask *task = taosMemoryCalloc(1, sizeof(SClientUdfTask)); - if(task == NULL) { + if (task == NULL) { fnError("udfc call udf. failed to allocate memory for task"); return terrno; } @@ -2163,8 +2224,8 @@ int32_t doCallUdfAggFinalize(UdfcFuncHandle handle, SUdfInterBuf *interBuf, SUdf int32_t doCallUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t numOfCols, SScalarParam *output) { int8_t callType = TSDB_UDF_CALL_SCALA_PROC; SSDataBlock inputBlock = {0}; - int32_t code = convertScalarParamToDataBlock(input, numOfCols, &inputBlock); - if(code != 0) { + int32_t code = convertScalarParamToDataBlock(input, numOfCols, &inputBlock); + if (code != 0) { fnError("doCallUdfScalarFunc, convertScalarParamToDataBlock failed. code: %d", code); return code; } @@ -2174,13 +2235,13 @@ int32_t doCallUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t err = convertDataBlockToScalarParm(&resultBlock, output); taosArrayDestroy(resultBlock.pDataBlock); } - + blockDataFreeRes(&inputBlock); return err; } int32_t doTeardownUdf(UdfcFuncHandle handle) { - int32_t code = TSDB_CODE_SUCCESS, lino = 0;; + int32_t code = TSDB_CODE_SUCCESS, lino = 0; SUdfcUvSession *session = (SUdfcUvSession *)handle; if (session->udfUvPipe == NULL) { @@ -2190,7 +2251,7 @@ int32_t doTeardownUdf(UdfcFuncHandle handle) { } SClientUdfTask *task = taosMemoryCalloc(1, sizeof(SClientUdfTask)); - if(task == NULL) { + if (task == NULL) { fnError("doTeardownUdf, failed to allocate memory for task"); taosMemoryFree(session); return terrno; diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index c360cf68949..6eef99e1f82 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -1217,7 +1217,7 @@ int32_t udfdOpenClientRpc() { connLimitNum = TMIN(connLimitNum, 500); rpcInit.connLimitNum = connLimitNum; rpcInit.timeToGetConn = tsTimeToGetAvailableConn; - TAOS_CHECK_RETURN(taosVersionStrToInt(version, &(rpcInit.compatibilityVer))); + TAOS_CHECK_RETURN(taosVersionStrToInt(td_version, &rpcInit.compatibilityVer)); global.clientRpc = rpcOpen(&rpcInit); if (global.clientRpc == NULL) { fnError("failed to init dnode rpc client"); @@ -1470,9 +1470,9 @@ static int32_t udfdParseArgs(int32_t argc, char *argv[]) { } static void udfdPrintVersion() { - (void)printf("udfd version: %s compatible_version: %s\n", version, compatible_version); - (void)printf("git: %s\n", gitinfo); - (void)printf("build: %s\n", buildinfo); + (void)printf("udfd version: %s compatible_version: %s\n", td_version, td_compatible_version); + (void)printf("git: %s\n", td_gitinfo); + (void)printf("build: %s\n", td_buildinfo); } static int32_t udfdInitLog() { diff --git a/source/libs/index/test/CMakeLists.txt b/source/libs/index/test/CMakeLists.txt index eff74f93d24..e8a8194ea2a 100644 --- a/source/libs/index/test/CMakeLists.txt +++ b/source/libs/index/test/CMakeLists.txt @@ -7,160 +7,159 @@ IF(NOT TD_DARWIN) add_executable(idxFstUtilUT "") target_sources(idxTest - PRIVATE - "indexTests.cc" + PRIVATE + "indexTests.cc" ) target_sources(idxFstTest - PRIVATE - "fstTest.cc" + PRIVATE + "fstTest.cc" ) target_sources(idxFstUT - PRIVATE - "fstUT.cc" + PRIVATE + "fstUT.cc" ) target_sources(idxUtilUT - PRIVATE - "utilUT.cc" + PRIVATE + "utilUT.cc" ) target_sources(idxJsonUT - PRIVATE - "jsonUT.cc" + PRIVATE + "jsonUT.cc" ) target_sources(idxFstUtilUT - PRIVATE - "fstUtilUT.cc" - ) - - target_include_directories (idxTest - PUBLIC - "${TD_SOURCE_DIR}/include/libs/index" - "${CMAKE_CURRENT_SOURCE_DIR}/../inc" - ) - target_include_directories (idxFstTest - PUBLIC - "${TD_SOURCE_DIR}/include/libs/index" - "${CMAKE_CURRENT_SOURCE_DIR}/../inc" - ) + PRIVATE + "fstUtilUT.cc" + ) + + target_include_directories(idxTest + PUBLIC + "${TD_SOURCE_DIR}/include/libs/index" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" + ) + target_include_directories(idxFstTest + PUBLIC + "${TD_SOURCE_DIR}/include/libs/index" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" + ) target_sources(idxJsonUT - PRIVATE - "jsonUT.cc" + PRIVATE + "jsonUT.cc" ) - target_include_directories (idxTest + target_include_directories(idxTest PUBLIC - "${TD_SOURCE_DIR}/include/libs/index" + "${TD_SOURCE_DIR}/include/libs/index" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" - ) - target_include_directories (idxFstTest + ) + target_include_directories(idxFstTest PUBLIC - "${TD_SOURCE_DIR}/include/libs/index" + "${TD_SOURCE_DIR}/include/libs/index" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" - ) + ) - target_include_directories (idxFstUT + target_include_directories(idxFstUT PUBLIC - "${TD_SOURCE_DIR}/include/libs/index" + "${TD_SOURCE_DIR}/include/libs/index" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" - ) + ) - target_include_directories (idxUtilUT + target_include_directories(idxUtilUT PUBLIC - "${TD_SOURCE_DIR}/include/libs/index" + "${TD_SOURCE_DIR}/include/libs/index" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" - ) + ) - target_include_directories (idxJsonUT - PUBLIC - "${TD_SOURCE_DIR}/include/libs/index" - "${CMAKE_CURRENT_SOURCE_DIR}/../inc" - ) - target_include_directories (idxFstUtilUT - PUBLIC - "${TD_SOURCE_DIR}/include/libs/index" - "${CMAKE_CURRENT_SOURCE_DIR}/../inc" - ) - target_include_directories (idxJsonUT + target_include_directories(idxJsonUT + PUBLIC + "${TD_SOURCE_DIR}/include/libs/index" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" + ) + target_include_directories(idxFstUtilUT PUBLIC - "${TD_SOURCE_DIR}/include/libs/index" + "${TD_SOURCE_DIR}/include/libs/index" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" - ) + ) + target_include_directories(idxJsonUT + PUBLIC + "${TD_SOURCE_DIR}/include/libs/index" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" + ) - target_link_libraries (idxTest - os + target_link_libraries(idxTest + os util common gtest_main index ) - target_link_libraries (idxFstTest - os + target_link_libraries(idxFstTest + os util common gtest_main index ) - target_link_libraries (idxFstUT - os + target_link_libraries(idxFstUT + os util common gtest_main index ) - target_link_libraries (idxTest - os + target_link_libraries(idxTest + os util common gtest_main index ) - target_link_libraries (idxFstTest - os + target_link_libraries(idxFstTest + os util common gtest_main index ) - target_link_libraries (idxFstUT - os + target_link_libraries(idxFstUT + os util common gtest_main index ) - target_link_libraries (idxUtilUT - os + target_link_libraries(idxUtilUT + os util common gtest_main index ) - target_link_libraries (idxJsonUT - os + target_link_libraries(idxJsonUT + os util common gtest_main index ) - target_link_libraries (idxFstUtilUT - os + target_link_libraries(idxFstUtilUT + os util common gtest_main index ) - + add_test( NAME idxJsonUT - COMMAND idxJsonUT + COMMAND idxJsonUT ) add_test( - NAME idxFstUtilUT - COMMAND idxFstUtilUT - + NAME idxFstUtilUT + COMMAND idxFstUtilUT ) add_test( @@ -168,15 +167,15 @@ IF(NOT TD_DARWIN) COMMAND idxTest ) add_test( - NAME idxUtilUT - COMMAND idxUtilUT + NAME idxUtilUT + COMMAND idxUtilUT ) add_test( - NAME idxFstUT - COMMAND idxFstUT + NAME idxFstUT + COMMAND idxFstUT ) add_test( NAME idxFstTest - COMMAND idxFstTest + COMMAND idxFstTest ) -ENDIF () +ENDIF() diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index b2b06e6beab..866b105ca17 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -175,8 +175,8 @@ static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARBINARY: case TSDB_DATA_TYPE_GEOMETRY: { - int32_t len = pSrc->node.resType.bytes + 1; - pDst->datum.p = taosMemoryCalloc(1, len); + int32_t len = varDataTLen(pSrc->datum.p); + pDst->datum.p = taosMemoryCalloc(1, len + 1); if (NULL == pDst->datum.p) { return terrno; } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 6830dd01b6a..af51eff8a9f 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -703,6 +703,8 @@ int32_t nodesMakeNode(ENodeType type, SNode** ppNodeOut) { code = makeNode(type, sizeof(SGroupSortPhysiNode), &pNode); break; case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: code = makeNode(type, sizeof(SIntervalPhysiNode), &pNode); break; + case QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL: + code = makeNode(type, sizeof(SMergeIntervalPhysiNode), &pNode); break; case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: code = makeNode(type, sizeof(SMergeAlignedIntervalPhysiNode), &pNode); break; case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: @@ -1606,10 +1608,14 @@ void nodesDestroyNode(SNode* pNode) { case QUERY_NODE_PHYSICAL_PLAN_HASH_JOIN: { SHashJoinPhysiNode* pPhyNode = (SHashJoinPhysiNode*)pNode; destroyPhysiNode((SPhysiNode*)pPhyNode); + nodesDestroyNode(pPhyNode->pWindowOffset); + nodesDestroyNode(pPhyNode->pJLimit); nodesDestroyList(pPhyNode->pOnLeft); nodesDestroyList(pPhyNode->pOnRight); nodesDestroyNode(pPhyNode->leftPrimExpr); nodesDestroyNode(pPhyNode->rightPrimExpr); + nodesDestroyNode(pPhyNode->pLeftOnCond); + nodesDestroyNode(pPhyNode->pRightOnCond); nodesDestroyNode(pPhyNode->pFullOnCond); nodesDestroyList(pPhyNode->pTargets); @@ -1617,8 +1623,6 @@ void nodesDestroyNode(SNode* pNode) { nodesDestroyNode(pPhyNode->pColEqCond); nodesDestroyNode(pPhyNode->pTagEqCond); - nodesDestroyNode(pPhyNode->pLeftOnCond); - nodesDestroyNode(pPhyNode->pRightOnCond); break; } case QUERY_NODE_PHYSICAL_PLAN_HASH_AGG: { @@ -1652,6 +1656,7 @@ void nodesDestroyNode(SNode* pNode) { break; } case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: @@ -2056,6 +2061,8 @@ void* nodesGetValueFromNode(SValueNode* pNode) { int32_t nodesSetValueNodeValue(SValueNode* pNode, void* value) { switch (pNode->node.resType.type) { + case TSDB_DATA_TYPE_NULL: + break; case TSDB_DATA_TYPE_BOOL: pNode->datum.b = *(bool*)value; *(bool*)&pNode->typeData = pNode->datum.b; @@ -2107,7 +2114,10 @@ int32_t nodesSetValueNodeValue(SValueNode* pNode, void* value) { case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARBINARY: + case TSDB_DATA_TYPE_DECIMAL: case TSDB_DATA_TYPE_JSON: + case TSDB_DATA_TYPE_BLOB: + case TSDB_DATA_TYPE_MEDIUMBLOB: case TSDB_DATA_TYPE_GEOMETRY: pNode->datum.p = (char*)value; break; diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 597ee5f5d2c..3caa8da80fd 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -69,6 +69,7 @@ typedef enum EDatabaseOptionType { DB_OPTION_S3_COMPACT, DB_OPTION_KEEP_TIME_OFFSET, DB_OPTION_ENCRYPT_ALGORITHM, + DB_OPTION_DNODES, } EDatabaseOptionType; typedef enum ETableOptionType { diff --git a/source/libs/parser/inc/parInt.h b/source/libs/parser/inc/parInt.h index c231de653c9..5999ada70f1 100644 --- a/source/libs/parser/inc/parInt.h +++ b/source/libs/parser/inc/parInt.h @@ -28,6 +28,8 @@ extern "C" { #define QUERY_SMA_OPTIMIZE_DISABLE 0 #define QUERY_SMA_OPTIMIZE_ENABLE 1 +#define QUERY_NUMBER_MAX_DISPLAY_LEN 65 + int32_t parseInsertSql(SParseContext* pCxt, SQuery** pQuery, SCatalogReq* pCatalogReq, const SMetaData* pMetaData); int32_t continueCreateTbFromFile(SParseContext* pCxt, SQuery** pQuery); int32_t parse(SParseContext* pParseCxt, SQuery** pQuery); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 067a8e3ccc1..635e9f570f7 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -286,6 +286,7 @@ db_options(A) ::= db_options(B) S3_KEEPLOCAL NK_VARIABLE(C). db_options(A) ::= db_options(B) S3_COMPACT NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_S3_COMPACT, &C); } db_options(A) ::= db_options(B) KEEP_TIME_OFFSET NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_KEEP_TIME_OFFSET, &C); } db_options(A) ::= db_options(B) ENCRYPT_ALGORITHM NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_ENCRYPT_ALGORITHM, &C); } +db_options(A) ::= db_options(B) DNODES NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_DNODES, &C); } alter_db_options(A) ::= alter_db_option(B). { A = createAlterDatabaseOptions(pCxt); A = setAlterDatabaseOption(pCxt, A, &B); } alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setAlterDatabaseOption(pCxt, B, &C); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index afc5ed6463b..269e9e4a04f 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -1799,6 +1799,7 @@ SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { pOptions->s3Compact = TSDB_DEFAULT_S3_COMPACT; pOptions->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR; pOptions->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO; + pOptions->dnodeListStr[0] = 0; return (SNode*)pOptions; _err: return NULL; @@ -1842,6 +1843,7 @@ SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) { pOptions->s3Compact = -1; pOptions->withArbitrator = -1; pOptions->encryptAlgorithm = -1; + pOptions->dnodeListStr[0] = 0; return (SNode*)pOptions; _err: return NULL; @@ -1981,6 +1983,14 @@ static SNode* setDatabaseOptionImpl(SAstCreateContext* pCxt, SNode* pOptions, ED COPY_STRING_FORM_STR_TOKEN(pDbOptions->encryptAlgorithmStr, (SToken*)pVal); pDbOptions->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO; break; + case DB_OPTION_DNODES: + if (((SToken*)pVal)->n >= TSDB_DNODE_LIST_LEN) { + snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "the dnode list is too long (should less than %d)", + TSDB_DNODE_LIST_LEN); + pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR; + } else { + COPY_STRING_FORM_STR_TOKEN(pDbOptions->dnodeListStr, (SToken*)pVal); + } default: break; } diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index 1c26a7c70ed..4b91f01a8c8 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -30,7 +30,7 @@ typedef struct SInsertParseContext { bool forceUpdate; bool needTableTagVal; bool needRequest; // whether or not request server - bool isStmtBind; // whether is stmt bind + bool isStmtBind; // whether is stmt bind } SInsertParseContext; typedef int32_t (*_row_append_fn_t)(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param); @@ -757,7 +757,7 @@ int32_t parseTagValue(SMsgBuf* pMsgBuf, const char** pSql, uint8_t precision, SS STagVal val = {0}; int32_t code = parseTagToken(pSql, pToken, pTagSchema, precision, &val, pMsgBuf); if (TSDB_CODE_SUCCESS == code) { - if (NULL == taosArrayPush(pTagVals, &val)){ + if (NULL == taosArrayPush(pTagVals, &val)) { code = terrno; } } @@ -775,11 +775,14 @@ static int32_t buildCreateTbReq(SVnodeModifyOpStmt* pStmt, STag* pTag, SArray* p return terrno; } return insBuildCreateTbReq(pStmt->pCreateTblReq, pStmt->targetTableName.tname, pTag, pStmt->pTableMeta->suid, - pStmt->usingTableName.tname, pTagName, pStmt->pTableMeta->tableInfo.numOfTags, - TSDB_DEFAULT_TABLE_TTL); + pStmt->usingTableName.tname, pTagName, pStmt->pTableMeta->tableInfo.numOfTags, + TSDB_DEFAULT_TABLE_TTL); } int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, SMsgBuf* pMsgBuf, int8_t type) { + if (pToken->type == TK_NK_QUESTION) { + return buildInvalidOperationMsg(pMsgBuf, "insert into super table syntax is not supported for stmt"); + } 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 && pToken->type != TK_NK_BIN && @@ -810,7 +813,7 @@ typedef struct SRewriteTagCondCxt { static int32_t rewriteTagCondColumnImpl(STagVal* pVal, SNode** pNode) { SValueNode* pValue = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pValue); + int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pValue); if (NULL == pValue) { return code; } @@ -1041,7 +1044,7 @@ static int32_t storeChildTableMeta(SInsertParseContext* pCxt, SVnodeModifyOpStmt return TSDB_CODE_OUT_OF_MEMORY; } - char tbFName[TSDB_TABLE_FNAME_LEN]; + char tbFName[TSDB_TABLE_FNAME_LEN]; int32_t code = tNameExtractFullName(&pStmt->targetTableName, tbFName); if (TSDB_CODE_SUCCESS != code) { taosMemoryFree(pBackup); @@ -1236,7 +1239,7 @@ static int32_t getTargetTableMetaAndVgroup(SInsertParseContext* pCxt, SVnodeModi } static int32_t collectUseTable(const SName* pName, SHashObj* pTable) { - char fullName[TSDB_TABLE_FNAME_LEN]; + char fullName[TSDB_TABLE_FNAME_LEN]; int32_t code = tNameExtractFullName(pName, fullName); if (TSDB_CODE_SUCCESS != code) { return code; @@ -1382,7 +1385,7 @@ static int32_t getTableDataCxt(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pS pStmt->pTableMeta, &pStmt->pCreateTblReq, pTableCxt, false, false); } - char tbFName[TSDB_TABLE_FNAME_LEN]; + char tbFName[TSDB_TABLE_FNAME_LEN]; int32_t code = tNameExtractFullName(&pStmt->targetTableName, tbFName); if (TSDB_CODE_SUCCESS != code) { return code; @@ -1824,37 +1827,49 @@ static int32_t doGetStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt* code = generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_INVALID_COLUMNS_NUM); break; } - 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, precision, pVal); - if (TK_NK_VARIABLE == pToken->type) { - code = buildInvalidOperationMsg(&pCxt->msg, "not expected row value"); - } - } else if (pCols->pColIndex[i] < tbnameIdx) { - const SSchema* pTagSchema = &pSchemas[pCols->pColIndex[i]]; - if (canParseTagsAfter) { - tagTokens[(*pNumOfTagTokens)] = *pToken; - tagSchemas[(*pNumOfTagTokens)] = (SSchema*)pTagSchema; - ++(*pNumOfTagTokens); - } else { - code = checkAndTrimValue(pToken, pCxt->tmpTokenBuf, &pCxt->msg, pTagSchema->type); - if (code == TSDB_CODE_SUCCESS && TK_NK_VARIABLE == pToken->type) { + + if (TK_NK_QUESTION == pToken->type) { + pCxt->isStmtBind = true; + if (pCols->pColIndex[i] == tbnameIdx) { + *bFoundTbName = true; + } + if (NULL == pCxt->pComCxt->pStmtCb) { + code = buildSyntaxErrMsg(&pCxt->msg, "? only used in stmt", pToken->z); + break; + } + } else { + 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, precision, pVal); + if (TK_NK_VARIABLE == pToken->type) { code = buildInvalidOperationMsg(&pCxt->msg, "not expected row value"); } - if (code == TSDB_CODE_SUCCESS) { - code = parseTagValue(&pCxt->msg, ppSql, precision, (SSchema*)pTagSchema, pToken, pTagNames, pTagVals, - &pStbRowsCxt->pTag); + } else if (pCols->pColIndex[i] < tbnameIdx) { + const SSchema* pTagSchema = &pSchemas[pCols->pColIndex[i]]; + if (canParseTagsAfter) { + tagTokens[(*pNumOfTagTokens)] = *pToken; + tagSchemas[(*pNumOfTagTokens)] = (SSchema*)pTagSchema; + ++(*pNumOfTagTokens); + } else { + code = checkAndTrimValue(pToken, pCxt->tmpTokenBuf, &pCxt->msg, pTagSchema->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->msg, ppSql, precision, (SSchema*)pTagSchema, pToken, pTagNames, pTagVals, + &pStbRowsCxt->pTag); + } + } + } else if (pCols->pColIndex[i] == tbnameIdx) { + code = checkAndTrimValue(pToken, pCxt->tmpTokenBuf, &pCxt->msg, TSDB_DATA_TYPE_BINARY); + if (TK_NK_VARIABLE == pToken->type) { + code = buildInvalidOperationMsg(&pCxt->msg, "not expected tbname"); } - } - } else if (pCols->pColIndex[i] == tbnameIdx) { - code = checkAndTrimValue(pToken, pCxt->tmpTokenBuf, &pCxt->msg, TSDB_DATA_TYPE_BINARY); - if (TK_NK_VARIABLE == pToken->type) { - code = buildInvalidOperationMsg(&pCxt->msg, "not expected tbname"); - } - if (code == TSDB_CODE_SUCCESS) { - code = parseTbnameToken(&pCxt->msg, pStbRowsCxt->ctbName.tname, pToken, bFoundTbName); + if (code == TSDB_CODE_SUCCESS) { + code = parseTbnameToken(&pCxt->msg, pStbRowsCxt->ctbName.tname, pToken, bFoundTbName); + } } } @@ -1888,6 +1903,11 @@ static int32_t getStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pS code = buildSyntaxErrMsg(&pCxt->msg, "tbname value expected", pOrigSql); } + if (code == TSDB_CODE_SUCCESS && pStbRowsCxt->ctbName.tname[0] == '\0') { + *pGotRow = true; + return TSDB_CODE_TSC_STMT_TBNAME_ERROR; + } + bool ctbFirst = true; char ctbFName[TSDB_TABLE_FNAME_LEN]; if (code == TSDB_CODE_SUCCESS) { @@ -1923,8 +1943,8 @@ static int32_t processCtbAutoCreationAndCtbMeta(SInsertParseContext* pCxt, SVnod } if (code == TSDB_CODE_SUCCESS) { code = insBuildCreateTbReq(pStbRowsCxt->pCreateCtbReq, pStbRowsCxt->ctbName.tname, pStbRowsCxt->pTag, - pStbRowsCxt->pStbMeta->uid, pStbRowsCxt->stbName.tname, pStbRowsCxt->aTagNames, - getNumOfTags(pStbRowsCxt->pStbMeta), TSDB_DEFAULT_TABLE_TTL); + pStbRowsCxt->pStbMeta->uid, pStbRowsCxt->stbName.tname, pStbRowsCxt->aTagNames, + getNumOfTags(pStbRowsCxt->pStbMeta), TSDB_DEFAULT_TABLE_TTL); pStbRowsCxt->pTag = NULL; } @@ -1933,9 +1953,9 @@ static int32_t processCtbAutoCreationAndCtbMeta(SInsertParseContext* pCxt, SVnod code = tNameExtractFullName(&pStbRowsCxt->ctbName, ctbFName); SVgroupInfo vg; SRequestConnInfo conn = {.pTrans = pCxt->pComCxt->pTransporter, - .requestId = pCxt->pComCxt->requestId, - .requestObjRefId = pCxt->pComCxt->requestRid, - .mgmtEps = pCxt->pComCxt->mgmtEpSet}; + .requestId = pCxt->pComCxt->requestId, + .requestObjRefId = pCxt->pComCxt->requestRid, + .mgmtEps = pCxt->pComCxt->mgmtEpSet}; if (TSDB_CODE_SUCCESS == code) { code = catalogGetTableHashVgroup(pCxt->pComCxt->pCatalog, &conn, &pStbRowsCxt->ctbName, &vg); } @@ -1979,11 +1999,47 @@ static void clearStbRowsDataContext(SStbRowsDataContext* pStbRowsCxt) { taosMemoryFreeClear(pStbRowsCxt->pCreateCtbReq); } +static int32_t parseStbBoundInfo(SVnodeModifyOpStmt* pStmt, SStbRowsDataContext* pStbRowsCxt, + STableDataCxt** ppTableDataCxt) { + char tbFName[TSDB_TABLE_FNAME_LEN]; + int32_t code = tNameExtractFullName(&pStmt->targetTableName, tbFName); + if (TSDB_CODE_SUCCESS != code) { + return code; + } + if (pStmt->usingTableProcessing) { + pStmt->pTableMeta->uid = 0; + } + + code = insGetTableDataCxt(pStmt->pTableBlockHashObj, tbFName, strlen(tbFName), pStmt->pTableMeta, + &pStmt->pCreateTblReq, ppTableDataCxt, false, true); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + insDestroyBoundColInfo(&((*ppTableDataCxt)->boundColsInfo)); + (*ppTableDataCxt)->boundColsInfo = pStbRowsCxt->boundColsInfo; + (*ppTableDataCxt)->boundColsInfo.numOfCols = pStbRowsCxt->boundColsInfo.numOfBound; + (*ppTableDataCxt)->boundColsInfo.numOfBound = pStbRowsCxt->boundColsInfo.numOfBound; + (*ppTableDataCxt)->boundColsInfo.hasBoundCols = pStbRowsCxt->boundColsInfo.hasBoundCols; + (*ppTableDataCxt)->boundColsInfo.pColIndex = taosMemoryCalloc(pStbRowsCxt->boundColsInfo.numOfBound, sizeof(int16_t)); + if (NULL == (*ppTableDataCxt)->boundColsInfo.pColIndex) { + return terrno; + } + (void)memcpy((*ppTableDataCxt)->boundColsInfo.pColIndex, pStbRowsCxt->boundColsInfo.pColIndex, + sizeof(int16_t) * pStmt->pStbRowsCxt->boundColsInfo.numOfBound); + return TSDB_CODE_SUCCESS; +} + static int32_t parseOneStbRow(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, const char** ppSql, SStbRowsDataContext* pStbRowsCxt, bool* pGotRow, SToken* pToken, STableDataCxt** ppTableDataCxt) { bool bFirstTable = false; int32_t code = getStbRowValues(pCxt, pStmt, ppSql, pStbRowsCxt, pGotRow, pToken, &bFirstTable); + + if (code == TSDB_CODE_TSC_STMT_TBNAME_ERROR && *pGotRow) { + return parseStbBoundInfo(pStmt, pStbRowsCxt, ppTableDataCxt); + } + if (code != TSDB_CODE_SUCCESS || !*pGotRow) { return code; } @@ -2176,8 +2232,8 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt if (code == TSDB_CODE_SUCCESS) { SStbRowsDataContext* pStbRowsCxt = rowsDataCxt.pStbRowsCxt; void* pData = pTableDataCxt; - code = taosHashPut(pStmt->pTableCxtHashObj, &pStbRowsCxt->pCtbMeta->uid, sizeof(pStbRowsCxt->pCtbMeta->uid), &pData, - POINTER_BYTES); + code = taosHashPut(pStmt->pTableCxtHashObj, &pStbRowsCxt->pCtbMeta->uid, sizeof(pStbRowsCxt->pCtbMeta->uid), + &pData, POINTER_BYTES); if (TSDB_CODE_SUCCESS != code) { break; } @@ -2249,7 +2305,7 @@ static int32_t parseDataFromFileImpl(SInsertParseContext* pCxt, SVnodeModifyOpSt if (!pStmt->stbSyntax && numOfRows > 0) { void* pData = rowsDataCxt.pTableDataCxt; code = taosHashPut(pStmt->pTableCxtHashObj, &pStmt->pTableMeta->uid, sizeof(pStmt->pTableMeta->uid), &pData, - POINTER_BYTES); + POINTER_BYTES); } return code; @@ -2363,8 +2419,7 @@ static int32_t constructStbRowsDataContext(SVnodeModifyOpStmt* pStmt, SStbRowsDa if (TSDB_CODE_SUCCESS == code) { // col values and bound cols info of STableDataContext is not used pStbRowsCxt->aColVals = taosArrayInit(getNumOfColumns(pStbRowsCxt->pStbMeta), sizeof(SColVal)); - if (!pStbRowsCxt->aColVals) - code = terrno; + if (!pStbRowsCxt->aColVals) code = terrno; } if (TSDB_CODE_SUCCESS == code) { code = insInitColValues(pStbRowsCxt->pStbMeta, pStbRowsCxt->aColVals); @@ -2422,9 +2477,6 @@ static int32_t parseInsertStbClauseBottom(SInsertParseContext* pCxt, SVnodeModif // 1. [(tag1_name, ...)] ... // 2. VALUES ... | FILE ... static int32_t parseInsertTableClauseBottom(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt) { - if (pStmt->stbSyntax && TSDB_QUERY_HAS_TYPE(pStmt->insertType, TSDB_QUERY_TYPE_STMT_INSERT)) { - return buildInvalidOperationMsg(&pCxt->msg, "insert into super table syntax is not supported for stmt"); - } if (!pStmt->stbSyntax) { STableDataCxt* pTableCxt = NULL; int32_t code = parseSchemaClauseBottom(pCxt, pStmt, &pTableCxt); @@ -2511,9 +2563,9 @@ static int32_t checkTableClauseFirstToken(SInsertParseContext* pCxt, SVnodeModif } // db.? situation,ensure that the only thing following the '.' mark is '?' - char *tbNameAfterDbName = strnchr(pTbName->z, '.', pTbName->n, true); + char* tbNameAfterDbName = strnchr(pTbName->z, '.', pTbName->n, true); if ((tbNameAfterDbName != NULL) && (*(tbNameAfterDbName + 1) == '?')) { - char *tbName = NULL; + char* tbName = NULL; if (NULL == pCxt->pComCxt->pStmtCb) { return buildSyntaxErrMsg(&pCxt->msg, "? only used in stmt", pTbName->z); } @@ -2528,7 +2580,8 @@ static int32_t checkTableClauseFirstToken(SInsertParseContext* pCxt, SVnodeModif if (pCxt->isStmtBind) { if (TK_NK_ID == pTbName->type || (tbNameAfterDbName != NULL && *(tbNameAfterDbName + 1) != '?')) { // In SQL statements, the table name has already been specified. - parserWarn("0x%" PRIx64 " table name is specified in sql, ignore the table name in bind param", pCxt->pComCxt->requestId); + parserWarn("0x%" PRIx64 " table name is specified in sql, ignore the table name in bind param", + pCxt->pComCxt->requestId); } } @@ -2614,7 +2667,7 @@ static void destroySubTableHashElem(void* p) { taosMemoryFree(*(STableMeta**)p); static int32_t createVnodeModifOpStmt(SInsertParseContext* pCxt, bool reentry, SNode** pOutput) { SVnodeModifyOpStmt* pStmt = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_VNODE_MODIFY_STMT, (SNode**)&pStmt); + int32_t code = nodesMakeNode(QUERY_NODE_VNODE_MODIFY_STMT, (SNode**)&pStmt); if (NULL == pStmt) { return code; } @@ -2729,7 +2782,7 @@ static int32_t buildTagNameFromMeta(STableMeta* pMeta, SArray** pTagName) { return terrno; } SSchema* pSchema = getTableTagSchema(pMeta); - int32_t code = 0; + int32_t code = 0; for (int32_t i = 0; i < pMeta->tableInfo.numOfTags; ++i) { if (NULL == taosArrayPush(*pTagName, pSchema[i].name)) { code = terrno; @@ -2834,7 +2887,7 @@ static int32_t resetVnodeModifOpStmt(SInsertParseContext* pCxt, SQuery* pQuery) } if (NULL == pStmt->pTableBlockHashObj) { pStmt->pTableBlockHashObj = - taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); } if (NULL == pStmt->pVgroupsHashObj || NULL == pStmt->pTableBlockHashObj) { code = TSDB_CODE_OUT_OF_MEMORY; @@ -2866,7 +2919,7 @@ static int32_t initInsertQuery(SInsertParseContext* pCxt, SCatalogReq* pCatalogR static int32_t setRefreshMeta(SQuery* pQuery) { SVnodeModifyOpStmt* pStmt = (SVnodeModifyOpStmt*)pQuery->pRoot; - int32_t code = 0; + int32_t code = 0; if (taosHashGetSize(pStmt->pTableNameHashObj) > 0) { taosArrayDestroy(pQuery->pTableList); @@ -3065,9 +3118,10 @@ int32_t parseInsertSql(SParseContext* pCxt, SQuery** pQuery, SCatalogReq* pCatal .forceUpdate = (NULL != pCatalogReq ? pCatalogReq->forceUpdate : false), .isStmtBind = pCxt->isStmtBind}; - int32_t code = initInsertQuery(&context, pCatalogReq, pMetaData, pQuery); + int32_t code = initInsertQuery(&context, pCatalogReq, pMetaData, pQuery); + SVnodeModifyOpStmt* pStmt = (SVnodeModifyOpStmt*)((*pQuery)->pRoot); if (TSDB_CODE_SUCCESS == code) { - code = parseInsertSqlImpl(&context, (SVnodeModifyOpStmt*)(*pQuery)->pRoot); + code = parseInsertSqlImpl(&context, pStmt); } if (TSDB_CODE_SUCCESS == code) { code = setNextStageInfo(&context, *pQuery, pCatalogReq); @@ -3076,8 +3130,8 @@ int32_t parseInsertSql(SParseContext* pCxt, SQuery** pQuery, SCatalogReq* pCatal QUERY_EXEC_STAGE_SCHEDULE == (*pQuery)->execStage) { code = setRefreshMeta(*pQuery); } - insDestroyBoundColInfo(&context.tags); + insDestroyBoundColInfo(&context.tags); // if no data to insert, set emptyMode to avoid request server if (!context.needRequest) { (*pQuery)->execMode = QUERY_EXEC_MODE_EMPTY_RESULT; diff --git a/source/libs/parser/src/parInsertStmt.c b/source/libs/parser/src/parInsertStmt.c index ee61611bf27..0979028e6df 100644 --- a/source/libs/parser/src/parInsertStmt.c +++ b/source/libs/parser/src/parInsertStmt.c @@ -242,7 +242,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch } code = insBuildCreateTbReq(pDataBlock->pData->pCreateTbReq, tName, pTag, suid, sTableName, tagName, - pDataBlock->pMeta->tableInfo.numOfTags, TSDB_DEFAULT_TABLE_TTL); + pDataBlock->pMeta->tableInfo.numOfTags, TSDB_DEFAULT_TABLE_TTL); pTag = NULL; end: @@ -594,7 +594,7 @@ int32_t qBindStmtTagsValue2(void* pBlock, void* boundTags, int64_t suid, const c } code = insBuildCreateTbReq(pDataBlock->pData->pCreateTbReq, tName, pTag, suid, sTableName, tagName, - pDataBlock->pMeta->tableInfo.numOfTags, TSDB_DEFAULT_TABLE_TTL); + pDataBlock->pMeta->tableInfo.numOfTags, TSDB_DEFAULT_TABLE_TTL); pTag = NULL; end: @@ -797,6 +797,10 @@ int32_t qBindStmtColsValue2(void* pBlock, SArray* pCols, TAOS_STMT2_BIND* bind, for (int c = 0; c < boundInfo->numOfBound; ++c) { SSchema* pColSchema = &pSchema[boundInfo->pColIndex[c]]; SColData* pCol = taosArrayGet(pCols, c); + if (pCol == NULL || pColSchema == NULL) { + code = buildInvalidOperationMsg(&pBuf, "get column schema or column data failed"); + goto _return; + } if (bind[c].num != rowNum) { code = buildInvalidOperationMsg(&pBuf, "row number in each bind param should be the same"); @@ -886,7 +890,7 @@ int32_t qBindStmtSingleColValue2(void* pBlock, SArray* pCols, TAOS_STMT2_BIND* b int32_t buildBoundFields(int32_t numOfBound, int16_t* boundColumns, SSchema* pSchema, int32_t* fieldNum, TAOS_FIELD_E** fields, uint8_t timePrec) { - if (fields) { + if (fields != NULL) { *fields = taosMemoryCalloc(numOfBound, sizeof(TAOS_FIELD_E)); if (NULL == *fields) { return terrno; @@ -910,6 +914,44 @@ int32_t buildBoundFields(int32_t numOfBound, int16_t* boundColumns, SSchema* pSc return TSDB_CODE_SUCCESS; } +int32_t buildStbBoundFields(SBoundColInfo boundColsInfo, SSchema* pSchema, int32_t* fieldNum, TAOS_FIELD_STB** fields, + STableMeta* pMeta) { + if (fields != NULL) { + *fields = taosMemoryCalloc(boundColsInfo.numOfBound, sizeof(TAOS_FIELD_STB)); + if (NULL == *fields) { + return terrno; + } + + SSchema* schema = &pSchema[boundColsInfo.pColIndex[0]]; + if (TSDB_DATA_TYPE_TIMESTAMP == schema->type) { + (*fields)[0].precision = pMeta->tableInfo.precision; + } + + for (int32_t i = 0; i < boundColsInfo.numOfBound; ++i) { + int16_t idx = boundColsInfo.pColIndex[i]; + + if (idx == pMeta->tableInfo.numOfColumns + pMeta->tableInfo.numOfTags) { + (*fields)[i].field_type = TAOS_FIELD_TBNAME; + tstrncpy((*fields)[i].name, "tbname", sizeof((*fields)[i].name)); + continue; + } else if (idx < pMeta->tableInfo.numOfColumns) { + (*fields)[i].field_type = TAOS_FIELD_COL; + } else { + (*fields)[i].field_type = TAOS_FIELD_TAG; + } + + schema = &pSchema[idx]; + tstrncpy((*fields)[i].name, schema->name, sizeof((*fields)[i].name)); + (*fields)[i].type = schema->type; + (*fields)[i].bytes = schema->bytes; + } + } + + *fieldNum = boundColsInfo.numOfBound; + + return TSDB_CODE_SUCCESS; +} + int32_t qBuildStmtTagFields(void* pBlock, void* boundTags, int32_t* fieldNum, TAOS_FIELD_E** fields) { STableDataCxt* pDataBlock = (STableDataCxt*)pBlock; SBoundColInfo* tags = (SBoundColInfo*)boundTags; @@ -939,7 +981,7 @@ int32_t qBuildStmtColFields(void* pBlock, int32_t* fieldNum, TAOS_FIELD_E** fiel SSchema* pSchema = getTableColumnSchema(pDataBlock->pMeta); if (pDataBlock->boundColsInfo.numOfBound <= 0) { *fieldNum = 0; - if (fields) { + if (fields != NULL) { *fields = NULL; } @@ -952,6 +994,23 @@ int32_t qBuildStmtColFields(void* pBlock, int32_t* fieldNum, TAOS_FIELD_E** fiel return TSDB_CODE_SUCCESS; } +int32_t qBuildStmtStbColFields(void* pBlock, int32_t* fieldNum, TAOS_FIELD_STB** fields) { + STableDataCxt* pDataBlock = (STableDataCxt*)pBlock; + SSchema* pSchema = getTableColumnSchema(pDataBlock->pMeta); + if (pDataBlock->boundColsInfo.numOfBound <= 0) { + *fieldNum = 0; + if (fields != NULL) { + *fields = NULL; + } + + return TSDB_CODE_SUCCESS; + } + + CHECK_CODE(buildStbBoundFields(pDataBlock->boundColsInfo, pSchema, fieldNum, fields, pDataBlock->pMeta)); + + return TSDB_CODE_SUCCESS; +} + int32_t qResetStmtColumns(SArray* pCols, bool deepClear) { int32_t colNum = taosArrayGetSize(pCols); diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index 8adf32d2ddd..bcb560ab5ef 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -147,7 +147,7 @@ int16_t insFindCol(SToken* pColname, int16_t start, int16_t end, SSchema* pSchem } int32_t insBuildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTag, int64_t suid, const char* sname, - SArray* tagName, uint8_t tagNum, int32_t ttl) { + SArray* tagName, uint8_t tagNum, int32_t ttl) { pTbReq->type = TD_CHILD_TABLE; pTbReq->ctb.pTag = (uint8_t*)pTag; pTbReq->name = taosStrdup(tname); @@ -174,7 +174,7 @@ static void initBoundCols(int32_t ncols, int16_t* pBoundCols) { static int32_t initColValues(STableMeta* pTableMeta, SArray* pValues) { SSchema* pSchemas = getTableColumnSchema(pTableMeta); - int32_t code = 0; + int32_t code = 0; for (int32_t i = 0; i < pTableMeta->tableInfo.numOfColumns; ++i) { SColVal val = COL_VAL_NONE(pSchemas[i].colId, pSchemas[i].type); if (NULL == taosArrayPush(pValues, &val)) { @@ -886,19 +886,77 @@ static bool findFileds(SSchema* pSchema, TAOS_FIELD* fields, int numFields) { return false; } +int32_t checkSchema(SSchema* pColSchema, int8_t* fields, char* errstr, int32_t errstrLen) { + if (*fields != pColSchema->type) { + if (errstr != NULL) + snprintf(errstr, errstrLen, "column type not equal, name:%s, schema type:%s, data type:%s", pColSchema->name, + tDataTypes[pColSchema->type].name, tDataTypes[*fields].name); + return TSDB_CODE_INVALID_PARA; + } + if (IS_VAR_DATA_TYPE(pColSchema->type) && *(int32_t*)(fields + sizeof(int8_t)) > pColSchema->bytes) { + if (errstr != NULL) + snprintf(errstr, errstrLen, + "column var data bytes error, name:%s, schema type:%s, bytes:%d, data type:%s, bytes:%d", + pColSchema->name, tDataTypes[pColSchema->type].name, pColSchema->bytes, tDataTypes[*fields].name, + *(int32_t*)(fields + sizeof(int8_t))); + return TSDB_CODE_INVALID_PARA; + } + + if (!IS_VAR_DATA_TYPE(pColSchema->type) && *(int32_t*)(fields + sizeof(int8_t)) != pColSchema->bytes) { + if (errstr != NULL) + snprintf(errstr, errstrLen, + "column normal data bytes not equal, name:%s, schema type:%s, bytes:%d, data type:%s, bytes:%d", + pColSchema->name, tDataTypes[pColSchema->type].name, pColSchema->bytes, tDataTypes[*fields].name, + *(int32_t*)(fields + sizeof(int8_t))); + return TSDB_CODE_INVALID_PARA; + } + return 0; +} + +#define PRCESS_DATA(i, j) \ + ret = checkSchema(pColSchema, fields, errstr, errstrLen); \ + if (ret != 0) { \ + goto end; \ + } \ + \ + if (pColSchema->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { \ + hasTs = true; \ + } \ + \ + int8_t* offset = pStart; \ + if (IS_VAR_DATA_TYPE(pColSchema->type)) { \ + pStart += numOfRows * sizeof(int32_t); \ + } else { \ + pStart += BitmapLen(numOfRows); \ + } \ + char* pData = pStart; \ + \ + SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, j); \ + ret = tColDataAddValueByDataBlock(pCol, pColSchema->type, pColSchema->bytes, numOfRows, offset, pData); \ + if (ret != 0) { \ + goto end; \ + } \ + fields += sizeof(int8_t) + sizeof(int32_t); \ + if (needChangeLength && version == BLOCK_VERSION_1) { \ + pStart += htonl(colLength[i]); \ + } else { \ + pStart += colLength[i]; \ + } \ + boundInfo->pColIndex[j] = -1; + int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreateTbReq* pCreateTb, void* tFields, int numFields, bool needChangeLength, char* errstr, int32_t errstrLen, bool raw) { int ret = 0; - if(data == NULL) { + if (data == NULL) { uError("rawBlockBindData, data is NULL"); return TSDB_CODE_APP_ERROR; } void* tmp = taosHashGet(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid, sizeof(pTableMeta->uid)); - SVCreateTbReq *pCreateReqTmp = NULL; - if (tmp == NULL && pCreateTb != NULL){ + SVCreateTbReq* pCreateReqTmp = NULL; + if (tmp == NULL && pCreateTb != NULL) { ret = cloneSVreateTbReq(pCreateTb, &pCreateReqTmp); - if (ret != TSDB_CODE_SUCCESS){ + if (ret != TSDB_CODE_SUCCESS) { uError("cloneSVreateTbReq error"); goto end; } @@ -906,7 +964,7 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate STableDataCxt* pTableCxt = NULL; ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid, - sizeof(pTableMeta->uid), pTableMeta, &pCreateReqTmp, &pTableCxt, true, false); + sizeof(pTableMeta->uid), pTableMeta, &pCreateReqTmp, &pTableCxt, true, false); if (pCreateReqTmp != NULL) { tdDestroySVCreateTbReq(pCreateReqTmp); taosMemoryFree(pCreateReqTmp); @@ -963,121 +1021,48 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate ret = TSDB_CODE_INVALID_PARA; goto end; } -// if (tFields != NULL && numFields > boundInfo->numOfBound) { -// if (errstr != NULL) snprintf(errstr, errstrLen, "numFields:%d bigger than num of bound cols:%d", numFields, boundInfo->numOfBound); -// ret = TSDB_CODE_INVALID_PARA; -// goto end; -// } - if (tFields == NULL && numOfCols != boundInfo->numOfBound) { - if (errstr != NULL) snprintf(errstr, errstrLen, "numFields:%d not equal to num of bound cols:%d", numOfCols, boundInfo->numOfBound); - ret = TSDB_CODE_INVALID_PARA; - goto end; - } + bool hasTs = false; if (tFields == NULL) { - for (int j = 0; j < boundInfo->numOfBound; j++) { - SSchema* pColSchema = &pSchema[j]; - SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, j); - if (*fields != pColSchema->type && *(int32_t*)(fields + sizeof(int8_t)) != pColSchema->bytes) { - if (errstr != NULL) - snprintf(errstr, errstrLen, - "column type or bytes not equal, name:%s, schema type:%s, bytes:%d, data type:%s, bytes:%d", - pColSchema->name, tDataTypes[pColSchema->type].name, pColSchema->bytes, tDataTypes[*fields].name, - *(int32_t*)(fields + sizeof(int8_t))); - ret = TSDB_CODE_INVALID_PARA; - goto end; - } - - int8_t* offset = pStart; - if (IS_VAR_DATA_TYPE(pColSchema->type)) { - pStart += numOfRows * sizeof(int32_t); - } else { - pStart += BitmapLen(numOfRows); - } - char* pData = pStart; - ret = tColDataAddValueByDataBlock(pCol, pColSchema->type, pColSchema->bytes, numOfRows, offset, pData); - if (ret != 0) { - goto end; - } - fields += sizeof(int8_t) + sizeof(int32_t); - if (needChangeLength && version == BLOCK_VERSION_1) { - pStart += htonl(colLength[j]); - } else { - pStart += colLength[j]; - } + int32_t len = TMIN(numOfCols, boundInfo->numOfBound); + for (int j = 0; j < len; j++) { + SSchema* pColSchema = &pSchema[j]; + PRCESS_DATA(j, j) } } else { - bool hasTs = false; for (int i = 0; i < numFields; i++) { for (int j = 0; j < boundInfo->numOfBound; j++) { SSchema* pColSchema = &pSchema[j]; - char* fieldName = NULL; + char* fieldName = NULL; if (raw) { fieldName = ((SSchemaWrapper*)tFields)->pSchema[i].name; } else { fieldName = ((TAOS_FIELD*)tFields)[i].name; } if (strcmp(pColSchema->name, fieldName) == 0) { - if (*fields != pColSchema->type && *(int32_t*)(fields + sizeof(int8_t)) != pColSchema->bytes) { - if (errstr != NULL) - snprintf(errstr, errstrLen, - "column type or bytes not equal, name:%s, schema type:%s, bytes:%d, data type:%s, bytes:%d", - pColSchema->name, tDataTypes[pColSchema->type].name, pColSchema->bytes, tDataTypes[*fields].name, - *(int32_t*)(fields + sizeof(int8_t))); - ret = TSDB_CODE_INVALID_PARA; - goto end; - } - - if (pColSchema->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { - hasTs = true; - } - - int8_t* offset = pStart; - if (IS_VAR_DATA_TYPE(pColSchema->type)) { - pStart += numOfRows * sizeof(int32_t); - } else { - pStart += BitmapLen(numOfRows); -// for(int k = 0; k < numOfRows; k++) { -// if(!colDataIsNull_f(offset, k) && pColSchema->type == TSDB_DATA_TYPE_INT){ -// printf("colName:%s,val:%d", fieldName, *(int32_t*)(pStart + k * sizeof(int32_t))); -// } -// } - } - char* pData = pStart; - - SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, j); - ret = tColDataAddValueByDataBlock(pCol, pColSchema->type, pColSchema->bytes, numOfRows, offset, pData); - if (ret != 0) { - goto end; - } - fields += sizeof(int8_t) + sizeof(int32_t); - if (needChangeLength && version == BLOCK_VERSION_1) { - pStart += htonl(colLength[i]); - } else { - pStart += colLength[i]; - } - boundInfo->pColIndex[j] = -1; + PRCESS_DATA(i, j) break; } } } + } - if (!hasTs) { - if (errstr != NULL) snprintf(errstr, errstrLen, "timestamp column(primary key) not found in raw data"); - ret = TSDB_CODE_INVALID_PARA; - goto end; - } + if (!hasTs) { + if (errstr != NULL) snprintf(errstr, errstrLen, "timestamp column(primary key) not found in raw data"); + ret = TSDB_CODE_INVALID_PARA; + goto end; + } - for (int c = 0; c < boundInfo->numOfBound; ++c) { - if (boundInfo->pColIndex[c] != -1) { - SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, c); - ret = tColDataAddValueByDataBlock(pCol, 0, 0, numOfRows, NULL, NULL); - if (ret != 0) { - goto end; - } - } else { - boundInfo->pColIndex[c] = c; // restore for next block + // process NULL data + for (int c = 0; c < boundInfo->numOfBound; ++c) { + if (boundInfo->pColIndex[c] != -1) { + SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, c); + ret = tColDataAddValueByDataBlock(pCol, 0, 0, numOfRows, NULL, NULL); + if (ret != 0) { + goto end; } + } else { + boundInfo->pColIndex[c] = c; // restore for next block } } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 52c40ef0a43..7aada2be12f 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -2902,7 +2902,7 @@ static int32_t rewriteDatabaseFunc(STranslateContext* pCxt, SNode** pNode) { } static int32_t rewriteClentVersionFunc(STranslateContext* pCxt, SNode** pNode) { - char* pVer = taosStrdup((void*)version); + char* pVer = taosStrdup((void*)td_version); if (NULL == pVer) { return terrno; } @@ -3308,25 +3308,26 @@ static int32_t selectCommonType(SDataType* commonType, const SDataType* newType) } else { resultType = gDisplyTypes[type2][type1]; } + if (resultType == -1) { return TSDB_CODE_SCALAR_CONVERT_ERROR; } + if (commonType->type == newType->type) { commonType->bytes = TMAX(commonType->bytes, newType->bytes); return TSDB_CODE_SUCCESS; } - if (resultType == commonType->type) { - return TSDB_CODE_SUCCESS; - } - if (resultType == newType->type) { - *commonType = *newType; - return TSDB_CODE_SUCCESS; - } - commonType->bytes = TMAX(TMAX(commonType->bytes, newType->bytes), TYPE_BYTES[resultType]); - if (resultType == TSDB_DATA_TYPE_VARCHAR && (IS_FLOAT_TYPE(commonType->type) || IS_FLOAT_TYPE(newType->type))) { - commonType->bytes += TYPE_BYTES[TSDB_DATA_TYPE_DOUBLE]; + + if ((resultType == TSDB_DATA_TYPE_VARCHAR) && (IS_MATHABLE_TYPE(commonType->type) || IS_MATHABLE_TYPE(newType->type))) { + commonType->bytes = TMAX(TMAX(commonType->bytes, newType->bytes), QUERY_NUMBER_MAX_DISPLAY_LEN); + } else if ((resultType == TSDB_DATA_TYPE_NCHAR) && (IS_MATHABLE_TYPE(commonType->type) || IS_MATHABLE_TYPE(newType->type))) { + commonType->bytes = TMAX(TMAX(commonType->bytes, newType->bytes), QUERY_NUMBER_MAX_DISPLAY_LEN * TSDB_NCHAR_SIZE); + } else { + commonType->bytes = TMAX(TMAX(commonType->bytes, newType->bytes), TYPE_BYTES[resultType]); } + commonType->type = resultType; + return TSDB_CODE_SUCCESS; } @@ -7541,6 +7542,8 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS pReq->ignoreExist = pStmt->ignoreExists; pReq->withArbitrator = pStmt->pOptions->withArbitrator; pReq->encryptAlgorithm = pStmt->pOptions->encryptAlgorithm; + tstrncpy(pReq->dnodeListStr, pStmt->pOptions->dnodeListStr, TSDB_DNODE_LIST_LEN); + return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq); } @@ -10885,7 +10888,7 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStm parseNatualDuration(str, strlen(str), &minDelay, &pVal->unit, pVal->node.resType.precision, false)) { if (pVal->datum.i < minDelay) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, - "stream max delay must be bigger than 5 session"); + "stream max delay must be bigger than 5 seconds"); } } } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 9ddf50f7aaf..a352b237b6f 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,8 +22,9 @@ ** The following is the concatenation of all %include directives from the ** input grammar file: */ +#include +#include /************ Begin %include sections from the grammar ************************/ -#line 11 "sql.y" #include #include @@ -42,401 +41,12 @@ #include "parAst.h" #define YYSTACKDEPTH 0 -#line 46 "sql.c" /**************** 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_IS_IMPORT 35 -#define TK_NK_INTEGER 36 -#define TK_CREATEDB 37 -#define TK_USER 38 -#define TK_ENABLE 39 -#define TK_SYSINFO 40 -#define TK_ADD 41 -#define TK_DROP 42 -#define TK_GRANT 43 -#define TK_ON 44 -#define TK_TO 45 -#define TK_REVOKE 46 -#define TK_FROM 47 -#define TK_SUBSCRIBE 48 -#define TK_READ 49 -#define TK_WRITE 50 -#define TK_NK_DOT 51 -#define TK_WITH 52 -#define TK_ENCRYPT_KEY 53 -#define TK_ANODE 54 -#define TK_UPDATE 55 -#define TK_ANODES 56 -#define TK_DNODE 57 -#define TK_PORT 58 -#define TK_DNODES 59 -#define TK_RESTORE 60 -#define TK_NK_IPTOKEN 61 -#define TK_FORCE 62 -#define TK_UNSAFE 63 -#define TK_CLUSTER 64 -#define TK_LOCAL 65 -#define TK_QNODE 66 -#define TK_BNODE 67 -#define TK_SNODE 68 -#define TK_MNODE 69 -#define TK_VNODE 70 -#define TK_DATABASE 71 -#define TK_USE 72 -#define TK_FLUSH 73 -#define TK_TRIM 74 -#define TK_S3MIGRATE 75 -#define TK_COMPACT 76 -#define TK_IF 77 -#define TK_NOT 78 -#define TK_EXISTS 79 -#define TK_BUFFER 80 -#define TK_CACHEMODEL 81 -#define TK_CACHESIZE 82 -#define TK_COMP 83 -#define TK_DURATION 84 -#define TK_NK_VARIABLE 85 -#define TK_MAXROWS 86 -#define TK_MINROWS 87 -#define TK_KEEP 88 -#define TK_PAGES 89 -#define TK_PAGESIZE 90 -#define TK_TSDB_PAGESIZE 91 -#define TK_PRECISION 92 -#define TK_REPLICA 93 -#define TK_VGROUPS 94 -#define TK_SINGLE_STABLE 95 -#define TK_RETENTIONS 96 -#define TK_SCHEMALESS 97 -#define TK_WAL_LEVEL 98 -#define TK_WAL_FSYNC_PERIOD 99 -#define TK_WAL_RETENTION_PERIOD 100 -#define TK_WAL_RETENTION_SIZE 101 -#define TK_WAL_ROLL_PERIOD 102 -#define TK_WAL_SEGMENT_SIZE 103 -#define TK_STT_TRIGGER 104 -#define TK_TABLE_PREFIX 105 -#define TK_TABLE_SUFFIX 106 -#define TK_S3_CHUNKPAGES 107 -#define TK_S3_KEEPLOCAL 108 -#define TK_S3_COMPACT 109 -#define TK_KEEP_TIME_OFFSET 110 -#define TK_ENCRYPT_ALGORITHM 111 -#define TK_NK_COLON 112 -#define TK_BWLIMIT 113 -#define TK_START 114 -#define TK_TIMESTAMP 115 -#define TK_END 116 -#define TK_TABLE 117 -#define TK_NK_LP 118 -#define TK_NK_RP 119 -#define TK_USING 120 -#define TK_FILE 121 -#define TK_STABLE 122 -#define TK_COLUMN 123 -#define TK_MODIFY 124 -#define TK_RENAME 125 -#define TK_TAG 126 -#define TK_SET 127 -#define TK_NK_EQ 128 -#define TK_TAGS 129 -#define TK_BOOL 130 -#define TK_TINYINT 131 -#define TK_SMALLINT 132 -#define TK_INT 133 -#define TK_INTEGER 134 -#define TK_BIGINT 135 -#define TK_FLOAT 136 -#define TK_DOUBLE 137 -#define TK_BINARY 138 -#define TK_NCHAR 139 -#define TK_UNSIGNED 140 -#define TK_JSON 141 -#define TK_VARCHAR 142 -#define TK_MEDIUMBLOB 143 -#define TK_BLOB 144 -#define TK_VARBINARY 145 -#define TK_GEOMETRY 146 -#define TK_DECIMAL 147 -#define TK_COMMENT 148 -#define TK_MAX_DELAY 149 -#define TK_WATERMARK 150 -#define TK_ROLLUP 151 -#define TK_TTL 152 -#define TK_SMA 153 -#define TK_DELETE_MARK 154 -#define TK_FIRST 155 -#define TK_LAST 156 -#define TK_SHOW 157 -#define TK_FULL 158 -#define TK_PRIVILEGES 159 -#define TK_DATABASES 160 -#define TK_TABLES 161 -#define TK_STABLES 162 -#define TK_MNODES 163 -#define TK_QNODES 164 -#define TK_ARBGROUPS 165 -#define TK_FUNCTIONS 166 -#define TK_INDEXES 167 -#define TK_ACCOUNTS 168 -#define TK_APPS 169 -#define TK_CONNECTIONS 170 -#define TK_LICENCES 171 -#define TK_GRANTS 172 -#define TK_LOGS 173 -#define TK_MACHINES 174 -#define TK_ENCRYPTIONS 175 -#define TK_QUERIES 176 -#define TK_SCORES 177 -#define TK_TOPICS 178 -#define TK_VARIABLES 179 -#define TK_BNODES 180 -#define TK_SNODES 181 -#define TK_TRANSACTIONS 182 -#define TK_DISTRIBUTED 183 -#define TK_CONSUMERS 184 -#define TK_SUBSCRIPTIONS 185 -#define TK_VNODES 186 -#define TK_ALIVE 187 -#define TK_VIEWS 188 -#define TK_VIEW 189 -#define TK_COMPACTS 190 -#define TK_NORMAL 191 -#define TK_CHILD 192 -#define TK_LIKE 193 -#define TK_TBNAME 194 -#define TK_QTAGS 195 -#define TK_AS 196 -#define TK_SYSTEM 197 -#define TK_TSMA 198 -#define TK_INTERVAL 199 -#define TK_RECURSIVE 200 -#define TK_TSMAS 201 -#define TK_FUNCTION 202 -#define TK_INDEX 203 -#define TK_COUNT 204 -#define TK_LAST_ROW 205 -#define TK_META 206 -#define TK_ONLY 207 -#define TK_TOPIC 208 -#define TK_CONSUMER 209 -#define TK_GROUP 210 -#define TK_DESC 211 -#define TK_DESCRIBE 212 -#define TK_RESET 213 -#define TK_QUERY 214 -#define TK_CACHE 215 -#define TK_EXPLAIN 216 -#define TK_ANALYZE 217 -#define TK_VERBOSE 218 -#define TK_NK_BOOL 219 -#define TK_RATIO 220 -#define TK_NK_FLOAT 221 -#define TK_OUTPUTTYPE 222 -#define TK_AGGREGATE 223 -#define TK_BUFSIZE 224 -#define TK_LANGUAGE 225 -#define TK_REPLACE 226 -#define TK_STREAM 227 -#define TK_INTO 228 -#define TK_PAUSE 229 -#define TK_RESUME 230 -#define TK_PRIMARY 231 -#define TK_KEY 232 -#define TK_TRIGGER 233 -#define TK_AT_ONCE 234 -#define TK_WINDOW_CLOSE 235 -#define TK_IGNORE 236 -#define TK_EXPIRED 237 -#define TK_FILL_HISTORY 238 -#define TK_SUBTABLE 239 -#define TK_UNTREATED 240 -#define TK_KILL 241 -#define TK_CONNECTION 242 -#define TK_TRANSACTION 243 -#define TK_BALANCE 244 -#define TK_VGROUP 245 -#define TK_LEADER 246 -#define TK_MERGE 247 -#define TK_REDISTRIBUTE 248 -#define TK_SPLIT 249 -#define TK_DELETE 250 -#define TK_INSERT 251 -#define TK_NK_BIN 252 -#define TK_NK_HEX 253 -#define TK_NULL 254 -#define TK_NK_QUESTION 255 -#define TK_NK_ALIAS 256 -#define TK_NK_ARROW 257 -#define TK_ROWTS 258 -#define TK_QSTART 259 -#define TK_QEND 260 -#define TK_QDURATION 261 -#define TK_WSTART 262 -#define TK_WEND 263 -#define TK_WDURATION 264 -#define TK_IROWTS 265 -#define TK_ISFILLED 266 -#define TK_FLOW 267 -#define TK_FHIGH 268 -#define TK_FROWTS 269 -#define TK_CAST 270 -#define TK_POSITION 271 -#define TK_IN 272 -#define TK_FOR 273 -#define TK_NOW 274 -#define TK_TODAY 275 -#define TK_RAND 276 -#define TK_SUBSTR 277 -#define TK_SUBSTRING 278 -#define TK_BOTH 279 -#define TK_TRAILING 280 -#define TK_LEADING 281 -#define TK_TIMEZONE 282 -#define TK_CLIENT_VERSION 283 -#define TK_SERVER_VERSION 284 -#define TK_SERVER_STATUS 285 -#define TK_CURRENT_USER 286 -#define TK_PI 287 -#define TK_CASE 288 -#define TK_WHEN 289 -#define TK_THEN 290 -#define TK_ELSE 291 -#define TK_BETWEEN 292 -#define TK_IS 293 -#define TK_NK_LT 294 -#define TK_NK_GT 295 -#define TK_NK_LE 296 -#define TK_NK_GE 297 -#define TK_NK_NE 298 -#define TK_MATCH 299 -#define TK_NMATCH 300 -#define TK_CONTAINS 301 -#define TK_JOIN 302 -#define TK_INNER 303 -#define TK_LEFT 304 -#define TK_RIGHT 305 -#define TK_OUTER 306 -#define TK_SEMI 307 -#define TK_ANTI 308 -#define TK_ASOF 309 -#define TK_WINDOW 310 -#define TK_WINDOW_OFFSET 311 -#define TK_JLIMIT 312 -#define TK_SELECT 313 -#define TK_NK_HINT 314 -#define TK_DISTINCT 315 -#define TK_WHERE 316 -#define TK_PARTITION 317 -#define TK_BY 318 -#define TK_SESSION 319 -#define TK_STATE_WINDOW 320 -#define TK_EVENT_WINDOW 321 -#define TK_COUNT_WINDOW 322 -#define TK_ANOMALY_WINDOW 323 -#define TK_SLIDING 324 -#define TK_FILL 325 -#define TK_VALUE 326 -#define TK_VALUE_F 327 -#define TK_NONE 328 -#define TK_PREV 329 -#define TK_NULL_F 330 -#define TK_LINEAR 331 -#define TK_NEXT 332 -#define TK_HAVING 333 -#define TK_RANGE 334 -#define TK_EVERY 335 -#define TK_ORDER 336 -#define TK_SLIMIT 337 -#define TK_SOFFSET 338 -#define TK_LIMIT 339 -#define TK_OFFSET 340 -#define TK_ASC 341 -#define TK_NULLS 342 -#define TK_ABORT 343 -#define TK_AFTER 344 -#define TK_ATTACH 345 -#define TK_BEFORE 346 -#define TK_BEGIN 347 -#define TK_BITAND 348 -#define TK_BITNOT 349 -#define TK_BITOR 350 -#define TK_BLOCKS 351 -#define TK_CHANGE 352 -#define TK_COMMA 353 -#define TK_CONCAT 354 -#define TK_CONFLICT 355 -#define TK_COPY 356 -#define TK_DEFERRED 357 -#define TK_DELIMITERS 358 -#define TK_DETACH 359 -#define TK_DIVIDE 360 -#define TK_DOT 361 -#define TK_EACH 362 -#define TK_FAIL 363 -#define TK_GLOB 364 -#define TK_ID 365 -#define TK_IMMEDIATE 366 -#define TK_IMPORT 367 -#define TK_INITIALLY 368 -#define TK_INSTEAD 369 -#define TK_ISNULL 370 -#define TK_MODULES 371 -#define TK_NK_BITNOT 372 -#define TK_NK_SEMI 373 -#define TK_NOTNULL 374 -#define TK_OF 375 -#define TK_PLUS 376 -#define TK_PRIVILEGE 377 -#define TK_RAISE 378 -#define TK_RESTRICT 379 -#define TK_ROW 380 -#define TK_STAR 381 -#define TK_STATEMENT 382 -#define TK_STRICT 383 -#define TK_STRING 384 -#define TK_TIMES 385 -#define TK_VALUES 386 -#define TK_VARIABLE 387 -#define TK_WAL 388 -#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. @@ -534,18 +144,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 1025 -#define YYNRULE 784 -#define YYNRULE_WITH_ACTION 784 +#define YYNSTATE 1026 +#define YYNRULE 785 +#define YYNRULE_WITH_ACTION 785 #define YYNTOKEN 389 -#define YY_MAX_SHIFT 1024 -#define YY_MIN_SHIFTREDUCE 1516 -#define YY_MAX_SHIFTREDUCE 2299 -#define YY_ERROR_ACTION 2300 -#define YY_ACCEPT_ACTION 2301 -#define YY_NO_ACTION 2302 -#define YY_MIN_REDUCE 2303 -#define YY_MAX_REDUCE 3086 +#define YY_MAX_SHIFT 1025 +#define YY_MIN_SHIFTREDUCE 1518 +#define YY_MAX_SHIFTREDUCE 2302 +#define YY_ERROR_ACTION 2303 +#define YY_ACCEPT_ACTION 2304 +#define YY_NO_ACTION 2305 +#define YY_MIN_REDUCE 2306 +#define YY_MAX_REDUCE 3090 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -614,753 +224,753 @@ typedef union { *********** Begin parsing tables **********************************************/ #define YY_ACTTAB_COUNT (4475) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 839, 683, 3059, 691, 684, 2351, 684, 2351, 3054, 2577, - /* 10 */ 3054, 2816, 60, 58, 678, 59, 57, 56, 55, 54, - /* 20 */ 506, 2304, 2016, 2521, 915, 2517, 838, 231, 858, 3058, - /* 30 */ 2816, 3055, 840, 3055, 3057, 205, 2014, 332, 2124, 2399, - /* 40 */ 2041, 2820, 151, 2841, 530, 150, 149, 148, 147, 146, - /* 50 */ 145, 144, 143, 142, 914, 851, 170, 466, 854, 389, - /* 60 */ 2820, 53, 52, 220, 680, 59, 57, 56, 55, 54, - /* 70 */ 2303, 2119, 151, 2045, 884, 150, 149, 148, 147, 146, - /* 80 */ 145, 144, 143, 142, 782, 2022, 2041, 2674, 2859, 829, - /* 90 */ 2647, 2822, 2824, 501, 160, 159, 158, 157, 156, 155, - /* 100 */ 154, 153, 152, 688, 2806, 919, 896, 2672, 901, 685, - /* 110 */ 2822, 2825, 1592, 2759, 1591, 1021, 851, 170, 61, 990, - /* 120 */ 989, 988, 987, 536, 919, 986, 985, 175, 980, 979, - /* 130 */ 978, 977, 976, 975, 974, 174, 968, 967, 966, 535, - /* 140 */ 534, 963, 962, 961, 211, 210, 960, 531, 959, 958, - /* 150 */ 957, 2840, 63, 1593, 2891, 2127, 2128, 197, 134, 2842, - /* 160 */ 900, 2844, 2845, 895, 75, 2448, 883, 2892, 919, 2041, - /* 170 */ 802, 772, 1592, 213, 1591, 2954, 2042, 251, 3054, 500, - /* 180 */ 2950, 207, 2962, 850, 75, 162, 849, 766, 166, 770, - /* 190 */ 768, 303, 302, 3054, 2077, 2087, 3060, 231, 198, 232, - /* 200 */ 2315, 3055, 840, 3059, 2126, 2129, 528, 3001, 509, 2570, - /* 210 */ 2572, 838, 231, 1593, 1862, 1863, 3055, 840, 195, 2017, - /* 220 */ 2044, 2015, 824, 107, 914, 9, 882, 2220, 106, 2522, - /* 230 */ 53, 52, 914, 2041, 59, 57, 56, 55, 54, 676, - /* 240 */ 64, 853, 200, 2962, 2963, 2213, 168, 2967, 674, 227, - /* 250 */ 318, 670, 666, 581, 2020, 2021, 2074, 2841, 2076, 2079, - /* 260 */ 2080, 2081, 2082, 2083, 2084, 2085, 2086, 2088, 2089, 2090, - /* 270 */ 892, 885, 894, 914, 917, 916, 881, 2111, 2112, 2113, - /* 280 */ 2114, 2115, 2118, 2120, 2121, 2122, 2123, 2125, 2, 60, - /* 290 */ 58, 2216, 700, 2841, 445, 105, 2039, 506, 75, 2016, - /* 300 */ 458, 118, 2859, 625, 644, 642, 469, 441, 897, 2046, - /* 310 */ 245, 1889, 1890, 2014, 646, 2124, 915, 2517, 2806, 2286, - /* 320 */ 896, 2616, 53, 52, 127, 2074, 59, 57, 56, 55, - /* 330 */ 54, 510, 468, 604, 2599, 648, 236, 220, 2859, 2191, - /* 340 */ 446, 606, 830, 825, 818, 814, 810, 339, 2119, 2674, - /* 350 */ 2154, 884, 584, 785, 2806, 19, 896, 701, 2667, 339, - /* 360 */ 1888, 1891, 2022, 498, 2647, 2840, 2042, 2326, 2891, 2671, - /* 370 */ 901, 63, 436, 2842, 900, 2844, 2845, 895, 893, 339, - /* 380 */ 883, 2892, 919, 874, 2919, 954, 187, 186, 951, 950, - /* 390 */ 949, 184, 1021, 467, 973, 15, 337, 2474, 572, 2044, - /* 400 */ 571, 2840, 2251, 887, 2891, 592, 2674, 2078, 134, 2842, - /* 410 */ 900, 2844, 2845, 895, 886, 2155, 883, 2892, 919, 922, - /* 420 */ 508, 172, 224, 181, 2925, 2954, 2671, 901, 2806, 500, - /* 430 */ 2950, 570, 2127, 2128, 801, 339, 2654, 2633, 2564, 634, - /* 440 */ 633, 631, 630, 629, 624, 623, 622, 621, 450, 590, - /* 450 */ 2643, 611, 610, 609, 608, 607, 601, 600, 599, 267, - /* 460 */ 594, 593, 465, 686, 699, 2359, 585, 1850, 1851, 2075, - /* 470 */ 220, 2077, 2087, 1869, 821, 820, 2249, 2250, 2252, 2253, - /* 480 */ 2254, 2126, 2129, 2974, 2188, 2189, 2190, 2974, 2974, 2974, - /* 490 */ 2974, 2974, 620, 339, 2160, 618, 2017, 2648, 2015, 41, - /* 500 */ 617, 1786, 1787, 882, 247, 53, 52, 619, 616, 59, - /* 510 */ 57, 56, 55, 54, 44, 502, 2149, 2150, 2151, 2152, - /* 520 */ 2153, 2157, 2158, 2159, 79, 2293, 2193, 2194, 2195, 2196, - /* 530 */ 2197, 2020, 2021, 2074, 2841, 2076, 2079, 2080, 2081, 2082, - /* 540 */ 2083, 2084, 2085, 2086, 2088, 2089, 2090, 892, 885, 854, - /* 550 */ 3059, 917, 916, 881, 2111, 2112, 2212, 786, 3054, 2118, - /* 560 */ 2120, 2121, 2122, 2123, 2125, 2, 60, 58, 2841, 2191, - /* 570 */ 2016, 828, 533, 532, 506, 337, 2016, 3058, 73, 2859, - /* 580 */ 2577, 3055, 3056, 897, 2014, 2135, 45, 355, 1747, 799, - /* 590 */ 2014, 2041, 2124, 702, 269, 2806, 2023, 896, 686, 866, - /* 600 */ 2359, 2859, 1561, 1738, 946, 945, 944, 1742, 943, 1744, - /* 610 */ 1745, 942, 939, 2859, 1753, 936, 1755, 1756, 933, 930, - /* 620 */ 927, 1568, 2499, 473, 786, 2119, 195, 2969, 884, 2806, - /* 630 */ 923, 896, 19, 2022, 137, 596, 2643, 2523, 75, 2022, - /* 640 */ 693, 2713, 2840, 526, 2519, 2891, 1563, 1566, 1567, 134, - /* 650 */ 2842, 900, 2844, 2845, 895, 2292, 2966, 883, 2892, 919, - /* 660 */ 915, 2517, 706, 1021, 213, 196, 2954, 725, 724, 1021, - /* 670 */ 500, 2950, 15, 827, 526, 2519, 2840, 915, 2517, 2891, - /* 680 */ 161, 2841, 2045, 135, 2842, 900, 2844, 2845, 895, 731, - /* 690 */ 249, 883, 2892, 919, 487, 2721, 897, 161, 3002, 2489, - /* 700 */ 2954, 56, 55, 54, 2953, 2950, 736, 788, 2713, 2127, - /* 710 */ 2128, 627, 2643, 2974, 2188, 2189, 2190, 2974, 2974, 2974, - /* 720 */ 2974, 2974, 518, 53, 52, 956, 2859, 59, 57, 56, - /* 730 */ 55, 54, 752, 751, 750, 851, 170, 14, 13, 742, - /* 740 */ 167, 746, 2806, 783, 896, 745, 1683, 521, 2077, 2087, - /* 750 */ 744, 749, 480, 479, 2191, 12, 743, 558, 2126, 2129, - /* 760 */ 478, 739, 738, 737, 2969, 2078, 254, 2017, 2022, 2015, - /* 770 */ 2571, 2572, 43, 2017, 1695, 2015, 956, 2045, 53, 52, - /* 780 */ 882, 2026, 59, 57, 56, 55, 54, 2799, 1694, 2840, - /* 790 */ 523, 703, 2891, 2965, 2041, 1685, 199, 2842, 900, 2844, - /* 800 */ 2845, 895, 2020, 2021, 883, 2892, 919, 2301, 2020, 2021, - /* 810 */ 2074, 2841, 2076, 2079, 2080, 2081, 2082, 2083, 2084, 2085, - /* 820 */ 2086, 2088, 2089, 2090, 892, 885, 897, 2075, 917, 916, - /* 830 */ 881, 2111, 2112, 339, 2262, 2325, 2118, 2120, 2121, 2122, - /* 840 */ 2123, 2125, 2, 12, 60, 58, 803, 3012, 851, 170, - /* 850 */ 512, 2661, 506, 704, 2016, 2168, 2859, 947, 226, 1699, - /* 860 */ 1747, 140, 2962, 2963, 919, 168, 2967, 649, 2014, 2969, - /* 870 */ 2124, 117, 2806, 1698, 896, 1738, 946, 945, 944, 1742, - /* 880 */ 943, 1744, 1745, 891, 890, 2577, 1753, 889, 1755, 1756, - /* 890 */ 888, 930, 927, 464, 2324, 562, 2806, 539, 2964, 2188, - /* 900 */ 2189, 2190, 538, 2119, 2575, 1917, 884, 1985, 113, 396, - /* 910 */ 19, 1595, 1596, 915, 2517, 1568, 307, 2022, 2046, 2840, - /* 920 */ 2506, 126, 2891, 564, 560, 638, 135, 2842, 900, 2844, - /* 930 */ 2845, 895, 1984, 68, 883, 2892, 919, 2511, 517, 516, - /* 940 */ 553, 1566, 1567, 2954, 2841, 915, 2517, 1021, 2951, 2508, - /* 950 */ 15, 2800, 651, 234, 802, 2806, 225, 915, 2517, 897, - /* 960 */ 2760, 2361, 3054, 520, 519, 578, 190, 238, 2078, 486, - /* 970 */ 2721, 409, 533, 532, 201, 2962, 2963, 579, 168, 2967, - /* 980 */ 3060, 231, 2030, 512, 839, 3055, 840, 2127, 2128, 2859, - /* 990 */ 407, 89, 3054, 256, 88, 2323, 2023, 919, 2124, 727, - /* 1000 */ 726, 1943, 1944, 470, 2491, 2806, 2504, 896, 447, 2322, - /* 1010 */ 838, 231, 2502, 2046, 512, 3055, 840, 802, 637, 255, - /* 1020 */ 265, 661, 659, 656, 654, 3054, 2077, 2087, 919, 97, - /* 1030 */ 2075, 2119, 635, 3, 53, 52, 2126, 2129, 59, 57, - /* 1040 */ 56, 55, 54, 3060, 231, 2022, 173, 66, 3055, 840, - /* 1050 */ 2321, 2017, 2840, 2015, 113, 2891, 2806, 2507, 882, 134, - /* 1060 */ 2842, 900, 2844, 2845, 895, 2243, 75, 883, 2892, 919, - /* 1070 */ 2806, 748, 747, 471, 3074, 879, 2954, 346, 347, 2244, - /* 1080 */ 500, 2950, 345, 2510, 574, 3058, 2020, 2021, 2074, 573, - /* 1090 */ 2076, 2079, 2080, 2081, 2082, 2083, 2084, 2085, 2086, 2088, - /* 1100 */ 2089, 2090, 892, 885, 970, 76, 917, 916, 881, 2111, - /* 1110 */ 2112, 2806, 984, 982, 2118, 2120, 2121, 2122, 2123, 2125, - /* 1120 */ 2, 60, 58, 2130, 915, 2517, 2320, 2319, 2242, 506, - /* 1130 */ 2318, 2016, 53, 52, 2331, 1014, 59, 57, 56, 55, - /* 1140 */ 54, 802, 306, 2577, 598, 2014, 305, 2124, 2449, 3054, - /* 1150 */ 759, 496, 954, 187, 186, 951, 950, 949, 184, 101, - /* 1160 */ 100, 577, 2575, 846, 244, 773, 2577, 3060, 231, 2488, - /* 1170 */ 2317, 40, 3055, 840, 511, 395, 972, 569, 567, 2031, - /* 1180 */ 2119, 2026, 403, 884, 304, 2575, 2554, 2806, 2806, 444, - /* 1190 */ 2402, 2806, 556, 314, 2022, 552, 548, 544, 541, 570, - /* 1200 */ 2727, 53, 52, 762, 402, 59, 57, 56, 55, 54, - /* 1210 */ 756, 754, 915, 2517, 2034, 2036, 12, 301, 10, 2314, - /* 1220 */ 116, 2841, 2521, 196, 1021, 453, 34, 61, 485, 2577, - /* 1230 */ 774, 2806, 612, 2520, 917, 916, 897, 527, 3009, 185, - /* 1240 */ 915, 2517, 2118, 2120, 2121, 2122, 2123, 2125, 2575, 915, - /* 1250 */ 2517, 53, 52, 915, 2517, 59, 57, 56, 55, 54, - /* 1260 */ 613, 339, 308, 85, 2127, 2128, 2859, 2045, 84, 614, - /* 1270 */ 752, 751, 750, 705, 2041, 2746, 809, 742, 167, 746, - /* 1280 */ 2806, 396, 2806, 745, 896, 915, 2517, 2313, 744, 749, - /* 1290 */ 480, 479, 333, 2312, 743, 915, 2517, 2577, 478, 739, - /* 1300 */ 738, 737, 2386, 2077, 2087, 2512, 915, 2517, 875, 877, - /* 1310 */ 2926, 2926, 2263, 2126, 2129, 309, 2576, 954, 187, 186, - /* 1320 */ 951, 950, 949, 184, 753, 67, 317, 2311, 2017, 2840, - /* 1330 */ 2015, 2156, 2891, 833, 843, 882, 134, 2842, 900, 2844, - /* 1340 */ 2845, 895, 2722, 2316, 883, 2892, 919, 948, 2806, 952, - /* 1350 */ 2568, 3074, 2568, 2954, 2806, 2310, 735, 500, 2950, 2309, - /* 1360 */ 734, 205, 2238, 2020, 2021, 2074, 2841, 2076, 2079, 2080, - /* 1370 */ 2081, 2082, 2083, 2084, 2085, 2086, 2088, 2089, 2090, 892, - /* 1380 */ 885, 897, 2626, 917, 916, 881, 2111, 2112, 2806, 915, - /* 1390 */ 2517, 2118, 2120, 2121, 2122, 2123, 2125, 2, 60, 58, - /* 1400 */ 2841, 915, 2517, 915, 2517, 2202, 506, 2750, 2016, 857, - /* 1410 */ 2161, 2859, 915, 2517, 2308, 897, 2806, 3022, 842, 2307, - /* 1420 */ 2806, 350, 2014, 871, 2124, 171, 588, 2806, 2925, 896, - /* 1430 */ 42, 2306, 357, 53, 52, 915, 2517, 59, 57, 56, - /* 1440 */ 55, 54, 53, 52, 529, 2859, 59, 57, 56, 55, - /* 1450 */ 54, 775, 915, 2517, 195, 908, 1570, 2119, 915, 2517, - /* 1460 */ 884, 2806, 2040, 896, 546, 2522, 953, 915, 2517, 2568, - /* 1470 */ 847, 2022, 909, 2588, 2840, 2806, 3015, 2891, 913, 163, - /* 1480 */ 2806, 413, 2842, 900, 2844, 2845, 895, 385, 32, 883, - /* 1490 */ 2892, 919, 2806, 103, 91, 2492, 294, 296, 2841, 292, - /* 1500 */ 295, 1021, 177, 2046, 61, 2109, 2295, 2296, 2840, 2579, - /* 1510 */ 2075, 2891, 740, 897, 1678, 134, 2842, 900, 2844, 2845, - /* 1520 */ 895, 222, 177, 883, 2892, 919, 298, 2384, 176, 297, - /* 1530 */ 3074, 300, 2954, 812, 299, 1676, 500, 2950, 2375, 741, - /* 1540 */ 185, 2127, 2128, 2859, 2101, 2373, 62, 822, 104, 755, - /* 1550 */ 53, 52, 62, 2232, 59, 57, 56, 55, 54, 2806, - /* 1560 */ 757, 896, 1674, 1679, 14, 13, 880, 760, 53, 52, - /* 1570 */ 364, 363, 59, 57, 56, 55, 54, 2025, 53, 52, - /* 1580 */ 2077, 2087, 59, 57, 56, 55, 54, 325, 1933, 47, - /* 1590 */ 2126, 2129, 53, 52, 214, 344, 59, 57, 56, 55, - /* 1600 */ 54, 90, 62, 366, 365, 2017, 2840, 2015, 1941, 2891, - /* 1610 */ 77, 852, 882, 134, 2842, 900, 2844, 2845, 895, 2236, - /* 1620 */ 62, 883, 2892, 919, 2827, 2024, 856, 165, 2929, 2860, - /* 1630 */ 2954, 632, 2248, 776, 500, 2950, 368, 367, 2247, 844, - /* 1640 */ 2020, 2021, 2074, 62, 2076, 2079, 2080, 2081, 2082, 2083, - /* 1650 */ 2084, 2085, 2086, 2088, 2089, 2090, 892, 885, 62, 2441, - /* 1660 */ 917, 916, 881, 2111, 2112, 62, 90, 647, 2118, 2120, - /* 1670 */ 2121, 2122, 2123, 2125, 2, 60, 58, 2841, 182, 2097, - /* 1680 */ 323, 348, 779, 506, 2440, 2016, 163, 863, 2100, 2099, - /* 1690 */ 185, 2829, 897, 132, 816, 129, 2162, 2352, 46, 2014, - /* 1700 */ 87, 2124, 2367, 2102, 370, 369, 2110, 53, 52, 3005, - /* 1710 */ 39, 59, 57, 56, 55, 54, 372, 371, 1656, 53, - /* 1720 */ 52, 819, 2859, 59, 57, 56, 55, 54, 2841, 2103, - /* 1730 */ 374, 373, 376, 375, 2119, 378, 377, 884, 2806, 802, - /* 1740 */ 896, 925, 2146, 897, 1886, 380, 379, 3054, 2022, 382, - /* 1750 */ 381, 2091, 1876, 384, 383, 1629, 964, 965, 48, 492, - /* 1760 */ 1008, 826, 2028, 183, 360, 3060, 231, 1657, 185, 164, - /* 1770 */ 3055, 840, 912, 2859, 488, 182, 1729, 860, 1021, 1648, - /* 1780 */ 1646, 61, 2652, 555, 2565, 2840, 401, 537, 2891, 2806, - /* 1790 */ 2358, 896, 134, 2842, 900, 2844, 2845, 895, 795, 3006, - /* 1800 */ 883, 2892, 919, 3016, 1630, 834, 835, 3074, 330, 2954, - /* 1810 */ 2027, 338, 335, 500, 2950, 2653, 53, 52, 2127, 2128, - /* 1820 */ 59, 57, 56, 55, 54, 2475, 5, 1760, 540, 545, - /* 1830 */ 2096, 462, 2039, 554, 2049, 566, 2840, 565, 239, 2891, - /* 1840 */ 568, 240, 394, 135, 2842, 900, 2844, 2845, 895, 1768, - /* 1850 */ 242, 883, 2892, 919, 1775, 1773, 1910, 2077, 2087, 582, - /* 1860 */ 2954, 188, 2040, 589, 878, 2950, 253, 2126, 2129, 53, - /* 1870 */ 52, 591, 595, 59, 57, 56, 55, 54, 597, 640, - /* 1880 */ 602, 615, 2017, 626, 2015, 2645, 53, 52, 636, 882, - /* 1890 */ 59, 57, 56, 55, 54, 628, 639, 641, 652, 477, - /* 1900 */ 475, 653, 650, 259, 258, 657, 2047, 655, 658, 262, - /* 1910 */ 660, 662, 4, 681, 682, 689, 2042, 2020, 2021, 2074, - /* 1920 */ 690, 2076, 2079, 2080, 2081, 2082, 2083, 2084, 2085, 2086, - /* 1930 */ 2088, 2089, 2090, 892, 885, 692, 270, 917, 916, 881, - /* 1940 */ 2111, 2112, 694, 787, 109, 2118, 2120, 2121, 2122, 2123, - /* 1950 */ 2125, 2, 60, 58, 273, 2048, 695, 2050, 696, 276, - /* 1960 */ 506, 698, 2016, 2051, 855, 278, 2668, 110, 2052, 111, - /* 1970 */ 112, 49, 2662, 1727, 2841, 730, 2014, 707, 2124, 284, - /* 1980 */ 2098, 287, 474, 472, 114, 733, 732, 763, 764, 897, - /* 1990 */ 2736, 3047, 139, 2505, 291, 439, 2501, 2095, 778, 115, - /* 2000 */ 802, 293, 191, 780, 138, 2841, 735, 310, 3054, 136, - /* 2010 */ 734, 2119, 2043, 178, 884, 2503, 2498, 192, 193, 2859, - /* 2020 */ 897, 802, 397, 2714, 790, 2022, 3060, 231, 791, 3054, - /* 2030 */ 789, 3055, 840, 315, 313, 2806, 2733, 896, 2732, 823, - /* 2040 */ 797, 861, 3021, 794, 3020, 8, 832, 3060, 231, 326, - /* 2050 */ 2859, 806, 3055, 840, 796, 1021, 2841, 2993, 61, 807, - /* 2060 */ 805, 837, 804, 320, 204, 2973, 2806, 328, 896, 324, - /* 2070 */ 322, 897, 327, 2986, 836, 329, 331, 845, 848, 169, - /* 2080 */ 493, 2044, 2840, 2210, 2208, 2891, 217, 340, 179, 134, - /* 2090 */ 2842, 900, 2844, 2845, 895, 2127, 2128, 883, 2892, 919, - /* 2100 */ 3077, 2859, 3053, 398, 3074, 2970, 2954, 859, 334, 2682, - /* 2110 */ 500, 2950, 2681, 898, 1, 2680, 2891, 2806, 497, 896, - /* 2120 */ 135, 2842, 900, 2844, 2845, 895, 864, 872, 883, 2892, - /* 2130 */ 919, 399, 869, 74, 2077, 2087, 865, 2954, 180, 2935, - /* 2140 */ 353, 457, 2950, 904, 2126, 2129, 902, 233, 906, 907, - /* 2150 */ 2798, 2797, 128, 400, 2793, 2518, 2792, 404, 2784, 2017, - /* 2160 */ 358, 2015, 2783, 125, 2840, 387, 882, 2891, 2775, 2774, - /* 2170 */ 921, 134, 2842, 900, 2844, 2845, 895, 1540, 1016, 883, - /* 2180 */ 2892, 919, 2790, 1017, 2789, 2781, 3074, 2780, 2954, 1018, - /* 2190 */ 189, 1013, 500, 2950, 2020, 2021, 2074, 391, 2076, 2079, - /* 2200 */ 2080, 2081, 2082, 2083, 2084, 2085, 2086, 2088, 2089, 2090, - /* 2210 */ 892, 885, 1020, 2769, 917, 916, 881, 2111, 2112, 2768, - /* 2220 */ 2787, 2786, 2118, 2120, 2121, 2122, 2123, 2125, 2, 60, - /* 2230 */ 58, 2778, 2777, 2766, 2765, 390, 2763, 506, 2762, 2016, - /* 2240 */ 2569, 65, 476, 454, 427, 782, 440, 455, 524, 438, - /* 2250 */ 428, 2841, 406, 2014, 408, 2124, 2758, 2757, 2756, 98, - /* 2260 */ 2751, 542, 543, 1967, 1968, 547, 897, 237, 2749, 549, - /* 2270 */ 550, 551, 1966, 2748, 2747, 463, 2745, 557, 2744, 559, - /* 2280 */ 2743, 561, 2742, 563, 1954, 2718, 241, 2717, 2119, 243, - /* 2290 */ 1913, 884, 99, 1912, 2695, 2694, 2859, 2693, 575, 576, - /* 2300 */ 2692, 2691, 2022, 2635, 580, 1849, 2632, 583, 2631, 2625, - /* 2310 */ 2622, 586, 2806, 246, 896, 248, 102, 2620, 587, 2621, - /* 2320 */ 2619, 2624, 2623, 2618, 2617, 2615, 2614, 449, 448, 2613, - /* 2330 */ 2612, 2610, 1021, 2841, 603, 15, 250, 513, 605, 2609, - /* 2340 */ 2608, 2607, 2606, 2630, 2605, 2604, 2603, 2628, 897, 2611, - /* 2350 */ 2602, 522, 2601, 2124, 2600, 2598, 2597, 2596, 2595, 2840, - /* 2360 */ 2594, 2593, 2891, 252, 2592, 108, 134, 2842, 900, 2844, - /* 2370 */ 2845, 895, 2127, 2128, 883, 2892, 919, 2591, 2859, 257, - /* 2380 */ 2582, 2927, 2590, 2954, 2589, 2587, 2119, 500, 2950, 2586, - /* 2390 */ 2660, 2629, 2627, 2585, 2806, 2584, 896, 1855, 2583, 643, - /* 2400 */ 2581, 645, 2580, 2578, 2406, 1696, 260, 2405, 1700, 261, - /* 2410 */ 1692, 2077, 2087, 2404, 451, 452, 2403, 2401, 2398, 263, - /* 2420 */ 665, 2126, 2129, 663, 264, 664, 2397, 668, 2390, 672, - /* 2430 */ 667, 2377, 669, 671, 2365, 675, 2017, 677, 2015, 2364, - /* 2440 */ 673, 2840, 679, 882, 2891, 2347, 1569, 212, 134, 2842, - /* 2450 */ 900, 2844, 2845, 895, 94, 266, 883, 2892, 919, 2346, - /* 2460 */ 2826, 2716, 223, 876, 268, 2954, 687, 95, 2712, 500, - /* 2470 */ 2950, 2020, 2021, 2074, 2702, 2076, 2079, 2080, 2081, 2082, - /* 2480 */ 2083, 2084, 2085, 2086, 2088, 2089, 2090, 892, 885, 784, - /* 2490 */ 2690, 917, 916, 881, 2111, 2112, 275, 2689, 277, 2118, - /* 2500 */ 2120, 2121, 2122, 2123, 2125, 2, 280, 1024, 2666, 282, - /* 2510 */ 2659, 2493, 1622, 2400, 2396, 2841, 708, 709, 2394, 710, - /* 2520 */ 712, 713, 714, 2392, 717, 716, 393, 718, 2389, 720, - /* 2530 */ 897, 722, 2372, 721, 2007, 2370, 1983, 2371, 2369, 2366, - /* 2540 */ 728, 1012, 1010, 2343, 2495, 221, 1779, 290, 86, 2494, - /* 2550 */ 2387, 1780, 1682, 1681, 1006, 1002, 998, 994, 1680, 388, - /* 2560 */ 2859, 1677, 1675, 1673, 981, 1672, 983, 515, 514, 2008, - /* 2570 */ 1671, 2385, 1670, 481, 1664, 482, 2806, 1669, 896, 2376, - /* 2580 */ 483, 1666, 1665, 1663, 2374, 484, 2342, 2341, 2340, 917, - /* 2590 */ 916, 761, 765, 2339, 2338, 767, 769, 2118, 2120, 2121, - /* 2600 */ 2122, 2123, 2125, 2337, 771, 133, 1948, 758, 1950, 141, - /* 2610 */ 361, 1947, 2715, 1952, 33, 312, 80, 2711, 69, 1919, - /* 2620 */ 1921, 2841, 2701, 2840, 792, 70, 2891, 1923, 2688, 316, - /* 2630 */ 202, 2842, 900, 2844, 2845, 895, 897, 1938, 883, 2892, - /* 2640 */ 919, 867, 793, 2687, 2841, 1898, 798, 194, 800, 1897, - /* 2650 */ 3059, 22, 17, 808, 25, 781, 811, 489, 35, 897, - /* 2660 */ 6, 2265, 7, 23, 228, 24, 2859, 216, 38, 229, - /* 2670 */ 2827, 78, 319, 2205, 26, 2280, 2239, 18, 2279, 36, - /* 2680 */ 817, 2237, 2806, 813, 896, 815, 359, 494, 873, 2859, - /* 2690 */ 2203, 342, 841, 3075, 2284, 321, 341, 2246, 203, 215, - /* 2700 */ 2283, 495, 72, 37, 336, 2806, 503, 896, 208, 2231, - /* 2710 */ 96, 2686, 2665, 2664, 2201, 311, 2285, 230, 120, 2286, - /* 2720 */ 2841, 121, 351, 2185, 2658, 2184, 343, 119, 122, 2840, - /* 2730 */ 2241, 27, 2891, 218, 349, 897, 437, 2842, 900, 2844, - /* 2740 */ 2845, 895, 82, 71, 883, 2892, 919, 11, 868, 13, - /* 2750 */ 2032, 209, 2840, 2147, 219, 2891, 352, 2067, 21, 199, - /* 2760 */ 2842, 900, 2844, 2845, 895, 2859, 862, 883, 2892, 919, - /* 2770 */ 2137, 2841, 870, 28, 29, 354, 2657, 2136, 2094, 2490, - /* 2780 */ 20, 2806, 2093, 896, 50, 932, 897, 123, 935, 938, - /* 2790 */ 941, 51, 910, 362, 2092, 2059, 16, 30, 31, 83, - /* 2800 */ 905, 903, 2106, 356, 2841, 490, 124, 129, 2299, 92, - /* 2810 */ 3013, 911, 2904, 2903, 918, 81, 2859, 924, 920, 897, - /* 2820 */ 1761, 525, 926, 386, 1758, 928, 929, 931, 2840, 1757, - /* 2830 */ 934, 2891, 2806, 1754, 896, 437, 2842, 900, 2844, 2845, - /* 2840 */ 895, 1748, 937, 883, 2892, 919, 2298, 940, 899, 2859, - /* 2850 */ 1746, 130, 131, 1774, 93, 1752, 491, 1751, 1750, 1749, - /* 2860 */ 1770, 1620, 955, 1660, 1659, 2806, 1658, 896, 1655, 2841, - /* 2870 */ 1652, 1651, 1650, 1649, 969, 1647, 1645, 1690, 1644, 2840, - /* 2880 */ 1643, 1689, 2891, 971, 897, 235, 437, 2842, 900, 2844, - /* 2890 */ 2845, 895, 2841, 1641, 883, 2892, 919, 1640, 1639, 1638, - /* 2900 */ 1637, 1636, 1635, 1686, 1684, 1632, 1631, 894, 1628, 1627, - /* 2910 */ 1626, 1625, 2840, 992, 2859, 2891, 2395, 991, 993, 430, - /* 2920 */ 2842, 900, 2844, 2845, 895, 2393, 995, 883, 2892, 919, - /* 2930 */ 2806, 997, 896, 996, 2391, 999, 1000, 2859, 1001, 2388, - /* 2940 */ 1003, 1004, 1005, 2368, 1007, 2363, 1009, 2362, 1011, 2336, - /* 2950 */ 1558, 1541, 1015, 2806, 1546, 896, 1548, 392, 1019, 1022, - /* 2960 */ 2841, 2302, 2018, 405, 1023, 2302, 2302, 2302, 2302, 2302, - /* 2970 */ 2302, 2302, 2302, 831, 2302, 897, 2302, 2840, 2302, 2302, - /* 2980 */ 2891, 2302, 2302, 2302, 202, 2842, 900, 2844, 2845, 895, - /* 2990 */ 2302, 2302, 883, 2892, 919, 2302, 2302, 2302, 2302, 2302, - /* 3000 */ 2840, 2302, 2302, 2891, 2302, 2859, 2302, 436, 2842, 900, - /* 3010 */ 2844, 2845, 895, 2302, 2302, 883, 2892, 919, 2302, 2920, - /* 3020 */ 2302, 2806, 2302, 896, 2302, 2841, 2302, 289, 2302, 2302, - /* 3030 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 3040 */ 897, 2302, 2302, 729, 2302, 504, 206, 3076, 2302, 2302, - /* 3050 */ 2302, 2302, 2841, 2302, 2302, 723, 719, 715, 711, 2302, - /* 3060 */ 288, 2302, 2302, 2302, 2302, 2302, 2302, 897, 2840, 2302, - /* 3070 */ 2859, 2891, 2302, 2302, 2302, 437, 2842, 900, 2844, 2845, - /* 3080 */ 895, 2302, 2302, 883, 2892, 919, 2806, 2302, 896, 2302, - /* 3090 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2859, 2302, 2302, - /* 3100 */ 2302, 2302, 2302, 2302, 2302, 2302, 286, 2302, 2302, 2302, - /* 3110 */ 499, 285, 2302, 2806, 2302, 896, 2302, 2302, 2302, 2302, - /* 3120 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 3130 */ 2302, 2302, 2302, 2840, 2302, 2302, 2891, 505, 2841, 2302, - /* 3140 */ 422, 2842, 900, 2844, 2845, 895, 2302, 2302, 883, 2892, - /* 3150 */ 919, 2302, 2302, 897, 2302, 2302, 2302, 2302, 2841, 2302, - /* 3160 */ 2840, 2302, 2302, 2891, 2302, 2302, 2302, 437, 2842, 900, - /* 3170 */ 2844, 2845, 895, 897, 2302, 883, 2892, 919, 272, 2841, - /* 3180 */ 2302, 2302, 2302, 2859, 2302, 2302, 2302, 283, 2302, 2302, - /* 3190 */ 2302, 274, 281, 2302, 897, 2302, 2302, 279, 697, 2806, - /* 3200 */ 2302, 896, 2302, 2859, 2302, 2302, 2302, 2302, 2302, 2302, - /* 3210 */ 2302, 2302, 2302, 2302, 2302, 2302, 271, 2302, 2302, 2806, - /* 3220 */ 2302, 896, 2302, 507, 2859, 2302, 2302, 2302, 2302, 2302, - /* 3230 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 3240 */ 2806, 2302, 896, 2302, 2302, 2302, 2840, 2302, 2302, 2891, - /* 3250 */ 2302, 2302, 2302, 437, 2842, 900, 2844, 2845, 895, 2302, - /* 3260 */ 2302, 883, 2892, 919, 2302, 2302, 2840, 2302, 2302, 2891, - /* 3270 */ 2302, 2302, 2302, 418, 2842, 900, 2844, 2845, 895, 2302, - /* 3280 */ 2302, 883, 2892, 919, 2302, 2841, 2302, 777, 2302, 2302, - /* 3290 */ 2891, 2302, 2302, 2302, 432, 2842, 900, 2844, 2845, 895, - /* 3300 */ 897, 2302, 883, 2892, 919, 2841, 2302, 2302, 2302, 2302, - /* 3310 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 3320 */ 897, 2302, 2302, 2302, 2302, 2841, 2302, 2302, 2302, 2302, - /* 3330 */ 2859, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 3340 */ 897, 2302, 2302, 2302, 2302, 2302, 2806, 2302, 896, 2302, - /* 3350 */ 2859, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 3360 */ 2302, 2302, 2302, 2302, 2302, 2302, 2806, 2302, 896, 2302, - /* 3370 */ 2859, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 3380 */ 2302, 2302, 2302, 2302, 2302, 2302, 2806, 2302, 896, 2302, - /* 3390 */ 2302, 2302, 2302, 2840, 2302, 2302, 2891, 2302, 2302, 2302, - /* 3400 */ 414, 2842, 900, 2844, 2845, 895, 2302, 2302, 883, 2892, - /* 3410 */ 919, 2302, 2841, 2840, 2302, 2302, 2891, 2302, 2302, 2302, - /* 3420 */ 410, 2842, 900, 2844, 2845, 895, 2302, 897, 883, 2892, - /* 3430 */ 919, 2302, 2302, 2840, 2302, 2302, 2891, 2302, 2841, 2302, - /* 3440 */ 411, 2842, 900, 2844, 2845, 895, 2302, 2302, 883, 2892, - /* 3450 */ 919, 2302, 2302, 897, 2302, 2302, 2302, 2859, 2302, 2302, - /* 3460 */ 2302, 2841, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 3470 */ 2302, 2302, 2302, 2806, 2302, 896, 897, 2302, 2302, 2302, - /* 3480 */ 2302, 2841, 2302, 2859, 2302, 2302, 2302, 2302, 2302, 2302, - /* 3490 */ 2302, 2302, 2302, 2302, 2302, 2302, 897, 2302, 2302, 2806, - /* 3500 */ 2302, 896, 2302, 2841, 2302, 2302, 2859, 2302, 2302, 2302, - /* 3510 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 897, 2302, - /* 3520 */ 2840, 2302, 2806, 2891, 896, 2302, 2859, 415, 2842, 900, - /* 3530 */ 2844, 2845, 895, 2302, 2302, 883, 2892, 919, 2302, 2302, - /* 3540 */ 2302, 2302, 2806, 2302, 896, 2302, 2840, 2302, 2859, 2891, - /* 3550 */ 2302, 2302, 2302, 429, 2842, 900, 2844, 2845, 895, 2302, - /* 3560 */ 2302, 883, 2892, 919, 2806, 2302, 896, 2302, 2841, 2840, - /* 3570 */ 2302, 2302, 2891, 2302, 2302, 2302, 416, 2842, 900, 2844, - /* 3580 */ 2845, 895, 2302, 897, 883, 2892, 919, 2841, 2302, 2840, - /* 3590 */ 2302, 2302, 2891, 2302, 2302, 2302, 417, 2842, 900, 2844, - /* 3600 */ 2845, 895, 897, 2302, 883, 2892, 919, 2302, 2302, 2841, - /* 3610 */ 2302, 2840, 2302, 2859, 2891, 2302, 2302, 2302, 433, 2842, - /* 3620 */ 900, 2844, 2845, 895, 897, 2302, 883, 2892, 919, 2806, - /* 3630 */ 2302, 896, 2859, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 3640 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2806, 2302, - /* 3650 */ 896, 2302, 2302, 2302, 2859, 2302, 2302, 2302, 2302, 2302, - /* 3660 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 3670 */ 2806, 2302, 896, 2302, 2841, 2302, 2840, 2302, 2302, 2891, - /* 3680 */ 2302, 2302, 2302, 419, 2842, 900, 2844, 2845, 895, 897, - /* 3690 */ 2302, 883, 2892, 919, 2302, 2840, 2302, 2302, 2891, 2302, - /* 3700 */ 2302, 2302, 434, 2842, 900, 2844, 2845, 895, 2302, 2302, - /* 3710 */ 883, 2892, 919, 2302, 2302, 2302, 2302, 2840, 2302, 2859, - /* 3720 */ 2891, 2302, 2302, 2841, 420, 2842, 900, 2844, 2845, 895, - /* 3730 */ 2302, 2302, 883, 2892, 919, 2806, 2302, 896, 897, 2302, - /* 3740 */ 2302, 2302, 2302, 2841, 2302, 2302, 2302, 2302, 2302, 2302, - /* 3750 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 897, 2302, - /* 3760 */ 2302, 2302, 2302, 2841, 2302, 2302, 2302, 2302, 2859, 2302, - /* 3770 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 897, 2302, - /* 3780 */ 2302, 2302, 2840, 2302, 2806, 2891, 896, 2302, 2859, 435, - /* 3790 */ 2842, 900, 2844, 2845, 895, 2302, 2302, 883, 2892, 919, - /* 3800 */ 2302, 2302, 2302, 2302, 2806, 2302, 896, 2302, 2859, 2302, - /* 3810 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 3820 */ 2302, 2302, 2302, 2302, 2806, 2302, 896, 2302, 2302, 2302, - /* 3830 */ 2302, 2840, 2302, 2302, 2891, 2302, 2302, 2302, 421, 2842, - /* 3840 */ 900, 2844, 2845, 895, 2302, 2302, 883, 2892, 919, 2302, - /* 3850 */ 2841, 2840, 2302, 2302, 2891, 2302, 2302, 2302, 412, 2842, - /* 3860 */ 900, 2844, 2845, 895, 2302, 897, 883, 2892, 919, 2841, - /* 3870 */ 2302, 2840, 2302, 2302, 2891, 2302, 2302, 2302, 423, 2842, - /* 3880 */ 900, 2844, 2845, 895, 897, 2302, 883, 2892, 919, 2841, - /* 3890 */ 2302, 2302, 2302, 2302, 2302, 2859, 2302, 2302, 2302, 2302, - /* 3900 */ 2302, 2302, 2302, 2302, 897, 2302, 2302, 2302, 2302, 2302, - /* 3910 */ 2302, 2806, 2302, 896, 2859, 2302, 2302, 2302, 2302, 2302, - /* 3920 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 3930 */ 2806, 2302, 896, 2302, 2859, 2302, 2302, 2302, 2302, 2302, - /* 3940 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 3950 */ 2806, 2302, 896, 2302, 2302, 2302, 2841, 2302, 2840, 2302, - /* 3960 */ 2302, 2891, 2302, 2302, 2302, 424, 2842, 900, 2844, 2845, - /* 3970 */ 895, 897, 2302, 883, 2892, 919, 2841, 2840, 2302, 2302, - /* 3980 */ 2891, 2302, 2302, 2302, 425, 2842, 900, 2844, 2845, 895, - /* 3990 */ 2302, 897, 883, 2892, 919, 2841, 2302, 2840, 2302, 2302, - /* 4000 */ 2891, 2859, 2302, 2302, 426, 2842, 900, 2844, 2845, 895, - /* 4010 */ 897, 2302, 883, 2892, 919, 2302, 2302, 2806, 2302, 896, - /* 4020 */ 2302, 2859, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 4030 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2806, 2302, 896, - /* 4040 */ 2859, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 4050 */ 2302, 2302, 2302, 2302, 2302, 2302, 2806, 2302, 896, 2302, - /* 4060 */ 2302, 2302, 2302, 2841, 2840, 2302, 2302, 2891, 2302, 2302, - /* 4070 */ 2302, 442, 2842, 900, 2844, 2845, 895, 2302, 897, 883, - /* 4080 */ 2892, 919, 2841, 2302, 2840, 2302, 2302, 2891, 2302, 2302, - /* 4090 */ 2302, 443, 2842, 900, 2844, 2845, 895, 897, 2302, 883, - /* 4100 */ 2892, 919, 2302, 2840, 2302, 2302, 2891, 2302, 2859, 2302, - /* 4110 */ 2853, 2842, 900, 2844, 2845, 895, 2302, 2302, 883, 2892, - /* 4120 */ 919, 2302, 2302, 2302, 2806, 2302, 896, 2859, 2302, 2302, - /* 4130 */ 2302, 2841, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 4140 */ 2302, 2302, 2302, 2806, 2302, 896, 897, 2302, 2302, 2302, - /* 4150 */ 2302, 2841, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 4160 */ 2302, 2302, 2302, 2302, 2302, 2302, 897, 2302, 2302, 2302, - /* 4170 */ 2302, 2840, 2302, 2302, 2891, 2302, 2859, 2302, 2852, 2842, - /* 4180 */ 900, 2844, 2845, 895, 2302, 2302, 883, 2892, 919, 2302, - /* 4190 */ 2840, 2302, 2806, 2891, 896, 2302, 2859, 2851, 2842, 900, - /* 4200 */ 2844, 2845, 895, 2302, 2302, 883, 2892, 919, 2302, 2302, - /* 4210 */ 2302, 2302, 2806, 2302, 896, 2302, 2302, 2302, 2302, 2841, - /* 4220 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 4230 */ 2302, 2302, 2302, 2302, 897, 2302, 2302, 2302, 2302, 2840, - /* 4240 */ 2302, 2302, 2891, 2841, 2302, 2302, 459, 2842, 900, 2844, - /* 4250 */ 2845, 895, 2302, 2302, 883, 2892, 919, 2302, 897, 2840, - /* 4260 */ 2302, 2302, 2891, 2302, 2859, 2302, 460, 2842, 900, 2844, - /* 4270 */ 2845, 895, 2302, 2302, 883, 2892, 919, 2302, 2302, 2302, - /* 4280 */ 2806, 2302, 896, 2302, 2302, 2302, 2302, 2302, 2859, 2302, - /* 4290 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 4300 */ 2302, 2302, 2302, 2302, 2806, 2302, 896, 2302, 2302, 2302, - /* 4310 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 4320 */ 2302, 2302, 2302, 2302, 2302, 2841, 2302, 2840, 2302, 2302, - /* 4330 */ 2891, 2302, 2302, 2302, 456, 2842, 900, 2844, 2845, 895, - /* 4340 */ 897, 2302, 883, 2892, 919, 2302, 2302, 2302, 2302, 2841, - /* 4350 */ 2302, 2840, 2302, 2302, 2891, 2302, 2302, 2302, 461, 2842, - /* 4360 */ 900, 2844, 2845, 895, 897, 2302, 883, 2892, 919, 2302, - /* 4370 */ 2859, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 4380 */ 2302, 2302, 2302, 2302, 2302, 2302, 2806, 2302, 896, 2302, - /* 4390 */ 2302, 2302, 2302, 2302, 2859, 2302, 2302, 2302, 2302, 2302, - /* 4400 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 4410 */ 2806, 2302, 896, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 4420 */ 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, 2302, - /* 4430 */ 2302, 2302, 2302, 898, 2302, 2302, 2891, 2302, 2302, 2302, - /* 4440 */ 432, 2842, 900, 2844, 2845, 895, 2302, 2302, 883, 2892, - /* 4450 */ 919, 2302, 2302, 2302, 2302, 2302, 2302, 2840, 2302, 2302, - /* 4460 */ 2891, 2302, 2302, 2302, 431, 2842, 900, 2844, 2845, 895, - /* 4470 */ 2302, 2302, 883, 2892, 919, + /* 0 */ 839, 683, 3063, 2678, 684, 2354, 113, 2510, 3058, 678, + /* 10 */ 3058, 2820, 60, 58, 225, 59, 57, 56, 55, 54, + /* 20 */ 506, 2307, 2019, 2676, 901, 471, 838, 231, 224, 3062, + /* 30 */ 2820, 3059, 840, 3059, 3061, 2514, 2017, 2803, 2127, 2402, + /* 40 */ 523, 2824, 151, 2845, 2568, 150, 149, 148, 147, 146, + /* 50 */ 145, 144, 143, 142, 196, 851, 170, 914, 854, 680, + /* 60 */ 2824, 53, 52, 526, 2523, 59, 57, 56, 55, 54, + /* 70 */ 512, 2122, 151, 2048, 884, 150, 149, 148, 147, 146, + /* 80 */ 145, 144, 143, 142, 919, 2025, 914, 2678, 2863, 53, + /* 90 */ 52, 2826, 2829, 59, 57, 56, 55, 54, 957, 691, + /* 100 */ 512, 498, 684, 2354, 2810, 919, 896, 2675, 901, 2044, + /* 110 */ 2826, 2828, 501, 2763, 919, 1022, 851, 170, 61, 991, + /* 120 */ 990, 989, 988, 536, 919, 987, 986, 175, 981, 980, + /* 130 */ 979, 978, 977, 976, 975, 174, 969, 968, 967, 535, + /* 140 */ 534, 964, 963, 962, 211, 210, 961, 531, 960, 959, + /* 150 */ 958, 2844, 2804, 2525, 2895, 2130, 2131, 127, 134, 2846, + /* 160 */ 900, 2848, 2849, 895, 45, 355, 883, 2896, 919, 914, + /* 170 */ 802, 772, 1594, 213, 1593, 2958, 2045, 251, 3058, 500, + /* 180 */ 2954, 207, 2966, 850, 63, 162, 849, 766, 166, 770, + /* 190 */ 768, 303, 302, 3058, 2080, 2090, 3064, 231, 829, 232, + /* 200 */ 785, 3059, 840, 3063, 2129, 2132, 528, 3005, 75, 2574, + /* 210 */ 2576, 838, 231, 1595, 782, 512, 3059, 840, 914, 2020, + /* 220 */ 2047, 2018, 824, 107, 197, 9, 882, 2223, 106, 919, + /* 230 */ 53, 52, 2452, 2044, 59, 57, 56, 55, 54, 676, + /* 240 */ 64, 853, 200, 2966, 2967, 699, 168, 2971, 674, 227, + /* 250 */ 318, 670, 666, 581, 2023, 2024, 2077, 2845, 2079, 2082, + /* 260 */ 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2091, 2092, 2093, + /* 270 */ 892, 885, 894, 307, 917, 916, 881, 2114, 2115, 2116, + /* 280 */ 2117, 2118, 2121, 2123, 2124, 2125, 2126, 2128, 2, 60, + /* 290 */ 58, 2219, 2296, 2845, 445, 105, 2042, 506, 2306, 2019, + /* 300 */ 458, 118, 2863, 625, 644, 642, 469, 441, 897, 2049, + /* 310 */ 245, 1892, 1893, 2017, 646, 2127, 63, 79, 2810, 2289, + /* 320 */ 896, 2620, 160, 159, 158, 157, 156, 155, 154, 153, + /* 330 */ 152, 466, 468, 604, 2750, 648, 828, 220, 2863, 2194, + /* 340 */ 446, 606, 830, 825, 818, 814, 810, 2138, 2122, 2678, + /* 350 */ 2157, 884, 584, 2044, 2810, 19, 896, 3062, 1946, 1947, + /* 360 */ 1891, 1894, 2025, 508, 2651, 2844, 2863, 2329, 2895, 2675, + /* 370 */ 901, 2028, 436, 2846, 900, 2848, 2849, 895, 893, 339, + /* 380 */ 883, 2896, 919, 874, 2923, 954, 187, 186, 951, 950, + /* 390 */ 949, 184, 1022, 467, 2048, 15, 337, 2044, 851, 170, + /* 400 */ 1698, 2844, 2254, 339, 2895, 592, 518, 2081, 134, 2846, + /* 410 */ 900, 2848, 2849, 895, 1697, 2158, 883, 2896, 919, 558, + /* 420 */ 2603, 172, 2295, 181, 2929, 2958, 533, 532, 2810, 500, + /* 430 */ 2954, 75, 2130, 2131, 2077, 339, 2658, 2637, 827, 634, + /* 440 */ 633, 631, 630, 629, 624, 623, 622, 621, 450, 702, + /* 450 */ 2026, 611, 610, 609, 608, 607, 601, 600, 599, 510, + /* 460 */ 594, 593, 465, 2045, 706, 220, 585, 1853, 1854, 2078, + /* 470 */ 220, 2080, 2090, 1872, 821, 820, 2252, 2253, 2255, 2256, + /* 480 */ 2257, 2129, 2132, 2978, 2191, 2192, 2193, 2978, 2978, 2978, + /* 490 */ 2978, 2978, 2651, 649, 2163, 618, 2020, 2652, 2018, 41, + /* 500 */ 617, 688, 2044, 882, 956, 53, 52, 685, 616, 59, + /* 510 */ 57, 56, 55, 54, 44, 502, 2152, 2153, 2154, 2155, + /* 520 */ 2156, 2160, 2161, 2162, 140, 2966, 2967, 2081, 168, 2971, + /* 530 */ 2754, 2023, 2024, 2077, 2845, 2079, 2082, 2083, 2084, 2085, + /* 540 */ 2086, 2087, 2088, 2089, 2091, 2092, 2093, 892, 885, 854, + /* 550 */ 3063, 917, 916, 881, 2114, 2115, 2031, 562, 3058, 2121, + /* 560 */ 2123, 2124, 2125, 2126, 2128, 2, 60, 58, 2845, 2194, + /* 570 */ 2019, 1865, 1866, 75, 506, 700, 2019, 3062, 620, 2863, + /* 580 */ 222, 3059, 3060, 897, 2017, 564, 560, 546, 1750, 2078, + /* 590 */ 2017, 1988, 2127, 619, 205, 2810, 332, 896, 1789, 1790, + /* 600 */ 75, 2328, 1563, 1741, 946, 945, 944, 1745, 943, 1747, + /* 610 */ 1748, 942, 939, 2863, 1756, 936, 1758, 1759, 933, 930, + /* 620 */ 927, 1570, 517, 516, 786, 2122, 339, 887, 884, 2810, + /* 630 */ 2049, 896, 19, 2025, 137, 2029, 915, 2521, 886, 2025, + /* 640 */ 701, 2671, 2844, 526, 2523, 2895, 1565, 1568, 1569, 134, + /* 650 */ 2846, 900, 2848, 2849, 895, 12, 530, 883, 2896, 919, + /* 660 */ 915, 2521, 2810, 1022, 213, 117, 2958, 590, 2647, 1022, + /* 670 */ 500, 2954, 15, 572, 971, 571, 2844, 915, 2521, 2895, + /* 680 */ 161, 2845, 521, 135, 2846, 900, 2848, 2849, 895, 731, + /* 690 */ 842, 883, 2896, 919, 487, 2725, 897, 236, 3006, 1920, + /* 700 */ 2958, 2503, 473, 2194, 2957, 2954, 570, 693, 2717, 2130, + /* 710 */ 2131, 2575, 2576, 2978, 2191, 2192, 2193, 2978, 2978, 2978, + /* 720 */ 2978, 2978, 247, 53, 52, 783, 2863, 59, 57, 56, + /* 730 */ 55, 54, 752, 751, 750, 851, 170, 915, 2521, 742, + /* 740 */ 167, 746, 2810, 2025, 896, 745, 973, 2973, 2080, 2090, + /* 750 */ 744, 749, 480, 479, 915, 2521, 743, 161, 2129, 2132, + /* 760 */ 478, 739, 738, 737, 1597, 1598, 736, 2020, 339, 2018, + /* 770 */ 915, 2521, 43, 2020, 68, 2018, 2970, 2048, 53, 52, + /* 780 */ 882, 389, 59, 57, 56, 55, 54, 267, 2047, 2844, + /* 790 */ 578, 686, 2895, 2362, 2496, 339, 199, 2846, 900, 2848, + /* 800 */ 2849, 895, 2023, 2024, 883, 2896, 919, 2304, 2023, 2024, + /* 810 */ 2077, 2845, 2079, 2082, 2083, 2084, 2085, 2086, 2087, 2088, + /* 820 */ 2089, 2091, 2092, 2093, 892, 885, 897, 176, 917, 916, + /* 830 */ 881, 2114, 2115, 947, 2265, 2044, 2121, 2123, 2124, 2125, + /* 840 */ 2126, 2128, 2, 12, 60, 58, 803, 3016, 2191, 2192, + /* 850 */ 2193, 269, 506, 195, 2019, 686, 2863, 2362, 786, 1686, + /* 860 */ 1750, 201, 2966, 2967, 2527, 168, 2971, 1987, 2017, 198, + /* 870 */ 2127, 2318, 2810, 2508, 896, 1741, 946, 945, 944, 1745, + /* 880 */ 943, 1747, 1748, 891, 890, 2581, 1756, 889, 1758, 1759, + /* 890 */ 888, 930, 927, 464, 596, 2647, 2973, 539, 520, 519, + /* 900 */ 346, 347, 538, 2122, 2579, 345, 884, 638, 1688, 396, + /* 910 */ 19, 3019, 2196, 2197, 2198, 2199, 2200, 2025, 1681, 2844, + /* 920 */ 915, 2521, 2895, 627, 2647, 2969, 135, 2846, 900, 2848, + /* 930 */ 2849, 895, 915, 2521, 883, 2896, 919, 2506, 915, 2521, + /* 940 */ 579, 788, 2717, 2958, 2845, 915, 2521, 1022, 2955, 249, + /* 950 */ 15, 2327, 598, 226, 802, 2581, 915, 2521, 612, 897, + /* 960 */ 2764, 2364, 3058, 496, 337, 613, 190, 1682, 703, 486, + /* 970 */ 2725, 409, 533, 532, 2579, 256, 614, 1594, 254, 1593, + /* 980 */ 3064, 231, 2033, 2581, 839, 3059, 840, 2130, 2131, 2863, + /* 990 */ 407, 89, 3058, 395, 88, 2326, 2026, 12, 2127, 10, + /* 1000 */ 637, 255, 858, 470, 2495, 2810, 314, 896, 447, 2081, + /* 1010 */ 838, 231, 2810, 2049, 635, 3059, 840, 802, 1595, 402, + /* 1020 */ 265, 661, 659, 656, 654, 3058, 2080, 2090, 2665, 974, + /* 1030 */ 704, 2122, 2478, 1702, 53, 52, 2129, 2132, 59, 57, + /* 1040 */ 56, 55, 54, 3064, 231, 2025, 2581, 1701, 3059, 840, + /* 1050 */ 91, 2020, 2844, 2018, 511, 2895, 2810, 2048, 882, 134, + /* 1060 */ 2846, 900, 2848, 2849, 895, 2579, 75, 883, 2896, 919, + /* 1070 */ 875, 2078, 2930, 2325, 3078, 879, 2958, 56, 55, 54, + /* 1080 */ 500, 2954, 14, 13, 574, 1570, 2023, 2024, 2077, 573, + /* 1090 */ 2079, 2082, 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2091, + /* 1100 */ 2092, 2093, 892, 885, 104, 76, 917, 916, 881, 2114, + /* 1110 */ 2115, 1568, 1569, 2324, 2121, 2123, 2124, 2125, 2126, 2128, + /* 1120 */ 2, 60, 58, 2133, 915, 2521, 651, 2323, 2525, 506, + /* 1130 */ 2322, 2019, 53, 52, 2810, 2370, 59, 57, 56, 55, + /* 1140 */ 54, 802, 306, 775, 705, 2017, 305, 2127, 171, 3058, + /* 1150 */ 759, 2929, 954, 187, 186, 951, 950, 949, 184, 101, + /* 1160 */ 100, 577, 915, 2521, 244, 773, 509, 3064, 231, 2492, + /* 1170 */ 2321, 40, 3059, 840, 2810, 2319, 195, 569, 567, 2034, + /* 1180 */ 2122, 2029, 2516, 884, 304, 725, 724, 2526, 2810, 444, + /* 1190 */ 2405, 2810, 556, 1009, 2025, 552, 548, 544, 541, 570, + /* 1200 */ 2171, 53, 52, 762, 2246, 59, 57, 56, 55, 54, + /* 1210 */ 756, 754, 915, 2521, 2037, 2039, 948, 301, 2247, 2572, + /* 1220 */ 116, 2845, 727, 726, 1022, 453, 34, 61, 485, 2581, + /* 1230 */ 774, 2810, 309, 234, 917, 916, 897, 527, 3013, 748, + /* 1240 */ 747, 2320, 2121, 2123, 2124, 2125, 2126, 2128, 2579, 915, + /* 1250 */ 2521, 53, 52, 915, 2521, 59, 57, 56, 55, 54, + /* 1260 */ 2216, 339, 2453, 85, 2130, 2131, 2863, 2245, 84, 317, + /* 1270 */ 752, 751, 750, 857, 2044, 205, 809, 742, 167, 746, + /* 1280 */ 97, 801, 2810, 745, 896, 915, 2521, 2317, 744, 749, + /* 1290 */ 480, 479, 822, 2049, 743, 915, 2521, 173, 478, 739, + /* 1300 */ 738, 737, 2810, 2080, 2090, 350, 915, 2521, 2511, 877, + /* 1310 */ 833, 2930, 2266, 2129, 2132, 871, 553, 954, 187, 186, + /* 1320 */ 951, 950, 949, 184, 126, 776, 357, 2316, 2020, 2844, + /* 1330 */ 2018, 2159, 2895, 985, 983, 882, 134, 2846, 900, 2848, + /* 1340 */ 2849, 895, 2581, 238, 883, 2896, 919, 952, 2810, 2592, + /* 1350 */ 2572, 3078, 2512, 2958, 2493, 2315, 403, 500, 2954, 2314, + /* 1360 */ 2558, 866, 2241, 2023, 2024, 2077, 2845, 2079, 2082, 2083, + /* 1370 */ 2084, 2085, 2086, 2087, 2088, 2089, 2091, 2092, 2093, 892, + /* 1380 */ 885, 897, 2205, 917, 916, 881, 2114, 2115, 2810, 915, + /* 1390 */ 2521, 2121, 2123, 2124, 2125, 2126, 2128, 2, 60, 58, + /* 1400 */ 2845, 915, 2521, 915, 2521, 2313, 506, 2312, 2019, 908, + /* 1410 */ 2164, 2863, 915, 2521, 2311, 897, 2810, 3026, 396, 2310, + /* 1420 */ 2810, 909, 2017, 913, 2127, 73, 2309, 2810, 185, 896, + /* 1430 */ 42, 956, 385, 53, 52, 2973, 799, 59, 57, 56, + /* 1440 */ 55, 54, 53, 52, 529, 2863, 59, 57, 56, 55, + /* 1450 */ 54, 2581, 953, 1572, 195, 2572, 2630, 2122, 735, 2043, + /* 1460 */ 884, 2810, 734, 896, 2968, 2526, 2810, 113, 2810, 2583, + /* 1470 */ 2580, 2025, 2731, 294, 2844, 2810, 292, 2895, 177, 2726, + /* 1480 */ 2810, 413, 2846, 900, 2848, 2849, 895, 2810, 32, 883, + /* 1490 */ 2896, 919, 196, 2334, 1015, 3, 2515, 333, 2845, 843, + /* 1500 */ 588, 1022, 2524, 846, 61, 2112, 922, 632, 2844, 66, + /* 1510 */ 2078, 2895, 2027, 897, 67, 134, 2846, 900, 2848, 2849, + /* 1520 */ 895, 163, 177, 883, 2896, 919, 296, 852, 298, 295, + /* 1530 */ 3078, 297, 2958, 185, 308, 103, 500, 2954, 2389, 740, + /* 1540 */ 741, 2130, 2131, 2863, 2104, 300, 2298, 2299, 299, 325, + /* 1550 */ 53, 52, 812, 2235, 59, 57, 56, 55, 54, 2810, + /* 1560 */ 753, 896, 1679, 1677, 1936, 14, 13, 165, 53, 52, + /* 1570 */ 880, 2215, 59, 57, 56, 55, 54, 2864, 53, 52, + /* 1580 */ 2080, 2090, 59, 57, 56, 55, 54, 2444, 1658, 47, + /* 1590 */ 2129, 2132, 53, 52, 62, 62, 59, 57, 56, 55, + /* 1600 */ 54, 132, 214, 129, 62, 2020, 2844, 2018, 1944, 2895, + /* 1610 */ 2387, 2378, 882, 134, 2846, 900, 2848, 2849, 895, 856, + /* 1620 */ 344, 883, 2896, 919, 364, 363, 2831, 647, 2933, 2443, + /* 1630 */ 2958, 2355, 755, 757, 500, 2954, 2376, 1659, 2239, 3009, + /* 1640 */ 2023, 2024, 2077, 819, 2079, 2082, 2083, 2084, 2085, 2086, + /* 1650 */ 2087, 2088, 2089, 2091, 2092, 2093, 892, 885, 760, 492, + /* 1660 */ 917, 916, 881, 2114, 2115, 488, 90, 62, 2121, 2123, + /* 1670 */ 2124, 2125, 2126, 2128, 2, 60, 58, 2845, 77, 2100, + /* 1680 */ 2251, 2250, 779, 506, 826, 2019, 62, 860, 323, 2102, + /* 1690 */ 2113, 62, 897, 2833, 816, 366, 365, 2030, 46, 2017, + /* 1700 */ 62, 2127, 2656, 2105, 90, 537, 348, 53, 52, 555, + /* 1710 */ 39, 59, 57, 56, 55, 54, 2361, 923, 2569, 53, + /* 1720 */ 52, 795, 2863, 59, 57, 56, 55, 54, 2845, 87, + /* 1730 */ 368, 367, 370, 369, 2122, 372, 371, 884, 2810, 802, + /* 1740 */ 896, 182, 163, 897, 3010, 185, 2149, 3058, 2025, 374, + /* 1750 */ 373, 965, 863, 2103, 376, 375, 378, 377, 48, 380, + /* 1760 */ 379, 382, 381, 925, 2165, 3064, 231, 384, 383, 183, + /* 1770 */ 3059, 840, 2106, 2863, 1650, 966, 185, 2094, 1022, 3020, + /* 1780 */ 335, 61, 834, 835, 1631, 2844, 1889, 330, 2895, 2810, + /* 1790 */ 1879, 896, 134, 2846, 900, 2848, 2849, 895, 1648, 164, + /* 1800 */ 883, 2896, 919, 2657, 844, 338, 2479, 3078, 540, 2958, + /* 1810 */ 847, 182, 5, 500, 2954, 401, 53, 52, 2130, 2131, + /* 1820 */ 59, 57, 56, 55, 54, 545, 462, 360, 912, 2042, + /* 1830 */ 2099, 1732, 554, 1632, 2052, 566, 2844, 565, 239, 2895, + /* 1840 */ 1913, 582, 240, 135, 2846, 900, 2848, 2849, 895, 1763, + /* 1850 */ 568, 883, 2896, 919, 394, 1771, 242, 2080, 2090, 2043, + /* 1860 */ 2958, 589, 1778, 253, 878, 2954, 591, 2129, 2132, 53, + /* 1870 */ 52, 597, 595, 59, 57, 56, 55, 54, 640, 602, + /* 1880 */ 615, 2649, 2020, 628, 2018, 1776, 53, 52, 626, 882, + /* 1890 */ 59, 57, 56, 55, 54, 636, 639, 188, 652, 477, + /* 1900 */ 475, 641, 650, 653, 259, 258, 657, 655, 658, 262, + /* 1910 */ 660, 662, 2050, 681, 4, 682, 689, 2023, 2024, 2077, + /* 1920 */ 692, 2079, 2082, 2083, 2084, 2085, 2086, 2087, 2088, 2089, + /* 1930 */ 2091, 2092, 2093, 892, 885, 690, 270, 917, 916, 881, + /* 1940 */ 2114, 2115, 2045, 787, 109, 2121, 2123, 2124, 2125, 2126, + /* 1950 */ 2128, 2, 60, 58, 694, 273, 2051, 695, 2053, 696, + /* 1960 */ 506, 276, 2019, 698, 855, 278, 2054, 2672, 110, 2055, + /* 1970 */ 1730, 49, 2666, 111, 2845, 730, 2017, 284, 2127, 707, + /* 1980 */ 2101, 112, 474, 472, 114, 733, 2740, 287, 763, 897, + /* 1990 */ 764, 3051, 2737, 732, 2509, 139, 291, 2098, 439, 778, + /* 2000 */ 802, 2736, 2505, 780, 138, 2845, 735, 115, 3058, 178, + /* 2010 */ 734, 2122, 2046, 397, 884, 293, 191, 136, 2507, 2863, + /* 2020 */ 897, 802, 2502, 192, 2718, 2025, 3064, 231, 193, 3058, + /* 2030 */ 310, 3059, 840, 791, 789, 2810, 790, 896, 794, 315, + /* 2040 */ 823, 313, 3025, 796, 797, 806, 861, 3064, 231, 3024, + /* 2050 */ 2863, 832, 3059, 840, 8, 1022, 2845, 2997, 61, 204, + /* 2060 */ 807, 320, 326, 322, 324, 805, 2810, 804, 896, 837, + /* 2070 */ 327, 897, 328, 2990, 329, 836, 493, 2977, 331, 848, + /* 2080 */ 334, 3081, 2844, 845, 3057, 2895, 169, 2047, 2213, 134, + /* 2090 */ 2846, 900, 2848, 2849, 895, 2130, 2131, 883, 2896, 919, + /* 2100 */ 2211, 2863, 2974, 217, 3078, 340, 2958, 179, 398, 859, + /* 2110 */ 500, 2954, 2686, 898, 1, 2685, 2895, 2810, 2684, 896, + /* 2120 */ 135, 2846, 900, 2848, 2849, 895, 497, 399, 883, 2896, + /* 2130 */ 919, 864, 180, 869, 2080, 2090, 865, 2958, 872, 353, + /* 2140 */ 74, 457, 2954, 233, 2129, 2132, 2939, 902, 906, 400, + /* 2150 */ 904, 2802, 907, 2801, 358, 2797, 2796, 2788, 125, 2020, + /* 2160 */ 2522, 2018, 128, 2787, 2844, 387, 882, 2895, 1542, 2779, + /* 2170 */ 921, 134, 2846, 900, 2848, 2849, 895, 2778, 404, 883, + /* 2180 */ 2896, 919, 2794, 1018, 1019, 2793, 3078, 782, 2958, 1017, + /* 2190 */ 1014, 406, 500, 2954, 2023, 2024, 2077, 189, 2079, 2082, + /* 2200 */ 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2091, 2092, 2093, + /* 2210 */ 892, 885, 2785, 390, 917, 916, 881, 2114, 2115, 391, + /* 2220 */ 2784, 1021, 2121, 2123, 2124, 2125, 2126, 2128, 2, 60, + /* 2230 */ 58, 440, 2773, 2772, 2791, 476, 2790, 506, 2782, 2019, + /* 2240 */ 2781, 65, 2770, 2769, 2767, 2766, 427, 2573, 454, 455, + /* 2250 */ 438, 2845, 524, 2017, 428, 2127, 408, 2762, 2761, 2760, + /* 2260 */ 98, 2755, 542, 543, 1970, 547, 897, 1971, 237, 2753, + /* 2270 */ 549, 550, 551, 1969, 2752, 2751, 463, 2749, 557, 2748, + /* 2280 */ 559, 2747, 561, 2746, 563, 1957, 2722, 241, 2122, 2721, + /* 2290 */ 243, 884, 99, 1916, 1915, 2699, 2863, 2698, 2697, 575, + /* 2300 */ 576, 2696, 2025, 2695, 2639, 580, 1852, 2636, 583, 2635, + /* 2310 */ 2629, 2626, 2810, 587, 896, 246, 586, 2625, 102, 2624, + /* 2320 */ 2623, 2628, 2627, 2622, 248, 2621, 2619, 449, 448, 2618, + /* 2330 */ 2617, 250, 1022, 2845, 2616, 15, 603, 513, 605, 2614, + /* 2340 */ 2613, 2612, 2611, 2610, 2634, 2609, 2608, 2607, 897, 2632, + /* 2350 */ 2615, 522, 2606, 2127, 2605, 2604, 2602, 2601, 2600, 2844, + /* 2360 */ 2599, 2598, 2895, 2597, 252, 2596, 134, 2846, 900, 2848, + /* 2370 */ 2849, 895, 2130, 2131, 883, 2896, 919, 2595, 2863, 108, + /* 2380 */ 2594, 2931, 2593, 2958, 2591, 2590, 2122, 500, 2954, 2664, + /* 2390 */ 2633, 2631, 2589, 2588, 2810, 1858, 896, 2587, 2586, 257, + /* 2400 */ 643, 2585, 645, 2584, 2582, 1699, 2409, 260, 1703, 2408, + /* 2410 */ 1695, 2080, 2090, 2407, 451, 2406, 452, 2404, 2401, 261, + /* 2420 */ 665, 2129, 2132, 663, 263, 664, 2400, 668, 2393, 672, + /* 2430 */ 264, 667, 669, 2380, 2368, 671, 2020, 677, 2018, 2367, + /* 2440 */ 673, 2844, 2350, 882, 2895, 2830, 675, 679, 134, 2846, + /* 2450 */ 900, 2848, 2849, 895, 266, 212, 883, 2896, 919, 223, + /* 2460 */ 94, 1571, 2349, 876, 268, 2958, 2720, 2716, 95, 500, + /* 2470 */ 2954, 2023, 2024, 2077, 687, 2079, 2082, 2083, 2084, 2085, + /* 2480 */ 2086, 2087, 2088, 2089, 2091, 2092, 2093, 892, 885, 784, + /* 2490 */ 2706, 917, 916, 881, 2114, 2115, 2694, 275, 277, 2121, + /* 2500 */ 2123, 2124, 2125, 2126, 2128, 2, 2693, 1025, 280, 2670, + /* 2510 */ 282, 2663, 2497, 2403, 1624, 2845, 2399, 708, 709, 710, + /* 2520 */ 2397, 712, 713, 714, 2395, 716, 393, 717, 718, 2392, + /* 2530 */ 897, 720, 2375, 721, 2010, 722, 1986, 2373, 2374, 2372, + /* 2540 */ 2369, 1013, 1011, 728, 2346, 221, 2499, 290, 86, 1782, + /* 2550 */ 1783, 2498, 1685, 1684, 1007, 1003, 999, 995, 1683, 388, + /* 2560 */ 2863, 1680, 1678, 2390, 1676, 2388, 982, 515, 514, 2011, + /* 2570 */ 1675, 1674, 1673, 2379, 1667, 984, 2810, 1672, 896, 1669, + /* 2580 */ 481, 1668, 482, 1666, 483, 2377, 484, 2345, 2344, 917, + /* 2590 */ 916, 761, 2343, 765, 2342, 767, 2341, 2121, 2123, 2124, + /* 2600 */ 2125, 2126, 2128, 769, 2340, 133, 771, 758, 1951, 141, + /* 2610 */ 361, 1953, 1950, 1955, 2719, 33, 80, 312, 2715, 1922, + /* 2620 */ 1924, 2845, 2705, 2844, 792, 69, 2895, 70, 1926, 316, + /* 2630 */ 202, 2846, 900, 2848, 2849, 895, 897, 1941, 883, 2896, + /* 2640 */ 919, 867, 793, 2692, 2845, 781, 2691, 194, 1901, 798, + /* 2650 */ 1900, 800, 3063, 22, 808, 17, 23, 811, 6, 897, + /* 2660 */ 489, 7, 24, 216, 228, 2206, 2863, 35, 2831, 2268, + /* 2670 */ 38, 319, 229, 2242, 36, 78, 2208, 26, 2283, 336, + /* 2680 */ 2240, 2282, 2810, 494, 896, 817, 359, 813, 873, 2863, + /* 2690 */ 815, 342, 841, 3079, 2287, 203, 341, 321, 2249, 215, + /* 2700 */ 37, 2286, 495, 72, 96, 2810, 503, 896, 208, 2234, + /* 2710 */ 2204, 230, 2690, 2669, 2288, 311, 2289, 119, 25, 2188, + /* 2720 */ 2845, 120, 2187, 2668, 343, 121, 2244, 2662, 218, 2844, + /* 2730 */ 349, 122, 2895, 82, 71, 897, 437, 2846, 900, 2848, + /* 2740 */ 2849, 895, 27, 352, 883, 2896, 919, 13, 18, 209, + /* 2750 */ 868, 2140, 2844, 11, 2139, 2895, 2035, 2150, 219, 199, + /* 2760 */ 2846, 900, 2848, 2849, 895, 2863, 21, 883, 2896, 919, + /* 2770 */ 28, 2845, 29, 351, 20, 2070, 899, 50, 2661, 123, + /* 2780 */ 2097, 2810, 2096, 896, 129, 932, 897, 935, 2494, 938, + /* 2790 */ 910, 941, 51, 362, 2095, 2062, 16, 30, 31, 2302, + /* 2800 */ 862, 83, 1755, 903, 2845, 490, 356, 870, 124, 354, + /* 2810 */ 3017, 92, 911, 2908, 2907, 905, 2863, 924, 2109, 897, + /* 2820 */ 918, 81, 525, 920, 1764, 1761, 926, 928, 2844, 929, + /* 2830 */ 931, 2895, 2810, 1760, 896, 437, 2846, 900, 2848, 2849, + /* 2840 */ 895, 1757, 934, 883, 2896, 919, 937, 1751, 1749, 2863, + /* 2850 */ 940, 2301, 386, 1777, 130, 1754, 491, 1753, 1752, 131, + /* 2860 */ 1773, 93, 1622, 955, 1663, 2810, 1662, 896, 1661, 2845, + /* 2870 */ 1660, 1657, 1654, 1653, 1693, 1652, 1651, 1649, 1692, 2844, + /* 2880 */ 1640, 1647, 2895, 1646, 897, 1645, 437, 2846, 900, 2848, + /* 2890 */ 2849, 895, 2845, 235, 883, 2896, 919, 1643, 1642, 1641, + /* 2900 */ 1639, 1638, 970, 1637, 972, 1689, 1687, 894, 1634, 1633, + /* 2910 */ 1630, 1629, 2844, 1628, 2863, 2895, 1627, 2398, 992, 430, + /* 2920 */ 2846, 900, 2848, 2849, 895, 993, 2396, 883, 2896, 919, + /* 2930 */ 2810, 994, 896, 996, 997, 2394, 998, 2863, 1000, 1002, + /* 2940 */ 1001, 2391, 1004, 1005, 1006, 2371, 1008, 2366, 2365, 1010, + /* 2950 */ 1012, 1560, 2339, 2810, 1543, 896, 1016, 1548, 1550, 392, + /* 2960 */ 2845, 1020, 2305, 2305, 2021, 405, 2305, 1023, 2305, 1024, + /* 2970 */ 2305, 2305, 2305, 831, 2305, 897, 2305, 2844, 2305, 2305, + /* 2980 */ 2895, 2305, 2305, 2305, 202, 2846, 900, 2848, 2849, 895, + /* 2990 */ 2305, 2305, 883, 2896, 919, 2305, 2305, 2305, 2305, 2305, + /* 3000 */ 2844, 2305, 2305, 2895, 2305, 2863, 2305, 436, 2846, 900, + /* 3010 */ 2848, 2849, 895, 2305, 2305, 883, 2896, 919, 2305, 2924, + /* 3020 */ 2305, 2810, 2305, 896, 2305, 2845, 2305, 289, 2305, 2305, + /* 3030 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 3040 */ 897, 2305, 2305, 729, 2305, 504, 206, 3080, 2305, 2305, + /* 3050 */ 2305, 2305, 2845, 2305, 2305, 723, 719, 715, 711, 2305, + /* 3060 */ 288, 2305, 2305, 2305, 2305, 2305, 2305, 897, 2844, 2305, + /* 3070 */ 2863, 2895, 2305, 2305, 2305, 437, 2846, 900, 2848, 2849, + /* 3080 */ 895, 2305, 2305, 883, 2896, 919, 2810, 2305, 896, 2305, + /* 3090 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2863, 2305, 2305, + /* 3100 */ 2305, 2305, 2305, 2305, 2305, 2305, 286, 2305, 2305, 2305, + /* 3110 */ 499, 285, 2305, 2810, 2305, 896, 2305, 2305, 2305, 2305, + /* 3120 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 3130 */ 2305, 2305, 2305, 2844, 2305, 2305, 2895, 505, 2845, 2305, + /* 3140 */ 422, 2846, 900, 2848, 2849, 895, 2305, 2305, 883, 2896, + /* 3150 */ 919, 2305, 2305, 897, 2305, 2305, 2305, 2305, 2845, 2305, + /* 3160 */ 2844, 2305, 2305, 2895, 2305, 2305, 2305, 437, 2846, 900, + /* 3170 */ 2848, 2849, 895, 897, 2305, 883, 2896, 919, 272, 2845, + /* 3180 */ 2305, 2305, 2305, 2863, 2305, 2305, 2305, 283, 2305, 2305, + /* 3190 */ 2305, 274, 281, 2305, 897, 2305, 2305, 279, 697, 2810, + /* 3200 */ 2305, 896, 2305, 2863, 2305, 2305, 2305, 2305, 2305, 2305, + /* 3210 */ 2305, 2305, 2305, 2305, 2305, 2305, 271, 2305, 2305, 2810, + /* 3220 */ 2305, 896, 2305, 507, 2863, 2305, 2305, 2305, 2305, 2305, + /* 3230 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 3240 */ 2810, 2305, 896, 2305, 2305, 2305, 2844, 2305, 2305, 2895, + /* 3250 */ 2305, 2305, 2305, 437, 2846, 900, 2848, 2849, 895, 2305, + /* 3260 */ 2305, 883, 2896, 919, 2305, 2305, 2844, 2305, 2305, 2895, + /* 3270 */ 2305, 2305, 2305, 418, 2846, 900, 2848, 2849, 895, 2305, + /* 3280 */ 2305, 883, 2896, 919, 2305, 2845, 2305, 777, 2305, 2305, + /* 3290 */ 2895, 2305, 2305, 2305, 432, 2846, 900, 2848, 2849, 895, + /* 3300 */ 897, 2305, 883, 2896, 919, 2845, 2305, 2305, 2305, 2305, + /* 3310 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 3320 */ 897, 2305, 2305, 2305, 2305, 2845, 2305, 2305, 2305, 2305, + /* 3330 */ 2863, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 3340 */ 897, 2305, 2305, 2305, 2305, 2305, 2810, 2305, 896, 2305, + /* 3350 */ 2863, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 3360 */ 2305, 2305, 2305, 2305, 2305, 2305, 2810, 2305, 896, 2305, + /* 3370 */ 2863, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 3380 */ 2305, 2305, 2305, 2305, 2305, 2305, 2810, 2305, 896, 2305, + /* 3390 */ 2305, 2305, 2305, 2844, 2305, 2305, 2895, 2305, 2305, 2305, + /* 3400 */ 414, 2846, 900, 2848, 2849, 895, 2305, 2305, 883, 2896, + /* 3410 */ 919, 2305, 2845, 2844, 2305, 2305, 2895, 2305, 2305, 2305, + /* 3420 */ 410, 2846, 900, 2848, 2849, 895, 2305, 897, 883, 2896, + /* 3430 */ 919, 2305, 2305, 2844, 2305, 2305, 2895, 2305, 2845, 2305, + /* 3440 */ 411, 2846, 900, 2848, 2849, 895, 2305, 2305, 883, 2896, + /* 3450 */ 919, 2305, 2305, 897, 2305, 2305, 2305, 2863, 2305, 2305, + /* 3460 */ 2305, 2845, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 3470 */ 2305, 2305, 2305, 2810, 2305, 896, 897, 2305, 2305, 2305, + /* 3480 */ 2305, 2845, 2305, 2863, 2305, 2305, 2305, 2305, 2305, 2305, + /* 3490 */ 2305, 2305, 2305, 2305, 2305, 2305, 897, 2305, 2305, 2810, + /* 3500 */ 2305, 896, 2305, 2845, 2305, 2305, 2863, 2305, 2305, 2305, + /* 3510 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 897, 2305, + /* 3520 */ 2844, 2305, 2810, 2895, 896, 2305, 2863, 415, 2846, 900, + /* 3530 */ 2848, 2849, 895, 2305, 2305, 883, 2896, 919, 2305, 2305, + /* 3540 */ 2305, 2305, 2810, 2305, 896, 2305, 2844, 2305, 2863, 2895, + /* 3550 */ 2305, 2305, 2305, 429, 2846, 900, 2848, 2849, 895, 2305, + /* 3560 */ 2305, 883, 2896, 919, 2810, 2305, 896, 2305, 2845, 2844, + /* 3570 */ 2305, 2305, 2895, 2305, 2305, 2305, 416, 2846, 900, 2848, + /* 3580 */ 2849, 895, 2305, 897, 883, 2896, 919, 2845, 2305, 2844, + /* 3590 */ 2305, 2305, 2895, 2305, 2305, 2305, 417, 2846, 900, 2848, + /* 3600 */ 2849, 895, 897, 2305, 883, 2896, 919, 2305, 2305, 2845, + /* 3610 */ 2305, 2844, 2305, 2863, 2895, 2305, 2305, 2305, 433, 2846, + /* 3620 */ 900, 2848, 2849, 895, 897, 2305, 883, 2896, 919, 2810, + /* 3630 */ 2305, 896, 2863, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 3640 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2810, 2305, + /* 3650 */ 896, 2305, 2305, 2305, 2863, 2305, 2305, 2305, 2305, 2305, + /* 3660 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 3670 */ 2810, 2305, 896, 2305, 2845, 2305, 2844, 2305, 2305, 2895, + /* 3680 */ 2305, 2305, 2305, 419, 2846, 900, 2848, 2849, 895, 897, + /* 3690 */ 2305, 883, 2896, 919, 2305, 2844, 2305, 2305, 2895, 2305, + /* 3700 */ 2305, 2305, 434, 2846, 900, 2848, 2849, 895, 2305, 2305, + /* 3710 */ 883, 2896, 919, 2305, 2305, 2305, 2305, 2844, 2305, 2863, + /* 3720 */ 2895, 2305, 2305, 2845, 420, 2846, 900, 2848, 2849, 895, + /* 3730 */ 2305, 2305, 883, 2896, 919, 2810, 2305, 896, 897, 2305, + /* 3740 */ 2305, 2305, 2305, 2845, 2305, 2305, 2305, 2305, 2305, 2305, + /* 3750 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 897, 2305, + /* 3760 */ 2305, 2305, 2305, 2845, 2305, 2305, 2305, 2305, 2863, 2305, + /* 3770 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 897, 2305, + /* 3780 */ 2305, 2305, 2844, 2305, 2810, 2895, 896, 2305, 2863, 435, + /* 3790 */ 2846, 900, 2848, 2849, 895, 2305, 2305, 883, 2896, 919, + /* 3800 */ 2305, 2305, 2305, 2305, 2810, 2305, 896, 2305, 2863, 2305, + /* 3810 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 3820 */ 2305, 2305, 2305, 2305, 2810, 2305, 896, 2305, 2305, 2305, + /* 3830 */ 2305, 2844, 2305, 2305, 2895, 2305, 2305, 2305, 421, 2846, + /* 3840 */ 900, 2848, 2849, 895, 2305, 2305, 883, 2896, 919, 2305, + /* 3850 */ 2845, 2844, 2305, 2305, 2895, 2305, 2305, 2305, 412, 2846, + /* 3860 */ 900, 2848, 2849, 895, 2305, 897, 883, 2896, 919, 2845, + /* 3870 */ 2305, 2844, 2305, 2305, 2895, 2305, 2305, 2305, 423, 2846, + /* 3880 */ 900, 2848, 2849, 895, 897, 2305, 883, 2896, 919, 2845, + /* 3890 */ 2305, 2305, 2305, 2305, 2305, 2863, 2305, 2305, 2305, 2305, + /* 3900 */ 2305, 2305, 2305, 2305, 897, 2305, 2305, 2305, 2305, 2305, + /* 3910 */ 2305, 2810, 2305, 896, 2863, 2305, 2305, 2305, 2305, 2305, + /* 3920 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 3930 */ 2810, 2305, 896, 2305, 2863, 2305, 2305, 2305, 2305, 2305, + /* 3940 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 3950 */ 2810, 2305, 896, 2305, 2305, 2305, 2845, 2305, 2844, 2305, + /* 3960 */ 2305, 2895, 2305, 2305, 2305, 424, 2846, 900, 2848, 2849, + /* 3970 */ 895, 897, 2305, 883, 2896, 919, 2845, 2844, 2305, 2305, + /* 3980 */ 2895, 2305, 2305, 2305, 425, 2846, 900, 2848, 2849, 895, + /* 3990 */ 2305, 897, 883, 2896, 919, 2845, 2305, 2844, 2305, 2305, + /* 4000 */ 2895, 2863, 2305, 2305, 426, 2846, 900, 2848, 2849, 895, + /* 4010 */ 897, 2305, 883, 2896, 919, 2305, 2305, 2810, 2305, 896, + /* 4020 */ 2305, 2863, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 4030 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2810, 2305, 896, + /* 4040 */ 2863, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 4050 */ 2305, 2305, 2305, 2305, 2305, 2305, 2810, 2305, 896, 2305, + /* 4060 */ 2305, 2305, 2305, 2845, 2844, 2305, 2305, 2895, 2305, 2305, + /* 4070 */ 2305, 442, 2846, 900, 2848, 2849, 895, 2305, 897, 883, + /* 4080 */ 2896, 919, 2845, 2305, 2844, 2305, 2305, 2895, 2305, 2305, + /* 4090 */ 2305, 443, 2846, 900, 2848, 2849, 895, 897, 2305, 883, + /* 4100 */ 2896, 919, 2305, 2844, 2305, 2305, 2895, 2305, 2863, 2305, + /* 4110 */ 2857, 2846, 900, 2848, 2849, 895, 2305, 2305, 883, 2896, + /* 4120 */ 919, 2305, 2305, 2305, 2810, 2305, 896, 2863, 2305, 2305, + /* 4130 */ 2305, 2845, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 4140 */ 2305, 2305, 2305, 2810, 2305, 896, 897, 2305, 2305, 2305, + /* 4150 */ 2305, 2845, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 4160 */ 2305, 2305, 2305, 2305, 2305, 2305, 897, 2305, 2305, 2305, + /* 4170 */ 2305, 2844, 2305, 2305, 2895, 2305, 2863, 2305, 2856, 2846, + /* 4180 */ 900, 2848, 2849, 895, 2305, 2305, 883, 2896, 919, 2305, + /* 4190 */ 2844, 2305, 2810, 2895, 896, 2305, 2863, 2855, 2846, 900, + /* 4200 */ 2848, 2849, 895, 2305, 2305, 883, 2896, 919, 2305, 2305, + /* 4210 */ 2305, 2305, 2810, 2305, 896, 2305, 2305, 2305, 2305, 2845, + /* 4220 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 4230 */ 2305, 2305, 2305, 2305, 897, 2305, 2305, 2305, 2305, 2844, + /* 4240 */ 2305, 2305, 2895, 2845, 2305, 2305, 459, 2846, 900, 2848, + /* 4250 */ 2849, 895, 2305, 2305, 883, 2896, 919, 2305, 897, 2844, + /* 4260 */ 2305, 2305, 2895, 2305, 2863, 2305, 460, 2846, 900, 2848, + /* 4270 */ 2849, 895, 2305, 2305, 883, 2896, 919, 2305, 2305, 2305, + /* 4280 */ 2810, 2305, 896, 2305, 2305, 2305, 2305, 2305, 2863, 2305, + /* 4290 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 4300 */ 2305, 2305, 2305, 2305, 2810, 2305, 896, 2305, 2305, 2305, + /* 4310 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 4320 */ 2305, 2305, 2305, 2305, 2305, 2845, 2305, 2844, 2305, 2305, + /* 4330 */ 2895, 2305, 2305, 2305, 456, 2846, 900, 2848, 2849, 895, + /* 4340 */ 897, 2305, 883, 2896, 919, 2305, 2305, 2305, 2305, 2845, + /* 4350 */ 2305, 2844, 2305, 2305, 2895, 2305, 2305, 2305, 461, 2846, + /* 4360 */ 900, 2848, 2849, 895, 897, 2305, 883, 2896, 919, 2305, + /* 4370 */ 2863, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 4380 */ 2305, 2305, 2305, 2305, 2305, 2305, 2810, 2305, 896, 2305, + /* 4390 */ 2305, 2305, 2305, 2305, 2863, 2305, 2305, 2305, 2305, 2305, + /* 4400 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 4410 */ 2810, 2305, 896, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 4420 */ 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, + /* 4430 */ 2305, 2305, 2305, 898, 2305, 2305, 2895, 2305, 2305, 2305, + /* 4440 */ 432, 2846, 900, 2848, 2849, 895, 2305, 2305, 883, 2896, + /* 4450 */ 919, 2305, 2305, 2305, 2305, 2305, 2305, 2844, 2305, 2305, + /* 4460 */ 2895, 2305, 2305, 2305, 431, 2846, 900, 2848, 2849, 895, + /* 4470 */ 2305, 2305, 883, 2896, 919, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 536, 401, 536, 401, 404, 405, 404, 405, 544, 437, - /* 10 */ 544, 423, 12, 13, 4, 12, 13, 14, 15, 16, - /* 20 */ 20, 0, 22, 438, 406, 407, 562, 563, 456, 563, - /* 30 */ 423, 567, 568, 567, 568, 538, 36, 540, 38, 0, - /* 40 */ 20, 453, 21, 392, 426, 24, 25, 26, 27, 28, - /* 50 */ 29, 30, 31, 32, 20, 406, 407, 431, 407, 34, - /* 60 */ 453, 8, 9, 437, 54, 12, 13, 14, 15, 16, - /* 70 */ 0, 71, 21, 20, 74, 24, 25, 26, 27, 28, - /* 80 */ 29, 30, 31, 32, 499, 85, 20, 455, 437, 20, - /* 90 */ 464, 503, 504, 505, 24, 25, 26, 27, 28, 29, - /* 100 */ 30, 31, 32, 14, 453, 517, 455, 475, 476, 20, - /* 110 */ 503, 504, 20, 479, 22, 115, 406, 407, 118, 80, + /* 0 */ 536, 401, 536, 455, 404, 405, 415, 440, 544, 4, + /* 10 */ 544, 423, 12, 13, 485, 12, 13, 14, 15, 16, + /* 20 */ 20, 0, 22, 475, 476, 434, 562, 563, 436, 563, + /* 30 */ 423, 567, 568, 567, 568, 444, 36, 440, 38, 0, + /* 40 */ 443, 453, 21, 392, 452, 24, 25, 26, 27, 28, + /* 50 */ 29, 30, 31, 32, 437, 406, 407, 20, 407, 54, + /* 60 */ 453, 8, 9, 446, 447, 12, 13, 14, 15, 16, + /* 70 */ 503, 71, 21, 20, 74, 24, 25, 26, 27, 28, + /* 80 */ 29, 30, 31, 32, 517, 85, 20, 455, 437, 8, + /* 90 */ 9, 503, 504, 12, 13, 14, 15, 16, 59, 401, + /* 100 */ 503, 469, 404, 405, 453, 517, 455, 475, 476, 20, + /* 110 */ 503, 504, 505, 479, 517, 115, 406, 407, 118, 80, /* 120 */ 81, 82, 83, 84, 517, 86, 87, 88, 89, 90, /* 130 */ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, /* 140 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, - /* 150 */ 111, 500, 118, 61, 503, 155, 156, 416, 507, 508, - /* 160 */ 509, 510, 511, 512, 118, 424, 515, 516, 517, 20, + /* 150 */ 111, 500, 440, 438, 503, 155, 156, 120, 507, 508, + /* 160 */ 509, 510, 511, 512, 525, 526, 515, 516, 517, 20, /* 170 */ 536, 21, 20, 522, 22, 524, 20, 71, 544, 528, /* 180 */ 529, 532, 533, 534, 118, 536, 537, 37, 36, 39, - /* 190 */ 40, 41, 42, 544, 194, 195, 562, 563, 391, 548, - /* 200 */ 393, 567, 568, 3, 204, 205, 451, 556, 427, 454, - /* 210 */ 455, 562, 563, 61, 194, 195, 567, 568, 437, 219, - /* 220 */ 20, 221, 199, 117, 20, 44, 226, 14, 122, 448, - /* 230 */ 8, 9, 20, 20, 12, 13, 14, 15, 16, 57, - /* 240 */ 118, 531, 532, 533, 534, 4, 536, 537, 66, 196, + /* 190 */ 40, 41, 42, 544, 194, 195, 562, 563, 20, 548, + /* 200 */ 20, 567, 568, 3, 204, 205, 451, 556, 118, 454, + /* 210 */ 455, 562, 563, 61, 499, 503, 567, 568, 20, 219, + /* 220 */ 20, 221, 199, 117, 416, 44, 226, 14, 122, 517, + /* 230 */ 8, 9, 424, 20, 12, 13, 14, 15, 16, 57, + /* 240 */ 118, 531, 532, 533, 534, 20, 536, 537, 66, 196, /* 250 */ 71, 69, 70, 406, 254, 255, 256, 392, 258, 259, /* 260 */ 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, - /* 270 */ 270, 271, 407, 20, 274, 275, 276, 277, 278, 279, + /* 270 */ 270, 271, 407, 149, 274, 275, 276, 277, 278, 279, /* 280 */ 280, 281, 282, 283, 284, 285, 286, 287, 288, 12, - /* 290 */ 13, 14, 406, 392, 18, 189, 20, 20, 118, 22, + /* 290 */ 13, 14, 211, 392, 18, 189, 20, 20, 0, 22, /* 300 */ 78, 122, 437, 27, 457, 458, 30, 460, 407, 256, - /* 310 */ 463, 155, 156, 36, 38, 38, 406, 407, 453, 119, - /* 320 */ 455, 0, 8, 9, 120, 256, 12, 13, 14, 15, - /* 330 */ 16, 431, 56, 57, 0, 59, 426, 437, 437, 158, - /* 340 */ 64, 65, 319, 320, 321, 322, 323, 313, 71, 455, - /* 350 */ 128, 74, 76, 20, 453, 78, 455, 471, 472, 313, - /* 360 */ 204, 205, 85, 469, 464, 500, 20, 392, 503, 475, - /* 370 */ 476, 118, 507, 508, 509, 510, 511, 512, 513, 313, + /* 310 */ 463, 155, 156, 36, 38, 38, 118, 4, 453, 119, + /* 320 */ 455, 0, 24, 25, 26, 27, 28, 29, 30, 31, + /* 330 */ 32, 431, 56, 57, 0, 59, 407, 437, 437, 158, + /* 340 */ 64, 65, 319, 320, 321, 322, 323, 14, 71, 455, + /* 350 */ 128, 74, 76, 20, 453, 78, 455, 3, 234, 235, + /* 360 */ 204, 205, 85, 469, 464, 500, 437, 392, 503, 475, + /* 370 */ 476, 36, 507, 508, 509, 510, 511, 512, 513, 313, /* 380 */ 515, 516, 517, 518, 519, 148, 149, 150, 151, 152, - /* 390 */ 153, 154, 115, 117, 422, 118, 196, 425, 218, 20, - /* 400 */ 220, 500, 254, 438, 503, 129, 455, 194, 507, 508, - /* 410 */ 509, 510, 511, 512, 449, 193, 515, 516, 517, 20, - /* 420 */ 469, 520, 436, 522, 523, 524, 475, 476, 453, 528, - /* 430 */ 529, 251, 155, 156, 52, 313, 160, 161, 452, 163, - /* 440 */ 164, 165, 166, 167, 168, 169, 170, 171, 172, 406, - /* 450 */ 407, 175, 176, 177, 178, 179, 180, 181, 182, 402, - /* 460 */ 184, 185, 186, 406, 20, 408, 190, 191, 192, 256, + /* 390 */ 153, 154, 115, 117, 20, 118, 196, 20, 406, 407, + /* 400 */ 22, 500, 254, 313, 503, 129, 36, 194, 507, 508, + /* 410 */ 509, 510, 511, 512, 36, 193, 515, 516, 517, 76, + /* 420 */ 0, 520, 341, 522, 523, 524, 12, 13, 453, 528, + /* 430 */ 529, 118, 155, 156, 256, 313, 160, 161, 509, 163, + /* 440 */ 164, 165, 166, 167, 168, 169, 170, 171, 172, 20, + /* 450 */ 36, 175, 176, 177, 178, 179, 180, 181, 182, 431, + /* 460 */ 184, 185, 186, 20, 77, 437, 190, 191, 192, 256, /* 470 */ 437, 194, 195, 197, 326, 327, 328, 329, 330, 331, /* 480 */ 332, 204, 205, 302, 303, 304, 305, 306, 307, 308, - /* 490 */ 309, 310, 158, 313, 272, 174, 219, 464, 221, 2, - /* 500 */ 179, 155, 156, 226, 461, 8, 9, 173, 187, 12, + /* 490 */ 309, 310, 464, 115, 272, 174, 219, 464, 221, 2, + /* 500 */ 179, 14, 20, 226, 77, 8, 9, 20, 187, 12, /* 510 */ 13, 14, 15, 16, 292, 293, 294, 295, 296, 297, - /* 520 */ 298, 299, 300, 301, 4, 211, 306, 307, 308, 309, - /* 530 */ 310, 254, 255, 256, 392, 258, 259, 260, 261, 262, + /* 520 */ 298, 299, 300, 301, 532, 533, 534, 194, 536, 537, + /* 530 */ 0, 254, 255, 256, 392, 258, 259, 260, 261, 262, /* 540 */ 263, 264, 265, 266, 267, 268, 269, 270, 271, 407, - /* 550 */ 536, 274, 275, 276, 277, 278, 315, 406, 544, 282, + /* 550 */ 536, 274, 275, 276, 277, 278, 221, 214, 544, 282, /* 560 */ 283, 284, 285, 286, 287, 288, 12, 13, 392, 158, - /* 570 */ 22, 407, 12, 13, 20, 196, 22, 563, 196, 437, - /* 580 */ 437, 567, 568, 407, 36, 14, 525, 526, 115, 207, - /* 590 */ 36, 20, 38, 20, 402, 453, 36, 455, 406, 456, - /* 600 */ 408, 437, 4, 130, 131, 132, 133, 134, 135, 136, + /* 570 */ 22, 194, 195, 118, 20, 406, 22, 563, 158, 437, + /* 580 */ 246, 567, 568, 407, 36, 242, 243, 57, 115, 256, + /* 590 */ 36, 221, 38, 173, 538, 453, 540, 455, 155, 156, + /* 600 */ 118, 392, 4, 130, 131, 132, 133, 134, 135, 136, /* 610 */ 137, 138, 139, 437, 141, 142, 143, 144, 145, 146, - /* 620 */ 147, 23, 438, 439, 406, 71, 437, 506, 74, 453, - /* 630 */ 231, 455, 78, 85, 437, 406, 407, 448, 118, 85, - /* 640 */ 489, 490, 500, 446, 447, 503, 48, 49, 50, 507, - /* 650 */ 508, 509, 510, 511, 512, 341, 535, 515, 516, 517, - /* 660 */ 406, 407, 77, 115, 522, 437, 524, 411, 412, 115, - /* 670 */ 528, 529, 118, 509, 446, 447, 500, 406, 407, 503, - /* 680 */ 426, 392, 20, 507, 508, 509, 510, 511, 512, 435, - /* 690 */ 461, 515, 516, 517, 497, 498, 407, 426, 556, 0, - /* 700 */ 524, 14, 15, 16, 528, 529, 435, 489, 490, 155, - /* 710 */ 156, 406, 407, 302, 303, 304, 305, 306, 307, 308, - /* 720 */ 309, 310, 36, 8, 9, 77, 437, 12, 13, 14, - /* 730 */ 15, 16, 80, 81, 82, 406, 407, 1, 2, 87, - /* 740 */ 88, 89, 453, 129, 455, 93, 36, 36, 194, 195, - /* 750 */ 98, 99, 100, 101, 158, 289, 104, 76, 204, 205, - /* 760 */ 108, 109, 110, 111, 506, 194, 461, 219, 85, 221, - /* 770 */ 454, 455, 2, 219, 22, 221, 77, 20, 8, 9, - /* 780 */ 226, 221, 12, 13, 14, 15, 16, 440, 36, 500, - /* 790 */ 443, 406, 503, 535, 20, 85, 507, 508, 509, 510, + /* 620 */ 147, 23, 252, 253, 406, 71, 313, 438, 74, 453, + /* 630 */ 256, 455, 78, 85, 437, 221, 406, 407, 449, 85, + /* 640 */ 471, 472, 500, 446, 447, 503, 48, 49, 50, 507, + /* 650 */ 508, 509, 510, 511, 512, 289, 426, 515, 516, 517, + /* 660 */ 406, 407, 453, 115, 522, 189, 524, 406, 407, 115, + /* 670 */ 528, 529, 118, 218, 13, 220, 500, 406, 407, 503, + /* 680 */ 426, 392, 36, 507, 508, 509, 510, 511, 512, 435, + /* 690 */ 336, 515, 516, 517, 497, 498, 407, 426, 556, 223, + /* 700 */ 524, 438, 439, 158, 528, 529, 251, 489, 490, 155, + /* 710 */ 156, 454, 455, 302, 303, 304, 305, 306, 307, 308, + /* 720 */ 309, 310, 461, 8, 9, 129, 437, 12, 13, 14, + /* 730 */ 15, 16, 80, 81, 82, 406, 407, 406, 407, 87, + /* 740 */ 88, 89, 453, 85, 455, 93, 85, 506, 194, 195, + /* 750 */ 98, 99, 100, 101, 406, 407, 104, 426, 204, 205, + /* 760 */ 108, 109, 110, 111, 62, 63, 435, 219, 313, 221, + /* 770 */ 406, 407, 2, 219, 426, 221, 535, 20, 8, 9, + /* 780 */ 226, 34, 12, 13, 14, 15, 16, 402, 20, 500, + /* 790 */ 426, 406, 503, 408, 0, 313, 507, 508, 509, 510, /* 800 */ 511, 512, 254, 255, 515, 516, 517, 389, 254, 255, /* 810 */ 256, 392, 258, 259, 260, 261, 262, 263, 264, 265, - /* 820 */ 266, 267, 268, 269, 270, 271, 407, 256, 274, 275, - /* 830 */ 276, 277, 278, 313, 119, 392, 282, 283, 284, 285, - /* 840 */ 286, 287, 288, 289, 12, 13, 557, 558, 406, 407, - /* 850 */ 503, 466, 20, 468, 22, 119, 437, 129, 196, 22, - /* 860 */ 115, 532, 533, 534, 517, 536, 537, 115, 36, 506, - /* 870 */ 38, 189, 453, 36, 455, 130, 131, 132, 133, 134, + /* 820 */ 266, 267, 268, 269, 270, 271, 407, 33, 274, 275, + /* 830 */ 276, 277, 278, 129, 119, 20, 282, 283, 284, 285, + /* 840 */ 286, 287, 288, 289, 12, 13, 557, 558, 303, 304, + /* 850 */ 305, 402, 20, 437, 22, 406, 437, 408, 406, 36, + /* 860 */ 115, 532, 533, 534, 448, 536, 537, 221, 36, 391, + /* 870 */ 38, 393, 453, 438, 455, 130, 131, 132, 133, 134, /* 880 */ 135, 136, 137, 138, 139, 437, 141, 142, 143, 144, - /* 890 */ 145, 146, 147, 445, 392, 214, 453, 479, 535, 303, - /* 900 */ 304, 305, 484, 71, 456, 223, 74, 221, 415, 437, - /* 910 */ 78, 62, 63, 406, 407, 23, 149, 85, 256, 500, - /* 920 */ 440, 413, 503, 242, 243, 94, 507, 508, 509, 510, - /* 930 */ 511, 512, 221, 426, 515, 516, 517, 444, 252, 253, - /* 940 */ 44, 49, 50, 524, 392, 406, 407, 115, 529, 441, - /* 950 */ 118, 440, 115, 196, 536, 453, 485, 406, 407, 407, - /* 960 */ 479, 409, 544, 252, 253, 426, 18, 71, 194, 497, - /* 970 */ 498, 23, 12, 13, 532, 533, 534, 426, 536, 537, - /* 980 */ 562, 563, 22, 503, 536, 567, 568, 155, 156, 437, - /* 990 */ 42, 43, 544, 162, 46, 392, 36, 517, 38, 411, - /* 1000 */ 412, 234, 235, 55, 0, 453, 438, 455, 60, 392, - /* 1010 */ 562, 563, 438, 256, 503, 567, 568, 536, 187, 188, - /* 1020 */ 72, 73, 74, 75, 76, 544, 194, 195, 517, 413, - /* 1030 */ 256, 71, 201, 33, 8, 9, 204, 205, 12, 13, - /* 1040 */ 14, 15, 16, 562, 563, 85, 430, 47, 567, 568, - /* 1050 */ 392, 219, 500, 221, 415, 503, 453, 441, 226, 507, - /* 1060 */ 508, 509, 510, 511, 512, 22, 118, 515, 516, 517, - /* 1070 */ 453, 420, 421, 434, 522, 115, 524, 149, 150, 36, - /* 1080 */ 528, 529, 154, 444, 479, 3, 254, 255, 256, 484, + /* 890 */ 145, 146, 147, 445, 406, 407, 506, 479, 252, 253, + /* 900 */ 149, 150, 484, 71, 456, 154, 74, 94, 85, 437, + /* 910 */ 78, 465, 306, 307, 308, 309, 310, 85, 36, 500, + /* 920 */ 406, 407, 503, 406, 407, 535, 507, 508, 509, 510, + /* 930 */ 511, 512, 406, 407, 515, 516, 517, 438, 406, 407, + /* 940 */ 426, 489, 490, 524, 392, 406, 407, 115, 529, 461, + /* 950 */ 118, 392, 426, 196, 536, 437, 406, 407, 426, 407, + /* 960 */ 479, 409, 544, 445, 196, 426, 18, 85, 406, 497, + /* 970 */ 498, 23, 12, 13, 456, 162, 426, 20, 461, 22, + /* 980 */ 562, 563, 22, 437, 536, 567, 568, 155, 156, 437, + /* 990 */ 42, 43, 544, 438, 46, 392, 36, 289, 38, 291, + /* 1000 */ 187, 188, 456, 55, 0, 453, 438, 455, 60, 194, + /* 1010 */ 562, 563, 453, 256, 201, 567, 568, 536, 61, 438, + /* 1020 */ 72, 73, 74, 75, 76, 544, 194, 195, 466, 422, + /* 1030 */ 468, 71, 425, 22, 8, 9, 204, 205, 12, 13, + /* 1040 */ 14, 15, 16, 562, 563, 85, 437, 36, 567, 568, + /* 1050 */ 129, 219, 500, 221, 445, 503, 453, 20, 226, 507, + /* 1060 */ 508, 509, 510, 511, 512, 456, 118, 515, 516, 517, + /* 1070 */ 521, 256, 523, 392, 522, 115, 524, 14, 15, 16, + /* 1080 */ 528, 529, 1, 2, 479, 23, 254, 255, 256, 484, /* 1090 */ 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, - /* 1100 */ 268, 269, 270, 271, 13, 157, 274, 275, 276, 277, - /* 1110 */ 278, 453, 420, 421, 282, 283, 284, 285, 286, 287, - /* 1120 */ 288, 12, 13, 14, 406, 407, 392, 392, 85, 20, - /* 1130 */ 392, 22, 8, 9, 395, 396, 12, 13, 14, 15, - /* 1140 */ 16, 536, 150, 437, 426, 36, 154, 38, 424, 544, - /* 1150 */ 4, 445, 148, 149, 150, 151, 152, 153, 154, 211, - /* 1160 */ 212, 213, 456, 33, 216, 19, 437, 562, 563, 0, - /* 1170 */ 392, 47, 567, 568, 445, 438, 85, 229, 230, 219, - /* 1180 */ 71, 221, 428, 74, 38, 456, 432, 453, 453, 241, - /* 1190 */ 0, 453, 244, 438, 85, 247, 248, 249, 250, 251, - /* 1200 */ 432, 8, 9, 57, 438, 12, 13, 14, 15, 16, - /* 1210 */ 64, 65, 406, 407, 254, 255, 289, 71, 291, 392, - /* 1220 */ 228, 392, 438, 437, 115, 233, 33, 118, 236, 437, - /* 1230 */ 238, 453, 426, 447, 274, 275, 407, 445, 409, 33, - /* 1240 */ 406, 407, 282, 283, 284, 285, 286, 287, 456, 406, + /* 1100 */ 268, 269, 270, 271, 183, 157, 274, 275, 276, 277, + /* 1110 */ 278, 49, 50, 392, 282, 283, 284, 285, 286, 287, + /* 1120 */ 288, 12, 13, 14, 406, 407, 115, 392, 438, 20, + /* 1130 */ 392, 22, 8, 9, 453, 0, 12, 13, 14, 15, + /* 1140 */ 16, 536, 150, 55, 426, 36, 154, 38, 520, 544, + /* 1150 */ 4, 523, 148, 149, 150, 151, 152, 153, 154, 211, + /* 1160 */ 212, 213, 406, 407, 216, 19, 427, 562, 563, 0, + /* 1170 */ 392, 47, 567, 568, 453, 393, 437, 229, 230, 219, + /* 1180 */ 71, 221, 426, 74, 38, 411, 412, 448, 453, 241, + /* 1190 */ 0, 453, 244, 58, 85, 247, 248, 249, 250, 251, + /* 1200 */ 119, 8, 9, 57, 22, 12, 13, 14, 15, 16, + /* 1210 */ 64, 65, 406, 407, 254, 255, 450, 71, 36, 453, + /* 1220 */ 228, 392, 411, 412, 115, 233, 33, 118, 236, 437, + /* 1230 */ 238, 453, 426, 196, 274, 275, 407, 445, 409, 420, + /* 1240 */ 421, 392, 282, 283, 284, 285, 286, 287, 456, 406, /* 1250 */ 407, 8, 9, 406, 407, 12, 13, 14, 15, 16, - /* 1260 */ 426, 313, 494, 117, 155, 156, 437, 20, 122, 426, - /* 1270 */ 80, 81, 82, 426, 20, 0, 33, 87, 88, 89, - /* 1280 */ 453, 437, 453, 93, 455, 406, 407, 392, 98, 99, - /* 1290 */ 100, 101, 571, 392, 104, 406, 407, 437, 108, 109, - /* 1300 */ 110, 111, 0, 194, 195, 426, 406, 407, 521, 521, - /* 1310 */ 523, 523, 119, 204, 205, 426, 456, 148, 149, 150, - /* 1320 */ 151, 152, 153, 154, 22, 119, 426, 392, 219, 500, - /* 1330 */ 221, 193, 503, 13, 33, 226, 507, 508, 509, 510, - /* 1340 */ 511, 512, 498, 393, 515, 516, 517, 450, 453, 450, - /* 1350 */ 453, 522, 453, 524, 453, 392, 148, 528, 529, 392, - /* 1360 */ 152, 538, 119, 254, 255, 256, 392, 258, 259, 260, + /* 1260 */ 4, 313, 424, 117, 155, 156, 437, 85, 122, 426, + /* 1270 */ 80, 81, 82, 426, 20, 538, 33, 87, 88, 89, + /* 1280 */ 413, 52, 453, 93, 455, 406, 407, 392, 98, 99, + /* 1290 */ 100, 101, 560, 256, 104, 406, 407, 430, 108, 109, + /* 1300 */ 110, 111, 453, 194, 195, 426, 406, 407, 441, 521, + /* 1310 */ 13, 523, 119, 204, 205, 426, 44, 148, 149, 150, + /* 1320 */ 151, 152, 153, 154, 413, 237, 426, 392, 219, 500, + /* 1330 */ 221, 193, 503, 420, 421, 226, 507, 508, 509, 510, + /* 1340 */ 511, 512, 437, 71, 515, 516, 517, 450, 453, 0, + /* 1350 */ 453, 522, 441, 524, 0, 392, 428, 528, 529, 392, + /* 1360 */ 432, 456, 119, 254, 255, 256, 392, 258, 259, 260, /* 1370 */ 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, - /* 1380 */ 271, 407, 0, 274, 275, 276, 277, 278, 453, 406, + /* 1380 */ 271, 407, 85, 274, 275, 276, 277, 278, 453, 406, /* 1390 */ 407, 282, 283, 284, 285, 286, 287, 288, 12, 13, - /* 1400 */ 392, 406, 407, 406, 407, 85, 20, 0, 22, 426, - /* 1410 */ 272, 437, 406, 407, 392, 407, 453, 409, 336, 392, - /* 1420 */ 453, 426, 36, 426, 38, 520, 44, 453, 523, 455, - /* 1430 */ 292, 392, 426, 8, 9, 406, 407, 12, 13, 14, + /* 1400 */ 392, 406, 407, 406, 407, 392, 20, 392, 22, 426, + /* 1410 */ 272, 437, 406, 407, 392, 407, 453, 409, 437, 392, + /* 1420 */ 453, 426, 36, 426, 38, 196, 392, 453, 33, 455, + /* 1430 */ 292, 77, 426, 8, 9, 506, 207, 12, 13, 14, /* 1440 */ 15, 16, 8, 9, 427, 437, 12, 13, 14, 15, - /* 1450 */ 16, 55, 406, 407, 437, 426, 14, 71, 406, 407, - /* 1460 */ 74, 453, 20, 455, 57, 448, 450, 406, 407, 453, - /* 1470 */ 340, 85, 426, 0, 500, 453, 465, 503, 426, 33, - /* 1480 */ 453, 507, 508, 509, 510, 511, 512, 426, 514, 515, - /* 1490 */ 516, 517, 453, 47, 129, 0, 123, 123, 392, 126, - /* 1500 */ 126, 115, 33, 256, 118, 119, 155, 156, 500, 0, - /* 1510 */ 256, 503, 13, 407, 36, 507, 508, 509, 510, 511, - /* 1520 */ 512, 246, 33, 515, 516, 517, 123, 0, 33, 126, - /* 1530 */ 522, 123, 524, 33, 126, 36, 528, 529, 0, 13, - /* 1540 */ 33, 155, 156, 437, 119, 0, 33, 560, 183, 22, + /* 1450 */ 16, 437, 450, 14, 437, 453, 0, 71, 148, 20, + /* 1460 */ 74, 453, 152, 455, 535, 448, 453, 415, 453, 0, + /* 1470 */ 456, 85, 432, 123, 500, 453, 126, 503, 33, 498, + /* 1480 */ 453, 507, 508, 509, 510, 511, 512, 453, 514, 515, + /* 1490 */ 516, 517, 437, 395, 396, 33, 444, 571, 392, 33, + /* 1500 */ 44, 115, 447, 33, 118, 119, 20, 158, 500, 47, + /* 1510 */ 256, 503, 36, 407, 119, 507, 508, 509, 510, 511, + /* 1520 */ 512, 33, 33, 515, 516, 517, 123, 539, 123, 126, + /* 1530 */ 522, 126, 524, 33, 494, 47, 528, 529, 0, 13, + /* 1540 */ 13, 155, 156, 437, 119, 123, 155, 156, 126, 553, /* 1550 */ 8, 9, 33, 119, 12, 13, 14, 15, 16, 453, - /* 1560 */ 22, 455, 36, 85, 1, 2, 78, 22, 8, 9, - /* 1570 */ 12, 13, 12, 13, 14, 15, 16, 36, 8, 9, - /* 1580 */ 194, 195, 12, 13, 14, 15, 16, 553, 119, 47, + /* 1560 */ 22, 455, 36, 36, 119, 1, 2, 410, 8, 9, + /* 1570 */ 78, 315, 12, 13, 14, 15, 16, 437, 8, 9, + /* 1580 */ 194, 195, 12, 13, 14, 15, 16, 423, 36, 47, /* 1590 */ 204, 205, 8, 9, 33, 33, 12, 13, 14, 15, - /* 1600 */ 16, 33, 33, 12, 13, 219, 500, 221, 119, 503, - /* 1610 */ 33, 539, 226, 507, 508, 509, 510, 511, 512, 119, - /* 1620 */ 33, 515, 516, 517, 51, 36, 119, 410, 522, 437, - /* 1630 */ 524, 158, 119, 237, 528, 529, 12, 13, 119, 338, - /* 1640 */ 254, 255, 256, 33, 258, 259, 260, 261, 262, 263, - /* 1650 */ 264, 265, 266, 267, 268, 269, 270, 271, 33, 423, - /* 1660 */ 274, 275, 276, 277, 278, 33, 33, 158, 282, 283, + /* 1600 */ 16, 118, 33, 120, 33, 219, 500, 221, 119, 503, + /* 1610 */ 0, 0, 226, 507, 508, 509, 510, 511, 512, 119, + /* 1620 */ 33, 515, 516, 517, 12, 13, 51, 158, 522, 423, + /* 1630 */ 524, 405, 22, 22, 528, 529, 0, 85, 119, 465, + /* 1640 */ 254, 255, 256, 559, 258, 259, 260, 261, 262, 263, + /* 1650 */ 264, 265, 266, 267, 268, 269, 270, 271, 22, 559, + /* 1660 */ 274, 275, 276, 277, 278, 478, 33, 33, 282, 283, /* 1670 */ 284, 285, 286, 287, 288, 12, 13, 392, 33, 119, - /* 1680 */ 119, 119, 479, 20, 423, 22, 33, 119, 119, 119, - /* 1690 */ 33, 118, 407, 118, 409, 120, 119, 405, 273, 36, - /* 1700 */ 33, 38, 0, 119, 12, 13, 119, 8, 9, 465, - /* 1710 */ 47, 12, 13, 14, 15, 16, 12, 13, 36, 8, - /* 1720 */ 9, 559, 437, 12, 13, 14, 15, 16, 392, 119, + /* 1680 */ 119, 119, 479, 20, 559, 22, 33, 559, 119, 119, + /* 1690 */ 119, 33, 407, 118, 409, 12, 13, 221, 273, 36, + /* 1700 */ 33, 38, 465, 119, 33, 410, 119, 8, 9, 501, + /* 1710 */ 47, 12, 13, 14, 15, 16, 407, 231, 452, 8, + /* 1720 */ 9, 486, 437, 12, 13, 14, 15, 16, 392, 33, /* 1730 */ 12, 13, 12, 13, 71, 12, 13, 74, 453, 536, - /* 1740 */ 455, 33, 254, 407, 119, 12, 13, 544, 85, 12, - /* 1750 */ 13, 119, 119, 12, 13, 36, 13, 13, 47, 559, - /* 1760 */ 58, 559, 221, 33, 119, 562, 563, 85, 33, 33, - /* 1770 */ 567, 568, 119, 437, 478, 33, 119, 559, 115, 36, - /* 1780 */ 36, 118, 465, 501, 452, 500, 119, 410, 503, 453, - /* 1790 */ 407, 455, 507, 508, 509, 510, 511, 512, 486, 465, - /* 1800 */ 515, 516, 517, 465, 85, 543, 543, 522, 530, 524, - /* 1810 */ 221, 546, 564, 528, 529, 465, 8, 9, 155, 156, - /* 1820 */ 12, 13, 14, 15, 16, 425, 316, 119, 480, 57, - /* 1830 */ 119, 502, 20, 406, 20, 491, 500, 236, 496, 503, - /* 1840 */ 491, 415, 482, 507, 508, 509, 510, 511, 512, 119, - /* 1850 */ 415, 515, 516, 517, 119, 119, 217, 194, 195, 406, - /* 1860 */ 524, 119, 20, 407, 528, 529, 47, 204, 205, 8, - /* 1870 */ 9, 462, 407, 12, 13, 14, 15, 16, 462, 193, - /* 1880 */ 459, 406, 219, 407, 221, 406, 8, 9, 459, 226, - /* 1890 */ 12, 13, 14, 15, 16, 462, 459, 459, 116, 41, - /* 1900 */ 42, 419, 114, 406, 418, 113, 20, 406, 417, 406, - /* 1910 */ 406, 406, 52, 399, 403, 399, 20, 254, 255, 256, - /* 1920 */ 403, 258, 259, 260, 261, 262, 263, 264, 265, 266, - /* 1930 */ 267, 268, 269, 270, 271, 491, 415, 274, 275, 276, - /* 1940 */ 277, 278, 455, 479, 415, 282, 283, 284, 285, 286, - /* 1950 */ 287, 288, 12, 13, 415, 20, 408, 20, 481, 415, - /* 1960 */ 20, 408, 22, 20, 479, 415, 472, 415, 20, 415, - /* 1970 */ 415, 272, 466, 52, 392, 399, 36, 406, 38, 433, - /* 1980 */ 119, 415, 124, 125, 433, 127, 437, 395, 395, 407, - /* 1990 */ 453, 409, 406, 437, 437, 399, 437, 119, 239, 118, - /* 2000 */ 536, 437, 437, 495, 196, 392, 148, 413, 544, 437, - /* 2010 */ 152, 71, 20, 493, 74, 437, 437, 437, 437, 437, - /* 2020 */ 407, 536, 491, 490, 225, 85, 562, 563, 488, 544, - /* 2030 */ 224, 567, 568, 413, 487, 453, 453, 455, 453, 325, - /* 2040 */ 406, 324, 552, 455, 552, 333, 210, 562, 563, 551, - /* 2050 */ 437, 453, 567, 568, 480, 115, 392, 555, 118, 335, - /* 2060 */ 334, 312, 317, 473, 552, 542, 453, 549, 455, 554, - /* 2070 */ 473, 407, 550, 409, 311, 480, 541, 337, 339, 407, - /* 2080 */ 342, 20, 500, 129, 314, 503, 408, 413, 413, 507, + /* 1740 */ 455, 33, 33, 407, 465, 33, 254, 544, 85, 12, + /* 1750 */ 13, 13, 119, 119, 12, 13, 12, 13, 47, 12, + /* 1760 */ 13, 12, 13, 33, 119, 562, 563, 12, 13, 33, + /* 1770 */ 567, 568, 119, 437, 36, 13, 33, 119, 115, 465, + /* 1780 */ 564, 118, 543, 543, 36, 500, 119, 530, 503, 453, + /* 1790 */ 119, 455, 507, 508, 509, 510, 511, 512, 36, 33, + /* 1800 */ 515, 516, 517, 465, 338, 546, 425, 522, 480, 524, + /* 1810 */ 340, 33, 316, 528, 529, 119, 8, 9, 155, 156, + /* 1820 */ 12, 13, 14, 15, 16, 57, 502, 119, 119, 20, + /* 1830 */ 119, 119, 406, 85, 20, 491, 500, 236, 496, 503, + /* 1840 */ 217, 406, 415, 507, 508, 509, 510, 511, 512, 119, + /* 1850 */ 491, 515, 516, 517, 482, 119, 415, 194, 195, 20, + /* 1860 */ 524, 407, 119, 47, 528, 529, 462, 204, 205, 8, + /* 1870 */ 9, 462, 407, 12, 13, 14, 15, 16, 193, 459, + /* 1880 */ 406, 406, 219, 462, 221, 119, 8, 9, 407, 226, + /* 1890 */ 12, 13, 14, 15, 16, 459, 459, 119, 116, 41, + /* 1900 */ 42, 459, 114, 419, 406, 418, 113, 406, 417, 406, + /* 1910 */ 406, 406, 20, 399, 52, 403, 399, 254, 255, 256, + /* 1920 */ 491, 258, 259, 260, 261, 262, 263, 264, 265, 266, + /* 1930 */ 267, 268, 269, 270, 271, 403, 415, 274, 275, 276, + /* 1940 */ 277, 278, 20, 479, 415, 282, 283, 284, 285, 286, + /* 1950 */ 287, 288, 12, 13, 455, 415, 20, 408, 20, 481, + /* 1960 */ 20, 415, 22, 408, 479, 415, 20, 472, 415, 20, + /* 1970 */ 52, 272, 466, 415, 392, 399, 36, 433, 38, 406, + /* 1980 */ 119, 415, 124, 125, 433, 127, 453, 415, 395, 407, + /* 1990 */ 395, 409, 453, 437, 437, 406, 437, 119, 399, 239, + /* 2000 */ 536, 453, 437, 495, 196, 392, 148, 118, 544, 493, + /* 2010 */ 152, 71, 20, 491, 74, 437, 437, 437, 437, 437, + /* 2020 */ 407, 536, 437, 437, 490, 85, 562, 563, 437, 544, + /* 2030 */ 413, 567, 568, 488, 224, 453, 225, 455, 455, 413, + /* 2040 */ 325, 487, 552, 480, 406, 453, 324, 562, 563, 552, + /* 2050 */ 437, 210, 567, 568, 333, 115, 392, 555, 118, 552, + /* 2060 */ 335, 473, 551, 473, 554, 334, 453, 317, 455, 312, + /* 2070 */ 550, 407, 549, 409, 480, 311, 342, 542, 541, 339, + /* 2080 */ 565, 572, 500, 337, 566, 503, 407, 20, 129, 507, /* 2090 */ 508, 509, 510, 511, 512, 155, 156, 515, 516, 517, - /* 2100 */ 572, 437, 566, 473, 522, 506, 524, 453, 565, 453, + /* 2100 */ 314, 437, 506, 408, 522, 413, 524, 413, 473, 453, /* 2110 */ 528, 529, 453, 500, 547, 453, 503, 453, 453, 455, - /* 2120 */ 507, 508, 509, 510, 511, 512, 202, 466, 515, 516, - /* 2130 */ 517, 473, 453, 118, 194, 195, 470, 524, 413, 527, - /* 2140 */ 413, 528, 529, 453, 204, 205, 202, 545, 467, 466, - /* 2150 */ 453, 453, 118, 432, 453, 407, 453, 406, 453, 219, - /* 2160 */ 413, 221, 453, 413, 500, 413, 226, 503, 453, 453, - /* 2170 */ 442, 507, 508, 509, 510, 511, 512, 22, 394, 515, - /* 2180 */ 516, 517, 453, 35, 453, 453, 522, 453, 524, 37, - /* 2190 */ 397, 40, 528, 529, 254, 255, 256, 400, 258, 259, + /* 2120 */ 507, 508, 509, 510, 511, 512, 453, 473, 515, 516, + /* 2130 */ 517, 202, 413, 453, 194, 195, 470, 524, 466, 413, + /* 2140 */ 118, 528, 529, 545, 204, 205, 527, 202, 467, 432, + /* 2150 */ 453, 453, 466, 453, 413, 453, 453, 453, 413, 219, + /* 2160 */ 407, 221, 118, 453, 500, 413, 226, 503, 22, 453, + /* 2170 */ 442, 507, 508, 509, 510, 511, 512, 453, 406, 515, + /* 2180 */ 516, 517, 453, 35, 37, 453, 522, 499, 524, 394, + /* 2190 */ 40, 414, 528, 529, 254, 255, 256, 397, 258, 259, /* 2200 */ 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, - /* 2210 */ 270, 271, 399, 453, 274, 275, 276, 277, 278, 453, - /* 2220 */ 453, 453, 282, 283, 284, 285, 286, 287, 288, 12, - /* 2230 */ 13, 453, 453, 453, 453, 398, 453, 20, 453, 22, - /* 2240 */ 453, 483, 439, 474, 429, 499, 492, 474, 439, 429, - /* 2250 */ 429, 392, 414, 36, 390, 38, 0, 0, 0, 47, - /* 2260 */ 0, 36, 245, 36, 36, 245, 407, 36, 0, 36, - /* 2270 */ 36, 245, 36, 0, 0, 245, 0, 36, 0, 36, - /* 2280 */ 0, 22, 0, 36, 240, 0, 227, 0, 71, 227, - /* 2290 */ 221, 74, 228, 219, 0, 0, 437, 0, 215, 214, - /* 2300 */ 0, 0, 85, 161, 51, 51, 0, 36, 0, 0, - /* 2310 */ 0, 36, 453, 51, 455, 51, 47, 0, 57, 0, - /* 2320 */ 0, 0, 0, 0, 0, 0, 0, 12, 13, 0, - /* 2330 */ 0, 0, 115, 392, 36, 118, 179, 22, 179, 0, + /* 2210 */ 270, 271, 453, 398, 274, 275, 276, 277, 278, 400, + /* 2220 */ 453, 399, 282, 283, 284, 285, 286, 287, 288, 12, + /* 2230 */ 13, 492, 453, 453, 453, 439, 453, 20, 453, 22, + /* 2240 */ 453, 483, 453, 453, 453, 453, 429, 453, 474, 474, + /* 2250 */ 429, 392, 439, 36, 429, 38, 390, 0, 0, 0, + /* 2260 */ 47, 0, 36, 245, 36, 245, 407, 36, 36, 0, + /* 2270 */ 36, 36, 245, 36, 0, 0, 245, 0, 36, 0, + /* 2280 */ 36, 0, 22, 0, 36, 240, 0, 227, 71, 0, + /* 2290 */ 227, 74, 228, 221, 219, 0, 437, 0, 0, 215, + /* 2300 */ 214, 0, 85, 0, 161, 51, 51, 0, 36, 0, + /* 2310 */ 0, 0, 453, 57, 455, 51, 36, 0, 47, 0, + /* 2320 */ 0, 0, 0, 0, 51, 0, 0, 12, 13, 0, + /* 2330 */ 0, 179, 115, 392, 0, 118, 36, 22, 179, 0, /* 2340 */ 0, 0, 0, 0, 0, 0, 0, 0, 407, 0, /* 2350 */ 0, 36, 0, 38, 0, 0, 0, 0, 0, 500, - /* 2360 */ 0, 0, 503, 51, 0, 47, 507, 508, 509, 510, - /* 2370 */ 511, 512, 155, 156, 515, 516, 517, 0, 437, 161, + /* 2360 */ 0, 0, 503, 0, 51, 0, 507, 508, 509, 510, + /* 2370 */ 511, 512, 155, 156, 515, 516, 517, 0, 437, 47, /* 2380 */ 0, 522, 0, 524, 0, 0, 71, 528, 529, 0, - /* 2390 */ 0, 0, 0, 0, 453, 0, 455, 22, 0, 160, - /* 2400 */ 0, 159, 0, 0, 0, 22, 71, 0, 22, 71, - /* 2410 */ 36, 194, 195, 0, 52, 52, 0, 0, 0, 71, + /* 2390 */ 0, 0, 0, 0, 453, 22, 455, 0, 0, 161, + /* 2400 */ 160, 0, 159, 0, 0, 22, 0, 71, 22, 0, + /* 2410 */ 36, 194, 195, 0, 52, 0, 52, 0, 0, 71, /* 2420 */ 44, 204, 205, 36, 71, 57, 0, 57, 0, 57, - /* 2430 */ 36, 0, 44, 36, 0, 36, 219, 56, 221, 0, - /* 2440 */ 44, 500, 36, 226, 503, 0, 14, 33, 507, 508, - /* 2450 */ 509, 510, 511, 512, 44, 47, 515, 516, 517, 0, - /* 2460 */ 51, 0, 51, 522, 45, 524, 51, 44, 0, 528, - /* 2470 */ 529, 254, 255, 256, 0, 258, 259, 260, 261, 262, + /* 2430 */ 71, 36, 44, 0, 0, 36, 219, 56, 221, 0, + /* 2440 */ 44, 500, 0, 226, 503, 51, 36, 36, 507, 508, + /* 2450 */ 509, 510, 511, 512, 47, 33, 515, 516, 517, 51, + /* 2460 */ 44, 14, 0, 522, 45, 524, 0, 0, 44, 528, + /* 2470 */ 529, 254, 255, 256, 51, 258, 259, 260, 261, 262, /* 2480 */ 263, 264, 265, 266, 267, 268, 269, 270, 271, 1, - /* 2490 */ 0, 274, 275, 276, 277, 278, 44, 0, 210, 282, - /* 2500 */ 283, 284, 285, 286, 287, 288, 51, 19, 0, 51, - /* 2510 */ 0, 0, 79, 0, 0, 392, 36, 57, 0, 44, - /* 2520 */ 36, 57, 44, 0, 57, 36, 38, 44, 0, 36, - /* 2530 */ 407, 44, 0, 57, 219, 0, 221, 0, 0, 0, - /* 2540 */ 36, 53, 54, 0, 0, 57, 22, 126, 128, 0, - /* 2550 */ 0, 36, 22, 36, 66, 67, 68, 69, 36, 71, - /* 2560 */ 437, 36, 36, 36, 33, 36, 33, 252, 253, 254, - /* 2570 */ 36, 0, 36, 22, 22, 22, 453, 36, 455, 0, - /* 2580 */ 22, 36, 36, 36, 0, 22, 0, 0, 0, 274, - /* 2590 */ 275, 36, 36, 0, 0, 36, 36, 282, 283, 284, - /* 2600 */ 285, 286, 287, 0, 22, 117, 36, 59, 36, 20, - /* 2610 */ 122, 36, 0, 119, 118, 51, 118, 0, 196, 36, - /* 2620 */ 22, 392, 0, 500, 22, 196, 503, 226, 0, 202, + /* 2490 */ 0, 274, 275, 276, 277, 278, 0, 44, 210, 282, + /* 2500 */ 283, 284, 285, 286, 287, 288, 0, 19, 51, 0, + /* 2510 */ 51, 0, 0, 0, 79, 392, 0, 36, 57, 44, + /* 2520 */ 0, 36, 57, 44, 0, 36, 38, 57, 44, 0, + /* 2530 */ 407, 36, 0, 57, 219, 44, 221, 0, 0, 0, + /* 2540 */ 0, 53, 54, 36, 0, 57, 0, 126, 128, 22, + /* 2550 */ 36, 0, 22, 36, 66, 67, 68, 69, 36, 71, + /* 2560 */ 437, 36, 36, 0, 36, 0, 33, 252, 253, 254, + /* 2570 */ 36, 36, 36, 0, 22, 33, 453, 36, 455, 36, + /* 2580 */ 22, 36, 22, 36, 22, 0, 22, 0, 0, 274, + /* 2590 */ 275, 36, 0, 36, 0, 36, 0, 282, 283, 284, + /* 2600 */ 285, 286, 287, 36, 0, 117, 22, 59, 36, 20, + /* 2610 */ 122, 36, 36, 119, 0, 118, 118, 51, 0, 36, + /* 2620 */ 22, 392, 0, 500, 22, 196, 503, 196, 226, 202, /* 2630 */ 507, 508, 509, 510, 511, 512, 407, 232, 515, 516, - /* 2640 */ 517, 153, 196, 0, 392, 196, 206, 222, 206, 196, - /* 2650 */ 3, 33, 318, 22, 318, 231, 36, 36, 118, 407, - /* 2660 */ 52, 119, 52, 33, 51, 33, 437, 33, 33, 33, - /* 2670 */ 51, 3, 118, 36, 33, 36, 119, 318, 36, 118, - /* 2680 */ 114, 119, 453, 118, 455, 116, 198, 36, 200, 437, - /* 2690 */ 85, 203, 569, 570, 36, 119, 208, 119, 118, 118, - /* 2700 */ 36, 36, 33, 118, 51, 453, 477, 455, 51, 119, - /* 2710 */ 118, 0, 0, 0, 119, 227, 119, 118, 44, 119, - /* 2720 */ 392, 44, 203, 119, 0, 119, 119, 118, 44, 500, - /* 2730 */ 119, 33, 503, 118, 118, 407, 507, 508, 509, 510, - /* 2740 */ 511, 512, 118, 302, 515, 516, 517, 290, 119, 2, - /* 2750 */ 22, 51, 500, 254, 51, 503, 118, 22, 118, 507, - /* 2760 */ 508, 509, 510, 511, 512, 437, 199, 515, 516, 517, - /* 2770 */ 116, 392, 199, 118, 118, 198, 0, 116, 119, 0, - /* 2780 */ 118, 453, 119, 455, 118, 118, 407, 44, 118, 118, - /* 2790 */ 118, 118, 22, 51, 119, 119, 118, 118, 118, 118, - /* 2800 */ 199, 119, 119, 118, 392, 477, 118, 120, 22, 118, - /* 2810 */ 558, 121, 118, 118, 118, 118, 437, 36, 129, 407, - /* 2820 */ 119, 36, 118, 33, 119, 36, 118, 36, 500, 119, + /* 2640 */ 517, 153, 196, 0, 392, 231, 0, 222, 196, 206, + /* 2650 */ 196, 206, 3, 33, 22, 318, 33, 36, 52, 407, + /* 2660 */ 36, 52, 33, 33, 51, 85, 437, 118, 51, 119, + /* 2670 */ 33, 118, 33, 119, 118, 3, 36, 33, 36, 51, + /* 2680 */ 119, 36, 453, 36, 455, 114, 198, 118, 200, 437, + /* 2690 */ 116, 203, 569, 570, 36, 118, 208, 119, 119, 118, + /* 2700 */ 118, 36, 36, 33, 118, 453, 477, 455, 51, 119, + /* 2710 */ 119, 118, 0, 0, 119, 227, 119, 118, 318, 119, + /* 2720 */ 392, 44, 119, 0, 119, 44, 119, 0, 118, 500, + /* 2730 */ 118, 44, 503, 118, 302, 407, 507, 508, 509, 510, + /* 2740 */ 511, 512, 33, 118, 515, 516, 517, 2, 318, 51, + /* 2750 */ 119, 116, 500, 290, 116, 503, 22, 254, 51, 507, + /* 2760 */ 508, 509, 510, 511, 512, 437, 118, 515, 516, 517, + /* 2770 */ 118, 392, 118, 203, 118, 22, 257, 118, 0, 44, + /* 2780 */ 119, 453, 119, 455, 120, 118, 407, 118, 0, 118, + /* 2790 */ 22, 118, 118, 51, 119, 119, 118, 118, 118, 22, + /* 2800 */ 199, 118, 140, 119, 392, 477, 118, 199, 118, 198, + /* 2810 */ 558, 118, 121, 118, 118, 199, 437, 36, 119, 407, + /* 2820 */ 118, 118, 36, 129, 119, 119, 118, 36, 500, 118, /* 2830 */ 36, 503, 453, 119, 455, 507, 508, 509, 510, 511, - /* 2840 */ 512, 119, 36, 515, 516, 517, 232, 36, 257, 437, - /* 2850 */ 119, 118, 118, 36, 118, 140, 477, 140, 140, 140, - /* 2860 */ 22, 79, 78, 22, 36, 453, 36, 455, 36, 392, - /* 2870 */ 36, 36, 36, 36, 112, 36, 36, 85, 36, 500, - /* 2880 */ 36, 85, 503, 112, 407, 33, 507, 508, 509, 510, - /* 2890 */ 511, 512, 392, 36, 515, 516, 517, 36, 36, 22, - /* 2900 */ 36, 36, 36, 85, 36, 36, 36, 407, 36, 36, - /* 2910 */ 22, 36, 500, 57, 437, 503, 0, 36, 44, 507, - /* 2920 */ 508, 509, 510, 511, 512, 0, 36, 515, 516, 517, - /* 2930 */ 453, 44, 455, 57, 0, 36, 57, 437, 44, 0, - /* 2940 */ 36, 57, 44, 0, 36, 0, 22, 0, 22, 0, - /* 2950 */ 36, 22, 33, 453, 36, 455, 36, 22, 21, 21, - /* 2960 */ 392, 573, 22, 22, 20, 573, 573, 573, 573, 573, + /* 2840 */ 512, 119, 36, 515, 516, 517, 36, 119, 119, 437, + /* 2850 */ 36, 232, 33, 36, 118, 140, 477, 140, 140, 118, + /* 2860 */ 22, 118, 79, 78, 22, 453, 22, 455, 36, 392, + /* 2870 */ 36, 36, 36, 36, 85, 36, 36, 36, 85, 500, + /* 2880 */ 22, 36, 503, 36, 407, 36, 507, 508, 509, 510, + /* 2890 */ 511, 512, 392, 33, 515, 516, 517, 36, 36, 36, + /* 2900 */ 36, 36, 112, 36, 112, 85, 36, 407, 36, 36, + /* 2910 */ 36, 36, 500, 22, 437, 503, 36, 0, 36, 507, + /* 2920 */ 508, 509, 510, 511, 512, 57, 0, 515, 516, 517, + /* 2930 */ 453, 44, 455, 36, 57, 0, 44, 437, 36, 44, + /* 2940 */ 57, 0, 36, 57, 44, 0, 36, 0, 0, 22, + /* 2950 */ 22, 36, 0, 453, 22, 455, 33, 36, 36, 22, + /* 2960 */ 392, 21, 573, 573, 22, 22, 573, 21, 573, 20, /* 2970 */ 573, 573, 573, 561, 573, 407, 573, 500, 573, 573, /* 2980 */ 503, 573, 573, 573, 507, 508, 509, 510, 511, 512, /* 2990 */ 573, 573, 515, 516, 517, 573, 573, 573, 573, 573, @@ -1552,7 +1162,7 @@ static const YYCODETYPE yy_lookahead[] = { /* 4850 */ 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, /* 4860 */ 389, 389, 389, 389, }; -#define YY_SHIFT_COUNT (1024) +#define YY_SHIFT_COUNT (1025) #define YY_SHIFT_MIN (0) #define YY_SHIFT_MAX (2989) static const unsigned short int yy_shift_ofst[] = { @@ -1562,103 +1172,103 @@ static const unsigned short int yy_shift_ofst[] = { /* 30 */ 1940, 1940, 1663, 1940, 1940, 1940, 1940, 1940, 1940, 1940, /* 40 */ 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, /* 50 */ 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, 1940, - /* 60 */ 1940, 1940, 1940, 34, 66, 180, 253, 46, 122, 46, - /* 70 */ 46, 253, 253, 46, 960, 46, 276, 960, 520, 46, - /* 80 */ 149, 2315, 156, 156, 212, 212, 2315, 2315, 598, 598, - /* 90 */ 156, 20, 20, 346, 89, 89, 69, 204, 212, 212, - /* 100 */ 212, 212, 212, 212, 212, 212, 212, 212, 212, 333, - /* 110 */ 444, 573, 212, 212, 585, 149, 212, 333, 212, 149, - /* 120 */ 212, 212, 212, 212, 149, 212, 212, 212, 149, 212, - /* 130 */ 149, 149, 149, 648, 222, 222, 473, 473, 745, 652, + /* 60 */ 1940, 1940, 1940, 66, 482, 455, 198, 90, 122, 90, + /* 70 */ 90, 198, 198, 90, 960, 90, 276, 960, 313, 90, + /* 80 */ 89, 2315, 156, 156, 149, 149, 2315, 2315, 598, 598, + /* 90 */ 156, 377, 377, 443, 487, 487, 178, 37, 149, 149, + /* 100 */ 149, 149, 149, 149, 149, 149, 149, 149, 149, 180, + /* 110 */ 225, 429, 149, 149, 387, 89, 149, 180, 149, 89, + /* 120 */ 149, 149, 149, 149, 89, 149, 149, 149, 89, 149, + /* 130 */ 89, 89, 89, 427, 222, 222, 473, 473, 745, 652, /* 140 */ 181, 51, 548, 548, 548, 548, 548, 548, 548, 548, /* 150 */ 548, 548, 548, 548, 548, 548, 548, 548, 548, 548, - /* 160 */ 548, 1858, 200, 20, 346, 849, 849, 710, 379, 379, - /* 170 */ 379, 927, 927, 699, 1091, 710, 585, 149, 614, 149, - /* 180 */ 149, 466, 149, 149, 683, 149, 683, 683, 728, 25, + /* 160 */ 548, 1858, 200, 377, 443, 702, 702, 823, 768, 768, + /* 170 */ 768, 708, 708, 1354, 661, 823, 387, 89, 596, 89, + /* 180 */ 89, 366, 89, 89, 658, 89, 658, 658, 704, 747, /* 190 */ 2488, 473, 473, 473, 473, 473, 473, 1190, 21, 53, - /* 200 */ 411, 411, 314, 148, 23, 220, 152, 596, 213, 571, - /* 210 */ 560, 560, 892, 662, 1043, 1043, 1043, 382, 1043, 774, - /* 220 */ 757, 92, 896, 1442, 1208, 682, 1247, 1247, 1254, 1320, - /* 230 */ 1320, 1082, 1000, 241, 1247, 1091, 1510, 1772, 1812, 1814, - /* 240 */ 1601, 585, 1814, 585, 1639, 1812, 1842, 1819, 1842, 1819, - /* 250 */ 1686, 1812, 1842, 1812, 1819, 1686, 1686, 1686, 1782, 1788, - /* 260 */ 1812, 1812, 1792, 1812, 1812, 1812, 1886, 1860, 1886, 1860, - /* 270 */ 1814, 585, 585, 1896, 585, 1935, 1937, 585, 1935, 585, - /* 280 */ 1943, 585, 1948, 585, 585, 1921, 1921, 1812, 585, 1886, - /* 290 */ 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - /* 300 */ 149, 1812, 25, 25, 1886, 683, 683, 683, 1759, 1881, - /* 310 */ 1814, 648, 1992, 1799, 1806, 1896, 648, 1510, 1812, 683, - /* 320 */ 1714, 1717, 1714, 1717, 1712, 1836, 1714, 1724, 1726, 1745, - /* 330 */ 1510, 1749, 1763, 1738, 1739, 1740, 1842, 2061, 1954, 1770, - /* 340 */ 1935, 648, 648, 1717, 683, 683, 683, 683, 1717, 683, - /* 350 */ 1924, 648, 683, 1948, 648, 2015, 683, 1944, 1948, 648, - /* 360 */ 728, 648, 1842, 683, 683, 683, 683, 683, 683, 683, - /* 370 */ 683, 683, 683, 683, 683, 683, 683, 683, 683, 683, - /* 380 */ 683, 683, 683, 683, 683, 2034, 683, 1812, 648, 2155, - /* 390 */ 2148, 2152, 2151, 1886, 4475, 4475, 4475, 4475, 4475, 4475, - /* 400 */ 4475, 4475, 4475, 4475, 4475, 4475, 39, 2989, 70, 1146, + /* 200 */ 411, 411, 81, 148, 23, 606, 152, 545, 213, 333, + /* 210 */ 414, 414, 1062, 757, 1182, 1182, 1182, 1229, 1182, 815, + /* 220 */ 1037, 957, 1272, 1439, 1310, 476, 374, 374, 1254, 1297, + /* 230 */ 1297, 354, 1462, 1256, 374, 661, 1496, 1768, 1809, 1814, + /* 240 */ 1601, 387, 1814, 387, 1623, 1809, 1839, 1816, 1839, 1816, + /* 250 */ 1685, 1809, 1839, 1809, 1816, 1685, 1685, 1685, 1782, 1788, + /* 260 */ 1809, 1809, 1793, 1809, 1809, 1809, 1892, 1862, 1892, 1862, + /* 270 */ 1814, 387, 387, 1922, 387, 1936, 1938, 387, 1936, 387, + /* 280 */ 1946, 387, 1949, 387, 387, 1918, 1918, 1809, 387, 1892, + /* 290 */ 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + /* 300 */ 89, 1809, 747, 747, 1892, 658, 658, 658, 1760, 1889, + /* 310 */ 1814, 427, 1992, 1811, 1810, 1922, 427, 1496, 1809, 658, + /* 320 */ 1715, 1722, 1715, 1722, 1721, 1841, 1715, 1725, 1731, 1750, + /* 330 */ 1496, 1757, 1764, 1734, 1740, 1746, 1839, 2067, 1959, 1786, + /* 340 */ 1936, 427, 427, 1722, 658, 658, 658, 658, 1722, 658, + /* 350 */ 1929, 427, 658, 1949, 427, 2022, 658, 1945, 1949, 427, + /* 360 */ 704, 427, 1839, 658, 658, 658, 658, 658, 658, 658, + /* 370 */ 658, 658, 658, 658, 658, 658, 658, 658, 658, 658, + /* 380 */ 658, 658, 658, 658, 658, 2044, 658, 1809, 427, 2146, + /* 390 */ 2148, 2147, 2150, 1892, 4475, 4475, 4475, 4475, 4475, 4475, + /* 400 */ 4475, 4475, 4475, 4475, 4475, 4475, 39, 2989, 298, 1146, /* 410 */ 1193, 1243, 1425, 1711, 715, 1434, 1560, 1570, 1124, 497, /* 420 */ 770, 1584, 1542, 1861, 1878, 1699, 1808, 1004, 1169, 1026, /* 430 */ 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 237, 150, - /* 440 */ 992, 831, 3, 3, 681, 106, 321, 182, 686, 711, - /* 450 */ 334, 752, 837, 767, 928, 928, 687, 736, 1138, 687, - /* 460 */ 687, 687, 1407, 1275, 1206, 1382, 1446, 1365, 1473, 1509, - /* 470 */ 10, 1495, 1373, 399, 1374, 1403, 399, 1408, 1478, 1499, - /* 480 */ 1526, 1302, 1527, 1538, 1545, 1396, 1469, 1489, 179, 1500, - /* 490 */ 1513, 1519, 1561, 1351, 1301, 1130, 1507, 1562, 1568, 1569, - /* 500 */ 1563, 1577, 1488, 1587, 1610, 1632, 1573, 1625, 1633, 1645, - /* 510 */ 1653, 1657, 1558, 1591, 1624, 1692, 1704, 1718, 1720, 1723, - /* 520 */ 1733, 1737, 1741, 1667, 399, 1708, 1730, 1735, 1736, 1742, - /* 530 */ 1575, 1682, 1541, 1589, 1743, 1744, 1719, 1702, 2256, 2257, - /* 540 */ 2258, 2212, 2260, 2225, 2017, 2227, 2228, 2231, 2020, 2268, - /* 550 */ 2233, 2234, 2026, 2236, 2273, 2274, 2030, 2276, 2241, 2278, - /* 560 */ 2243, 2280, 2259, 2282, 2247, 2044, 2285, 2059, 2287, 2062, - /* 570 */ 2064, 2069, 2074, 2294, 2295, 2297, 2083, 2085, 2300, 2301, - /* 580 */ 2142, 2253, 2254, 2306, 2271, 2308, 2309, 2275, 2261, 2310, - /* 590 */ 2262, 2319, 2269, 2317, 2320, 2321, 2264, 2322, 2323, 2324, - /* 600 */ 2325, 2326, 2329, 2157, 2298, 2330, 2159, 2331, 2339, 2340, - /* 610 */ 2341, 2342, 2343, 2344, 2345, 2346, 2347, 2349, 2350, 2352, - /* 620 */ 2354, 2355, 2356, 2357, 2358, 2360, 2361, 2312, 2364, 2318, - /* 630 */ 2377, 2382, 2384, 2385, 2389, 2390, 2391, 2392, 2393, 2395, - /* 640 */ 2375, 2398, 2218, 2380, 2239, 2400, 2242, 2402, 2403, 2383, - /* 650 */ 2362, 2386, 2363, 2404, 2335, 2407, 2338, 2374, 2413, 2348, - /* 660 */ 2416, 2353, 2417, 2418, 2387, 2368, 2376, 2426, 2394, 2370, - /* 670 */ 2388, 2428, 2397, 2372, 2396, 2431, 2399, 2434, 2381, 2439, - /* 680 */ 2406, 2445, 2408, 2410, 2414, 2409, 2411, 2432, 2415, 2459, - /* 690 */ 2419, 2423, 2461, 2468, 2474, 2490, 2452, 2288, 2497, 2409, - /* 700 */ 2455, 2508, 2409, 2458, 2510, 2511, 2433, 2513, 2514, 2480, - /* 710 */ 2460, 2475, 2518, 2484, 2464, 2478, 2523, 2489, 2467, 2483, - /* 720 */ 2528, 2493, 2476, 2487, 2532, 2535, 2537, 2538, 2539, 2504, - /* 730 */ 2543, 2544, 2420, 2421, 2515, 2524, 2549, 2530, 2517, 2522, - /* 740 */ 2525, 2526, 2527, 2529, 2534, 2536, 2541, 2531, 2533, 2545, - /* 750 */ 2546, 2552, 2547, 2550, 2551, 2571, 2553, 2579, 2558, 2548, - /* 760 */ 2584, 2563, 2555, 2586, 2587, 2588, 2556, 2593, 2559, 2594, - /* 770 */ 2560, 2603, 2582, 2589, 2570, 2572, 2575, 2494, 2496, 2612, - /* 780 */ 2422, 2405, 2424, 2498, 2401, 2409, 2564, 2617, 2429, 2583, - /* 790 */ 2598, 2622, 2425, 2602, 2446, 2427, 2628, 2643, 2449, 2440, - /* 800 */ 2453, 2442, 2647, 2618, 2334, 2540, 2542, 2554, 2557, 2631, - /* 810 */ 2561, 2562, 2620, 2621, 2565, 2608, 2569, 2610, 2566, 2576, - /* 820 */ 2630, 2632, 2578, 2580, 2581, 2585, 2590, 2634, 2613, 2619, - /* 830 */ 2592, 2635, 2336, 2605, 2595, 2636, 2599, 2637, 2597, 2600, - /* 840 */ 2668, 2641, 2359, 2639, 2642, 2651, 2658, 2664, 2665, 2604, - /* 850 */ 2606, 2653, 2441, 2669, 2657, 2711, 2712, 2609, 2674, 2607, - /* 860 */ 2611, 2615, 2616, 2567, 2624, 2713, 2677, 2519, 2724, 2629, - /* 870 */ 2638, 2573, 2684, 2577, 2698, 2654, 2457, 2661, 2747, 2728, - /* 880 */ 2499, 2640, 2655, 2656, 2662, 2666, 2659, 2663, 2667, 2670, - /* 890 */ 2671, 2672, 2673, 2675, 2700, 2678, 2679, 2703, 2676, 2735, - /* 900 */ 2591, 2680, 2681, 2776, 2682, 2685, 2601, 2743, 2688, 2687, - /* 910 */ 2779, 2770, 2690, 2691, 2409, 2742, 2694, 2695, 2683, 2696, - /* 920 */ 2697, 2689, 2786, 2614, 2701, 2781, 2785, 2704, 2705, 2789, - /* 930 */ 2708, 2710, 2791, 2667, 2714, 2794, 2670, 2722, 2806, 2671, - /* 940 */ 2731, 2811, 2672, 2715, 2717, 2718, 2719, 2733, 2790, 2734, - /* 950 */ 2817, 2736, 2790, 2790, 2838, 2782, 2784, 2841, 2828, 2830, - /* 960 */ 2832, 2834, 2835, 2836, 2837, 2839, 2840, 2842, 2844, 2792, - /* 970 */ 2762, 2796, 2771, 2852, 2857, 2861, 2862, 2877, 2864, 2865, - /* 980 */ 2866, 2818, 2531, 2868, 2533, 2869, 2870, 2872, 2873, 2888, - /* 990 */ 2875, 2916, 2881, 2856, 2874, 2925, 2890, 2876, 2887, 2934, - /* 1000 */ 2899, 2879, 2894, 2939, 2904, 2884, 2898, 2943, 2908, 2945, - /* 1010 */ 2924, 2947, 2926, 2914, 2949, 2929, 2919, 2918, 2920, 2935, - /* 1020 */ 2937, 2940, 2941, 2938, 2944, + /* 440 */ 992, 813, 3, 3, 343, 106, 321, 182, 370, 646, + /* 450 */ 420, 378, 1011, 124, 751, 751, 1063, 1081, 1138, 1063, + /* 460 */ 1063, 1063, 530, 334, 1395, 1456, 1488, 921, 1349, 1469, + /* 470 */ 5, 794, 1350, 1486, 1403, 1405, 1486, 1422, 882, 1526, + /* 480 */ 1527, 1538, 1610, 1611, 1636, 1088, 1445, 1489, 179, 1519, + /* 490 */ 1561, 1562, 1569, 1391, 1466, 1470, 1500, 1587, 1633, 1634, + /* 500 */ 1564, 1645, 1492, 1571, 1653, 1658, 1575, 1667, 1671, 1708, + /* 510 */ 1709, 1712, 1612, 1683, 1718, 1720, 1723, 1737, 1742, 1744, + /* 520 */ 1747, 1749, 1755, 1696, 1486, 1730, 1736, 1743, 1766, 1778, + /* 530 */ 1483, 1552, 335, 1476, 1738, 1762, 1748, 1135, 2257, 2258, + /* 540 */ 2259, 2213, 2261, 2226, 2018, 2228, 2231, 2232, 2020, 2269, + /* 550 */ 2234, 2235, 2027, 2237, 2274, 2275, 2031, 2277, 2242, 2279, + /* 560 */ 2244, 2281, 2260, 2283, 2248, 2045, 2286, 2060, 2289, 2063, + /* 570 */ 2064, 2072, 2075, 2295, 2297, 2298, 2084, 2086, 2301, 2303, + /* 580 */ 2143, 2254, 2255, 2307, 2272, 2309, 2310, 2280, 2256, 2311, + /* 590 */ 2264, 2317, 2271, 2319, 2320, 2321, 2273, 2322, 2323, 2325, + /* 600 */ 2326, 2329, 2330, 2152, 2300, 2334, 2159, 2339, 2340, 2341, + /* 610 */ 2342, 2343, 2344, 2345, 2346, 2347, 2349, 2350, 2352, 2354, + /* 620 */ 2355, 2356, 2357, 2358, 2360, 2361, 2363, 2313, 2365, 2332, + /* 630 */ 2377, 2380, 2382, 2384, 2385, 2389, 2390, 2391, 2392, 2393, + /* 640 */ 2373, 2397, 2238, 2398, 2240, 2401, 2243, 2403, 2404, 2383, + /* 650 */ 2362, 2386, 2364, 2406, 2336, 2409, 2348, 2374, 2413, 2353, + /* 660 */ 2415, 2359, 2417, 2418, 2387, 2368, 2376, 2426, 2395, 2370, + /* 670 */ 2388, 2428, 2399, 2372, 2396, 2433, 2410, 2434, 2381, 2439, + /* 680 */ 2411, 2442, 2407, 2416, 2422, 2394, 2408, 2447, 2423, 2462, + /* 690 */ 2419, 2424, 2466, 2467, 2490, 2496, 2453, 2288, 2506, 2394, + /* 700 */ 2457, 2509, 2394, 2459, 2511, 2512, 2435, 2513, 2516, 2481, + /* 710 */ 2461, 2475, 2520, 2485, 2465, 2479, 2524, 2489, 2470, 2484, + /* 720 */ 2529, 2495, 2476, 2491, 2532, 2537, 2538, 2539, 2540, 2507, + /* 730 */ 2544, 2546, 2420, 2421, 2514, 2527, 2551, 2530, 2517, 2522, + /* 740 */ 2525, 2526, 2528, 2534, 2535, 2536, 2541, 2533, 2542, 2543, + /* 750 */ 2545, 2552, 2547, 2563, 2558, 2565, 2560, 2573, 2562, 2548, + /* 760 */ 2585, 2564, 2555, 2587, 2588, 2592, 2557, 2594, 2559, 2596, + /* 770 */ 2567, 2604, 2584, 2589, 2572, 2575, 2576, 2494, 2497, 2614, + /* 780 */ 2429, 2405, 2414, 2498, 2402, 2394, 2566, 2618, 2431, 2583, + /* 790 */ 2598, 2622, 2425, 2602, 2446, 2427, 2643, 2646, 2452, 2443, + /* 800 */ 2454, 2445, 2649, 2620, 2337, 2549, 2550, 2553, 2554, 2632, + /* 810 */ 2556, 2561, 2621, 2624, 2569, 2606, 2574, 2609, 2571, 2578, + /* 820 */ 2623, 2629, 2579, 2577, 2581, 2582, 2590, 2630, 2613, 2617, + /* 830 */ 2586, 2637, 2400, 2580, 2591, 2639, 2593, 2640, 2595, 2597, + /* 840 */ 2672, 2644, 2430, 2642, 2645, 2647, 2658, 2665, 2666, 2600, + /* 850 */ 2603, 2628, 2432, 2670, 2657, 2712, 2713, 2599, 2677, 2605, + /* 860 */ 2607, 2610, 2612, 2601, 2615, 2723, 2681, 2570, 2727, 2631, + /* 870 */ 2625, 2608, 2687, 2611, 2709, 2635, 2463, 2638, 2745, 2734, + /* 880 */ 2503, 2648, 2652, 2654, 2656, 2659, 2661, 2663, 2667, 2669, + /* 890 */ 2671, 2673, 2674, 2675, 2698, 2678, 2679, 2707, 2676, 2753, + /* 900 */ 2519, 2680, 2683, 2778, 2684, 2688, 2616, 2735, 2690, 2664, + /* 910 */ 2788, 2768, 2691, 2693, 2394, 2742, 2695, 2696, 2699, 2702, + /* 920 */ 2703, 2694, 2777, 2619, 2705, 2781, 2786, 2708, 2706, 2791, + /* 930 */ 2711, 2714, 2794, 2667, 2722, 2806, 2669, 2728, 2810, 2671, + /* 940 */ 2729, 2814, 2673, 2662, 2715, 2717, 2718, 2736, 2819, 2741, + /* 950 */ 2817, 2743, 2819, 2819, 2838, 2783, 2785, 2842, 2844, 2832, + /* 960 */ 2834, 2835, 2836, 2837, 2839, 2840, 2841, 2845, 2847, 2849, + /* 970 */ 2789, 2790, 2793, 2792, 2860, 2861, 2862, 2863, 2858, 2864, + /* 980 */ 2865, 2867, 2820, 2533, 2870, 2542, 2872, 2873, 2874, 2875, + /* 990 */ 2891, 2880, 2917, 2882, 2868, 2887, 2926, 2897, 2877, 2892, + /* 1000 */ 2935, 2902, 2883, 2895, 2941, 2906, 2886, 2900, 2945, 2910, + /* 1010 */ 2947, 2927, 2948, 2928, 2915, 2952, 2932, 2923, 2921, 2922, + /* 1020 */ 2937, 2940, 2942, 2943, 2946, 2949, }; #define YY_REDUCE_COUNT (405) #define YY_REDUCE_MIN (-536) @@ -1671,145 +1281,145 @@ static const short yy_reduce_ofst[] = { /* 40 */ 3089, 3111, 3176, 3195, 3217, 3282, 3331, 3351, 3371, 3458, /* 50 */ 3477, 3497, 3564, 3584, 3603, 3671, 3690, 3739, 3759, 3827, /* 60 */ 3851, 3933, 3957, -351, 448, 605, -290, -366, 481, 1203, - /* 70 */ 1464, 329, 442, 1485, -412, -536, -153, -393, -534, 14, - /* 80 */ 197, 347, -106, -49, 254, 271, 480, 511, -400, -398, - /* 90 */ -368, -374, -100, -245, 57, 192, 164, -382, -90, 507, - /* 100 */ 539, 551, 43, 229, 718, 806, 834, 843, 305, 151, - /* 110 */ -114, 385, 847, 879, 639, 472, 889, 218, 900, 706, - /* 120 */ 983, 995, 997, 1006, -219, 1029, 1046, 1052, 729, 1061, - /* 130 */ 228, 792, 1017, 616, 61, 61, 184, -415, -35, -259, - /* 140 */ -503, -193, -25, 443, 502, 603, 617, 658, 734, 735, - /* 150 */ 738, 778, 827, 895, 901, 935, 963, 967, 1022, 1027, - /* 160 */ 1039, -14, 121, 33, 316, 256, 588, 651, 121, 258, - /* 170 */ 363, 787, 788, 508, -28, 692, 493, 844, 768, -428, - /* 180 */ 143, 905, 189, 786, 897, 860, 899, 1016, 754, 739, - /* 190 */ 471, 568, 574, 737, 755, 766, 784, 724, 950, 1011, - /* 200 */ 823, 823, 721, 987, 1034, 1072, 1217, 823, 1192, 1192, - /* 210 */ 1236, 1261, 1292, 1244, 1162, 1200, 1202, 1296, 1218, 1192, - /* 220 */ 1317, 1377, 1282, 1383, 1332, 1312, 1334, 1338, 1192, 1262, - /* 230 */ 1263, 1248, 1278, 1265, 1350, 1400, 1348, 1329, 1427, 1344, - /* 240 */ 1342, 1426, 1349, 1435, 1360, 1453, 1456, 1409, 1465, 1416, - /* 250 */ 1421, 1475, 1476, 1479, 1433, 1429, 1437, 1438, 1482, 1486, - /* 260 */ 1497, 1501, 1491, 1503, 1504, 1505, 1514, 1511, 1516, 1517, - /* 270 */ 1444, 1521, 1529, 1487, 1539, 1548, 1477, 1544, 1553, 1550, - /* 280 */ 1494, 1552, 1506, 1554, 1555, 1546, 1551, 1571, 1566, 1576, - /* 290 */ 1549, 1556, 1557, 1559, 1564, 1565, 1572, 1578, 1579, 1580, - /* 300 */ 1581, 1586, 1592, 1593, 1596, 1537, 1583, 1585, 1508, 1520, - /* 310 */ 1531, 1594, 1533, 1540, 1547, 1588, 1620, 1574, 1634, 1598, - /* 320 */ 1490, 1590, 1492, 1597, 1502, 1515, 1512, 1498, 1522, 1518, - /* 330 */ 1595, 1523, 1535, 1528, 1536, 1543, 1672, 1599, 1567, 1602, - /* 340 */ 1678, 1674, 1675, 1630, 1654, 1656, 1659, 1662, 1658, 1665, - /* 350 */ 1666, 1725, 1679, 1661, 1727, 1612, 1690, 1681, 1683, 1747, - /* 360 */ 1721, 1750, 1748, 1697, 1698, 1701, 1703, 1705, 1709, 1715, - /* 370 */ 1716, 1729, 1731, 1732, 1734, 1760, 1766, 1767, 1768, 1778, - /* 380 */ 1779, 1780, 1781, 1783, 1785, 1728, 1787, 1751, 1752, 1784, - /* 390 */ 1793, 1837, 1797, 1813, 1758, 1803, 1746, 1754, 1769, 1773, - /* 400 */ 1815, 1820, 1809, 1821, 1838, 1864, + /* 70 */ 1464, -8, 329, 1485, -393, -536, -153, -412, -534, 14, + /* 80 */ 197, -403, -368, -106, 254, 331, -433, -288, -400, -302, + /* 90 */ -452, -100, 28, -245, 385, 449, -71, 230, 271, 348, + /* 100 */ 364, 514, 261, 488, 526, 532, 539, 550, 517, 218, + /* 110 */ 169, 562, 718, 756, -409, 472, 806, 452, 843, 518, + /* 120 */ 847, 879, 889, 900, 739, 983, 995, 997, 609, 1006, + /* 130 */ -383, 792, 1017, 867, -361, -361, 263, -285, 189, -192, + /* 140 */ 56, 478, -25, 209, 559, 603, 681, 721, 735, 738, + /* 150 */ 778, 849, 895, 935, 963, 967, 1013, 1015, 1022, 1027, + /* 160 */ 1034, -408, 241, 33, 257, 774, 811, 819, 241, 390, + /* 170 */ 929, 549, 788, 911, 607, 913, 1052, 981, 1040, 546, + /* 180 */ 905, 628, 416, 1055, 766, 1014, 897, 1002, 928, 1098, + /* 190 */ -471, 435, 499, 555, 568, 581, 690, 838, 782, 446, + /* 200 */ 737, 737, 926, 732, 996, 988, 1157, 737, 1140, 1140, + /* 210 */ 1164, 1206, 1226, 1174, 1084, 1100, 1125, 1187, 1128, 1140, + /* 220 */ 1237, 1295, 1208, 1309, 1266, 1235, 1279, 1314, 1140, 1239, + /* 230 */ 1240, 1216, 1257, 1259, 1338, 1381, 1328, 1324, 1426, 1344, + /* 240 */ 1342, 1427, 1359, 1441, 1372, 1435, 1454, 1404, 1465, 1409, + /* 250 */ 1420, 1474, 1481, 1475, 1421, 1436, 1437, 1442, 1484, 1487, + /* 260 */ 1498, 1501, 1491, 1503, 1504, 1505, 1514, 1512, 1517, 1532, + /* 270 */ 1429, 1521, 1529, 1499, 1540, 1549, 1478, 1546, 1555, 1550, + /* 280 */ 1495, 1553, 1506, 1558, 1566, 1544, 1551, 1573, 1572, 1576, + /* 290 */ 1556, 1557, 1559, 1565, 1578, 1579, 1580, 1581, 1585, 1586, + /* 300 */ 1591, 1589, 1593, 1595, 1599, 1533, 1539, 1548, 1508, 1516, + /* 310 */ 1522, 1617, 1534, 1545, 1554, 1583, 1626, 1563, 1638, 1592, + /* 320 */ 1490, 1588, 1497, 1590, 1502, 1510, 1507, 1511, 1520, 1523, + /* 330 */ 1594, 1535, 1537, 1509, 1518, 1515, 1679, 1596, 1567, 1598, + /* 340 */ 1695, 1692, 1694, 1635, 1656, 1659, 1662, 1665, 1654, 1673, + /* 350 */ 1666, 1719, 1680, 1672, 1726, 1619, 1697, 1681, 1686, 1741, + /* 360 */ 1717, 1745, 1753, 1698, 1700, 1702, 1703, 1704, 1710, 1716, + /* 370 */ 1724, 1729, 1732, 1759, 1767, 1779, 1780, 1781, 1783, 1785, + /* 380 */ 1787, 1789, 1790, 1791, 1792, 1728, 1794, 1772, 1752, 1795, + /* 390 */ 1800, 1815, 1819, 1822, 1758, 1796, 1688, 1739, 1774, 1775, + /* 400 */ 1817, 1821, 1813, 1825, 1777, 1866, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 10 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 20 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 30 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 40 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 50 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 60 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 70 */ 2300, 2300, 2300, 2683, 2300, 2300, 2639, 2300, 2300, 2300, - /* 80 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 90 */ 2300, 2646, 2646, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 100 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 110 */ 2300, 2300, 2300, 2300, 2410, 2300, 2300, 2300, 2300, 2300, - /* 120 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 130 */ 2300, 2300, 2300, 2408, 2956, 2300, 3084, 2724, 2300, 2300, - /* 140 */ 2985, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 150 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 160 */ 2300, 2300, 2968, 2300, 2300, 2381, 2381, 2300, 2968, 2968, - /* 170 */ 2968, 2928, 2928, 2408, 2300, 2300, 2410, 2300, 2726, 2300, - /* 180 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2553, 2330, - /* 190 */ 2709, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 3014, - /* 200 */ 2960, 2961, 3078, 2300, 3017, 2979, 2300, 2974, 2300, 2300, - /* 210 */ 2300, 2300, 2300, 3004, 2300, 2300, 2300, 2300, 2300, 2300, - /* 220 */ 2651, 2300, 2752, 2300, 2496, 2703, 2300, 2300, 2300, 2300, - /* 230 */ 2300, 3062, 2958, 2998, 2300, 2300, 3008, 2300, 2300, 2300, - /* 240 */ 2740, 2410, 2300, 2410, 2696, 2634, 2300, 2644, 2300, 2644, - /* 250 */ 2641, 2300, 2300, 2300, 2644, 2641, 2641, 2641, 2484, 2480, - /* 260 */ 2300, 2300, 2478, 2300, 2300, 2300, 2300, 2360, 2300, 2360, - /* 270 */ 2300, 2410, 2410, 2300, 2410, 2300, 2300, 2410, 2300, 2410, - /* 280 */ 2300, 2410, 2300, 2410, 2410, 2513, 2513, 2300, 2410, 2300, - /* 290 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 300 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2738, 2719, - /* 310 */ 2300, 2408, 2300, 2707, 2705, 2300, 2408, 3008, 2300, 2300, - /* 320 */ 3032, 3027, 3032, 3027, 3046, 3042, 3032, 3051, 3048, 3010, - /* 330 */ 3008, 2991, 2987, 3081, 3068, 3064, 2300, 2300, 2996, 2994, - /* 340 */ 2300, 2408, 2408, 3027, 2300, 2300, 2300, 2300, 3027, 2300, - /* 350 */ 2300, 2408, 2300, 2300, 2408, 2300, 2300, 2300, 2300, 2408, - /* 360 */ 2300, 2408, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 370 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 380 */ 2300, 2300, 2300, 2300, 2300, 2515, 2300, 2300, 2408, 2300, - /* 390 */ 2332, 2334, 2344, 2300, 2698, 3084, 2724, 2729, 2679, 2679, - /* 400 */ 2556, 2556, 3084, 2556, 2411, 2305, 2300, 2300, 2300, 2300, - /* 410 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 420 */ 2300, 2300, 2857, 2300, 2300, 2300, 2300, 2300, 2300, 3045, - /* 430 */ 3044, 2858, 2300, 2932, 2931, 2930, 2921, 2857, 2509, 2300, - /* 440 */ 2300, 2300, 2856, 2855, 2300, 2300, 2300, 2300, 2300, 2300, - /* 450 */ 2300, 2300, 2300, 2300, 2670, 2669, 2849, 2300, 2300, 2850, - /* 460 */ 2848, 2847, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 470 */ 2300, 2300, 2300, 2500, 2300, 2300, 2497, 2300, 2300, 2300, - /* 480 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 490 */ 2300, 2300, 2300, 2300, 3065, 3069, 2300, 2300, 2300, 2300, - /* 500 */ 2957, 2300, 2300, 2300, 2300, 2300, 2828, 2300, 2300, 2300, - /* 510 */ 2300, 2300, 2796, 2791, 2782, 2773, 2788, 2779, 2767, 2785, - /* 520 */ 2776, 2764, 2761, 2300, 2524, 2300, 2300, 2300, 2300, 2300, - /* 530 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 540 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 550 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 560 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 570 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 580 */ 2640, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 590 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 600 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 610 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 620 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 630 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 640 */ 2300, 2300, 2300, 2300, 2300, 2300, 2655, 2300, 2300, 2300, - /* 650 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 660 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 670 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 680 */ 2300, 2300, 2300, 2300, 2349, 2835, 2300, 2300, 2300, 2300, - /* 690 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2838, - /* 700 */ 2300, 2300, 2839, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 710 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 720 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 730 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 740 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2455, 2454, 2300, - /* 750 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 760 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 770 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2840, 2300, 2300, - /* 780 */ 2300, 2300, 2723, 2300, 2300, 2830, 2300, 2300, 2300, 2300, - /* 790 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 800 */ 2300, 2300, 3061, 3011, 2300, 2300, 2300, 2300, 2300, 2300, - /* 810 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 820 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2828, - /* 830 */ 2300, 3043, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 3059, - /* 840 */ 2300, 3063, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2967, - /* 850 */ 2963, 2300, 2300, 2959, 2300, 2300, 2300, 2300, 2300, 2300, - /* 860 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 870 */ 2300, 2300, 2300, 2300, 2918, 2300, 2300, 2300, 2952, 2300, - /* 880 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2552, 2551, - /* 890 */ 2550, 2549, 2300, 2300, 2300, 2300, 2300, 2300, 2840, 2300, - /* 900 */ 2843, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 910 */ 2300, 2300, 2300, 2300, 2827, 2300, 2895, 2894, 2300, 2300, - /* 920 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2546, 2300, 2300, - /* 930 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 940 */ 2300, 2300, 2300, 2530, 2528, 2527, 2526, 2300, 2563, 2300, - /* 950 */ 2300, 2300, 2559, 2558, 2300, 2300, 2300, 2300, 2300, 2300, - /* 960 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 970 */ 2300, 2300, 2300, 2429, 2300, 2300, 2300, 2300, 2300, 2300, - /* 980 */ 2300, 2300, 2421, 2300, 2420, 2300, 2300, 2300, 2300, 2300, - /* 990 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 1000 */ 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, 2300, - /* 1010 */ 2300, 2300, 2300, 2300, 2300, 2300, 2329, 2300, 2300, 2300, - /* 1020 */ 2300, 2300, 2300, 2300, 2300, + /* 0 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 10 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 20 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 30 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 40 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 50 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 60 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 70 */ 2303, 2303, 2303, 2687, 2303, 2303, 2643, 2303, 2303, 2303, + /* 80 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 90 */ 2303, 2650, 2650, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 100 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 110 */ 2303, 2303, 2303, 2303, 2413, 2303, 2303, 2303, 2303, 2303, + /* 120 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 130 */ 2303, 2303, 2303, 2411, 2960, 2303, 3088, 2728, 2303, 2303, + /* 140 */ 2989, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 150 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 160 */ 2303, 2303, 2972, 2303, 2303, 2384, 2384, 2303, 2972, 2972, + /* 170 */ 2972, 2932, 2932, 2411, 2303, 2303, 2413, 2303, 2730, 2303, + /* 180 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2557, 2333, + /* 190 */ 2713, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 3018, + /* 200 */ 2964, 2965, 3082, 2303, 3021, 2983, 2303, 2978, 2303, 2303, + /* 210 */ 2303, 2303, 2303, 3008, 2303, 2303, 2303, 2303, 2303, 2303, + /* 220 */ 2655, 2303, 2756, 2303, 2500, 2707, 2303, 2303, 2303, 2303, + /* 230 */ 2303, 3066, 2962, 3002, 2303, 2303, 3012, 2303, 2303, 2303, + /* 240 */ 2744, 2413, 2303, 2413, 2700, 2638, 2303, 2648, 2303, 2648, + /* 250 */ 2645, 2303, 2303, 2303, 2648, 2645, 2645, 2645, 2488, 2484, + /* 260 */ 2303, 2303, 2482, 2303, 2303, 2303, 2303, 2363, 2303, 2363, + /* 270 */ 2303, 2413, 2413, 2303, 2413, 2303, 2303, 2413, 2303, 2413, + /* 280 */ 2303, 2413, 2303, 2413, 2413, 2517, 2517, 2303, 2413, 2303, + /* 290 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 300 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2742, 2723, + /* 310 */ 2303, 2411, 2303, 2711, 2709, 2303, 2411, 3012, 2303, 2303, + /* 320 */ 3036, 3031, 3036, 3031, 3050, 3046, 3036, 3055, 3052, 3014, + /* 330 */ 3012, 2995, 2991, 3085, 3072, 3068, 2303, 2303, 3000, 2998, + /* 340 */ 2303, 2411, 2411, 3031, 2303, 2303, 2303, 2303, 3031, 2303, + /* 350 */ 2303, 2411, 2303, 2303, 2411, 2303, 2303, 2303, 2303, 2411, + /* 360 */ 2303, 2411, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 370 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 380 */ 2303, 2303, 2303, 2303, 2303, 2519, 2303, 2303, 2411, 2303, + /* 390 */ 2335, 2337, 2347, 2303, 2702, 3088, 2728, 2733, 2683, 2683, + /* 400 */ 2560, 2560, 3088, 2560, 2414, 2308, 2303, 2303, 2303, 2303, + /* 410 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 420 */ 2303, 2303, 2861, 2303, 2303, 2303, 2303, 2303, 2303, 3049, + /* 430 */ 3048, 2862, 2303, 2936, 2935, 2934, 2925, 2861, 2513, 2303, + /* 440 */ 2303, 2303, 2860, 2859, 2303, 2303, 2303, 2303, 2303, 2303, + /* 450 */ 2303, 2303, 2303, 2303, 2674, 2673, 2853, 2303, 2303, 2854, + /* 460 */ 2852, 2851, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 470 */ 2303, 2303, 2303, 2504, 2303, 2303, 2501, 2303, 2303, 2303, + /* 480 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 490 */ 2303, 2303, 2303, 2303, 3069, 3073, 2303, 2303, 2303, 2303, + /* 500 */ 2961, 2303, 2303, 2303, 2303, 2303, 2832, 2303, 2303, 2303, + /* 510 */ 2303, 2303, 2800, 2795, 2786, 2777, 2792, 2783, 2771, 2789, + /* 520 */ 2780, 2768, 2765, 2303, 2528, 2303, 2303, 2303, 2303, 2303, + /* 530 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 540 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 550 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 560 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 570 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 580 */ 2644, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 590 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 600 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 610 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 620 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 630 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 640 */ 2303, 2303, 2303, 2303, 2303, 2303, 2659, 2303, 2303, 2303, + /* 650 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 660 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 670 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 680 */ 2303, 2303, 2303, 2303, 2352, 2839, 2303, 2303, 2303, 2303, + /* 690 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2842, + /* 700 */ 2303, 2303, 2843, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 710 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 720 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 730 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 740 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2459, 2458, 2303, + /* 750 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 760 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 770 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2844, 2303, 2303, + /* 780 */ 2303, 2303, 2727, 2303, 2303, 2834, 2303, 2303, 2303, 2303, + /* 790 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 800 */ 2303, 2303, 3065, 3015, 2303, 2303, 2303, 2303, 2303, 2303, + /* 810 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 820 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2832, + /* 830 */ 2303, 3047, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 3063, + /* 840 */ 2303, 3067, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2971, + /* 850 */ 2967, 2303, 2303, 2963, 2303, 2303, 2303, 2303, 2303, 2303, + /* 860 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 870 */ 2303, 2303, 2303, 2303, 2922, 2303, 2303, 2303, 2956, 2303, + /* 880 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2556, 2555, + /* 890 */ 2554, 2553, 2303, 2303, 2303, 2303, 2303, 2303, 2844, 2303, + /* 900 */ 2847, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 910 */ 2303, 2303, 2303, 2303, 2831, 2303, 2899, 2898, 2303, 2303, + /* 920 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2550, 2303, 2303, + /* 930 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 940 */ 2303, 2303, 2303, 2534, 2532, 2531, 2530, 2303, 2567, 2303, + /* 950 */ 2303, 2303, 2563, 2562, 2303, 2303, 2303, 2303, 2303, 2303, + /* 960 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 970 */ 2303, 2303, 2303, 2303, 2432, 2303, 2303, 2303, 2303, 2303, + /* 980 */ 2303, 2303, 2303, 2424, 2303, 2423, 2303, 2303, 2303, 2303, + /* 990 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 1000 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2303, + /* 1010 */ 2303, 2303, 2303, 2303, 2303, 2303, 2303, 2332, 2303, 2303, + /* 1020 */ 2303, 2303, 2303, 2303, 2303, 2303, }; /********** End of lemon-generated parsing tables *****************************/ @@ -2271,7 +1881,6 @@ typedef struct yyParser yyParser; #ifndef NDEBUG #include -#include static FILE *yyTraceFILE = 0; static char *yyTracePrompt = 0; #endif /* NDEBUG */ @@ -3031,645 +2640,646 @@ static const char *const yyRuleName[] = { /* 142 */ "db_options ::= db_options S3_COMPACT NK_INTEGER", /* 143 */ "db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER", /* 144 */ "db_options ::= db_options ENCRYPT_ALGORITHM NK_STRING", - /* 145 */ "alter_db_options ::= alter_db_option", - /* 146 */ "alter_db_options ::= alter_db_options alter_db_option", - /* 147 */ "alter_db_option ::= BUFFER NK_INTEGER", - /* 148 */ "alter_db_option ::= CACHEMODEL NK_STRING", - /* 149 */ "alter_db_option ::= CACHESIZE NK_INTEGER", - /* 150 */ "alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER", - /* 151 */ "alter_db_option ::= KEEP integer_list", - /* 152 */ "alter_db_option ::= KEEP variable_list", - /* 153 */ "alter_db_option ::= PAGES NK_INTEGER", - /* 154 */ "alter_db_option ::= REPLICA NK_INTEGER", - /* 155 */ "alter_db_option ::= WAL_LEVEL NK_INTEGER", - /* 156 */ "alter_db_option ::= STT_TRIGGER NK_INTEGER", - /* 157 */ "alter_db_option ::= MINROWS NK_INTEGER", - /* 158 */ "alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER", - /* 159 */ "alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER", - /* 160 */ "alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER", - /* 161 */ "alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER", - /* 162 */ "alter_db_option ::= S3_KEEPLOCAL NK_INTEGER", - /* 163 */ "alter_db_option ::= S3_KEEPLOCAL NK_VARIABLE", - /* 164 */ "alter_db_option ::= S3_COMPACT NK_INTEGER", - /* 165 */ "alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER", - /* 166 */ "alter_db_option ::= ENCRYPT_ALGORITHM NK_STRING", - /* 167 */ "integer_list ::= NK_INTEGER", - /* 168 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", - /* 169 */ "variable_list ::= NK_VARIABLE", - /* 170 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", - /* 171 */ "retention_list ::= retention", - /* 172 */ "retention_list ::= retention_list NK_COMMA retention", - /* 173 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", - /* 174 */ "retention ::= NK_MINUS NK_COLON NK_VARIABLE", - /* 175 */ "speed_opt ::=", - /* 176 */ "speed_opt ::= BWLIMIT NK_INTEGER", - /* 177 */ "start_opt ::=", - /* 178 */ "start_opt ::= START WITH NK_INTEGER", - /* 179 */ "start_opt ::= START WITH NK_STRING", - /* 180 */ "start_opt ::= START WITH TIMESTAMP NK_STRING", - /* 181 */ "end_opt ::=", - /* 182 */ "end_opt ::= END WITH NK_INTEGER", - /* 183 */ "end_opt ::= END WITH NK_STRING", - /* 184 */ "end_opt ::= END WITH TIMESTAMP NK_STRING", - /* 185 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 186 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 187 */ "cmd ::= CREATE TABLE not_exists_opt USING full_table_name NK_LP tag_list_opt NK_RP FILE NK_STRING", - /* 188 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 189 */ "cmd ::= DROP TABLE with_opt multi_drop_clause", - /* 190 */ "cmd ::= DROP STABLE with_opt exists_opt full_table_name", - /* 191 */ "cmd ::= ALTER TABLE alter_table_clause", - /* 192 */ "cmd ::= ALTER STABLE alter_table_clause", - /* 193 */ "alter_table_clause ::= full_table_name alter_table_options", - /* 194 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name column_options", - /* 195 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", - /* 196 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", - /* 197 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name column_options", - /* 198 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", - /* 199 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", - /* 200 */ "alter_table_clause ::= full_table_name DROP TAG column_name", - /* 201 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", - /* 202 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 203 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal", - /* 204 */ "multi_create_clause ::= create_subtable_clause", - /* 205 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 206 */ "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", - /* 207 */ "multi_drop_clause ::= drop_table_clause", - /* 208 */ "multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause", - /* 209 */ "drop_table_clause ::= exists_opt full_table_name", - /* 210 */ "with_opt ::=", - /* 211 */ "with_opt ::= WITH", - /* 212 */ "specific_cols_opt ::=", - /* 213 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", - /* 214 */ "full_table_name ::= table_name", - /* 215 */ "full_table_name ::= db_name NK_DOT table_name", - /* 216 */ "tag_def_list ::= tag_def", - /* 217 */ "tag_def_list ::= tag_def_list NK_COMMA tag_def", - /* 218 */ "tag_def ::= column_name type_name", - /* 219 */ "column_def_list ::= column_def", - /* 220 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 221 */ "column_def ::= column_name type_name column_options", - /* 222 */ "type_name ::= BOOL", - /* 223 */ "type_name ::= TINYINT", - /* 224 */ "type_name ::= SMALLINT", - /* 225 */ "type_name ::= INT", - /* 226 */ "type_name ::= INTEGER", - /* 227 */ "type_name ::= BIGINT", - /* 228 */ "type_name ::= FLOAT", - /* 229 */ "type_name ::= DOUBLE", - /* 230 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 231 */ "type_name ::= TIMESTAMP", - /* 232 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 233 */ "type_name ::= TINYINT UNSIGNED", - /* 234 */ "type_name ::= SMALLINT UNSIGNED", - /* 235 */ "type_name ::= INT UNSIGNED", - /* 236 */ "type_name ::= BIGINT UNSIGNED", - /* 237 */ "type_name ::= JSON", - /* 238 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 239 */ "type_name ::= MEDIUMBLOB", - /* 240 */ "type_name ::= BLOB", - /* 241 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 242 */ "type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP", - /* 243 */ "type_name ::= DECIMAL", - /* 244 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 245 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 246 */ "type_name_default_len ::= BINARY", - /* 247 */ "type_name_default_len ::= NCHAR", - /* 248 */ "type_name_default_len ::= VARCHAR", - /* 249 */ "type_name_default_len ::= VARBINARY", - /* 250 */ "tags_def_opt ::=", - /* 251 */ "tags_def_opt ::= tags_def", - /* 252 */ "tags_def ::= TAGS NK_LP tag_def_list NK_RP", - /* 253 */ "table_options ::=", - /* 254 */ "table_options ::= table_options COMMENT NK_STRING", - /* 255 */ "table_options ::= table_options MAX_DELAY duration_list", - /* 256 */ "table_options ::= table_options WATERMARK duration_list", - /* 257 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", - /* 258 */ "table_options ::= table_options TTL NK_INTEGER", - /* 259 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 260 */ "table_options ::= table_options DELETE_MARK duration_list", - /* 261 */ "alter_table_options ::= alter_table_option", - /* 262 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 263 */ "alter_table_option ::= COMMENT NK_STRING", - /* 264 */ "alter_table_option ::= TTL NK_INTEGER", - /* 265 */ "duration_list ::= duration_literal", - /* 266 */ "duration_list ::= duration_list NK_COMMA duration_literal", - /* 267 */ "rollup_func_list ::= rollup_func_name", - /* 268 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", - /* 269 */ "rollup_func_name ::= function_name", - /* 270 */ "rollup_func_name ::= FIRST", - /* 271 */ "rollup_func_name ::= LAST", - /* 272 */ "col_name_list ::= col_name", - /* 273 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 274 */ "col_name ::= column_name", - /* 275 */ "cmd ::= SHOW DNODES", - /* 276 */ "cmd ::= SHOW USERS", - /* 277 */ "cmd ::= SHOW USERS FULL", - /* 278 */ "cmd ::= SHOW USER PRIVILEGES", - /* 279 */ "cmd ::= SHOW db_kind_opt DATABASES", - /* 280 */ "cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt", - /* 281 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 282 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 283 */ "cmd ::= SHOW MNODES", - /* 284 */ "cmd ::= SHOW QNODES", - /* 285 */ "cmd ::= SHOW ANODES", - /* 286 */ "cmd ::= SHOW ANODES FULL", - /* 287 */ "cmd ::= SHOW ARBGROUPS", - /* 288 */ "cmd ::= SHOW FUNCTIONS", - /* 289 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 290 */ "cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name", - /* 291 */ "cmd ::= SHOW STREAMS", - /* 292 */ "cmd ::= SHOW ACCOUNTS", - /* 293 */ "cmd ::= SHOW APPS", - /* 294 */ "cmd ::= SHOW CONNECTIONS", - /* 295 */ "cmd ::= SHOW LICENCES", - /* 296 */ "cmd ::= SHOW GRANTS", - /* 297 */ "cmd ::= SHOW GRANTS FULL", - /* 298 */ "cmd ::= SHOW GRANTS LOGS", - /* 299 */ "cmd ::= SHOW CLUSTER MACHINES", - /* 300 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 301 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 302 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 303 */ "cmd ::= SHOW ENCRYPTIONS", - /* 304 */ "cmd ::= SHOW QUERIES", - /* 305 */ "cmd ::= SHOW SCORES", - /* 306 */ "cmd ::= SHOW TOPICS", - /* 307 */ "cmd ::= SHOW VARIABLES", - /* 308 */ "cmd ::= SHOW CLUSTER VARIABLES", - /* 309 */ "cmd ::= SHOW LOCAL VARIABLES", - /* 310 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt", - /* 311 */ "cmd ::= SHOW BNODES", - /* 312 */ "cmd ::= SHOW SNODES", - /* 313 */ "cmd ::= SHOW CLUSTER", - /* 314 */ "cmd ::= SHOW TRANSACTIONS", - /* 315 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", - /* 316 */ "cmd ::= SHOW CONSUMERS", - /* 317 */ "cmd ::= SHOW SUBSCRIPTIONS", - /* 318 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", - /* 319 */ "cmd ::= SHOW TAGS FROM db_name NK_DOT table_name", - /* 320 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", - /* 321 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name", - /* 322 */ "cmd ::= SHOW VNODES ON DNODE NK_INTEGER", - /* 323 */ "cmd ::= SHOW VNODES", - /* 324 */ "cmd ::= SHOW db_name_cond_opt ALIVE", - /* 325 */ "cmd ::= SHOW CLUSTER ALIVE", - /* 326 */ "cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt", - /* 327 */ "cmd ::= SHOW CREATE VIEW full_table_name", - /* 328 */ "cmd ::= SHOW COMPACTS", - /* 329 */ "cmd ::= SHOW COMPACT NK_INTEGER", - /* 330 */ "table_kind_db_name_cond_opt ::=", - /* 331 */ "table_kind_db_name_cond_opt ::= table_kind", - /* 332 */ "table_kind_db_name_cond_opt ::= db_name NK_DOT", - /* 333 */ "table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT", - /* 334 */ "table_kind ::= NORMAL", - /* 335 */ "table_kind ::= CHILD", - /* 336 */ "db_name_cond_opt ::=", - /* 337 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 338 */ "like_pattern_opt ::=", - /* 339 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 340 */ "table_name_cond ::= table_name", - /* 341 */ "from_db_opt ::=", - /* 342 */ "from_db_opt ::= FROM db_name", - /* 343 */ "tag_list_opt ::=", - /* 344 */ "tag_list_opt ::= tag_item", - /* 345 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", - /* 346 */ "tag_item ::= TBNAME", - /* 347 */ "tag_item ::= QTAGS", - /* 348 */ "tag_item ::= column_name", - /* 349 */ "tag_item ::= column_name column_alias", - /* 350 */ "tag_item ::= column_name AS column_alias", - /* 351 */ "db_kind_opt ::=", - /* 352 */ "db_kind_opt ::= USER", - /* 353 */ "db_kind_opt ::= SYSTEM", - /* 354 */ "cmd ::= CREATE TSMA not_exists_opt tsma_name ON full_table_name tsma_func_list INTERVAL NK_LP duration_literal NK_RP", - /* 355 */ "cmd ::= CREATE RECURSIVE TSMA not_exists_opt tsma_name ON full_table_name INTERVAL NK_LP duration_literal NK_RP", - /* 356 */ "cmd ::= DROP TSMA exists_opt full_tsma_name", - /* 357 */ "cmd ::= SHOW db_name_cond_opt TSMAS", - /* 358 */ "full_tsma_name ::= tsma_name", - /* 359 */ "full_tsma_name ::= db_name NK_DOT tsma_name", - /* 360 */ "tsma_func_list ::= FUNCTION NK_LP func_list NK_RP", - /* 361 */ "cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options", - /* 362 */ "cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP", - /* 363 */ "cmd ::= DROP INDEX exists_opt full_index_name", - /* 364 */ "full_index_name ::= index_name", - /* 365 */ "full_index_name ::= db_name NK_DOT index_name", - /* 366 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 367 */ "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", - /* 368 */ "func_list ::= func", - /* 369 */ "func_list ::= func_list NK_COMMA func", - /* 370 */ "func ::= sma_func_name NK_LP expression_list NK_RP", - /* 371 */ "sma_func_name ::= function_name", - /* 372 */ "sma_func_name ::= COUNT", - /* 373 */ "sma_func_name ::= FIRST", - /* 374 */ "sma_func_name ::= LAST", - /* 375 */ "sma_func_name ::= LAST_ROW", - /* 376 */ "sma_stream_opt ::=", - /* 377 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", - /* 378 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", - /* 379 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", - /* 380 */ "with_meta ::= AS", - /* 381 */ "with_meta ::= WITH META AS", - /* 382 */ "with_meta ::= ONLY META AS", - /* 383 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", - /* 384 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name", - /* 385 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt", - /* 386 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 387 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 388 */ "cmd ::= DESC full_table_name", - /* 389 */ "cmd ::= DESCRIBE full_table_name", - /* 390 */ "cmd ::= RESET QUERY CACHE", - /* 391 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", - /* 392 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", - /* 393 */ "analyze_opt ::=", - /* 394 */ "analyze_opt ::= ANALYZE", - /* 395 */ "explain_options ::=", - /* 396 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 397 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 398 */ "cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt", - /* 399 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 400 */ "agg_func_opt ::=", - /* 401 */ "agg_func_opt ::= AGGREGATE", - /* 402 */ "bufsize_opt ::=", - /* 403 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 404 */ "language_opt ::=", - /* 405 */ "language_opt ::= LANGUAGE NK_STRING", - /* 406 */ "or_replace_opt ::=", - /* 407 */ "or_replace_opt ::= OR REPLACE", - /* 408 */ "cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery", - /* 409 */ "cmd ::= DROP VIEW exists_opt full_view_name", - /* 410 */ "full_view_name ::= view_name", - /* 411 */ "full_view_name ::= db_name NK_DOT view_name", - /* 412 */ "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", - /* 413 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 414 */ "cmd ::= PAUSE STREAM exists_opt stream_name", - /* 415 */ "cmd ::= RESUME STREAM exists_opt ignore_opt stream_name", - /* 416 */ "col_list_opt ::=", - /* 417 */ "col_list_opt ::= NK_LP column_stream_def_list NK_RP", - /* 418 */ "column_stream_def_list ::= column_stream_def", - /* 419 */ "column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def", - /* 420 */ "column_stream_def ::= column_name stream_col_options", - /* 421 */ "stream_col_options ::=", - /* 422 */ "stream_col_options ::= stream_col_options PRIMARY KEY", - /* 423 */ "tag_def_or_ref_opt ::=", - /* 424 */ "tag_def_or_ref_opt ::= tags_def", - /* 425 */ "tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP", - /* 426 */ "stream_options ::=", - /* 427 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 428 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 429 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 430 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 431 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 432 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", - /* 433 */ "stream_options ::= stream_options DELETE_MARK duration_literal", - /* 434 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", - /* 435 */ "subtable_opt ::=", - /* 436 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 437 */ "ignore_opt ::=", - /* 438 */ "ignore_opt ::= IGNORE UNTREATED", - /* 439 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 440 */ "cmd ::= KILL QUERY NK_STRING", - /* 441 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 442 */ "cmd ::= KILL COMPACT NK_INTEGER", - /* 443 */ "cmd ::= BALANCE VGROUP", - /* 444 */ "cmd ::= BALANCE VGROUP LEADER on_vgroup_id", - /* 445 */ "cmd ::= BALANCE VGROUP LEADER DATABASE db_name", - /* 446 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 447 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 448 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 449 */ "on_vgroup_id ::=", - /* 450 */ "on_vgroup_id ::= ON NK_INTEGER", - /* 451 */ "dnode_list ::= DNODE NK_INTEGER", - /* 452 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 453 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 454 */ "cmd ::= query_or_subquery", - /* 455 */ "cmd ::= insert_query", - /* 456 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 457 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", - /* 458 */ "tags_literal ::= NK_INTEGER", - /* 459 */ "tags_literal ::= NK_INTEGER NK_PLUS duration_literal", - /* 460 */ "tags_literal ::= NK_INTEGER NK_MINUS duration_literal", - /* 461 */ "tags_literal ::= NK_PLUS NK_INTEGER", - /* 462 */ "tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal", - /* 463 */ "tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal", - /* 464 */ "tags_literal ::= NK_MINUS NK_INTEGER", - /* 465 */ "tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal", - /* 466 */ "tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal", - /* 467 */ "tags_literal ::= NK_FLOAT", - /* 468 */ "tags_literal ::= NK_PLUS NK_FLOAT", - /* 469 */ "tags_literal ::= NK_MINUS NK_FLOAT", - /* 470 */ "tags_literal ::= NK_BIN", - /* 471 */ "tags_literal ::= NK_BIN NK_PLUS duration_literal", - /* 472 */ "tags_literal ::= NK_BIN NK_MINUS duration_literal", - /* 473 */ "tags_literal ::= NK_PLUS NK_BIN", - /* 474 */ "tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal", - /* 475 */ "tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal", - /* 476 */ "tags_literal ::= NK_MINUS NK_BIN", - /* 477 */ "tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal", - /* 478 */ "tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal", - /* 479 */ "tags_literal ::= NK_HEX", - /* 480 */ "tags_literal ::= NK_HEX NK_PLUS duration_literal", - /* 481 */ "tags_literal ::= NK_HEX NK_MINUS duration_literal", - /* 482 */ "tags_literal ::= NK_PLUS NK_HEX", - /* 483 */ "tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal", - /* 484 */ "tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal", - /* 485 */ "tags_literal ::= NK_MINUS NK_HEX", - /* 486 */ "tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal", - /* 487 */ "tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal", - /* 488 */ "tags_literal ::= NK_STRING", - /* 489 */ "tags_literal ::= NK_STRING NK_PLUS duration_literal", - /* 490 */ "tags_literal ::= NK_STRING NK_MINUS duration_literal", - /* 491 */ "tags_literal ::= NK_BOOL", - /* 492 */ "tags_literal ::= NULL", - /* 493 */ "tags_literal ::= literal_func", - /* 494 */ "tags_literal ::= literal_func NK_PLUS duration_literal", - /* 495 */ "tags_literal ::= literal_func NK_MINUS duration_literal", - /* 496 */ "tags_literal_list ::= tags_literal", - /* 497 */ "tags_literal_list ::= tags_literal_list NK_COMMA tags_literal", - /* 498 */ "literal ::= NK_INTEGER", - /* 499 */ "literal ::= NK_FLOAT", - /* 500 */ "literal ::= NK_STRING", - /* 501 */ "literal ::= NK_BOOL", - /* 502 */ "literal ::= TIMESTAMP NK_STRING", - /* 503 */ "literal ::= duration_literal", - /* 504 */ "literal ::= NULL", - /* 505 */ "literal ::= NK_QUESTION", - /* 506 */ "duration_literal ::= NK_VARIABLE", - /* 507 */ "signed ::= NK_INTEGER", - /* 508 */ "signed ::= NK_PLUS NK_INTEGER", - /* 509 */ "signed ::= NK_MINUS NK_INTEGER", - /* 510 */ "signed ::= NK_FLOAT", - /* 511 */ "signed ::= NK_PLUS NK_FLOAT", - /* 512 */ "signed ::= NK_MINUS NK_FLOAT", - /* 513 */ "signed_literal ::= signed", - /* 514 */ "signed_literal ::= NK_STRING", - /* 515 */ "signed_literal ::= NK_BOOL", - /* 516 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 517 */ "signed_literal ::= duration_literal", - /* 518 */ "signed_literal ::= NULL", - /* 519 */ "signed_literal ::= literal_func", - /* 520 */ "signed_literal ::= NK_QUESTION", - /* 521 */ "literal_list ::= signed_literal", - /* 522 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 523 */ "db_name ::= NK_ID", - /* 524 */ "table_name ::= NK_ID", - /* 525 */ "column_name ::= NK_ID", - /* 526 */ "function_name ::= NK_ID", - /* 527 */ "view_name ::= NK_ID", - /* 528 */ "table_alias ::= NK_ID", - /* 529 */ "column_alias ::= NK_ID", - /* 530 */ "column_alias ::= NK_ALIAS", - /* 531 */ "user_name ::= NK_ID", - /* 532 */ "topic_name ::= NK_ID", - /* 533 */ "stream_name ::= NK_ID", - /* 534 */ "cgroup_name ::= NK_ID", - /* 535 */ "index_name ::= NK_ID", - /* 536 */ "tsma_name ::= NK_ID", - /* 537 */ "expr_or_subquery ::= expression", - /* 538 */ "expression ::= literal", - /* 539 */ "expression ::= pseudo_column", - /* 540 */ "expression ::= column_reference", - /* 541 */ "expression ::= function_expression", - /* 542 */ "expression ::= case_when_expression", - /* 543 */ "expression ::= NK_LP expression NK_RP", - /* 544 */ "expression ::= NK_PLUS expr_or_subquery", - /* 545 */ "expression ::= NK_MINUS expr_or_subquery", - /* 546 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 547 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 548 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 549 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 550 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 551 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 552 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 553 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 554 */ "expression_list ::= expr_or_subquery", - /* 555 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 556 */ "column_reference ::= column_name", - /* 557 */ "column_reference ::= table_name NK_DOT column_name", - /* 558 */ "column_reference ::= NK_ALIAS", - /* 559 */ "column_reference ::= table_name NK_DOT NK_ALIAS", - /* 560 */ "pseudo_column ::= ROWTS", - /* 561 */ "pseudo_column ::= TBNAME", - /* 562 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 563 */ "pseudo_column ::= QSTART", - /* 564 */ "pseudo_column ::= QEND", - /* 565 */ "pseudo_column ::= QDURATION", - /* 566 */ "pseudo_column ::= WSTART", - /* 567 */ "pseudo_column ::= WEND", - /* 568 */ "pseudo_column ::= WDURATION", - /* 569 */ "pseudo_column ::= IROWTS", - /* 570 */ "pseudo_column ::= ISFILLED", - /* 571 */ "pseudo_column ::= QTAGS", - /* 572 */ "pseudo_column ::= FLOW", - /* 573 */ "pseudo_column ::= FHIGH", - /* 574 */ "pseudo_column ::= FROWTS", - /* 575 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 576 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 577 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 578 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP", - /* 579 */ "function_expression ::= POSITION NK_LP expr_or_subquery IN expr_or_subquery NK_RP", - /* 580 */ "function_expression ::= TRIM NK_LP expr_or_subquery NK_RP", - /* 581 */ "function_expression ::= TRIM NK_LP trim_specification_type FROM expr_or_subquery NK_RP", - /* 582 */ "function_expression ::= TRIM NK_LP expr_or_subquery FROM expr_or_subquery NK_RP", - /* 583 */ "function_expression ::= TRIM NK_LP trim_specification_type expr_or_subquery FROM expr_or_subquery NK_RP", - /* 584 */ "function_expression ::= substr_func NK_LP expression_list NK_RP", - /* 585 */ "function_expression ::= substr_func NK_LP expr_or_subquery FROM expr_or_subquery NK_RP", - /* 586 */ "function_expression ::= substr_func NK_LP expr_or_subquery FROM expr_or_subquery FOR expr_or_subquery NK_RP", - /* 587 */ "function_expression ::= REPLACE NK_LP expression_list NK_RP", - /* 588 */ "function_expression ::= literal_func", - /* 589 */ "function_expression ::= rand_func", - /* 590 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 591 */ "literal_func ::= NOW", - /* 592 */ "literal_func ::= TODAY", - /* 593 */ "rand_func ::= RAND NK_LP NK_RP", - /* 594 */ "rand_func ::= RAND NK_LP expression_list NK_RP", - /* 595 */ "substr_func ::= SUBSTR", - /* 596 */ "substr_func ::= SUBSTRING", - /* 597 */ "trim_specification_type ::= BOTH", - /* 598 */ "trim_specification_type ::= TRAILING", - /* 599 */ "trim_specification_type ::= LEADING", - /* 600 */ "noarg_func ::= NOW", - /* 601 */ "noarg_func ::= TODAY", - /* 602 */ "noarg_func ::= TIMEZONE", - /* 603 */ "noarg_func ::= DATABASE", - /* 604 */ "noarg_func ::= CLIENT_VERSION", - /* 605 */ "noarg_func ::= SERVER_VERSION", - /* 606 */ "noarg_func ::= SERVER_STATUS", - /* 607 */ "noarg_func ::= CURRENT_USER", - /* 608 */ "noarg_func ::= USER", - /* 609 */ "noarg_func ::= PI", - /* 610 */ "star_func ::= COUNT", - /* 611 */ "star_func ::= FIRST", - /* 612 */ "star_func ::= LAST", - /* 613 */ "star_func ::= LAST_ROW", - /* 614 */ "star_func_para_list ::= NK_STAR", - /* 615 */ "star_func_para_list ::= other_para_list", - /* 616 */ "other_para_list ::= star_func_para", - /* 617 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 618 */ "star_func_para ::= expr_or_subquery", - /* 619 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 620 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 621 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 622 */ "when_then_list ::= when_then_expr", - /* 623 */ "when_then_list ::= when_then_list when_then_expr", - /* 624 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 625 */ "case_when_else_opt ::=", - /* 626 */ "case_when_else_opt ::= ELSE common_expression", - /* 627 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 628 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 629 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 630 */ "predicate ::= expr_or_subquery IS NULL", - /* 631 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 632 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 633 */ "compare_op ::= NK_LT", - /* 634 */ "compare_op ::= NK_GT", - /* 635 */ "compare_op ::= NK_LE", - /* 636 */ "compare_op ::= NK_GE", - /* 637 */ "compare_op ::= NK_NE", - /* 638 */ "compare_op ::= NK_EQ", - /* 639 */ "compare_op ::= LIKE", - /* 640 */ "compare_op ::= NOT LIKE", - /* 641 */ "compare_op ::= MATCH", - /* 642 */ "compare_op ::= NMATCH", - /* 643 */ "compare_op ::= CONTAINS", - /* 644 */ "in_op ::= IN", - /* 645 */ "in_op ::= NOT IN", - /* 646 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 647 */ "boolean_value_expression ::= boolean_primary", - /* 648 */ "boolean_value_expression ::= NOT boolean_primary", - /* 649 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 650 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 651 */ "boolean_primary ::= predicate", - /* 652 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 653 */ "common_expression ::= expr_or_subquery", - /* 654 */ "common_expression ::= boolean_value_expression", - /* 655 */ "from_clause_opt ::=", - /* 656 */ "from_clause_opt ::= FROM table_reference_list", - /* 657 */ "table_reference_list ::= table_reference", - /* 658 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 659 */ "table_reference ::= table_primary", - /* 660 */ "table_reference ::= joined_table", - /* 661 */ "table_primary ::= table_name alias_opt", - /* 662 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 663 */ "table_primary ::= subquery alias_opt", - /* 664 */ "table_primary ::= parenthesized_joined_table", - /* 665 */ "alias_opt ::=", - /* 666 */ "alias_opt ::= table_alias", - /* 667 */ "alias_opt ::= AS table_alias", - /* 668 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 669 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 670 */ "joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt", - /* 671 */ "join_type ::=", - /* 672 */ "join_type ::= INNER", - /* 673 */ "join_type ::= LEFT", - /* 674 */ "join_type ::= RIGHT", - /* 675 */ "join_type ::= FULL", - /* 676 */ "join_subtype ::=", - /* 677 */ "join_subtype ::= OUTER", - /* 678 */ "join_subtype ::= SEMI", - /* 679 */ "join_subtype ::= ANTI", - /* 680 */ "join_subtype ::= ASOF", - /* 681 */ "join_subtype ::= WINDOW", - /* 682 */ "join_on_clause_opt ::=", - /* 683 */ "join_on_clause_opt ::= ON search_condition", - /* 684 */ "window_offset_clause_opt ::=", - /* 685 */ "window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP", - /* 686 */ "window_offset_literal ::= NK_VARIABLE", - /* 687 */ "window_offset_literal ::= NK_MINUS NK_VARIABLE", - /* 688 */ "jlimit_clause_opt ::=", - /* 689 */ "jlimit_clause_opt ::= JLIMIT NK_INTEGER", - /* 690 */ "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", - /* 691 */ "hint_list ::=", - /* 692 */ "hint_list ::= NK_HINT", - /* 693 */ "tag_mode_opt ::=", - /* 694 */ "tag_mode_opt ::= TAGS", - /* 695 */ "set_quantifier_opt ::=", - /* 696 */ "set_quantifier_opt ::= DISTINCT", - /* 697 */ "set_quantifier_opt ::= ALL", - /* 698 */ "select_list ::= select_item", - /* 699 */ "select_list ::= select_list NK_COMMA select_item", - /* 700 */ "select_item ::= NK_STAR", - /* 701 */ "select_item ::= common_expression", - /* 702 */ "select_item ::= common_expression column_alias", - /* 703 */ "select_item ::= common_expression AS column_alias", - /* 704 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 705 */ "where_clause_opt ::=", - /* 706 */ "where_clause_opt ::= WHERE search_condition", - /* 707 */ "partition_by_clause_opt ::=", - /* 708 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 709 */ "partition_list ::= partition_item", - /* 710 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 711 */ "partition_item ::= expr_or_subquery", - /* 712 */ "partition_item ::= expr_or_subquery column_alias", - /* 713 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 714 */ "twindow_clause_opt ::=", - /* 715 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", - /* 716 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 717 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 718 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 719 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", - /* 720 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP", - /* 721 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 722 */ "twindow_clause_opt ::= ANOMALY_WINDOW NK_LP expr_or_subquery NK_RP", - /* 723 */ "twindow_clause_opt ::= ANOMALY_WINDOW NK_LP expr_or_subquery NK_COMMA NK_STRING NK_RP", - /* 724 */ "sliding_opt ::=", - /* 725 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", - /* 726 */ "interval_sliding_duration_literal ::= NK_VARIABLE", - /* 727 */ "interval_sliding_duration_literal ::= NK_STRING", - /* 728 */ "interval_sliding_duration_literal ::= NK_INTEGER", - /* 729 */ "fill_opt ::=", - /* 730 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 731 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", - /* 732 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", - /* 733 */ "fill_mode ::= NONE", - /* 734 */ "fill_mode ::= PREV", - /* 735 */ "fill_mode ::= NULL", - /* 736 */ "fill_mode ::= NULL_F", - /* 737 */ "fill_mode ::= LINEAR", - /* 738 */ "fill_mode ::= NEXT", - /* 739 */ "group_by_clause_opt ::=", - /* 740 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 741 */ "group_by_list ::= expr_or_subquery", - /* 742 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 743 */ "having_clause_opt ::=", - /* 744 */ "having_clause_opt ::= HAVING search_condition", - /* 745 */ "range_opt ::=", - /* 746 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 747 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", - /* 748 */ "every_opt ::=", - /* 749 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 750 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 751 */ "query_simple ::= query_specification", - /* 752 */ "query_simple ::= union_query_expression", - /* 753 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 754 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 755 */ "query_simple_or_subquery ::= query_simple", - /* 756 */ "query_simple_or_subquery ::= subquery", - /* 757 */ "query_or_subquery ::= query_expression", - /* 758 */ "query_or_subquery ::= subquery", - /* 759 */ "order_by_clause_opt ::=", - /* 760 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 761 */ "slimit_clause_opt ::=", - /* 762 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 763 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 764 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 765 */ "limit_clause_opt ::=", - /* 766 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 767 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 768 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 769 */ "subquery ::= NK_LP query_expression NK_RP", - /* 770 */ "subquery ::= NK_LP subquery NK_RP", - /* 771 */ "search_condition ::= common_expression", - /* 772 */ "sort_specification_list ::= sort_specification", - /* 773 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 774 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 775 */ "ordering_specification_opt ::=", - /* 776 */ "ordering_specification_opt ::= ASC", - /* 777 */ "ordering_specification_opt ::= DESC", - /* 778 */ "null_ordering_opt ::=", - /* 779 */ "null_ordering_opt ::= NULLS FIRST", - /* 780 */ "null_ordering_opt ::= NULLS LAST", - /* 781 */ "column_options ::=", - /* 782 */ "column_options ::= column_options PRIMARY KEY", - /* 783 */ "column_options ::= column_options NK_ID NK_STRING", + /* 145 */ "db_options ::= db_options DNODES NK_STRING", + /* 146 */ "alter_db_options ::= alter_db_option", + /* 147 */ "alter_db_options ::= alter_db_options alter_db_option", + /* 148 */ "alter_db_option ::= BUFFER NK_INTEGER", + /* 149 */ "alter_db_option ::= CACHEMODEL NK_STRING", + /* 150 */ "alter_db_option ::= CACHESIZE NK_INTEGER", + /* 151 */ "alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER", + /* 152 */ "alter_db_option ::= KEEP integer_list", + /* 153 */ "alter_db_option ::= KEEP variable_list", + /* 154 */ "alter_db_option ::= PAGES NK_INTEGER", + /* 155 */ "alter_db_option ::= REPLICA NK_INTEGER", + /* 156 */ "alter_db_option ::= WAL_LEVEL NK_INTEGER", + /* 157 */ "alter_db_option ::= STT_TRIGGER NK_INTEGER", + /* 158 */ "alter_db_option ::= MINROWS NK_INTEGER", + /* 159 */ "alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER", + /* 160 */ "alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER", + /* 161 */ "alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER", + /* 162 */ "alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER", + /* 163 */ "alter_db_option ::= S3_KEEPLOCAL NK_INTEGER", + /* 164 */ "alter_db_option ::= S3_KEEPLOCAL NK_VARIABLE", + /* 165 */ "alter_db_option ::= S3_COMPACT NK_INTEGER", + /* 166 */ "alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER", + /* 167 */ "alter_db_option ::= ENCRYPT_ALGORITHM NK_STRING", + /* 168 */ "integer_list ::= NK_INTEGER", + /* 169 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", + /* 170 */ "variable_list ::= NK_VARIABLE", + /* 171 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", + /* 172 */ "retention_list ::= retention", + /* 173 */ "retention_list ::= retention_list NK_COMMA retention", + /* 174 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", + /* 175 */ "retention ::= NK_MINUS NK_COLON NK_VARIABLE", + /* 176 */ "speed_opt ::=", + /* 177 */ "speed_opt ::= BWLIMIT NK_INTEGER", + /* 178 */ "start_opt ::=", + /* 179 */ "start_opt ::= START WITH NK_INTEGER", + /* 180 */ "start_opt ::= START WITH NK_STRING", + /* 181 */ "start_opt ::= START WITH TIMESTAMP NK_STRING", + /* 182 */ "end_opt ::=", + /* 183 */ "end_opt ::= END WITH NK_INTEGER", + /* 184 */ "end_opt ::= END WITH NK_STRING", + /* 185 */ "end_opt ::= END WITH TIMESTAMP NK_STRING", + /* 186 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 187 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 188 */ "cmd ::= CREATE TABLE not_exists_opt USING full_table_name NK_LP tag_list_opt NK_RP FILE NK_STRING", + /* 189 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 190 */ "cmd ::= DROP TABLE with_opt multi_drop_clause", + /* 191 */ "cmd ::= DROP STABLE with_opt exists_opt full_table_name", + /* 192 */ "cmd ::= ALTER TABLE alter_table_clause", + /* 193 */ "cmd ::= ALTER STABLE alter_table_clause", + /* 194 */ "alter_table_clause ::= full_table_name alter_table_options", + /* 195 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name column_options", + /* 196 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", + /* 197 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", + /* 198 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name column_options", + /* 199 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", + /* 200 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", + /* 201 */ "alter_table_clause ::= full_table_name DROP TAG column_name", + /* 202 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", + /* 203 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", + /* 204 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal", + /* 205 */ "multi_create_clause ::= create_subtable_clause", + /* 206 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 207 */ "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", + /* 208 */ "multi_drop_clause ::= drop_table_clause", + /* 209 */ "multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause", + /* 210 */ "drop_table_clause ::= exists_opt full_table_name", + /* 211 */ "with_opt ::=", + /* 212 */ "with_opt ::= WITH", + /* 213 */ "specific_cols_opt ::=", + /* 214 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", + /* 215 */ "full_table_name ::= table_name", + /* 216 */ "full_table_name ::= db_name NK_DOT table_name", + /* 217 */ "tag_def_list ::= tag_def", + /* 218 */ "tag_def_list ::= tag_def_list NK_COMMA tag_def", + /* 219 */ "tag_def ::= column_name type_name", + /* 220 */ "column_def_list ::= column_def", + /* 221 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 222 */ "column_def ::= column_name type_name column_options", + /* 223 */ "type_name ::= BOOL", + /* 224 */ "type_name ::= TINYINT", + /* 225 */ "type_name ::= SMALLINT", + /* 226 */ "type_name ::= INT", + /* 227 */ "type_name ::= INTEGER", + /* 228 */ "type_name ::= BIGINT", + /* 229 */ "type_name ::= FLOAT", + /* 230 */ "type_name ::= DOUBLE", + /* 231 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 232 */ "type_name ::= TIMESTAMP", + /* 233 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 234 */ "type_name ::= TINYINT UNSIGNED", + /* 235 */ "type_name ::= SMALLINT UNSIGNED", + /* 236 */ "type_name ::= INT UNSIGNED", + /* 237 */ "type_name ::= BIGINT UNSIGNED", + /* 238 */ "type_name ::= JSON", + /* 239 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 240 */ "type_name ::= MEDIUMBLOB", + /* 241 */ "type_name ::= BLOB", + /* 242 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 243 */ "type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP", + /* 244 */ "type_name ::= DECIMAL", + /* 245 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 246 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 247 */ "type_name_default_len ::= BINARY", + /* 248 */ "type_name_default_len ::= NCHAR", + /* 249 */ "type_name_default_len ::= VARCHAR", + /* 250 */ "type_name_default_len ::= VARBINARY", + /* 251 */ "tags_def_opt ::=", + /* 252 */ "tags_def_opt ::= tags_def", + /* 253 */ "tags_def ::= TAGS NK_LP tag_def_list NK_RP", + /* 254 */ "table_options ::=", + /* 255 */ "table_options ::= table_options COMMENT NK_STRING", + /* 256 */ "table_options ::= table_options MAX_DELAY duration_list", + /* 257 */ "table_options ::= table_options WATERMARK duration_list", + /* 258 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", + /* 259 */ "table_options ::= table_options TTL NK_INTEGER", + /* 260 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 261 */ "table_options ::= table_options DELETE_MARK duration_list", + /* 262 */ "alter_table_options ::= alter_table_option", + /* 263 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 264 */ "alter_table_option ::= COMMENT NK_STRING", + /* 265 */ "alter_table_option ::= TTL NK_INTEGER", + /* 266 */ "duration_list ::= duration_literal", + /* 267 */ "duration_list ::= duration_list NK_COMMA duration_literal", + /* 268 */ "rollup_func_list ::= rollup_func_name", + /* 269 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", + /* 270 */ "rollup_func_name ::= function_name", + /* 271 */ "rollup_func_name ::= FIRST", + /* 272 */ "rollup_func_name ::= LAST", + /* 273 */ "col_name_list ::= col_name", + /* 274 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 275 */ "col_name ::= column_name", + /* 276 */ "cmd ::= SHOW DNODES", + /* 277 */ "cmd ::= SHOW USERS", + /* 278 */ "cmd ::= SHOW USERS FULL", + /* 279 */ "cmd ::= SHOW USER PRIVILEGES", + /* 280 */ "cmd ::= SHOW db_kind_opt DATABASES", + /* 281 */ "cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt", + /* 282 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", + /* 283 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", + /* 284 */ "cmd ::= SHOW MNODES", + /* 285 */ "cmd ::= SHOW QNODES", + /* 286 */ "cmd ::= SHOW ANODES", + /* 287 */ "cmd ::= SHOW ANODES FULL", + /* 288 */ "cmd ::= SHOW ARBGROUPS", + /* 289 */ "cmd ::= SHOW FUNCTIONS", + /* 290 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 291 */ "cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name", + /* 292 */ "cmd ::= SHOW STREAMS", + /* 293 */ "cmd ::= SHOW ACCOUNTS", + /* 294 */ "cmd ::= SHOW APPS", + /* 295 */ "cmd ::= SHOW CONNECTIONS", + /* 296 */ "cmd ::= SHOW LICENCES", + /* 297 */ "cmd ::= SHOW GRANTS", + /* 298 */ "cmd ::= SHOW GRANTS FULL", + /* 299 */ "cmd ::= SHOW GRANTS LOGS", + /* 300 */ "cmd ::= SHOW CLUSTER MACHINES", + /* 301 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 302 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 303 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 304 */ "cmd ::= SHOW ENCRYPTIONS", + /* 305 */ "cmd ::= SHOW QUERIES", + /* 306 */ "cmd ::= SHOW SCORES", + /* 307 */ "cmd ::= SHOW TOPICS", + /* 308 */ "cmd ::= SHOW VARIABLES", + /* 309 */ "cmd ::= SHOW CLUSTER VARIABLES", + /* 310 */ "cmd ::= SHOW LOCAL VARIABLES", + /* 311 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt", + /* 312 */ "cmd ::= SHOW BNODES", + /* 313 */ "cmd ::= SHOW SNODES", + /* 314 */ "cmd ::= SHOW CLUSTER", + /* 315 */ "cmd ::= SHOW TRANSACTIONS", + /* 316 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", + /* 317 */ "cmd ::= SHOW CONSUMERS", + /* 318 */ "cmd ::= SHOW SUBSCRIPTIONS", + /* 319 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", + /* 320 */ "cmd ::= SHOW TAGS FROM db_name NK_DOT table_name", + /* 321 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", + /* 322 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name", + /* 323 */ "cmd ::= SHOW VNODES ON DNODE NK_INTEGER", + /* 324 */ "cmd ::= SHOW VNODES", + /* 325 */ "cmd ::= SHOW db_name_cond_opt ALIVE", + /* 326 */ "cmd ::= SHOW CLUSTER ALIVE", + /* 327 */ "cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt", + /* 328 */ "cmd ::= SHOW CREATE VIEW full_table_name", + /* 329 */ "cmd ::= SHOW COMPACTS", + /* 330 */ "cmd ::= SHOW COMPACT NK_INTEGER", + /* 331 */ "table_kind_db_name_cond_opt ::=", + /* 332 */ "table_kind_db_name_cond_opt ::= table_kind", + /* 333 */ "table_kind_db_name_cond_opt ::= db_name NK_DOT", + /* 334 */ "table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT", + /* 335 */ "table_kind ::= NORMAL", + /* 336 */ "table_kind ::= CHILD", + /* 337 */ "db_name_cond_opt ::=", + /* 338 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 339 */ "like_pattern_opt ::=", + /* 340 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 341 */ "table_name_cond ::= table_name", + /* 342 */ "from_db_opt ::=", + /* 343 */ "from_db_opt ::= FROM db_name", + /* 344 */ "tag_list_opt ::=", + /* 345 */ "tag_list_opt ::= tag_item", + /* 346 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", + /* 347 */ "tag_item ::= TBNAME", + /* 348 */ "tag_item ::= QTAGS", + /* 349 */ "tag_item ::= column_name", + /* 350 */ "tag_item ::= column_name column_alias", + /* 351 */ "tag_item ::= column_name AS column_alias", + /* 352 */ "db_kind_opt ::=", + /* 353 */ "db_kind_opt ::= USER", + /* 354 */ "db_kind_opt ::= SYSTEM", + /* 355 */ "cmd ::= CREATE TSMA not_exists_opt tsma_name ON full_table_name tsma_func_list INTERVAL NK_LP duration_literal NK_RP", + /* 356 */ "cmd ::= CREATE RECURSIVE TSMA not_exists_opt tsma_name ON full_table_name INTERVAL NK_LP duration_literal NK_RP", + /* 357 */ "cmd ::= DROP TSMA exists_opt full_tsma_name", + /* 358 */ "cmd ::= SHOW db_name_cond_opt TSMAS", + /* 359 */ "full_tsma_name ::= tsma_name", + /* 360 */ "full_tsma_name ::= db_name NK_DOT tsma_name", + /* 361 */ "tsma_func_list ::= FUNCTION NK_LP func_list NK_RP", + /* 362 */ "cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options", + /* 363 */ "cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP", + /* 364 */ "cmd ::= DROP INDEX exists_opt full_index_name", + /* 365 */ "full_index_name ::= index_name", + /* 366 */ "full_index_name ::= db_name NK_DOT index_name", + /* 367 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 368 */ "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", + /* 369 */ "func_list ::= func", + /* 370 */ "func_list ::= func_list NK_COMMA func", + /* 371 */ "func ::= sma_func_name NK_LP expression_list NK_RP", + /* 372 */ "sma_func_name ::= function_name", + /* 373 */ "sma_func_name ::= COUNT", + /* 374 */ "sma_func_name ::= FIRST", + /* 375 */ "sma_func_name ::= LAST", + /* 376 */ "sma_func_name ::= LAST_ROW", + /* 377 */ "sma_stream_opt ::=", + /* 378 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", + /* 379 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", + /* 380 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", + /* 381 */ "with_meta ::= AS", + /* 382 */ "with_meta ::= WITH META AS", + /* 383 */ "with_meta ::= ONLY META AS", + /* 384 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", + /* 385 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name", + /* 386 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt", + /* 387 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 388 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 389 */ "cmd ::= DESC full_table_name", + /* 390 */ "cmd ::= DESCRIBE full_table_name", + /* 391 */ "cmd ::= RESET QUERY CACHE", + /* 392 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", + /* 393 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", + /* 394 */ "analyze_opt ::=", + /* 395 */ "analyze_opt ::= ANALYZE", + /* 396 */ "explain_options ::=", + /* 397 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 398 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 399 */ "cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt", + /* 400 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 401 */ "agg_func_opt ::=", + /* 402 */ "agg_func_opt ::= AGGREGATE", + /* 403 */ "bufsize_opt ::=", + /* 404 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 405 */ "language_opt ::=", + /* 406 */ "language_opt ::= LANGUAGE NK_STRING", + /* 407 */ "or_replace_opt ::=", + /* 408 */ "or_replace_opt ::= OR REPLACE", + /* 409 */ "cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery", + /* 410 */ "cmd ::= DROP VIEW exists_opt full_view_name", + /* 411 */ "full_view_name ::= view_name", + /* 412 */ "full_view_name ::= db_name NK_DOT view_name", + /* 413 */ "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", + /* 414 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 415 */ "cmd ::= PAUSE STREAM exists_opt stream_name", + /* 416 */ "cmd ::= RESUME STREAM exists_opt ignore_opt stream_name", + /* 417 */ "col_list_opt ::=", + /* 418 */ "col_list_opt ::= NK_LP column_stream_def_list NK_RP", + /* 419 */ "column_stream_def_list ::= column_stream_def", + /* 420 */ "column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def", + /* 421 */ "column_stream_def ::= column_name stream_col_options", + /* 422 */ "stream_col_options ::=", + /* 423 */ "stream_col_options ::= stream_col_options PRIMARY KEY", + /* 424 */ "tag_def_or_ref_opt ::=", + /* 425 */ "tag_def_or_ref_opt ::= tags_def", + /* 426 */ "tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP", + /* 427 */ "stream_options ::=", + /* 428 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 429 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 430 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 431 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 432 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", + /* 433 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", + /* 434 */ "stream_options ::= stream_options DELETE_MARK duration_literal", + /* 435 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", + /* 436 */ "subtable_opt ::=", + /* 437 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 438 */ "ignore_opt ::=", + /* 439 */ "ignore_opt ::= IGNORE UNTREATED", + /* 440 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 441 */ "cmd ::= KILL QUERY NK_STRING", + /* 442 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 443 */ "cmd ::= KILL COMPACT NK_INTEGER", + /* 444 */ "cmd ::= BALANCE VGROUP", + /* 445 */ "cmd ::= BALANCE VGROUP LEADER on_vgroup_id", + /* 446 */ "cmd ::= BALANCE VGROUP LEADER DATABASE db_name", + /* 447 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 448 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 449 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 450 */ "on_vgroup_id ::=", + /* 451 */ "on_vgroup_id ::= ON NK_INTEGER", + /* 452 */ "dnode_list ::= DNODE NK_INTEGER", + /* 453 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 454 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 455 */ "cmd ::= query_or_subquery", + /* 456 */ "cmd ::= insert_query", + /* 457 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 458 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", + /* 459 */ "tags_literal ::= NK_INTEGER", + /* 460 */ "tags_literal ::= NK_INTEGER NK_PLUS duration_literal", + /* 461 */ "tags_literal ::= NK_INTEGER NK_MINUS duration_literal", + /* 462 */ "tags_literal ::= NK_PLUS NK_INTEGER", + /* 463 */ "tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal", + /* 464 */ "tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal", + /* 465 */ "tags_literal ::= NK_MINUS NK_INTEGER", + /* 466 */ "tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal", + /* 467 */ "tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal", + /* 468 */ "tags_literal ::= NK_FLOAT", + /* 469 */ "tags_literal ::= NK_PLUS NK_FLOAT", + /* 470 */ "tags_literal ::= NK_MINUS NK_FLOAT", + /* 471 */ "tags_literal ::= NK_BIN", + /* 472 */ "tags_literal ::= NK_BIN NK_PLUS duration_literal", + /* 473 */ "tags_literal ::= NK_BIN NK_MINUS duration_literal", + /* 474 */ "tags_literal ::= NK_PLUS NK_BIN", + /* 475 */ "tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal", + /* 476 */ "tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal", + /* 477 */ "tags_literal ::= NK_MINUS NK_BIN", + /* 478 */ "tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal", + /* 479 */ "tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal", + /* 480 */ "tags_literal ::= NK_HEX", + /* 481 */ "tags_literal ::= NK_HEX NK_PLUS duration_literal", + /* 482 */ "tags_literal ::= NK_HEX NK_MINUS duration_literal", + /* 483 */ "tags_literal ::= NK_PLUS NK_HEX", + /* 484 */ "tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal", + /* 485 */ "tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal", + /* 486 */ "tags_literal ::= NK_MINUS NK_HEX", + /* 487 */ "tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal", + /* 488 */ "tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal", + /* 489 */ "tags_literal ::= NK_STRING", + /* 490 */ "tags_literal ::= NK_STRING NK_PLUS duration_literal", + /* 491 */ "tags_literal ::= NK_STRING NK_MINUS duration_literal", + /* 492 */ "tags_literal ::= NK_BOOL", + /* 493 */ "tags_literal ::= NULL", + /* 494 */ "tags_literal ::= literal_func", + /* 495 */ "tags_literal ::= literal_func NK_PLUS duration_literal", + /* 496 */ "tags_literal ::= literal_func NK_MINUS duration_literal", + /* 497 */ "tags_literal_list ::= tags_literal", + /* 498 */ "tags_literal_list ::= tags_literal_list NK_COMMA tags_literal", + /* 499 */ "literal ::= NK_INTEGER", + /* 500 */ "literal ::= NK_FLOAT", + /* 501 */ "literal ::= NK_STRING", + /* 502 */ "literal ::= NK_BOOL", + /* 503 */ "literal ::= TIMESTAMP NK_STRING", + /* 504 */ "literal ::= duration_literal", + /* 505 */ "literal ::= NULL", + /* 506 */ "literal ::= NK_QUESTION", + /* 507 */ "duration_literal ::= NK_VARIABLE", + /* 508 */ "signed ::= NK_INTEGER", + /* 509 */ "signed ::= NK_PLUS NK_INTEGER", + /* 510 */ "signed ::= NK_MINUS NK_INTEGER", + /* 511 */ "signed ::= NK_FLOAT", + /* 512 */ "signed ::= NK_PLUS NK_FLOAT", + /* 513 */ "signed ::= NK_MINUS NK_FLOAT", + /* 514 */ "signed_literal ::= signed", + /* 515 */ "signed_literal ::= NK_STRING", + /* 516 */ "signed_literal ::= NK_BOOL", + /* 517 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 518 */ "signed_literal ::= duration_literal", + /* 519 */ "signed_literal ::= NULL", + /* 520 */ "signed_literal ::= literal_func", + /* 521 */ "signed_literal ::= NK_QUESTION", + /* 522 */ "literal_list ::= signed_literal", + /* 523 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 524 */ "db_name ::= NK_ID", + /* 525 */ "table_name ::= NK_ID", + /* 526 */ "column_name ::= NK_ID", + /* 527 */ "function_name ::= NK_ID", + /* 528 */ "view_name ::= NK_ID", + /* 529 */ "table_alias ::= NK_ID", + /* 530 */ "column_alias ::= NK_ID", + /* 531 */ "column_alias ::= NK_ALIAS", + /* 532 */ "user_name ::= NK_ID", + /* 533 */ "topic_name ::= NK_ID", + /* 534 */ "stream_name ::= NK_ID", + /* 535 */ "cgroup_name ::= NK_ID", + /* 536 */ "index_name ::= NK_ID", + /* 537 */ "tsma_name ::= NK_ID", + /* 538 */ "expr_or_subquery ::= expression", + /* 539 */ "expression ::= literal", + /* 540 */ "expression ::= pseudo_column", + /* 541 */ "expression ::= column_reference", + /* 542 */ "expression ::= function_expression", + /* 543 */ "expression ::= case_when_expression", + /* 544 */ "expression ::= NK_LP expression NK_RP", + /* 545 */ "expression ::= NK_PLUS expr_or_subquery", + /* 546 */ "expression ::= NK_MINUS expr_or_subquery", + /* 547 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 548 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 549 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 550 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 551 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 552 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 553 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 554 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 555 */ "expression_list ::= expr_or_subquery", + /* 556 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 557 */ "column_reference ::= column_name", + /* 558 */ "column_reference ::= table_name NK_DOT column_name", + /* 559 */ "column_reference ::= NK_ALIAS", + /* 560 */ "column_reference ::= table_name NK_DOT NK_ALIAS", + /* 561 */ "pseudo_column ::= ROWTS", + /* 562 */ "pseudo_column ::= TBNAME", + /* 563 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 564 */ "pseudo_column ::= QSTART", + /* 565 */ "pseudo_column ::= QEND", + /* 566 */ "pseudo_column ::= QDURATION", + /* 567 */ "pseudo_column ::= WSTART", + /* 568 */ "pseudo_column ::= WEND", + /* 569 */ "pseudo_column ::= WDURATION", + /* 570 */ "pseudo_column ::= IROWTS", + /* 571 */ "pseudo_column ::= ISFILLED", + /* 572 */ "pseudo_column ::= QTAGS", + /* 573 */ "pseudo_column ::= FLOW", + /* 574 */ "pseudo_column ::= FHIGH", + /* 575 */ "pseudo_column ::= FROWTS", + /* 576 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 577 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 578 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 579 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP", + /* 580 */ "function_expression ::= POSITION NK_LP expr_or_subquery IN expr_or_subquery NK_RP", + /* 581 */ "function_expression ::= TRIM NK_LP expr_or_subquery NK_RP", + /* 582 */ "function_expression ::= TRIM NK_LP trim_specification_type FROM expr_or_subquery NK_RP", + /* 583 */ "function_expression ::= TRIM NK_LP expr_or_subquery FROM expr_or_subquery NK_RP", + /* 584 */ "function_expression ::= TRIM NK_LP trim_specification_type expr_or_subquery FROM expr_or_subquery NK_RP", + /* 585 */ "function_expression ::= substr_func NK_LP expression_list NK_RP", + /* 586 */ "function_expression ::= substr_func NK_LP expr_or_subquery FROM expr_or_subquery NK_RP", + /* 587 */ "function_expression ::= substr_func NK_LP expr_or_subquery FROM expr_or_subquery FOR expr_or_subquery NK_RP", + /* 588 */ "function_expression ::= REPLACE NK_LP expression_list NK_RP", + /* 589 */ "function_expression ::= literal_func", + /* 590 */ "function_expression ::= rand_func", + /* 591 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 592 */ "literal_func ::= NOW", + /* 593 */ "literal_func ::= TODAY", + /* 594 */ "rand_func ::= RAND NK_LP NK_RP", + /* 595 */ "rand_func ::= RAND NK_LP expression_list NK_RP", + /* 596 */ "substr_func ::= SUBSTR", + /* 597 */ "substr_func ::= SUBSTRING", + /* 598 */ "trim_specification_type ::= BOTH", + /* 599 */ "trim_specification_type ::= TRAILING", + /* 600 */ "trim_specification_type ::= LEADING", + /* 601 */ "noarg_func ::= NOW", + /* 602 */ "noarg_func ::= TODAY", + /* 603 */ "noarg_func ::= TIMEZONE", + /* 604 */ "noarg_func ::= DATABASE", + /* 605 */ "noarg_func ::= CLIENT_VERSION", + /* 606 */ "noarg_func ::= SERVER_VERSION", + /* 607 */ "noarg_func ::= SERVER_STATUS", + /* 608 */ "noarg_func ::= CURRENT_USER", + /* 609 */ "noarg_func ::= USER", + /* 610 */ "noarg_func ::= PI", + /* 611 */ "star_func ::= COUNT", + /* 612 */ "star_func ::= FIRST", + /* 613 */ "star_func ::= LAST", + /* 614 */ "star_func ::= LAST_ROW", + /* 615 */ "star_func_para_list ::= NK_STAR", + /* 616 */ "star_func_para_list ::= other_para_list", + /* 617 */ "other_para_list ::= star_func_para", + /* 618 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 619 */ "star_func_para ::= expr_or_subquery", + /* 620 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 621 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 622 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 623 */ "when_then_list ::= when_then_expr", + /* 624 */ "when_then_list ::= when_then_list when_then_expr", + /* 625 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 626 */ "case_when_else_opt ::=", + /* 627 */ "case_when_else_opt ::= ELSE common_expression", + /* 628 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 629 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 630 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 631 */ "predicate ::= expr_or_subquery IS NULL", + /* 632 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 633 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 634 */ "compare_op ::= NK_LT", + /* 635 */ "compare_op ::= NK_GT", + /* 636 */ "compare_op ::= NK_LE", + /* 637 */ "compare_op ::= NK_GE", + /* 638 */ "compare_op ::= NK_NE", + /* 639 */ "compare_op ::= NK_EQ", + /* 640 */ "compare_op ::= LIKE", + /* 641 */ "compare_op ::= NOT LIKE", + /* 642 */ "compare_op ::= MATCH", + /* 643 */ "compare_op ::= NMATCH", + /* 644 */ "compare_op ::= CONTAINS", + /* 645 */ "in_op ::= IN", + /* 646 */ "in_op ::= NOT IN", + /* 647 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 648 */ "boolean_value_expression ::= boolean_primary", + /* 649 */ "boolean_value_expression ::= NOT boolean_primary", + /* 650 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 651 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 652 */ "boolean_primary ::= predicate", + /* 653 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 654 */ "common_expression ::= expr_or_subquery", + /* 655 */ "common_expression ::= boolean_value_expression", + /* 656 */ "from_clause_opt ::=", + /* 657 */ "from_clause_opt ::= FROM table_reference_list", + /* 658 */ "table_reference_list ::= table_reference", + /* 659 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 660 */ "table_reference ::= table_primary", + /* 661 */ "table_reference ::= joined_table", + /* 662 */ "table_primary ::= table_name alias_opt", + /* 663 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 664 */ "table_primary ::= subquery alias_opt", + /* 665 */ "table_primary ::= parenthesized_joined_table", + /* 666 */ "alias_opt ::=", + /* 667 */ "alias_opt ::= table_alias", + /* 668 */ "alias_opt ::= AS table_alias", + /* 669 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 670 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 671 */ "joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt", + /* 672 */ "join_type ::=", + /* 673 */ "join_type ::= INNER", + /* 674 */ "join_type ::= LEFT", + /* 675 */ "join_type ::= RIGHT", + /* 676 */ "join_type ::= FULL", + /* 677 */ "join_subtype ::=", + /* 678 */ "join_subtype ::= OUTER", + /* 679 */ "join_subtype ::= SEMI", + /* 680 */ "join_subtype ::= ANTI", + /* 681 */ "join_subtype ::= ASOF", + /* 682 */ "join_subtype ::= WINDOW", + /* 683 */ "join_on_clause_opt ::=", + /* 684 */ "join_on_clause_opt ::= ON search_condition", + /* 685 */ "window_offset_clause_opt ::=", + /* 686 */ "window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP", + /* 687 */ "window_offset_literal ::= NK_VARIABLE", + /* 688 */ "window_offset_literal ::= NK_MINUS NK_VARIABLE", + /* 689 */ "jlimit_clause_opt ::=", + /* 690 */ "jlimit_clause_opt ::= JLIMIT NK_INTEGER", + /* 691 */ "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", + /* 692 */ "hint_list ::=", + /* 693 */ "hint_list ::= NK_HINT", + /* 694 */ "tag_mode_opt ::=", + /* 695 */ "tag_mode_opt ::= TAGS", + /* 696 */ "set_quantifier_opt ::=", + /* 697 */ "set_quantifier_opt ::= DISTINCT", + /* 698 */ "set_quantifier_opt ::= ALL", + /* 699 */ "select_list ::= select_item", + /* 700 */ "select_list ::= select_list NK_COMMA select_item", + /* 701 */ "select_item ::= NK_STAR", + /* 702 */ "select_item ::= common_expression", + /* 703 */ "select_item ::= common_expression column_alias", + /* 704 */ "select_item ::= common_expression AS column_alias", + /* 705 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 706 */ "where_clause_opt ::=", + /* 707 */ "where_clause_opt ::= WHERE search_condition", + /* 708 */ "partition_by_clause_opt ::=", + /* 709 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 710 */ "partition_list ::= partition_item", + /* 711 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 712 */ "partition_item ::= expr_or_subquery", + /* 713 */ "partition_item ::= expr_or_subquery column_alias", + /* 714 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 715 */ "twindow_clause_opt ::=", + /* 716 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", + /* 717 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 718 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", + /* 719 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", + /* 720 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", + /* 721 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP", + /* 722 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 723 */ "twindow_clause_opt ::= ANOMALY_WINDOW NK_LP expr_or_subquery NK_RP", + /* 724 */ "twindow_clause_opt ::= ANOMALY_WINDOW NK_LP expr_or_subquery NK_COMMA NK_STRING NK_RP", + /* 725 */ "sliding_opt ::=", + /* 726 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", + /* 727 */ "interval_sliding_duration_literal ::= NK_VARIABLE", + /* 728 */ "interval_sliding_duration_literal ::= NK_STRING", + /* 729 */ "interval_sliding_duration_literal ::= NK_INTEGER", + /* 730 */ "fill_opt ::=", + /* 731 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 732 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", + /* 733 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", + /* 734 */ "fill_mode ::= NONE", + /* 735 */ "fill_mode ::= PREV", + /* 736 */ "fill_mode ::= NULL", + /* 737 */ "fill_mode ::= NULL_F", + /* 738 */ "fill_mode ::= LINEAR", + /* 739 */ "fill_mode ::= NEXT", + /* 740 */ "group_by_clause_opt ::=", + /* 741 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 742 */ "group_by_list ::= expr_or_subquery", + /* 743 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 744 */ "having_clause_opt ::=", + /* 745 */ "having_clause_opt ::= HAVING search_condition", + /* 746 */ "range_opt ::=", + /* 747 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 748 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", + /* 749 */ "every_opt ::=", + /* 750 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 751 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 752 */ "query_simple ::= query_specification", + /* 753 */ "query_simple ::= union_query_expression", + /* 754 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 755 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 756 */ "query_simple_or_subquery ::= query_simple", + /* 757 */ "query_simple_or_subquery ::= subquery", + /* 758 */ "query_or_subquery ::= query_expression", + /* 759 */ "query_or_subquery ::= subquery", + /* 760 */ "order_by_clause_opt ::=", + /* 761 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 762 */ "slimit_clause_opt ::=", + /* 763 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 764 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 765 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 766 */ "limit_clause_opt ::=", + /* 767 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 768 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 769 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 770 */ "subquery ::= NK_LP query_expression NK_RP", + /* 771 */ "subquery ::= NK_LP subquery NK_RP", + /* 772 */ "search_condition ::= common_expression", + /* 773 */ "sort_specification_list ::= sort_specification", + /* 774 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 775 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 776 */ "ordering_specification_opt ::=", + /* 777 */ "ordering_specification_opt ::= ASC", + /* 778 */ "ordering_specification_opt ::= DESC", + /* 779 */ "null_ordering_opt ::=", + /* 780 */ "null_ordering_opt ::= NULLS FIRST", + /* 781 */ "null_ordering_opt ::= NULLS LAST", + /* 782 */ "column_options ::=", + /* 783 */ "column_options ::= column_options PRIMARY KEY", + /* 784 */ "column_options ::= column_options NK_ID NK_STRING", }; #endif /* NDEBUG */ @@ -3884,9 +3494,7 @@ static void yy_destructor( case 568: /* query_simple_or_subquery */ case 570: /* sort_specification */ { -#line 7 "sql.y" nodesDestroyNode((yypminor->yy974)); -#line 3889 "sql.c" } break; case 390: /* account_options */ @@ -3896,9 +3504,7 @@ static void yy_destructor( case 478: /* with_meta */ case 487: /* bufsize_opt */ { -#line 54 "sql.y" -#line 3901 "sql.c" } break; case 394: /* ip_range_list */ @@ -3938,18 +3544,14 @@ static void yy_destructor( case 564: /* order_by_clause_opt */ case 569: /* sort_specification_list */ { -#line 85 "sql.y" nodesDestroyList((yypminor->yy946)); -#line 3943 "sql.c" } break; case 397: /* is_import_opt */ case 398: /* is_createdb_opt */ case 400: /* sysinfo_opt */ { -#line 99 "sql.y" -#line 3952 "sql.c" } break; case 399: /* user_name */ @@ -3974,25 +3576,19 @@ static void yy_destructor( case 517: /* noarg_func */ case 535: /* alias_opt */ { -#line 1095 "sql.y" -#line 3979 "sql.c" } break; case 401: /* privileges */ case 404: /* priv_type_list */ case 405: /* priv_type */ { -#line 131 "sql.y" -#line 3988 "sql.c" } break; case 402: /* priv_level */ { -#line 148 "sql.y" -#line 3995 "sql.c" } break; case 411: /* force_opt */ @@ -4007,97 +3603,71 @@ static void yy_destructor( case 546: /* set_quantifier_opt */ case 547: /* tag_mode_opt */ { -#line 186 "sql.y" -#line 4012 "sql.c" } break; case 424: /* alter_db_option */ case 452: /* alter_table_option */ { -#line 294 "sql.y" -#line 4020 "sql.c" } break; case 438: /* type_name */ case 449: /* type_name_default_len */ { -#line 436 "sql.y" -#line 4028 "sql.c" } break; case 457: /* db_kind_opt */ case 463: /* table_kind */ { -#line 617 "sql.y" -#line 4036 "sql.c" } break; case 458: /* table_kind_db_name_cond_opt */ { -#line 582 "sql.y" -#line 4043 "sql.c" } break; case 467: /* tsma_func_list */ { -#line 636 "sql.y" nodesDestroyNode((yypminor->yy974)); -#line 4050 "sql.c" } break; case 514: /* trim_specification_type */ { -#line 1241 "sql.y" -#line 4057 "sql.c" } break; case 525: /* compare_op */ case 526: /* in_op */ { -#line 1328 "sql.y" -#line 4065 "sql.c" } break; case 538: /* join_type */ { -#line 1409 "sql.y" -#line 4072 "sql.c" } break; case 539: /* join_subtype */ { -#line 1417 "sql.y" -#line 4079 "sql.c" } break; case 560: /* fill_mode */ { -#line 1537 "sql.y" -#line 4086 "sql.c" } break; case 571: /* ordering_specification_opt */ { -#line 1622 "sql.y" -#line 4093 "sql.c" } break; case 572: /* null_ordering_opt */ { -#line 1628 "sql.y" -#line 4100 "sql.c" } break; /********* End destructor definitions *****************************************/ @@ -4264,7 +3834,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; - assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); #ifndef NDEBUG - if( yyTraceFILE ){ + 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", @@ -6050,21 +5621,15 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ -#line 50 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } -#line 6055 "sql.c" yy_destructor(yypParser,390,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ -#line 51 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } -#line 6061 "sql.c" yy_destructor(yypParser,391,&yymsp[0].minor); break; case 2: /* account_options ::= */ -#line 55 "sql.y" { } -#line 6067 "sql.c" break; case 3: /* account_options ::= account_options PPS literal */ case 4: /* account_options ::= account_options TSERIES literal */ yytestcase(yyruleno==4); @@ -6076,24 +5641,18 @@ static YYACTIONTYPE yy_reduce( 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,390,&yymsp[-2].minor); -#line 56 "sql.y" { } -#line 6081 "sql.c" yy_destructor(yypParser,392,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ { yy_destructor(yypParser,393,&yymsp[0].minor); -#line 68 "sql.y" { } -#line 6089 "sql.c" } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ { yy_destructor(yypParser,391,&yymsp[-1].minor); -#line 69 "sql.y" { } -#line 6096 "sql.c" yy_destructor(yypParser,393,&yymsp[0].minor); } break; @@ -6107,2912 +5666,1979 @@ static YYACTIONTYPE yy_reduce( case 21: /* alter_account_option ::= USERS literal */ yytestcase(yyruleno==21); case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); -#line 73 "sql.y" { } -#line 6112 "sql.c" yy_destructor(yypParser,392,&yymsp[0].minor); break; case 24: /* ip_range_list ::= NK_STRING */ -#line 86 "sql.y" { yylhsminor.yy946 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } -#line 6118 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; case 25: /* ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ -#line 87 "sql.y" { yylhsminor.yy946 = addNodeToList(pCxt, yymsp[-2].minor.yy946, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } -#line 6124 "sql.c" yymsp[-2].minor.yy946 = yylhsminor.yy946; break; case 26: /* white_list ::= HOST ip_range_list */ -#line 91 "sql.y" { yymsp[-1].minor.yy946 = yymsp[0].minor.yy946; } -#line 6130 "sql.c" break; case 27: /* white_list_opt ::= */ - case 212: /* specific_cols_opt ::= */ yytestcase(yyruleno==212); - case 250: /* tags_def_opt ::= */ yytestcase(yyruleno==250); - case 343: /* tag_list_opt ::= */ yytestcase(yyruleno==343); - case 416: /* col_list_opt ::= */ yytestcase(yyruleno==416); - case 423: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==423); - case 707: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==707); - case 739: /* group_by_clause_opt ::= */ yytestcase(yyruleno==739); - case 759: /* order_by_clause_opt ::= */ yytestcase(yyruleno==759); -#line 95 "sql.y" + case 213: /* specific_cols_opt ::= */ yytestcase(yyruleno==213); + case 251: /* tags_def_opt ::= */ yytestcase(yyruleno==251); + case 344: /* tag_list_opt ::= */ yytestcase(yyruleno==344); + case 417: /* col_list_opt ::= */ yytestcase(yyruleno==417); + case 424: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==424); + case 708: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==708); + case 740: /* group_by_clause_opt ::= */ yytestcase(yyruleno==740); + case 760: /* order_by_clause_opt ::= */ yytestcase(yyruleno==760); { yymsp[1].minor.yy946 = NULL; } -#line 6143 "sql.c" break; case 28: /* white_list_opt ::= white_list */ - case 251: /* tags_def_opt ::= tags_def */ yytestcase(yyruleno==251); - case 424: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==424); - case 615: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==615); -#line 96 "sql.y" + case 252: /* tags_def_opt ::= tags_def */ yytestcase(yyruleno==252); + case 425: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==425); + case 616: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==616); { yylhsminor.yy946 = yymsp[0].minor.yy946; } -#line 6151 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; case 29: /* is_import_opt ::= */ case 31: /* is_createdb_opt ::= */ yytestcase(yyruleno==31); -#line 100 "sql.y" { yymsp[1].minor.yy815 = 0; } -#line 6158 "sql.c" break; case 30: /* is_import_opt ::= IS_IMPORT NK_INTEGER */ case 32: /* is_createdb_opt ::= CREATEDB NK_INTEGER */ yytestcase(yyruleno==32); case 42: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ yytestcase(yyruleno==42); -#line 101 "sql.y" { yymsp[-1].minor.yy815 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } -#line 6165 "sql.c" break; case 33: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt is_createdb_opt is_import_opt white_list_opt */ -#line 109 "sql.y" { pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-6].minor.yy557, &yymsp[-4].minor.yy0, yymsp[-3].minor.yy815, yymsp[-1].minor.yy815, yymsp[-2].minor.yy815); pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy946); } -#line 6173 "sql.c" break; case 34: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -#line 113 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy557, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } -#line 6178 "sql.c" break; case 35: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -#line 114 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy557, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } -#line 6183 "sql.c" break; case 36: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -#line 115 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy557, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } -#line 6188 "sql.c" break; case 37: /* cmd ::= ALTER USER user_name CREATEDB NK_INTEGER */ -#line 116 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy557, TSDB_ALTER_USER_CREATEDB, &yymsp[0].minor.yy0); } -#line 6193 "sql.c" break; case 38: /* cmd ::= ALTER USER user_name ADD white_list */ -#line 117 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy557, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy946); } -#line 6198 "sql.c" break; case 39: /* cmd ::= ALTER USER user_name DROP white_list */ -#line 118 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy557, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy946); } -#line 6203 "sql.c" break; case 40: /* cmd ::= DROP USER user_name */ -#line 119 "sql.y" { pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy557); } -#line 6208 "sql.c" break; case 41: /* sysinfo_opt ::= */ -#line 123 "sql.y" { yymsp[1].minor.yy815 = 1; } -#line 6213 "sql.c" break; case 43: /* cmd ::= GRANT privileges ON priv_level with_clause_opt TO user_name */ -#line 127 "sql.y" { pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy483, &yymsp[-3].minor.yy723, &yymsp[0].minor.yy557, yymsp[-2].minor.yy974); } -#line 6218 "sql.c" break; case 44: /* cmd ::= REVOKE privileges ON priv_level with_clause_opt FROM user_name */ -#line 128 "sql.y" { pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy483, &yymsp[-3].minor.yy723, &yymsp[0].minor.yy557, yymsp[-2].minor.yy974); } -#line 6223 "sql.c" break; case 45: /* privileges ::= ALL */ -#line 132 "sql.y" { yymsp[0].minor.yy483 = PRIVILEGE_TYPE_ALL; } -#line 6228 "sql.c" break; case 46: /* privileges ::= priv_type_list */ case 48: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==48); -#line 133 "sql.y" { yylhsminor.yy483 = yymsp[0].minor.yy483; } -#line 6234 "sql.c" yymsp[0].minor.yy483 = yylhsminor.yy483; break; case 47: /* privileges ::= SUBSCRIBE */ -#line 134 "sql.y" { yymsp[0].minor.yy483 = PRIVILEGE_TYPE_SUBSCRIBE; } -#line 6240 "sql.c" break; case 49: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -#line 139 "sql.y" { yylhsminor.yy483 = yymsp[-2].minor.yy483 | yymsp[0].minor.yy483; } -#line 6245 "sql.c" yymsp[-2].minor.yy483 = yylhsminor.yy483; break; case 50: /* priv_type ::= READ */ -#line 143 "sql.y" { yymsp[0].minor.yy483 = PRIVILEGE_TYPE_READ; } -#line 6251 "sql.c" break; case 51: /* priv_type ::= WRITE */ -#line 144 "sql.y" { yymsp[0].minor.yy483 = PRIVILEGE_TYPE_WRITE; } -#line 6256 "sql.c" break; case 52: /* priv_type ::= ALTER */ -#line 145 "sql.y" { yymsp[0].minor.yy483 = PRIVILEGE_TYPE_ALTER; } -#line 6261 "sql.c" break; case 53: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -#line 149 "sql.y" { yylhsminor.yy723.first = yymsp[-2].minor.yy0; yylhsminor.yy723.second = yymsp[0].minor.yy0; } -#line 6266 "sql.c" yymsp[-2].minor.yy723 = yylhsminor.yy723; break; case 54: /* priv_level ::= db_name NK_DOT NK_STAR */ -#line 150 "sql.y" { yylhsminor.yy723.first = yymsp[-2].minor.yy557; yylhsminor.yy723.second = yymsp[0].minor.yy0; } -#line 6272 "sql.c" yymsp[-2].minor.yy723 = yylhsminor.yy723; break; case 55: /* priv_level ::= db_name NK_DOT table_name */ -#line 151 "sql.y" { yylhsminor.yy723.first = yymsp[-2].minor.yy557; yylhsminor.yy723.second = yymsp[0].minor.yy557; } -#line 6278 "sql.c" yymsp[-2].minor.yy723 = yylhsminor.yy723; break; case 56: /* priv_level ::= topic_name */ -#line 152 "sql.y" { yylhsminor.yy723.first = yymsp[0].minor.yy557; yylhsminor.yy723.second = nil_token; } -#line 6284 "sql.c" yymsp[0].minor.yy723 = yylhsminor.yy723; break; case 57: /* with_clause_opt ::= */ - case 177: /* start_opt ::= */ yytestcase(yyruleno==177); - case 181: /* end_opt ::= */ yytestcase(yyruleno==181); - case 338: /* like_pattern_opt ::= */ yytestcase(yyruleno==338); - case 435: /* subtable_opt ::= */ yytestcase(yyruleno==435); - case 625: /* case_when_else_opt ::= */ yytestcase(yyruleno==625); - case 655: /* from_clause_opt ::= */ yytestcase(yyruleno==655); - case 682: /* join_on_clause_opt ::= */ yytestcase(yyruleno==682); - case 684: /* window_offset_clause_opt ::= */ yytestcase(yyruleno==684); - case 688: /* jlimit_clause_opt ::= */ yytestcase(yyruleno==688); - case 705: /* where_clause_opt ::= */ yytestcase(yyruleno==705); - case 714: /* twindow_clause_opt ::= */ yytestcase(yyruleno==714); - case 724: /* sliding_opt ::= */ yytestcase(yyruleno==724); - case 729: /* fill_opt ::= */ yytestcase(yyruleno==729); - case 743: /* having_clause_opt ::= */ yytestcase(yyruleno==743); - case 745: /* range_opt ::= */ yytestcase(yyruleno==745); - case 748: /* every_opt ::= */ yytestcase(yyruleno==748); - case 761: /* slimit_clause_opt ::= */ yytestcase(yyruleno==761); - case 765: /* limit_clause_opt ::= */ yytestcase(yyruleno==765); -#line 154 "sql.y" + case 178: /* start_opt ::= */ yytestcase(yyruleno==178); + case 182: /* end_opt ::= */ yytestcase(yyruleno==182); + case 339: /* like_pattern_opt ::= */ yytestcase(yyruleno==339); + case 436: /* subtable_opt ::= */ yytestcase(yyruleno==436); + case 626: /* case_when_else_opt ::= */ yytestcase(yyruleno==626); + case 656: /* from_clause_opt ::= */ yytestcase(yyruleno==656); + case 683: /* join_on_clause_opt ::= */ yytestcase(yyruleno==683); + case 685: /* window_offset_clause_opt ::= */ yytestcase(yyruleno==685); + case 689: /* jlimit_clause_opt ::= */ yytestcase(yyruleno==689); + case 706: /* where_clause_opt ::= */ yytestcase(yyruleno==706); + case 715: /* twindow_clause_opt ::= */ yytestcase(yyruleno==715); + case 725: /* sliding_opt ::= */ yytestcase(yyruleno==725); + case 730: /* fill_opt ::= */ yytestcase(yyruleno==730); + case 744: /* having_clause_opt ::= */ yytestcase(yyruleno==744); + case 746: /* range_opt ::= */ yytestcase(yyruleno==746); + case 749: /* every_opt ::= */ yytestcase(yyruleno==749); + case 762: /* slimit_clause_opt ::= */ yytestcase(yyruleno==762); + case 766: /* limit_clause_opt ::= */ yytestcase(yyruleno==766); { yymsp[1].minor.yy974 = NULL; } -#line 6308 "sql.c" break; case 58: /* with_clause_opt ::= WITH search_condition */ - case 656: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==656); - case 683: /* join_on_clause_opt ::= ON search_condition */ yytestcase(yyruleno==683); - case 706: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==706); - case 744: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==744); -#line 155 "sql.y" + case 657: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==657); + case 684: /* join_on_clause_opt ::= ON search_condition */ yytestcase(yyruleno==684); + case 707: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==707); + case 745: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==745); { yymsp[-1].minor.yy974 = yymsp[0].minor.yy974; } -#line 6317 "sql.c" break; case 59: /* cmd ::= CREATE ENCRYPT_KEY NK_STRING */ -#line 158 "sql.y" { pCxt->pRootNode = createEncryptKeyStmt(pCxt, &yymsp[0].minor.yy0); } -#line 6322 "sql.c" break; case 60: /* cmd ::= CREATE ANODE NK_STRING */ -#line 161 "sql.y" { pCxt->pRootNode = createCreateAnodeStmt(pCxt, &yymsp[0].minor.yy0); } -#line 6327 "sql.c" break; case 61: /* cmd ::= UPDATE ANODE NK_INTEGER */ -#line 162 "sql.y" { pCxt->pRootNode = createUpdateAnodeStmt(pCxt, &yymsp[0].minor.yy0, false); } -#line 6332 "sql.c" break; case 62: /* cmd ::= UPDATE ALL ANODES */ -#line 163 "sql.y" { pCxt->pRootNode = createUpdateAnodeStmt(pCxt, NULL, true); } -#line 6337 "sql.c" break; case 63: /* cmd ::= DROP ANODE NK_INTEGER */ -#line 164 "sql.y" { pCxt->pRootNode = createDropAnodeStmt(pCxt, &yymsp[0].minor.yy0); } -#line 6342 "sql.c" break; case 64: /* cmd ::= CREATE DNODE dnode_endpoint */ -#line 167 "sql.y" { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy557, NULL); } -#line 6347 "sql.c" break; case 65: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -#line 168 "sql.y" { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy0); } -#line 6352 "sql.c" break; case 66: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ -#line 169 "sql.y" { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy569, false); } -#line 6357 "sql.c" break; case 67: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ -#line 170 "sql.y" { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy557, yymsp[0].minor.yy569, false); } -#line 6362 "sql.c" break; case 68: /* cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ -#line 171 "sql.y" { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy569); } -#line 6367 "sql.c" break; case 69: /* cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ -#line 172 "sql.y" { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy557, false, yymsp[0].minor.yy569); } -#line 6372 "sql.c" break; case 70: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ -#line 173 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } -#line 6377 "sql.c" break; case 71: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ -#line 174 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 6382 "sql.c" break; case 72: /* cmd ::= ALTER ALL DNODES NK_STRING */ -#line 175 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[0].minor.yy0, NULL); } -#line 6387 "sql.c" break; case 73: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ -#line 176 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 6392 "sql.c" break; case 74: /* cmd ::= RESTORE DNODE NK_INTEGER */ -#line 177 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_DNODE_STMT, &yymsp[0].minor.yy0); } -#line 6397 "sql.c" break; case 75: /* dnode_endpoint ::= NK_STRING */ case 76: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==76); case 77: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==77); - case 372: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==372); - case 373: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==373); - case 374: /* sma_func_name ::= LAST */ yytestcase(yyruleno==374); - case 375: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==375); - case 523: /* db_name ::= NK_ID */ yytestcase(yyruleno==523); - case 524: /* table_name ::= NK_ID */ yytestcase(yyruleno==524); - case 525: /* column_name ::= NK_ID */ yytestcase(yyruleno==525); - case 526: /* function_name ::= NK_ID */ yytestcase(yyruleno==526); - case 527: /* view_name ::= NK_ID */ yytestcase(yyruleno==527); - case 528: /* table_alias ::= NK_ID */ yytestcase(yyruleno==528); - case 529: /* column_alias ::= NK_ID */ yytestcase(yyruleno==529); - case 530: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==530); - case 531: /* user_name ::= NK_ID */ yytestcase(yyruleno==531); - case 532: /* topic_name ::= NK_ID */ yytestcase(yyruleno==532); - case 533: /* stream_name ::= NK_ID */ yytestcase(yyruleno==533); - case 534: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==534); - case 535: /* index_name ::= NK_ID */ yytestcase(yyruleno==535); - case 536: /* tsma_name ::= NK_ID */ yytestcase(yyruleno==536); - case 595: /* substr_func ::= SUBSTR */ yytestcase(yyruleno==595); - case 596: /* substr_func ::= SUBSTRING */ yytestcase(yyruleno==596); - case 600: /* noarg_func ::= NOW */ yytestcase(yyruleno==600); - case 601: /* noarg_func ::= TODAY */ yytestcase(yyruleno==601); - case 602: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==602); - case 603: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==603); - case 604: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==604); - case 605: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==605); - case 606: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==606); - case 607: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==607); - case 608: /* noarg_func ::= USER */ yytestcase(yyruleno==608); - case 609: /* noarg_func ::= PI */ yytestcase(yyruleno==609); - case 610: /* star_func ::= COUNT */ yytestcase(yyruleno==610); - case 611: /* star_func ::= FIRST */ yytestcase(yyruleno==611); - case 612: /* star_func ::= LAST */ yytestcase(yyruleno==612); - case 613: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==613); -#line 181 "sql.y" + case 373: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==373); + case 374: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==374); + case 375: /* sma_func_name ::= LAST */ yytestcase(yyruleno==375); + case 376: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==376); + case 524: /* db_name ::= NK_ID */ yytestcase(yyruleno==524); + case 525: /* table_name ::= NK_ID */ yytestcase(yyruleno==525); + case 526: /* column_name ::= NK_ID */ yytestcase(yyruleno==526); + case 527: /* function_name ::= NK_ID */ yytestcase(yyruleno==527); + case 528: /* view_name ::= NK_ID */ yytestcase(yyruleno==528); + case 529: /* table_alias ::= NK_ID */ yytestcase(yyruleno==529); + case 530: /* column_alias ::= NK_ID */ yytestcase(yyruleno==530); + case 531: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==531); + case 532: /* user_name ::= NK_ID */ yytestcase(yyruleno==532); + case 533: /* topic_name ::= NK_ID */ yytestcase(yyruleno==533); + case 534: /* stream_name ::= NK_ID */ yytestcase(yyruleno==534); + case 535: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==535); + case 536: /* index_name ::= NK_ID */ yytestcase(yyruleno==536); + case 537: /* tsma_name ::= NK_ID */ yytestcase(yyruleno==537); + case 596: /* substr_func ::= SUBSTR */ yytestcase(yyruleno==596); + case 597: /* substr_func ::= SUBSTRING */ yytestcase(yyruleno==597); + case 601: /* noarg_func ::= NOW */ yytestcase(yyruleno==601); + case 602: /* noarg_func ::= TODAY */ yytestcase(yyruleno==602); + case 603: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==603); + case 604: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==604); + case 605: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==605); + case 606: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==606); + case 607: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==607); + case 608: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==608); + case 609: /* noarg_func ::= USER */ yytestcase(yyruleno==609); + case 610: /* noarg_func ::= PI */ yytestcase(yyruleno==610); + case 611: /* star_func ::= COUNT */ yytestcase(yyruleno==611); + case 612: /* star_func ::= FIRST */ yytestcase(yyruleno==612); + case 613: /* star_func ::= LAST */ yytestcase(yyruleno==613); + case 614: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==614); { yylhsminor.yy557 = yymsp[0].minor.yy0; } -#line 6438 "sql.c" yymsp[0].minor.yy557 = yylhsminor.yy557; break; case 78: /* force_opt ::= */ case 105: /* not_exists_opt ::= */ yytestcase(yyruleno==105); case 107: /* exists_opt ::= */ yytestcase(yyruleno==107); - case 210: /* with_opt ::= */ yytestcase(yyruleno==210); - case 393: /* analyze_opt ::= */ yytestcase(yyruleno==393); - case 400: /* agg_func_opt ::= */ yytestcase(yyruleno==400); - case 406: /* or_replace_opt ::= */ yytestcase(yyruleno==406); - case 437: /* ignore_opt ::= */ yytestcase(yyruleno==437); - case 693: /* tag_mode_opt ::= */ yytestcase(yyruleno==693); - case 695: /* set_quantifier_opt ::= */ yytestcase(yyruleno==695); -#line 187 "sql.y" + case 211: /* with_opt ::= */ yytestcase(yyruleno==211); + case 394: /* analyze_opt ::= */ yytestcase(yyruleno==394); + case 401: /* agg_func_opt ::= */ yytestcase(yyruleno==401); + case 407: /* or_replace_opt ::= */ yytestcase(yyruleno==407); + case 438: /* ignore_opt ::= */ yytestcase(yyruleno==438); + case 694: /* tag_mode_opt ::= */ yytestcase(yyruleno==694); + case 696: /* set_quantifier_opt ::= */ yytestcase(yyruleno==696); { yymsp[1].minor.yy569 = false; } -#line 6453 "sql.c" break; case 79: /* force_opt ::= FORCE */ case 80: /* unsafe_opt ::= UNSAFE */ yytestcase(yyruleno==80); - case 211: /* with_opt ::= WITH */ yytestcase(yyruleno==211); - case 394: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==394); - case 401: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==401); - case 694: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==694); - case 696: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==696); -#line 188 "sql.y" + case 212: /* with_opt ::= WITH */ yytestcase(yyruleno==212); + case 395: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==395); + case 402: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==402); + case 695: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==695); + case 697: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==697); { yymsp[0].minor.yy569 = true; } -#line 6464 "sql.c" break; case 81: /* cmd ::= ALTER CLUSTER NK_STRING */ -#line 195 "sql.y" { pCxt->pRootNode = createAlterClusterStmt(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 6469 "sql.c" break; case 82: /* cmd ::= ALTER CLUSTER NK_STRING NK_STRING */ -#line 196 "sql.y" { pCxt->pRootNode = createAlterClusterStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 6474 "sql.c" break; case 83: /* cmd ::= ALTER LOCAL NK_STRING */ -#line 199 "sql.y" { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 6479 "sql.c" break; case 84: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ -#line 200 "sql.y" { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 6484 "sql.c" break; case 85: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ -#line 203 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_QNODE_STMT, &yymsp[0].minor.yy0); } -#line 6489 "sql.c" break; case 86: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ -#line 204 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_QNODE_STMT, &yymsp[0].minor.yy0); } -#line 6494 "sql.c" break; case 87: /* cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ -#line 205 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_QNODE_STMT, &yymsp[0].minor.yy0); } -#line 6499 "sql.c" break; case 88: /* cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ -#line 208 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_BNODE_STMT, &yymsp[0].minor.yy0); } -#line 6504 "sql.c" break; case 89: /* cmd ::= DROP BNODE ON DNODE NK_INTEGER */ -#line 209 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_BNODE_STMT, &yymsp[0].minor.yy0); } -#line 6509 "sql.c" break; case 90: /* cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ -#line 212 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_SNODE_STMT, &yymsp[0].minor.yy0); } -#line 6514 "sql.c" break; case 91: /* cmd ::= DROP SNODE ON DNODE NK_INTEGER */ -#line 213 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_SNODE_STMT, &yymsp[0].minor.yy0); } -#line 6519 "sql.c" break; case 92: /* cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ -#line 216 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_MNODE_STMT, &yymsp[0].minor.yy0); } -#line 6524 "sql.c" break; case 93: /* cmd ::= DROP MNODE ON DNODE NK_INTEGER */ -#line 217 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } -#line 6529 "sql.c" break; case 94: /* cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ -#line 218 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_MNODE_STMT, &yymsp[0].minor.yy0); } -#line 6534 "sql.c" break; case 95: /* cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ -#line 221 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_VNODE_STMT, &yymsp[0].minor.yy0); } -#line 6539 "sql.c" break; case 96: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -#line 224 "sql.y" { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy569, &yymsp[-1].minor.yy557, yymsp[0].minor.yy974); } -#line 6544 "sql.c" break; case 97: /* cmd ::= DROP DATABASE exists_opt db_name */ -#line 225 "sql.y" { pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy569, &yymsp[0].minor.yy557); } -#line 6549 "sql.c" break; case 98: /* cmd ::= USE db_name */ -#line 226 "sql.y" { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy557); } -#line 6554 "sql.c" break; case 99: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -#line 227 "sql.y" { pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy557, yymsp[0].minor.yy974); } -#line 6559 "sql.c" break; case 100: /* cmd ::= FLUSH DATABASE db_name */ -#line 228 "sql.y" { pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy557); } -#line 6564 "sql.c" break; case 101: /* cmd ::= TRIM DATABASE db_name speed_opt */ -#line 229 "sql.y" { pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy557, yymsp[0].minor.yy904); } -#line 6569 "sql.c" break; case 102: /* cmd ::= S3MIGRATE DATABASE db_name */ -#line 230 "sql.y" { pCxt->pRootNode = createS3MigrateDatabaseStmt(pCxt, &yymsp[0].minor.yy557); } -#line 6574 "sql.c" break; case 103: /* cmd ::= COMPACT DATABASE db_name start_opt end_opt */ -#line 231 "sql.y" { pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy557, yymsp[-1].minor.yy974, yymsp[0].minor.yy974); } -#line 6579 "sql.c" break; case 104: /* not_exists_opt ::= IF NOT EXISTS */ -#line 235 "sql.y" { yymsp[-2].minor.yy569 = true; } -#line 6584 "sql.c" break; case 106: /* exists_opt ::= IF EXISTS */ - case 407: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==407); - case 438: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==438); -#line 240 "sql.y" + case 408: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==408); + case 439: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==439); { yymsp[-1].minor.yy569 = true; } -#line 6591 "sql.c" break; case 108: /* db_options ::= */ -#line 243 "sql.y" { yymsp[1].minor.yy974 = createDefaultDatabaseOptions(pCxt); } -#line 6596 "sql.c" break; case 109: /* db_options ::= db_options BUFFER NK_INTEGER */ -#line 244 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } -#line 6601 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 110: /* db_options ::= db_options CACHEMODEL NK_STRING */ -#line 245 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } -#line 6607 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 111: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -#line 246 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } -#line 6613 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 112: /* db_options ::= db_options COMP NK_INTEGER */ -#line 247 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_COMP, &yymsp[0].minor.yy0); } -#line 6619 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 113: /* db_options ::= db_options DURATION NK_INTEGER */ case 114: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==114); -#line 248 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } -#line 6626 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 115: /* db_options ::= db_options MAXROWS NK_INTEGER */ -#line 250 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } -#line 6632 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 116: /* db_options ::= db_options MINROWS NK_INTEGER */ -#line 251 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } -#line 6638 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 117: /* db_options ::= db_options KEEP integer_list */ case 118: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==118); -#line 252 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_KEEP, yymsp[0].minor.yy946); } -#line 6645 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 119: /* db_options ::= db_options PAGES NK_INTEGER */ -#line 254 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } -#line 6651 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 120: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -#line 255 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } -#line 6657 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 121: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ -#line 256 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } -#line 6663 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 122: /* db_options ::= db_options PRECISION NK_STRING */ -#line 257 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } -#line 6669 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 123: /* db_options ::= db_options REPLICA NK_INTEGER */ -#line 258 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } -#line 6675 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 124: /* db_options ::= db_options VGROUPS NK_INTEGER */ -#line 260 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } -#line 6681 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 125: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -#line 261 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } -#line 6687 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 126: /* db_options ::= db_options RETENTIONS retention_list */ -#line 262 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_RETENTIONS, yymsp[0].minor.yy946); } -#line 6693 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 127: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -#line 263 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } -#line 6699 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 128: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -#line 264 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_WAL, &yymsp[0].minor.yy0); } -#line 6705 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 129: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -#line 265 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } -#line 6711 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 130: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -#line 266 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } -#line 6717 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 131: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ -#line 267 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-3].minor.yy974, DB_OPTION_WAL_RETENTION_PERIOD, &t); } -#line 6727 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 132: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -#line 272 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } -#line 6733 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 133: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ -#line 273 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-3].minor.yy974, DB_OPTION_WAL_RETENTION_SIZE, &t); } -#line 6743 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 134: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -#line 278 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } -#line 6749 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 135: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -#line 279 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } -#line 6755 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 136: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ -#line 280 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } -#line 6761 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 137: /* db_options ::= db_options TABLE_PREFIX signed */ -#line 281 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy974); } -#line 6767 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 138: /* db_options ::= db_options TABLE_SUFFIX signed */ -#line 282 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy974); } -#line 6773 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 139: /* db_options ::= db_options S3_CHUNKPAGES NK_INTEGER */ -#line 283 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_S3_CHUNKPAGES, &yymsp[0].minor.yy0); } -#line 6779 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 140: /* db_options ::= db_options S3_KEEPLOCAL NK_INTEGER */ case 141: /* db_options ::= db_options S3_KEEPLOCAL NK_VARIABLE */ yytestcase(yyruleno==141); -#line 284 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_S3_KEEPLOCAL, &yymsp[0].minor.yy0); } -#line 6786 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 142: /* db_options ::= db_options S3_COMPACT NK_INTEGER */ -#line 286 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_S3_COMPACT, &yymsp[0].minor.yy0); } -#line 6792 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 143: /* db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ -#line 287 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } -#line 6798 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 144: /* db_options ::= db_options ENCRYPT_ALGORITHM NK_STRING */ -#line 288 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_ENCRYPT_ALGORITHM, &yymsp[0].minor.yy0); } -#line 6804 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 145: /* alter_db_options ::= alter_db_option */ -#line 290 "sql.y" + case 145: /* db_options ::= db_options DNODES NK_STRING */ +{ yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_DNODES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy974 = yylhsminor.yy974; + break; + case 146: /* alter_db_options ::= alter_db_option */ { yylhsminor.yy974 = createAlterDatabaseOptions(pCxt); yylhsminor.yy974 = setAlterDatabaseOption(pCxt, yylhsminor.yy974, &yymsp[0].minor.yy683); } -#line 6810 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 146: /* alter_db_options ::= alter_db_options alter_db_option */ -#line 291 "sql.y" + case 147: /* alter_db_options ::= alter_db_options alter_db_option */ { yylhsminor.yy974 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy974, &yymsp[0].minor.yy683); } -#line 6816 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 147: /* alter_db_option ::= BUFFER NK_INTEGER */ -#line 295 "sql.y" + case 148: /* alter_db_option ::= BUFFER NK_INTEGER */ { yymsp[-1].minor.yy683.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 6822 "sql.c" break; - case 148: /* alter_db_option ::= CACHEMODEL NK_STRING */ -#line 296 "sql.y" + case 149: /* alter_db_option ::= CACHEMODEL NK_STRING */ { yymsp[-1].minor.yy683.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 6827 "sql.c" break; - case 149: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -#line 297 "sql.y" + case 150: /* alter_db_option ::= CACHESIZE NK_INTEGER */ { yymsp[-1].minor.yy683.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 6832 "sql.c" break; - case 150: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -#line 298 "sql.y" + case 151: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ { yymsp[-1].minor.yy683.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 6837 "sql.c" break; - case 151: /* alter_db_option ::= KEEP integer_list */ - case 152: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==152); -#line 299 "sql.y" + case 152: /* alter_db_option ::= KEEP integer_list */ + case 153: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==153); { yymsp[-1].minor.yy683.type = DB_OPTION_KEEP; yymsp[-1].minor.yy683.pList = yymsp[0].minor.yy946; } -#line 6843 "sql.c" break; - case 153: /* alter_db_option ::= PAGES NK_INTEGER */ -#line 301 "sql.y" + case 154: /* alter_db_option ::= PAGES NK_INTEGER */ { yymsp[-1].minor.yy683.type = DB_OPTION_PAGES; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 6848 "sql.c" break; - case 154: /* alter_db_option ::= REPLICA NK_INTEGER */ -#line 302 "sql.y" + case 155: /* alter_db_option ::= REPLICA NK_INTEGER */ { yymsp[-1].minor.yy683.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 6853 "sql.c" break; - case 155: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -#line 304 "sql.y" + case 156: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ { yymsp[-1].minor.yy683.type = DB_OPTION_WAL; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 6858 "sql.c" break; - case 156: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ -#line 305 "sql.y" + case 157: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ { yymsp[-1].minor.yy683.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 6863 "sql.c" break; - case 157: /* alter_db_option ::= MINROWS NK_INTEGER */ -#line 306 "sql.y" + case 158: /* alter_db_option ::= MINROWS NK_INTEGER */ { yymsp[-1].minor.yy683.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 6868 "sql.c" break; - case 158: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ -#line 307 "sql.y" + case 159: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ { yymsp[-1].minor.yy683.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 6873 "sql.c" break; - case 159: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ -#line 308 "sql.y" + case 160: /* 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.yy683.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy683.val = t; } -#line 6882 "sql.c" break; - case 160: /* alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ -#line 313 "sql.y" + case 161: /* alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ { yymsp[-1].minor.yy683.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 6887 "sql.c" break; - case 161: /* alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ -#line 314 "sql.y" + case 162: /* 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.yy683.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy683.val = t; } -#line 6896 "sql.c" break; - case 162: /* alter_db_option ::= S3_KEEPLOCAL NK_INTEGER */ - case 163: /* alter_db_option ::= S3_KEEPLOCAL NK_VARIABLE */ yytestcase(yyruleno==163); -#line 319 "sql.y" + case 163: /* alter_db_option ::= S3_KEEPLOCAL NK_INTEGER */ + case 164: /* alter_db_option ::= S3_KEEPLOCAL NK_VARIABLE */ yytestcase(yyruleno==164); { yymsp[-1].minor.yy683.type = DB_OPTION_S3_KEEPLOCAL; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 6902 "sql.c" break; - case 164: /* alter_db_option ::= S3_COMPACT NK_INTEGER */ -#line 321 "sql.y" + case 165: /* alter_db_option ::= S3_COMPACT NK_INTEGER */ { yymsp[-1].minor.yy683.type = DB_OPTION_S3_COMPACT, yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 6907 "sql.c" break; - case 165: /* alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ -#line 322 "sql.y" + case 166: /* alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ { yymsp[-1].minor.yy683.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 6912 "sql.c" break; - case 166: /* alter_db_option ::= ENCRYPT_ALGORITHM NK_STRING */ -#line 323 "sql.y" + case 167: /* alter_db_option ::= ENCRYPT_ALGORITHM NK_STRING */ { yymsp[-1].minor.yy683.type = DB_OPTION_ENCRYPT_ALGORITHM; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 6917 "sql.c" break; - case 167: /* integer_list ::= NK_INTEGER */ -#line 327 "sql.y" + case 168: /* integer_list ::= NK_INTEGER */ { yylhsminor.yy946 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 6922 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; - case 168: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 452: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==452); -#line 328 "sql.y" + case 169: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ + case 453: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==453); { yylhsminor.yy946 = addNodeToList(pCxt, yymsp[-2].minor.yy946, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 6929 "sql.c" yymsp[-2].minor.yy946 = yylhsminor.yy946; break; - case 169: /* variable_list ::= NK_VARIABLE */ -#line 332 "sql.y" + case 170: /* variable_list ::= NK_VARIABLE */ { yylhsminor.yy946 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 6935 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; - case 170: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -#line 333 "sql.y" + case 171: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ { yylhsminor.yy946 = addNodeToList(pCxt, yymsp[-2].minor.yy946, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 6941 "sql.c" yymsp[-2].minor.yy946 = yylhsminor.yy946; break; - case 171: /* retention_list ::= retention */ - case 204: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==204); - case 207: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==207); - case 216: /* tag_def_list ::= tag_def */ yytestcase(yyruleno==216); - case 219: /* column_def_list ::= column_def */ yytestcase(yyruleno==219); - case 267: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==267); - case 272: /* col_name_list ::= col_name */ yytestcase(yyruleno==272); - case 344: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==344); - case 368: /* func_list ::= func */ yytestcase(yyruleno==368); - case 418: /* column_stream_def_list ::= column_stream_def */ yytestcase(yyruleno==418); - case 496: /* tags_literal_list ::= tags_literal */ yytestcase(yyruleno==496); - case 521: /* literal_list ::= signed_literal */ yytestcase(yyruleno==521); - case 616: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==616); - case 622: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==622); - case 698: /* select_list ::= select_item */ yytestcase(yyruleno==698); - case 709: /* partition_list ::= partition_item */ yytestcase(yyruleno==709); - case 772: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==772); -#line 337 "sql.y" + case 172: /* retention_list ::= retention */ + case 205: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==205); + case 208: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==208); + case 217: /* tag_def_list ::= tag_def */ yytestcase(yyruleno==217); + case 220: /* column_def_list ::= column_def */ yytestcase(yyruleno==220); + case 268: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==268); + case 273: /* col_name_list ::= col_name */ yytestcase(yyruleno==273); + case 345: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==345); + case 369: /* func_list ::= func */ yytestcase(yyruleno==369); + case 419: /* column_stream_def_list ::= column_stream_def */ yytestcase(yyruleno==419); + case 497: /* tags_literal_list ::= tags_literal */ yytestcase(yyruleno==497); + case 522: /* literal_list ::= signed_literal */ yytestcase(yyruleno==522); + case 617: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==617); + case 623: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==623); + case 699: /* select_list ::= select_item */ yytestcase(yyruleno==699); + case 710: /* partition_list ::= partition_item */ yytestcase(yyruleno==710); + case 773: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==773); { yylhsminor.yy946 = createNodeList(pCxt, yymsp[0].minor.yy974); } -#line 6963 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; - case 172: /* retention_list ::= retention_list NK_COMMA retention */ - case 208: /* multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ yytestcase(yyruleno==208); - case 217: /* tag_def_list ::= tag_def_list NK_COMMA tag_def */ yytestcase(yyruleno==217); - case 220: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==220); - case 268: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==268); - case 273: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==273); - case 345: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==345); - case 369: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==369); - case 419: /* column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ yytestcase(yyruleno==419); - case 497: /* tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ yytestcase(yyruleno==497); - case 522: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==522); - case 617: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==617); - case 699: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==699); - case 710: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==710); - case 773: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==773); -#line 338 "sql.y" + case 173: /* retention_list ::= retention_list NK_COMMA retention */ + case 209: /* multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ yytestcase(yyruleno==209); + case 218: /* tag_def_list ::= tag_def_list NK_COMMA tag_def */ yytestcase(yyruleno==218); + case 221: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==221); + case 269: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==269); + case 274: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==274); + case 346: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==346); + case 370: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==370); + case 420: /* column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ yytestcase(yyruleno==420); + case 498: /* tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ yytestcase(yyruleno==498); + case 523: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==523); + case 618: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==618); + case 700: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==700); + case 711: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==711); + case 774: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==774); { yylhsminor.yy946 = addNodeToList(pCxt, yymsp[-2].minor.yy946, yymsp[0].minor.yy974); } -#line 6983 "sql.c" yymsp[-2].minor.yy946 = yylhsminor.yy946; break; - case 173: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - case 174: /* retention ::= NK_MINUS NK_COLON NK_VARIABLE */ yytestcase(yyruleno==174); -#line 340 "sql.y" + case 174: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + case 175: /* retention ::= NK_MINUS NK_COLON NK_VARIABLE */ yytestcase(yyruleno==175); { yylhsminor.yy974 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 6990 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 175: /* speed_opt ::= */ - case 402: /* bufsize_opt ::= */ yytestcase(yyruleno==402); -#line 345 "sql.y" + case 176: /* speed_opt ::= */ + case 403: /* bufsize_opt ::= */ yytestcase(yyruleno==403); { yymsp[1].minor.yy904 = 0; } -#line 6997 "sql.c" break; - case 176: /* speed_opt ::= BWLIMIT NK_INTEGER */ - case 403: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==403); -#line 346 "sql.y" + case 177: /* speed_opt ::= BWLIMIT NK_INTEGER */ + case 404: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==404); { yymsp[-1].minor.yy904 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } -#line 7003 "sql.c" break; - case 178: /* start_opt ::= START WITH NK_INTEGER */ - case 182: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==182); -#line 349 "sql.y" + case 179: /* start_opt ::= START WITH NK_INTEGER */ + case 183: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==183); { yymsp[-2].minor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } -#line 7009 "sql.c" break; - case 179: /* start_opt ::= START WITH NK_STRING */ - case 183: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==183); -#line 350 "sql.y" + case 180: /* start_opt ::= START WITH NK_STRING */ + case 184: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==184); { yymsp[-2].minor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } -#line 7015 "sql.c" break; - case 180: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ - case 184: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==184); -#line 351 "sql.y" + case 181: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ + case 185: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==185); { yymsp[-3].minor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } -#line 7021 "sql.c" break; - case 185: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 188: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==188); -#line 360 "sql.y" + case 186: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 189: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==189); { pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy569, yymsp[-5].minor.yy974, yymsp[-3].minor.yy946, yymsp[-1].minor.yy946, yymsp[0].minor.yy974); } -#line 7027 "sql.c" break; - case 186: /* cmd ::= CREATE TABLE multi_create_clause */ -#line 361 "sql.y" + case 187: /* cmd ::= CREATE TABLE multi_create_clause */ { pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy946); } -#line 7032 "sql.c" break; - case 187: /* cmd ::= CREATE TABLE not_exists_opt USING full_table_name NK_LP tag_list_opt NK_RP FILE NK_STRING */ -#line 363 "sql.y" + case 188: /* cmd ::= CREATE TABLE not_exists_opt USING full_table_name NK_LP tag_list_opt NK_RP FILE NK_STRING */ { pCxt->pRootNode = createCreateSubTableFromFileClause(pCxt, yymsp[-7].minor.yy569, yymsp[-5].minor.yy974, yymsp[-3].minor.yy946, &yymsp[0].minor.yy0); } -#line 7037 "sql.c" break; - case 189: /* cmd ::= DROP TABLE with_opt multi_drop_clause */ -#line 366 "sql.y" + case 190: /* cmd ::= DROP TABLE with_opt multi_drop_clause */ { pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[-1].minor.yy569, yymsp[0].minor.yy946); } -#line 7042 "sql.c" break; - case 190: /* cmd ::= DROP STABLE with_opt exists_opt full_table_name */ -#line 367 "sql.y" + case 191: /* cmd ::= DROP STABLE with_opt exists_opt full_table_name */ { pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-2].minor.yy569, yymsp[-1].minor.yy569, yymsp[0].minor.yy974); } -#line 7047 "sql.c" break; - case 191: /* cmd ::= ALTER TABLE alter_table_clause */ - case 454: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==454); - case 455: /* cmd ::= insert_query */ yytestcase(yyruleno==455); -#line 369 "sql.y" + case 192: /* cmd ::= ALTER TABLE alter_table_clause */ + case 455: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==455); + case 456: /* cmd ::= insert_query */ yytestcase(yyruleno==456); { pCxt->pRootNode = yymsp[0].minor.yy974; } -#line 7054 "sql.c" break; - case 192: /* cmd ::= ALTER STABLE alter_table_clause */ -#line 370 "sql.y" + case 193: /* cmd ::= ALTER STABLE alter_table_clause */ { pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy974); } -#line 7059 "sql.c" break; - case 193: /* alter_table_clause ::= full_table_name alter_table_options */ -#line 372 "sql.y" + case 194: /* alter_table_clause ::= full_table_name alter_table_options */ { yylhsminor.yy974 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy974, yymsp[0].minor.yy974); } -#line 7064 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 194: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name column_options */ -#line 374 "sql.y" + case 195: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name column_options */ { yylhsminor.yy974 = createAlterTableAddModifyColOptions2(pCxt, yymsp[-5].minor.yy974, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-2].minor.yy557, yymsp[-1].minor.yy424, yymsp[0].minor.yy974); } -#line 7070 "sql.c" yymsp[-5].minor.yy974 = yylhsminor.yy974; break; - case 195: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -#line 375 "sql.y" + case 196: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ { yylhsminor.yy974 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy974, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy557); } -#line 7076 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; - case 196: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -#line 377 "sql.y" + case 197: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ { yylhsminor.yy974 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy974, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy557, yymsp[0].minor.yy424); } -#line 7082 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; - case 197: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name column_options */ -#line 379 "sql.y" + case 198: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name column_options */ { yylhsminor.yy974 = createAlterTableAddModifyColOptions(pCxt, yymsp[-4].minor.yy974, TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS, &yymsp[-1].minor.yy557, yymsp[0].minor.yy974); } -#line 7088 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; - case 198: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -#line 381 "sql.y" + case 199: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ { yylhsminor.yy974 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy974, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy557, &yymsp[0].minor.yy557); } -#line 7094 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; - case 199: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -#line 383 "sql.y" + case 200: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ { yylhsminor.yy974 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy974, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy557, yymsp[0].minor.yy424); } -#line 7100 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; - case 200: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -#line 384 "sql.y" + case 201: /* alter_table_clause ::= full_table_name DROP TAG column_name */ { yylhsminor.yy974 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy974, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy557); } -#line 7106 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; - case 201: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -#line 386 "sql.y" + case 202: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ { yylhsminor.yy974 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy974, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy557, yymsp[0].minor.yy424); } -#line 7112 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; - case 202: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -#line 388 "sql.y" + case 203: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ { yylhsminor.yy974 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy974, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy557, &yymsp[0].minor.yy557); } -#line 7118 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; - case 203: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal */ -#line 390 "sql.y" + case 204: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal */ { yylhsminor.yy974 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy974, &yymsp[-2].minor.yy557, yymsp[0].minor.yy974); } -#line 7124 "sql.c" yymsp[-5].minor.yy974 = yylhsminor.yy974; break; - case 205: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 623: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==623); -#line 395 "sql.y" + case 206: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 624: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==624); { yylhsminor.yy946 = addNodeToList(pCxt, yymsp[-1].minor.yy946, yymsp[0].minor.yy974); } -#line 7131 "sql.c" yymsp[-1].minor.yy946 = yylhsminor.yy946; break; - case 206: /* 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 */ -#line 399 "sql.y" + case 207: /* 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.yy974 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy569, yymsp[-8].minor.yy974, yymsp[-6].minor.yy974, yymsp[-5].minor.yy946, yymsp[-2].minor.yy946, yymsp[0].minor.yy974); } -#line 7137 "sql.c" yymsp[-9].minor.yy974 = yylhsminor.yy974; break; - case 209: /* drop_table_clause ::= exists_opt full_table_name */ -#line 406 "sql.y" + case 210: /* drop_table_clause ::= exists_opt full_table_name */ { yylhsminor.yy974 = createDropTableClause(pCxt, yymsp[-1].minor.yy569, yymsp[0].minor.yy974); } -#line 7143 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 213: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ - case 417: /* col_list_opt ::= NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==417); -#line 416 "sql.y" + case 214: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ + case 418: /* col_list_opt ::= NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==418); { yymsp[-2].minor.yy946 = yymsp[-1].minor.yy946; } -#line 7150 "sql.c" break; - case 214: /* full_table_name ::= table_name */ - case 358: /* full_tsma_name ::= tsma_name */ yytestcase(yyruleno==358); -#line 418 "sql.y" + case 215: /* full_table_name ::= table_name */ + case 359: /* full_tsma_name ::= tsma_name */ yytestcase(yyruleno==359); { yylhsminor.yy974 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy557, NULL); } -#line 7156 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 215: /* full_table_name ::= db_name NK_DOT table_name */ - case 359: /* full_tsma_name ::= db_name NK_DOT tsma_name */ yytestcase(yyruleno==359); -#line 419 "sql.y" + case 216: /* full_table_name ::= db_name NK_DOT table_name */ + case 360: /* full_tsma_name ::= db_name NK_DOT tsma_name */ yytestcase(yyruleno==360); { yylhsminor.yy974 = createRealTableNode(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy557, NULL); } -#line 7163 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 218: /* tag_def ::= column_name type_name */ -#line 425 "sql.y" + case 219: /* tag_def ::= column_name type_name */ { yylhsminor.yy974 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy557, yymsp[0].minor.yy424, NULL); } -#line 7169 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 221: /* column_def ::= column_name type_name column_options */ -#line 433 "sql.y" + case 222: /* column_def ::= column_name type_name column_options */ { yylhsminor.yy974 = createColumnDefNode(pCxt, &yymsp[-2].minor.yy557, yymsp[-1].minor.yy424, yymsp[0].minor.yy974); } -#line 7175 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 222: /* type_name ::= BOOL */ -#line 437 "sql.y" + case 223: /* type_name ::= BOOL */ { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_BOOL); } -#line 7181 "sql.c" break; - case 223: /* type_name ::= TINYINT */ -#line 438 "sql.y" + case 224: /* type_name ::= TINYINT */ { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_TINYINT); } -#line 7186 "sql.c" break; - case 224: /* type_name ::= SMALLINT */ -#line 439 "sql.y" + case 225: /* type_name ::= SMALLINT */ { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_SMALLINT); } -#line 7191 "sql.c" break; - case 225: /* type_name ::= INT */ - case 226: /* type_name ::= INTEGER */ yytestcase(yyruleno==226); -#line 440 "sql.y" + case 226: /* type_name ::= INT */ + case 227: /* type_name ::= INTEGER */ yytestcase(yyruleno==227); { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_INT); } -#line 7197 "sql.c" break; - case 227: /* type_name ::= BIGINT */ -#line 442 "sql.y" + case 228: /* type_name ::= BIGINT */ { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_BIGINT); } -#line 7202 "sql.c" break; - case 228: /* type_name ::= FLOAT */ -#line 443 "sql.y" + case 229: /* type_name ::= FLOAT */ { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_FLOAT); } -#line 7207 "sql.c" break; - case 229: /* type_name ::= DOUBLE */ -#line 444 "sql.y" + case 230: /* type_name ::= DOUBLE */ { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_DOUBLE); } -#line 7212 "sql.c" break; - case 230: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -#line 445 "sql.y" + case 231: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } -#line 7217 "sql.c" break; - case 231: /* type_name ::= TIMESTAMP */ -#line 446 "sql.y" + case 232: /* type_name ::= TIMESTAMP */ { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } -#line 7222 "sql.c" break; - case 232: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -#line 447 "sql.y" + case 233: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } -#line 7227 "sql.c" break; - case 233: /* type_name ::= TINYINT UNSIGNED */ -#line 448 "sql.y" + case 234: /* type_name ::= TINYINT UNSIGNED */ { yymsp[-1].minor.yy424 = createDataType(TSDB_DATA_TYPE_UTINYINT); } -#line 7232 "sql.c" break; - case 234: /* type_name ::= SMALLINT UNSIGNED */ -#line 449 "sql.y" + case 235: /* type_name ::= SMALLINT UNSIGNED */ { yymsp[-1].minor.yy424 = createDataType(TSDB_DATA_TYPE_USMALLINT); } -#line 7237 "sql.c" break; - case 235: /* type_name ::= INT UNSIGNED */ -#line 450 "sql.y" + case 236: /* type_name ::= INT UNSIGNED */ { yymsp[-1].minor.yy424 = createDataType(TSDB_DATA_TYPE_UINT); } -#line 7242 "sql.c" break; - case 236: /* type_name ::= BIGINT UNSIGNED */ -#line 451 "sql.y" + case 237: /* type_name ::= BIGINT UNSIGNED */ { yymsp[-1].minor.yy424 = createDataType(TSDB_DATA_TYPE_UBIGINT); } -#line 7247 "sql.c" break; - case 237: /* type_name ::= JSON */ -#line 452 "sql.y" + case 238: /* type_name ::= JSON */ { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_JSON); } -#line 7252 "sql.c" break; - case 238: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -#line 453 "sql.y" + case 239: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } -#line 7257 "sql.c" break; - case 239: /* type_name ::= MEDIUMBLOB */ -#line 454 "sql.y" + case 240: /* type_name ::= MEDIUMBLOB */ { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } -#line 7262 "sql.c" break; - case 240: /* type_name ::= BLOB */ -#line 455 "sql.y" + case 241: /* type_name ::= BLOB */ { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_BLOB); } -#line 7267 "sql.c" break; - case 241: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -#line 456 "sql.y" + case 242: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } -#line 7272 "sql.c" break; - case 242: /* type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ -#line 457 "sql.y" + case 243: /* type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } -#line 7277 "sql.c" break; - case 243: /* type_name ::= DECIMAL */ -#line 458 "sql.y" + case 244: /* type_name ::= DECIMAL */ { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_DECIMAL); } -#line 7282 "sql.c" break; - case 244: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -#line 459 "sql.y" + case 245: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy424 = createDataType(TSDB_DATA_TYPE_DECIMAL); } -#line 7287 "sql.c" break; - case 245: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -#line 460 "sql.y" + case 246: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ { yymsp[-5].minor.yy424 = createDataType(TSDB_DATA_TYPE_DECIMAL); } -#line 7292 "sql.c" break; - case 246: /* type_name_default_len ::= BINARY */ -#line 464 "sql.y" + case 247: /* type_name_default_len ::= BINARY */ { yymsp[0].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, NULL); } -#line 7297 "sql.c" break; - case 247: /* type_name_default_len ::= NCHAR */ -#line 465 "sql.y" + case 248: /* type_name_default_len ::= NCHAR */ { yymsp[0].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, NULL); } -#line 7302 "sql.c" break; - case 248: /* type_name_default_len ::= VARCHAR */ -#line 466 "sql.y" + case 249: /* type_name_default_len ::= VARCHAR */ { yymsp[0].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, NULL); } -#line 7307 "sql.c" break; - case 249: /* type_name_default_len ::= VARBINARY */ -#line 467 "sql.y" + case 250: /* type_name_default_len ::= VARBINARY */ { yymsp[0].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, NULL); } -#line 7312 "sql.c" break; - case 252: /* tags_def ::= TAGS NK_LP tag_def_list NK_RP */ - case 425: /* tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==425); -#line 476 "sql.y" + case 253: /* tags_def ::= TAGS NK_LP tag_def_list NK_RP */ + case 426: /* tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==426); { yymsp[-3].minor.yy946 = yymsp[-1].minor.yy946; } -#line 7318 "sql.c" break; - case 253: /* table_options ::= */ -#line 478 "sql.y" + case 254: /* table_options ::= */ { yymsp[1].minor.yy974 = createDefaultTableOptions(pCxt); } -#line 7323 "sql.c" break; - case 254: /* table_options ::= table_options COMMENT NK_STRING */ -#line 479 "sql.y" + case 255: /* table_options ::= table_options COMMENT NK_STRING */ { yylhsminor.yy974 = setTableOption(pCxt, yymsp[-2].minor.yy974, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } -#line 7328 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 255: /* table_options ::= table_options MAX_DELAY duration_list */ -#line 480 "sql.y" + case 256: /* table_options ::= table_options MAX_DELAY duration_list */ { yylhsminor.yy974 = setTableOption(pCxt, yymsp[-2].minor.yy974, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy946); } -#line 7334 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 256: /* table_options ::= table_options WATERMARK duration_list */ -#line 481 "sql.y" + case 257: /* table_options ::= table_options WATERMARK duration_list */ { yylhsminor.yy974 = setTableOption(pCxt, yymsp[-2].minor.yy974, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy946); } -#line 7340 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 257: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -#line 482 "sql.y" + case 258: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ { yylhsminor.yy974 = setTableOption(pCxt, yymsp[-4].minor.yy974, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy946); } -#line 7346 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; - case 258: /* table_options ::= table_options TTL NK_INTEGER */ -#line 483 "sql.y" + case 259: /* table_options ::= table_options TTL NK_INTEGER */ { yylhsminor.yy974 = setTableOption(pCxt, yymsp[-2].minor.yy974, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } -#line 7352 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 259: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -#line 484 "sql.y" + case 260: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ { yylhsminor.yy974 = setTableOption(pCxt, yymsp[-4].minor.yy974, TABLE_OPTION_SMA, yymsp[-1].minor.yy946); } -#line 7358 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; - case 260: /* table_options ::= table_options DELETE_MARK duration_list */ -#line 485 "sql.y" + case 261: /* table_options ::= table_options DELETE_MARK duration_list */ { yylhsminor.yy974 = setTableOption(pCxt, yymsp[-2].minor.yy974, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy946); } -#line 7364 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 261: /* alter_table_options ::= alter_table_option */ -#line 487 "sql.y" + case 262: /* alter_table_options ::= alter_table_option */ { yylhsminor.yy974 = createAlterTableOptions(pCxt); yylhsminor.yy974 = setTableOption(pCxt, yylhsminor.yy974, yymsp[0].minor.yy683.type, &yymsp[0].minor.yy683.val); } -#line 7370 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 262: /* alter_table_options ::= alter_table_options alter_table_option */ -#line 488 "sql.y" + case 263: /* alter_table_options ::= alter_table_options alter_table_option */ { yylhsminor.yy974 = setTableOption(pCxt, yymsp[-1].minor.yy974, yymsp[0].minor.yy683.type, &yymsp[0].minor.yy683.val); } -#line 7376 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 263: /* alter_table_option ::= COMMENT NK_STRING */ -#line 492 "sql.y" + case 264: /* alter_table_option ::= COMMENT NK_STRING */ { yymsp[-1].minor.yy683.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 7382 "sql.c" break; - case 264: /* alter_table_option ::= TTL NK_INTEGER */ -#line 493 "sql.y" + case 265: /* alter_table_option ::= TTL NK_INTEGER */ { yymsp[-1].minor.yy683.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } -#line 7387 "sql.c" break; - case 265: /* duration_list ::= duration_literal */ - case 554: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==554); -#line 497 "sql.y" + case 266: /* duration_list ::= duration_literal */ + case 555: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==555); { yylhsminor.yy946 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy974)); } -#line 7393 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; - case 266: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 555: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==555); -#line 498 "sql.y" + case 267: /* duration_list ::= duration_list NK_COMMA duration_literal */ + case 556: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==556); { yylhsminor.yy946 = addNodeToList(pCxt, yymsp[-2].minor.yy946, releaseRawExprNode(pCxt, yymsp[0].minor.yy974)); } -#line 7400 "sql.c" yymsp[-2].minor.yy946 = yylhsminor.yy946; break; - case 269: /* rollup_func_name ::= function_name */ -#line 505 "sql.y" + case 270: /* rollup_func_name ::= function_name */ { yylhsminor.yy974 = createFunctionNode(pCxt, &yymsp[0].minor.yy557, NULL); } -#line 7406 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 270: /* rollup_func_name ::= FIRST */ - case 271: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==271); - case 347: /* tag_item ::= QTAGS */ yytestcase(yyruleno==347); -#line 506 "sql.y" + case 271: /* rollup_func_name ::= FIRST */ + case 272: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==272); + case 348: /* tag_item ::= QTAGS */ yytestcase(yyruleno==348); { yylhsminor.yy974 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 7414 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 274: /* col_name ::= column_name */ - case 348: /* tag_item ::= column_name */ yytestcase(yyruleno==348); -#line 514 "sql.y" + case 275: /* col_name ::= column_name */ + case 349: /* tag_item ::= column_name */ yytestcase(yyruleno==349); { yylhsminor.yy974 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy557); } -#line 7421 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 275: /* cmd ::= SHOW DNODES */ -#line 517 "sql.y" + case 276: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } -#line 7427 "sql.c" break; - case 276: /* cmd ::= SHOW USERS */ -#line 518 "sql.y" + case 277: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } -#line 7432 "sql.c" break; - case 277: /* cmd ::= SHOW USERS FULL */ -#line 519 "sql.y" + case 278: /* cmd ::= SHOW USERS FULL */ { pCxt->pRootNode = createShowStmtWithFull(pCxt, QUERY_NODE_SHOW_USERS_FULL_STMT); } -#line 7437 "sql.c" break; - case 278: /* cmd ::= SHOW USER PRIVILEGES */ -#line 520 "sql.y" + case 279: /* cmd ::= SHOW USER PRIVILEGES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); } -#line 7442 "sql.c" break; - case 279: /* cmd ::= SHOW db_kind_opt DATABASES */ -#line 521 "sql.y" + case 280: /* cmd ::= SHOW db_kind_opt DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); (void)setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy741); } -#line 7450 "sql.c" break; - case 280: /* cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ -#line 525 "sql.y" + case 281: /* cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ { pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy595, yymsp[0].minor.yy974, OP_TYPE_LIKE); } -#line 7457 "sql.c" break; - case 281: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -#line 528 "sql.y" + case 282: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy974, yymsp[0].minor.yy974, OP_TYPE_LIKE); } -#line 7462 "sql.c" break; - case 282: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -#line 529 "sql.y" + case 283: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy974, NULL, OP_TYPE_LIKE); } -#line 7467 "sql.c" break; - case 283: /* cmd ::= SHOW MNODES */ -#line 530 "sql.y" + case 284: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } -#line 7472 "sql.c" break; - case 284: /* cmd ::= SHOW QNODES */ -#line 532 "sql.y" + case 285: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } -#line 7477 "sql.c" break; - case 285: /* cmd ::= SHOW ANODES */ -#line 533 "sql.y" + case 286: /* cmd ::= SHOW ANODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ANODES_STMT); } -#line 7482 "sql.c" break; - case 286: /* cmd ::= SHOW ANODES FULL */ -#line 534 "sql.y" + case 287: /* cmd ::= SHOW ANODES FULL */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ANODES_FULL_STMT); } -#line 7487 "sql.c" break; - case 287: /* cmd ::= SHOW ARBGROUPS */ -#line 535 "sql.y" + case 288: /* cmd ::= SHOW ARBGROUPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ARBGROUPS_STMT); } -#line 7492 "sql.c" break; - case 288: /* cmd ::= SHOW FUNCTIONS */ -#line 536 "sql.y" + case 289: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } -#line 7497 "sql.c" break; - case 289: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -#line 537 "sql.y" + case 290: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy974, yymsp[-1].minor.yy974, OP_TYPE_EQUAL); } -#line 7502 "sql.c" break; - case 290: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ -#line 538 "sql.y" + case 291: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy557), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy557), OP_TYPE_EQUAL); } -#line 7507 "sql.c" break; - case 291: /* cmd ::= SHOW STREAMS */ -#line 539 "sql.y" + case 292: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } -#line 7512 "sql.c" break; - case 292: /* cmd ::= SHOW ACCOUNTS */ -#line 540 "sql.y" + case 293: /* cmd ::= SHOW ACCOUNTS */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } -#line 7517 "sql.c" break; - case 293: /* cmd ::= SHOW APPS */ -#line 541 "sql.y" + case 294: /* cmd ::= SHOW APPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } -#line 7522 "sql.c" break; - case 294: /* cmd ::= SHOW CONNECTIONS */ -#line 542 "sql.y" + case 295: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } -#line 7527 "sql.c" break; - case 295: /* cmd ::= SHOW LICENCES */ - case 296: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==296); -#line 543 "sql.y" + case 296: /* cmd ::= SHOW LICENCES */ + case 297: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==297); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } -#line 7533 "sql.c" break; - case 297: /* cmd ::= SHOW GRANTS FULL */ -#line 545 "sql.y" + case 298: /* cmd ::= SHOW GRANTS FULL */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_FULL_STMT); } -#line 7538 "sql.c" break; - case 298: /* cmd ::= SHOW GRANTS LOGS */ -#line 546 "sql.y" + case 299: /* cmd ::= SHOW GRANTS LOGS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_LOGS_STMT); } -#line 7543 "sql.c" break; - case 299: /* cmd ::= SHOW CLUSTER MACHINES */ -#line 547 "sql.y" + case 300: /* cmd ::= SHOW CLUSTER MACHINES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT); } -#line 7548 "sql.c" break; - case 300: /* cmd ::= SHOW CREATE DATABASE db_name */ -#line 548 "sql.y" + case 301: /* cmd ::= SHOW CREATE DATABASE db_name */ { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy557); } -#line 7553 "sql.c" break; - case 301: /* cmd ::= SHOW CREATE TABLE full_table_name */ -#line 549 "sql.y" + case 302: /* cmd ::= SHOW CREATE TABLE full_table_name */ { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy974); } -#line 7558 "sql.c" break; - case 302: /* cmd ::= SHOW CREATE STABLE full_table_name */ -#line 550 "sql.y" + case 303: /* cmd ::= SHOW CREATE STABLE full_table_name */ { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy974); } -#line 7564 "sql.c" break; - case 303: /* cmd ::= SHOW ENCRYPTIONS */ -#line 552 "sql.y" + case 304: /* cmd ::= SHOW ENCRYPTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ENCRYPTIONS_STMT); } -#line 7569 "sql.c" break; - case 304: /* cmd ::= SHOW QUERIES */ -#line 553 "sql.y" + case 305: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } -#line 7574 "sql.c" break; - case 305: /* cmd ::= SHOW SCORES */ -#line 554 "sql.y" + case 306: /* cmd ::= SHOW SCORES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } -#line 7579 "sql.c" break; - case 306: /* cmd ::= SHOW TOPICS */ -#line 555 "sql.y" + case 307: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } -#line 7584 "sql.c" break; - case 307: /* cmd ::= SHOW VARIABLES */ - case 308: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==308); -#line 556 "sql.y" + case 308: /* cmd ::= SHOW VARIABLES */ + case 309: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==309); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } -#line 7590 "sql.c" break; - case 309: /* cmd ::= SHOW LOCAL VARIABLES */ -#line 558 "sql.y" + case 310: /* cmd ::= SHOW LOCAL VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } -#line 7595 "sql.c" break; - case 310: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ -#line 559 "sql.y" + case 311: /* 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.yy974); } -#line 7600 "sql.c" break; - case 311: /* cmd ::= SHOW BNODES */ -#line 560 "sql.y" + case 312: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } -#line 7605 "sql.c" break; - case 312: /* cmd ::= SHOW SNODES */ -#line 561 "sql.y" + case 313: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } -#line 7610 "sql.c" break; - case 313: /* cmd ::= SHOW CLUSTER */ -#line 562 "sql.y" + case 314: /* cmd ::= SHOW CLUSTER */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } -#line 7615 "sql.c" break; - case 314: /* cmd ::= SHOW TRANSACTIONS */ -#line 563 "sql.y" + case 315: /* cmd ::= SHOW TRANSACTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } -#line 7620 "sql.c" break; - case 315: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -#line 564 "sql.y" + case 316: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ { pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy974); } -#line 7625 "sql.c" break; - case 316: /* cmd ::= SHOW CONSUMERS */ -#line 565 "sql.y" + case 317: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } -#line 7630 "sql.c" break; - case 317: /* cmd ::= SHOW SUBSCRIPTIONS */ -#line 566 "sql.y" + case 318: /* cmd ::= SHOW SUBSCRIPTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } -#line 7635 "sql.c" break; - case 318: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -#line 567 "sql.y" + case 319: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy974, yymsp[-1].minor.yy974, OP_TYPE_EQUAL); } -#line 7640 "sql.c" break; - case 319: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ -#line 568 "sql.y" + case 320: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy557), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy557), OP_TYPE_EQUAL); } -#line 7645 "sql.c" break; - case 320: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ -#line 569 "sql.y" + case 321: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ { pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy974, yymsp[0].minor.yy974, yymsp[-3].minor.yy946); } -#line 7650 "sql.c" break; - case 321: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ -#line 570 "sql.y" + case 322: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ { pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy557), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy557), yymsp[-4].minor.yy946); } -#line 7655 "sql.c" break; - case 322: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ -#line 571 "sql.y" + case 323: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } -#line 7660 "sql.c" break; - case 323: /* cmd ::= SHOW VNODES */ -#line 572 "sql.y" + case 324: /* cmd ::= SHOW VNODES */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, NULL); } -#line 7665 "sql.c" break; - case 324: /* cmd ::= SHOW db_name_cond_opt ALIVE */ -#line 574 "sql.y" + case 325: /* cmd ::= SHOW db_name_cond_opt ALIVE */ { pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy974, QUERY_NODE_SHOW_DB_ALIVE_STMT); } -#line 7670 "sql.c" break; - case 325: /* cmd ::= SHOW CLUSTER ALIVE */ -#line 575 "sql.y" + case 326: /* cmd ::= SHOW CLUSTER ALIVE */ { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } -#line 7675 "sql.c" break; - case 326: /* cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ -#line 576 "sql.y" + case 327: /* cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-2].minor.yy974, yymsp[0].minor.yy974, OP_TYPE_LIKE); } -#line 7680 "sql.c" break; - case 327: /* cmd ::= SHOW CREATE VIEW full_table_name */ -#line 577 "sql.y" + case 328: /* cmd ::= SHOW CREATE VIEW full_table_name */ { pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy974); } -#line 7685 "sql.c" break; - case 328: /* cmd ::= SHOW COMPACTS */ -#line 578 "sql.y" + case 329: /* cmd ::= SHOW COMPACTS */ { pCxt->pRootNode = createShowCompactsStmt(pCxt, QUERY_NODE_SHOW_COMPACTS_STMT); } -#line 7690 "sql.c" break; - case 329: /* cmd ::= SHOW COMPACT NK_INTEGER */ -#line 579 "sql.y" + case 330: /* cmd ::= SHOW COMPACT NK_INTEGER */ { pCxt->pRootNode = createShowCompactDetailsStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 7695 "sql.c" break; - case 330: /* table_kind_db_name_cond_opt ::= */ -#line 583 "sql.y" + case 331: /* table_kind_db_name_cond_opt ::= */ { yymsp[1].minor.yy595.kind = SHOW_KIND_ALL; yymsp[1].minor.yy595.dbName = nil_token; } -#line 7700 "sql.c" break; - case 331: /* table_kind_db_name_cond_opt ::= table_kind */ -#line 584 "sql.y" + case 332: /* table_kind_db_name_cond_opt ::= table_kind */ { yylhsminor.yy595.kind = yymsp[0].minor.yy741; yylhsminor.yy595.dbName = nil_token; } -#line 7705 "sql.c" yymsp[0].minor.yy595 = yylhsminor.yy595; break; - case 332: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ -#line 585 "sql.y" + case 333: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ { yylhsminor.yy595.kind = SHOW_KIND_ALL; yylhsminor.yy595.dbName = yymsp[-1].minor.yy557; } -#line 7711 "sql.c" yymsp[-1].minor.yy595 = yylhsminor.yy595; break; - case 333: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ -#line 586 "sql.y" + case 334: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ { yylhsminor.yy595.kind = yymsp[-2].minor.yy741; yylhsminor.yy595.dbName = yymsp[-1].minor.yy557; } -#line 7717 "sql.c" yymsp[-2].minor.yy595 = yylhsminor.yy595; break; - case 334: /* table_kind ::= NORMAL */ -#line 590 "sql.y" + case 335: /* table_kind ::= NORMAL */ { yymsp[0].minor.yy741 = SHOW_KIND_TABLES_NORMAL; } -#line 7723 "sql.c" break; - case 335: /* table_kind ::= CHILD */ -#line 591 "sql.y" + case 336: /* table_kind ::= CHILD */ { yymsp[0].minor.yy741 = SHOW_KIND_TABLES_CHILD; } -#line 7728 "sql.c" break; - case 336: /* db_name_cond_opt ::= */ - case 341: /* from_db_opt ::= */ yytestcase(yyruleno==341); -#line 593 "sql.y" + case 337: /* db_name_cond_opt ::= */ + case 342: /* from_db_opt ::= */ yytestcase(yyruleno==342); { yymsp[1].minor.yy974 = createDefaultDatabaseCondValue(pCxt); } -#line 7734 "sql.c" break; - case 337: /* db_name_cond_opt ::= db_name NK_DOT */ -#line 594 "sql.y" + case 338: /* db_name_cond_opt ::= db_name NK_DOT */ { yylhsminor.yy974 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy557); } -#line 7739 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 339: /* like_pattern_opt ::= LIKE NK_STRING */ -#line 597 "sql.y" + case 340: /* like_pattern_opt ::= LIKE NK_STRING */ { yymsp[-1].minor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } -#line 7745 "sql.c" break; - case 340: /* table_name_cond ::= table_name */ -#line 599 "sql.y" + case 341: /* table_name_cond ::= table_name */ { yylhsminor.yy974 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy557); } -#line 7750 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 342: /* from_db_opt ::= FROM db_name */ -#line 602 "sql.y" + case 343: /* from_db_opt ::= FROM db_name */ { yymsp[-1].minor.yy974 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy557); } -#line 7756 "sql.c" break; - case 346: /* tag_item ::= TBNAME */ -#line 610 "sql.y" + case 347: /* tag_item ::= TBNAME */ { yylhsminor.yy974 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } -#line 7761 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 349: /* tag_item ::= column_name column_alias */ -#line 613 "sql.y" + case 350: /* tag_item ::= column_name column_alias */ { yylhsminor.yy974 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy557), &yymsp[0].minor.yy557); } -#line 7767 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 350: /* tag_item ::= column_name AS column_alias */ -#line 614 "sql.y" + case 351: /* tag_item ::= column_name AS column_alias */ { yylhsminor.yy974 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy557), &yymsp[0].minor.yy557); } -#line 7773 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 351: /* db_kind_opt ::= */ -#line 618 "sql.y" + case 352: /* db_kind_opt ::= */ { yymsp[1].minor.yy741 = SHOW_KIND_ALL; } -#line 7779 "sql.c" break; - case 352: /* db_kind_opt ::= USER */ -#line 619 "sql.y" + case 353: /* db_kind_opt ::= USER */ { yymsp[0].minor.yy741 = SHOW_KIND_DATABASES_USER; } -#line 7784 "sql.c" break; - case 353: /* db_kind_opt ::= SYSTEM */ -#line 620 "sql.y" + case 354: /* db_kind_opt ::= SYSTEM */ { yymsp[0].minor.yy741 = SHOW_KIND_DATABASES_SYSTEM; } -#line 7789 "sql.c" break; - case 354: /* cmd ::= CREATE TSMA not_exists_opt tsma_name ON full_table_name tsma_func_list INTERVAL NK_LP duration_literal NK_RP */ -#line 626 "sql.y" + case 355: /* cmd ::= CREATE TSMA not_exists_opt tsma_name ON full_table_name tsma_func_list INTERVAL NK_LP duration_literal NK_RP */ { pCxt->pRootNode = createCreateTSMAStmt(pCxt, yymsp[-8].minor.yy569, &yymsp[-7].minor.yy557, yymsp[-4].minor.yy974, yymsp[-5].minor.yy974, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974)); } -#line 7794 "sql.c" break; - case 355: /* cmd ::= CREATE RECURSIVE TSMA not_exists_opt tsma_name ON full_table_name INTERVAL NK_LP duration_literal NK_RP */ -#line 628 "sql.y" + case 356: /* cmd ::= CREATE RECURSIVE TSMA not_exists_opt tsma_name ON full_table_name INTERVAL NK_LP duration_literal NK_RP */ { pCxt->pRootNode = createCreateTSMAStmt(pCxt, yymsp[-7].minor.yy569, &yymsp[-6].minor.yy557, NULL, yymsp[-4].minor.yy974, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974)); } -#line 7799 "sql.c" break; - case 356: /* cmd ::= DROP TSMA exists_opt full_tsma_name */ -#line 629 "sql.y" + case 357: /* cmd ::= DROP TSMA exists_opt full_tsma_name */ { pCxt->pRootNode = createDropTSMAStmt(pCxt, yymsp[-1].minor.yy569, yymsp[0].minor.yy974); } -#line 7804 "sql.c" break; - case 357: /* cmd ::= SHOW db_name_cond_opt TSMAS */ -#line 630 "sql.y" + case 358: /* cmd ::= SHOW db_name_cond_opt TSMAS */ { pCxt->pRootNode = createShowTSMASStmt(pCxt, yymsp[-1].minor.yy974); } -#line 7809 "sql.c" break; - case 360: /* tsma_func_list ::= FUNCTION NK_LP func_list NK_RP */ -#line 637 "sql.y" + case 361: /* tsma_func_list ::= FUNCTION NK_LP func_list NK_RP */ { yymsp[-3].minor.yy974 = createTSMAOptions(pCxt, yymsp[-1].minor.yy946); } -#line 7814 "sql.c" break; - case 361: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ -#line 641 "sql.y" + case 362: /* 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.yy569, yymsp[-3].minor.yy974, yymsp[-1].minor.yy974, NULL, yymsp[0].minor.yy974); } -#line 7819 "sql.c" break; - case 362: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ -#line 643 "sql.y" + case 363: /* 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.yy569, yymsp[-5].minor.yy974, yymsp[-3].minor.yy974, yymsp[-1].minor.yy946, NULL); } -#line 7824 "sql.c" break; - case 363: /* cmd ::= DROP INDEX exists_opt full_index_name */ -#line 644 "sql.y" + case 364: /* cmd ::= DROP INDEX exists_opt full_index_name */ { pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy569, yymsp[0].minor.yy974); } -#line 7829 "sql.c" break; - case 364: /* full_index_name ::= index_name */ -#line 646 "sql.y" + case 365: /* full_index_name ::= index_name */ { yylhsminor.yy974 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy557); } -#line 7834 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 365: /* full_index_name ::= db_name NK_DOT index_name */ -#line 647 "sql.y" + case 366: /* full_index_name ::= db_name NK_DOT index_name */ { yylhsminor.yy974 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy557); } -#line 7840 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 366: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -#line 650 "sql.y" + case 367: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ { yymsp[-9].minor.yy974 = createIndexOption(pCxt, yymsp[-7].minor.yy946, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), NULL, yymsp[-1].minor.yy974, yymsp[0].minor.yy974); } -#line 7846 "sql.c" break; - case 367: /* 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 */ -#line 653 "sql.y" + case 368: /* 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.yy974 = createIndexOption(pCxt, yymsp[-9].minor.yy946, releaseRawExprNode(pCxt, yymsp[-5].minor.yy974), releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), yymsp[-1].minor.yy974, yymsp[0].minor.yy974); } -#line 7851 "sql.c" break; - case 370: /* func ::= sma_func_name NK_LP expression_list NK_RP */ -#line 660 "sql.y" + case 371: /* func ::= sma_func_name NK_LP expression_list NK_RP */ { yylhsminor.yy974 = createFunctionNode(pCxt, &yymsp[-3].minor.yy557, yymsp[-1].minor.yy946); } -#line 7856 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; - case 371: /* sma_func_name ::= function_name */ - case 666: /* alias_opt ::= table_alias */ yytestcase(yyruleno==666); -#line 664 "sql.y" + case 372: /* sma_func_name ::= function_name */ + case 667: /* alias_opt ::= table_alias */ yytestcase(yyruleno==667); { yylhsminor.yy557 = yymsp[0].minor.yy557; } -#line 7863 "sql.c" yymsp[0].minor.yy557 = yylhsminor.yy557; break; - case 376: /* sma_stream_opt ::= */ - case 426: /* stream_options ::= */ yytestcase(yyruleno==426); -#line 670 "sql.y" + case 377: /* sma_stream_opt ::= */ + case 427: /* stream_options ::= */ yytestcase(yyruleno==427); { yymsp[1].minor.yy974 = createStreamOptions(pCxt); } -#line 7870 "sql.c" break; - case 377: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ -#line 671 "sql.y" + case 378: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ { ((SStreamOptions*)yymsp[-2].minor.yy974)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = yymsp[-2].minor.yy974; } -#line 7875 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 378: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ -#line 672 "sql.y" + case 379: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ { ((SStreamOptions*)yymsp[-2].minor.yy974)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = yymsp[-2].minor.yy974; } -#line 7881 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 379: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ -#line 673 "sql.y" + case 380: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ { ((SStreamOptions*)yymsp[-2].minor.yy974)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = yymsp[-2].minor.yy974; } -#line 7887 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 380: /* with_meta ::= AS */ -#line 678 "sql.y" + case 381: /* with_meta ::= AS */ { yymsp[0].minor.yy904 = 0; } -#line 7893 "sql.c" break; - case 381: /* with_meta ::= WITH META AS */ -#line 679 "sql.y" + case 382: /* with_meta ::= WITH META AS */ { yymsp[-2].minor.yy904 = 1; } -#line 7898 "sql.c" break; - case 382: /* with_meta ::= ONLY META AS */ -#line 680 "sql.y" + case 383: /* with_meta ::= ONLY META AS */ { yymsp[-2].minor.yy904 = 2; } -#line 7903 "sql.c" break; - case 383: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -#line 682 "sql.y" + case 384: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy569, &yymsp[-2].minor.yy557, yymsp[0].minor.yy974); } -#line 7908 "sql.c" break; - case 384: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ -#line 684 "sql.y" + case 385: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy569, &yymsp[-3].minor.yy557, &yymsp[0].minor.yy557, yymsp[-2].minor.yy904); } -#line 7913 "sql.c" break; - case 385: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ -#line 686 "sql.y" + case 386: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy569, &yymsp[-4].minor.yy557, yymsp[-1].minor.yy974, yymsp[-3].minor.yy904, yymsp[0].minor.yy974); } -#line 7918 "sql.c" break; - case 386: /* cmd ::= DROP TOPIC exists_opt topic_name */ -#line 688 "sql.y" + case 387: /* cmd ::= DROP TOPIC exists_opt topic_name */ { pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy569, &yymsp[0].minor.yy557); } -#line 7923 "sql.c" break; - case 387: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -#line 689 "sql.y" + case 388: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ { pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy569, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy557); } -#line 7928 "sql.c" break; - case 388: /* cmd ::= DESC full_table_name */ - case 389: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==389); -#line 692 "sql.y" + case 389: /* cmd ::= DESC full_table_name */ + case 390: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==390); { pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy974); } -#line 7934 "sql.c" break; - case 390: /* cmd ::= RESET QUERY CACHE */ -#line 696 "sql.y" + case 391: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } -#line 7939 "sql.c" break; - case 391: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - case 392: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==392); -#line 699 "sql.y" + case 392: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + case 393: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==393); { pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy569, yymsp[-1].minor.yy974, yymsp[0].minor.yy974); } -#line 7945 "sql.c" break; - case 395: /* explain_options ::= */ -#line 707 "sql.y" + case 396: /* explain_options ::= */ { yymsp[1].minor.yy974 = createDefaultExplainOptions(pCxt); } -#line 7950 "sql.c" break; - case 396: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -#line 708 "sql.y" + case 397: /* explain_options ::= explain_options VERBOSE NK_BOOL */ { yylhsminor.yy974 = setExplainVerbose(pCxt, yymsp[-2].minor.yy974, &yymsp[0].minor.yy0); } -#line 7955 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 397: /* explain_options ::= explain_options RATIO NK_FLOAT */ -#line 709 "sql.y" + case 398: /* explain_options ::= explain_options RATIO NK_FLOAT */ { yylhsminor.yy974 = setExplainRatio(pCxt, yymsp[-2].minor.yy974, &yymsp[0].minor.yy0); } -#line 7961 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 398: /* cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ -#line 714 "sql.y" + case 399: /* 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.yy569, yymsp[-9].minor.yy569, &yymsp[-6].minor.yy557, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy424, yymsp[-1].minor.yy904, &yymsp[0].minor.yy557, yymsp[-10].minor.yy569); } -#line 7967 "sql.c" break; - case 399: /* cmd ::= DROP FUNCTION exists_opt function_name */ -#line 715 "sql.y" + case 400: /* cmd ::= DROP FUNCTION exists_opt function_name */ { pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy569, &yymsp[0].minor.yy557); } -#line 7972 "sql.c" break; - case 404: /* language_opt ::= */ - case 449: /* on_vgroup_id ::= */ yytestcase(yyruleno==449); -#line 729 "sql.y" + case 405: /* language_opt ::= */ + case 450: /* on_vgroup_id ::= */ yytestcase(yyruleno==450); { yymsp[1].minor.yy557 = nil_token; } -#line 7978 "sql.c" break; - case 405: /* language_opt ::= LANGUAGE NK_STRING */ - case 450: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==450); -#line 730 "sql.y" + case 406: /* language_opt ::= LANGUAGE NK_STRING */ + case 451: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==451); { yymsp[-1].minor.yy557 = yymsp[0].minor.yy0; } -#line 7984 "sql.c" break; - case 408: /* cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ -#line 739 "sql.y" + case 409: /* cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ { pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy569, yymsp[-2].minor.yy974, &yymsp[-1].minor.yy0, yymsp[0].minor.yy974); } -#line 7989 "sql.c" break; - case 409: /* cmd ::= DROP VIEW exists_opt full_view_name */ -#line 740 "sql.y" + case 410: /* cmd ::= DROP VIEW exists_opt full_view_name */ { pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy569, yymsp[0].minor.yy974); } -#line 7994 "sql.c" break; - case 410: /* full_view_name ::= view_name */ -#line 742 "sql.y" + case 411: /* full_view_name ::= view_name */ { yylhsminor.yy974 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy557); } -#line 7999 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 411: /* full_view_name ::= db_name NK_DOT view_name */ -#line 743 "sql.y" + case 412: /* full_view_name ::= db_name NK_DOT view_name */ { yylhsminor.yy974 = createViewNode(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy557); } -#line 8005 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 412: /* 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 */ -#line 748 "sql.y" + case 413: /* 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.yy569, &yymsp[-8].minor.yy557, yymsp[-5].minor.yy974, yymsp[-7].minor.yy974, yymsp[-3].minor.yy946, yymsp[-2].minor.yy974, yymsp[0].minor.yy974, yymsp[-4].minor.yy946); } -#line 8011 "sql.c" break; - case 413: /* cmd ::= DROP STREAM exists_opt stream_name */ -#line 749 "sql.y" + case 414: /* cmd ::= DROP STREAM exists_opt stream_name */ { pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy569, &yymsp[0].minor.yy557); } -#line 8016 "sql.c" break; - case 414: /* cmd ::= PAUSE STREAM exists_opt stream_name */ -#line 750 "sql.y" + case 415: /* cmd ::= PAUSE STREAM exists_opt stream_name */ { pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy569, &yymsp[0].minor.yy557); } -#line 8021 "sql.c" break; - case 415: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ -#line 751 "sql.y" + case 416: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ { pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy569, yymsp[-1].minor.yy569, &yymsp[0].minor.yy557); } -#line 8026 "sql.c" break; - case 420: /* column_stream_def ::= column_name stream_col_options */ -#line 764 "sql.y" + case 421: /* column_stream_def ::= column_name stream_col_options */ { yylhsminor.yy974 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy557, createDataType(TSDB_DATA_TYPE_NULL), yymsp[0].minor.yy974); } -#line 8031 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 421: /* stream_col_options ::= */ - case 781: /* column_options ::= */ yytestcase(yyruleno==781); -#line 765 "sql.y" + case 422: /* stream_col_options ::= */ + case 782: /* column_options ::= */ yytestcase(yyruleno==782); { yymsp[1].minor.yy974 = createDefaultColumnOptions(pCxt); } -#line 8038 "sql.c" break; - case 422: /* stream_col_options ::= stream_col_options PRIMARY KEY */ - case 782: /* column_options ::= column_options PRIMARY KEY */ yytestcase(yyruleno==782); -#line 766 "sql.y" + case 423: /* stream_col_options ::= stream_col_options PRIMARY KEY */ + case 783: /* column_options ::= column_options PRIMARY KEY */ yytestcase(yyruleno==783); { yylhsminor.yy974 = setColumnOptionsPK(pCxt, yymsp[-2].minor.yy974); } -#line 8044 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 427: /* stream_options ::= stream_options TRIGGER AT_ONCE */ - case 428: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==428); -#line 776 "sql.y" + case 428: /* stream_options ::= stream_options TRIGGER AT_ONCE */ + case 429: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==429); { yylhsminor.yy974 = setStreamOptions(pCxt, yymsp[-2].minor.yy974, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } -#line 8051 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 429: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -#line 778 "sql.y" + case 430: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ { yylhsminor.yy974 = setStreamOptions(pCxt, yymsp[-3].minor.yy974, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy974)); } -#line 8057 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; - case 430: /* stream_options ::= stream_options WATERMARK duration_literal */ -#line 779 "sql.y" + case 431: /* stream_options ::= stream_options WATERMARK duration_literal */ { yylhsminor.yy974 = setStreamOptions(pCxt, yymsp[-2].minor.yy974, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy974)); } -#line 8063 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 431: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -#line 780 "sql.y" + case 432: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ { yylhsminor.yy974 = setStreamOptions(pCxt, yymsp[-3].minor.yy974, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } -#line 8069 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; - case 432: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ -#line 781 "sql.y" + case 433: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ { yylhsminor.yy974 = setStreamOptions(pCxt, yymsp[-2].minor.yy974, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } -#line 8075 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 433: /* stream_options ::= stream_options DELETE_MARK duration_literal */ -#line 782 "sql.y" + case 434: /* stream_options ::= stream_options DELETE_MARK duration_literal */ { yylhsminor.yy974 = setStreamOptions(pCxt, yymsp[-2].minor.yy974, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy974)); } -#line 8081 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 434: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ -#line 783 "sql.y" + case 435: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ { yylhsminor.yy974 = setStreamOptions(pCxt, yymsp[-3].minor.yy974, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } -#line 8087 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; - case 436: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 725: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==725); - case 749: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==749); -#line 786 "sql.y" + case 437: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 726: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==726); + case 750: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==750); { yymsp[-3].minor.yy974 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy974); } -#line 8095 "sql.c" break; - case 439: /* cmd ::= KILL CONNECTION NK_INTEGER */ -#line 794 "sql.y" + case 440: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } -#line 8100 "sql.c" break; - case 440: /* cmd ::= KILL QUERY NK_STRING */ -#line 795 "sql.y" + case 441: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } -#line 8105 "sql.c" break; - case 441: /* cmd ::= KILL TRANSACTION NK_INTEGER */ -#line 796 "sql.y" + case 442: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } -#line 8110 "sql.c" break; - case 442: /* cmd ::= KILL COMPACT NK_INTEGER */ -#line 797 "sql.y" + case 443: /* cmd ::= KILL COMPACT NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_COMPACT_STMT, &yymsp[0].minor.yy0); } -#line 8115 "sql.c" break; - case 443: /* cmd ::= BALANCE VGROUP */ -#line 800 "sql.y" + case 444: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } -#line 8120 "sql.c" break; - case 444: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ -#line 801 "sql.y" + case 445: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ { pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy557); } -#line 8125 "sql.c" break; - case 445: /* cmd ::= BALANCE VGROUP LEADER DATABASE db_name */ -#line 802 "sql.y" + case 446: /* cmd ::= BALANCE VGROUP LEADER DATABASE db_name */ { pCxt->pRootNode = createBalanceVgroupLeaderDBNameStmt(pCxt, &yymsp[0].minor.yy557); } -#line 8130 "sql.c" break; - case 446: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ -#line 803 "sql.y" + case 447: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 8135 "sql.c" break; - case 447: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -#line 804 "sql.y" + case 448: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ { pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy946); } -#line 8140 "sql.c" break; - case 448: /* cmd ::= SPLIT VGROUP NK_INTEGER */ -#line 805 "sql.y" + case 449: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } -#line 8145 "sql.c" break; - case 451: /* dnode_list ::= DNODE NK_INTEGER */ -#line 814 "sql.y" + case 452: /* dnode_list ::= DNODE NK_INTEGER */ { yymsp[-1].minor.yy946 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 8150 "sql.c" break; - case 453: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -#line 821 "sql.y" + case 454: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ { pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy974, yymsp[0].minor.yy974); } -#line 8155 "sql.c" break; - case 456: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -#line 830 "sql.y" + case 457: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ { yymsp[-6].minor.yy974 = createInsertStmt(pCxt, yymsp[-4].minor.yy974, yymsp[-2].minor.yy946, yymsp[0].minor.yy974); } -#line 8160 "sql.c" break; - case 457: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ -#line 831 "sql.y" + case 458: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ { yymsp[-3].minor.yy974 = createInsertStmt(pCxt, yymsp[-1].minor.yy974, NULL, yymsp[0].minor.yy974); } -#line 8165 "sql.c" break; - case 458: /* tags_literal ::= NK_INTEGER */ - case 470: /* tags_literal ::= NK_BIN */ yytestcase(yyruleno==470); - case 479: /* tags_literal ::= NK_HEX */ yytestcase(yyruleno==479); -#line 834 "sql.y" + case 459: /* tags_literal ::= NK_INTEGER */ + case 471: /* tags_literal ::= NK_BIN */ yytestcase(yyruleno==471); + case 480: /* tags_literal ::= NK_HEX */ yytestcase(yyruleno==480); { yylhsminor.yy974 = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0, NULL); } -#line 8172 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 459: /* tags_literal ::= NK_INTEGER NK_PLUS duration_literal */ - case 460: /* tags_literal ::= NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==460); - case 471: /* tags_literal ::= NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==471); - case 472: /* tags_literal ::= NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==472); - case 480: /* tags_literal ::= NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==480); - case 481: /* tags_literal ::= NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==481); - case 489: /* tags_literal ::= NK_STRING NK_PLUS duration_literal */ yytestcase(yyruleno==489); - case 490: /* tags_literal ::= NK_STRING NK_MINUS duration_literal */ yytestcase(yyruleno==490); -#line 835 "sql.y" + case 460: /* tags_literal ::= NK_INTEGER NK_PLUS duration_literal */ + case 461: /* tags_literal ::= NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==461); + case 472: /* tags_literal ::= NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==472); + case 473: /* tags_literal ::= NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==473); + case 481: /* tags_literal ::= NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==481); + case 482: /* tags_literal ::= NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==482); + case 490: /* tags_literal ::= NK_STRING NK_PLUS duration_literal */ yytestcase(yyruleno==490); + case 491: /* tags_literal ::= NK_STRING NK_MINUS duration_literal */ yytestcase(yyruleno==491); { SToken l = yymsp[-2].minor.yy0; SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); l.n = (r.z + r.n) - l.z; yylhsminor.yy974 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, yymsp[0].minor.yy974); } -#line 8190 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 461: /* tags_literal ::= NK_PLUS NK_INTEGER */ - case 464: /* tags_literal ::= NK_MINUS NK_INTEGER */ yytestcase(yyruleno==464); - case 473: /* tags_literal ::= NK_PLUS NK_BIN */ yytestcase(yyruleno==473); - case 476: /* tags_literal ::= NK_MINUS NK_BIN */ yytestcase(yyruleno==476); - case 482: /* tags_literal ::= NK_PLUS NK_HEX */ yytestcase(yyruleno==482); - case 485: /* tags_literal ::= NK_MINUS NK_HEX */ yytestcase(yyruleno==485); -#line 847 "sql.y" + case 462: /* tags_literal ::= NK_PLUS NK_INTEGER */ + case 465: /* tags_literal ::= NK_MINUS NK_INTEGER */ yytestcase(yyruleno==465); + case 474: /* tags_literal ::= NK_PLUS NK_BIN */ yytestcase(yyruleno==474); + case 477: /* tags_literal ::= NK_MINUS NK_BIN */ yytestcase(yyruleno==477); + case 483: /* tags_literal ::= NK_PLUS NK_HEX */ yytestcase(yyruleno==483); + case 486: /* tags_literal ::= NK_MINUS NK_HEX */ yytestcase(yyruleno==486); { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy974 = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); } -#line 8205 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 462: /* tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal */ - case 463: /* tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==463); - case 465: /* tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal */ yytestcase(yyruleno==465); - case 466: /* tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==466); - case 474: /* tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==474); - case 475: /* tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==475); - case 477: /* tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==477); - case 478: /* tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==478); - case 483: /* tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==483); - case 484: /* tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==484); - case 486: /* tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==486); - case 487: /* tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==487); -#line 852 "sql.y" + case 463: /* tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal */ + case 464: /* tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==464); + case 466: /* tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal */ yytestcase(yyruleno==466); + case 467: /* tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==467); + case 475: /* tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==475); + case 476: /* tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==476); + case 478: /* tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==478); + case 479: /* tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==479); + case 484: /* tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==484); + case 485: /* tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==485); + case 487: /* tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==487); + case 488: /* tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==488); { SToken l = yymsp[-3].minor.yy0; SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); l.n = (r.z + r.n) - l.z; yylhsminor.yy974 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, yymsp[0].minor.yy974); } -#line 8227 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; - case 467: /* tags_literal ::= NK_FLOAT */ -#line 881 "sql.y" + case 468: /* tags_literal ::= NK_FLOAT */ { yylhsminor.yy974 = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0, NULL); } -#line 8233 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 468: /* tags_literal ::= NK_PLUS NK_FLOAT */ - case 469: /* tags_literal ::= NK_MINUS NK_FLOAT */ yytestcase(yyruleno==469); -#line 882 "sql.y" + case 469: /* tags_literal ::= NK_PLUS NK_FLOAT */ + case 470: /* tags_literal ::= NK_MINUS NK_FLOAT */ yytestcase(yyruleno==470); { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy974 = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t, NULL); } -#line 8244 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 488: /* tags_literal ::= NK_STRING */ -#line 988 "sql.y" + case 489: /* tags_literal ::= NK_STRING */ { yylhsminor.yy974 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0, NULL); } -#line 8250 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 491: /* tags_literal ::= NK_BOOL */ -#line 1001 "sql.y" + case 492: /* tags_literal ::= NK_BOOL */ { yylhsminor.yy974 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0, NULL); } -#line 8256 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 492: /* tags_literal ::= NULL */ -#line 1002 "sql.y" + case 493: /* tags_literal ::= NULL */ { yylhsminor.yy974 = createRawValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0, NULL); } -#line 8262 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 493: /* tags_literal ::= literal_func */ -#line 1004 "sql.y" + case 494: /* tags_literal ::= literal_func */ { yylhsminor.yy974 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, NULL, yymsp[0].minor.yy974); } -#line 8268 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 494: /* tags_literal ::= literal_func NK_PLUS duration_literal */ - case 495: /* tags_literal ::= literal_func NK_MINUS duration_literal */ yytestcase(yyruleno==495); -#line 1005 "sql.y" + case 495: /* tags_literal ::= literal_func NK_PLUS duration_literal */ + case 496: /* tags_literal ::= literal_func NK_MINUS duration_literal */ yytestcase(yyruleno==496); { SToken l = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); l.n = (r.z + r.n) - l.z; yylhsminor.yy974 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, yymsp[-2].minor.yy974, yymsp[0].minor.yy974); } -#line 8280 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 498: /* literal ::= NK_INTEGER */ -#line 1024 "sql.y" + case 499: /* literal ::= NK_INTEGER */ { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } -#line 8286 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 499: /* literal ::= NK_FLOAT */ -#line 1025 "sql.y" + case 500: /* literal ::= NK_FLOAT */ { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } -#line 8292 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 500: /* literal ::= NK_STRING */ -#line 1026 "sql.y" + case 501: /* literal ::= NK_STRING */ { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } -#line 8298 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 501: /* literal ::= NK_BOOL */ -#line 1027 "sql.y" + case 502: /* literal ::= NK_BOOL */ { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } -#line 8304 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 502: /* literal ::= TIMESTAMP NK_STRING */ -#line 1028 "sql.y" + case 503: /* literal ::= TIMESTAMP NK_STRING */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } -#line 8310 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 503: /* literal ::= duration_literal */ - case 513: /* signed_literal ::= signed */ yytestcase(yyruleno==513); - case 537: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==537); - case 538: /* expression ::= literal */ yytestcase(yyruleno==538); - case 540: /* expression ::= column_reference */ yytestcase(yyruleno==540); - case 541: /* expression ::= function_expression */ yytestcase(yyruleno==541); - case 542: /* expression ::= case_when_expression */ yytestcase(yyruleno==542); - case 588: /* function_expression ::= literal_func */ yytestcase(yyruleno==588); - case 589: /* function_expression ::= rand_func */ yytestcase(yyruleno==589); - case 647: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==647); - case 651: /* boolean_primary ::= predicate */ yytestcase(yyruleno==651); - case 653: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==653); - case 654: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==654); - case 657: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==657); - case 659: /* table_reference ::= table_primary */ yytestcase(yyruleno==659); - case 660: /* table_reference ::= joined_table */ yytestcase(yyruleno==660); - case 664: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==664); - case 751: /* query_simple ::= query_specification */ yytestcase(yyruleno==751); - case 752: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==752); - case 755: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==755); - case 757: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==757); -#line 1029 "sql.y" + case 504: /* literal ::= duration_literal */ + case 514: /* signed_literal ::= signed */ yytestcase(yyruleno==514); + case 538: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==538); + case 539: /* expression ::= literal */ yytestcase(yyruleno==539); + case 541: /* expression ::= column_reference */ yytestcase(yyruleno==541); + case 542: /* expression ::= function_expression */ yytestcase(yyruleno==542); + case 543: /* expression ::= case_when_expression */ yytestcase(yyruleno==543); + case 589: /* function_expression ::= literal_func */ yytestcase(yyruleno==589); + case 590: /* function_expression ::= rand_func */ yytestcase(yyruleno==590); + case 648: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==648); + case 652: /* boolean_primary ::= predicate */ yytestcase(yyruleno==652); + case 654: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==654); + case 655: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==655); + case 658: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==658); + case 660: /* table_reference ::= table_primary */ yytestcase(yyruleno==660); + case 661: /* table_reference ::= joined_table */ yytestcase(yyruleno==661); + case 665: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==665); + case 752: /* query_simple ::= query_specification */ yytestcase(yyruleno==752); + case 753: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==753); + case 756: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==756); + case 758: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==758); { yylhsminor.yy974 = yymsp[0].minor.yy974; } -#line 8336 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 504: /* literal ::= NULL */ -#line 1030 "sql.y" + case 505: /* literal ::= NULL */ { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } -#line 8342 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 505: /* literal ::= NK_QUESTION */ -#line 1031 "sql.y" + case 506: /* literal ::= NK_QUESTION */ { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 8348 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 506: /* duration_literal ::= NK_VARIABLE */ - case 726: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==726); - case 727: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==727); - case 728: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==728); -#line 1033 "sql.y" + case 507: /* duration_literal ::= NK_VARIABLE */ + case 727: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==727); + case 728: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==728); + case 729: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==729); { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 8357 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 507: /* signed ::= NK_INTEGER */ -#line 1035 "sql.y" + case 508: /* signed ::= NK_INTEGER */ { yylhsminor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } -#line 8363 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 508: /* signed ::= NK_PLUS NK_INTEGER */ -#line 1036 "sql.y" + case 509: /* signed ::= NK_PLUS NK_INTEGER */ { yymsp[-1].minor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } -#line 8369 "sql.c" break; - case 509: /* signed ::= NK_MINUS NK_INTEGER */ -#line 1037 "sql.y" + case 510: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } -#line 8378 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 510: /* signed ::= NK_FLOAT */ -#line 1042 "sql.y" + case 511: /* signed ::= NK_FLOAT */ { yylhsminor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } -#line 8384 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 511: /* signed ::= NK_PLUS NK_FLOAT */ -#line 1043 "sql.y" + case 512: /* signed ::= NK_PLUS NK_FLOAT */ { yymsp[-1].minor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } -#line 8390 "sql.c" break; - case 512: /* signed ::= NK_MINUS NK_FLOAT */ -#line 1044 "sql.y" + case 513: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } -#line 8399 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 514: /* signed_literal ::= NK_STRING */ -#line 1051 "sql.y" + case 515: /* signed_literal ::= NK_STRING */ { yylhsminor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } -#line 8405 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 515: /* signed_literal ::= NK_BOOL */ -#line 1052 "sql.y" + case 516: /* signed_literal ::= NK_BOOL */ { yylhsminor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } -#line 8411 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 516: /* signed_literal ::= TIMESTAMP NK_STRING */ -#line 1053 "sql.y" + case 517: /* signed_literal ::= TIMESTAMP NK_STRING */ { yymsp[-1].minor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } -#line 8417 "sql.c" - break; - case 517: /* signed_literal ::= duration_literal */ - case 519: /* signed_literal ::= literal_func */ yytestcase(yyruleno==519); - case 618: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==618); - case 701: /* select_item ::= common_expression */ yytestcase(yyruleno==701); - case 711: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==711); - case 756: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==756); - case 758: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==758); - case 771: /* search_condition ::= common_expression */ yytestcase(yyruleno==771); -#line 1054 "sql.y" + break; + case 518: /* signed_literal ::= duration_literal */ + case 520: /* signed_literal ::= literal_func */ yytestcase(yyruleno==520); + case 619: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==619); + case 702: /* select_item ::= common_expression */ yytestcase(yyruleno==702); + case 712: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==712); + case 757: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==757); + case 759: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==759); + case 772: /* search_condition ::= common_expression */ yytestcase(yyruleno==772); { yylhsminor.yy974 = releaseRawExprNode(pCxt, yymsp[0].minor.yy974); } -#line 8429 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 518: /* signed_literal ::= NULL */ -#line 1055 "sql.y" + case 519: /* signed_literal ::= NULL */ { yylhsminor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } -#line 8435 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 520: /* signed_literal ::= NK_QUESTION */ -#line 1057 "sql.y" + case 521: /* signed_literal ::= NK_QUESTION */ { yylhsminor.yy974 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } -#line 8441 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 539: /* expression ::= pseudo_column */ -#line 1123 "sql.y" + case 540: /* expression ::= pseudo_column */ { yylhsminor.yy974 = yymsp[0].minor.yy974; (void)setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy974, true); } -#line 8447 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 543: /* expression ::= NK_LP expression NK_RP */ - case 652: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==652); - case 770: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==770); -#line 1127 "sql.y" + case 544: /* expression ::= NK_LP expression NK_RP */ + case 653: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==653); + case 771: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==771); { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974)); } -#line 8455 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 544: /* expression ::= NK_PLUS expr_or_subquery */ -#line 1128 "sql.y" + case 545: /* expression ::= NK_PLUS expr_or_subquery */ { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy974)); } -#line 8464 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 545: /* expression ::= NK_MINUS expr_or_subquery */ -#line 1132 "sql.y" + case 546: /* expression ::= NK_MINUS expr_or_subquery */ { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy974), NULL)); } -#line 8473 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 546: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ -#line 1136 "sql.y" + case 547: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } -#line 8483 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 547: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ -#line 1141 "sql.y" + case 548: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } -#line 8493 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 548: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ -#line 1146 "sql.y" + case 549: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } -#line 8503 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 549: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ -#line 1151 "sql.y" + case 550: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } -#line 8513 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 550: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ -#line 1156 "sql.y" + case 551: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } -#line 8523 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 551: /* expression ::= column_reference NK_ARROW NK_STRING */ -#line 1161 "sql.y" + case 552: /* expression ::= column_reference NK_ARROW NK_STRING */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } -#line 8532 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 552: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ -#line 1165 "sql.y" + case 553: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } -#line 8542 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 553: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ -#line 1170 "sql.y" + case 554: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } -#line 8552 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 556: /* column_reference ::= column_name */ -#line 1181 "sql.y" + case 557: /* column_reference ::= column_name */ { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy557, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy557)); } -#line 8558 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 557: /* column_reference ::= table_name NK_DOT column_name */ -#line 1182 "sql.y" + case 558: /* column_reference ::= table_name NK_DOT column_name */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy557, createColumnNode(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy557)); } -#line 8564 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 558: /* column_reference ::= NK_ALIAS */ -#line 1183 "sql.y" + case 559: /* column_reference ::= NK_ALIAS */ { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } -#line 8570 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 559: /* column_reference ::= table_name NK_DOT NK_ALIAS */ -#line 1184 "sql.y" + case 560: /* column_reference ::= table_name NK_DOT NK_ALIAS */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy0)); } -#line 8576 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 560: /* pseudo_column ::= ROWTS */ - case 561: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==561); - case 563: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==563); - case 564: /* pseudo_column ::= QEND */ yytestcase(yyruleno==564); - case 565: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==565); - case 566: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==566); - case 567: /* pseudo_column ::= WEND */ yytestcase(yyruleno==567); - case 568: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==568); - case 569: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==569); - case 570: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==570); - case 571: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==571); - case 572: /* pseudo_column ::= FLOW */ yytestcase(yyruleno==572); - case 573: /* pseudo_column ::= FHIGH */ yytestcase(yyruleno==573); - case 574: /* pseudo_column ::= FROWTS */ yytestcase(yyruleno==574); - case 591: /* literal_func ::= NOW */ yytestcase(yyruleno==591); - case 592: /* literal_func ::= TODAY */ yytestcase(yyruleno==592); -#line 1186 "sql.y" + case 561: /* pseudo_column ::= ROWTS */ + case 562: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==562); + case 564: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==564); + case 565: /* pseudo_column ::= QEND */ yytestcase(yyruleno==565); + case 566: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==566); + case 567: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==567); + case 568: /* pseudo_column ::= WEND */ yytestcase(yyruleno==568); + case 569: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==569); + case 570: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==570); + case 571: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==571); + case 572: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==572); + case 573: /* pseudo_column ::= FLOW */ yytestcase(yyruleno==573); + case 574: /* pseudo_column ::= FHIGH */ yytestcase(yyruleno==574); + case 575: /* pseudo_column ::= FROWTS */ yytestcase(yyruleno==575); + case 592: /* literal_func ::= NOW */ yytestcase(yyruleno==592); + case 593: /* literal_func ::= TODAY */ yytestcase(yyruleno==593); { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } -#line 8597 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 562: /* pseudo_column ::= table_name NK_DOT TBNAME */ -#line 1188 "sql.y" + case 563: /* pseudo_column ::= table_name NK_DOT TBNAME */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy557)))); } -#line 8603 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 575: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 576: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==576); - case 584: /* function_expression ::= substr_func NK_LP expression_list NK_RP */ yytestcase(yyruleno==584); -#line 1202 "sql.y" + case 576: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 577: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==577); + case 585: /* function_expression ::= substr_func NK_LP expression_list NK_RP */ yytestcase(yyruleno==585); { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy557, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy557, yymsp[-1].minor.yy946)); } -#line 8611 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; - case 577: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - case 578: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP */ yytestcase(yyruleno==578); -#line 1205 "sql.y" + case 578: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + case 579: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP */ yytestcase(yyruleno==579); { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), yymsp[-1].minor.yy424)); } -#line 8618 "sql.c" yymsp[-5].minor.yy974 = yylhsminor.yy974; break; - case 579: /* function_expression ::= POSITION NK_LP expr_or_subquery IN expr_or_subquery NK_RP */ -#line 1209 "sql.y" + case 580: /* function_expression ::= POSITION NK_LP expr_or_subquery IN expr_or_subquery NK_RP */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createPositionFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), releaseRawExprNode(pCxt, yymsp[-1].minor.yy974))); } -#line 8624 "sql.c" yymsp[-5].minor.yy974 = yylhsminor.yy974; break; - case 580: /* function_expression ::= TRIM NK_LP expr_or_subquery NK_RP */ -#line 1211 "sql.y" + case 581: /* function_expression ::= TRIM NK_LP expr_or_subquery NK_RP */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createTrimFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974), TRIM_TYPE_BOTH)); } -#line 8630 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; - case 581: /* function_expression ::= TRIM NK_LP trim_specification_type FROM expr_or_subquery NK_RP */ -#line 1213 "sql.y" + case 582: /* function_expression ::= TRIM NK_LP trim_specification_type FROM expr_or_subquery NK_RP */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createTrimFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974), yymsp[-3].minor.yy300)); } -#line 8636 "sql.c" yymsp[-5].minor.yy974 = yylhsminor.yy974; break; - case 582: /* function_expression ::= TRIM NK_LP expr_or_subquery FROM expr_or_subquery NK_RP */ -#line 1215 "sql.y" + case 583: /* function_expression ::= TRIM NK_LP expr_or_subquery FROM expr_or_subquery NK_RP */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createTrimFunctionNodeExt(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), releaseRawExprNode(pCxt, yymsp[-1].minor.yy974), TRIM_TYPE_BOTH)); } -#line 8642 "sql.c" yymsp[-5].minor.yy974 = yylhsminor.yy974; break; - case 583: /* function_expression ::= TRIM NK_LP trim_specification_type expr_or_subquery FROM expr_or_subquery NK_RP */ -#line 1217 "sql.y" + case 584: /* function_expression ::= TRIM NK_LP trim_specification_type expr_or_subquery FROM expr_or_subquery NK_RP */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-6].minor.yy0, &yymsp[0].minor.yy0, createTrimFunctionNodeExt(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), releaseRawExprNode(pCxt, yymsp[-1].minor.yy974), yymsp[-4].minor.yy300)); } -#line 8648 "sql.c" yymsp[-6].minor.yy974 = yylhsminor.yy974; break; - case 585: /* function_expression ::= substr_func NK_LP expr_or_subquery FROM expr_or_subquery NK_RP */ -#line 1221 "sql.y" + case 586: /* function_expression ::= substr_func NK_LP expr_or_subquery FROM expr_or_subquery NK_RP */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy557, &yymsp[0].minor.yy0, createSubstrFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), releaseRawExprNode(pCxt, yymsp[-1].minor.yy974))); } -#line 8654 "sql.c" yymsp[-5].minor.yy974 = yylhsminor.yy974; break; - case 586: /* function_expression ::= substr_func NK_LP expr_or_subquery FROM expr_or_subquery FOR expr_or_subquery NK_RP */ -#line 1223 "sql.y" + case 587: /* function_expression ::= substr_func NK_LP expr_or_subquery FROM expr_or_subquery FOR expr_or_subquery NK_RP */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-7].minor.yy557, &yymsp[0].minor.yy0, createSubstrFunctionNodeExt(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy974), releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), releaseRawExprNode(pCxt, yymsp[-1].minor.yy974))); } -#line 8660 "sql.c" yymsp[-7].minor.yy974 = yylhsminor.yy974; break; - case 587: /* function_expression ::= REPLACE NK_LP expression_list NK_RP */ - case 594: /* rand_func ::= RAND NK_LP expression_list NK_RP */ yytestcase(yyruleno==594); -#line 1224 "sql.y" + case 588: /* function_expression ::= REPLACE NK_LP expression_list NK_RP */ + case 595: /* rand_func ::= RAND NK_LP expression_list NK_RP */ yytestcase(yyruleno==595); { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy946)); } -#line 8667 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; - case 590: /* literal_func ::= noarg_func NK_LP NK_RP */ -#line 1228 "sql.y" + case 591: /* literal_func ::= noarg_func NK_LP NK_RP */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy557, NULL)); } -#line 8673 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 593: /* rand_func ::= RAND NK_LP NK_RP */ -#line 1232 "sql.y" + case 594: /* rand_func ::= RAND NK_LP NK_RP */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy0, NULL)); } -#line 8679 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 597: /* trim_specification_type ::= BOTH */ -#line 1242 "sql.y" + case 598: /* trim_specification_type ::= BOTH */ { yymsp[0].minor.yy300 = TRIM_TYPE_BOTH; } -#line 8685 "sql.c" break; - case 598: /* trim_specification_type ::= TRAILING */ -#line 1243 "sql.y" + case 599: /* trim_specification_type ::= TRAILING */ { yymsp[0].minor.yy300 = TRIM_TYPE_TRAILING; } -#line 8690 "sql.c" break; - case 599: /* trim_specification_type ::= LEADING */ -#line 1244 "sql.y" + case 600: /* trim_specification_type ::= LEADING */ { yymsp[0].minor.yy300 = TRIM_TYPE_LEADING; } -#line 8695 "sql.c" break; - case 614: /* star_func_para_list ::= NK_STAR */ -#line 1268 "sql.y" + case 615: /* star_func_para_list ::= NK_STAR */ { yylhsminor.yy946 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } -#line 8700 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; - case 619: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 704: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==704); -#line 1277 "sql.y" + case 620: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 705: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==705); { yylhsminor.yy974 = createColumnNode(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy0); } -#line 8707 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 620: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -#line 1280 "sql.y" + case 621: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy946, yymsp[-1].minor.yy974)); } -#line 8713 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; - case 621: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -#line 1282 "sql.y" + case 622: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), yymsp[-2].minor.yy946, yymsp[-1].minor.yy974)); } -#line 8719 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; - case 624: /* when_then_expr ::= WHEN common_expression THEN common_expression */ -#line 1289 "sql.y" + case 625: /* when_then_expr ::= WHEN common_expression THEN common_expression */ { yymsp[-3].minor.yy974 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974)); } -#line 8725 "sql.c" break; - case 626: /* case_when_else_opt ::= ELSE common_expression */ -#line 1292 "sql.y" + case 627: /* case_when_else_opt ::= ELSE common_expression */ { yymsp[-1].minor.yy974 = releaseRawExprNode(pCxt, yymsp[0].minor.yy974); } -#line 8730 "sql.c" break; - case 627: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 632: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==632); -#line 1295 "sql.y" + case 628: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 633: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==633); { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy140, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } -#line 8740 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 628: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ -#line 1302 "sql.y" + case 629: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy974), releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } -#line 8750 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; - case 629: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ -#line 1308 "sql.y" + case 630: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy974), releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } -#line 8760 "sql.c" yymsp[-5].minor.yy974 = yylhsminor.yy974; break; - case 630: /* predicate ::= expr_or_subquery IS NULL */ -#line 1313 "sql.y" + case 631: /* predicate ::= expr_or_subquery IS NULL */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), NULL)); } -#line 8769 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 631: /* predicate ::= expr_or_subquery IS NOT NULL */ -#line 1317 "sql.y" + case 632: /* predicate ::= expr_or_subquery IS NOT NULL */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), NULL)); } -#line 8778 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; - case 633: /* compare_op ::= NK_LT */ -#line 1329 "sql.y" + case 634: /* compare_op ::= NK_LT */ { yymsp[0].minor.yy140 = OP_TYPE_LOWER_THAN; } -#line 8784 "sql.c" break; - case 634: /* compare_op ::= NK_GT */ -#line 1330 "sql.y" + case 635: /* compare_op ::= NK_GT */ { yymsp[0].minor.yy140 = OP_TYPE_GREATER_THAN; } -#line 8789 "sql.c" break; - case 635: /* compare_op ::= NK_LE */ -#line 1331 "sql.y" + case 636: /* compare_op ::= NK_LE */ { yymsp[0].minor.yy140 = OP_TYPE_LOWER_EQUAL; } -#line 8794 "sql.c" break; - case 636: /* compare_op ::= NK_GE */ -#line 1332 "sql.y" + case 637: /* compare_op ::= NK_GE */ { yymsp[0].minor.yy140 = OP_TYPE_GREATER_EQUAL; } -#line 8799 "sql.c" break; - case 637: /* compare_op ::= NK_NE */ -#line 1333 "sql.y" + case 638: /* compare_op ::= NK_NE */ { yymsp[0].minor.yy140 = OP_TYPE_NOT_EQUAL; } -#line 8804 "sql.c" break; - case 638: /* compare_op ::= NK_EQ */ -#line 1334 "sql.y" + case 639: /* compare_op ::= NK_EQ */ { yymsp[0].minor.yy140 = OP_TYPE_EQUAL; } -#line 8809 "sql.c" break; - case 639: /* compare_op ::= LIKE */ -#line 1335 "sql.y" + case 640: /* compare_op ::= LIKE */ { yymsp[0].minor.yy140 = OP_TYPE_LIKE; } -#line 8814 "sql.c" break; - case 640: /* compare_op ::= NOT LIKE */ -#line 1336 "sql.y" + case 641: /* compare_op ::= NOT LIKE */ { yymsp[-1].minor.yy140 = OP_TYPE_NOT_LIKE; } -#line 8819 "sql.c" break; - case 641: /* compare_op ::= MATCH */ -#line 1337 "sql.y" + case 642: /* compare_op ::= MATCH */ { yymsp[0].minor.yy140 = OP_TYPE_MATCH; } -#line 8824 "sql.c" break; - case 642: /* compare_op ::= NMATCH */ -#line 1338 "sql.y" + case 643: /* compare_op ::= NMATCH */ { yymsp[0].minor.yy140 = OP_TYPE_NMATCH; } -#line 8829 "sql.c" break; - case 643: /* compare_op ::= CONTAINS */ -#line 1339 "sql.y" + case 644: /* compare_op ::= CONTAINS */ { yymsp[0].minor.yy140 = OP_TYPE_JSON_CONTAINS; } -#line 8834 "sql.c" break; - case 644: /* in_op ::= IN */ -#line 1343 "sql.y" + case 645: /* in_op ::= IN */ { yymsp[0].minor.yy140 = OP_TYPE_IN; } -#line 8839 "sql.c" break; - case 645: /* in_op ::= NOT IN */ -#line 1344 "sql.y" + case 646: /* in_op ::= NOT IN */ { yymsp[-1].minor.yy140 = OP_TYPE_NOT_IN; } -#line 8844 "sql.c" break; - case 646: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -#line 1346 "sql.y" + case 647: /* in_predicate_value ::= NK_LP literal_list NK_RP */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy946)); } -#line 8849 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 648: /* boolean_value_expression ::= NOT boolean_primary */ -#line 1350 "sql.y" + case 649: /* boolean_value_expression ::= NOT boolean_primary */ { SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy974), NULL)); } -#line 8858 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 649: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ -#line 1355 "sql.y" + case 650: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } -#line 8868 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 650: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ -#line 1361 "sql.y" + case 651: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } -#line 8878 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 658: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -#line 1379 "sql.y" + case 659: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ { yylhsminor.yy974 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, JOIN_STYPE_NONE, yymsp[-2].minor.yy974, yymsp[0].minor.yy974, NULL); } -#line 8884 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 661: /* table_primary ::= table_name alias_opt */ -#line 1385 "sql.y" + case 662: /* table_primary ::= table_name alias_opt */ { yylhsminor.yy974 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy557, &yymsp[0].minor.yy557); } -#line 8890 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 662: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -#line 1386 "sql.y" + case 663: /* table_primary ::= db_name NK_DOT table_name alias_opt */ { yylhsminor.yy974 = createRealTableNode(pCxt, &yymsp[-3].minor.yy557, &yymsp[-1].minor.yy557, &yymsp[0].minor.yy557); } -#line 8896 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; - case 663: /* table_primary ::= subquery alias_opt */ -#line 1387 "sql.y" + case 664: /* table_primary ::= subquery alias_opt */ { yylhsminor.yy974 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974), &yymsp[0].minor.yy557); } -#line 8902 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 665: /* alias_opt ::= */ -#line 1392 "sql.y" + case 666: /* alias_opt ::= */ { yymsp[1].minor.yy557 = nil_token; } -#line 8908 "sql.c" break; - case 667: /* alias_opt ::= AS table_alias */ -#line 1394 "sql.y" + case 668: /* alias_opt ::= AS table_alias */ { yymsp[-1].minor.yy557 = yymsp[0].minor.yy557; } -#line 8913 "sql.c" break; - case 668: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 669: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==669); -#line 1396 "sql.y" + case 669: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 670: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==670); { yymsp[-2].minor.yy974 = yymsp[-1].minor.yy974; } -#line 8919 "sql.c" break; - case 670: /* joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt */ -#line 1402 "sql.y" + case 671: /* joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt */ { yylhsminor.yy974 = createJoinTableNode(pCxt, yymsp[-6].minor.yy792, yymsp[-5].minor.yy744, yymsp[-7].minor.yy974, yymsp[-3].minor.yy974, yymsp[-2].minor.yy974); yylhsminor.yy974 = addWindowOffsetClause(pCxt, yylhsminor.yy974, yymsp[-1].minor.yy974); yylhsminor.yy974 = addJLimitClause(pCxt, yylhsminor.yy974, yymsp[0].minor.yy974); } -#line 8928 "sql.c" yymsp[-7].minor.yy974 = yylhsminor.yy974; break; - case 671: /* join_type ::= */ -#line 1410 "sql.y" + case 672: /* join_type ::= */ { yymsp[1].minor.yy792 = JOIN_TYPE_INNER; } -#line 8934 "sql.c" break; - case 672: /* join_type ::= INNER */ -#line 1411 "sql.y" + case 673: /* join_type ::= INNER */ { yymsp[0].minor.yy792 = JOIN_TYPE_INNER; } -#line 8939 "sql.c" break; - case 673: /* join_type ::= LEFT */ -#line 1412 "sql.y" + case 674: /* join_type ::= LEFT */ { yymsp[0].minor.yy792 = JOIN_TYPE_LEFT; } -#line 8944 "sql.c" break; - case 674: /* join_type ::= RIGHT */ -#line 1413 "sql.y" + case 675: /* join_type ::= RIGHT */ { yymsp[0].minor.yy792 = JOIN_TYPE_RIGHT; } -#line 8949 "sql.c" break; - case 675: /* join_type ::= FULL */ -#line 1414 "sql.y" + case 676: /* join_type ::= FULL */ { yymsp[0].minor.yy792 = JOIN_TYPE_FULL; } -#line 8954 "sql.c" break; - case 676: /* join_subtype ::= */ -#line 1418 "sql.y" + case 677: /* join_subtype ::= */ { yymsp[1].minor.yy744 = JOIN_STYPE_NONE; } -#line 8959 "sql.c" break; - case 677: /* join_subtype ::= OUTER */ -#line 1419 "sql.y" + case 678: /* join_subtype ::= OUTER */ { yymsp[0].minor.yy744 = JOIN_STYPE_OUTER; } -#line 8964 "sql.c" break; - case 678: /* join_subtype ::= SEMI */ -#line 1420 "sql.y" + case 679: /* join_subtype ::= SEMI */ { yymsp[0].minor.yy744 = JOIN_STYPE_SEMI; } -#line 8969 "sql.c" break; - case 679: /* join_subtype ::= ANTI */ -#line 1421 "sql.y" + case 680: /* join_subtype ::= ANTI */ { yymsp[0].minor.yy744 = JOIN_STYPE_ANTI; } -#line 8974 "sql.c" break; - case 680: /* join_subtype ::= ASOF */ -#line 1422 "sql.y" + case 681: /* join_subtype ::= ASOF */ { yymsp[0].minor.yy744 = JOIN_STYPE_ASOF; } -#line 8979 "sql.c" break; - case 681: /* join_subtype ::= WINDOW */ -#line 1423 "sql.y" + case 682: /* join_subtype ::= WINDOW */ { yymsp[0].minor.yy744 = JOIN_STYPE_WIN; } -#line 8984 "sql.c" break; - case 685: /* window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP */ -#line 1430 "sql.y" + case 686: /* window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP */ { yymsp[-5].minor.yy974 = createWindowOffsetNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), releaseRawExprNode(pCxt, yymsp[-1].minor.yy974)); } -#line 8989 "sql.c" break; - case 686: /* window_offset_literal ::= NK_VARIABLE */ -#line 1432 "sql.y" + case 687: /* window_offset_literal ::= NK_VARIABLE */ { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createTimeOffsetValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 8994 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 687: /* window_offset_literal ::= NK_MINUS NK_VARIABLE */ -#line 1433 "sql.y" + case 688: /* window_offset_literal ::= NK_MINUS NK_VARIABLE */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy974 = createRawExprNode(pCxt, &t, createTimeOffsetValueNode(pCxt, &t)); } -#line 9004 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 689: /* jlimit_clause_opt ::= JLIMIT NK_INTEGER */ - case 762: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ yytestcase(yyruleno==762); - case 766: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==766); -#line 1440 "sql.y" + case 690: /* jlimit_clause_opt ::= JLIMIT NK_INTEGER */ + case 763: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ yytestcase(yyruleno==763); + case 767: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==767); { yymsp[-1].minor.yy974 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 9012 "sql.c" break; - case 690: /* 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 */ -#line 1446 "sql.y" + case 691: /* 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.yy974 = createSelectStmt(pCxt, yymsp[-11].minor.yy569, yymsp[-9].minor.yy946, yymsp[-8].minor.yy974, yymsp[-12].minor.yy946); yymsp[-13].minor.yy974 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy974, yymsp[-10].minor.yy569); @@ -9025,243 +7651,156 @@ yymsp[0].minor.yy974); } yymsp[-13].minor.yy974 = addEveryClause(pCxt, yymsp[-13].minor.yy974, yymsp[-4].minor.yy974); yymsp[-13].minor.yy974 = addFillClause(pCxt, yymsp[-13].minor.yy974, yymsp[-3].minor.yy974); } -#line 9028 "sql.c" break; - case 691: /* hint_list ::= */ -#line 1461 "sql.y" + case 692: /* hint_list ::= */ { yymsp[1].minor.yy946 = createHintNodeList(pCxt, NULL); } -#line 9033 "sql.c" break; - case 692: /* hint_list ::= NK_HINT */ -#line 1462 "sql.y" + case 693: /* hint_list ::= NK_HINT */ { yylhsminor.yy946 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } -#line 9038 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; - case 697: /* set_quantifier_opt ::= ALL */ -#line 1473 "sql.y" + case 698: /* set_quantifier_opt ::= ALL */ { yymsp[0].minor.yy569 = false; } -#line 9044 "sql.c" break; - case 700: /* select_item ::= NK_STAR */ -#line 1480 "sql.y" + case 701: /* select_item ::= NK_STAR */ { yylhsminor.yy974 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } -#line 9049 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; - case 702: /* select_item ::= common_expression column_alias */ - case 712: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==712); -#line 1482 "sql.y" + case 703: /* select_item ::= common_expression column_alias */ + case 713: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==713); { yylhsminor.yy974 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974), &yymsp[0].minor.yy557); } -#line 9056 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; - case 703: /* select_item ::= common_expression AS column_alias */ - case 713: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==713); -#line 1483 "sql.y" + case 704: /* select_item ::= common_expression AS column_alias */ + case 714: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==714); { yylhsminor.yy974 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), &yymsp[0].minor.yy557); } -#line 9063 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 708: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 740: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==740); - case 760: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==760); -#line 1492 "sql.y" + case 709: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 741: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==741); + case 761: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==761); { yymsp[-2].minor.yy946 = yymsp[0].minor.yy946; } -#line 9071 "sql.c" break; - case 715: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ -#line 1505 "sql.y" + case 716: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ { yymsp[-5].minor.yy974 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), releaseRawExprNode(pCxt, yymsp[-1].minor.yy974)); } -#line 9076 "sql.c" break; - case 716: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -#line 1506 "sql.y" + case 717: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ { yymsp[-3].minor.yy974 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974)); } -#line 9081 "sql.c" break; - case 717: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -#line 1508 "sql.y" + case 718: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ { yymsp[-5].minor.yy974 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), NULL, yymsp[-1].minor.yy974, yymsp[0].minor.yy974); } -#line 9086 "sql.c" break; - case 718: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -#line 1512 "sql.y" + case 719: /* 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.yy974 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy974), releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), yymsp[-1].minor.yy974, yymsp[0].minor.yy974); } -#line 9091 "sql.c" break; - case 719: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ -#line 1514 "sql.y" + case 720: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ { yymsp[-6].minor.yy974 = createEventWindowNode(pCxt, yymsp[-3].minor.yy974, yymsp[0].minor.yy974); } -#line 9096 "sql.c" break; - case 720: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ -#line 1516 "sql.y" + case 721: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy974 = createCountWindowNode(pCxt, &yymsp[-1].minor.yy0, &yymsp[-1].minor.yy0); } -#line 9101 "sql.c" break; - case 721: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -#line 1518 "sql.y" + case 722: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ { yymsp[-5].minor.yy974 = createCountWindowNode(pCxt, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0); } -#line 9106 "sql.c" break; - case 722: /* twindow_clause_opt ::= ANOMALY_WINDOW NK_LP expr_or_subquery NK_RP */ -#line 1520 "sql.y" + case 723: /* twindow_clause_opt ::= ANOMALY_WINDOW NK_LP expr_or_subquery NK_RP */ { yymsp[-3].minor.yy974 = createAnomalyWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974), NULL); } -#line 9111 "sql.c" break; - case 723: /* twindow_clause_opt ::= ANOMALY_WINDOW NK_LP expr_or_subquery NK_COMMA NK_STRING NK_RP */ -#line 1522 "sql.y" + case 724: /* twindow_clause_opt ::= ANOMALY_WINDOW NK_LP expr_or_subquery NK_COMMA NK_STRING NK_RP */ { yymsp[-5].minor.yy974 = createAnomalyWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), &yymsp[-1].minor.yy0); } -#line 9116 "sql.c" break; - case 730: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -#line 1532 "sql.y" + case 731: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ { yymsp[-3].minor.yy974 = createFillNode(pCxt, yymsp[-1].minor.yy102, NULL); } -#line 9121 "sql.c" break; - case 731: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ -#line 1533 "sql.y" + case 732: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ { yymsp[-5].minor.yy974 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy946)); } -#line 9126 "sql.c" break; - case 732: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ -#line 1534 "sql.y" + case 733: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ { yymsp[-5].minor.yy974 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy946)); } -#line 9131 "sql.c" break; - case 733: /* fill_mode ::= NONE */ -#line 1538 "sql.y" + case 734: /* fill_mode ::= NONE */ { yymsp[0].minor.yy102 = FILL_MODE_NONE; } -#line 9136 "sql.c" break; - case 734: /* fill_mode ::= PREV */ -#line 1539 "sql.y" + case 735: /* fill_mode ::= PREV */ { yymsp[0].minor.yy102 = FILL_MODE_PREV; } -#line 9141 "sql.c" break; - case 735: /* fill_mode ::= NULL */ -#line 1540 "sql.y" + case 736: /* fill_mode ::= NULL */ { yymsp[0].minor.yy102 = FILL_MODE_NULL; } -#line 9146 "sql.c" break; - case 736: /* fill_mode ::= NULL_F */ -#line 1541 "sql.y" + case 737: /* fill_mode ::= NULL_F */ { yymsp[0].minor.yy102 = FILL_MODE_NULL_F; } -#line 9151 "sql.c" break; - case 737: /* fill_mode ::= LINEAR */ -#line 1542 "sql.y" + case 738: /* fill_mode ::= LINEAR */ { yymsp[0].minor.yy102 = FILL_MODE_LINEAR; } -#line 9156 "sql.c" break; - case 738: /* fill_mode ::= NEXT */ -#line 1543 "sql.y" + case 739: /* fill_mode ::= NEXT */ { yymsp[0].minor.yy102 = FILL_MODE_NEXT; } -#line 9161 "sql.c" break; - case 741: /* group_by_list ::= expr_or_subquery */ -#line 1552 "sql.y" + case 742: /* group_by_list ::= expr_or_subquery */ { yylhsminor.yy946 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } -#line 9166 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; - case 742: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -#line 1553 "sql.y" + case 743: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ { yylhsminor.yy946 = addNodeToList(pCxt, yymsp[-2].minor.yy946, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } -#line 9172 "sql.c" yymsp[-2].minor.yy946 = yylhsminor.yy946; break; - case 746: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -#line 1560 "sql.y" + case 747: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ { yymsp[-5].minor.yy974 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), releaseRawExprNode(pCxt, yymsp[-1].minor.yy974)); } -#line 9178 "sql.c" break; - case 747: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ -#line 1562 "sql.y" + case 748: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ { yymsp[-3].minor.yy974 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974)); } -#line 9183 "sql.c" break; - case 750: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ -#line 1569 "sql.y" + case 751: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ { yylhsminor.yy974 = addOrderByClause(pCxt, yymsp[-3].minor.yy974, yymsp[-2].minor.yy946); yylhsminor.yy974 = addSlimitClause(pCxt, yylhsminor.yy974, yymsp[-1].minor.yy974); yylhsminor.yy974 = addLimitClause(pCxt, yylhsminor.yy974, yymsp[0].minor.yy974); } -#line 9192 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; - case 753: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -#line 1579 "sql.y" + case 754: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ { yylhsminor.yy974 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy974, yymsp[0].minor.yy974); } -#line 9198 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; - case 754: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -#line 1581 "sql.y" + case 755: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ { yylhsminor.yy974 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy974, yymsp[0].minor.yy974); } -#line 9204 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 763: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 767: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==767); -#line 1596 "sql.y" + case 764: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 768: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==768); { yymsp[-3].minor.yy974 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } -#line 9211 "sql.c" break; - case 764: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 768: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==768); -#line 1597 "sql.y" + case 765: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 769: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==769); { yymsp[-3].minor.yy974 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } -#line 9217 "sql.c" break; - case 769: /* subquery ::= NK_LP query_expression NK_RP */ -#line 1605 "sql.y" + case 770: /* subquery ::= NK_LP query_expression NK_RP */ { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy974); } -#line 9222 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 774: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -#line 1619 "sql.y" + case 775: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ { yylhsminor.yy974 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), yymsp[-1].minor.yy410, yymsp[0].minor.yy307); } -#line 9228 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 775: /* ordering_specification_opt ::= */ -#line 1623 "sql.y" + case 776: /* ordering_specification_opt ::= */ { yymsp[1].minor.yy410 = ORDER_ASC; } -#line 9234 "sql.c" break; - case 776: /* ordering_specification_opt ::= ASC */ -#line 1624 "sql.y" + case 777: /* ordering_specification_opt ::= ASC */ { yymsp[0].minor.yy410 = ORDER_ASC; } -#line 9239 "sql.c" break; - case 777: /* ordering_specification_opt ::= DESC */ -#line 1625 "sql.y" + case 778: /* ordering_specification_opt ::= DESC */ { yymsp[0].minor.yy410 = ORDER_DESC; } -#line 9244 "sql.c" break; - case 778: /* null_ordering_opt ::= */ -#line 1629 "sql.y" + case 779: /* null_ordering_opt ::= */ { yymsp[1].minor.yy307 = NULL_ORDER_DEFAULT; } -#line 9249 "sql.c" break; - case 779: /* null_ordering_opt ::= NULLS FIRST */ -#line 1630 "sql.y" + case 780: /* null_ordering_opt ::= NULLS FIRST */ { yymsp[-1].minor.yy307 = NULL_ORDER_FIRST; } -#line 9254 "sql.c" break; - case 780: /* null_ordering_opt ::= NULLS LAST */ -#line 1631 "sql.y" + case 781: /* null_ordering_opt ::= NULLS LAST */ { yymsp[-1].minor.yy307 = NULL_ORDER_LAST; } -#line 9259 "sql.c" break; - case 783: /* column_options ::= column_options NK_ID NK_STRING */ -#line 1639 "sql.y" + case 784: /* column_options ::= column_options NK_ID NK_STRING */ { yylhsminor.yy974 = setColumnOptions(pCxt, yymsp[-2].minor.yy974, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 9264 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; default: @@ -9324,7 +7863,6 @@ static void yy_syntax_error( ParseCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ -#line 29 "sql.y" if (TSDB_CODE_SUCCESS == pCxt->errCode) { if(TOKEN.z) { @@ -9335,7 +7873,6 @@ static void yy_syntax_error( } else if (TSDB_CODE_PAR_DB_NOT_SPECIFIED == pCxt->errCode && TK_NK_FLOAT == TOKEN.type) { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z); } -#line 9338 "sql.c" /************ End %syntax_error code ******************************************/ ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ ParseCTX_STORE diff --git a/source/libs/planner/inc/planInt.h b/source/libs/planner/inc/planInt.h index beb277493cb..59e771454c6 100644 --- a/source/libs/planner/inc/planInt.h +++ b/source/libs/planner/inc/planInt.h @@ -24,6 +24,18 @@ extern "C" { #include "tsimplehash.h" #include "taoserror.h" + +typedef struct SPhysiPlanContext { + SPlanContext* pPlanCxt; + int32_t errCode; + int16_t nextDataBlockId; + SArray* pLocationHelper; + SArray* pProjIdxLocHelper; + bool hasScan; + bool hasSysScan; +} SPhysiPlanContext; + + #define planFatal(param, ...) qFatal("PLAN: " param, ##__VA_ARGS__) #define planError(param, ...) qError("PLAN: " param, ##__VA_ARGS__) #define planWarn(param, ...) qWarn("PLAN: " param, ##__VA_ARGS__) diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index f05966802be..d80cfc17614 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -30,15 +30,6 @@ typedef struct SSlotIndex { SArray* pSlotIdsInfo; // duplicate name slot } SSlotIndex; -typedef struct SPhysiPlanContext { - SPlanContext* pPlanCxt; - int32_t errCode; - int16_t nextDataBlockId; - SArray* pLocationHelper; - SArray* pProjIdxLocHelper; - bool hasScan; - bool hasSysScan; -} SPhysiPlanContext; static int32_t getSlotKey(SNode* pNode, const char* pStmtName, char** ppKey, int32_t *pLen, uint16_t extraBufLen) { int32_t code = 0; diff --git a/source/libs/qworker/src/qwMsg.c b/source/libs/qworker/src/qwMsg.c index 69014d5b1c5..20b81bfc14d 100644 --- a/source/libs/qworker/src/qwMsg.c +++ b/source/libs/qworker/src/qwMsg.c @@ -429,7 +429,7 @@ int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg, bool chkGran tFreeSSubQueryMsg(&msg); - return TSDB_CODE_SUCCESS; + return code; } int32_t qWorkerAbortPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg) { diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index ddc4812b559..9b96c1e5190 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -751,7 +751,7 @@ int32_t qwPreprocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) { qwReleaseTaskCtx(mgmt, ctx); } - return TSDB_CODE_SUCCESS; + return code; } int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, char *sql) { diff --git a/source/libs/qworker/test/CMakeLists.txt b/source/libs/qworker/test/CMakeLists.txt index 22870ea94dc..e87456cf72f 100644 --- a/source/libs/qworker/test/CMakeLists.txt +++ b/source/libs/qworker/test/CMakeLists.txt @@ -1,5 +1,6 @@ MESSAGE(STATUS "build qworker unit test") + IF(NOT TD_DARWIN) # GoogleTest requires at least C++11 SET(CMAKE_CXX_STANDARD 11) diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 6f6362a8f79..9e75abcfe89 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -2085,7 +2085,8 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp (void)memcpy(varDataVal(output), convBuf, len); varDataSetLen(output, len); } else { - NUM_TO_STRING(inputType, input, bufSize, buf); + int32_t outputSize = (outputLen - VARSTR_HEADER_SIZE) < bufSize ? (outputLen - VARSTR_HEADER_SIZE + 1): bufSize; + NUM_TO_STRING(inputType, input, outputSize, buf); int32_t len = (int32_t)strlen(buf); len = (outputLen - VARSTR_HEADER_SIZE) > len ? len : (outputLen - VARSTR_HEADER_SIZE); (void)memcpy(varDataVal(output), buf, len); diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index 54794b9044f..8db0562c631 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -1031,23 +1031,23 @@ int8_t gConvertTypes[TSDB_DATA_TYPE_MAX][TSDB_DATA_TYPE_MAX] = { /*GEOM*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0}; int8_t gDisplyTypes[TSDB_DATA_TYPE_MAX][TSDB_DATA_TYPE_MAX] = { - /*NULL BOOL TINY SMAL INT BIGI FLOA DOUB VARC TIME NCHA UTINY USMA UINT UBIG JSON VARB DECI BLOB MEDB GEOM*/ - /*NULL*/ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, -1, -1, 8, - /*BOOL*/ 0, 1, 2, 3, 4, 5, 6, 7, 8, 5, 10, 11, 12, 13, 14, 8, -1, -1, -1, -1, 8, - /*TINY*/ 0, 0, 2, 3, 4, 5, 8, 8, 8, 5, 10, 3, 4, 5, 8, 8, -1, -1, -1, -1, 8, - /*SMAL*/ 0, 0, 0, 3, 4, 5, 8, 8, 8, 5, 10, 3, 4, 5, 8, 8, -1, -1, -1, -1, 8, - /*INT */ 0, 0, 0, 0, 4, 5, 8, 8, 8, 5, 10, 4, 4, 5, 8, 8, -1, -1, -1, -1, 8, - /*BIGI*/ 0, 0, 0, 0, 0, 5, 8, 8, 8, 5, 10, 5, 5, 5, 8, 8, -1, -1, -1, -1, 8, - /*FLOA*/ 0, 0, 0, 0, 0, 0, 6, 7, 8, 8, 10, 8, 8, 8, 8, 8, -1, -1, -1, -1, 8, - /*DOUB*/ 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 10, 8, 8, 8, 8, 8, -1, -1, -1, -1, 8, - /*VARC*/ 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 10, 8, 8, 8, 8, 8, -1, -1, -1, -1, 8, - /*TIME*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 5, 5, 5, 8, 8, -1, -1, -1, -1, 8, - /*NCHA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, -1, -1, -1, -1, 10, - /*UTINY*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 13, 14, 8, -1, -1, -1, -1, 8, - /*USMA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 14, 8, -1, -1, -1, -1, 8, - /*UINT*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 8, -1, -1, -1, -1, 8, - /*UBIG*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 8, -1, -1, -1, -1, 8, - /*JSON*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, -1, -1, -1, -1, 8, + /*NULL BOOL TINY SMAL INT BIGI FLOA DOUB VARC TIM NCHA UTIN USMA UINT UBIG JSON VARB DECI BLOB MEDB GEOM*/ + /*NULL*/ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, -1, -1, 20, + /*BOOL*/ 0, 1, 2, 3, 4, 5, 6, 7, 8, 5, 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, -1, + /*TINY*/ 0, 0, 2, 3, 4, 5, 8, 8, 8, 5, 10, 3, 4, 5, 8, -1, -1, -1, -1, -1, -1, + /*SMAL*/ 0, 0, 0, 3, 4, 5, 8, 8, 8, 5, 10, 3, 4, 5, 8, -1, -1, -1, -1, -1, -1, + /*INT */ 0, 0, 0, 0, 4, 5, 8, 8, 8, 5, 10, 4, 4, 5, 8, -1, -1, -1, -1, -1, -1, + /*BIGI*/ 0, 0, 0, 0, 0, 5, 8, 8, 8, 5, 10, 5, 5, 5, 8, -1, -1, -1, -1, -1, -1, + /*FLOA*/ 0, 0, 0, 0, 0, 0, 6, 7, 8, 8, 10, 8, 8, 8, 8, -1, -1, -1, -1, -1, -1, + /*DOUB*/ 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 10, 8, 8, 8, 8, -1, -1, -1, -1, -1, -1, + /*VARC*/ 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 10, 8, 8, 8, 8, -1, 16, -1, -1, -1, -1, + /*TIME*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 5, 5, 5, 8, -1, -1, -1, -1, -1, -1, + /*NCHA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, -1, -1, -1, -1, -1, -1, + /*UTINY*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 13, 14, -1, -1, -1, -1, -1, -1, + /*USMA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 14, -1, -1, -1, -1, -1, -1, + /*UINT*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, -1, -1, -1, -1, -1, -1, + /*UBIG*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, -1, -1, -1, -1, -1, -1, + /*JSON*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, -1, -1, -1, -1, -1, /*VARB*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, -1, -1, -1, -1, /*DECI*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, /*BLOB*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, diff --git a/source/libs/scheduler/inc/schInt.h b/source/libs/scheduler/inc/schInt.h index 8a156e8a06d..96b9d2da8d3 100644 --- a/source/libs/scheduler/inc/schInt.h +++ b/source/libs/scheduler/inc/schInt.h @@ -62,6 +62,7 @@ typedef enum { #define SCH_DEFAULT_MAX_RETRY_NUM 6 #define SCH_MIN_AYSNC_EXEC_NUM 3 #define SCH_DEFAULT_RETRY_TOTAL_ROUND 3 +#define SCH_DEFAULT_TASK_CAPACITY_NUM 1000 typedef struct SSchDebug { bool lockEnable; @@ -318,6 +319,8 @@ typedef struct SSchTaskCtx { extern SSchedulerMgmt schMgmt; +#define SCH_GET_TASK_CAPACITY(_n) ((_n) > SCH_DEFAULT_TASK_CAPACITY_NUM ? SCH_DEFAULT_TASK_CAPACITY_NUM : (_n)) + #define SCH_TASK_TIMEOUT(_task) \ ((taosGetTimestampUs() - *(int64_t *)taosArrayGet((_task)->profile.execTime, (_task)->execId)) > (_task)->timeoutUsec) @@ -330,8 +333,8 @@ extern SSchedulerMgmt schMgmt; #define SCH_TASK_EID(_task) ((_task) ? (_task)->execId : -1) #define SCH_IS_DATA_BIND_QRY_TASK(task) ((task)->plan->subplanType == SUBPLAN_TYPE_SCAN) -#define SCH_IS_DATA_BIND_TASK(task) \ - (((task)->plan->subplanType == SUBPLAN_TYPE_SCAN) || ((task)->plan->subplanType == SUBPLAN_TYPE_MODIFY)) +#define SCH_IS_DATA_BIND_PLAN(_plan) (((_plan)->subplanType == SUBPLAN_TYPE_SCAN) || ((_plan)->subplanType == SUBPLAN_TYPE_MODIFY)) +#define SCH_IS_DATA_BIND_TASK(task) SCH_IS_DATA_BIND_PLAN((task)->plan) #define SCH_IS_LEAF_TASK(_job, _task) (((_task)->level->level + 1) == (_job)->levelNum) #define SCH_IS_DATA_MERGE_TASK(task) (!SCH_IS_DATA_BIND_TASK(task)) #define SCH_IS_LOCAL_EXEC_TASK(_job, _task) \ @@ -641,6 +644,7 @@ void schDropTaskInHashList(SSchJob *pJob, SHashObj *list); int32_t schNotifyTaskInHashList(SSchJob *pJob, SHashObj *list, ETaskNotifyType type, SSchTask *pTask); int32_t schLaunchLevelTasks(SSchJob *pJob, SSchLevel *level); void schGetTaskFromList(SHashObj *pTaskList, uint64_t taskId, SSchTask **pTask); +int32_t schValidateSubplan(SSchJob *pJob, SSubplan* pSubplan, int32_t level, int32_t idx, int32_t taskNum); int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *pLevel); int32_t schSwitchTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask); void schDirectPostJobRes(SSchedulerReq *pReq, int32_t errCode); diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index 03145da9398..375a3161852 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -200,7 +200,12 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { SSubplan *child = (SSubplan *)nodesListGetNode(pPlan->pChildren, n); if (NULL == child) { SCH_JOB_ELOG("fail to get the %dth child subplan, childNum: %d", n, childNum); - SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + + if (QUERY_NODE_PHYSICAL_SUBPLAN != nodeType(child)) { + SCH_JOB_ELOG("invalid subplan type for the %dth child, level:%d, subplanNodeType:%d", n, i, nodeType(child)); + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } SSchTask **childTask = taosHashGet(planToTask, &child, POINTER_BYTES); @@ -242,6 +247,11 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); } + if (QUERY_NODE_PHYSICAL_SUBPLAN != nodeType(parent)) { + SCH_JOB_ELOG("invalid subplan type for the %dth parent, level:%d, subplanNodeType:%d", n, i, nodeType(parent)); + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + SSchTask **parentTask = taosHashGet(planToTask, &parent, POINTER_BYTES); if (NULL == parentTask || NULL == *parentTask) { SCH_TASK_ELOG("subplan parent relationship error, level:%d, taskIdx:%d, childIdx:%d", i, m, n); @@ -307,7 +317,7 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - pJob->dataSrcTasks = taosArrayInit(pDag->numOfSubplans, POINTER_BYTES); + pJob->dataSrcTasks = taosArrayInit(SCH_GET_TASK_CAPACITY(pDag->numOfSubplans), POINTER_BYTES); if (NULL == pJob->dataSrcTasks) { SCH_ERR_RET(terrno); } @@ -319,12 +329,12 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { } SHashObj *planToTask = taosHashInit( - pDag->numOfSubplans, + SCH_GET_TASK_CAPACITY(pDag->numOfSubplans), taosGetDefaultHashFunction(POINTER_BYTES == sizeof(int64_t) ? TSDB_DATA_TYPE_BIGINT : TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); if (NULL == planToTask) { SCH_JOB_ELOG("taosHashInit %d failed", SCHEDULE_DEFAULT_MAX_TASK_NUM); - SCH_ERR_RET(terrno); + SCH_ERR_JRET(terrno); } pJob->levels = taosArrayInit(levelNum, sizeof(SSchLevel)); @@ -339,6 +349,7 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { SSchLevel level = {0}; SNodeListNode *plans = NULL; int32_t taskNum = 0; + int32_t totalTaskNum = 0; SSchLevel *pLevel = NULL; level.status = JOB_TASK_STATUS_INIT; @@ -352,7 +363,7 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { pLevel = taosArrayGet(pJob->levels, i); if (NULL == pLevel) { SCH_JOB_ELOG("fail to get the %dth level, levelNum: %d", i, levelNum); - SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); + SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); } pLevel->level = i; @@ -363,12 +374,23 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); } + if (QUERY_NODE_NODE_LIST != nodeType(plans)) { + SCH_JOB_ELOG("invalid level plan, level:%d, planNodeType:%d", i, nodeType(plans)); + SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); + } + taskNum = (int32_t)LIST_LENGTH(plans->pNodeList); if (taskNum <= 0) { SCH_JOB_ELOG("invalid level plan number:%d, level:%d", taskNum, i); SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); } + totalTaskNum += taskNum; + if (totalTaskNum > pDag->numOfSubplans) { + SCH_JOB_ELOG("current totalTaskNum %d is bigger than numOfSubplans %d, level:%d", totalTaskNum, pDag->numOfSubplans, i); + SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); + } + pLevel->taskNum = taskNum; pLevel->subTasks = taosArrayInit(taskNum, sizeof(SSchTask)); @@ -379,11 +401,9 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { for (int32_t n = 0; n < taskNum; ++n) { SSubplan *plan = (SSubplan *)nodesListGetNode(plans->pNodeList, n); - if (NULL == plan) { - SCH_JOB_ELOG("fail to get the %dth subplan, taskNum: %d", n, taskNum); - SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); - } + SCH_ERR_JRET(schValidateSubplan(pJob, plan, pLevel->level, n, taskNum)); + SCH_SET_JOB_TYPE(pJob, plan->subplanType); SSchTask task = {0}; @@ -397,14 +417,16 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { SCH_ERR_JRET(schAppendJobDataSrc(pJob, pTask)); - if (0 != taosHashPut(planToTask, &plan, POINTER_BYTES, &pTask, POINTER_BYTES)) { - SCH_TASK_ELOG("taosHashPut to planToTaks failed, taskIdx:%d", n); - SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + code = taosHashPut(planToTask, &plan, POINTER_BYTES, &pTask, POINTER_BYTES); + if (0 != code) { + SCH_TASK_ELOG("taosHashPut to planToTaks failed, taskIdx:%d, error:%s", n, tstrerror(code)); + SCH_ERR_JRET(code); } - if (0 != taosHashPut(pJob->taskList, &pTask->taskId, sizeof(pTask->taskId), &pTask, POINTER_BYTES)) { - SCH_TASK_ELOG("taosHashPut to taskList failed, taskIdx:%d", n); - SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + code = taosHashPut(pJob->taskList, &pTask->taskId, sizeof(pTask->taskId), &pTask, POINTER_BYTES); + if (0 != code) { + SCH_TASK_ELOG("taosHashPut to taskList failed, taskIdx:%d, error:%s", n, tstrerror(code)); + SCH_ERR_JRET(code); } ++pJob->taskNum; @@ -413,6 +435,11 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { SCH_JOB_DLOG("level %d initialized, taskNum:%d", i, taskNum); } + if (totalTaskNum != pDag->numOfSubplans) { + SCH_JOB_ELOG("totalTaskNum %d mis-match with numOfSubplans %d", totalTaskNum, pDag->numOfSubplans); + SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); + } + SCH_ERR_JRET(schBuildTaskRalation(pJob, planToTask)); _return: @@ -781,9 +808,11 @@ void schFreeJobImpl(void *job) { } taosMemoryFree(pJob); - int32_t jobNum = atomic_sub_fetch_32(&schMgmt.jobNum, 1); - if (jobNum == 0) { - schCloseJobRef(); + if (refId > 0) { + int32_t jobNum = atomic_sub_fetch_32(&schMgmt.jobNum, 1); + if (jobNum == 0) { + schCloseJobRef(); + } } qDebug("QID:0x%" PRIx64 " sch job freed, refId:0x%" PRIx64 ", pointer:%p", queryId, refId, pJob); @@ -861,10 +890,10 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) { } } - pJob->taskList = taosHashInit(pReq->pDag->numOfSubplans, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, + pJob->taskList = taosHashInit(SCH_GET_TASK_CAPACITY(pReq->pDag->numOfSubplans), taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK); if (NULL == pJob->taskList) { - SCH_JOB_ELOG("taosHashInit %d taskList failed", pReq->pDag->numOfSubplans); + SCH_JOB_ELOG("taosHashInit %d taskList failed", SCH_GET_TASK_CAPACITY(pReq->pDag->numOfSubplans)); SCH_ERR_JRET(terrno); } @@ -904,7 +933,7 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) { if (NULL == pJob) { qDestroyQueryPlan(pReq->pDag); - } else if (pJob->refId < 0) { + } else if (pJob->refId <= 0) { schFreeJobImpl(pJob); } else { code = taosRemoveRef(schMgmt.jobRef, pJob->refId); diff --git a/source/libs/scheduler/src/schTask.c b/source/libs/scheduler/src/schTask.c index e6b68051f93..fe24633c122 100644 --- a/source/libs/scheduler/src/schTask.c +++ b/source/libs/scheduler/src/schTask.c @@ -831,7 +831,7 @@ int32_t schSetTaskCandidateAddrs(SSchJob *pJob, SSchTask *pTask) { if (SCH_IS_DATA_BIND_TASK(pTask)) { SCH_TASK_ELOG("no execNode specifed for data src task, numOfEps:%d", pTask->plan->execNode.epSet.numOfEps); - SCH_ERR_RET(TSDB_CODE_MND_INVALID_SCHEMA_VER); + SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); } SCH_ERR_RET(schSetAddrsFromNodeList(pJob, pTask)); diff --git a/source/libs/scheduler/src/schUtil.c b/source/libs/scheduler/src/schUtil.c index b68f665200f..4697de6f285 100644 --- a/source/libs/scheduler/src/schUtil.c +++ b/source/libs/scheduler/src/schUtil.c @@ -360,3 +360,50 @@ void schGetTaskFromList(SHashObj *pTaskList, uint64_t taskId, SSchTask **pTask) *pTask = *task; } + +int32_t schValidateSubplan(SSchJob *pJob, SSubplan* pSubplan, int32_t level, int32_t idx, int32_t taskNum) { + if (NULL == pSubplan) { + SCH_JOB_ELOG("fail to get the %dth subplan, taskNum: %d, level: %d", idx, taskNum, level); + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + + if (QUERY_NODE_PHYSICAL_SUBPLAN != nodeType(pSubplan)) { + SCH_JOB_ELOG("invalid subplan type, level:%d, subplanNodeType:%d", level, nodeType(pSubplan)); + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + + if (pSubplan->subplanType < SUBPLAN_TYPE_MERGE || pSubplan->subplanType > SUBPLAN_TYPE_COMPUTE) { + SCH_JOB_ELOG("invalid subplanType %d, level:%d, subplan idx:%d", pSubplan->subplanType, level, idx); + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + + if (pSubplan->level != level) { + SCH_JOB_ELOG("plan level %d mis-match with current level %d", pSubplan->level, level); + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + + if (SCH_IS_DATA_BIND_PLAN(pSubplan)) { + if (pSubplan->execNode.epSet.numOfEps <= 0) { + SCH_JOB_ELOG("no execNode specifed for data src plan %d, numOfEps:%d", pSubplan->subplanType, pSubplan->execNode.epSet.numOfEps); + SCH_ERR_RET(TSDB_CODE_SCH_DATA_SRC_EP_MISS); + } + if (pSubplan->execNode.epSet.inUse >= pSubplan->execNode.epSet.numOfEps) { + SCH_JOB_ELOG("invalid epset inUse %d for data src plan %d, numOfEps:%d", pSubplan->execNode.epSet.inUse, pSubplan->subplanType, pSubplan->execNode.epSet.numOfEps); + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + } + + if (NULL == pSubplan->pNode && pSubplan->subplanType != SUBPLAN_TYPE_MODIFY) { + SCH_JOB_ELOG("empty plan root node, level:%d, subplan idx:%d, subplanType:%d", level, idx, pSubplan->subplanType); + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + + if (NULL == pSubplan->pDataSink) { + SCH_JOB_ELOG("empty plan dataSink, level:%d, subplan idx:%d", level, idx); + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + + return TSDB_CODE_SUCCESS; +} + + diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 091de5c0482..db9ecd60250 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -224,3 +224,33 @@ void schedulerDestroy(void) { qWorkerDestroy(&schMgmt.queryMgmt); schMgmt.queryMgmt = NULL; } + +int32_t schedulerValidatePlan(SQueryPlan* pPlan) { + int32_t code = TSDB_CODE_SUCCESS; + SSchJob *pJob = taosMemoryCalloc(1, sizeof(SSchJob)); + if (NULL == pJob) { + qError("QID:0x%" PRIx64 " calloc %d failed", pPlan->queryId, (int32_t)sizeof(SSchJob)); + SCH_ERR_RET(terrno); + } + + pJob->taskList = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, + HASH_ENTRY_LOCK); + if (NULL == pJob->taskList) { + SCH_JOB_ELOG("taosHashInit %d taskList failed", 100); + SCH_ERR_JRET(terrno); + } + + SCH_ERR_JRET(schValidateAndBuildJob(pPlan, pJob)); + + if (SCH_IS_EXPLAIN_JOB(pJob)) { + SCH_ERR_JRET(qExecExplainBegin(pPlan, &pJob->explainCtx, 0)); + } + +_return: + + schFreeJobImpl(pJob); + + return code; +} + + diff --git a/source/libs/scheduler/test/schedulerTests.cpp b/source/libs/scheduler/test/schedulerTests.cpp index 44d32b9480e..6e13e37e88e 100644 --- a/source/libs/scheduler/test/schedulerTests.cpp +++ b/source/libs/scheduler/test/schedulerTests.cpp @@ -203,6 +203,10 @@ void schtBuildQueryDag(SQueryPlan *dag) { return; } scanPlan->msgType = TDMT_SCH_QUERY; + code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DISPATCH, (SNode**)&scanPlan->pDataSink); + if (NULL == scanPlan->pDataSink) { + return; + } mergePlan->id.queryId = qId; mergePlan->id.groupId = schtMergeTemplateId; @@ -223,6 +227,10 @@ void schtBuildQueryDag(SQueryPlan *dag) { return; } mergePlan->msgType = TDMT_SCH_QUERY; + code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DISPATCH, (SNode**)&mergePlan->pDataSink); + if (NULL == mergePlan->pDataSink) { + return; + } merge->pNodeList = NULL; code = nodesMakeList(&merge->pNodeList); @@ -235,6 +243,7 @@ void schtBuildQueryDag(SQueryPlan *dag) { return; } + (void)nodesListAppend(merge->pNodeList, (SNode *)mergePlan); (void)nodesListAppend(scan->pNodeList, (SNode *)scanPlan); @@ -250,7 +259,7 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) { int32_t scanPlanNum = 20; dag->queryId = qId; - dag->numOfSubplans = 2; + dag->numOfSubplans = scanPlanNum + 1; dag->pSubplans = NULL; int32_t code = nodesMakeList(&dag->pSubplans); if (NULL == dag->pSubplans) { @@ -289,6 +298,10 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) { if (NULL == mergePlan->pChildren) { return; } + code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DISPATCH, (SNode**)&mergePlan->pDataSink); + if (NULL == mergePlan->pDataSink) { + return; + } for (int32_t i = 0; i < scanPlanNum; ++i) { SSubplan *scanPlan = NULL; @@ -322,6 +335,10 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) { return; } scanPlan->msgType = TDMT_SCH_QUERY; + code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DISPATCH, (SNode**)&scanPlan->pDataSink); + if (NULL == scanPlan->pDataSink) { + return; + } (void)nodesListAppend(scanPlan->pParents, (SNode *)mergePlan); (void)nodesListAppend(mergePlan->pChildren, (SNode *)scanPlan); diff --git a/source/libs/stream/inc/streamInt.h b/source/libs/stream/inc/streamInt.h index 94c196d280f..93c8dc3b404 100644 --- a/source/libs/stream/inc/streamInt.h +++ b/source/libs/stream/inc/streamInt.h @@ -21,6 +21,7 @@ #include "streamBackendRocksdb.h" #include "trpc.h" #include "tstream.h" +#include "tref.h" #ifdef __cplusplus extern "C" { @@ -70,7 +71,7 @@ struct SActiveCheckpointInfo { SStreamTmrInfo chkptReadyMsgTmr; }; -int32_t streamCleanBeforeQuitTmr(SStreamTmrInfo* pInfo, SStreamTask* pTask); +void streamCleanBeforeQuitTmr(SStreamTmrInfo* pInfo, void* param); typedef struct { int8_t type; @@ -225,6 +226,8 @@ void destroyMetaHbInfo(SMetaHbInfo* pInfo); void streamMetaWaitForHbTmrQuit(SStreamMeta* pMeta); void streamMetaGetHbSendInfo(SMetaHbInfo* pInfo, int64_t* pStartTs, int32_t* pSendCount); int32_t streamMetaSendHbHelper(SStreamMeta* pMeta); +int32_t metaRefMgtAdd(int64_t vgId, int64_t* rid); +void metaRefMgtRemove(int64_t* pRefId); ECHECKPOINT_BACKUP_TYPE streamGetCheckpointBackupType(); diff --git a/source/libs/stream/src/streamCheckStatus.c b/source/libs/stream/src/streamCheckStatus.c index c1c54b3c0bf..64b19e4ed9e 100644 --- a/source/libs/stream/src/streamCheckStatus.c +++ b/source/libs/stream/src/streamCheckStatus.c @@ -299,13 +299,14 @@ void streamTaskStartMonitorCheckRsp(SStreamTask* pTask) { return; } - int32_t unusedRetRef = streamMetaAcquireOneTask(pTask); // add task ref here streamTaskInitTaskCheckInfo(pInfo, &pTask->outputInfo, taosGetTimestampMs()); - int32_t ref = atomic_add_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:%s start check-rsp monitor, ref:%d ", pTask->id.idStr, ref); - streamTmrStart(rspMonitorFn, CHECK_RSP_CHECK_INTERVAL, pTask, streamTimer, &pInfo->checkRspTmr, vgId, - "check-status-monitor"); + int64_t* pTaskRefId = NULL; + code = streamTaskAllocRefId(pTask, &pTaskRefId); + if (code == 0) { + streamTmrStart(rspMonitorFn, CHECK_RSP_CHECK_INTERVAL, pTaskRefId, streamTimer, &pInfo->checkRspTmr, vgId, + "check-status-monitor"); + } streamMutexUnlock(&pInfo->checkInfoLock); } @@ -721,21 +722,45 @@ int32_t addDownstreamFailedStatusResultAsync(SMsgCb* pMsgCb, int32_t vgId, int64 return streamTaskSchedTask(pMsgCb, vgId, streamId, taskId, STREAM_EXEC_T_ADD_FAILED_TASK); } +static void doCleanup(SStreamTask* pTask, SArray* pNotReadyList, SArray* pTimeoutList, void* param) { + streamMetaReleaseTask(pTask->pMeta, pTask); + + taosArrayDestroy(pNotReadyList); + taosArrayDestroy(pTimeoutList); + streamTaskFreeRefId(param); +} + // this function is executed in timer thread void rspMonitorFn(void* param, void* tmrId) { - SStreamTask* pTask = param; - SStreamMeta* pMeta = pTask->pMeta; - STaskCheckInfo* pInfo = &pTask->taskCheckInfo; - int32_t vgId = pTask->pMeta->vgId; - int64_t now = taosGetTimestampMs(); - int64_t timeoutDuration = now - pInfo->timeoutStartTs; - const char* id = pTask->id.idStr; int32_t numOfReady = 0; int32_t numOfFault = 0; int32_t numOfNotRsp = 0; int32_t numOfNotReady = 0; int32_t numOfTimeout = 0; - int32_t total = taosArrayGetSize(pInfo->pList); + int64_t taskRefId = *(int64_t*)param; + int64_t now = taosGetTimestampMs(); + SArray* pNotReadyList = NULL; + SArray* pTimeoutList = NULL; + SStreamMeta* pMeta = NULL; + STaskCheckInfo* pInfo = NULL; + int32_t vgId = -1; + int64_t timeoutDuration = 0; + const char* id = NULL; + int32_t total = 0; + + SStreamTask* pTask = taosAcquireRef(streamTaskRefPool, taskRefId); + if (pTask == NULL) { + stError("invalid task rid:%" PRId64 " failed to acquired stream-task at %s", taskRefId, __func__); + streamTaskFreeRefId(param); + return; + } + + pMeta = pTask->pMeta; + pInfo = &pTask->taskCheckInfo; + vgId = pTask->pMeta->vgId; + timeoutDuration = now - pInfo->timeoutStartTs; + id = pTask->id.idStr; + total = (int32_t) taosArrayGetSize(pInfo->pList); stDebug("s-task:%s start to do check-downstream-rsp check in tmr", id); @@ -744,12 +769,10 @@ void rspMonitorFn(void* param, void* tmrId) { streamMutexUnlock(&pTask->lock); if (state.state == TASK_STATUS__STOP) { - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:%s status:%s vgId:%d quit from monitor check-rsp tmr, ref:%d", id, state.name, vgId, ref); - + stDebug("s-task:%s status:%s vgId:%d quit from monitor check-rsp tmr", id, state.name, vgId); streamTaskCompleteCheckRsp(pInfo, true, id); - // not record the failed of the current task if try to close current vnode + // not record the failure of the current task if try to close current vnode // otherwise, the put of message operation may incur invalid read of message queue. if (!pMeta->closeFlag) { int32_t code = addDownstreamFailedStatusResultAsync(pTask->pMsgCb, vgId, pTask->id.streamId, pTask->id.taskId); @@ -758,33 +781,30 @@ void rspMonitorFn(void* param, void* tmrId) { } } - streamMetaReleaseTask(pMeta, pTask); + doCleanup(pTask, pNotReadyList, pTimeoutList, param); return; } if (state.state == TASK_STATUS__DROPPING || state.state == TASK_STATUS__READY) { - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:%s status:%s vgId:%d quit from monitor check-rsp tmr, ref:%d", id, state.name, vgId, ref); + stDebug("s-task:%s status:%s vgId:%d quit from monitor check-rsp tmr", id, state.name, vgId); streamTaskCompleteCheckRsp(pInfo, true, id); - streamMetaReleaseTask(pMeta, pTask); + doCleanup(pTask, pNotReadyList, pTimeoutList, param); return; } streamMutexLock(&pInfo->checkInfoLock); if (pInfo->notReadyTasks == 0) { - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:%s status:%s vgId:%d all downstream ready, quit from monitor rsp tmr, ref:%d", id, state.name, vgId, - ref); + stDebug("s-task:%s status:%s vgId:%d all downstream ready, quit from monitor rsp tmr", id, state.name, vgId); streamTaskCompleteCheckRsp(pInfo, false, id); streamMutexUnlock(&pInfo->checkInfoLock); - streamMetaReleaseTask(pMeta, pTask); + doCleanup(pTask, pNotReadyList, pTimeoutList, param); return; } - SArray* pNotReadyList = taosArrayInit(4, sizeof(int64_t)); - SArray* pTimeoutList = taosArrayInit(4, sizeof(int64_t)); + pNotReadyList = taosArrayInit(4, sizeof(int64_t)); + pTimeoutList = taosArrayInit(4, sizeof(int64_t)); if (state.state == TASK_STATUS__UNINIT) { getCheckRspStatus(pInfo, timeoutDuration, &numOfReady, &numOfFault, &numOfNotRsp, pTimeoutList, pNotReadyList, id); @@ -795,31 +815,25 @@ void rspMonitorFn(void* param, void* tmrId) { // fault tasks detected, not try anymore bool jumpOut = false; if ((numOfReady + numOfFault + numOfNotReady + numOfTimeout + numOfNotRsp) != total) { - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); - stError( "s-task:%s vgId:%d internal error in handling the check downstream procedure, rsp number is inconsistent, " - "stop rspMonitor tmr, total:%d, notRsp:%d, notReady:%d, fault:%d, timeout:%d, ready:%d ref:%d", - id, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady, ref); + "stop rspMonitor tmr, total:%d, notRsp:%d, notReady:%d, fault:%d, timeout:%d, ready:%d", + id, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady); jumpOut = true; } if (numOfFault > 0) { - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); stDebug( "s-task:%s status:%s vgId:%d all rsp. quit from monitor rsp tmr, since vnode-transfer/leader-change/restart " - "detected, total:%d, notRsp:%d, notReady:%d, fault:%d, timeout:%d, ready:%d ref:%d", - id, state.name, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady, ref); + "detected, total:%d, notRsp:%d, notReady:%d, fault:%d, timeout:%d, ready:%d", + id, state.name, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady); jumpOut = true; } if (jumpOut) { streamTaskCompleteCheckRsp(pInfo, false, id); streamMutexUnlock(&pInfo->checkInfoLock); - streamMetaReleaseTask(pMeta, pTask); - - taosArrayDestroy(pNotReadyList); - taosArrayDestroy(pTimeoutList); + doCleanup(pTask, pNotReadyList, pTimeoutList, param); return; } } else { // unexpected status @@ -828,11 +842,10 @@ void rspMonitorFn(void* param, void* tmrId) { // checking of downstream tasks has been stopped by other threads if (pInfo->stopCheckProcess == 1) { - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); stDebug( "s-task:%s status:%s vgId:%d stopped by other threads to check downstream process, total:%d, notRsp:%d, " - "notReady:%d, fault:%d, timeout:%d, ready:%d ref:%d", - id, state.name, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady, ref); + "notReady:%d, fault:%d, timeout:%d, ready:%d", + id, state.name, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady); streamTaskCompleteCheckRsp(pInfo, false, id); streamMutexUnlock(&pInfo->checkInfoLock); @@ -842,10 +855,7 @@ void rspMonitorFn(void* param, void* tmrId) { stError("s-task:%s failed to create async record start failed task, code:%s", id, tstrerror(code)); } - streamMetaReleaseTask(pMeta, pTask); - - taosArrayDestroy(pNotReadyList); - taosArrayDestroy(pTimeoutList); + doCleanup(pTask, pNotReadyList, pTimeoutList, param); return; } @@ -857,7 +867,7 @@ void rspMonitorFn(void* param, void* tmrId) { handleTimeoutDownstreamTasks(pTask, pTimeoutList); } - streamTmrStart(rspMonitorFn, CHECK_RSP_CHECK_INTERVAL, pTask, streamTimer, &pInfo->checkRspTmr, vgId, + streamTmrStart(rspMonitorFn, CHECK_RSP_CHECK_INTERVAL, param, streamTimer, &pInfo->checkRspTmr, vgId, "check-status-monitor"); streamMutexUnlock(&pInfo->checkInfoLock); @@ -865,7 +875,5 @@ void rspMonitorFn(void* param, void* tmrId) { "s-task:%s vgId:%d continue checking rsp in 300ms, total:%d, notRsp:%d, notReady:%d, fault:%d, timeout:%d, " "ready:%d", id, vgId, total, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady); - - taosArrayDestroy(pNotReadyList); - taosArrayDestroy(pTimeoutList); + doCleanup(pTask, pNotReadyList, pTimeoutList, NULL); } diff --git a/source/libs/stream/src/streamCheckpoint.c b/source/libs/stream/src/streamCheckpoint.c index 302090bb373..7724d1c5ffb 100644 --- a/source/libs/stream/src/streamCheckpoint.c +++ b/source/libs/stream/src/streamCheckpoint.c @@ -345,13 +345,15 @@ int32_t streamProcessCheckpointTriggerBlock(SStreamTask* pTask, SStreamDataBlock SStreamTmrInfo* pTmrInfo = &pActiveInfo->chkptTriggerMsgTmr; int8_t old = atomic_val_compare_exchange_8(&pTmrInfo->isActive, 0, 1); if (old == 0) { - int32_t ref = atomic_add_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:%s start checkpoint-trigger monitor in 10s, ref:%d ", pTask->id.idStr, ref); - - int32_t unusedRetRef = streamMetaAcquireOneTask(pTask); - streamTmrStart(checkpointTriggerMonitorFn, 200, pTask, streamTimer, &pTmrInfo->tmrHandle, vgId, - "trigger-recv-monitor"); - pTmrInfo->launchChkptId = pActiveInfo->activeId; + stDebug("s-task:%s start checkpoint-trigger monitor in 10s", pTask->id.idStr); + + int64_t* pTaskRefId = NULL; + code = streamTaskAllocRefId(pTask, &pTaskRefId); + if (code == 0) { + streamTmrStart(checkpointTriggerMonitorFn, 200, pTaskRefId, streamTimer, &pTmrInfo->tmrHandle, vgId, + "trigger-recv-monitor"); + pTmrInfo->launchChkptId = pActiveInfo->activeId; + } } else { // already launched, do nothing stError("s-task:%s previous checkpoint-trigger monitor tmr is set, not start new one", pTask->id.idStr); } @@ -890,7 +892,7 @@ int32_t streamTaskBuildCheckpoint(SStreamTask* pTask) { return code; } -static int32_t doChkptStatusCheck(SStreamTask* pTask) { +static int32_t doChkptStatusCheck(SStreamTask* pTask, void* param) { const char* id = pTask->id.idStr; int32_t vgId = pTask->pMeta->vgId; SActiveCheckpointInfo* pActiveInfo = pTask->chkInfo.pActiveInfo; @@ -898,25 +900,24 @@ static int32_t doChkptStatusCheck(SStreamTask* pTask) { // checkpoint-trigger recv flag is set, quit if (pActiveInfo->allUpstreamTriggerRecv) { - int32_t ref = streamCleanBeforeQuitTmr(pTmrInfo, pTask); - stDebug("s-task:%s vgId:%d all checkpoint-trigger recv, quit from monitor checkpoint-trigger, ref:%d", id, vgId, - ref); + streamCleanBeforeQuitTmr(pTmrInfo, param); + stDebug("s-task:%s vgId:%d all checkpoint-trigger recv, quit from monitor checkpoint-trigger", id, vgId); return -1; } if (pTmrInfo->launchChkptId != pActiveInfo->activeId) { - int32_t ref = streamCleanBeforeQuitTmr(pTmrInfo, pTask); + streamCleanBeforeQuitTmr(pTmrInfo, param); stWarn("s-task:%s vgId:%d checkpoint-trigger retrieve by previous checkpoint procedure, checkpointId:%" PRId64 - ", quit, ref:%d", - id, vgId, pTmrInfo->launchChkptId, ref); + ", quit", + id, vgId, pTmrInfo->launchChkptId); return -1; } // active checkpoint info is cleared for now if ((pActiveInfo->activeId == 0) || (pActiveInfo->transId == 0) || (pTask->chkInfo.startTs == 0)) { - int32_t ref = streamCleanBeforeQuitTmr(pTmrInfo, pTask); - stWarn("s-task:%s vgId:%d active checkpoint may be cleared, quit from retrieve checkpoint-trigger send tmr, ref:%d", - id, vgId, ref); + streamCleanBeforeQuitTmr(pTmrInfo, param); + stWarn("s-task:%s vgId:%d active checkpoint may be cleared, quit from retrieve checkpoint-trigger send tmr", id, + vgId); return -1; } @@ -964,22 +965,22 @@ static int32_t doFindNotSendUpstream(SStreamTask* pTask, SArray* pList, SArray** return 0; } -static int32_t chkptTriggerRecvMonitorHelper(SStreamTask* pTask, SArray* pNotSendList) { +static int32_t chkptTriggerRecvMonitorHelper(SStreamTask* pTask, void* param, SArray* pNotSendList) { const char* id = pTask->id.idStr; SArray* pList = pTask->upstreamInfo.pList; // send msg to retrieve checkpoint trigger msg SActiveCheckpointInfo* pActiveInfo = pTask->chkInfo.pActiveInfo; SStreamTmrInfo* pTmrInfo = &pActiveInfo->chkptTriggerMsgTmr; int32_t vgId = pTask->pMeta->vgId; - int32_t code = doChkptStatusCheck(pTask); + int32_t code = doChkptStatusCheck(pTask, param); if (code) { return code; } code = doFindNotSendUpstream(pTask, pList, &pNotSendList); if (code) { - int32_t ref = streamCleanBeforeQuitTmr(pTmrInfo, pTask); - stDebug("s-task:%s failed to find not send upstream, code:%s, out of tmr, ref:%d", id, tstrerror(code), ref); + streamCleanBeforeQuitTmr(pTmrInfo, param); + stDebug("s-task:%s failed to find not send upstream, code:%s, out of tmr", id, tstrerror(code)); return code; } @@ -993,37 +994,50 @@ static int32_t chkptTriggerRecvMonitorHelper(SStreamTask* pTask, SArray* pNotSen return code; } +static void doCleanup(SStreamTask* pTask, SArray* pList) { + streamMetaReleaseTask(pTask->pMeta, pTask); + taosArrayDestroy(pList); +} + void checkpointTriggerMonitorFn(void* param, void* tmrId) { - SStreamTask* pTask = param; - int32_t vgId = pTask->pMeta->vgId; - int64_t now = taosGetTimestampMs(); - const char* id = pTask->id.idStr; - SArray* pNotSendList = NULL; - SArray* pList = pTask->upstreamInfo.pList; // send msg to retrieve checkpoint trigger msg int32_t code = 0; int32_t numOfNotSend = 0; + SArray* pNotSendList = NULL; + int64_t taskRefId = *(int64_t*)param; + int64_t now = taosGetTimestampMs(); + + SStreamTask* pTask = taosAcquireRef(streamTaskRefPool, taskRefId); + if (pTask == NULL) { + stError("invalid task rid:%" PRId64 " failed to acquired stream-task at %s", taskRefId, __func__); + streamTaskFreeRefId(param); + return; + } + int32_t vgId = pTask->pMeta->vgId; + const char* id = pTask->id.idStr; + SArray* pList = pTask->upstreamInfo.pList; // send msg to retrieve checkpoint trigger msg SActiveCheckpointInfo* pActiveInfo = pTask->chkInfo.pActiveInfo; SStreamTmrInfo* pTmrInfo = &pActiveInfo->chkptTriggerMsgTmr; if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) { - int32_t ref = streamCleanBeforeQuitTmr(pTmrInfo, pTask); - stError("s-task:%s source task should not start the checkpoint-trigger monitor fn, ref:%d quit", id, ref); - streamMetaReleaseTask(pTask->pMeta, pTask); + streamCleanBeforeQuitTmr(pTmrInfo, param); + stError("s-task:%s source task should not start the checkpoint-trigger monitor fn, quit", id); + doCleanup(pTask, pNotSendList); return; } // check the status every 100ms if (streamTaskShouldStop(pTask)) { - int32_t ref = streamCleanBeforeQuitTmr(pTmrInfo, pTask); - stDebug("s-task:%s vgId:%d quit from monitor checkpoint-trigger, ref:%d", id, vgId, ref); - streamMetaReleaseTask(pTask->pMeta, pTask); + streamCleanBeforeQuitTmr(pTmrInfo, param); + stDebug("s-task:%s vgId:%d quit from monitor checkpoint-trigger", id, vgId); + doCleanup(pTask, pNotSendList); return; } if (++pTmrInfo->activeCounter < 50) { - streamTmrStart(checkpointTriggerMonitorFn, 200, pTask, streamTimer, &pTmrInfo->tmrHandle, vgId, + streamTmrStart(checkpointTriggerMonitorFn, 200, param, streamTimer, &pTmrInfo->tmrHandle, vgId, "trigger-recv-monitor"); + doCleanup(pTask, pNotSendList); return; } @@ -1035,20 +1049,19 @@ void checkpointTriggerMonitorFn(void* param, void* tmrId) { streamMutexUnlock(&pTask->lock); if (state.state != TASK_STATUS__CK) { - int32_t ref = streamCleanBeforeQuitTmr(pTmrInfo, pTask); - stDebug("s-task:%s vgId:%d status:%s not in checkpoint status, quit from monitor checkpoint-trigger, ref:%d", id, - vgId, state.name, ref); - streamMetaReleaseTask(pTask->pMeta, pTask); + streamCleanBeforeQuitTmr(pTmrInfo, param); + stDebug("s-task:%s vgId:%d status:%s not in checkpoint status, quit from monitor checkpoint-trigger", id, + vgId, state.name); + doCleanup(pTask, pNotSendList); return; } streamMutexLock(&pActiveInfo->lock); - code = chkptTriggerRecvMonitorHelper(pTask, pNotSendList); + code = chkptTriggerRecvMonitorHelper(pTask, param, pNotSendList); streamMutexUnlock(&pActiveInfo->lock); if (code != TSDB_CODE_SUCCESS) { - streamMetaReleaseTask(pTask->pMeta, pTask); - taosArrayDestroy(pNotSendList); + doCleanup(pTask, pNotSendList); return; } @@ -1056,15 +1069,14 @@ void checkpointTriggerMonitorFn(void* param, void* tmrId) { numOfNotSend = taosArrayGetSize(pNotSendList); if (numOfNotSend > 0) { stDebug("s-task:%s start to monitor checkpoint-trigger in 10s", id); - streamTmrStart(checkpointTriggerMonitorFn, 200, pTask, streamTimer, &pTmrInfo->tmrHandle, vgId, + streamTmrStart(checkpointTriggerMonitorFn, 200, param, streamTimer, &pTmrInfo->tmrHandle, vgId, "trigger-recv-monitor"); } else { - int32_t ref = streamCleanBeforeQuitTmr(pTmrInfo, pTask); - stDebug("s-task:%s all checkpoint-trigger recved, quit from monitor checkpoint-trigger tmr, ref:%d", id, ref); - streamMetaReleaseTask(pTask->pMeta, pTask); + streamCleanBeforeQuitTmr(pTmrInfo, param); + stDebug("s-task:%s all checkpoint-trigger recved, quit from monitor checkpoint-trigger tmr", id); } - taosArrayDestroy(pNotSendList); + doCleanup(pTask, pNotSendList); } int32_t doSendRetrieveTriggerMsg(SStreamTask* pTask, SArray* pNotSendList) { diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 62d60ff6642..5f31364e76c 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -518,45 +518,66 @@ static void doSendFailedDispatch(SStreamTask* pTask, SDispatchEntry* pEntry, int } } +static void cleanupInMonitor(int32_t taskId, int64_t taskRefId, void* param) { + int32_t ret = taosReleaseRef(streamTaskRefPool, taskRefId); + if (ret) { + stError("s-task:0x%x failed to release task refId:%" PRId64, taskId, taskRefId); + } + streamTaskFreeRefId(param); +} + static void doMonitorDispatchData(void* param, void* tmrId) { - SStreamTask* pTask = param; - const char* id = pTask->id.idStr; - int32_t vgId = pTask->pMeta->vgId; - SDispatchMsgInfo* pMsgInfo = &pTask->msgInfo; - int32_t msgId = pMsgInfo->msgId; int32_t code = 0; int64_t now = taosGetTimestampMs(); bool inDispatch = true; + SStreamTask* pTask = NULL; + int64_t taskRefId = *(int64_t*)param; + const char* id = NULL; + int32_t vgId = -1; + SDispatchMsgInfo* pMsgInfo = NULL; + int32_t msgId = -1; + + pTask = taosAcquireRef(streamTaskRefPool, taskRefId); + if (pTask == NULL) { + stError("invalid task rid:%" PRId64 " failed to acquired stream-task at %s", taskRefId, __func__); + streamTaskFreeRefId(param); + return; + } - stDebug("s-task:%s start monitor dispatch data", id); + id = pTask->id.idStr; + vgId = pTask->pMeta->vgId; + pMsgInfo = &pTask->msgInfo; + msgId = pMsgInfo->msgId; + + stDebug("s-task:%s start to monitor dispatch data", id); if (streamTaskShouldStop(pTask)) { - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:%s should stop, abort from timer, ref:%d", pTask->id.idStr, ref); + stDebug("s-task:%s should stop, abort from timer", pTask->id.idStr); setNotInDispatchMonitor(pMsgInfo); + cleanupInMonitor(pTask->id.taskId, taskRefId, param); return; } // slave task not handle the dispatch, downstream not ready will break the monitor timer // follower not handle the dispatch rsp if ((pTask->pMeta->role == NODE_ROLE_FOLLOWER) || (pTask->status.downstreamReady != 1)) { - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); - stError("s-task:%s vgId:%d follower or downstream not ready, jump out of monitor tmr, ref:%d", id, vgId, ref); + stError("s-task:%s vgId:%d follower or downstream not ready, jump out of monitor tmr", id, vgId); setNotInDispatchMonitor(pMsgInfo); + cleanupInMonitor(pTask->id.taskId, taskRefId, param); return; } streamMutexLock(&pMsgInfo->lock); if (pTask->outputq.status == TASK_OUTPUT_STATUS__NORMAL) { - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:%s not in dispatch procedure, abort from timer, ref:%d", pTask->id.idStr, ref); - + stDebug("s-task:%s not in dispatch procedure, abort from timer", pTask->id.idStr); pMsgInfo->inMonitor = 0; inDispatch = false; } + streamMutexUnlock(&pMsgInfo->lock); if (!inDispatch) { + cleanupInMonitor(pTask->id.taskId, taskRefId, param); return; } @@ -564,6 +585,7 @@ static void doMonitorDispatchData(void* param, void* tmrId) { if (numOfFailed == 0) { stDebug("s-task:%s no error occurs, check again in %dms", id, DISPATCH_RETRY_INTERVAL_MS); streamStartMonitorDispatchData(pTask, DISPATCH_RETRY_INTERVAL_MS); + cleanupInMonitor(pTask->id.taskId, taskRefId, param); return; } @@ -628,18 +650,23 @@ static void doMonitorDispatchData(void* param, void* tmrId) { } if (streamTaskShouldStop(pTask)) { - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:%s should stop, abort from timer, ref:%d", pTask->id.idStr, ref); + stDebug("s-task:%s should stop, abort from timer", pTask->id.idStr); setNotInDispatchMonitor(pMsgInfo); } else { streamStartMonitorDispatchData(pTask, DISPATCH_RETRY_INTERVAL_MS); } + + cleanupInMonitor(pTask->id.taskId, taskRefId, param); } void streamStartMonitorDispatchData(SStreamTask* pTask, int64_t waitDuration) { - int32_t vgId = pTask->pMeta->vgId; - streamTmrStart(doMonitorDispatchData, waitDuration, pTask, streamTimer, &pTask->msgInfo.pRetryTmr, vgId, - "dispatch-monitor"); + int32_t vgId = pTask->pMeta->vgId; + int64_t* pTaskRefId = NULL; + int32_t code = streamTaskAllocRefId(pTask, &pTaskRefId); + if (code == 0) { + streamTmrStart(doMonitorDispatchData, waitDuration, pTaskRefId, streamTimer, &pTask->msgInfo.pRetryTmr, vgId, + "dispatch-monitor"); + } } static int32_t doAddDispatchBlock(SStreamTask* pTask, SStreamDispatchReq* pReqs, SSDataBlock* pDataBlock, @@ -854,9 +881,9 @@ int32_t streamDispatchStreamBlock(SStreamTask* pTask) { } else { streamMutexLock(&pTask->msgInfo.lock); if (pTask->msgInfo.inMonitor == 0) { - int32_t ref = atomic_add_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:%s start dispatch monitor tmr in %dms, ref:%d, dispatch code:%s", id, DISPATCH_RETRY_INTERVAL_MS, - ref, tstrerror(code)); +// int32_t ref = atomic_add_fetch_32(&pTask->status.timerActive, 1); + stDebug("s-task:%s start dispatch monitor tmr in %dms, dispatch code:%s", id, DISPATCH_RETRY_INTERVAL_MS, + tstrerror(code)); streamStartMonitorDispatchData(pTask, DISPATCH_RETRY_INTERVAL_MS); pTask->msgInfo.inMonitor = 1; } else { @@ -911,31 +938,31 @@ int32_t initCheckpointReadyMsg(SStreamTask* pTask, int32_t upstreamNodeId, int32 return TSDB_CODE_SUCCESS; } -static int32_t doTaskChkptStatusCheck(SStreamTask* pTask, int32_t num) { +static int32_t doTaskChkptStatusCheck(SStreamTask* pTask, void* param, int32_t num) { SActiveCheckpointInfo* pActiveInfo = pTask->chkInfo.pActiveInfo; SStreamTmrInfo* pTmrInfo = &pActiveInfo->chkptReadyMsgTmr; const char* id = pTask->id.idStr; int32_t vgId = pTask->pMeta->vgId; if (pTmrInfo->launchChkptId != pActiveInfo->activeId) { - int32_t ref = streamCleanBeforeQuitTmr(pTmrInfo, pTask); + streamCleanBeforeQuitTmr(pTmrInfo, param); stWarn("s-task:%s vgId:%d ready-msg send tmr launched by previous checkpoint procedure, checkpointId:%" PRId64 - ", quit, ref:%d", - id, vgId, pTmrInfo->launchChkptId, ref); + ", quit", + id, vgId, pTmrInfo->launchChkptId); return -1; } // active checkpoint info is cleared for now if ((pActiveInfo->activeId == 0) || (pActiveInfo->transId == 0) || (num == 0) || (pTask->chkInfo.startTs == 0)) { - int32_t ref = streamCleanBeforeQuitTmr(pTmrInfo, pTask); - stWarn("s-task:%s vgId:%d active checkpoint may be cleared, quit from readyMsg send tmr, ref:%d", id, vgId, ref); + streamCleanBeforeQuitTmr(pTmrInfo, param); + stWarn("s-task:%s vgId:%d active checkpoint may be cleared, quit from readyMsg send tmr", id, vgId); return -1; } if (taosArrayGetSize(pTask->upstreamInfo.pList) != num) { - int32_t ref = streamCleanBeforeQuitTmr(pTmrInfo, pTask); - stWarn("s-task:%s vgId:%d upstream number:%d not equals sent readyMsg:%d, quit from readyMsg send tmr, ref:%d", id, - vgId, (int32_t)taosArrayGetSize(pTask->upstreamInfo.pList), num, ref); + streamCleanBeforeQuitTmr(pTmrInfo, param); + stWarn("s-task:%s vgId:%d upstream number:%d not equals sent readyMsg:%d, quit from readyMsg send tmr", id, + vgId, (int32_t)taosArrayGetSize(pTask->upstreamInfo.pList), num); return -1; } @@ -1011,7 +1038,7 @@ static void doSendChkptReadyMsg(SStreamTask* pTask, SArray* pNotRspList, int64_t } } -static int32_t chkptReadyMsgSendHelper(SStreamTask* pTask, SArray* pNotRspList) { +static int32_t chkptReadyMsgSendHelper(SStreamTask* pTask, void* param, SArray* pNotRspList) { SActiveCheckpointInfo* pActiveInfo = pTask->chkInfo.pActiveInfo; SStreamTmrInfo* pTmrInfo = &pActiveInfo->chkptReadyMsgTmr; SArray* pList = pActiveInfo->pReadyMsgList; @@ -1021,16 +1048,15 @@ static int32_t chkptReadyMsgSendHelper(SStreamTask* pTask, SArray* pNotRspList) const char* id = pTask->id.idStr; int32_t notRsp = 0; - int32_t code = doTaskChkptStatusCheck(pTask, num); + int32_t code = doTaskChkptStatusCheck(pTask, param, num); if (code) { return code; } code = doFindNotConfirmUpstream(&pNotRspList, pList, num, vgId, pTask->info.taskLevel, id); if (code) { - int32_t ref = streamCleanBeforeQuitTmr(pTmrInfo, pTask); - stError("s-task:%s failed to find not rsp checkpoint-ready downstream, code:%s, out of tmr, ref:%d", id, - tstrerror(code), ref); + streamCleanBeforeQuitTmr(pTmrInfo, param); + stError("s-task:%s failed to find not rsp checkpoint-ready downstream, code:%s, out of tmr", id, tstrerror(code)); return code; } @@ -1045,26 +1071,41 @@ static int32_t chkptReadyMsgSendHelper(SStreamTask* pTask, SArray* pNotRspList) } static void chkptReadyMsgSendMonitorFn(void* param, void* tmrId) { - SStreamTask* pTask = param; - int32_t vgId = pTask->pMeta->vgId; - const char* id = pTask->id.idStr; - SActiveCheckpointInfo* pActiveInfo = pTask->chkInfo.pActiveInfo; - SStreamTmrInfo* pTmrInfo = &pActiveInfo->chkptReadyMsgTmr; SArray* pNotRspList = NULL; int32_t code = 0; int32_t notRsp = 0; + int64_t taskRefId = *(int64_t*)param; + int32_t vgId = -1; + const char* id = NULL; + SActiveCheckpointInfo* pActiveInfo = NULL; + SStreamTmrInfo* pTmrInfo = NULL; + + SStreamTask* pTask = taosAcquireRef(streamTaskRefPool, taskRefId); + if (pTask == NULL) { + stError("invalid task rid:%" PRId64 " failed to acquired stream-task at %s", taskRefId, __func__); + streamTaskFreeRefId(param); + return; + } + + vgId = pTask->pMeta->vgId; + id = pTask->id.idStr; + pActiveInfo = pTask->chkInfo.pActiveInfo; + pTmrInfo = &pActiveInfo->chkptReadyMsgTmr; // check the status every 100ms if (streamTaskShouldStop(pTask)) { - int32_t ref = streamCleanBeforeQuitTmr(pTmrInfo, pTask); - stDebug("s-task:%s vgId:%d status:stop, quit from monitor checkpoint-trigger, ref:%d", id, vgId, ref); + streamCleanBeforeQuitTmr(pTmrInfo, param); + stDebug("s-task:%s vgId:%d status:stop, quit from monitor checkpoint-trigger", id, vgId); streamMetaReleaseTask(pTask->pMeta, pTask); + taosArrayDestroy(pNotRspList); return; } if (++pTmrInfo->activeCounter < 50) { - streamTmrStart(chkptReadyMsgSendMonitorFn, 200, pTask, streamTimer, &pTmrInfo->tmrHandle, vgId, + streamTmrStart(chkptReadyMsgSendMonitorFn, 200, param, streamTimer, &pTmrInfo->tmrHandle, vgId, "chkpt-ready-monitor"); + streamMetaReleaseTask(pTask->pMeta, pTask); + taosArrayDestroy(pNotRspList); return; } @@ -1078,15 +1119,16 @@ static void chkptReadyMsgSendMonitorFn(void* param, void* tmrId) { // 1. check status in the first place if (state.state != TASK_STATUS__CK) { - int32_t ref = streamCleanBeforeQuitTmr(pTmrInfo, pTask); - stDebug("s-task:%s vgId:%d status:%s not in checkpoint, quit from monitor checkpoint-ready, ref:%d", id, vgId, - state.name, ref); + streamCleanBeforeQuitTmr(pTmrInfo, param); + stDebug("s-task:%s vgId:%d status:%s not in checkpoint, quit from monitor checkpoint-ready", id, vgId, + state.name); streamMetaReleaseTask(pTask->pMeta, pTask); + taosArrayDestroy(pNotRspList); return; } streamMutexLock(&pActiveInfo->lock); - code = chkptReadyMsgSendHelper(pTask, pNotRspList); + code = chkptReadyMsgSendHelper(pTask, param, pNotRspList); streamMutexUnlock(&pActiveInfo->lock); if (code != TSDB_CODE_SUCCESS) { @@ -1098,18 +1140,18 @@ static void chkptReadyMsgSendMonitorFn(void* param, void* tmrId) { notRsp = taosArrayGetSize(pNotRspList); if (notRsp > 0) { // send checkpoint-ready msg again stDebug("s-task:%s start to monitor checkpoint-ready msg recv status in 10s", id); - streamTmrStart(chkptReadyMsgSendMonitorFn, 200, pTask, streamTimer, &pTmrInfo->tmrHandle, vgId, + streamTmrStart(chkptReadyMsgSendMonitorFn, 200, param, streamTimer, &pTmrInfo->tmrHandle, vgId, "chkpt-ready-monitor"); } else { - int32_t ref = streamCleanBeforeQuitTmr(pTmrInfo, pTask); + streamCleanBeforeQuitTmr(pTmrInfo, param); stDebug( "s-task:%s vgId:%d checkpoint-ready msg confirmed by all upstream task(s), clear checkpoint-ready msg and quit " - "from timer, ref:%d", - id, vgId, ref); - // release should be the last execution, since pTask may be destroy after it immidiately. - streamMetaReleaseTask(pTask->pMeta, pTask); + "from timer", + id, vgId); } + // release should be the last execution, since pTask may be destroyed after it immediately. + streamMetaReleaseTask(pTask->pMeta, pTask); taosArrayDestroy(pNotRspList); } @@ -1160,15 +1202,17 @@ int32_t streamTaskSendCheckpointReadyMsg(SStreamTask* pTask) { int8_t old = atomic_val_compare_exchange_8(&pTmrInfo->isActive, 0, 1); if (old == 0) { - int32_t ref = atomic_add_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:%s start checkpoint-ready monitor in 10s, ref:%d ", pTask->id.idStr, ref); - int32_t unusedRetRef = streamMetaAcquireOneTask(pTask); + stDebug("s-task:%s start checkpoint-ready monitor in 10s", pTask->id.idStr); - streamTmrStart(chkptReadyMsgSendMonitorFn, 200, pTask, streamTimer, &pTmrInfo->tmrHandle, vgId, - "chkpt-ready-monitor"); + int64_t* pTaskRefId = NULL; + int32_t code = streamTaskAllocRefId(pTask, &pTaskRefId); + if (code == 0) { + streamTmrStart(chkptReadyMsgSendMonitorFn, 200, pTaskRefId, streamTimer, &pTmrInfo->tmrHandle, vgId, + "chkpt-ready-monitor"); - // mark the timer monitor checkpointId - pTmrInfo->launchChkptId = pActiveInfo->activeId; + // mark the timer monitor checkpointId + pTmrInfo->launchChkptId = pActiveInfo->activeId; + } } else { stError("s-task:%s previous checkpoint-ready monitor tmr is set, not start new one", pTask->id.idStr); } diff --git a/source/libs/stream/src/streamHb.c b/source/libs/stream/src/streamHb.c index 19391bf7a05..25cb28f77c5 100644 --- a/source/libs/stream/src/streamHb.c +++ b/source/libs/stream/src/streamHb.c @@ -21,7 +21,7 @@ #include "ttimer.h" #include "wal.h" -int32_t streamMetaId = 0; +int32_t streamMetaRefPool = 0; struct SMetaHbInfo { tmr_h hbTmr; @@ -123,17 +123,21 @@ int32_t streamMetaSendHbHelper(SStreamMeta* pMeta) { for(int32_t i = 0; i < numOfTasks; ++i) { SStreamTaskId* pId = taosArrayGet(pMeta->pTaskList, i); - STaskId id = {.streamId = pId->streamId, .taskId = pId->taskId}; - SStreamTask** pTask = taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); - if (pTask == NULL) { + STaskId id = {.streamId = pId->streamId, .taskId = pId->taskId}; + SStreamTask* pTask = NULL; + + code = streamMetaAcquireTaskUnsafe(pMeta, &id, &pTask); + if (code != 0) { continue; } - if ((*pTask)->info.fillHistory == 1) { + if (pTask->info.fillHistory == 1) { + streamMetaReleaseTask(pMeta, pTask); continue; } - epsetAssign(&epset, &(*pTask)->info.mnodeEpset); + epsetAssign(&epset, &pTask->info.mnodeEpset); + streamMetaReleaseTask(pMeta, pTask); break; } @@ -159,28 +163,30 @@ int32_t streamMetaSendHbHelper(SStreamMeta* pMeta) { for (int32_t i = 0; i < numOfTasks; ++i) { SStreamTaskId* pId = taosArrayGet(pMeta->pTaskList, i); - STaskId id = {.streamId = pId->streamId, .taskId = pId->taskId}; - SStreamTask** pTask = taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); - if (pTask == NULL) { + STaskId id = {.streamId = pId->streamId, .taskId = pId->taskId}; + SStreamTask* pTask = NULL; + code = streamMetaAcquireTaskUnsafe(pMeta, &id, &pTask); + if (code != 0) { continue; } // not report the status of fill-history task - if ((*pTask)->info.fillHistory == 1) { + if (pTask->info.fillHistory == 1) { + streamMetaReleaseTask(pMeta, pTask); continue; } - streamMutexLock(&(*pTask)->lock); - STaskStatusEntry entry = streamTaskGetStatusEntry(*pTask); - streamMutexUnlock(&(*pTask)->lock); + streamMutexLock(&pTask->lock); + STaskStatusEntry entry = streamTaskGetStatusEntry(pTask); + streamMutexUnlock(&pTask->lock); entry.inputRate = entry.inputQUsed * 100.0 / (2 * STREAM_TASK_QUEUE_CAPACITY_IN_SIZE); - if ((*pTask)->info.taskLevel == TASK_LEVEL__SINK) { - entry.sinkQuota = (*pTask)->outputInfo.pTokenBucket->quotaRate; - entry.sinkDataSize = SIZE_IN_MiB((*pTask)->execInfo.sink.dataSize); + if (pTask->info.taskLevel == TASK_LEVEL__SINK) { + entry.sinkQuota = pTask->outputInfo.pTokenBucket->quotaRate; + entry.sinkDataSize = SIZE_IN_MiB(pTask->execInfo.sink.dataSize); } - SActiveCheckpointInfo* p = (*pTask)->chkInfo.pActiveInfo; + SActiveCheckpointInfo* p = pTask->chkInfo.pActiveInfo; if (p->activeId != 0) { entry.checkpointInfo.failed = (p->failedId >= p->activeId) ? 1 : 0; entry.checkpointInfo.activeId = p->activeId; @@ -188,40 +194,42 @@ int32_t streamMetaSendHbHelper(SStreamMeta* pMeta) { if (entry.checkpointInfo.failed) { stInfo("s-task:%s set kill checkpoint trans in hbMsg, transId:%d, clear the active checkpointInfo", - (*pTask)->id.idStr, p->transId); + pTask->id.idStr, p->transId); - streamMutexLock(&(*pTask)->lock); - streamTaskClearCheckInfo((*pTask), true); - streamMutexUnlock(&(*pTask)->lock); + streamMutexLock(&pTask->lock); + streamTaskClearCheckInfo(pTask, true); + streamMutexUnlock(&pTask->lock); } } - streamMutexLock(&(*pTask)->lock); - entry.checkpointInfo.consensusChkptId = streamTaskCheckIfReqConsenChkptId(*pTask, pMsg->ts); + streamMutexLock(&pTask->lock); + entry.checkpointInfo.consensusChkptId = streamTaskCheckIfReqConsenChkptId(pTask, pMsg->ts); if (entry.checkpointInfo.consensusChkptId) { entry.checkpointInfo.consensusTs = pMsg->ts; } - streamMutexUnlock(&(*pTask)->lock); + streamMutexUnlock(&pTask->lock); - if ((*pTask)->exec.pWalReader != NULL) { - entry.processedVer = walReaderGetCurrentVer((*pTask)->exec.pWalReader) - 1; + if (pTask->exec.pWalReader != NULL) { + entry.processedVer = walReaderGetCurrentVer(pTask->exec.pWalReader) - 1; if (entry.processedVer < 0) { - entry.processedVer = (*pTask)->chkInfo.processedVer; + entry.processedVer = pTask->chkInfo.processedVer; } - walReaderValidVersionRange((*pTask)->exec.pWalReader, &entry.verRange.minVer, &entry.verRange.maxVer); + walReaderValidVersionRange(pTask->exec.pWalReader, &entry.verRange.minVer, &entry.verRange.maxVer); } - addUpdateNodeIntoHbMsg(*pTask, pMsg); + addUpdateNodeIntoHbMsg(pTask, pMsg); p = taosArrayPush(pMsg->pTaskStatus, &entry); if (p == NULL) { - stError("failed to add taskInfo:0x%x in hbMsg, vgId:%d", (*pTask)->id.taskId, pMeta->vgId); + stError("failed to add taskInfo:0x%x in hbMsg, vgId:%d", pTask->id.taskId, pMeta->vgId); } if (!hasMnodeEpset) { - epsetAssign(&epset, &(*pTask)->info.mnodeEpset); + epsetAssign(&epset, &pTask->info.mnodeEpset); hasMnodeEpset = true; } + + streamMetaReleaseTask(pMeta, pTask); } pMsg->numOfTasks = taosArrayGetSize(pMsg->pTaskStatus); @@ -244,9 +252,10 @@ void streamMetaHbToMnode(void* param, void* tmrId) { int32_t vgId = 0; int32_t role = 0; - SStreamMeta* pMeta = taosAcquireRef(streamMetaId, rid); + SStreamMeta* pMeta = taosAcquireRef(streamMetaRefPool, rid); if (pMeta == NULL) { - stError("invalid rid:%" PRId64 " failed to acquired stream-meta", rid); + stError("invalid meta rid:%" PRId64 " failed to acquired stream-meta", rid); +// taosMemoryFree(param); return; } @@ -256,24 +265,26 @@ void streamMetaHbToMnode(void* param, void* tmrId) { // need to stop, stop now if (pMeta->closeFlag) { pMeta->pHbInfo->hbStart = 0; - code = taosReleaseRef(streamMetaId, rid); + code = taosReleaseRef(streamMetaRefPool, rid); if (code == TSDB_CODE_SUCCESS) { stDebug("vgId:%d jump out of meta timer", vgId); } else { stError("vgId:%d jump out of meta timer, failed to release the meta rid:%" PRId64, vgId, rid); } +// taosMemoryFree(param); return; } // not leader not send msg if (pMeta->role != NODE_ROLE_LEADER) { pMeta->pHbInfo->hbStart = 0; - code = taosReleaseRef(streamMetaId, rid); + code = taosReleaseRef(streamMetaRefPool, rid); if (code == TSDB_CODE_SUCCESS) { stInfo("vgId:%d role:%d not leader not send hb to mnode", vgId, role); } else { stError("vgId:%d role:%d not leader not send hb to mnodefailed to release the meta rid:%" PRId64, vgId, role, rid); } +// taosMemoryFree(param); return; } @@ -281,7 +292,7 @@ void streamMetaHbToMnode(void* param, void* tmrId) { streamTmrStart(streamMetaHbToMnode, META_HB_CHECK_INTERVAL, param, streamTimer, &pMeta->pHbInfo->hbTmr, vgId, "meta-hb-tmr"); - code = taosReleaseRef(streamMetaId, rid); + code = taosReleaseRef(streamMetaRefPool, rid); if (code) { stError("vgId:%d in meta timer, failed to release the meta rid:%" PRId64, vgId, rid); } @@ -298,12 +309,13 @@ void streamMetaHbToMnode(void* param, void* tmrId) { if (code) { stError("vgId:%d failed to send hmMsg to mnode, try again in 5s, code:%s", pMeta->vgId, tstrerror(code)); } + streamMetaRUnLock(pMeta); streamTmrStart(streamMetaHbToMnode, META_HB_CHECK_INTERVAL, param, streamTimer, &pMeta->pHbInfo->hbTmr, pMeta->vgId, "meta-hb-tmr"); - code = taosReleaseRef(streamMetaId, rid); + code = taosReleaseRef(streamMetaRefPool, rid); if (code) { stError("vgId:%d in meta timer, failed to release the meta rid:%" PRId64, vgId, rid); } @@ -316,12 +328,13 @@ int32_t createMetaHbInfo(int64_t* pRid, SMetaHbInfo** pRes) { return terrno; } - streamTmrStart(streamMetaHbToMnode, META_HB_CHECK_INTERVAL, pRid, streamTimer, &pInfo->hbTmr, 0, "stream-hb"); pInfo->tickCounter = 0; pInfo->msgSendTs = -1; pInfo->hbCount = 0; *pRes = pInfo; + + streamTmrStart(streamMetaHbToMnode, META_HB_CHECK_INTERVAL, pRid, streamTimer, &pInfo->hbTmr, 0, "stream-hb"); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index 7e9b60b61a8..f5de719848e 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -13,7 +13,6 @@ * along with this program. If not, see . */ -#include "executor.h" #include "streamBackendRocksdb.h" #include "streamInt.h" #include "tmisce.h" @@ -28,6 +27,7 @@ static TdThreadOnce streamMetaModuleInit = PTHREAD_ONCE_INIT; int32_t streamBackendId = 0; int32_t streamBackendCfWrapperId = 0; int32_t taskDbWrapperId = 0; +int32_t streamTaskRefPool = 0; static int32_t streamMetaBegin(SStreamMeta* pMeta); static void streamMetaCloseImpl(void* arg); @@ -41,14 +41,14 @@ SMetaRefMgt gMetaRefMgt; int32_t metaRefMgtInit(); void metaRefMgtCleanup(); -int32_t metaRefMgtAdd(int64_t vgId, int64_t* rid); static void streamMetaEnvInit() { streamBackendId = taosOpenRef(64, streamBackendCleanup); streamBackendCfWrapperId = taosOpenRef(64, streamBackendHandleCleanup); taskDbWrapperId = taosOpenRef(64, taskDbDestroy2); - streamMetaId = taosOpenRef(64, streamMetaCloseImpl); + streamMetaRefPool = taosOpenRef(64, streamMetaCloseImpl); + streamTaskRefPool = taosOpenRef(64, tFreeStreamTask); int32_t code = metaRefMgtInit(); if (code) { @@ -72,7 +72,8 @@ void streamMetaInit() { void streamMetaCleanup() { taosCloseRef(streamBackendId); taosCloseRef(streamBackendCfWrapperId); - taosCloseRef(streamMetaId); + taosCloseRef(streamMetaRefPool); + taosCloseRef(streamTaskRefPool); metaRefMgtCleanup(); streamTimerCleanUp(); @@ -98,16 +99,12 @@ int32_t metaRefMgtInit() { void metaRefMgtCleanup() { void* pIter = taosHashIterate(gMetaRefMgt.pTable, NULL); while (pIter) { - SArray* list = *(SArray**)pIter; - for (int i = 0; i < taosArrayGetSize(list); i++) { - void* rid = taosArrayGetP(list, i); - taosMemoryFree(rid); - } - taosArrayDestroy(list); + int64_t* p = *(int64_t**) pIter; + taosMemoryFree(p); pIter = taosHashIterate(gMetaRefMgt.pTable, pIter); } - taosHashCleanup(gMetaRefMgt.pTable); + taosHashCleanup(gMetaRefMgt.pTable); streamMutexDestroy(&gMetaRefMgt.mutex); } @@ -117,35 +114,32 @@ int32_t metaRefMgtAdd(int64_t vgId, int64_t* rid) { streamMutexLock(&gMetaRefMgt.mutex); - p = taosHashGet(gMetaRefMgt.pTable, &vgId, sizeof(vgId)); + p = taosHashGet(gMetaRefMgt.pTable, &rid, sizeof(rid)); if (p == NULL) { - SArray* pList = taosArrayInit(8, POINTER_BYTES); - if (pList == NULL) { - return terrno; - } - - p = taosArrayPush(pList, &rid); - if (p == NULL) { - return terrno; - } - - code = taosHashPut(gMetaRefMgt.pTable, &vgId, sizeof(vgId), &pList, sizeof(void*)); + code = taosHashPut(gMetaRefMgt.pTable, &rid, sizeof(rid), &rid, sizeof(void*)); if (code) { - stError("vgId:%d failed to put into metaRef table, rid:%" PRId64, (int32_t)vgId, *rid); + stError("vgId:%d failed to put into refId mgt, refId:%" PRId64" %p, code:%s", (int32_t)vgId, *rid, rid, + tstrerror(code)); return code; + } else { // not +// stInfo("add refId:%"PRId64" vgId:%d, %p", *rid, (int32_t)vgId, rid); } } else { - SArray* list = *(SArray**)p; - void* px = taosArrayPush(list, &rid); - if (px == NULL) { - code = terrno; - } + stFatal("try to add refId:%"PRId64" vgId:%d, %p that already added into mgt", *rid, (int32_t) vgId, rid); } streamMutexUnlock(&gMetaRefMgt.mutex); return code; } +void metaRefMgtRemove(int64_t* pRefId) { + streamMutexLock(&gMetaRefMgt.mutex); + + int32_t code = taosHashRemove(gMetaRefMgt.pTable, &pRefId, sizeof(pRefId)); + taosMemoryFree(pRefId); + streamMutexUnlock(&gMetaRefMgt.mutex); +} + int32_t streamMetaOpenTdb(SStreamMeta* pMeta) { if (tdbOpen(pMeta->path, 16 * 1024, 1, &pMeta->db, 0, 0, NULL) < 0) { stError("vgId:%d open file:%s failed, stream meta open failed", pMeta->vgId, pMeta->path); @@ -434,7 +428,6 @@ int32_t streamMetaOpen(const char* path, void* ahandle, FTaskBuild buildTaskFn, pMeta->closeFlag = false; stInfo("vgId:%d open stream meta succ, latest checkpoint:%" PRId64 ", stage:%" PRId64, vgId, pMeta->chkpId, stage); - pMeta->rid = taosAddRef(streamMetaId, pMeta); // set the attribute when running on Linux OS TdThreadRwlockAttr attr; @@ -452,20 +445,25 @@ int32_t streamMetaOpen(const char* path, void* ahandle, FTaskBuild buildTaskFn, code = taosThreadRwlockAttrDestroy(&attr); TSDB_CHECK_CODE(code, lino, _err); + code = bkdMgtCreate(tpath, (SBkdMgt**)&pMeta->bkdChkptMgt); + TSDB_CHECK_CODE(code, lino, _err); + + code = taosThreadMutexInit(&pMeta->backendMutex, NULL); + TSDB_CHECK_CODE(code, lino, _err); + + // add refId at the end of initialization function + pMeta->rid = taosAddRef(streamMetaRefPool, pMeta); + int64_t* pRid = taosMemoryMalloc(sizeof(int64_t)); TSDB_CHECK_NULL(pRid, code, lino, _err, terrno); memcpy(pRid, &pMeta->rid, sizeof(pMeta->rid)); + code = metaRefMgtAdd(pMeta->vgId, pRid); TSDB_CHECK_CODE(code, lino, _err); code = createMetaHbInfo(pRid, &pMeta->pHbInfo); - TSDB_CHECK_CODE(code, lino, _err); - - code = bkdMgtCreate(tpath, (SBkdMgt**)&pMeta->bkdChkptMgt); - TSDB_CHECK_CODE(code, lino, _err); - code = taosThreadMutexInit(&pMeta->backendMutex, NULL); TSDB_CHECK_CODE(code, lino, _err); *p = pMeta; @@ -527,17 +525,28 @@ void streamMetaClear(SStreamMeta* pMeta) { // remove all existed tasks in this vnode void* pIter = NULL; while ((pIter = taosHashIterate(pMeta->pTasksMap, pIter)) != NULL) { - SStreamTask* p = *(SStreamTask**)pIter; + int64_t refId = *(int64_t*)pIter; + SStreamTask* p = taosAcquireRef(streamTaskRefPool, refId); + if (p == NULL) { + continue; + } // release the ref by timer if (p->info.delaySchedParam != 0 && p->info.fillHistory == 0) { // one more ref in timer - stDebug("s-task:%s stop schedTimer, and (before) desc ref:%d", p->id.idStr, p->refCnt); + stDebug("s-task:%s stop schedTimer", p->id.idStr); streamTmrStop(p->schedInfo.pDelayTimer); p->info.delaySchedParam = 0; - streamMetaReleaseTask(pMeta, p); } - streamMetaReleaseTask(pMeta, p); + int32_t code = taosRemoveRef(streamTaskRefPool, refId); + if (code) { + stError("vgId:%d remove task refId failed, refId:%" PRId64, pMeta->vgId, refId); + } + + code = taosReleaseRef(streamTaskRefPool, refId); + if (code) { + stError("vgId:%d failed to release refId:%" PRId64, pMeta->vgId, refId); + } } if (pMeta->streamBackendRid != 0) { @@ -567,9 +576,9 @@ void streamMetaClose(SStreamMeta* pMeta) { if (pMeta == NULL) { return; } - int32_t code = taosRemoveRef(streamMetaId, pMeta->rid); + int32_t code = taosRemoveRef(streamMetaRefPool, pMeta->rid); if (code) { - stError("vgId:%d failed to remove ref:%" PRId64 ", code:%s", pMeta->vgId, pMeta->rid, tstrerror(code)); + stError("vgId:%d failed to remove meta ref:%" PRId64 ", code:%s", pMeta->vgId, pMeta->rid, tstrerror(code)); } } @@ -656,9 +665,16 @@ int32_t streamMetaSaveTask(SStreamMeta* pMeta, SStreamTask* pTask) { code = tdbTbUpsert(pMeta->pTaskDb, id, STREAM_TASK_KEY_LEN, buf, len, pMeta->txn); if (code != TSDB_CODE_SUCCESS) { code = terrno; - stError("s-task:%s vgId:%d task meta save to disk failed, code:%s", pTask->id.idStr, vgId, tstrerror(terrno)); + stError("s-task:%s vgId:%d refId:%" PRId64 " task meta save to disk failed, remove ref, code:%s", pTask->id.idStr, + vgId, pTask->id.refId, tstrerror(code)); + + int64_t refId = pTask->id.refId; + int32_t ret = taosRemoveRef(streamTaskRefPool, pTask->id.refId); + if (ret != 0) { + stError("s-task:0x%x failed to remove ref, refId:%"PRId64, (int32_t) id[1], refId); + } } else { - stDebug("s-task:%s vgId:%d task meta save to disk", pTask->id.idStr, vgId); + stDebug("s-task:%s vgId:%d refId:%" PRId64 " task meta save to disk", pTask->id.idStr, vgId, pTask->id.refId); } taosMemoryFree(buf); @@ -683,34 +699,54 @@ int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTa *pAdded = false; int32_t code = 0; + int64_t refId = 0; STaskId id = streamTaskGetTaskId(pTask); void* p = taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); + if (p != NULL) { stDebug("s-task:%" PRIx64 " already exist in meta, no need to register", id.taskId); + tFreeStreamTask(pTask); return code; } if ((code = pMeta->buildTaskFn(pMeta->ahandle, pTask, ver)) != 0) { + tFreeStreamTask(pTask); return code; } p = taosArrayPush(pMeta->pTaskList, &pTask->id); if (p == NULL) { stError("s-task:0x%" PRIx64 " failed to register task into meta-list, code: out of memory", id.taskId); + tFreeStreamTask(pTask); return terrno; } - code = taosHashPut(pMeta->pTasksMap, &id, sizeof(id), &pTask, POINTER_BYTES); + pTask->id.refId = refId = taosAddRef(streamTaskRefPool, pTask); + code = taosHashPut(pMeta->pTasksMap, &id, sizeof(id), &pTask->id.refId, sizeof(int64_t)); if (code) { stError("s-task:0x%" PRIx64 " failed to register task into meta-list, code: out of memory", id.taskId); + + int32_t ret = taosRemoveRef(streamTaskRefPool, refId); + if (ret != 0) { + stError("s-task:0x%x failed to remove ref, refId:%"PRId64, (int32_t) id.taskId, refId); + } return code; } if ((code = streamMetaSaveTask(pMeta, pTask)) != 0) { + int32_t ret = taosRemoveRef(streamTaskRefPool, refId); + if (ret) { + stError("vgId:%d remove task refId failed, refId:%" PRId64, pMeta->vgId, refId); + } return code; } if ((code = streamMetaCommit(pMeta)) != 0) { + int32_t ret = taosRemoveRef(streamTaskRefPool, refId); + if (ret) { + stError("vgId:%d remove task refId failed, refId:%" PRId64, pMeta->vgId, refId); + } + return code; } @@ -718,6 +754,9 @@ int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTa int32_t val = atomic_add_fetch_32(&pMeta->numOfStreamTasks, 1); } + // enable the scheduler for stream tasks + streamSetupScheduleTrigger(pTask); + *pAdded = true; return code; } @@ -733,16 +772,72 @@ int32_t streamMetaGetNumOfTasks(SStreamMeta* pMeta) { } int32_t streamMetaAcquireTaskNoLock(SStreamMeta* pMeta, int64_t streamId, int32_t taskId, SStreamTask** pTask) { - STaskId id = {.streamId = streamId, .taskId = taskId}; - SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); - if (ppTask == NULL || streamTaskShouldStop(*ppTask)) { - *pTask = NULL; + QRY_PARAM_CHECK(pTask); + STaskId id = {.streamId = streamId, .taskId = taskId}; + int64_t* pTaskRefId = (int64_t*)taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); + if (pTaskRefId == NULL) { + return TSDB_CODE_STREAM_TASK_NOT_EXIST; + } + + SStreamTask* p = taosAcquireRef(streamTaskRefPool, *pTaskRefId); + if (p == NULL) { + stDebug("s-task:%x failed to acquire task refId:%"PRId64", may have been destoried", taskId, *pTaskRefId); + return TSDB_CODE_STREAM_TASK_NOT_EXIST; + } + + if (p->id.refId != *pTaskRefId) { + stFatal("s-task:%x inconsistent refId, task refId:%" PRId64 " try acquire:%" PRId64, taskId, *pTaskRefId, + p->id.refId); + int32_t ret = taosReleaseRef(streamTaskRefPool, *pTaskRefId); + if (ret) { + stError("s-task:0x%x failed to release task refId:%" PRId64, taskId, *pTaskRefId); + } + return TSDB_CODE_STREAM_TASK_NOT_EXIST; } - int32_t ref = atomic_add_fetch_32(&(*ppTask)->refCnt, 1); - stTrace("s-task:%s acquire task, ref:%d", (*ppTask)->id.idStr, ref); - *pTask = *ppTask; + if (streamTaskShouldStop(p)) { + stDebug("s-task:%s is stopped, failed to acquire it now", p->id.idStr); + int32_t ret = taosReleaseRef(streamTaskRefPool, *pTaskRefId); + if (ret) { + stError("s-task:0x%x failed to release task refId:%" PRId64, taskId, *pTaskRefId); + } + return TSDB_CODE_STREAM_TASK_NOT_EXIST; + } + + stDebug("s-task:%s acquire task, refId:%" PRId64, p->id.idStr, p->id.refId); + *pTask = p; + return TSDB_CODE_SUCCESS; +} + +int32_t streamMetaAcquireTaskUnsafe(SStreamMeta* pMeta, STaskId* pId, SStreamTask** pTask) { + QRY_PARAM_CHECK(pTask); + int64_t* pTaskRefId = (int64_t*)taosHashGet(pMeta->pTasksMap, pId, sizeof(*pId)); + + if (pTaskRefId == NULL) { + return TSDB_CODE_STREAM_TASK_NOT_EXIST; + } + + SStreamTask* p = taosAcquireRef(streamTaskRefPool, *pTaskRefId); + if (p == NULL) { + stDebug("s-task:%" PRIx64 " failed to acquire task refId:%" PRId64 ", may have been destoried", pId->taskId, + *pTaskRefId); + return TSDB_CODE_STREAM_TASK_NOT_EXIST; + } + + if (p->id.refId != *pTaskRefId) { + stFatal("s-task:%" PRIx64 " inconsistent refId, task refId:%" PRId64 " try acquire:%" PRId64, pId->taskId, + *pTaskRefId, p->id.refId); + int32_t ret = taosReleaseRef(streamTaskRefPool, *pTaskRefId); + if (ret) { + stError("s-task:0x%" PRIx64 " failed to release task refId:%" PRId64, pId->taskId, *pTaskRefId); + } + + return TSDB_CODE_STREAM_TASK_NOT_EXIST; + } + + stDebug("s-task:%s acquire task, refId:%" PRId64, p->id.idStr, p->id.refId); + *pTask = p; return TSDB_CODE_SUCCESS; } @@ -753,28 +848,17 @@ int32_t streamMetaAcquireTask(SStreamMeta* pMeta, int64_t streamId, int32_t task return code; } -int32_t streamMetaAcquireOneTask(SStreamTask* pTask) { - int32_t ref = atomic_add_fetch_32(&pTask->refCnt, 1); - stTrace("s-task:%s acquire task, ref:%d", pTask->id.idStr, ref); - return ref; -} - void streamMetaReleaseTask(SStreamMeta* UNUSED_PARAM(pMeta), SStreamTask* pTask) { if (pTask == NULL) { return; } int32_t taskId = pTask->id.taskId; - int32_t ref = atomic_sub_fetch_32(&pTask->refCnt, 1); - - // not safe to use the pTask->id.idStr, since pTask may be released by other threads when print logs. - if (ref > 0) { - stTrace("s-task:0x%x release task, ref:%d", taskId, ref); - } else if (ref == 0) { - stTrace("s-task:0x%x all refs are gone, free it", taskId); - tFreeStreamTask(pTask); - } else if (ref < 0) { - stError("task ref is invalid, ref:%d, 0x%x", ref, taskId); + int64_t refId = pTask->id.refId; + stDebug("s-task:0x%x release task, refId:%" PRId64, taskId, pTask->id.refId); + int32_t ret = taosReleaseRef(streamTaskRefPool, pTask->id.refId); + if (ret) { + stError("s-task:0x%x failed to release task refId:%" PRId64, taskId, refId); } } @@ -812,13 +896,10 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t t int32_t code = 0; STaskId id = {.streamId = streamId, .taskId = taskId}; - // pre-delete operation streamMetaWLock(pMeta); - SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); - if (ppTask) { - pTask = *ppTask; - + code = streamMetaAcquireTaskUnsafe(pMeta, &id, &pTask); + if (code == 0) { // desc the paused task counter if (streamTaskShouldPause(pTask)) { int32_t num = atomic_sub_fetch_32(&pMeta->numOfPausedTasks, 1); @@ -830,43 +911,9 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t t if (code) { stError("s-task:0x%" PRIx64 " failed to handle dropping event async, code:%s", id.taskId, tstrerror(code)); } - } else { - stDebug("vgId:%d failed to find the task:0x%x, it may be dropped already", vgId, taskId); - streamMetaWUnLock(pMeta); - return 0; - } - streamMetaWUnLock(pMeta); + stDebug("s-task:0x%x vgId:%d set task status:dropping and start to unregister it", taskId, vgId); - stDebug("s-task:0x%x vgId:%d set task status:dropping and start to unregister it", taskId, vgId); - - while (1) { - int32_t timerActive = 0; - - streamMetaRLock(pMeta); - ppTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); - if (ppTask) { - // to make sure check status will not start the check downstream status when we start to check timerActive count. - streamMutexLock(&pTask->taskCheckInfo.checkInfoLock); - timerActive = (*ppTask)->status.timerActive; - streamMutexUnlock(&pTask->taskCheckInfo.checkInfoLock); - } - streamMetaRUnLock(pMeta); - - if (timerActive > 0) { - taosMsleep(100); - stDebug("s-task:0x%" PRIx64 " wait for quit from timer", id.taskId); - } else { - break; - } - } - - // let's do delete of stream task - streamMetaWLock(pMeta); - - ppTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); - if (ppTask) { - pTask = *ppTask; // it is a fill-history task, remove the related stream task's id that points to it if (pTask->info.fillHistory == 0) { int32_t ret = atomic_sub_fetch_32(&pMeta->numOfStreamTasks, 1); @@ -884,21 +931,22 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t t if (sizeInList != size) { stError("vgId:%d tasks number not consistent in list:%d and map:%d, ", vgId, sizeInList, size); } - streamMetaWUnLock(pMeta); - - int32_t numOfTmr = pTask->status.timerActive; - if (numOfTmr != 0) { - stError("s-task:%s vgId:%d invalid timer Active record:%d, internal error", pTask->id.idStr, vgId, numOfTmr); - } if (pTask->info.delaySchedParam != 0 && pTask->info.fillHistory == 0) { - stDebug("s-task:%s stop schedTimer, and (before) desc ref:%d", pTask->id.idStr, pTask->refCnt); + stDebug("s-task:%s stop schedTimer", pTask->id.idStr); streamTmrStop(pTask->schedInfo.pDelayTimer); pTask->info.delaySchedParam = 0; - streamMetaReleaseTask(pMeta, pTask); + } + + + int64_t refId = pTask->id.refId; + int32_t ret = taosRemoveRef(streamTaskRefPool, refId); + if (ret != 0) { + stError("s-task:0x%x failed to remove ref, refId:%"PRId64, (int32_t) id.taskId, refId); } streamMetaReleaseTask(pMeta, pTask); + streamMetaWUnLock(pMeta); } else { stDebug("vgId:%d failed to find the task:0x%x, it may have been dropped already", vgId, taskId); streamMetaWUnLock(pMeta); @@ -1008,13 +1056,13 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) { return; } + vgId = pMeta->vgId; pRecycleList = taosArrayInit(4, sizeof(STaskId)); if (pRecycleList == NULL) { stError("vgId:%d failed prepare load all tasks, code:out of memory", vgId); return; } - vgId = pMeta->vgId; stInfo("vgId:%d load stream tasks from meta files", vgId); code = tdbTbcOpen(pMeta->pTaskDb, &pCur, NULL); @@ -1058,9 +1106,9 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) { if (pTask->status.taskStatus == TASK_STATUS__DROPPING) { int32_t taskId = pTask->id.taskId; - tFreeStreamTask(pTask); - STaskId id = streamTaskGetTaskId(pTask); + + tFreeStreamTask(pTask); void* px = taosArrayPush(pRecycleList, &id); if (px == NULL) { stError("s-task:0x%x failed record the task into recycle list due to out of memory", taskId); @@ -1096,13 +1144,25 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) { continue; } - if (taosHashPut(pMeta->pTasksMap, &id, sizeof(id), &pTask, POINTER_BYTES) != 0) { - stError("s-task:0x%x failed to put into hashTable, code:%s, continue", pTask->id.taskId, tstrerror(terrno)); - void* px = taosArrayPop(pMeta->pTaskList); - tFreeStreamTask(pTask); + pTask->id.refId = taosAddRef(streamTaskRefPool, pTask); + + if (taosHashPut(pMeta->pTasksMap, &id, sizeof(id), &pTask->id.refId, sizeof(int64_t)) != 0) { + int64_t refId = pTask->id.refId; + stError("s-task:0x%x failed to put into hashTable, code:%s, remove task ref, refId:%" PRId64 " continue", + pTask->id.taskId, tstrerror(terrno), refId); + + void* px = taosArrayPop(pMeta->pTaskList); + int32_t ret = taosRemoveRef(streamTaskRefPool, refId); + if (ret != 0) { + stError("s-task:0x%x failed to remove ref, refId:%" PRId64, (int32_t)id.taskId, refId); + } continue; } + // enable the scheduler for stream tasks after acquire the task RefId. + streamSetupScheduleTrigger(pTask); + + stInfo("s-task:0x%x vgId:%d set refId:%"PRId64, (int32_t) id.taskId, vgId, pTask->id.refId); if (pTask->info.fillHistory == 0) { int32_t val = atomic_add_fetch_32(&pMeta->numOfStreamTasks, 1); } @@ -1138,72 +1198,22 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) { } } -bool streamMetaTaskInTimer(SStreamMeta* pMeta) { - bool inTimer = false; - streamMetaRLock(pMeta); - - void* pIter = NULL; - while (1) { - pIter = taosHashIterate(pMeta->pTasksMap, pIter); - if (pIter == NULL) { - break; - } - - SStreamTask* pTask = *(SStreamTask**)pIter; - if (pTask->status.timerActive >= 1) { - stDebug("s-task:%s in timer, blocking tasks in vgId:%d restart, set closing again", pTask->id.idStr, pMeta->vgId); - int32_t code = streamTaskStop(pTask); - if (code) { - stError("s-task:%s failed to stop task, code:%s", pTask->id.idStr, tstrerror(code)); - } - inTimer = true; - } - } - - streamMetaRUnLock(pMeta); - return inTimer; -} - void streamMetaNotifyClose(SStreamMeta* pMeta) { int32_t vgId = pMeta->vgId; int64_t startTs = 0; int32_t sendCount = 0; - streamMetaGetHbSendInfo(pMeta->pHbInfo, &startTs, &sendCount); + streamMetaGetHbSendInfo(pMeta->pHbInfo, &startTs, &sendCount); stInfo("vgId:%d notify all stream tasks that current vnode is closing. isLeader:%d startHb:%" PRId64 ", totalHb:%d", vgId, (pMeta->role == NODE_ROLE_LEADER), startTs, sendCount); // wait for the stream meta hb function stopping streamMetaWaitForHbTmrQuit(pMeta); - - streamMetaWLock(pMeta); - pMeta->closeFlag = true; - void* pIter = NULL; - while (1) { - pIter = taosHashIterate(pMeta->pTasksMap, pIter); - if (pIter == NULL) { - break; - } - - SStreamTask* pTask = *(SStreamTask**)pIter; - stDebug("vgId:%d s-task:%s set task closing flag", vgId, pTask->id.idStr); - int32_t code = streamTaskStop(pTask); - if (code) { - stError("vgId:%d failed to stop task:0x%x, code:%s", vgId, pTask->id.taskId, tstrerror(code)); - } - } - - streamMetaWUnLock(pMeta); stDebug("vgId:%d start to check all tasks for closing", vgId); int64_t st = taosGetTimestampMs(); - while (streamMetaTaskInTimer(pMeta)) { - stDebug("vgId:%d some tasks in timer, wait for 100ms and recheck", pMeta->vgId); - taosMsleep(100); - } - streamMetaRLock(pMeta); SArray* pTaskList = NULL; @@ -1211,14 +1221,34 @@ void streamMetaNotifyClose(SStreamMeta* pMeta) { if (code != TSDB_CODE_SUCCESS) { } - streamMetaRUnLock(pMeta); + int32_t numOfTasks = taosArrayGetSize(pTaskList); + for (int32_t i = 0; i < numOfTasks; ++i) { + SStreamTaskId* pTaskId = taosArrayGet(pTaskList, i); + SStreamTask* pTask = NULL; + + code = streamMetaAcquireTaskNoLock(pMeta, pTaskId->streamId, pTaskId->taskId, &pTask); + if (code != TSDB_CODE_SUCCESS) { + continue; + } - if (pTaskList != NULL) { - taosArrayDestroy(pTaskList); + int64_t refId = pTask->id.refId; + int32_t ret = streamTaskStop(pTask); + if (ret) { + stError("s-task:0x%x failed to stop task, code:%s", pTaskId->taskId, tstrerror(ret)); + } + + streamMetaReleaseTask(pMeta, pTask); + ret = taosRemoveRef(streamTaskRefPool, refId); + if (ret) { + stError("vgId:%d failed to remove task:0x%x, refId:%" PRId64, pMeta->vgId, pTaskId->taskId, refId); + } } - int64_t el = taosGetTimestampMs() - st; - stDebug("vgId:%d all stream tasks are not in timer, continue close, elapsed time:%" PRId64 " ms", pMeta->vgId, el); + taosArrayDestroy(pTaskList); + + double el = (taosGetTimestampMs() - st) / 1000.0; + stDebug("vgId:%d stop all %d task(s) completed, elapsed time:%.2f Sec.", pMeta->vgId, numOfTasks, el); + streamMetaRUnLock(pMeta); } void streamMetaStartHb(SStreamMeta* pMeta) { @@ -1228,12 +1258,12 @@ void streamMetaStartHb(SStreamMeta* pMeta) { return; } + *pRid = pMeta->rid; int32_t code = metaRefMgtAdd(pMeta->vgId, pRid); if (code) { return; } - *pRid = pMeta->rid; streamMetaHbToMnode(pRid, NULL); } @@ -1308,13 +1338,15 @@ bool streamMetaAllTasksReady(const SStreamMeta* pMeta) { for (int32_t i = 0; i < num; ++i) { SStreamTaskId* pId = taosArrayGet(pMeta->pTaskList, i); STaskId id = {.streamId = pId->streamId, .taskId = pId->taskId}; - SStreamTask** ppTask = taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); - if (ppTask == NULL) { - continue; - } + SStreamTask* pTask = NULL; + int32_t code = streamMetaAcquireTaskUnsafe((SStreamMeta*)pMeta, &id, &pTask); - if ((*ppTask)->status.downstreamReady == 0) { - return false; + if (code == 0) { + if (pTask->status.downstreamReady == 0) { + streamMetaReleaseTask((SStreamMeta*)pMeta, pTask); + return false; + } + streamMetaReleaseTask((SStreamMeta*)pMeta, pTask); } } @@ -1331,10 +1363,13 @@ int32_t streamMetaResetTaskStatus(SStreamMeta* pMeta) { for (int32_t i = 0; i < numOfTasks; ++i) { SStreamTaskId* pTaskId = taosArrayGet(pMeta->pTaskList, i); - - STaskId id = {.streamId = pTaskId->streamId, .taskId = pTaskId->taskId}; - SStreamTask** pTask = taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); - streamTaskResetStatus(*pTask); + STaskId id = {.streamId = pTaskId->streamId, .taskId = pTaskId->taskId}; + SStreamTask* pTask = NULL; + int32_t code = streamMetaAcquireTaskUnsafe(pMeta, &id, &pTask); + if (code == 0) { + streamTaskResetStatus(pTask); + streamMetaReleaseTask(pMeta, pTask); + } } return 0; @@ -1343,7 +1378,7 @@ int32_t streamMetaResetTaskStatus(SStreamMeta* pMeta) { void streamMetaAddIntoUpdateTaskList(SStreamMeta* pMeta, SStreamTask* pTask, SStreamTask* pHTask, int32_t transId, int64_t startTs) { const char* id = pTask->id.idStr; - int32_t vgId = pTask->pMeta->vgId; + int32_t vgId = pMeta->vgId; int32_t code = 0; // keep the already updated info diff --git a/source/libs/stream/src/streamSched.c b/source/libs/stream/src/streamSched.c index cdaa603e386..c5c4a8cc343 100644 --- a/source/libs/stream/src/streamSched.c +++ b/source/libs/stream/src/streamSched.c @@ -20,15 +20,18 @@ static void streamTaskResumeHelper(void* param, void* tmrId); static void streamTaskSchedHelper(void* param, void* tmrId); void streamSetupScheduleTrigger(SStreamTask* pTask) { - int64_t delaySchema = pTask->info.delaySchedParam; - if (delaySchema != 0 && pTask->info.fillHistory == 0) { - int32_t ref = streamMetaAcquireOneTask(pTask); - stDebug("s-task:%s setup scheduler trigger, ref:%d delay:%" PRId64 " ms", pTask->id.idStr, ref, - pTask->info.delaySchedParam); - - streamTmrStart(streamTaskSchedHelper, (int32_t)delaySchema, pTask, streamTimer, &pTask->schedInfo.pDelayTimer, - pTask->pMeta->vgId, "sched-tmr"); - pTask->schedInfo.status = TASK_TRIGGER_STATUS__INACTIVE; + int64_t delayParam = pTask->info.delaySchedParam; + if (delayParam != 0 && pTask->info.fillHistory == 0) { + int64_t* pTaskRefId = NULL; + int32_t code = streamTaskAllocRefId(pTask, &pTaskRefId); + if (code == 0) { + stDebug("s-task:%s refId:%" PRId64 " enable the scheduler trigger, delay:%" PRId64, pTask->id.idStr, + pTask->id.refId, delayParam); + + streamTmrStart(streamTaskSchedHelper, (int32_t)delayParam, pTaskRefId, streamTimer, + &pTask->schedInfo.pDelayTimer, pTask->pMeta->vgId, "sched-tmr"); + pTask->schedInfo.status = TASK_TRIGGER_STATUS__INACTIVE; + } } } @@ -75,49 +78,67 @@ void streamTaskClearSchedIdleInfo(SStreamTask* pTask) { pTask->status.schedIdleT void streamTaskSetIdleInfo(SStreamTask* pTask, int32_t idleTime) { pTask->status.schedIdleTime = idleTime; } void streamTaskResumeInFuture(SStreamTask* pTask) { - int32_t ref = atomic_add_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:%s task should idle, add into timer to retry in %dms, ref:%d", pTask->id.idStr, - pTask->status.schedIdleTime, ref); + stDebug("s-task:%s task should idle, add into timer to retry in %dms", pTask->id.idStr, + pTask->status.schedIdleTime); // add one ref count for task - int32_t unusedRetRef = streamMetaAcquireOneTask(pTask); - streamTmrStart(streamTaskResumeHelper, pTask->status.schedIdleTime, pTask, streamTimer, &pTask->schedInfo.pIdleTimer, - pTask->pMeta->vgId, "resume-task-tmr"); + int64_t* pTaskRefId = NULL; + int32_t code = streamTaskAllocRefId(pTask, &pTaskRefId); + if (code == 0) { + streamTmrStart(streamTaskResumeHelper, pTask->status.schedIdleTime, pTaskRefId, streamTimer, + &pTask->schedInfo.pIdleTimer, pTask->pMeta->vgId, "resume-task-tmr"); + } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void streamTaskResumeHelper(void* param, void* tmrId) { - SStreamTask* pTask = (SStreamTask*)param; + int32_t code = 0; + int64_t taskRefId = *(int64_t*)param; + SStreamTask* pTask = taosAcquireRef(streamTaskRefPool, taskRefId); + if (pTask == NULL) { + stError("invalid task rid:%" PRId64 " failed to acquired stream-task at %s", taskRefId, __func__); + streamTaskFreeRefId(param); + return; + } + SStreamTaskId* pId = &pTask->id; SStreamTaskState p = streamTaskGetStatus(pTask); - int32_t code = 0; if (p.state == TASK_STATUS__DROPPING || p.state == TASK_STATUS__STOP) { int8_t status = streamTaskSetSchedStatusInactive(pTask); TAOS_UNUSED(status); - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:%s status:%s not resume task, ref:%d", pId->idStr, p.name, ref); - + stDebug("s-task:%s status:%s not resume task", pId->idStr, p.name); streamMetaReleaseTask(pTask->pMeta, pTask); + streamTaskFreeRefId(param); return; } code = streamTaskSchedTask(pTask->pMsgCb, pTask->info.nodeId, pId->streamId, pId->taskId, STREAM_EXEC_T_RESUME_TASK); - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); if (code) { - stError("s-task:%s sched task failed, code:%s, ref:%d", pId->idStr, tstrerror(code), ref); + stError("s-task:%s sched task failed, code:%s", pId->idStr, tstrerror(code)); } else { - stDebug("trigger to resume s-task:%s after idled for %dms, ref:%d", pId->idStr, pTask->status.schedIdleTime, ref); + stDebug("trigger to resume s-task:%s after idled for %dms", pId->idStr, pTask->status.schedIdleTime); // release the task ref count streamTaskClearSchedIdleInfo(pTask); - streamMetaReleaseTask(pTask->pMeta, pTask); } + + streamMetaReleaseTask(pTask->pMeta, pTask); + streamTaskFreeRefId(param); } void streamTaskSchedHelper(void* param, void* tmrId) { - SStreamTask* pTask = (void*)param; + int64_t taskRefId = *(int64_t*)param; + SStreamTask* pTask = taosAcquireRef(streamTaskRefPool, taskRefId); + if (pTask == NULL) { + stError("invalid task rid:%" PRId64 " failed to acquired stream-task at %s", taskRefId, __func__); + streamTaskFreeRefId(param); + return; + } + + stDebug("s-task:%s acquire task, refId:%"PRId64, pTask->id.idStr, pTask->id.refId); + const char* id = pTask->id.idStr; int32_t nextTrigger = (int32_t)pTask->info.delaySchedParam; int32_t vgId = pTask->pMeta->vgId; @@ -125,8 +146,18 @@ void streamTaskSchedHelper(void* param, void* tmrId) { int8_t status = atomic_load_8(&pTask->schedInfo.status); stTrace("s-task:%s in scheduler, trigger status:%d, next:%dms", id, status, nextTrigger); - if (streamTaskShouldStop(pTask) || streamTaskShouldPause(pTask)) { + if (streamTaskShouldStop(pTask)) { stDebug("s-task:%s should stop, jump out of schedTimer", id); + streamMetaReleaseTask(pTask->pMeta, pTask); + streamTaskFreeRefId(param); + return; + } + + if (streamTaskShouldPause(pTask)) { + stDebug("s-task:%s is paused, recheck in %.2fs", id, nextTrigger/1000.0); + streamTmrStart(streamTaskSchedHelper, nextTrigger, param, streamTimer, &pTask->schedInfo.pDelayTimer, vgId, + "sched-run-tmr"); + streamMetaReleaseTask(pTask->pMeta, pTask); return; } @@ -171,6 +202,7 @@ void streamTaskSchedHelper(void* param, void* tmrId) { } _end: - streamTmrStart(streamTaskSchedHelper, nextTrigger, pTask, streamTimer, &pTask->schedInfo.pDelayTimer, vgId, + streamTmrStart(streamTaskSchedHelper, nextTrigger, param, streamTimer, &pTask->schedInfo.pDelayTimer, vgId, "sched-run-tmr"); + streamMetaReleaseTask(pTask->pMeta, pTask); } diff --git a/source/libs/stream/src/streamStartHistory.c b/source/libs/stream/src/streamStartHistory.c index 4d7bf2ba875..54a8929123c 100644 --- a/source/libs/stream/src/streamStartHistory.c +++ b/source/libs/stream/src/streamStartHistory.c @@ -15,6 +15,7 @@ #include "streamInt.h" #include "streamsm.h" +#include "tref.h" #include "trpc.h" #include "ttimer.h" #include "wal.h" @@ -24,7 +25,7 @@ #define SCANHISTORY_IDLE_TICK ((SCANHISTORY_MAX_IDLE_TIME * 1000) / SCANHISTORY_IDLE_TIME_SLICE) typedef struct SLaunchHTaskInfo { - SStreamMeta* pMeta; + int64_t metaRid; STaskId id; STaskId hTaskId; } SLaunchHTaskInfo; @@ -87,21 +88,15 @@ void streamExecScanHistoryInFuture(SStreamTask* pTask, int32_t idleDuration) { numOfTicks = SCANHISTORY_IDLE_TICK; } - // add ref for task - SStreamTask* p = NULL; - int32_t code = streamMetaAcquireTask(pTask->pMeta, pTask->id.streamId, pTask->id.taskId, &p); - if (p == NULL || code != 0) { - stError("s-task:0x%x failed to acquire task, status:%s, not exec scan-history data", pTask->id.taskId, - streamTaskGetStatus(pTask).name); - return; - } - pTask->schedHistoryInfo.numOfTicks = numOfTicks; - int32_t ref = atomic_add_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:%s scan-history resumed in %.2fs, ref:%d", pTask->id.idStr, numOfTicks * 0.1, ref); - streamTmrStart(doExecScanhistoryInFuture, SCANHISTORY_IDLE_TIME_SLICE, pTask, streamTimer, - &pTask->schedHistoryInfo.pTimer, vgId, "history-task"); + stDebug("s-task:%s scan-history resumed in %.2fs", pTask->id.idStr, numOfTicks * 0.1); + int64_t* pTaskRefId = NULL; + int32_t ret = streamTaskAllocRefId(pTask, &pTaskRefId); + if (ret == 0) { + streamTmrStart(doExecScanhistoryInFuture, SCANHISTORY_IDLE_TIME_SLICE, pTaskRefId, streamTimer, + &pTask->schedHistoryInfo.pTimer, vgId, "history-task"); + } } int32_t streamTaskStartScanHistory(SStreamTask* pTask) { @@ -220,42 +215,32 @@ int32_t streamLaunchFillHistoryTask(SStreamTask* pTask) { // Set the execution conditions, including the query time window and the version range streamMetaRLock(pMeta); - SStreamTask** pHTask = taosHashGet(pMeta->pTasksMap, &pTask->hTaskInfo.id, sizeof(pTask->hTaskInfo.id)); + SStreamTask* pHisTask = NULL; + code = streamMetaAcquireTaskUnsafe(pMeta, &pTask->hTaskInfo.id, &pHisTask); streamMetaRUnLock(pMeta); - if (pHTask != NULL) { // it is already added into stream meta store. - SStreamTask* pHisTask = NULL; - code = streamMetaAcquireTask(pMeta, hStreamId, hTaskId, &pHisTask); - if (pHisTask == NULL) { - stDebug("s-task:%s failed acquire and start fill-history task, it may have been dropped/stopped", idStr); - code = streamMetaAddTaskLaunchResult(pMeta, hStreamId, hTaskId, pExecInfo->checkTs, pExecInfo->readyTs, false); + if (code == 0) { // it is already added into stream meta store. + if (pHisTask->status.downstreamReady == 1) { // it's ready now, do nothing + stDebug("s-task:%s fill-history task is ready, no need to check downstream", pHisTask->id.idStr); + code = streamMetaAddTaskLaunchResult(pMeta, hStreamId, hTaskId, pExecInfo->checkTs, pExecInfo->readyTs, true); if (code) { stError("s-task:%s failed to record start task status, code:%s", idStr, tstrerror(code)); } - } else { - if (pHisTask->status.downstreamReady == 1) { // it's ready now, do nothing - stDebug("s-task:%s fill-history task is ready, no need to check downstream", pHisTask->id.idStr); - code = streamMetaAddTaskLaunchResult(pMeta, hStreamId, hTaskId, pExecInfo->checkTs, pExecInfo->readyTs, true); - if (code) { - stError("s-task:%s failed to record start task status, code:%s", idStr, tstrerror(code)); - } - } else { // exist, but not ready, continue check downstream task status - if (pHisTask->pBackend == NULL) { - code = pMeta->expandTaskFn(pHisTask); - if (code != TSDB_CODE_SUCCESS) { - streamMetaAddFailedTaskSelf(pHisTask, now); - stError("s-task:%s failed to expand fill-history task, code:%s", pHisTask->id.idStr, tstrerror(code)); - } - } - - if (code == TSDB_CODE_SUCCESS) { - checkFillhistoryTaskStatus(pTask, pHisTask); + } else { // exist, but not ready, continue check downstream task status + if (pHisTask->pBackend == NULL) { + code = pMeta->expandTaskFn(pHisTask); + if (code != TSDB_CODE_SUCCESS) { + streamMetaAddFailedTaskSelf(pHisTask, now); + stError("s-task:%s failed to expand fill-history task, code:%s", pHisTask->id.idStr, tstrerror(code)); } } - streamMetaReleaseTask(pMeta, pHisTask); + if (code == TSDB_CODE_SUCCESS) { + checkFillhistoryTaskStatus(pTask, pHisTask); + } } + streamMetaReleaseTask(pMeta, pHisTask); return code; } else { return launchNotBuiltFillHistoryTask(pTask); @@ -296,14 +281,14 @@ void notRetryLaunchFillHistoryTask(SStreamTask* pTask, SLaunchHTaskInfo* pInfo, SStreamMeta* pMeta = pTask->pMeta; SHistoryTaskInfo* pHTaskInfo = &pTask->hTaskInfo; - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); +// int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); int32_t code = streamMetaAddTaskLaunchResult(pMeta, pInfo->hTaskId.streamId, pInfo->hTaskId.taskId, 0, now, false); if (code) { stError("s-task:%s failed to record the start task status, code:%s", pTask->id.idStr, tstrerror(code)); } else { - stError("s-task:%s max retry:%d reached, quit from retrying launch related fill-history task:0x%x, ref:%d", - pTask->id.idStr, MAX_RETRY_LAUNCH_HISTORY_TASK, (int32_t)pHTaskInfo->id.taskId, ref); + stError("s-task:%s max retry:%d reached, quit from retrying launch related fill-history task:0x%x", + pTask->id.idStr, MAX_RETRY_LAUNCH_HISTORY_TASK, (int32_t)pHTaskInfo->id.taskId); } pHTaskInfo->id.taskId = 0; @@ -315,9 +300,9 @@ void doRetryLaunchFillHistoryTask(SStreamTask* pTask, SLaunchHTaskInfo* pInfo, i SHistoryTaskInfo* pHTaskInfo = &pTask->hTaskInfo; if (streamTaskShouldStop(pTask)) { // record the failure - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:0x%" PRIx64 " stopped, not launch rel history task:0x%" PRIx64 ", ref:%d", pInfo->id.taskId, - pInfo->hTaskId.taskId, ref); +// int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); + stDebug("s-task:0x%" PRIx64 " stopped, not launch rel history task:0x%" PRIx64, pInfo->id.taskId, + pInfo->hTaskId.taskId); int32_t code = streamMetaAddTaskLaunchResult(pMeta, pInfo->hTaskId.streamId, pInfo->hTaskId.taskId, 0, now, false); if (code) { @@ -336,30 +321,60 @@ void doRetryLaunchFillHistoryTask(SStreamTask* pTask, SLaunchHTaskInfo* pInfo, i } } +static void doCleanup(SStreamTask* pTask, int64_t metaRid, SLaunchHTaskInfo* pInfo) { + SStreamMeta* pMeta = pTask->pMeta; + int32_t vgId = pMeta->vgId; + + streamMetaReleaseTask(pMeta, pTask); + int32_t ret = taosReleaseRef(streamMetaRefPool, metaRid); + if (ret) { + stError("vgId:%d failed to release meta refId:%"PRId64, vgId, metaRid); + } + + if (pInfo != NULL) { + taosMemoryFree(pInfo); + } +} + void tryLaunchHistoryTask(void* param, void* tmrId) { SLaunchHTaskInfo* pInfo = param; - SStreamMeta* pMeta = pInfo->pMeta; + int64_t metaRid = pInfo->metaRid; int64_t now = taosGetTimestampMs(); int32_t code = 0; + SStreamTask* pTask = NULL; + int32_t vgId = 0; + + SStreamMeta* pMeta = taosAcquireRef(streamMetaRefPool, metaRid); + if (pMeta == NULL) { + stError("invalid meta rid:%" PRId64 " failed to acquired stream-meta", metaRid); + taosMemoryFree(pInfo); + return; + } + + vgId = pMeta->vgId; streamMetaWLock(pMeta); - SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &pInfo->id, sizeof(pInfo->id)); - if (ppTask == NULL || *ppTask == NULL) { + code = streamMetaAcquireTaskUnsafe(pMeta, &pInfo->id, &pTask); + if (code != 0) { stError("s-task:0x%x and rel fill-history task:0x%" PRIx64 " all have been destroyed, not launch", (int32_t)pInfo->id.taskId, pInfo->hTaskId.taskId); streamMetaWUnLock(pMeta); + int32_t ret = taosReleaseRef(streamMetaRefPool, metaRid); + if (ret) { + stError("vgId:%d failed to release meta refId:%"PRId64, vgId, metaRid); + } + // already dropped, no need to set the failure info into the stream task meta. taosMemoryFree(pInfo); return; } - if (streamTaskShouldStop(*ppTask)) { - char* p = streamTaskGetStatus(*ppTask).name; - int32_t ref = atomic_sub_fetch_32(&(*ppTask)->status.timerActive, 1); - stDebug("s-task:%s status:%s should stop, quit launch fill-history task timer, retry:%d, ref:%d", - (*ppTask)->id.idStr, p, (*ppTask)->hTaskInfo.retryTimes, ref); + if (streamTaskShouldStop(pTask)) { + char* p = streamTaskGetStatus(pTask).name; + stDebug("s-task:%s status:%s should stop, quit launch fill-history task timer, retry:%d", pTask->id.idStr, p, + pTask->hTaskInfo.retryTimes); streamMetaWUnLock(pMeta); @@ -369,77 +384,54 @@ void tryLaunchHistoryTask(void* param, void* tmrId) { stError("s-task:0x%" PRId64 " failed to record the start task status, code:%s", pInfo->hTaskId.taskId, tstrerror(code)); } - taosMemoryFree(pInfo); + + doCleanup(pTask, metaRid, pInfo); return; } - SStreamTask* pTask = NULL; - code = streamMetaAcquireTaskNoLock(pMeta, pInfo->id.streamId, pInfo->id.taskId, &pTask); - if (code != TSDB_CODE_SUCCESS) { - // todo - } streamMetaWUnLock(pMeta); - if (pTask != NULL) { - SHistoryTaskInfo* pHTaskInfo = &pTask->hTaskInfo; + SHistoryTaskInfo* pHTaskInfo = &pTask->hTaskInfo; + pHTaskInfo->tickCount -= 1; + if (pHTaskInfo->tickCount > 0) { + streamTmrStart(tryLaunchHistoryTask, LAUNCH_HTASK_INTERVAL, pInfo, streamTimer, &pHTaskInfo->pTimer, + pTask->pMeta->vgId, " start-history-task-tmr"); + doCleanup(pTask, metaRid, NULL); + return; + } - pHTaskInfo->tickCount -= 1; - if (pHTaskInfo->tickCount > 0) { - streamTmrStart(tryLaunchHistoryTask, LAUNCH_HTASK_INTERVAL, pInfo, streamTimer, &pHTaskInfo->pTimer, - pTask->pMeta->vgId, " start-history-task-tmr"); - streamMetaReleaseTask(pMeta, pTask); + if (pHTaskInfo->retryTimes > MAX_RETRY_LAUNCH_HISTORY_TASK) { + notRetryLaunchFillHistoryTask(pTask, pInfo, now); + } else { // not reach the limitation yet, let's continue retrying launch related fill-history task. + streamTaskSetRetryInfoForLaunch(pHTaskInfo); + + // abort the timer if intend to stop task + SStreamTask* pHTask = NULL; + code = streamMetaAcquireTask(pMeta, pHTaskInfo->id.streamId, pHTaskInfo->id.taskId, &pHTask); + if (pHTask == NULL) { + doRetryLaunchFillHistoryTask(pTask, pInfo, now); + doCleanup(pTask, metaRid, NULL); return; - } - - if (pHTaskInfo->retryTimes > MAX_RETRY_LAUNCH_HISTORY_TASK) { - notRetryLaunchFillHistoryTask(pTask, pInfo, now); - } else { // not reach the limitation yet, let's continue retrying launch related fill-history task. - streamTaskSetRetryInfoForLaunch(pHTaskInfo); - if (pTask->status.timerActive < 1) { - stError("s-task:%s invalid timerActive recorder:%d, abort timer", pTask->id.idStr, pTask->status.timerActive); - return; - } - - // abort the timer if intend to stop task - SStreamTask* pHTask = NULL; - code = streamMetaAcquireTask(pMeta, pHTaskInfo->id.streamId, pHTaskInfo->id.taskId, &pHTask); - if (pHTask == NULL) { - doRetryLaunchFillHistoryTask(pTask, pInfo, now); - streamMetaReleaseTask(pMeta, pTask); - return; - } else { - if (pHTask->pBackend == NULL) { - code = pMeta->expandTaskFn(pHTask); - if (code != TSDB_CODE_SUCCESS) { - streamMetaAddFailedTaskSelf(pHTask, now); - stError("failed to expand fill-history task:%s, code:%s", pHTask->id.idStr, tstrerror(code)); - } - } - - if (code == TSDB_CODE_SUCCESS) { - checkFillhistoryTaskStatus(pTask, pHTask); - // not in timer anymore - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:0x%x fill-history task launch completed, retry times:%d, ref:%d", (int32_t)pInfo->id.taskId, - pHTaskInfo->retryTimes, ref); + } else { + if (pHTask->pBackend == NULL) { + code = pMeta->expandTaskFn(pHTask); + if (code != TSDB_CODE_SUCCESS) { + streamMetaAddFailedTaskSelf(pHTask, now); + stError("failed to expand fill-history task:%s, code:%s", pHTask->id.idStr, tstrerror(code)); } - streamMetaReleaseTask(pMeta, pHTask); } - } - streamMetaReleaseTask(pMeta, pTask); - } else { - code = streamMetaAddTaskLaunchResult(pMeta, pInfo->hTaskId.streamId, pInfo->hTaskId.taskId, 0, now, false); - if (code) { - stError("s-task:%s failed to record the start task status, code:%s", pTask->id.idStr, tstrerror(code)); + if (code == TSDB_CODE_SUCCESS) { + checkFillhistoryTaskStatus(pTask, pHTask); + // not in timer anymore + stDebug("s-task:0x%x fill-history task launch completed, retry times:%d", (int32_t)pInfo->id.taskId, + pHTaskInfo->retryTimes); + } + streamMetaReleaseTask(pMeta, pHTask); } - - int32_t ref = atomic_sub_fetch_32(&(*ppTask)->status.timerActive, 1); - stError("s-task:0x%x rel fill-history task:0x%" PRIx64 " may have been destroyed, not launch, ref:%d", - (int32_t)pInfo->id.taskId, pInfo->hTaskId.taskId, ref); } - taosMemoryFree(pInfo); + doCleanup(pTask, metaRid, pInfo); } int32_t createHTaskLaunchInfo(SStreamMeta* pMeta, STaskId* pTaskId, int64_t hStreamId, int32_t hTaskId, @@ -455,7 +447,7 @@ int32_t createHTaskLaunchInfo(SStreamMeta* pMeta, STaskId* pTaskId, int64_t hStr (*pInfo)->hTaskId.streamId = hStreamId; (*pInfo)->hTaskId.taskId = hTaskId; - (*pInfo)->pMeta = pMeta; + (*pInfo)->metaRid = pMeta->rid; return TSDB_CODE_SUCCESS; } @@ -485,12 +477,10 @@ int32_t launchNotBuiltFillHistoryTask(SStreamTask* pTask) { // check for the timer if (pTask->hTaskInfo.pTimer == NULL) { - int32_t ref = atomic_add_fetch_32(&pTask->status.timerActive, 1); pTask->hTaskInfo.pTimer = taosTmrStart(tryLaunchHistoryTask, WAIT_FOR_MINIMAL_INTERVAL, pInfo, streamTimer); if (pTask->hTaskInfo.pTimer == NULL) { - ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); - stError("s-task:%s failed to start timer, related fill-history task not launched, ref:%d", idStr, ref); + stError("s-task:%s failed to start timer, related fill-history task not launched", idStr); taosMemoryFree(pInfo); code = streamMetaAddTaskLaunchResult(pMeta, hStreamId, hTaskId, pExecInfo->checkTs, pExecInfo->readyTs, false); @@ -500,18 +490,8 @@ int32_t launchNotBuiltFillHistoryTask(SStreamTask* pTask) { return terrno; } - if (ref < 1) { - stError("s-task:%s invalid timerActive recorder:%d, abort timer", pTask->id.idStr, pTask->status.timerActive); - return TSDB_CODE_STREAM_INTERNAL_ERROR; - } - - stDebug("s-task:%s set timer active flag, ref:%d", idStr, ref); + stDebug("s-task:%s set timer active flag", idStr); } else { // timer exists - if (pTask->status.timerActive < 1) { - stError("s-task:%s invalid timerActive recorder:%d, abort timer", pTask->id.idStr, pTask->status.timerActive); - return TSDB_CODE_STREAM_INTERNAL_ERROR; - } - stDebug("s-task:%s set timer active flag, task timer not null", idStr); streamTmrStart(tryLaunchHistoryTask, WAIT_FOR_MINIMAL_INTERVAL, pInfo, streamTimer, &pTask->hTaskInfo.pTimer, pTask->pMeta->vgId, " start-history-task-tmr"); @@ -590,15 +570,22 @@ int32_t streamTaskSetRangeStreamCalc(SStreamTask* pTask) { } void doExecScanhistoryInFuture(void* param, void* tmrId) { - SStreamTask* pTask = param; + int64_t taskRefId = *(int64_t*) param; + + SStreamTask* pTask = taosAcquireRef(streamTaskRefPool, taskRefId); + if (pTask == NULL) { + stError("invalid task rid:%" PRId64 " failed to acquired stream-task at %s", taskRefId, __func__); + streamTaskFreeRefId(param); + return; + } + pTask->schedHistoryInfo.numOfTicks -= 1; SStreamTaskState p = streamTaskGetStatus(pTask); if (p.state == TASK_STATUS__DROPPING || p.state == TASK_STATUS__STOP) { - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:%s status:%s not start scan-history again, ref:%d", pTask->id.idStr, p.name, ref); - + stDebug("s-task:%s status:%s not start scan-history again", pTask->id.idStr, p.name); streamMetaReleaseTask(pTask->pMeta, pTask); + streamTaskFreeRefId(param); return; } @@ -608,16 +595,19 @@ void doExecScanhistoryInFuture(void* param, void* tmrId) { stError("s-task:%s async start history task failed", pTask->id.idStr); } - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); - stDebug("s-task:%s fill-history:%d start scan-history data, out of tmr, ref:%d", pTask->id.idStr, - pTask->info.fillHistory, ref); - - // release the task. - streamMetaReleaseTask(pTask->pMeta, pTask); + stDebug("s-task:%s fill-history:%d start scan-history data, out of tmr", pTask->id.idStr, + pTask->info.fillHistory); } else { - streamTmrStart(doExecScanhistoryInFuture, SCANHISTORY_IDLE_TIME_SLICE, pTask, streamTimer, - &pTask->schedHistoryInfo.pTimer, pTask->pMeta->vgId, " start-history-task-tmr"); + int64_t* pTaskRefId = NULL; + int32_t code = streamTaskAllocRefId(pTask, &pTaskRefId); + if (code == 0) { + streamTmrStart(doExecScanhistoryInFuture, SCANHISTORY_IDLE_TIME_SLICE, pTaskRefId, streamTimer, + &pTask->schedHistoryInfo.pTimer, pTask->pMeta->vgId, " start-history-task-tmr"); + } } + + streamMetaReleaseTask(pTask->pMeta, pTask); + streamTaskFreeRefId(param); } int32_t doStartScanHistoryTask(SStreamTask* pTask) { diff --git a/source/libs/stream/src/streamStartTask.c b/source/libs/stream/src/streamStartTask.c index 0858f57414a..ed12687e410 100644 --- a/source/libs/stream/src/streamStartTask.c +++ b/source/libs/stream/src/streamStartTask.c @@ -196,19 +196,17 @@ int32_t streamMetaAddTaskLaunchResult(SStreamMeta* pMeta, int64_t streamId, int3 STaskId id = {.streamId = streamId, .taskId = taskId}; int32_t vgId = pMeta->vgId; bool allRsp = true; + SStreamTask* p = NULL; streamMetaWLock(pMeta); - SStreamTask** p = taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); - if (p == NULL) { // task does not exists in current vnode, not record the complete info + int32_t code = streamMetaAcquireTaskUnsafe(pMeta, &id, &p); + if (code != 0) { // task does not exist in current vnode, not record the complete info stError("vgId:%d s-task:0x%x not exists discard the check downstream info", vgId, taskId); streamMetaWUnLock(pMeta); return 0; } - // clear the send consensus-checkpointId flag -// streamMutexLock(&(*p)->lock); -// (*p)->status.sendConsensusChkptId = false; -// streamMutexUnlock(&(*p)->lock); + streamMetaReleaseTask(pMeta, p); if (pStartInfo->startAllTasks != 1) { int64_t el = endTs - startTs; @@ -222,7 +220,7 @@ int32_t streamMetaAddTaskLaunchResult(SStreamMeta* pMeta, int64_t streamId, int3 STaskInitTs initTs = {.start = startTs, .end = endTs, .success = ready}; SHashObj* pDst = ready ? pStartInfo->pReadyTaskSet : pStartInfo->pFailedTaskSet; - int32_t code = taosHashPut(pDst, &id, sizeof(id), &initTs, sizeof(STaskInitTs)); + code = taosHashPut(pDst, &id, sizeof(id), &initTs, sizeof(STaskInitTs)); if (code) { if (code == TSDB_CODE_DUP_KEY) { stError("vgId:%d record start task result failed, s-task:0x%" PRIx64 @@ -296,13 +294,14 @@ void displayStatusInfo(SStreamMeta* pMeta, SHashObj* pTaskSet, bool succ) { while ((pIter = taosHashIterate(pTaskSet, pIter)) != NULL) { STaskInitTs* pInfo = pIter; void* key = taosHashGetKey(pIter, &keyLen); - - SStreamTask** pTask1 = taosHashGet(pMeta->pTasksMap, key, sizeof(STaskId)); - if (pTask1 == NULL) { - stInfo("s-task:0x%x is dropped already, %s", (int32_t)((STaskId*)key)->taskId, succ ? "success" : "failed"); + SStreamTask* pTask = NULL; + int32_t code = streamMetaAcquireTaskUnsafe(pMeta, key, &pTask); + if (code == 0) { + stInfo("s-task:%s level:%d vgId:%d, init:%" PRId64 ", initEnd:%" PRId64 ", %s", pTask->id.idStr, + pTask->info.taskLevel, vgId, pInfo->start, pInfo->end, pInfo->success ? "success" : "failed"); + streamMetaReleaseTask(pMeta, pTask); } else { - stInfo("s-task:%s level:%d vgId:%d, init:%" PRId64 ", initEnd:%" PRId64 ", %s", (*pTask1)->id.idStr, - (*pTask1)->info.taskLevel, vgId, pInfo->start, pInfo->end, pInfo->success ? "success" : "failed"); + stInfo("s-task:0x%x is dropped already, %s", (int32_t)((STaskId*)key)->taskId, succ ? "success" : "failed"); } } } @@ -356,7 +355,7 @@ int32_t streamMetaStartOneTask(SStreamMeta* pMeta, int64_t streamId, int32_t tas // fill-history task can only be launched by related stream tasks. STaskExecStatisInfo* pInfo = &pTask->execInfo; if (pTask->info.fillHistory == 1) { - stError("s-task:0x%x vgId:%d fill-histroy task, not start here", taskId, vgId); + stError("s-task:0x%x vgId:%d fill-history task, not start here", taskId, vgId); streamMetaReleaseTask(pMeta, pTask); return TSDB_CODE_SUCCESS; } @@ -364,6 +363,7 @@ int32_t streamMetaStartOneTask(SStreamMeta* pMeta, int64_t streamId, int32_t tas // the start all tasks procedure may happen to start the newly deployed stream task, and results in the // concurrently start this task by two threads. streamMutexLock(&pTask->lock); + SStreamTaskState status = streamTaskGetStatus(pTask); if (status.state != TASK_STATUS__UNINIT) { stError("s-task:0x%x vgId:%d status:%s not uninit status, not start stream task", taskId, vgId, status.name); @@ -380,6 +380,7 @@ int32_t streamMetaStartOneTask(SStreamMeta* pMeta, int64_t streamId, int32_t tas if(pTask->status.downstreamReady != 0) { stFatal("s-task:0x%x downstream should be not ready, but it ready here, internal error happens", taskId); + streamMetaReleaseTask(pMeta, pTask); return TSDB_CODE_STREAM_INTERNAL_ERROR; } @@ -396,7 +397,7 @@ int32_t streamMetaStartOneTask(SStreamMeta* pMeta, int64_t streamId, int32_t tas streamMutexUnlock(&pTask->lock); } - // concurrently start task may cause the later started task be failed, and also failed to added into meta result. + // concurrently start task may cause the latter started task be failed, and also failed to added into meta result. if (code == TSDB_CODE_SUCCESS) { code = streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_INIT); if (code != TSDB_CODE_SUCCESS) { @@ -417,8 +418,10 @@ int32_t streamMetaStartOneTask(SStreamMeta* pMeta, int64_t streamId, int32_t tas int32_t streamMetaStopAllTasks(SStreamMeta* pMeta) { streamMetaRLock(pMeta); + SArray* pTaskList = NULL; int32_t num = taosArrayGetSize(pMeta->pTaskList); stDebug("vgId:%d stop all %d stream task(s)", pMeta->vgId, num); + if (num == 0) { stDebug("vgId:%d stop all %d task(s) completed, elapsed time:0 Sec.", pMeta->vgId, num); streamMetaRUnLock(pMeta); @@ -428,14 +431,12 @@ int32_t streamMetaStopAllTasks(SStreamMeta* pMeta) { int64_t st = taosGetTimestampMs(); // send hb msg to mnode before closing all tasks. - SArray* pTaskList = NULL; int32_t code = streamMetaSendMsgBeforeCloseTasks(pMeta, &pTaskList); if (code != TSDB_CODE_SUCCESS) { return code; } int32_t numOfTasks = taosArrayGetSize(pTaskList); - for (int32_t i = 0; i < numOfTasks; ++i) { SStreamTaskId* pTaskId = taosArrayGet(pTaskList, i); SStreamTask* pTask = NULL; @@ -445,10 +446,12 @@ int32_t streamMetaStopAllTasks(SStreamMeta* pMeta) { continue; } + int64_t refId = pTask->id.refId; int32_t ret = streamTaskStop(pTask); if (ret) { stError("s-task:0x%x failed to stop task, code:%s", pTaskId->taskId, tstrerror(ret)); } + streamMetaReleaseTask(pMeta, pTask); } @@ -466,6 +469,7 @@ int32_t streamTaskCheckIfReqConsenChkptId(SStreamTask* pTask, int64_t ts) { int32_t vgId = pTask->pMeta->vgId; if (pConChkptInfo->status == TASK_CONSEN_CHKPT_REQ) { + // mark the sending of req consensus checkpoint request. pConChkptInfo->status = TASK_CONSEN_CHKPT_SEND; pConChkptInfo->statusTs = ts; stDebug("s-task:%s vgId:%d set requiring consensus-chkptId in hbMsg, ts:%" PRId64, pTask->id.idStr, @@ -473,6 +477,8 @@ int32_t streamTaskCheckIfReqConsenChkptId(SStreamTask* pTask, int64_t ts) { return 1; } else { int32_t el = (ts - pConChkptInfo->statusTs) / 1000; + + // not recv consensus-checkpoint rsp for 60sec, send it again in hb to mnode if ((pConChkptInfo->status == TASK_CONSEN_CHKPT_SEND) && el > 60) { pConChkptInfo->statusTs = ts; @@ -492,7 +498,7 @@ void streamTaskSetConsenChkptIdRecv(SStreamTask* pTask, int32_t transId, int64_t pInfo->status = TASK_CONSEN_CHKPT_RECV; pInfo->statusTs = ts; - stDebug("s-task:%s set recv consen-checkpointId, transId:%d", pTask->id.idStr, transId); + stInfo("s-task:%s set recv consen-checkpointId, transId:%d", pTask->id.idStr, transId); } void streamTaskSetReqConsenChkptId(SStreamTask* pTask, int64_t ts) { @@ -507,23 +513,24 @@ void streamTaskSetReqConsenChkptId(SStreamTask* pTask, int64_t ts) { } int32_t streamMetaAddFailedTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId) { - int32_t code = TSDB_CODE_SUCCESS; - int64_t now = taosGetTimestampMs(); - int64_t startTs = 0; - bool hasFillhistoryTask = false; - STaskId hId = {0}; + int32_t code = TSDB_CODE_SUCCESS; + int64_t now = taosGetTimestampMs(); + int64_t startTs = 0; + bool hasFillhistoryTask = false; + STaskId hId = {0}; + STaskId id = {.streamId = streamId, .taskId = taskId}; + SStreamTask* pTask = NULL; stDebug("vgId:%d add start failed task:0x%x", pMeta->vgId, taskId); streamMetaRLock(pMeta); - STaskId id = {.streamId = streamId, .taskId = taskId}; - SStreamTask** ppTask = taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); - - if (ppTask != NULL) { - startTs = (*ppTask)->taskCheckInfo.startTs; - hasFillhistoryTask = HAS_RELATED_FILLHISTORY_TASK(*ppTask); - hId = (*ppTask)->hTaskInfo.id; + code = streamMetaAcquireTaskUnsafe(pMeta, &id, &pTask); + if (code == 0) { + startTs = pTask->taskCheckInfo.startTs; + hasFillhistoryTask = HAS_RELATED_FILLHISTORY_TASK(pTask); + hId = pTask->hTaskInfo.id; + streamMetaReleaseTask(pMeta, pTask); streamMetaRUnLock(pMeta); diff --git a/source/libs/stream/src/streamTask.c b/source/libs/stream/src/streamTask.c index b359cdfc81b..35cacc29dc5 100644 --- a/source/libs/stream/src/streamTask.c +++ b/source/libs/stream/src/streamTask.c @@ -211,22 +211,23 @@ int32_t tDecodeStreamTaskId(SDecoder* pDecoder, STaskId* pTaskId) { return 0; } -void tFreeStreamTask(SStreamTask* pTask) { - char* p = NULL; - int32_t taskId = pTask->id.taskId; +void tFreeStreamTask(void* pParam) { + char* p = NULL; + SStreamTask* pTask = pParam; + int32_t taskId = pTask->id.taskId; STaskExecStatisInfo* pStatis = &pTask->execInfo; ETaskStatus status1 = TASK_STATUS__UNINIT; streamMutexLock(&pTask->lock); if (pTask->status.pSM != NULL) { - SStreamTaskState pStatus = streamTaskGetStatus(pTask); - p = pStatus.name; - status1 = pStatus.state; + SStreamTaskState status = streamTaskGetStatus(pTask); + p = status.name; + status1 = status.state; } streamMutexUnlock(&pTask->lock); - stDebug("start to free s-task:0x%x %p, state:%s", taskId, pTask, p); + stDebug("start to free s-task:0x%x %p, state:%s, refId:%" PRId64, taskId, pTask, p, pTask->id.refId); SCheckpointInfo* pCkInfo = &pTask->chkInfo; stDebug("s-task:0x%x task exec summary: create:%" PRId64 ", init:%" PRId64 ", start:%" PRId64 @@ -235,12 +236,6 @@ void tFreeStreamTask(SStreamTask* pTask) { taskId, pStatis->created, pStatis->checkTs, pStatis->readyTs, pStatis->updateCount, pStatis->latestUpdateTs, pCkInfo->checkpointId, pCkInfo->checkpointVer, pCkInfo->nextProcessVer, pStatis->checkpoint); - // remove the ref by timer - while (pTask->status.timerActive > 0) { - stDebug("s-task:%s wait for task stop timer activities, ref:%d", pTask->id.idStr, pTask->status.timerActive); - taosMsleep(100); - } - if (pTask->schedInfo.pDelayTimer != NULL) { streamTmrStop(pTask->schedInfo.pDelayTimer); pTask->schedInfo.pDelayTimer = NULL; @@ -428,8 +423,7 @@ int32_t streamTaskInit(SStreamTask* pTask, SStreamMeta* pMeta, SMsgCb* pMsgCb, i return code; } - pTask->refCnt = 1; - + pTask->id.refId = 0; pTask->inputq.status = TASK_INPUT_STATUS__NORMAL; pTask->outputq.status = TASK_OUTPUT_STATUS__NORMAL; @@ -441,7 +435,6 @@ int32_t streamTaskInit(SStreamTask* pTask, SStreamMeta* pMeta, SMsgCb* pMsgCb, i } pTask->status.schedStatus = TASK_SCHED_STATUS__INACTIVE; - pTask->status.timerActive = 0; code = streamCreateStateMachine(pTask); if (pTask->status.pSM == NULL || code != TSDB_CODE_SUCCESS) { @@ -837,28 +830,31 @@ int8_t streamTaskSetSchedStatusInactive(SStreamTask* pTask) { int32_t streamTaskClearHTaskAttr(SStreamTask* pTask, int32_t resetRelHalt) { int32_t code = 0; SStreamMeta* pMeta = pTask->pMeta; - STaskId sTaskId = {.streamId = pTask->streamTaskId.streamId, .taskId = pTask->streamTaskId.taskId}; + SStreamTask* pStreamTask = NULL; + if (pTask->info.fillHistory == 0) { return code; } - SStreamTask** ppStreamTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &sTaskId, sizeof(sTaskId)); - if (ppStreamTask != NULL) { + code = streamMetaAcquireTaskUnsafe(pMeta, &pTask->streamTaskId, &pStreamTask); + if (code == 0) { stDebug("s-task:%s clear the related stream task:0x%x attr to fill-history task", pTask->id.idStr, - (int32_t)sTaskId.taskId); + (int32_t)pTask->streamTaskId.taskId); - streamMutexLock(&(*ppStreamTask)->lock); - CLEAR_RELATED_FILLHISTORY_TASK((*ppStreamTask)); + streamMutexLock(&(pStreamTask->lock)); + CLEAR_RELATED_FILLHISTORY_TASK(pStreamTask); if (resetRelHalt) { stDebug("s-task:0x%" PRIx64 " set the persistent status attr to be ready, prev:%s, status in sm:%s", - sTaskId.taskId, streamTaskGetStatusStr((*ppStreamTask)->status.taskStatus), - streamTaskGetStatus(*ppStreamTask).name); - (*ppStreamTask)->status.taskStatus = TASK_STATUS__READY; + pTask->streamTaskId.taskId, streamTaskGetStatusStr(pStreamTask->status.taskStatus), + streamTaskGetStatus(pStreamTask).name); + pStreamTask->status.taskStatus = TASK_STATUS__READY; } - code = streamMetaSaveTask(pMeta, *ppStreamTask); - streamMutexUnlock(&(*ppStreamTask)->lock); + code = streamMetaSaveTask(pMeta, pStreamTask); + streamMutexUnlock(&(pStreamTask->lock)); + + streamMetaReleaseTask(pMeta, pStreamTask); } return code; @@ -887,7 +883,7 @@ int32_t streamBuildAndSendDropTaskMsg(SMsgCb* pMsgCb, int32_t vgId, SStreamTaskI } int32_t streamSendChkptReportMsg(SStreamTask* pTask, SCheckpointInfo* pCheckpointInfo, int8_t dropRelHTask) { - int32_t code; + int32_t code = 0; int32_t tlen = 0; int32_t vgId = pTask->pMeta->vgId; const char* id = pTask->id.idStr; @@ -1282,3 +1278,27 @@ const char* streamTaskGetExecType(int32_t type) { return "invalid-exec-type"; } } + +int32_t streamTaskAllocRefId(SStreamTask* pTask, int64_t** pRefId) { + *pRefId = taosMemoryMalloc(sizeof(int64_t)); + if (*pRefId != NULL) { + **pRefId = pTask->id.refId; + int32_t code = metaRefMgtAdd(pTask->pMeta->vgId, *pRefId); + if (code != 0) { + stError("s-task:%s failed to add refId:%" PRId64 " into refId-mgmt, code:%s", pTask->id.idStr, pTask->id.refId, + tstrerror(code)); + } + return code; + } else { + stError("s-task:%s failed to alloc new ref id, code:%s", pTask->id.idStr, tstrerror(terrno)); + return terrno; + } +} + +void streamTaskFreeRefId(int64_t* pRefId) { + if (pRefId == NULL) { + return; + } + + metaRefMgtRemove(pRefId); +} \ No newline at end of file diff --git a/source/libs/stream/src/streamTimer.c b/source/libs/stream/src/streamTimer.c index 0da9acfd1db..848e9c874ee 100644 --- a/source/libs/stream/src/streamTimer.c +++ b/source/libs/stream/src/streamTimer.c @@ -66,15 +66,9 @@ void streamTmrStop(tmr_h tmrId) { } } -int32_t streamCleanBeforeQuitTmr(SStreamTmrInfo* pInfo, SStreamTask* pTask) { +void streamCleanBeforeQuitTmr(SStreamTmrInfo* pInfo, void* param) { pInfo->activeCounter = 0; pInfo->launchChkptId = 0; atomic_store_8(&pInfo->isActive, 0); - - int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); - if (ref < 0) { - stFatal("invalid task timer ref value:%d, %s", ref, pTask->id.idStr); - } - - return ref; + streamTaskFreeRefId(param); } \ No newline at end of file diff --git a/source/libs/sync/CMakeLists.txt b/source/libs/sync/CMakeLists.txt index 6025070cb72..57e1ec63b2f 100644 --- a/source/libs/sync/CMakeLists.txt +++ b/source/libs/sync/CMakeLists.txt @@ -1,6 +1,10 @@ aux_source_directory(src SYNC_SRC) add_library(sync STATIC ${SYNC_SRC}) +if(${TD_DARWIN}) + target_compile_options(sync PRIVATE -Wno-error=deprecated-non-prototype) +endif() + target_link_libraries( sync PUBLIC common diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index efb258d952d..9058b6ecefa 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -234,14 +234,14 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo ", elect-times:%d, as-leader-times:%d, as-assigned-leader-times:%d, cfg-ch-times:%d, hb-slow:%d, hbr-slow:%d, " "aq-items:%d, snaping:%" PRId64 ", replicas:%d, last-cfg:%" PRId64 ", chging:%d, restore:%d, quorum:%d, elect-lc-timer:%" PRId64 ", hb:%" PRId64 - ", buffer:%s, repl-mgrs:%s, members:%s, hb:%s, hb-reply:%s", + ", buffer:%s, repl-mgrs:%s, members:%s, hb:%s, hb-reply:%s, arb-token:%s", pNode->vgId, eventLog, syncStr(pNode->state), currentTerm, pNode->commitIndex, pNode->assignedCommitIndex, appliedIndex, logBeginIndex, logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm, pNode->electNum, pNode->becomeLeaderNum, pNode->becomeAssignedLeaderNum, pNode->configChangeNum, pNode->hbSlowNum, pNode->hbrSlowNum, aqItems, pNode->snapshottingIndex, pNode->replicaNum, pNode->raftCfg.lastConfigIndex, pNode->changing, pNode->restoreFinish, syncNodeDynamicQuorum(pNode), pNode->electTimerLogicClock, pNode->heartbeatTimerLogicClockUser, bufferStatesStr, - replMgrStatesStr, cfgStr, hbTimeStr, hbrTimeStr); + replMgrStatesStr, cfgStr, hbTimeStr, hbrTimeStr, pNode->arbToken); } } diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index d835d12c791..5c79b379eda 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -353,6 +353,7 @@ typedef struct { queue node; void (*freeFunc)(void* arg); int32_t size; + int8_t inited; } STransQueue; /* diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 5ade768d0c2..5f9811ab805 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -127,10 +127,12 @@ typedef struct { typedef struct SCliReq { SReqCtx* ctx; queue q; + queue sendQ; STransMsgType type; uint64_t st; int64_t seq; int32_t sent; //(0: no send, 1: alread sent) + int8_t inSendQ; STransMsg msg; int8_t inRetry; @@ -274,6 +276,8 @@ static FORCE_INLINE void destroyReqAndAhanlde(void* cmsg); static FORCE_INLINE int cliRBChoseIdx(STrans* pInst); static FORCE_INLINE void destroyReqCtx(SReqCtx* ctx); +static FORCE_INLINE void removeReqFromSendQ(SCliReq* pReq); + static int32_t cliHandleState_mayUpdateState(SCliConn* pConn, SCliReq* pReq); static int32_t cliHandleState_mayHandleReleaseResp(SCliConn* conn, STransMsgHead* pHead); static int32_t cliHandleState_mayCreateAhandle(SCliConn* conn, STransMsgHead* pHead, STransMsg* pResp); @@ -453,6 +457,7 @@ static bool filteBySeq(void* key, void* arg) { SFiterArg* targ = arg; SCliReq* pReq = QUEUE_DATA(key, SCliReq, q); if (pReq->seq == targ->seq && pReq->msg.msgType + 1 == targ->msgType) { + removeReqFromSendQ(pReq); return true; } else { return false; @@ -539,6 +544,7 @@ bool filterByQid(void* key, void* arg) { SCliReq* pReq = QUEUE_DATA(key, SCliReq, q); if (pReq->msg.info.qId == *qid) { + removeReqFromSendQ(pReq); return true; } else { return false; @@ -600,7 +606,7 @@ int32_t cliHandleState_mayHandleReleaseResp(SCliConn* conn, STransMsgHead* pHead queue* el = QUEUE_HEAD(&set); QUEUE_REMOVE(el); SCliReq* pReq = QUEUE_DATA(el, SCliReq, q); - + removeReqFromSendQ(pReq); STraceId* trace = &pReq->msg.info.traceId; tGDebug("start to free msg %p", pReq); destroyReqWrapper(pReq, pThrd); @@ -700,6 +706,7 @@ void cliHandleResp(SCliConn* conn) { tstrerror(code)); } } + removeReqFromSendQ(pReq); code = cliBuildRespFromCont(pReq, &resp, pHead); STraceId* trace = &resp.info.traceId; @@ -905,6 +912,10 @@ static void addConnToPool(void* pool, SCliConn* conn) { } SCliThrd* thrd = conn->hostThrd; + if (thrd->quit == true) { + return; + } + cliResetConnTimer(conn); if (conn->list == NULL && conn->dstAddr != NULL) { conn->list = taosHashGet((SHashObj*)pool, conn->dstAddr, strlen(conn->dstAddr)); @@ -1092,6 +1103,7 @@ static int32_t cliCreateConn(SCliThrd* pThrd, SCliConn** pCliConn, char* ip, int transQueueDestroy(&conn->reqsToSend); transQueueDestroy(&conn->reqsSentOut); taosMemoryFree(conn->dstAddr); + taosMemoryFree(conn->ipStr); } tError("failed to create conn, code:%d", code); taosMemoryFree(conn); @@ -1216,6 +1228,7 @@ static FORCE_INLINE void destroyReqInQueue(SCliConn* conn, queue* set, int32_t c QUEUE_REMOVE(el); SCliReq* pReq = QUEUE_DATA(el, SCliReq, q); + removeReqFromSendQ(pReq); notifyAndDestroyReq(conn, pReq, code); } } @@ -1246,8 +1259,8 @@ static void cliHandleException(SCliConn* conn) { } cliDestroyAllQidFromThrd(conn); - QUEUE_REMOVE(&conn->q); - if (conn->list) { + if (pThrd->quit == false && conn->list) { + QUEUE_REMOVE(&conn->q); conn->list->totalSize -= 1; conn->list = NULL; } @@ -1273,7 +1286,8 @@ static void cliHandleException(SCliConn* conn) { bool filterToRmReq(void* h, void* arg) { queue* el = h; SCliReq* pReq = QUEUE_DATA(el, SCliReq, q); - if (pReq->sent == 1 && REQUEST_NO_RESP(&pReq->msg)) { + if (pReq->sent == 1 && pReq->inSendQ == 0 && REQUEST_NO_RESP(&pReq->msg)) { + removeReqFromSendQ(pReq); return true; } return false; @@ -1300,12 +1314,18 @@ static void cliBatchSendCb(uv_write_t* req, int status) { SCliThrd* pThrd = conn->hostThrd; STrans* pInst = pThrd->pInst; + while (!QUEUE_IS_EMPTY(&wrapper->node)) { + queue* h = QUEUE_HEAD(&wrapper->node); + SCliReq* pReq = QUEUE_DATA(h, SCliReq, sendQ); + removeReqFromSendQ(pReq); + } freeWReqToWQ(&conn->wq, wrapper); int32_t ref = transUnrefCliHandle(conn); if (ref <= 0) { return; } + cliConnRmReqs(conn); if (status != 0) { tDebug("%s conn %p failed to send msg since %s", CONN_GET_INST_LABEL(conn), conn, uv_err_name(status)); @@ -1340,6 +1360,9 @@ bool cliConnMayAddUserInfo(SCliConn* pConn, STransMsgHead** ppHead, int32_t* msg } STransMsgHead* pHead = *ppHead; STransMsgHead* tHead = taosMemoryCalloc(1, *msgLen + sizeof(pInst->user)); + if (tHead == NULL) { + return false; + } memcpy((char*)tHead, (char*)pHead, TRANS_MSG_OVERHEAD); memcpy((char*)tHead + TRANS_MSG_OVERHEAD, pInst->user, sizeof(pInst->user)); @@ -1398,6 +1421,10 @@ int32_t cliBatchSend(SCliConn* pConn, int8_t direct) { int j = 0; int32_t batchLimit = 64; + + queue reqToSend; + QUEUE_INIT(&reqToSend); + while (!transQueueEmpty(&pConn->reqsToSend)) { queue* h = transQueuePop(&pConn->reqsToSend); SCliReq* pCliMsg = QUEUE_DATA(h, SCliReq, q); @@ -1422,6 +1449,10 @@ int32_t cliBatchSend(SCliConn* pConn, int8_t direct) { if (cliConnMayAddUserInfo(pConn, &pHead, &msgLen)) { content = transContFromHead(pHead); contLen = transContLenFromMsg(msgLen); + } else { + if (pConn->userInited == 0) { + return terrno; + } } if (pHead->comp == 0) { pHead->noResp = REQUEST_NO_RESP(pReq) ? 1 : 0; @@ -1447,30 +1478,51 @@ int32_t cliBatchSend(SCliConn* pConn, int8_t direct) { wb[j++] = uv_buf_init((char*)pHead, msgLen); totalLen += msgLen; - pCliMsg->sent = 1; pCliMsg->seq = pConn->seq; + pCliMsg->sent = 1; STraceId* trace = &pCliMsg->msg.info.traceId; tGDebug("%s conn %p %s is sent to %s, local info:%s, seq:%" PRId64 ", sid:%" PRId64 "", CONN_GET_INST_LABEL(pConn), pConn, TMSG_INFO(pReq->msgType), pConn->dst, pConn->src, pConn->seq, pReq->info.qId); + transQueuePush(&pConn->reqsSentOut, &pCliMsg->q); + QUEUE_INIT(&pCliMsg->sendQ); + QUEUE_PUSH(&reqToSend, &pCliMsg->sendQ); + + pCliMsg->inSendQ = 1; if (j >= batchLimit) { break; } } transRefCliHandle(pConn); uv_write_t* req = allocWReqFromWQ(&pConn->wq, pConn); + if (req == NULL) { tError("%s conn %p failed to send msg since %s", CONN_GET_INST_LABEL(pConn), pConn, tstrerror(terrno)); + while (!QUEUE_IS_EMPTY(&reqToSend)) { + queue* h = QUEUE_HEAD(&reqToSend); + SCliReq* pCliMsg = QUEUE_DATA(h, SCliReq, sendQ); + removeReqFromSendQ(pCliMsg); + } + transRefCliHandle(pConn); return terrno; } + SWReqsWrapper* pWreq = req->data; + + QUEUE_MOVE(&reqToSend, &pWreq->node); tDebug("%s conn %p start to send msg, batch size:%d, len:%d", CONN_GET_INST_LABEL(pConn), pConn, j, totalLen); int32_t ret = uv_write(req, (uv_stream_t*)pConn->stream, wb, j, cliBatchSendCb); if (ret != 0) { tError("%s conn %p failed to send msg since %s", CONN_GET_INST_LABEL(pConn), pConn, uv_err_name(ret)); + while (!QUEUE_IS_EMPTY(&pWreq->node)) { + queue* h = QUEUE_HEAD(&pWreq->node); + SCliReq* pCliMsg = QUEUE_DATA(h, SCliReq, sendQ); + removeReqFromSendQ(pCliMsg); + } + freeWReqToWQ(&pConn->wq, req->data); code = TSDB_CODE_THIRDPARTY_ERROR; TAOS_UNUSED(transUnrefCliHandle(pConn)); @@ -2182,11 +2234,21 @@ static void cliAsyncCb(uv_async_t* handle) { if (pThrd->stopMsg != NULL) cliHandleQuit(pThrd, pThrd->stopMsg); } +static FORCE_INLINE void removeReqFromSendQ(SCliReq* pReq) { + if (pReq == NULL || pReq->inSendQ == 0) { + return; + } + QUEUE_REMOVE(&pReq->sendQ); + pReq->inSendQ = 0; +} + static FORCE_INLINE void destroyReq(void* arg) { SCliReq* pReq = arg; if (pReq == NULL) { return; } + + removeReqFromSendQ(pReq); STraceId* trace = &pReq->msg.info.traceId; tGDebug("free memory:%p, free ctx: %p", pReq, pReq->ctx); @@ -2961,6 +3023,7 @@ int32_t cliNotifyCb(SCliConn* pConn, SCliReq* pReq, STransMsg* pResp) { STrans* pInst = pThrd->pInst; if (pReq != NULL) { + removeReqFromSendQ(pReq); if (pResp->code != TSDB_CODE_SUCCESS) { if (cliMayRetry(pConn, pReq, pResp)) { return TSDB_CODE_RPC_ASYNC_IN_PROCESS; @@ -3114,7 +3177,7 @@ static int32_t transInitMsg(void* pInstRef, const SEpSet* pEpSet, STransMsg* pRe if (ctx != NULL) pCtx->userCtx = *ctx; pCliReq = taosMemoryCalloc(1, sizeof(SCliReq)); - if (pReq == NULL) { + if (pCliReq == NULL) { TAOS_CHECK_GOTO(terrno, NULL, _exception); } @@ -3183,6 +3246,7 @@ int32_t transSendRequestWithId(void* pInstRef, const SEpSet* pEpSet, STransMsg* return TSDB_CODE_INVALID_PARA; } int32_t code = 0; + int8_t transIdInited = 0; STrans* pInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)pInstRef); if (pInst == NULL) { @@ -3200,6 +3264,7 @@ int32_t transSendRequestWithId(void* pInstRef, const SEpSet* pEpSet, STransMsg* if (exh == NULL) { TAOS_CHECK_GOTO(TSDB_CODE_RPC_MODULE_QUIT, NULL, _exception); } + transIdInited = 1; pReq->info.handle = (void*)(*transpointId); pReq->info.qId = *transpointId; @@ -3216,9 +3281,6 @@ int32_t transSendRequestWithId(void* pInstRef, const SEpSet* pEpSet, STransMsg* return (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code); } - // if (pReq->msgType == TDMT_SCH_DROP_TASK) { - // TAOS_UNUSED(transReleaseCliHandle(pReq->info.handle)); - // } transReleaseExHandle(transGetRefMgt(), *transpointId); transReleaseExHandle(transGetInstMgt(), (int64_t)pInstRef); return 0; @@ -3226,6 +3288,7 @@ int32_t transSendRequestWithId(void* pInstRef, const SEpSet* pEpSet, STransMsg* _exception: transFreeMsg(pReq->pCont); pReq->pCont = NULL; + if (transIdInited) transReleaseExHandle(transGetRefMgt(), *transpointId); transReleaseExHandle(transGetInstMgt(), (int64_t)pInstRef); tError("failed to send request since %s", tstrerror(code)); @@ -3641,6 +3704,7 @@ bool filterTimeoutReq(void* key, void* arg) { if (pReq->msg.info.qId == 0 && !REQUEST_NO_RESP(&pReq->msg) && pReq->ctx) { int64_t elapse = ((st - pReq->st) / 1000000); if (listArg && elapse >= listArg->pInst->readTimeout) { + removeReqFromSendQ(pReq); return true; } else { return false; diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 35ca6678b87..66bd4a08f3b 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -423,6 +423,7 @@ int32_t transQueueInit(STransQueue* wq, void (*freeFunc)(void* arg)) { QUEUE_INIT(&wq->node); wq->freeFunc = (void (*)(void*))freeFunc; wq->size = 0; + wq->inited = 1; return 0; } void transQueuePush(STransQueue* q, void* arg) { @@ -497,6 +498,7 @@ void transQueueRemove(STransQueue* q, void* e) { bool transQueueEmpty(STransQueue* q) { return q->size == 0 ? true : false; } void transQueueClear(STransQueue* q) { + if (q->inited == 0) return; while (!QUEUE_IS_EMPTY(&q->node)) { queue* h = QUEUE_HEAD(&q->node); QUEUE_REMOVE(h); diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index 5723f2ff237..d02bfb8281e 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -1289,8 +1289,8 @@ static FORCE_INLINE SSvrConn* createConn(void* hThrd) { int32_t code = 0; SWorkThrd* pThrd = hThrd; int32_t lino; - - SSvrConn* pConn = (SSvrConn*)taosMemoryCalloc(1, sizeof(SSvrConn)); + int8_t wqInited = 0; + SSvrConn* pConn = (SSvrConn*)taosMemoryCalloc(1, sizeof(SSvrConn)); if (pConn == NULL) { TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _end); } @@ -1340,6 +1340,7 @@ static FORCE_INLINE SSvrConn* createConn(void* hThrd) { code = initWQ(&pConn->wq); TAOS_CHECK_GOTO(code, &lino, _end); + wqInited = 1; // init client handle pConn->pTcp = (uv_tcp_t*)taosMemoryMalloc(sizeof(uv_tcp_t)); @@ -1372,7 +1373,7 @@ static FORCE_INLINE SSvrConn* createConn(void* hThrd) { transDestroyBuffer(&pConn->readBuf); taosHashCleanup(pConn->pQTable); taosMemoryFree(pConn->pTcp); - destroyWQ(&pConn->wq); + if (wqInited) destroyWQ(&pConn->wq); taosMemoryFree(pConn->buf); taosMemoryFree(pConn); pConn = NULL; diff --git a/source/libs/transport/test/CMakeLists.txt b/source/libs/transport/test/CMakeLists.txt index e68e93c48e3..f30dfc56a2d 100644 --- a/source/libs/transport/test/CMakeLists.txt +++ b/source/libs/transport/test/CMakeLists.txt @@ -1,5 +1,6 @@ add_executable(transportTest "") add_executable(transUT "") +add_executable(transUT2 "") add_executable(svrBench "") add_executable(cliBench "") add_executable(httpBench "") @@ -9,7 +10,11 @@ target_sources(transUT "transUT.cpp" ) -target_sources(transportTest +target_sources(transUT2 + PRIVATE + "transUT2.cpp" +) +target_sources(transportTest PRIVATE "transportTests.cpp" ) @@ -25,16 +30,16 @@ target_sources(cliBench target_sources(httpBench PRIVATE "http_test.c" -) +) -target_include_directories(transportTest +target_include_directories(transportTest PUBLIC - "${TD_SOURCE_DIR}/include/libs/transport" + "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) -target_link_libraries (transportTest - os +target_link_libraries(transportTest + os util common gtest_main @@ -42,67 +47,81 @@ target_link_libraries (transportTest function ) -target_link_libraries (transUT - os +target_link_libraries(transUT + os util common gtest_main - transport + transport ) target_include_directories(transUT PUBLIC - "${TD_SOURCE_DIR}/include/libs/transport" + "${TD_SOURCE_DIR}/include/libs/transport" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) + +target_link_libraries(transUT2 + os + util + common + gtest_main + transport +) + +target_include_directories(transUT2 + PUBLIC + "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(svrBench PUBLIC - "${TD_SOURCE_DIR}/include/libs/transport" + "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) -target_link_libraries (svrBench - os +target_link_libraries(svrBench + os util common gtest_main - transport + transport ) target_include_directories(cliBench PUBLIC - "${TD_SOURCE_DIR}/include/libs/transport" + "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(httpBench PUBLIC - "${TD_SOURCE_DIR}/include/libs/transport" + "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) -target_link_libraries (cliBench - os +target_link_libraries(cliBench + os util common gtest_main - transport + transport ) target_link_libraries(httpBench - os + os util common gtest_main - transport + transport ) add_test( - NAME transUT - COMMAND transUT + NAME transUT + COMMAND transUT ) add_test( - NAME transUtilUt + NAME transUtilUt COMMAND transportTest ) diff --git a/source/libs/transport/test/cliBench.c b/source/libs/transport/test/cliBench.c index e73c209d558..0a5cb5d1bb2 100644 --- a/source/libs/transport/test/cliBench.c +++ b/source/libs/transport/test/cliBench.c @@ -53,8 +53,6 @@ static void processResponse(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { tDebug("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen, pMsg->code); - if (pEpSet) pInfo->epSet = *pEpSet; - rpcFreeCont(pMsg->pCont); tsem_post(&pInfo->rspSem); } @@ -72,12 +70,12 @@ static void *sendRequest(void *param) { rpcMsg.pCont = rpcMallocCont(pInfo->msgSize); rpcMsg.contLen = pInfo->msgSize; rpcMsg.info.ahandle = pInfo; - rpcMsg.info.noResp = 1; + rpcMsg.info.noResp = 0; rpcMsg.msgType = 1; tDebug("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num); rpcSendRequest(pInfo->pRpc, &pInfo->epSet, &rpcMsg, NULL); if (pInfo->num % 20000 == 0) tInfo("thread:%d, %d requests have been sent", pInfo->index, pInfo->num); - // tsem_wait(&pInfo->rspSem); + tsem_wait(&pInfo->rspSem); } tDebug("thread:%d, it is over", pInfo->index); @@ -110,17 +108,15 @@ int main(int argc, char *argv[]) { rpcInit.label = "APP"; rpcInit.numOfThreads = 1; rpcInit.cfp = processResponse; - rpcInit.sessions = 100; + rpcInit.sessions = 1000; rpcInit.idleTime = tsShellActivityTimer * 1000; rpcInit.user = "michael"; rpcInit.connType = TAOS_CONN_CLIENT; - rpcInit.connLimitNum = 10; - rpcInit.connLimitLock = 1; - rpcInit.shareConnLimit = 16 * 1024; + rpcInit.shareConnLimit = tsShareConnLimit; rpcInit.supportBatch = 1; - - rpcDebugFlag = 135; + rpcInit.compressSize = -1; + rpcDebugFlag = 143; for (int i = 1; i < argc; ++i) { if (strcmp(argv[i], "-p") == 0 && i < argc - 1) { } else if (strcmp(argv[i], "-i") == 0 && i < argc - 1) { @@ -139,6 +135,10 @@ int main(int argc, char *argv[]) { } else if (strcmp(argv[i], "-u") == 0 && i < argc - 1) { } else if (strcmp(argv[i], "-k") == 0 && i < argc - 1) { } else if (strcmp(argv[i], "-spi") == 0 && i < argc - 1) { + } else if (strcmp(argv[i], "-l") == 0 && i < argc - 1) { + rpcInit.shareConnLimit = atoi(argv[++i]); + } else if (strcmp(argv[i], "-c") == 0 && i < argc - 1) { + rpcInit.compressSize = atoi(argv[++i]); } else if (strcmp(argv[i], "-d") == 0 && i < argc - 1) { rpcDebugFlag = atoi(argv[++i]); } else { @@ -150,13 +150,15 @@ int main(int argc, char *argv[]) { printf(" [-n requests]: number of requests per thread, default is:%d\n", numOfReqs); printf(" [-u user]: user name for the connection, default is:%s\n", rpcInit.user); printf(" [-d debugFlag]: debug flag, default:%d\n", rpcDebugFlag); + printf(" [-c compressSize]: compress size, default:%d\n", tsCompressMsgSize); + printf(" [-l shareConnLimit]: share conn limit, default:%d\n", tsShareConnLimit); printf(" [-h help]: print out this help\n\n"); exit(0); } } initLogEnv(); - taosVersionStrToInt(version, &(rpcInit.compatibilityVer)); + taosVersionStrToInt(td_version, &(rpcInit.compatibilityVer)); void *pRpc = rpcOpen(&rpcInit); if (pRpc == NULL) { tError("failed to initialize RPC"); @@ -168,18 +170,18 @@ int main(int argc, char *argv[]) { int64_t now = taosGetTimestampUs(); - SInfo *pInfo = (SInfo *)taosMemoryCalloc(1, sizeof(SInfo) * appThreads); - SInfo *p = pInfo; + SInfo **pInfo = (SInfo **)taosMemoryCalloc(1, sizeof(SInfo *) * appThreads); for (int i = 0; i < appThreads; ++i) { - pInfo->index = i; - pInfo->epSet = epSet; - pInfo->numOfReqs = numOfReqs; - pInfo->msgSize = msgSize; - tsem_init(&pInfo->rspSem, 0, 0); - pInfo->pRpc = pRpc; - - taosThreadCreate(&pInfo->thread, NULL, sendRequest, pInfo); - pInfo++; + SInfo *p = taosMemoryCalloc(1, sizeof(SInfo)); + p->index = i; + p->epSet = epSet; + p->numOfReqs = numOfReqs; + p->msgSize = msgSize; + tsem_init(&p->rspSem, 0, 0); + p->pRpc = pRpc; + pInfo[i] = p; + + taosThreadCreate(&p->thread, NULL, sendRequest, pInfo[i]); } do { @@ -192,12 +194,14 @@ int main(int argc, char *argv[]) { tInfo("Performance: %.3f requests per second, msgSize:%d bytes", 1000.0 * numOfReqs * appThreads / usedTime, msgSize); for (int i = 0; i < appThreads; i++) { - SInfo *pInfo = p; - taosThreadJoin(pInfo->thread, NULL); - p++; + SInfo *p = pInfo[i]; + taosThreadJoin(p->thread, NULL); + taosMemoryFree(p); } - int ch = getchar(); - UNUSED(ch); + taosMemoryFree(pInfo); + + // int ch = getchar(); + // UNUSED(ch); taosCloseLog(); diff --git a/source/libs/transport/test/svrBench.c b/source/libs/transport/test/svrBench.c index 6408e4dcb2d..44299d86a3a 100644 --- a/source/libs/transport/test/svrBench.c +++ b/source/libs/transport/test/svrBench.c @@ -76,23 +76,6 @@ void *processShellMsg(void *arg) { for (int i = 0; i < numOfMsgs; ++i) { taosGetQitem(qall, (void **)&pRpcMsg); - - if (pDataFile != NULL) { - if (taosWriteFile(pDataFile, pRpcMsg->pCont, pRpcMsg->contLen) < 0) { - tInfo("failed to write data file, reason:%s", strerror(errno)); - } - } - } - - if (commit >= 2) { - num += numOfMsgs; - // if (taosFsync(pDataFile) < 0) { - // tInfo("failed to flush data to file, reason:%s", strerror(errno)); - //} - - if (num % 10000 == 0) { - tInfo("%d request have been written into disk", num); - } } taosResetQitems(qall); @@ -107,16 +90,7 @@ void *processShellMsg(void *arg) { rpcMsg.code = 0; rpcSendResponse(&rpcMsg); - void *handle = pRpcMsg->info.handle; taosFreeQitem(pRpcMsg); - //{ - // SRpcMsg nRpcMsg = {0}; - // nRpcMsg.pCont = rpcMallocCont(msgSize); - // nRpcMsg.contLen = msgSize; - // nRpcMsg.info.handle = handle; - // nRpcMsg.code = TSDB_CODE_CTG_NOT_READY; - // rpcSendResponse(&nRpcMsg); - //} } taosUpdateItemSize(qinfo.queue, numOfMsgs); @@ -149,12 +123,13 @@ int main(int argc, char *argv[]) { rpcInit.localPort = 7000; memcpy(rpcInit.localFqdn, "localhost", strlen("localhost")); rpcInit.label = "SER"; - rpcInit.numOfThreads = 1; + rpcInit.numOfThreads = 10; rpcInit.cfp = processRequestMsg; rpcInit.idleTime = 2 * 1500; - taosVersionStrToInt(version, &(rpcInit.compatibilityVer)); + taosVersionStrToInt(td_version, &(rpcInit.compatibilityVer)); rpcDebugFlag = 131; + rpcInit.compressSize = -1; for (int i = 1; i < argc; ++i) { if (strcmp(argv[i], "-p") == 0 && i < argc - 1) { @@ -190,7 +165,7 @@ int main(int argc, char *argv[]) { rpcInit.connType = TAOS_CONN_SERVER; initLogEnv(); - taosVersionStrToInt(version, &(rpcInit.compatibilityVer)); + taosVersionStrToInt(td_version, &(rpcInit.compatibilityVer)); void *pRpc = rpcOpen(&rpcInit); if (pRpc == NULL) { tError("failed to start RPC server"); @@ -205,8 +180,8 @@ int main(int argc, char *argv[]) { if (pDataFile == NULL) tInfo("failed to open data file, reason:%s", strerror(errno)); } - int32_t numOfAthread = 5; - multiQ = taosMemoryMalloc(sizeof(numOfAthread)); + int32_t numOfAthread = 1; + multiQ = taosMemoryMalloc(sizeof(MultiThreadQhandle)); multiQ->numOfThread = numOfAthread; multiQ->qhandle = (STaosQueue **)taosMemoryMalloc(sizeof(STaosQueue *) * numOfAthread); multiQ->qset = (STaosQset **)taosMemoryMalloc(sizeof(STaosQset *) * numOfAthread); @@ -221,11 +196,6 @@ int main(int argc, char *argv[]) { threads[i].idx = i; taosThreadCreate(&(threads[i].thread), NULL, processShellMsg, (void *)&threads[i]); } - // qhandle = taosOpenQueue(); - // qset = taosOpenQset(); - // taosAddIntoQset(qset, qhandle, NULL); - - // processShellMsg(); if (pDataFile != NULL) { taosCloseFile(&pDataFile); diff --git a/source/libs/transport/test/transUT.cpp b/source/libs/transport/test/transUT.cpp index e57d01bcbc7..8e396d59d77 100644 --- a/source/libs/transport/test/transUT.cpp +++ b/source/libs/transport/test/transUT.cpp @@ -54,8 +54,9 @@ class Client { rpcInit_.user = (char *)user; rpcInit_.parent = this; rpcInit_.connType = TAOS_CONN_CLIENT; + rpcInit_.shareConnLimit = 200; - taosVersionStrToInt(version, &(rpcInit_.compatibilityVer)); + taosVersionStrToInt(td_version, &(rpcInit_.compatibilityVer)); this->transCli = rpcOpen(&rpcInit_); tsem_init(&this->sem, 0, 0); } @@ -68,7 +69,7 @@ class Client { void Restart(CB cb) { rpcClose(this->transCli); rpcInit_.cfp = cb; - taosVersionStrToInt(version, &(rpcInit_.compatibilityVer)); + taosVersionStrToInt(td_version, &(rpcInit_.compatibilityVer)); this->transCli = rpcOpen(&rpcInit_); } void Stop() { @@ -85,6 +86,14 @@ class Client { SemWait(); *resp = this->resp; } + void sendReq(SRpcMsg *req) { + SEpSet epSet = {0}; + epSet.inUse = 0; + addEpIntoEpSet(&epSet, "127.0.0.1", 7000); + + rpcSendRequest(this->transCli, &epSet, req, NULL); + + } void SendAndRecvNoHandle(SRpcMsg *req, SRpcMsg *resp) { if (req->info.handle != NULL) { rpcReleaseHandle(req->info.handle, TAOS_CONN_CLIENT); @@ -120,7 +129,7 @@ class Server { rpcInit_.cfp = processReq; rpcInit_.user = (char *)user; rpcInit_.connType = TAOS_CONN_SERVER; - taosVersionStrToInt(version, &(rpcInit_.compatibilityVer)); + taosVersionStrToInt(td_version, &(rpcInit_.compatibilityVer)); } void Start() { this->transSrv = rpcOpen(&this->rpcInit_); @@ -160,6 +169,7 @@ static void processReq(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { rpcMsg.contLen = 100; rpcMsg.info = pMsg->info; rpcMsg.code = 0; + rpcFreeCont(pMsg->pCont); rpcSendResponse(&rpcMsg); } @@ -264,6 +274,7 @@ class TransObj { cli->Stop(); } void cliSendAndRecv(SRpcMsg *req, SRpcMsg *resp) { cli->SendAndRecv(req, resp); } + void cliSendReq(SRpcMsg *req) { cli->sendReq(req); } void cliSendAndRecvNoHandle(SRpcMsg *req, SRpcMsg *resp) { cli->SendAndRecvNoHandle(req, resp); } ~TransObj() { @@ -492,15 +503,16 @@ TEST_F(TransEnv, queryExcept) { TEST_F(TransEnv, noResp) { SRpcMsg resp = {0}; SRpcMsg req = {0}; - // for (int i = 0; i < 5; i++) { - // memset(&req, 0, sizeof(req)); - // req.info.noResp = 1; - // req.msgType = 1; - // req.pCont = rpcMallocCont(10); - // req.contLen = 10; - // tr->cliSendAndRecv(&req, &resp); - //} - // taosMsleep(2000); + for (int i = 0; i < 500000; i++) { + memset(&req, 0, sizeof(req)); + req.info.noResp = 1; + req.msgType = 3; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + tr->cliSendReq(&req); + //tr->cliSendAndRecv(&req, &resp); + } + taosMsleep(2000); // no resp } diff --git a/source/libs/transport/test/transUT2.cpp b/source/libs/transport/test/transUT2.cpp new file mode 100644 index 00000000000..54d23b1f64f --- /dev/null +++ b/source/libs/transport/test/transUT2.cpp @@ -0,0 +1,529 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 * or later ("AGPL"), as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include +#include +#include +#include "tdatablock.h" +#include "tglobal.h" +#include "tlog.h" +#include "tmisce.h" +#include "transLog.h" +#include "trpc.h" +#include "tversion.h" +using namespace std; + +const char *label = "APP"; +const char *secret = "secret"; +const char *user = "user"; +const char *ckey = "ckey"; + +class Server; +int port = 7000; +// server process +// server except + +typedef void (*CB)(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); + +static void processContinueSend(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); +static void processReleaseHandleCb(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); +static void processRegisterFailure(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); +static void processReq(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); +// client process; +static void processResp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); +class Client { + public: + void Init(int nThread) { + memcpy(tsTempDir, TD_TMP_DIR_PATH, strlen(TD_TMP_DIR_PATH)); + memset(&rpcInit_, 0, sizeof(rpcInit_)); + rpcInit_.localPort = 0; + rpcInit_.label = (char *)"client"; + rpcInit_.numOfThreads = nThread; + rpcInit_.cfp = processResp; + rpcInit_.user = (char *)user; + rpcInit_.parent = this; + rpcInit_.connType = TAOS_CONN_CLIENT; + rpcInit_.shareConnLimit = 200; + + taosVersionStrToInt(td_version, &(rpcInit_.compatibilityVer)); + this->transCli = rpcOpen(&rpcInit_); + //tsem_init(&this->sem, 0, 0); + } + void SetResp(SRpcMsg *pMsg) { + // set up resp; + this->resp = *pMsg; + } + SRpcMsg *Resp() { return &this->resp; } + + void Restart(CB cb) { + rpcClose(this->transCli); + rpcInit_.cfp = cb; + taosVersionStrToInt(td_version, &(rpcInit_.compatibilityVer)); + this->transCli = rpcOpen(&rpcInit_); + } + void Stop() { + rpcClose(this->transCli); + this->transCli = NULL; + } + + void SendAndRecv(SRpcMsg *req, SRpcMsg *resp) { + SEpSet epSet = {0}; + epSet.inUse = 0; + addEpIntoEpSet(&epSet, "127.0.0.1", 7000); + + rpcSendRequest(this->transCli, &epSet, req, NULL); + SemWait(); + *resp = this->resp; + } + void sendReq(SRpcMsg *req) { + SEpSet epSet = {0}; + epSet.inUse = 0; + addEpIntoEpSet(&epSet, "127.0.0.1", 7000); + + rpcSendRequest(this->transCli, &epSet, req, NULL); + } + + void sendReqWithId(SRpcMsg *req, int64_t *id) { + SEpSet epSet = {0}; + epSet.inUse = 0; + addEpIntoEpSet(&epSet, "127.0.0.1",7000); + rpcSendRequestWithCtx(this->transCli, &epSet, req, id, NULL); + + } + void freeId(int64_t *id) { + rpcFreeConnById(this->transCli, *id); + } + void SendAndRecvNoHandle(SRpcMsg *req, SRpcMsg *resp) { + if (req->info.handle != NULL) { + rpcReleaseHandle(req->info.handle, TAOS_CONN_CLIENT); + req->info.handle = NULL; + } + SendAndRecv(req, resp); + } + + void SemWait() { tsem_wait(&this->sem); } + void SemPost() { tsem_post(&this->sem); } + void Reset() {} + + ~Client() { + if (this->transCli) rpcClose(this->transCli); + } + + private: + tsem_t sem; + SRpcInit rpcInit_; + void *transCli; + SRpcMsg resp; +}; +class Server { + public: + Server() { + memcpy(tsTempDir, TD_TMP_DIR_PATH, strlen(TD_TMP_DIR_PATH)); + memset(&rpcInit_, 0, sizeof(rpcInit_)); + + memcpy(rpcInit_.localFqdn, "localhost", strlen("localhost")); + rpcInit_.localPort = port; + rpcInit_.label = (char *)"server"; + rpcInit_.numOfThreads = 5; + rpcInit_.cfp = processReq; + rpcInit_.user = (char *)user; + rpcInit_.connType = TAOS_CONN_SERVER; + taosVersionStrToInt(td_version, &(rpcInit_.compatibilityVer)); + } + void Start() { + this->transSrv = rpcOpen(&this->rpcInit_); + taosMsleep(1000); + } + void SetSrvContinueSend(CB cb) { + this->Stop(); + rpcInit_.cfp = cb; + this->Start(); + } + void Stop() { + if (this->transSrv == NULL) return; + rpcClose(this->transSrv); + this->transSrv = NULL; + } + void SetSrvSend(void (*cfp)(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet)) { + this->Stop(); + rpcInit_.cfp = cfp; + this->Start(); + } + void Restart() { + this->Stop(); + this->Start(); + } + ~Server() { + if (this->transSrv) rpcClose(this->transSrv); + this->transSrv = NULL; + } + + private: + SRpcInit rpcInit_; + void *transSrv; +}; +static void processReq(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { + SRpcMsg rpcMsg = {0}; + rpcMsg.pCont = rpcMallocCont(100); + rpcMsg.contLen = 100; + rpcMsg.info = pMsg->info; + rpcMsg.code = 0; + rpcFreeCont(pMsg->pCont); + rpcSendResponse(&rpcMsg); +} + +static void processContinueSend(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { + // for (int i = 0; i < 10; i++) { + // SRpcMsg rpcMsg = {0}; + // rpcMsg.pCont = rpcMallocCont(100); + // rpcMsg.contLen = 100; + // rpcMsg.info = pMsg->info; + // rpcMsg.code = 0; + // rpcSendResponse(&rpcMsg); + // } +} +static void processReleaseHandleCb(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { + SRpcMsg rpcMsg = {0}; + rpcMsg.pCont = rpcMallocCont(100); + rpcMsg.contLen = 100; + rpcMsg.info = pMsg->info; + rpcMsg.code = 0; + rpcSendResponse(&rpcMsg); + + rpcReleaseHandle(&pMsg->info, TAOS_CONN_SERVER); +} +static void processRegisterFailure(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { + // { + // SRpcMsg rpcMsg1 = {0}; + // rpcMsg1.pCont = rpcMallocCont(100); + // rpcMsg1.contLen = 100; + // rpcMsg1.info = pMsg->info; + // rpcMsg1.code = 0; + // rpcRegisterBrokenLinkArg(&rpcMsg1); + // } + // taosMsleep(10); + + // SRpcMsg rpcMsg = {0}; + // rpcMsg.pCont = rpcMallocCont(100); + // rpcMsg.contLen = 100; + // rpcMsg.info = pMsg->info; + // rpcMsg.code = 0; + // rpcSendResponse(&rpcMsg); +} +// client process; +static void processResp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { + Client *client = (Client *)parent; + rpcFreeCont(pMsg->pCont); + STraceId *trace = (STraceId *)&pMsg->info.traceId; + tGDebug("received resp %s",tstrerror(pMsg->code)); +} + +static void initEnv() { + dDebugFlag = 143; + vDebugFlag = 0; + mDebugFlag = 143; + cDebugFlag = 0; + jniDebugFlag = 0; + tmrDebugFlag = 143; + uDebugFlag = 143; + rpcDebugFlag = 143; + qDebugFlag = 0; + wDebugFlag = 0; + sDebugFlag = 0; + tsdbDebugFlag = 0; + tsLogEmbedded = 1; + tsAsyncLog = 0; + + std::string path = TD_TMP_DIR_PATH "transport"; + // taosRemoveDir(path.c_str()); + taosMkDir(path.c_str()); + + tstrncpy(tsLogDir, path.c_str(), PATH_MAX); + if (taosInitLog("taosdlog", 1, false) != 0) { + printf("failed to init log file\n"); + } +} + +class TransObj { + public: + TransObj() { + initEnv(); + cli = new Client; + cli->Init(1); + srv = new Server; + srv->Start(); + } + + void RestartCli(CB cb) { + // + cli->Restart(cb); + } + void StopSrv() { + // + srv->Stop(); + } + // call when link broken, and notify query or fetch stop + void SetSrvContinueSend(void (*cfp)(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet)) { + /////// + srv->SetSrvContinueSend(cfp); + } + void RestartSrv() { srv->Restart(); } + void StopCli() { + /////// + cli->Stop(); + } + void cliSendAndRecv(SRpcMsg *req, SRpcMsg *resp) { cli->SendAndRecv(req, resp); } + void cliSendReq(SRpcMsg *req) { cli->sendReq(req); } + + void cliSendReqWithId(SRpcMsg *req, int64_t *id) { cli->sendReqWithId(req, id);} + void cliFreeReqId(int64_t *id) { cli->freeId(id);} + void cliSendAndRecvNoHandle(SRpcMsg *req, SRpcMsg *resp) { cli->SendAndRecvNoHandle(req, resp); } + + ~TransObj() { + delete cli; + delete srv; + } + + private: + Client *cli; + Server *srv; +}; +class TransEnv : public ::testing::Test { + protected: + virtual void SetUp() { + // set up trans obj + tr = new TransObj(); + } + virtual void TearDown() { + // tear down + delete tr; + } + + TransObj *tr = NULL; +}; + +TEST_F(TransEnv, 01sendAndRec) { + // for (int i = 0; i < 10; i++) { + // SRpcMsg req = {0}, resp = {0}; + // req.msgType = 0; + // req.pCont = rpcMallocCont(10); + // req.contLen = 10; + // tr->cliSendAndRecv(&req, &resp); + // assert(resp.code == 0); + // } +} + +TEST_F(TransEnv, 02StopServer) { + // for (int i = 0; i < 1; i++) { + // SRpcMsg req = {0}, resp = {0}; + // req.msgType = 0; + // req.info.ahandle = (void *)0x35; + // req.pCont = rpcMallocCont(10); + // req.contLen = 10; + // tr->cliSendAndRecv(&req, &resp); + // assert(resp.code == 0); + // } + // SRpcMsg req = {0}, resp = {0}; + // req.info.ahandle = (void *)0x35; + // req.msgType = 1; + // req.pCont = rpcMallocCont(10); + // req.contLen = 10; + // tr->StopSrv(); + // // tr->RestartSrv(); + // tr->cliSendAndRecv(&req, &resp); + // assert(resp.code != 0); +} +TEST_F(TransEnv, clientUserDefined) { + // tr->RestartSrv(); + // for (int i = 0; i < 10; i++) { + // SRpcMsg req = {0}, resp = {0}; + // req.msgType = 0; + // req.pCont = rpcMallocCont(10); + // req.contLen = 10; + // tr->cliSendAndRecv(&req, &resp); + // assert(resp.code == 0); + // } + + ////////////////// +} + +TEST_F(TransEnv, cliPersistHandle) { + // SRpcMsg resp = {0}; + // void *handle = NULL; + // for (int i = 0; i < 10; i++) { + // SRpcMsg req = {0}; + // req.info = resp.info; + // req.info.persistHandle = 1; + + // req.msgType = 1; + // req.pCont = rpcMallocCont(10); + // req.contLen = 10; + // tr->cliSendAndRecv(&req, &resp); + // // if (i == 5) { + // // std::cout << "stop server" << std::endl; + // // tr->StopSrv(); + // //} + // // if (i >= 6) { + // // EXPECT_TRUE(resp.code != 0); + // //} + // handle = resp.info.handle; + // } + // rpcReleaseHandle(handle, TAOS_CONN_CLIENT); + // for (int i = 0; i < 10; i++) { + // SRpcMsg req = {0}; + // req.msgType = 1; + // req.pCont = rpcMallocCont(10); + // req.contLen = 10; + // tr->cliSendAndRecv(&req, &resp); + // } + + // taosMsleep(1000); + ////////////////// +} + +TEST_F(TransEnv, srvReleaseHandle) { + // SRpcMsg resp = {0}; + // tr->SetSrvContinueSend(processReleaseHandleCb); + // // tr->Restart(processReleaseHandleCb); + // void *handle = NULL; + // SRpcMsg req = {0}; + // for (int i = 0; i < 1; i++) { + // memset(&req, 0, sizeof(req)); + // req.info = resp.info; + // req.info.persistHandle = 1; + // req.msgType = 1; + // req.pCont = rpcMallocCont(10); + // req.contLen = 10; + // tr->cliSendAndRecv(&req, &resp); + // // tr->cliSendAndRecvNoHandle(&req, &resp); + // EXPECT_TRUE(resp.code == 0); + // } + ////////////////// +} +// reopen later +// TEST_F(TransEnv, cliReleaseHandleExcept) { +// SRpcMsg resp = {0}; +// SRpcMsg req = {0}; +// for (int i = 0; i < 3; i++) { +// memset(&req, 0, sizeof(req)); +// req.info = resp.info; +// req.info.persistHandle = 1; +// req.info.ahandle = (void *)1234; +// req.msgType = 1; +// req.pCont = rpcMallocCont(10); +// req.contLen = 10; +// tr->cliSendAndRecv(&req, &resp); +// if (i == 1) { +// std::cout << "stop server" << std::endl; +// tr->StopSrv(); +// } +// if (i > 1) { +// EXPECT_TRUE(resp.code != 0); +// } +// } +// ////////////////// +//} +TEST_F(TransEnv, srvContinueSend) { + // tr->SetSrvContinueSend(processContinueSend); + // SRpcMsg req = {0}, resp = {0}; + // for (int i = 0; i < 10; i++) { + // // memset(&req, 0, sizeof(req)); + // // memset(&resp, 0, sizeof(resp)); + // // req.msgType = 1; + // // req.pCont = rpcMallocCont(10); + // // req.contLen = 10; + // // tr->cliSendAndRecv(&req, &resp); + // } + // taosMsleep(1000); +} + +TEST_F(TransEnv, srvPersistHandleExcept) { + // tr->SetSrvContinueSend(processContinueSend); + // // tr->SetCliPersistFp(cliPersistHandle); + // SRpcMsg resp = {0}; + // SRpcMsg req = {0}; + // for (int i = 0; i < 5; i++) { + // // memset(&req, 0, sizeof(req)); + // // req.info = resp.info; + // // req.msgType = 1; + // // req.pCont = rpcMallocCont(10); + // // req.contLen = 10; + // // tr->cliSendAndRecv(&req, &resp); + // // if (i > 2) { + // // tr->StopCli(); + // // break; + // //} + // } + // taosMsleep(2000); + // conn broken + // +} +TEST_F(TransEnv, cliPersistHandleExcept) { + // tr->SetSrvContinueSend(processContinueSend); + // SRpcMsg resp = {0}; + // SRpcMsg req = {0}; + // for (int i = 0; i < 5; i++) { + // // memset(&req, 0, sizeof(req)); + // // req.info = resp.info; + // // req.msgType = 1; + // // req.pCont = rpcMallocCont(10); + // // req.contLen = 10; + // // tr->cliSendAndRecv(&req, &resp); + // // if (i > 2) { + // // tr->StopSrv(); + // // break; + // //} + // } + // taosMsleep(2000); + // // conn broken + // +} + +TEST_F(TransEnv, multiCliPersistHandleExcept) { + // conn broken +} +TEST_F(TransEnv, queryExcept) { + //taosMsleep(4 * 1000); +} +TEST_F(TransEnv, idTest) { + SRpcMsg resp = {0}; + SRpcMsg req = {0}; + for (int i = 0; i < 50000; i++) { + memset(&req, 0, sizeof(req)); + req.info.noResp = 0; + req.msgType = 3; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + int64_t id; + tr->cliSendReqWithId(&req, &id); + tr->cliFreeReqId(&id); + } + taosMsleep(1000); + // no resp +} +TEST_F(TransEnv, noResp) { + SRpcMsg resp = {0}; + SRpcMsg req = {0}; + for (int i = 0; i < 500000; i++) { + memset(&req, 0, sizeof(req)); + req.info.noResp = 0; + req.msgType = 3; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + tr->cliSendReq(&req); + //tr->cliSendAndRecv(&req, &resp); + } + taosMsleep(10000); + // no resp +} diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index 3c396f0599d..da26ddae3ae 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -411,14 +411,14 @@ static int32_t walTrimIdxFile(SWal* pWal, int32_t fileIdx) { TAOS_RETURN(TSDB_CODE_SUCCESS); } -void printFileSet(SArray* fileSet) { +static void printFileSet(int32_t vgId, SArray* fileSet, const char* str) { int32_t sz = taosArrayGetSize(fileSet); for (int32_t i = 0; i < sz; i++) { SWalFileInfo* pFileInfo = taosArrayGet(fileSet, i); - wInfo("firstVer:%" PRId64 ", lastVer:%" PRId64 ", fileSize:%" PRId64 ", syncedOffset:%" PRId64 ", createTs:%" PRId64 - ", closeTs:%" PRId64, - pFileInfo->firstVer, pFileInfo->lastVer, pFileInfo->fileSize, pFileInfo->syncedOffset, pFileInfo->createTs, - pFileInfo->closeTs); + wInfo("vgId:%d, %s-%d, firstVer:%" PRId64 ", lastVer:%" PRId64 ", fileSize:%" PRId64 ", syncedOffset:%" PRId64 + ", createTs:%" PRId64 ", closeTs:%" PRId64, + vgId, str, i, pFileInfo->firstVer, pFileInfo->lastVer, pFileInfo->fileSize, pFileInfo->syncedOffset, + pFileInfo->createTs, pFileInfo->closeTs); } } @@ -430,6 +430,9 @@ int32_t walCheckAndRepairMeta(SWal* pWal) { regex_t logRegPattern; regex_t idxRegPattern; + wInfo("vgId:%d, begin to repair meta, wal path:%s, firstVer:%" PRId64 ", lastVer:%" PRId64 ", snapshotVer:%" PRId64, + pWal->cfg.vgId, pWal->path, pWal->vers.firstVer, pWal->vers.lastVer, pWal->vers.snapshotVer); + if (regcomp(&logRegPattern, logPattern, REG_EXTENDED) != 0) { wError("failed to compile log pattern, error:%s", tstrerror(terrno)); return terrno; @@ -482,9 +485,9 @@ int32_t walCheckAndRepairMeta(SWal* pWal) { taosArraySort(actualLog, compareWalFileInfo); - wInfo("vgId:%d, wal path:%s, actual log file num:%d", pWal->cfg.vgId, pWal->path, + wInfo("vgId:%d, actual log file, wal path:%s, num:%d", pWal->cfg.vgId, pWal->path, (int32_t)taosArrayGetSize(actualLog)); - printFileSet(actualLog); + printFileSet(pWal->cfg.vgId, actualLog, "actual log file"); int metaFileNum = taosArrayGetSize(pWal->fileInfoSet); int actualFileNum = taosArrayGetSize(actualLog); @@ -500,9 +503,9 @@ int32_t walCheckAndRepairMeta(SWal* pWal) { TAOS_RETURN(code); } - wInfo("vgId:%d, wal path:%s, meta log file num:%d", pWal->cfg.vgId, pWal->path, + wInfo("vgId:%d, log file in meta, wal path:%s, num:%d", pWal->cfg.vgId, pWal->path, (int32_t)taosArrayGetSize(pWal->fileInfoSet)); - printFileSet(pWal->fileInfoSet); + printFileSet(pWal->cfg.vgId, pWal->fileInfoSet, "log file in meta"); int32_t sz = taosArrayGetSize(pWal->fileInfoSet); @@ -563,7 +566,9 @@ int32_t walCheckAndRepairMeta(SWal* pWal) { // repair ts of files TAOS_CHECK_RETURN(walRepairLogFileTs(pWal, &updateMeta)); - printFileSet(pWal->fileInfoSet); + wInfo("vgId:%d, log file after repair, wal path:%s, num:%d", pWal->cfg.vgId, pWal->path, + (int32_t)taosArrayGetSize(pWal->fileInfoSet)); + printFileSet(pWal->cfg.vgId, pWal->fileInfoSet, "file after repair"); // update meta file if (updateMeta) { TAOS_CHECK_RETURN(walSaveMeta(pWal)); @@ -571,6 +576,9 @@ int32_t walCheckAndRepairMeta(SWal* pWal) { TAOS_CHECK_RETURN(walLogEntriesComplete(pWal)); + wInfo("vgId:%d, success to repair meta, wal path:%s, firstVer:%" PRId64 ", lastVer:%" PRId64 ", snapshotVer:%" PRId64, + pWal->cfg.vgId, pWal->path, pWal->vers.firstVer, pWal->vers.lastVer, pWal->vers.snapshotVer); + return code; } @@ -1157,9 +1165,9 @@ int32_t walLoadMeta(SWal* pWal) { (void)taosCloseFile(&pFile); taosMemoryFree(buf); - wInfo("vgId:%d, load meta file: %s, firstVer:%" PRId64 ", lastVer:%" PRId64 ", fileInfoSet size:%d", pWal->cfg.vgId, + wInfo("vgId:%d, meta file loaded: %s, firstVer:%" PRId64 ", lastVer:%" PRId64 ", fileInfoSet size:%d", pWal->cfg.vgId, fnameStr, pWal->vers.firstVer, pWal->vers.lastVer, (int32_t)taosArrayGetSize(pWal->fileInfoSet)); - printFileSet(pWal->fileInfoSet); + printFileSet(pWal->cfg.vgId, pWal->fileInfoSet, "file in meta"); TAOS_RETURN(code); } diff --git a/source/os/src/osDir.c b/source/os/src/osDir.c index 497769a71cf..84de563cda2 100644 --- a/source/os/src/osDir.c +++ b/source/os/src/osDir.c @@ -223,10 +223,15 @@ int32_t taosMulModeMkDir(const char *dirname, int mode, bool checkAccess) { if (checkAccess && taosCheckAccessFile(temp, TD_FILE_ACCESS_EXIST_OK | TD_FILE_ACCESS_READ_OK | TD_FILE_ACCESS_WRITE_OK)) { return 0; } + code = chmod(temp, mode); if (-1 == code) { - terrno = TAOS_SYSTEM_ERROR(errno); - return terrno; + struct stat statbuf = {0}; + code = stat(temp, &statbuf); + if (code != 0 || (statbuf.st_mode & mode) != mode) { + terrno = TAOS_SYSTEM_ERROR(errno); + return terrno; + } } } diff --git a/source/os/src/osEnv.c b/source/os/src/osEnv.c index a3791eb0267..05c9936c2ea 100644 --- a/source/os/src/osEnv.c +++ b/source/os/src/osEnv.c @@ -37,7 +37,6 @@ float tsNumOfCores = 0; int64_t tsTotalMemoryKB = 0; char *tsProcPath = NULL; -char tsSIMDEnable = 1; char tsAVX512Enable = 0; char tsSSE42Supported = 0; char tsAVXSupported = 0; diff --git a/source/os/test/CMakeLists.txt b/source/os/test/CMakeLists.txt index 324920f37bd..cc7110517f7 100644 --- a/source/os/test/CMakeLists.txt +++ b/source/os/test/CMakeLists.txt @@ -5,12 +5,11 @@ FIND_PATH(HEADER_GTEST_INCLUDE_DIR gtest.h /usr/include/gtest /usr/local/include FIND_LIBRARY(LIB_GTEST_STATIC_DIR libgtest.a /usr/lib/ /usr/local/lib /usr/lib64) FIND_LIBRARY(LIB_GTEST_SHARED_DIR libgtest.so /usr/lib/ /usr/local/lib /usr/lib64) -IF (HEADER_GTEST_INCLUDE_DIR AND (LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) +IF(HEADER_GTEST_INCLUDE_DIR AND(LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) MESSAGE(STATUS "gTest library found, build os test") INCLUDE_DIRECTORIES(${HEADER_GTEST_INCLUDE_DIR}) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) - ENDIF() INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/src/util/inc) diff --git a/source/util/CMakeLists.txt b/source/util/CMakeLists.txt index 063988ea00c..7f5955f3ddb 100644 --- a/source/util/CMakeLists.txt +++ b/source/util/CMakeLists.txt @@ -1,5 +1,9 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/version.c.in" "${CMAKE_CURRENT_SOURCE_DIR}/src/version.c") aux_source_directory(src UTIL_SRC) +IF(COMPILER_SUPPORT_AVX2) + MESSAGE(STATUS "AVX2 instructions is ACTIVATED") + set_source_files_properties(src/tdecompressavx.c PROPERTIES COMPILE_FLAGS -mavx2) +ENDIF() add_library(util STATIC ${UTIL_SRC}) if(DEFINED GRANT_CFG_INCLUDE_DIR) diff --git a/source/util/src/tcompression.c b/source/util/src/tcompression.c index 9c9ded693e0..6ffb5b635ac 100644 --- a/source/util/src/tcompression.c +++ b/source/util/src/tcompression.c @@ -471,12 +471,12 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha return nelements * word_length; } -#ifdef __AVX512F__ if (tsSIMDEnable && tsAVX512Enable && tsAVX512Supported) { - tsDecompressIntImpl_Hw(input, nelements, output, type); - return nelements * word_length; + int32_t cnt = tsDecompressIntImpl_Hw(input, nelements, output, type); + if (cnt >= 0) { + return cnt; + } } -#endif // Selector value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 char bit_per_integer[] = {0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 15, 20, 30, 60}; @@ -867,12 +867,12 @@ int32_t tsDecompressTimestampImp(const char *const input, const int32_t nelement memcpy(output, input + 1, nelements * longBytes); return nelements * longBytes; } else if (input[0] == 1) { // Decompress -#ifdef __AVX512VL__ if (tsSIMDEnable && tsAVX512Enable && tsAVX512Supported) { - tsDecompressTimestampAvx512(const char *const input, const int32_t nelements, char *const output, bool bigEndian); - return nelements * longBytes; + int32_t cnt = tsDecompressTimestampAvx512(input, nelements, output, false); + if (cnt >= 0) { + return cnt; + } } -#endif int64_t *ostream = (int64_t *)output; @@ -1103,13 +1103,14 @@ int32_t tsDecompressDoubleImp(const char *const input, int32_t ninput, const int return nelements * DOUBLE_BYTES; } -#ifdef __AVX2__ // use AVX2 implementation when allowed and the compression ratio is not high double compressRatio = 1.0 * nelements * DOUBLE_BYTES / ninput; if (tsSIMDEnable && tsAVX2Supported && compressRatio < 2) { - return tsDecompressDoubleImpAvx2(input + 1, nelements, output); + int32_t cnt = tsDecompressDoubleImpAvx2(input + 1, nelements, output); + if (cnt >= 0) { + return cnt; + } } -#endif // use implementation without SIMD instructions by default return tsDecompressDoubleImpHelper(input + 1, nelements, output); @@ -1257,13 +1258,14 @@ int32_t tsDecompressFloatImp(const char *const input, int32_t ninput, const int3 return nelements * FLOAT_BYTES; } -#ifdef __AVX2__ // use AVX2 implementation when allowed and the compression ratio is not high double compressRatio = 1.0 * nelements * FLOAT_BYTES / ninput; if (tsSIMDEnable && tsAVX2Supported && compressRatio < 2) { - return tsDecompressFloatImpAvx2(input + 1, nelements, output); + int32_t cnt = tsDecompressFloatImpAvx2(input + 1, nelements, output); + if (cnt >= 0) { + return cnt; + } } -#endif // use implementation without SIMD instructions by default return tsDecompressFloatImpHelper(input + 1, nelements, output); @@ -1617,7 +1619,10 @@ int32_t tsDecompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int uTrace("encode:%s, compress:%s, level:%d, type:%s, l1:%d", compressL1Dict[l1].name, compressL2Dict[l2].name, \ lvl, tDataTypes[type].name, l1); \ int32_t len = compressL1Dict[l1].comprFn(pIn, nEle, pBuf, type); \ - int8_t alvl = tsGetCompressL2Level(l2, lvl); \ + if (len < 0) { \ + return len; \ + } \ + int8_t alvl = tsGetCompressL2Level(l2, lvl); \ return compressL2Dict[l2].comprFn(pBuf, len, pOut, nOut, type, alvl); \ } else { \ uTrace("dencode:%s, decompress:%s, level:%d, type:%s", compressL1Dict[l1].name, compressL2Dict[l2].name, lvl, \ @@ -1628,8 +1633,7 @@ int32_t tsDecompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int } \ } else if (l1 == L1_DISABLED && l2 != L2_DISABLED) { \ if (compress) { \ - uTrace("encode:%s, compress:%s, level:%d, type:%s", "disabled", compressL2Dict[l1].name, lvl, \ - tDataTypes[type].name); \ + uTrace("encode:%s, compress:%s, level:%d, type:%s", "disabled", "disable", lvl, tDataTypes[type].name); \ int8_t alvl = tsGetCompressL2Level(l2, lvl); \ return compressL2Dict[l2].comprFn(pIn, nIn, pOut, nOut, type, alvl); \ } else { \ @@ -1883,3 +1887,26 @@ int8_t tUpdateCompress(uint32_t oldCmpr, uint32_t newCmpr, uint8_t l2Disabled, u return update; } + +int32_t getWordLength(char type) { + int32_t wordLength = 0; + switch (type) { + case TSDB_DATA_TYPE_BIGINT: + wordLength = LONG_BYTES; + break; + case TSDB_DATA_TYPE_INT: + wordLength = INT_BYTES; + break; + case TSDB_DATA_TYPE_SMALLINT: + wordLength = SHORT_BYTES; + break; + case TSDB_DATA_TYPE_TINYINT: + wordLength = CHAR_BYTES; + break; + default: + uError("Invalid decompress integer type:%d", type); + return TSDB_CODE_INVALID_PARA; + } + + return wordLength; +} diff --git a/source/util/src/tdecompress.c b/source/util/src/tdecompressavx.c similarity index 95% rename from source/util/src/tdecompress.c rename to source/util/src/tdecompressavx.c index 81223d73111..143867b783e 100644 --- a/source/util/src/tdecompress.c +++ b/source/util/src/tdecompressavx.c @@ -13,35 +13,16 @@ * along with this program. If not, see . */ -#include "os.h" #include "tcompression.h" -#include "ttypes.h" - -int32_t getWordLength(char type) { - int32_t wordLength = 0; - switch (type) { - case TSDB_DATA_TYPE_BIGINT: - wordLength = LONG_BYTES; - break; - case TSDB_DATA_TYPE_INT: - wordLength = INT_BYTES; - break; - case TSDB_DATA_TYPE_SMALLINT: - wordLength = SHORT_BYTES; - break; - case TSDB_DATA_TYPE_TINYINT: - wordLength = CHAR_BYTES; - break; - default: - uError("Invalid decompress integer type:%d", type); - return TSDB_CODE_INVALID_PARA; - } - - return wordLength; -} #ifdef __AVX2__ +char tsSIMDEnable = 1; +#else +char tsSIMDEnable = 0; +#endif + int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements, char *const output, const char type) { +#ifdef __AVX2__ int32_t word_length = getWordLength(type); // Selector value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 @@ -75,12 +56,12 @@ int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements, int32_t batch = 0; int32_t remain = 0; if (tsSIMDEnable && tsAVX512Supported && tsAVX512Enable) { -#if __AVX512F__ +#ifdef __AVX512F__ batch = num >> 3; remain = num & 0x07; #endif } else if (tsSIMDEnable && tsAVX2Supported) { -#if __AVX2__ +#ifdef __AVX2__ batch = num >> 2; remain = num & 0x03; #endif @@ -88,7 +69,7 @@ int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements, if (selector == 0 || selector == 1) { if (tsSIMDEnable && tsAVX512Supported && tsAVX512Enable) { -#if __AVX512F__ +#ifdef __AVX512F__ for (int32_t i = 0; i < batch; ++i) { __m512i prev = _mm512_set1_epi64(prevValue); _mm512_storeu_si512((__m512i *)&p[_pos], prev); @@ -117,7 +98,7 @@ int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements, } } else { if (tsSIMDEnable && tsAVX512Supported && tsAVX512Enable) { -#if __AVX512F__ +#ifdef __AVX512F__ __m512i sum_mask1 = _mm512_set_epi64(6, 6, 4, 4, 2, 2, 0, 0); __m512i sum_mask2 = _mm512_set_epi64(5, 5, 5, 5, 1, 1, 1, 1); __m512i sum_mask3 = _mm512_set_epi64(3, 3, 3, 3, 3, 3, 3, 3); @@ -310,10 +291,13 @@ int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements, } return nelements * word_length; +#else + uError("unable run %s without avx2 instructions", __func__); + return -1; +#endif } -#define M256_BYTES sizeof(__m256i) - +#ifdef __AVX2__ FORCE_INLINE __m256i decodeFloatAvx2(const char *data, const char *flag) { __m256i dataVec = _mm256_load_si256((__m256i *)data); __m256i flagVec = _mm256_load_si256((__m256i *)flag); @@ -332,7 +316,27 @@ FORCE_INLINE __m256i decodeFloatAvx2(const char *data, const char *flag) { return diffVec; } +FORCE_INLINE __m256i decodeDoubleAvx2(const char *data, const char *flag) { + __m256i dataVec = _mm256_load_si256((__m256i *)data); + __m256i flagVec = _mm256_load_si256((__m256i *)flag); + __m256i k7 = _mm256_set1_epi64x(7); + __m256i lopart = _mm256_set_epi64x(0, -1, 0, -1); + __m256i hipart = _mm256_set_epi64x(-1, 0, -1, 0); + __m256i trTail = _mm256_cmpgt_epi64(flagVec, k7); + __m256i trHead = _mm256_andnot_si256(trTail, _mm256_set1_epi64x(-1)); + __m256i shiftVec = _mm256_slli_epi64(_mm256_sub_epi64(k7, _mm256_and_si256(flagVec, k7)), 3); + __m256i maskVec = hipart; + __m256i diffVec = _mm256_sllv_epi64(dataVec, _mm256_and_si256(shiftVec, maskVec)); + maskVec = _mm256_or_si256(trHead, lopart); + diffVec = _mm256_srlv_epi64(diffVec, _mm256_and_si256(shiftVec, maskVec)); + maskVec = _mm256_and_si256(trTail, lopart); + diffVec = _mm256_sllv_epi64(diffVec, _mm256_and_si256(shiftVec, maskVec)); + return diffVec; +} +#endif + int32_t tsDecompressFloatImpAvx2(const char *input, int32_t nelements, char *output) { +#ifdef __AVX2__ // Allocate memory-aligned buffer char buf[M256_BYTES * 3]; memset(buf, 0, sizeof(buf)); @@ -343,7 +347,7 @@ int32_t tsDecompressFloatImpAvx2(const char *input, int32_t nelements, char *out // Load data into the buffer for batch processing int32_t batchSize = M256_BYTES / FLOAT_BYTES; - int32_t idx = 0; + int32_t idx = 0; uint32_t cur = 0; for (int32_t i = 0; i < nelements; i += 2) { if (idx == batchSize) { @@ -380,27 +384,14 @@ int32_t tsDecompressFloatImpAvx2(const char *input, int32_t nelements, char *out out += idx * FLOAT_BYTES; } return (int32_t)(out - output); -} - -FORCE_INLINE __m256i decodeDoubleAvx2(const char *data, const char *flag) { - __m256i dataVec = _mm256_load_si256((__m256i *)data); - __m256i flagVec = _mm256_load_si256((__m256i *)flag); - __m256i k7 = _mm256_set1_epi64x(7); - __m256i lopart = _mm256_set_epi64x(0, -1, 0, -1); - __m256i hipart = _mm256_set_epi64x(-1, 0, -1, 0); - __m256i trTail = _mm256_cmpgt_epi64(flagVec, k7); - __m256i trHead = _mm256_andnot_si256(trTail, _mm256_set1_epi64x(-1)); - __m256i shiftVec = _mm256_slli_epi64(_mm256_sub_epi64(k7, _mm256_and_si256(flagVec, k7)), 3); - __m256i maskVec = hipart; - __m256i diffVec = _mm256_sllv_epi64(dataVec, _mm256_and_si256(shiftVec, maskVec)); - maskVec = _mm256_or_si256(trHead, lopart); - diffVec = _mm256_srlv_epi64(diffVec, _mm256_and_si256(shiftVec, maskVec)); - maskVec = _mm256_and_si256(trTail, lopart); - diffVec = _mm256_sllv_epi64(diffVec, _mm256_and_si256(shiftVec, maskVec)); - return diffVec; +#else + uError("unable run %s without avx2 instructions", __func__); + return -1; +#endif } int32_t tsDecompressDoubleImpAvx2(const char *input, const int32_t nelements, char *const output) { +#ifdef __AVX2__ // Allocate memory-aligned buffer char buf[M256_BYTES * 3]; memset(buf, 0, sizeof(buf)); @@ -448,12 +439,15 @@ int32_t tsDecompressDoubleImpAvx2(const char *input, const int32_t nelements, ch out += idx * DOUBLE_BYTES; } return (int32_t)(out - output); -} +#else + uError("unable run %s without avx2 instructions", __func__); + return -1; #endif +} -#if __AVX512VL__ -// decode two timestamps in one loop. -void tsDecompressTimestampAvx2(const char *const input, const int32_t nelements, char *const output, bool bigEndian) { +int32_t tsDecompressTimestampAvx2(const char *const input, const int32_t nelements, char *const output, + bool bigEndian) { +#ifdef __AVX512VL__ int64_t *ostream = (int64_t *)output; int32_t ipos = 1, opos = 0; @@ -588,11 +582,16 @@ void tsDecompressTimestampAvx2(const char *const input, const int32_t nelements, ostream[opos++] = prevVal[1] + prevDeltaX; } } - return; + return opos; +#else + uError("unable run %s without avx512 instructions", __func__); + return -1; +#endif } -void tsDecompressTimestampAvx512(const char *const input, const int32_t nelements, char *const output, - bool UNUSED_PARAM(bigEndian)) { +int32_t tsDecompressTimestampAvx512(const char *const input, const int32_t nelements, char *const output, + bool UNUSED_PARAM(bigEndian)) { +#ifdef __AVX512VL__ int64_t *ostream = (int64_t *)output; int32_t ipos = 1, opos = 0; @@ -700,6 +699,9 @@ void tsDecompressTimestampAvx512(const char *const input, const int32_t nelement } } - return; -} + return opos; +#else + uError("unable run %s without avx512 instructions", __func__); + return -1; #endif +} diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 52a3be120d5..d660edd0b86 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -268,6 +268,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_IN_CREATING, "Database in creating TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SYS_TABLENAME, "Invalid system table name") TAOS_DEFINE_ERROR(TSDB_CODE_MND_ENCRYPT_NOT_ALLOW_CHANGE, "Encryption is not allowed to be changed after database is created") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_WAL_LEVEL, "Invalid option, wal_level 0 should be used with replica 1") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DNODE_LIST_FMT, "Invalid dnode list format") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_LIST_REPEAT, "Duplicate items in the dnode list") // mnode-node TAOS_DEFINE_ERROR(TSDB_CODE_MND_MNODE_ALREADY_EXIST, "Mnode already exists") @@ -618,6 +620,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SCH_INTERNAL_ERROR, "scheduler internal er TAOS_DEFINE_ERROR(TSDB_CODE_SCH_TIMEOUT_ERROR, "Task timeout") TAOS_DEFINE_ERROR(TSDB_CODE_SCH_JOB_IS_DROPPING, "Job is dropping") TAOS_DEFINE_ERROR(TSDB_CODE_SCH_JOB_NOT_EXISTS, "Job no longer exist") +TAOS_DEFINE_ERROR(TSDB_CODE_SCH_DATA_SRC_EP_MISS, "No valid epSet for data source node") // parser TAOS_DEFINE_ERROR(TSDB_CODE_PAR_SYNTAX_ERROR, "syntax error near") diff --git a/source/util/src/tlrucache.c b/source/util/src/tlrucache.c index 69832cd46c6..43a220af50a 100644 --- a/source/util/src/tlrucache.c +++ b/source/util/src/tlrucache.c @@ -14,12 +14,12 @@ */ #define _DEFAULT_SOURCE +#include "tlrucache.h" #include "os.h" #include "taoserror.h" #include "tarray.h" #include "tdef.h" #include "tlog.h" -#include "tlrucache.h" #include "tutil.h" typedef struct SLRUEntry SLRUEntry; @@ -110,7 +110,7 @@ struct SLRUEntryTable { }; static int taosLRUEntryTableInit(SLRUEntryTable *table, int maxUpperHashBits) { - table->lengthBits = 4; + table->lengthBits = 16; table->list = taosMemoryCalloc(1 << table->lengthBits, sizeof(SLRUEntry *)); if (!table->list) { TAOS_RETURN(terrno); @@ -371,24 +371,35 @@ static void taosLRUCacheShardCleanup(SLRUCacheShard *shard) { static LRUStatus taosLRUCacheShardInsertEntry(SLRUCacheShard *shard, SLRUEntry *e, LRUHandle **handle, bool freeOnFail) { - LRUStatus status = TAOS_LRU_STATUS_OK; - SArray *lastReferenceList = taosArrayInit(16, POINTER_BYTES); - if (!lastReferenceList) { - taosLRUEntryFree(e); - return TAOS_LRU_STATUS_FAIL; + LRUStatus status = TAOS_LRU_STATUS_OK; + SLRUEntry *toFree = NULL; + SArray *lastReferenceList = NULL; + if (shard->usage + e->totalCharge > shard->capacity) { + lastReferenceList = taosArrayInit(16, POINTER_BYTES); + if (!lastReferenceList) { + taosLRUEntryFree(e); + return TAOS_LRU_STATUS_FAIL; + } } (void)taosThreadMutexLock(&shard->mutex); - taosLRUCacheShardEvictLRU(shard, e->totalCharge, lastReferenceList); + if (shard->usage + e->totalCharge > shard->capacity && shard->lru.next != &shard->lru) { + if (!lastReferenceList) { + lastReferenceList = taosArrayInit(16, POINTER_BYTES); + if (!lastReferenceList) { + taosLRUEntryFree(e); + (void)taosThreadMutexUnlock(&shard->mutex); + return TAOS_LRU_STATUS_FAIL; + } + } + taosLRUCacheShardEvictLRU(shard, e->totalCharge, lastReferenceList); + } if (shard->usage + e->totalCharge > shard->capacity && (shard->strictCapacity || handle == NULL)) { TAOS_LRU_ENTRY_SET_IN_CACHE(e, false); if (handle == NULL) { - if (!taosArrayPush(lastReferenceList, &e)) { - taosLRUEntryFree(e); - goto _exit; - } + toFree = e; } else { if (freeOnFail) { taosLRUEntryFree(e); @@ -413,11 +424,7 @@ static LRUStatus taosLRUCacheShardInsertEntry(SLRUCacheShard *shard, SLRUEntry * taosLRUCacheShardLRURemove(shard, old); shard->usage -= old->totalCharge; - if (!taosArrayPush(lastReferenceList, &old)) { - taosLRUEntryFree(e); - taosLRUEntryFree(old); - goto _exit; - } + toFree = old; } } if (handle == NULL) { @@ -434,6 +441,10 @@ static LRUStatus taosLRUCacheShardInsertEntry(SLRUCacheShard *shard, SLRUEntry * _exit: (void)taosThreadMutexUnlock(&shard->mutex); + if (toFree) { + taosLRUEntryFree(toFree); + } + for (int i = 0; i < taosArrayGetSize(lastReferenceList); ++i) { SLRUEntry *entry = taosArrayGetP(lastReferenceList, i); @@ -733,7 +744,8 @@ void taosLRUCacheCleanup(SLRUCache *cache) { } LRUStatus taosLRUCacheInsert(SLRUCache *cache, const void *key, size_t keyLen, void *value, size_t charge, - _taos_lru_deleter_t deleter, _taos_lru_overwriter_t overwriter, LRUHandle **handle, LRUPriority priority, void *ud) { + _taos_lru_deleter_t deleter, _taos_lru_overwriter_t overwriter, LRUHandle **handle, + LRUPriority priority, void *ud) { uint32_t hash = TAOS_LRU_CACHE_SHARD_HASH32(key, keyLen); uint32_t shardIndex = hash & cache->shardedCache.shardMask; diff --git a/source/util/src/version.c.in b/source/util/src/version.c.in index c91b46e18d1..c5123e6f214 100644 --- a/source/util/src/version.c.in +++ b/source/util/src/version.c.in @@ -1,7 +1,7 @@ -char version[64] = "${TD_VER_NUMBER}"; -char compatible_version[12] = "${TD_VER_COMPATIBLE}"; -char gitinfo[48] = "${TD_VER_GIT}"; -char gitinfoOfInternal[48] = "${TD_VER_GIT_INTERNAL}"; -char buildinfo[64] = "${TD_VER_OSTYPE}-${TD_VER_CPUTYPE} ${TD_VER_DATE}"; +char td_version[64] = "${TD_VER_NUMBER}"; +char td_compatible_version[12] = "${TD_VER_COMPATIBLE}"; +char td_gitinfo[48] = "${TD_VER_GIT}"; +char td_gitinfoOfInternal[48] = "${TD_VER_GIT_INTERNAL}"; +char td_buildinfo[64] = "${TD_VER_OSTYPE}-${TD_VER_CPUTYPE} ${TD_VER_DATE}"; void libtaos_${TD_LIB_VER_NUMBER}_${TD_VER_OSTYPE}_${TD_VER_CPUTYPE}_${TD_VER_VERTYPE}() {}; \ No newline at end of file diff --git a/source/util/test/CMakeLists.txt b/source/util/test/CMakeLists.txt index 3732c2af59e..e8010089700 100644 --- a/source/util/test/CMakeLists.txt +++ b/source/util/test/CMakeLists.txt @@ -5,7 +5,7 @@ FIND_PATH(HEADER_GTEST_INCLUDE_DIR gtest.h /usr/include/gtest /usr/local/include FIND_LIBRARY(LIB_GTEST_STATIC_DIR libgtest.a /usr/lib/ /usr/local/lib /usr/lib64) FIND_LIBRARY(LIB_GTEST_SHARED_DIR libgtest.so /usr/lib/ /usr/local/lib /usr/lib64) -IF (HEADER_GTEST_INCLUDE_DIR AND (LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) +IF(HEADER_GTEST_INCLUDE_DIR AND(LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) MESSAGE(STATUS "gTest library found, build unit test") INCLUDE_DIRECTORIES(${HEADER_GTEST_INCLUDE_DIR}) @@ -20,18 +20,16 @@ IF (HEADER_GTEST_INCLUDE_DIR AND (LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) LIST(APPEND SOURCE_LIST ${CMAKE_CURRENT_SOURCE_DIR}/hashTest.cpp) ADD_EXECUTABLE(hashTest ${SOURCE_LIST}) TARGET_LINK_LIBRARIES(hashTest util common os gtest pthread) - + LIST(APPEND BIN_SRC ${CMAKE_CURRENT_SOURCE_DIR}/trefTest.c) ADD_EXECUTABLE(trefTest ${BIN_SRC}) TARGET_LINK_LIBRARIES(trefTest common util) - ENDIF() -#IF (TD_LINUX) -# ADD_EXECUTABLE(trefTest ./trefTest.c) -# TARGET_LINK_LIBRARIES(trefTest util common) -#ENDIF () - +# IF (TD_LINUX) +# ADD_EXECUTABLE(trefTest ./trefTest.c) +# TARGET_LINK_LIBRARIES(trefTest util common) +# ENDIF () INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/src/util/inc) INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/include/common) @@ -46,8 +44,8 @@ add_test( # # freelistTest # add_executable(freelistTest "") # target_sources(freelistTest -# PRIVATE -# "freelistTest.cpp" +# PRIVATE +# "freelistTest.cpp" # ) # target_link_libraries(freelistTest os util gtest gtest_main) @@ -57,7 +55,7 @@ add_test( # cfgTest add_executable(cfgTest "cfgTest.cpp") -target_link_libraries(cfgTest os util gtest_main) +target_link_libraries(cfgTest os util gtest_main) add_test( NAME cfgTest COMMAND cfgTest @@ -65,7 +63,7 @@ add_test( # bloomFilterTest add_executable(bloomFilterTest "bloomFilterTest.cpp") -target_link_libraries(bloomFilterTest os util gtest_main) +target_link_libraries(bloomFilterTest os util gtest_main) add_test( NAME bloomFilterTest COMMAND bloomFilterTest @@ -73,7 +71,7 @@ add_test( # taosbsearchTest add_executable(taosbsearchTest "taosbsearchTest.cpp") -target_link_libraries(taosbsearchTest os util gtest_main) +target_link_libraries(taosbsearchTest os util gtest_main) add_test( NAME taosbsearchTest COMMAND taosbsearchTest @@ -81,7 +79,7 @@ add_test( # trbtreeTest add_executable(rbtreeTest "trbtreeTest.cpp") -target_link_libraries(rbtreeTest os util gtest_main) +target_link_libraries(rbtreeTest os util gtest_main) add_test( NAME rbtreeTest COMMAND rbtreeTest @@ -120,17 +118,17 @@ add_test( ) add_executable(regexTest "regexTest.cpp") -target_link_libraries(regexTest os util gtest_main ) +target_link_libraries(regexTest os util gtest_main) add_test( NAME regexTest COMMAND regexTest ) add_executable(logTest "log.cpp") - target_link_libraries(logTest os util common gtest_main) - add_test( - NAME logTest - COMMAND logTest +target_link_libraries(logTest os util common gtest_main) +add_test( + NAME logTest + COMMAND logTest ) add_executable(decompressTest "decompressTest.cpp") @@ -140,7 +138,7 @@ add_test( COMMAND decompressTest ) -if (${TD_LINUX}) +if(${TD_LINUX}) # terrorTest add_executable(terrorTest "terrorTest.cpp") target_link_libraries(terrorTest os util common gtest_main) @@ -154,4 +152,4 @@ if (${TD_LINUX}) add_custom_command(TARGET terrorTest POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ERR_TBL_FILE} $ ) -endif () +endif() diff --git a/tests/army/query/function/ans/interp.csv b/tests/army/query/function/ans/interp.csv new file mode 100644 index 00000000000..e1ba236aa11 --- /dev/null +++ b/tests/army/query/function/ans/interp.csv @@ -0,0 +1,368 @@ + +taos> select _irowts as irowts ,tbname as table_name, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (null) order by irowts; + irowts | table_name | isfilled | intp_c1 | +================================================================================ + 2020-02-01 00:00:04.000 | td32727 | true | NULL | + 2020-02-01 00:00:05.000 | td32727 | false | 5 | + 2020-02-01 00:00:06.000 | td32727 | true | NULL | + 2020-02-01 00:00:07.000 | td32727 | true | NULL | + 2020-02-01 00:00:08.000 | td32727 | true | NULL | + 2020-02-01 00:00:09.000 | td32727 | true | NULL | + 2020-02-01 00:00:10.000 | td32727 | false | 10 | + 2020-02-01 00:00:11.000 | td32727 | true | NULL | + 2020-02-01 00:00:12.000 | td32727 | true | NULL | + 2020-02-01 00:00:13.000 | td32727 | true | NULL | + 2020-02-01 00:00:14.000 | td32727 | true | NULL | + 2020-02-01 00:00:15.000 | td32727 | false | 15 | + 2020-02-01 00:00:16.000 | td32727 | true | NULL | + +taos> select _irowts as irowts ,tbname as table_name, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (next) order by irowts; + irowts | table_name | isfilled | intp_c1 | +================================================================================ + 2020-02-01 00:00:04.000 | td32727 | true | 5 | + 2020-02-01 00:00:05.000 | td32727 | false | 5 | + 2020-02-01 00:00:06.000 | td32727 | true | 10 | + 2020-02-01 00:00:07.000 | td32727 | true | 10 | + 2020-02-01 00:00:08.000 | td32727 | true | 10 | + 2020-02-01 00:00:09.000 | td32727 | true | 10 | + 2020-02-01 00:00:10.000 | td32727 | false | 10 | + 2020-02-01 00:00:11.000 | td32727 | true | 15 | + 2020-02-01 00:00:12.000 | td32727 | true | 15 | + 2020-02-01 00:00:13.000 | td32727 | true | 15 | + 2020-02-01 00:00:14.000 | td32727 | true | 15 | + 2020-02-01 00:00:15.000 | td32727 | false | 15 | + +taos> select _irowts as irowts ,tbname as table_name, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (prev) order by irowts; + irowts | table_name | isfilled | intp_c1 | +================================================================================ + 2020-02-01 00:00:05.000 | td32727 | false | 5 | + 2020-02-01 00:00:06.000 | td32727 | true | 5 | + 2020-02-01 00:00:07.000 | td32727 | true | 5 | + 2020-02-01 00:00:08.000 | td32727 | true | 5 | + 2020-02-01 00:00:09.000 | td32727 | true | 5 | + 2020-02-01 00:00:10.000 | td32727 | false | 10 | + 2020-02-01 00:00:11.000 | td32727 | true | 10 | + 2020-02-01 00:00:12.000 | td32727 | true | 10 | + 2020-02-01 00:00:13.000 | td32727 | true | 10 | + 2020-02-01 00:00:14.000 | td32727 | true | 10 | + 2020-02-01 00:00:15.000 | td32727 | false | 15 | + 2020-02-01 00:00:16.000 | td32727 | true | 15 | + +taos> select _irowts as irowts ,tbname as table_name, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (linear) order by irowts; + irowts | table_name | isfilled | intp_c1 | +================================================================================ + 2020-02-01 00:00:05.000 | td32727 | false | 5 | + 2020-02-01 00:00:06.000 | td32727 | true | 6 | + 2020-02-01 00:00:07.000 | td32727 | true | 7 | + 2020-02-01 00:00:08.000 | td32727 | true | 8 | + 2020-02-01 00:00:09.000 | td32727 | true | 9 | + 2020-02-01 00:00:10.000 | td32727 | false | 10 | + 2020-02-01 00:00:11.000 | td32727 | true | 11 | + 2020-02-01 00:00:12.000 | td32727 | true | 12 | + 2020-02-01 00:00:13.000 | td32727 | true | 13 | + 2020-02-01 00:00:14.000 | td32727 | true | 14 | + 2020-02-01 00:00:15.000 | td32727 | false | 15 | + +taos> select _irowts as irowts ,tbname as table_name, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (value, 1) order by irowts; + irowts | table_name | isfilled | intp_c1 | +================================================================================ + 2020-02-01 00:00:04.000 | td32727 | true | 1 | + 2020-02-01 00:00:05.000 | td32727 | false | 5 | + 2020-02-01 00:00:06.000 | td32727 | true | 1 | + 2020-02-01 00:00:07.000 | td32727 | true | 1 | + 2020-02-01 00:00:08.000 | td32727 | true | 1 | + 2020-02-01 00:00:09.000 | td32727 | true | 1 | + 2020-02-01 00:00:10.000 | td32727 | false | 10 | + 2020-02-01 00:00:11.000 | td32727 | true | 1 | + 2020-02-01 00:00:12.000 | td32727 | true | 1 | + 2020-02-01 00:00:13.000 | td32727 | true | 1 | + 2020-02-01 00:00:14.000 | td32727 | true | 1 | + 2020-02-01 00:00:15.000 | td32727 | false | 15 | + 2020-02-01 00:00:16.000 | td32727 | true | 1 | + +taos> select _irowts as irowts ,tbname as table_name, c2 as c_c2, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (null) order by irowts, c2; + irowts | table_name | c_c2 | isfilled | intp_c1 | +============================================================================================== + 2020-02-01 00:00:04.000 | td32727 | 5 | true | NULL | + 2020-02-01 00:00:04.000 | td32727 | 10 | true | NULL | + 2020-02-01 00:00:04.000 | td32727 | 15 | true | NULL | + 2020-02-01 00:00:05.000 | td32727 | 5 | false | 5 | + 2020-02-01 00:00:05.000 | td32727 | 10 | true | NULL | + 2020-02-01 00:00:05.000 | td32727 | 15 | true | NULL | + 2020-02-01 00:00:06.000 | td32727 | 5 | true | NULL | + 2020-02-01 00:00:06.000 | td32727 | 10 | true | NULL | + 2020-02-01 00:00:06.000 | td32727 | 15 | true | NULL | + 2020-02-01 00:00:07.000 | td32727 | 5 | true | NULL | + 2020-02-01 00:00:07.000 | td32727 | 10 | true | NULL | + 2020-02-01 00:00:07.000 | td32727 | 15 | true | NULL | + 2020-02-01 00:00:08.000 | td32727 | 5 | true | NULL | + 2020-02-01 00:00:08.000 | td32727 | 10 | true | NULL | + 2020-02-01 00:00:08.000 | td32727 | 15 | true | NULL | + 2020-02-01 00:00:09.000 | td32727 | 5 | true | NULL | + 2020-02-01 00:00:09.000 | td32727 | 10 | true | NULL | + 2020-02-01 00:00:09.000 | td32727 | 15 | true | NULL | + 2020-02-01 00:00:10.000 | td32727 | 5 | true | NULL | + 2020-02-01 00:00:10.000 | td32727 | 10 | false | 10 | + 2020-02-01 00:00:10.000 | td32727 | 15 | true | NULL | + 2020-02-01 00:00:11.000 | td32727 | 5 | true | NULL | + 2020-02-01 00:00:11.000 | td32727 | 10 | true | NULL | + 2020-02-01 00:00:11.000 | td32727 | 15 | true | NULL | + 2020-02-01 00:00:12.000 | td32727 | 5 | true | NULL | + 2020-02-01 00:00:12.000 | td32727 | 10 | true | NULL | + 2020-02-01 00:00:12.000 | td32727 | 15 | true | NULL | + 2020-02-01 00:00:13.000 | td32727 | 5 | true | NULL | + 2020-02-01 00:00:13.000 | td32727 | 10 | true | NULL | + 2020-02-01 00:00:13.000 | td32727 | 15 | true | NULL | + 2020-02-01 00:00:14.000 | td32727 | 5 | true | NULL | + 2020-02-01 00:00:14.000 | td32727 | 10 | true | NULL | + 2020-02-01 00:00:14.000 | td32727 | 15 | true | NULL | + 2020-02-01 00:00:15.000 | td32727 | 5 | true | NULL | + 2020-02-01 00:00:15.000 | td32727 | 10 | true | NULL | + 2020-02-01 00:00:15.000 | td32727 | 15 | false | 15 | + 2020-02-01 00:00:16.000 | td32727 | 5 | true | NULL | + 2020-02-01 00:00:16.000 | td32727 | 10 | true | NULL | + 2020-02-01 00:00:16.000 | td32727 | 15 | true | NULL | + +taos> select _irowts as irowts ,tbname as table_name, c2 as c_c2, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (next) order by irowts, c2; + irowts | table_name | c_c2 | isfilled | intp_c1 | +============================================================================================== + 2020-02-01 00:00:04.000 | td32727 | 5 | true | 5 | + 2020-02-01 00:00:04.000 | td32727 | 10 | true | 10 | + 2020-02-01 00:00:04.000 | td32727 | 15 | true | 15 | + 2020-02-01 00:00:05.000 | td32727 | 5 | false | 5 | + 2020-02-01 00:00:05.000 | td32727 | 10 | true | 10 | + 2020-02-01 00:00:05.000 | td32727 | 15 | true | 15 | + 2020-02-01 00:00:06.000 | td32727 | 10 | true | 10 | + 2020-02-01 00:00:06.000 | td32727 | 15 | true | 15 | + 2020-02-01 00:00:07.000 | td32727 | 10 | true | 10 | + 2020-02-01 00:00:07.000 | td32727 | 15 | true | 15 | + 2020-02-01 00:00:08.000 | td32727 | 10 | true | 10 | + 2020-02-01 00:00:08.000 | td32727 | 15 | true | 15 | + 2020-02-01 00:00:09.000 | td32727 | 10 | true | 10 | + 2020-02-01 00:00:09.000 | td32727 | 15 | true | 15 | + 2020-02-01 00:00:10.000 | td32727 | 10 | false | 10 | + 2020-02-01 00:00:10.000 | td32727 | 15 | true | 15 | + 2020-02-01 00:00:11.000 | td32727 | 15 | true | 15 | + 2020-02-01 00:00:12.000 | td32727 | 15 | true | 15 | + 2020-02-01 00:00:13.000 | td32727 | 15 | true | 15 | + 2020-02-01 00:00:14.000 | td32727 | 15 | true | 15 | + 2020-02-01 00:00:15.000 | td32727 | 15 | false | 15 | + +taos> select _irowts as irowts ,tbname as table_name, c2 as c_c2, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (prev) order by irowts, c2; + irowts | table_name | c_c2 | isfilled | intp_c1 | +============================================================================================== + 2020-02-01 00:00:05.000 | td32727 | 5 | false | 5 | + 2020-02-01 00:00:06.000 | td32727 | 5 | true | 5 | + 2020-02-01 00:00:07.000 | td32727 | 5 | true | 5 | + 2020-02-01 00:00:08.000 | td32727 | 5 | true | 5 | + 2020-02-01 00:00:09.000 | td32727 | 5 | true | 5 | + 2020-02-01 00:00:10.000 | td32727 | 5 | true | 5 | + 2020-02-01 00:00:10.000 | td32727 | 10 | false | 10 | + 2020-02-01 00:00:11.000 | td32727 | 5 | true | 5 | + 2020-02-01 00:00:11.000 | td32727 | 10 | true | 10 | + 2020-02-01 00:00:12.000 | td32727 | 5 | true | 5 | + 2020-02-01 00:00:12.000 | td32727 | 10 | true | 10 | + 2020-02-01 00:00:13.000 | td32727 | 5 | true | 5 | + 2020-02-01 00:00:13.000 | td32727 | 10 | true | 10 | + 2020-02-01 00:00:14.000 | td32727 | 5 | true | 5 | + 2020-02-01 00:00:14.000 | td32727 | 10 | true | 10 | + 2020-02-01 00:00:15.000 | td32727 | 5 | true | 5 | + 2020-02-01 00:00:15.000 | td32727 | 10 | true | 10 | + 2020-02-01 00:00:15.000 | td32727 | 15 | false | 15 | + 2020-02-01 00:00:16.000 | td32727 | 5 | true | 5 | + 2020-02-01 00:00:16.000 | td32727 | 10 | true | 10 | + 2020-02-01 00:00:16.000 | td32727 | 15 | true | 15 | + +taos> select _irowts as irowts ,tbname as table_name, c2 as c_c2, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (linear) order by irowts, c2; + irowts | table_name | c_c2 | isfilled | intp_c1 | +============================================================================================== + 2020-02-01 00:00:05.000 | td32727 | 5 | false | 5 | + 2020-02-01 00:00:10.000 | td32727 | 10 | false | 10 | + 2020-02-01 00:00:15.000 | td32727 | 15 | false | 15 | + +taos> select _irowts as irowts ,tbname as table_name, c2 as c_c2, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (value, 1) order by irowts, c2; + irowts | table_name | c_c2 | isfilled | intp_c1 | +============================================================================================== + 2020-02-01 00:00:04.000 | td32727 | 5 | true | 1 | + 2020-02-01 00:00:04.000 | td32727 | 10 | true | 1 | + 2020-02-01 00:00:04.000 | td32727 | 15 | true | 1 | + 2020-02-01 00:00:05.000 | td32727 | 5 | false | 5 | + 2020-02-01 00:00:05.000 | td32727 | 10 | true | 1 | + 2020-02-01 00:00:05.000 | td32727 | 15 | true | 1 | + 2020-02-01 00:00:06.000 | td32727 | 5 | true | 1 | + 2020-02-01 00:00:06.000 | td32727 | 10 | true | 1 | + 2020-02-01 00:00:06.000 | td32727 | 15 | true | 1 | + 2020-02-01 00:00:07.000 | td32727 | 5 | true | 1 | + 2020-02-01 00:00:07.000 | td32727 | 10 | true | 1 | + 2020-02-01 00:00:07.000 | td32727 | 15 | true | 1 | + 2020-02-01 00:00:08.000 | td32727 | 5 | true | 1 | + 2020-02-01 00:00:08.000 | td32727 | 10 | true | 1 | + 2020-02-01 00:00:08.000 | td32727 | 15 | true | 1 | + 2020-02-01 00:00:09.000 | td32727 | 5 | true | 1 | + 2020-02-01 00:00:09.000 | td32727 | 10 | true | 1 | + 2020-02-01 00:00:09.000 | td32727 | 15 | true | 1 | + 2020-02-01 00:00:10.000 | td32727 | 5 | true | 1 | + 2020-02-01 00:00:10.000 | td32727 | 10 | false | 10 | + 2020-02-01 00:00:10.000 | td32727 | 15 | true | 1 | + 2020-02-01 00:00:11.000 | td32727 | 5 | true | 1 | + 2020-02-01 00:00:11.000 | td32727 | 10 | true | 1 | + 2020-02-01 00:00:11.000 | td32727 | 15 | true | 1 | + 2020-02-01 00:00:12.000 | td32727 | 5 | true | 1 | + 2020-02-01 00:00:12.000 | td32727 | 10 | true | 1 | + 2020-02-01 00:00:12.000 | td32727 | 15 | true | 1 | + 2020-02-01 00:00:13.000 | td32727 | 5 | true | 1 | + 2020-02-01 00:00:13.000 | td32727 | 10 | true | 1 | + 2020-02-01 00:00:13.000 | td32727 | 15 | true | 1 | + 2020-02-01 00:00:14.000 | td32727 | 5 | true | 1 | + 2020-02-01 00:00:14.000 | td32727 | 10 | true | 1 | + 2020-02-01 00:00:14.000 | td32727 | 15 | true | 1 | + 2020-02-01 00:00:15.000 | td32727 | 5 | true | 1 | + 2020-02-01 00:00:15.000 | td32727 | 10 | true | 1 | + 2020-02-01 00:00:15.000 | td32727 | 15 | false | 15 | + 2020-02-01 00:00:16.000 | td32727 | 5 | true | 1 | + 2020-02-01 00:00:16.000 | td32727 | 10 | true | 1 | + 2020-02-01 00:00:16.000 | td32727 | 15 | true | 1 | + +taos> select _irowts as irowts ,tbname as table_name, c2 as c_c2, c3 as c_c3, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2,c3 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (null) order by irowts, c2, c3; + irowts | table_name | c_c2 | c_c3 | isfilled | intp_c1 | +====================================================================================================================== + 2020-02-01 00:00:04.000 | td32727 | 5 | 5 | true | NULL | + 2020-02-01 00:00:04.000 | td32727 | 10 | 10 | true | NULL | + 2020-02-01 00:00:04.000 | td32727 | 15 | 15 | true | NULL | + 2020-02-01 00:00:05.000 | td32727 | 5 | 5 | false | 5 | + 2020-02-01 00:00:05.000 | td32727 | 10 | 10 | true | NULL | + 2020-02-01 00:00:05.000 | td32727 | 15 | 15 | true | NULL | + 2020-02-01 00:00:06.000 | td32727 | 5 | 5 | true | NULL | + 2020-02-01 00:00:06.000 | td32727 | 10 | 10 | true | NULL | + 2020-02-01 00:00:06.000 | td32727 | 15 | 15 | true | NULL | + 2020-02-01 00:00:07.000 | td32727 | 5 | 5 | true | NULL | + 2020-02-01 00:00:07.000 | td32727 | 10 | 10 | true | NULL | + 2020-02-01 00:00:07.000 | td32727 | 15 | 15 | true | NULL | + 2020-02-01 00:00:08.000 | td32727 | 5 | 5 | true | NULL | + 2020-02-01 00:00:08.000 | td32727 | 10 | 10 | true | NULL | + 2020-02-01 00:00:08.000 | td32727 | 15 | 15 | true | NULL | + 2020-02-01 00:00:09.000 | td32727 | 5 | 5 | true | NULL | + 2020-02-01 00:00:09.000 | td32727 | 10 | 10 | true | NULL | + 2020-02-01 00:00:09.000 | td32727 | 15 | 15 | true | NULL | + 2020-02-01 00:00:10.000 | td32727 | 5 | 5 | true | NULL | + 2020-02-01 00:00:10.000 | td32727 | 10 | 10 | false | 10 | + 2020-02-01 00:00:10.000 | td32727 | 15 | 15 | true | NULL | + 2020-02-01 00:00:11.000 | td32727 | 5 | 5 | true | NULL | + 2020-02-01 00:00:11.000 | td32727 | 10 | 10 | true | NULL | + 2020-02-01 00:00:11.000 | td32727 | 15 | 15 | true | NULL | + 2020-02-01 00:00:12.000 | td32727 | 5 | 5 | true | NULL | + 2020-02-01 00:00:12.000 | td32727 | 10 | 10 | true | NULL | + 2020-02-01 00:00:12.000 | td32727 | 15 | 15 | true | NULL | + 2020-02-01 00:00:13.000 | td32727 | 5 | 5 | true | NULL | + 2020-02-01 00:00:13.000 | td32727 | 10 | 10 | true | NULL | + 2020-02-01 00:00:13.000 | td32727 | 15 | 15 | true | NULL | + 2020-02-01 00:00:14.000 | td32727 | 5 | 5 | true | NULL | + 2020-02-01 00:00:14.000 | td32727 | 10 | 10 | true | NULL | + 2020-02-01 00:00:14.000 | td32727 | 15 | 15 | true | NULL | + 2020-02-01 00:00:15.000 | td32727 | 5 | 5 | true | NULL | + 2020-02-01 00:00:15.000 | td32727 | 10 | 10 | true | NULL | + 2020-02-01 00:00:15.000 | td32727 | 15 | 15 | false | 15 | + 2020-02-01 00:00:16.000 | td32727 | 5 | 5 | true | NULL | + 2020-02-01 00:00:16.000 | td32727 | 10 | 10 | true | NULL | + 2020-02-01 00:00:16.000 | td32727 | 15 | 15 | true | NULL | + +taos> select _irowts as irowts ,tbname as table_name, c2 as c_c2, c3 as c_c3, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2,c3 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (next) order by irowts, c2, c3; + irowts | table_name | c_c2 | c_c3 | isfilled | intp_c1 | +====================================================================================================================== + 2020-02-01 00:00:04.000 | td32727 | 5 | 5 | true | 5 | + 2020-02-01 00:00:04.000 | td32727 | 10 | 10 | true | 10 | + 2020-02-01 00:00:04.000 | td32727 | 15 | 15 | true | 15 | + 2020-02-01 00:00:05.000 | td32727 | 5 | 5 | false | 5 | + 2020-02-01 00:00:05.000 | td32727 | 10 | 10 | true | 10 | + 2020-02-01 00:00:05.000 | td32727 | 15 | 15 | true | 15 | + 2020-02-01 00:00:06.000 | td32727 | 10 | 10 | true | 10 | + 2020-02-01 00:00:06.000 | td32727 | 15 | 15 | true | 15 | + 2020-02-01 00:00:07.000 | td32727 | 10 | 10 | true | 10 | + 2020-02-01 00:00:07.000 | td32727 | 15 | 15 | true | 15 | + 2020-02-01 00:00:08.000 | td32727 | 10 | 10 | true | 10 | + 2020-02-01 00:00:08.000 | td32727 | 15 | 15 | true | 15 | + 2020-02-01 00:00:09.000 | td32727 | 10 | 10 | true | 10 | + 2020-02-01 00:00:09.000 | td32727 | 15 | 15 | true | 15 | + 2020-02-01 00:00:10.000 | td32727 | 10 | 10 | false | 10 | + 2020-02-01 00:00:10.000 | td32727 | 15 | 15 | true | 15 | + 2020-02-01 00:00:11.000 | td32727 | 15 | 15 | true | 15 | + 2020-02-01 00:00:12.000 | td32727 | 15 | 15 | true | 15 | + 2020-02-01 00:00:13.000 | td32727 | 15 | 15 | true | 15 | + 2020-02-01 00:00:14.000 | td32727 | 15 | 15 | true | 15 | + 2020-02-01 00:00:15.000 | td32727 | 15 | 15 | false | 15 | + +taos> select _irowts as irowts ,tbname as table_name, c2 as c_c2, c3 as c_c3, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2,c3 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (prev) order by irowts, c2, c3; + irowts | table_name | c_c2 | c_c3 | isfilled | intp_c1 | +====================================================================================================================== + 2020-02-01 00:00:05.000 | td32727 | 5 | 5 | false | 5 | + 2020-02-01 00:00:06.000 | td32727 | 5 | 5 | true | 5 | + 2020-02-01 00:00:07.000 | td32727 | 5 | 5 | true | 5 | + 2020-02-01 00:00:08.000 | td32727 | 5 | 5 | true | 5 | + 2020-02-01 00:00:09.000 | td32727 | 5 | 5 | true | 5 | + 2020-02-01 00:00:10.000 | td32727 | 5 | 5 | true | 5 | + 2020-02-01 00:00:10.000 | td32727 | 10 | 10 | false | 10 | + 2020-02-01 00:00:11.000 | td32727 | 5 | 5 | true | 5 | + 2020-02-01 00:00:11.000 | td32727 | 10 | 10 | true | 10 | + 2020-02-01 00:00:12.000 | td32727 | 5 | 5 | true | 5 | + 2020-02-01 00:00:12.000 | td32727 | 10 | 10 | true | 10 | + 2020-02-01 00:00:13.000 | td32727 | 5 | 5 | true | 5 | + 2020-02-01 00:00:13.000 | td32727 | 10 | 10 | true | 10 | + 2020-02-01 00:00:14.000 | td32727 | 5 | 5 | true | 5 | + 2020-02-01 00:00:14.000 | td32727 | 10 | 10 | true | 10 | + 2020-02-01 00:00:15.000 | td32727 | 5 | 5 | true | 5 | + 2020-02-01 00:00:15.000 | td32727 | 10 | 10 | true | 10 | + 2020-02-01 00:00:15.000 | td32727 | 15 | 15 | false | 15 | + 2020-02-01 00:00:16.000 | td32727 | 5 | 5 | true | 5 | + 2020-02-01 00:00:16.000 | td32727 | 10 | 10 | true | 10 | + 2020-02-01 00:00:16.000 | td32727 | 15 | 15 | true | 15 | + +taos> select _irowts as irowts ,tbname as table_name, c2 as c_c2, c3 as c_c3, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2,c3 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (linear) order by irowts, c2, c3; + irowts | table_name | c_c2 | c_c3 | isfilled | intp_c1 | +====================================================================================================================== + 2020-02-01 00:00:05.000 | td32727 | 5 | 5 | false | 5 | + 2020-02-01 00:00:10.000 | td32727 | 10 | 10 | false | 10 | + 2020-02-01 00:00:15.000 | td32727 | 15 | 15 | false | 15 | + +taos> select _irowts as irowts ,tbname as table_name, c2 as c_c2, c3 as c_c3, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2,c3 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (value, 1) order by irowts, c2, c3; + irowts | table_name | c_c2 | c_c3 | isfilled | intp_c1 | +====================================================================================================================== + 2020-02-01 00:00:04.000 | td32727 | 5 | 5 | true | 1 | + 2020-02-01 00:00:04.000 | td32727 | 10 | 10 | true | 1 | + 2020-02-01 00:00:04.000 | td32727 | 15 | 15 | true | 1 | + 2020-02-01 00:00:05.000 | td32727 | 5 | 5 | false | 5 | + 2020-02-01 00:00:05.000 | td32727 | 10 | 10 | true | 1 | + 2020-02-01 00:00:05.000 | td32727 | 15 | 15 | true | 1 | + 2020-02-01 00:00:06.000 | td32727 | 5 | 5 | true | 1 | + 2020-02-01 00:00:06.000 | td32727 | 10 | 10 | true | 1 | + 2020-02-01 00:00:06.000 | td32727 | 15 | 15 | true | 1 | + 2020-02-01 00:00:07.000 | td32727 | 5 | 5 | true | 1 | + 2020-02-01 00:00:07.000 | td32727 | 10 | 10 | true | 1 | + 2020-02-01 00:00:07.000 | td32727 | 15 | 15 | true | 1 | + 2020-02-01 00:00:08.000 | td32727 | 5 | 5 | true | 1 | + 2020-02-01 00:00:08.000 | td32727 | 10 | 10 | true | 1 | + 2020-02-01 00:00:08.000 | td32727 | 15 | 15 | true | 1 | + 2020-02-01 00:00:09.000 | td32727 | 5 | 5 | true | 1 | + 2020-02-01 00:00:09.000 | td32727 | 10 | 10 | true | 1 | + 2020-02-01 00:00:09.000 | td32727 | 15 | 15 | true | 1 | + 2020-02-01 00:00:10.000 | td32727 | 5 | 5 | true | 1 | + 2020-02-01 00:00:10.000 | td32727 | 10 | 10 | false | 10 | + 2020-02-01 00:00:10.000 | td32727 | 15 | 15 | true | 1 | + 2020-02-01 00:00:11.000 | td32727 | 5 | 5 | true | 1 | + 2020-02-01 00:00:11.000 | td32727 | 10 | 10 | true | 1 | + 2020-02-01 00:00:11.000 | td32727 | 15 | 15 | true | 1 | + 2020-02-01 00:00:12.000 | td32727 | 5 | 5 | true | 1 | + 2020-02-01 00:00:12.000 | td32727 | 10 | 10 | true | 1 | + 2020-02-01 00:00:12.000 | td32727 | 15 | 15 | true | 1 | + 2020-02-01 00:00:13.000 | td32727 | 5 | 5 | true | 1 | + 2020-02-01 00:00:13.000 | td32727 | 10 | 10 | true | 1 | + 2020-02-01 00:00:13.000 | td32727 | 15 | 15 | true | 1 | + 2020-02-01 00:00:14.000 | td32727 | 5 | 5 | true | 1 | + 2020-02-01 00:00:14.000 | td32727 | 10 | 10 | true | 1 | + 2020-02-01 00:00:14.000 | td32727 | 15 | 15 | true | 1 | + 2020-02-01 00:00:15.000 | td32727 | 5 | 5 | true | 1 | + 2020-02-01 00:00:15.000 | td32727 | 10 | 10 | true | 1 | + 2020-02-01 00:00:15.000 | td32727 | 15 | 15 | false | 15 | + 2020-02-01 00:00:16.000 | td32727 | 5 | 5 | true | 1 | + 2020-02-01 00:00:16.000 | td32727 | 10 | 10 | true | 1 | + 2020-02-01 00:00:16.000 | td32727 | 15 | 15 | true | 1 | + diff --git a/tests/army/query/function/in/interp.in b/tests/army/query/function/in/interp.in new file mode 100644 index 00000000000..4825ab46b16 --- /dev/null +++ b/tests/army/query/function/in/interp.in @@ -0,0 +1,15 @@ +select _irowts as irowts ,tbname as table_name, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (null) order by irowts; +select _irowts as irowts ,tbname as table_name, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (next) order by irowts; +select _irowts as irowts ,tbname as table_name, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (prev) order by irowts; +select _irowts as irowts ,tbname as table_name, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (linear) order by irowts; +select _irowts as irowts ,tbname as table_name, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (value, 1) order by irowts; +select _irowts as irowts ,tbname as table_name, c2 as c_c2, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (null) order by irowts, c2; +select _irowts as irowts ,tbname as table_name, c2 as c_c2, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (next) order by irowts, c2; +select _irowts as irowts ,tbname as table_name, c2 as c_c2, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (prev) order by irowts, c2; +select _irowts as irowts ,tbname as table_name, c2 as c_c2, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (linear) order by irowts, c2; +select _irowts as irowts ,tbname as table_name, c2 as c_c2, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (value, 1) order by irowts, c2; +select _irowts as irowts ,tbname as table_name, c2 as c_c2, c3 as c_c3, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2,c3 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (null) order by irowts, c2, c3; +select _irowts as irowts ,tbname as table_name, c2 as c_c2, c3 as c_c3, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2,c3 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (next) order by irowts, c2, c3; +select _irowts as irowts ,tbname as table_name, c2 as c_c2, c3 as c_c3, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2,c3 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (prev) order by irowts, c2, c3; +select _irowts as irowts ,tbname as table_name, c2 as c_c2, c3 as c_c3, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2,c3 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (linear) order by irowts, c2, c3; +select _irowts as irowts ,tbname as table_name, c2 as c_c2, c3 as c_c3, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname,c2,c3 range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (value, 1) order by irowts, c2, c3; diff --git a/tests/army/query/function/test_interp.py b/tests/army/query/function/test_interp.py new file mode 100644 index 00000000000..f903e7be734 --- /dev/null +++ b/tests/army/query/function/test_interp.py @@ -0,0 +1,72 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +from frame import etool +from frame.etool import * +from frame.log import * +from frame.cases import * +from frame.sql import * +from frame.caseBase import * +from frame.common import * + +class TDTestCase(TBase): + updatecfgDict = { + "keepColumnName": "1", + "ttlChangeOnWrite": "1", + "querySmaOptimize": "1", + "slowLogScope": "none", + "queryBufferSize": 10240 + } + + def insert_data(self): + tdLog.printNoPrefix("==========step1:create table") + + tdSql.execute("create database test keep 36500") + tdSql.execute("use test") + tdSql.execute( + f'''create table if not exists test.td32727 + (ts timestamp, c0 tinyint, c1 smallint, c2 int, c3 bigint, c4 double, c5 float, c6 bool, c7 varchar(10), c8 nchar(10), c9 tinyint unsigned, c10 smallint unsigned, c11 int unsigned, c12 bigint unsigned) + ''' + ) + + tdLog.printNoPrefix("==========step2:insert data") + + tdSql.execute(f"insert into test.td32727 values ('2020-02-01 00:00:05', 5, 5, 5, 5, 5.0, 5.0, true, 'varchar', 'nchar', 5, 5, 5, 5)") + tdSql.execute(f"insert into test.td32727 values ('2020-02-01 00:00:10', 10, 10, 10, 10, 10.0, 10.0, true, 'varchar', 'nchar', 10, 10, 10, 10)") + tdSql.execute(f"insert into test.td32727 values ('2020-02-01 00:00:15', 15, 15, 15, 15, 15.0, 15.0, true, 'varchar', 'nchar', 15, 15, 15, 15)") + + + def test_normal_query_new(self, testCase): + # read sql from .sql file and execute + tdLog.info("test normal query.") + self.sqlFile = etool.curFile(__file__, f"in/{testCase}.in") + self.ansFile = etool.curFile(__file__, f"ans/{testCase}.csv") + + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + def test_interp(self): + self.test_normal_query_new("interp") + + def run(self): + tdLog.debug(f"start to excute {__file__}") + + self.insert_data() + + # math function + self.test_interp() + + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/army/query/function/test_percentile.py b/tests/army/query/function/test_percentile.py new file mode 100644 index 00000000000..004cad54c99 --- /dev/null +++ b/tests/army/query/function/test_percentile.py @@ -0,0 +1,194 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +from frame import etool +from frame.etool import * +from frame.log import * +from frame.cases import * +from frame.sql import * +from frame.caseBase import * +from frame.common import * + +class TDTestCase(TBase): + updatecfgDict = { + "keepColumnName": "1", + "ttlChangeOnWrite": "1", + "querySmaOptimize": "1", + "slowLogScope": "none", + "queryBufferSize": 10240 + } + + def insert_data(self): + tdLog.printNoPrefix("==========step1:create table") + + tdSql.execute(f'create database if not exists td32506') + tdSql.execute(f'use td32506') + tdSql.execute(f'CREATE STABLE fs_table (ts TIMESTAMP, speed INT, color VARCHAR(16), tinyint_type_col_name TINYINT, smallint_type_col_name SMALLINT, bigint_type_col_name BIGINT, ' + f'utinyint_type_col_name TINYINT, usmallint_type_col_name SMALLINT, uint_type_col_name INT, ubigint_type_col_name BIGINT, float_type_col_name FLOAT, ' + f'double_type_col_name DOUBLE, bool_type_col_name BOOL, nchar_type_col_name NCHAR(16), varchar_type_col_name VARCHAR(16), ' + f'varbinary_type_col_name VARBINARY(16),geometry_type_col_name GEOMETRY(32)) TAGS (b VARCHAR(200), f FLOAT, tinyint_type_tag_name TINYINT, ' + f'smallint_type_tag_name SMALLINT, int_type_tag_name INT, bigint_type_tag_name BIGINT, utinyint_type_tag_name TINYINT, ' + f'usmallint_type_tag_name SMALLINT UNSIGNED, uint_type_tag_name INT UNSIGNED, ubigint_type_tag_name BIGINT, double_type_tag_name DOUBLE, ' + f'bool_type_tag_name BOOL, nchar_type_tag_name NCHAR(16), varchar_type_tag_name VARCHAR(16), varbinary_type_tag_name VARBINARY(64), ' + f'geometry_type_tag_name GEOMETRY(32), extratag INT)') + tdSql.execute(f'CREATE TABLE reg_table_159 USING fs_table ' + f'(b, f, tinyint_type_tag_name, smallint_type_tag_name, int_type_tag_name, bigint_type_tag_name, ' + f'utinyint_type_tag_name, usmallint_type_tag_name, uint_type_tag_name, ubigint_type_tag_name, ' + f'double_type_tag_name, bool_type_tag_name, nchar_type_tag_name, varchar_type_tag_name, varbinary_type_tag_name) ' + f'TAGS ("fgiaaopuphardlom", -3.302167e+38, 40, 18667, 1116729408, -6426992149481917950, 55, 4674, 1756351183, ' + f'7228005179153159914, -3.428740e+307, false, "emvhqjcixroitxiw", "fixwxdovhhbizqdm", "\x786565787775656D6F667A666A646463")') + + tdLog.printNoPrefix("==========step2:insert data") + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(nchar_type_tag_name,double_type_tag_name,bigint_type_tag_name,usmallint_type_tag_name,varchar_type_tag_name,geometry_type_tag_name,int_type_tag_name,varbinary_type_tag_name,ubigint_type_tag_name,smallint_type_tag_name,utinyint_type_tag_name,uint_type_tag_name,f,tinyint_type_tag_name,bool_type_tag_name,b) TAGS("emvhqjcixroitxiw", -3.4287401579952453e+307, -6426992149481917950, 4674, "fixwxdovhhbizqdm", "point(1.0 1.0)", 1116729408, "xeexwuemofzfjddc", 7228005179153159914, 18667, 55, 1756351183, -3.302167385734522e+38, 40, False, "fgiaaopuphardlom") (ts,varchar_type_col_name,uint_type_col_name,speed,smallint_type_col_name,nchar_type_col_name,ubigint_type_col_name,varbinary_type_col_name,float_type_col_name,bigint_type_col_name,double_type_col_name,geometry_type_col_name,color,bool_type_col_name,usmallint_type_col_name,utinyint_type_col_name,tinyint_type_col_name) VALUES ("2016-12-16 00:49:27", "jvudhjbmixxuubhl", 1327384783, 215895363, 16025, "llosyvhgzqpixdru", -3772449087838215561, "jvludkxlqobiigip", -2.978105332100778e+37, -5559805599911459602, -4.028726372555818e+307, "point(1.0 1.0)", "bdencejzdarqaeef", True, 19468, 35, -30);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(int_type_tag_name,bool_type_tag_name) TAGS(1653079398, True) (ts,bigint_type_col_name,ubigint_type_col_name,float_type_col_name,color,double_type_col_name,bool_type_col_name,smallint_type_col_name,uint_type_col_name) VALUES ("2016-12-16 00:58:36", 1083391961316260438, 3613986442426750782, -1.0453149756996617e+38, "tvaiakmmcxzbepra", -1.4689107839018581e+308, True, -18675, 138061020);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(double_type_tag_name,bigint_type_tag_name,ubigint_type_tag_name,int_type_tag_name,varchar_type_tag_name,b,f,smallint_type_tag_name,tinyint_type_tag_name,bool_type_tag_name,uint_type_tag_name,utinyint_type_tag_name,nchar_type_tag_name,usmallint_type_tag_name,geometry_type_tag_name,varbinary_type_tag_name) TAGS(-7.061730755263099e+307, 2107452935481758830, 2258834966577471147, -952230254, "vhnwshrapagnalqu", "levvmtztgprzatat", 6.737169619795772e+37, 8872, 2, True, 1075287886, -60, "mpdmcvwntqfusvhm", 36270, "point(1.0 1.0)", "ctnxatxiaymaekvj") (ts) VALUES ("2016-12-16 01:23:36");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(geometry_type_tag_name,f,usmallint_type_tag_name,smallint_type_tag_name,double_type_tag_name) TAGS("point(1.0 1.0)", -8.285007090644336e+37, 50936, -28943, 3.4910133200480327e+307) (ts,tinyint_type_col_name,geometry_type_col_name,ubigint_type_col_name,smallint_type_col_name) VALUES ("2016-12-16 01:37:37", 20, "point(1.0 1.0)", -8279051334405446366, -11586);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(varbinary_type_tag_name,f,ubigint_type_tag_name,nchar_type_tag_name,uint_type_tag_name,int_type_tag_name,utinyint_type_tag_name,smallint_type_tag_name) TAGS("qbwmnupomqkllhdf", -1.731243531476578e+38, -3044376275988311477, "onwtdayawxuoayuh", 3923375490, -122362890, -50, -25842) (ts,tinyint_type_col_name,uint_type_col_name,bigint_type_col_name,varbinary_type_col_name,color) VALUES ("2016-12-16 01:47:01", 38, -912910938, -7421282029380796738, "zqqrmdatsixdjwmv", "qensugigfedpokag");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(f,nchar_type_tag_name,bigint_type_tag_name,b,tinyint_type_tag_name,smallint_type_tag_name) TAGS(3.0006598369272955e+38, "qgmecuzexdlbjoen", 2548336842131148813, "kvulvyjmnsujbygx", 54, 12017) (ts,ubigint_type_col_name,double_type_col_name,geometry_type_col_name,color,bool_type_col_name,tinyint_type_col_name) VALUES ("2016-12-16 02:41:15", -8037368176580035774, 1.8094617142119061e+307, "point(1.0 1.0)", "uriutisredzfnels", False, -50);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(smallint_type_tag_name,usmallint_type_tag_name,uint_type_tag_name,geometry_type_tag_name) TAGS(-18163, 36635, 3511596470, "point(1.0 1.0)") (ts,utinyint_type_col_name,varchar_type_col_name,uint_type_col_name,bigint_type_col_name,bool_type_col_name,varbinary_type_col_name,ubigint_type_col_name,smallint_type_col_name,geometry_type_col_name,float_type_col_name,color,tinyint_type_col_name,usmallint_type_col_name,speed,double_type_col_name) VALUES ("2016-12-16 02:41:32", 53, "izpzycfgyyljiafe", 748493885, 1182091325231355552, True, "wirugruhofvuzvfq", -6622830592002864757, 2403, "point(1.0 1.0)", -2.0533976172415304e+38, "ypyrkfwkzsvykvbq", -98, 7975, 1661529650, 1.4776735328584477e+308);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(tinyint_type_tag_name,varchar_type_tag_name,bool_type_tag_name,uint_type_tag_name,ubigint_type_tag_name,double_type_tag_name,f) TAGS(58, "mxcovlujiaipbrxe", False, 3023725445, -8300199672256037241, 3.493291803670194e+307, -2.0809024953240414e+38) (ts,utinyint_type_col_name,varbinary_type_col_name,bigint_type_col_name,speed,color,uint_type_col_name,usmallint_type_col_name,bool_type_col_name,geometry_type_col_name,nchar_type_col_name) VALUES ("2016-12-16 03:00:08", -47, "achpeufmryizqrmv", -3195561950072510641, -674332102, "ocyfdyeztjbdajyj", 1620966159, 3256, True, "point(1.0 1.0)", "ujaddbbtrpfhirhk");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(usmallint_type_tag_name,bool_type_tag_name,b,smallint_type_tag_name,geometry_type_tag_name,double_type_tag_name) TAGS(22844, False, "mtfrbktpnjmdaazm", 26985, "point(1.0 1.0)", 1.6179238326982066e+308) (ts) VALUES ("2016-12-16 03:02:29");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(geometry_type_tag_name,f,uint_type_tag_name,smallint_type_tag_name,tinyint_type_tag_name) TAGS("point(1.0 1.0)", -3.0320850510538104e+38, 3560125456, 11119, 100) (ts,varbinary_type_col_name,double_type_col_name,bigint_type_col_name) VALUES ("2016-12-16 03:04:06", "sujwqvsfertzzcuk", -1.4040026870544444e+308, 2475978411998036438);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(varbinary_type_tag_name,usmallint_type_tag_name) TAGS("orgrtrdbgldlyogq", 28231) (ts,varchar_type_col_name,double_type_col_name,bool_type_col_name,usmallint_type_col_name,geometry_type_col_name,bigint_type_col_name,color,speed,uint_type_col_name,ubigint_type_col_name) VALUES ("2016-12-16 03:04:22", "xdwjwlgxgpkaqnnb", 9.723011865690129e+307, True, -13258, "point(1.0 1.0)", 7895225088661281332, "srsjscgbnyrhrpmo", -1908698583, -777280648, -562221736344996425);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(tinyint_type_tag_name) TAGS(-86) (ts,nchar_type_col_name) VALUES ("2016-12-16 03:12:18", "vcjkutzmjnmwreep");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(f,tinyint_type_tag_name) TAGS(-6.142189587223866e+37, -107) (ts,uint_type_col_name,usmallint_type_col_name,bigint_type_col_name,geometry_type_col_name,double_type_col_name,nchar_type_col_name,utinyint_type_col_name,speed,tinyint_type_col_name,ubigint_type_col_name,varbinary_type_col_name) VALUES ("2016-12-16 03:16:08", -1334666808, 16860, 3563429449831894323, "point(1.0 1.0)", -6.706661740752272e+307, "vmfhrazqvgrsyjbi", 106, -2118429478, -24, -5510629554223761040, "hcpvgxxsqivxahrs");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(geometry_type_tag_name,varbinary_type_tag_name,f,b,tinyint_type_tag_name,utinyint_type_tag_name) TAGS("point(1.0 1.0)", "ycquvwnecivxvdkq", 1.0805517348297708e+38, "qvdfdhvjokfwimfb", -16, -28) (ts,color,varbinary_type_col_name) VALUES ("2016-12-16 03:24:44", "khyzooeyfjsndqbl", "mxeaotkheqyjkwfe");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(f,double_type_tag_name,nchar_type_tag_name,tinyint_type_tag_name,bigint_type_tag_name,bool_type_tag_name,ubigint_type_tag_name,uint_type_tag_name) TAGS(-2.6250101215841932e+38, -1.4224845739873728e+308, "vitarwbjdtoaouwk", -21, 2835005149249208489, False, -2853745842969962537, 2818492304) (ts,float_type_col_name,varbinary_type_col_name,speed,utinyint_type_col_name,double_type_col_name,uint_type_col_name) VALUES ("2016-12-16 03:33:59", 4.143242721974893e+37, "tkcfmjxczscjjbfw", -126722956, 32, 1.5620105176463347e+308, -403334517);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(f,bool_type_tag_name,usmallint_type_tag_name,varbinary_type_tag_name,uint_type_tag_name) TAGS(1.1219685887309601e+38, True, 38172, "yjkrksyfhkqpxulw", 3797495177) (ts,double_type_col_name,ubigint_type_col_name,speed,nchar_type_col_name,smallint_type_col_name,usmallint_type_col_name) VALUES ("2016-12-16 03:37:00", 4.3397415421427257e+307, 2658580196646742125, 1848731552, "dauismisbvpldvbh", -8915, -10205);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(double_type_tag_name,nchar_type_tag_name,f,bool_type_tag_name,varchar_type_tag_name,bigint_type_tag_name,int_type_tag_name,usmallint_type_tag_name,varbinary_type_tag_name,smallint_type_tag_name,ubigint_type_tag_name,geometry_type_tag_name,b,utinyint_type_tag_name) TAGS(1.8933544224270275e+307, "xeuwzufexkviruji", -1.0719023172814157e+38, False, "etafmdbercjranpw", 8783154341984945645, 1620912647, 35459, "amdmlvxpympytkxq", 27136, 4977907901152915273, "point(1.0 1.0)", "sndpqcboosvhuzuq", -27) (ts) VALUES ("2016-12-16 03:38:29");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(ubigint_type_tag_name,f,int_type_tag_name,varbinary_type_tag_name,usmallint_type_tag_name,varchar_type_tag_name,smallint_type_tag_name,b,geometry_type_tag_name,uint_type_tag_name) TAGS(-1374459770575094448, 2.693293747482498e+38, 650971033, "pmviadhwiouunffs", 44961, "nxvgxzcwabujtppn", 17943, "pcctjatkdlbevdrn", "point(1.0 1.0)", 1568392342) (ts,utinyint_type_col_name,varbinary_type_col_name,nchar_type_col_name,float_type_col_name) VALUES ("2016-12-16 03:50:53", 37, "tqdxypikpbpopiid", "evjbmpbxsscpssei", 2.890872457201385e+38);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(double_type_tag_name,nchar_type_tag_name,uint_type_tag_name,varbinary_type_tag_name,varchar_type_tag_name,b,utinyint_type_tag_name,bool_type_tag_name,geometry_type_tag_name,bigint_type_tag_name,ubigint_type_tag_name,tinyint_type_tag_name,usmallint_type_tag_name,int_type_tag_name,smallint_type_tag_name) TAGS(3.1967188798436023e+307, "dlqosxrxmrdlexvu", 490088010, "abfyijmjhtypgmjo", "vrjjkvfezfqjsjxn", "jguyfszmyqtoaiuy", 15, False, "point(1.0 1.0)", 7656873837277040486, -2879397104283241297, 79, 1548, 474297665, 27763) (ts,usmallint_type_col_name,tinyint_type_col_name,float_type_col_name,ubigint_type_col_name,varchar_type_col_name,speed,uint_type_col_name,geometry_type_col_name,double_type_col_name,utinyint_type_col_name,color,varbinary_type_col_name) VALUES ("2016-12-16 04:02:41", -22725, 121, -1.7363002143786742e+38, -5956529834331945772, "fdebpzbdywcxygxq", -1037829517, -344092943, "point(1.0 1.0)", 1.687974407803454e+308, -15, "njduhepaglkeckdd", "svrtpquvktqimuab");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(f,smallint_type_tag_name,geometry_type_tag_name,usmallint_type_tag_name,int_type_tag_name,tinyint_type_tag_name,utinyint_type_tag_name,varbinary_type_tag_name,bigint_type_tag_name,bool_type_tag_name,ubigint_type_tag_name,uint_type_tag_name) TAGS(2.0855939441502307e+38, 31096, "point(1.0 1.0)", 1835, -1486483188, -63, -123, "dhfkbddofbppzizu", -8035802647163979457, True, -7483826213921795749, 795995100) (ts,geometry_type_col_name,bigint_type_col_name) VALUES ("2016-12-16 04:10:21", "point(1.0 1.0)", 1969408246531214471);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(usmallint_type_tag_name,tinyint_type_tag_name,ubigint_type_tag_name,utinyint_type_tag_name,varbinary_type_tag_name,int_type_tag_name,double_type_tag_name,nchar_type_tag_name,b,f,geometry_type_tag_name,smallint_type_tag_name) TAGS(25593, 43, 7818398761945137262, -55, "vpwzpopkwmijjyqx", 826644318, -8.222056376363248e+307, "jjxxlxujrdkmkqez", "hkzvxvlmluxfhiao", 9.217736393675792e+37, "point(1.0 1.0)", 13064) (ts,float_type_col_name,geometry_type_col_name,nchar_type_col_name,tinyint_type_col_name,usmallint_type_col_name,ubigint_type_col_name,smallint_type_col_name,bool_type_col_name,utinyint_type_col_name,varchar_type_col_name,double_type_col_name,uint_type_col_name,bigint_type_col_name,varbinary_type_col_name) VALUES ("2016-12-16 04:12:51", -1.1155033313780145e+38, "point(1.0 1.0)", "vwwljlxnuieozvfo", 5, -21906, 166234169597926020, -26423, True, -124, "johlaoepdvtqhimi", 1.6733911742274567e+308, 2100308092, 5485398075914940612, "goqmambtlodgwgxq");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(geometry_type_tag_name,bigint_type_tag_name,tinyint_type_tag_name,int_type_tag_name,double_type_tag_name,usmallint_type_tag_name,bool_type_tag_name,varchar_type_tag_name,b,uint_type_tag_name,f) TAGS("point(1.0 1.0)", -303959115421074377, 55, 58404549, 1.1317582542682038e+308, 8228, False, "bctnlrzfozjhicdk", "tgtjnkhoxjrqmnmu", 2346764198, -1.431762906013641e+38) (ts,float_type_col_name,speed,bigint_type_col_name,smallint_type_col_name) VALUES ("2016-12-16 04:13:42", 9.989635187087936e+37, -1325033823, 6439771353766292866, -8002);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(nchar_type_tag_name) TAGS("zsmwyzfqmozmyniw") (ts,bool_type_col_name,speed,varbinary_type_col_name,uint_type_col_name,varchar_type_col_name,geometry_type_col_name,double_type_col_name,utinyint_type_col_name,bigint_type_col_name) VALUES ("2016-12-16 04:21:19", True, -1595645133, "fcmpqbuxdduvfwrq", -1256972424, "doijzwclrxdbzwwq", "point(1.0 1.0)", 6.027483417919201e+307, 107, 5847005732723402961);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(double_type_tag_name,smallint_type_tag_name,varchar_type_tag_name,usmallint_type_tag_name,b,geometry_type_tag_name,uint_type_tag_name,ubigint_type_tag_name) TAGS(1.9234061768725975e+306, 27143, "dlsvyehikpxuzggw", 18465, "xhwupqgazckmiobv", "point(1.0 1.0)", 1009963833, 2202148978430704618) (ts,nchar_type_col_name,color,tinyint_type_col_name,ubigint_type_col_name) VALUES ("2016-12-16 04:25:17", "qshpnutukcvqxtaj", "zryqatfkrrhxravq", -123, 5614613512735569542);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(smallint_type_tag_name,bigint_type_tag_name,uint_type_tag_name,ubigint_type_tag_name,geometry_type_tag_name,usmallint_type_tag_name,double_type_tag_name,varchar_type_tag_name,bool_type_tag_name,nchar_type_tag_name,tinyint_type_tag_name,int_type_tag_name,varbinary_type_tag_name,b,f,utinyint_type_tag_name) TAGS(-25502, -4694006038921375834, 4273176734, -7092260276769281916, "point(1.0 1.0)", 3016, 1.6354692626546982e+308, "hjbzklszxdzdoxqn", False, "dexhfkdiumjzdbtu", 55, 1628959, "caeogfirfkzuqrgm", "kklniqcfjgtnpaat", 1.2381441388115072e+38, 34) (ts,smallint_type_col_name,float_type_col_name,uint_type_col_name,nchar_type_col_name,geometry_type_col_name,varchar_type_col_name,varbinary_type_col_name) VALUES ("2016-12-16 04:30:12", -15424, -9.958486706164754e+37, 1543951155, "uonnnwqaxjnzcktw", "point(1.0 1.0)", "sbnhooyzwvvvgdsb", "iguafwamsgzdtcid");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(tinyint_type_tag_name,bigint_type_tag_name,nchar_type_tag_name,geometry_type_tag_name,usmallint_type_tag_name,b,smallint_type_tag_name,f,ubigint_type_tag_name,int_type_tag_name,uint_type_tag_name,varchar_type_tag_name) TAGS(125, 7128483423223572360, "wknmbdmxriwytuzs", "point(1.0 1.0)", 23719, "cehohszybqisbcsr", 29052, -1.2266502524670797e+38, -5190174475276867332, -1054122176, 3316814729, "zeympzallufrrwwk") (ts,float_type_col_name) VALUES ("2016-12-16 04:42:07", -3.0086436232306867e+38);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(usmallint_type_tag_name,smallint_type_tag_name) TAGS(24922, 19120) (ts,ubigint_type_col_name,varbinary_type_col_name,bool_type_col_name,bigint_type_col_name,usmallint_type_col_name,tinyint_type_col_name) VALUES ("2016-12-16 04:44:37", 2119708740431033246, "tfscgthihrecwcca", True, 3858755530043058209, 16911, 49);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(bool_type_tag_name,geometry_type_tag_name,varchar_type_tag_name,int_type_tag_name,nchar_type_tag_name,uint_type_tag_name,tinyint_type_tag_name,utinyint_type_tag_name,smallint_type_tag_name,double_type_tag_name,usmallint_type_tag_name) TAGS(False, "point(1.0 1.0)", "lgomrzeuveghuavk", 698597980, "fibwfbupmoxwxwhu", 2299571086, 88, 26, -784, 5.836820071314546e+307, 44181) (ts,color,nchar_type_col_name,ubigint_type_col_name,float_type_col_name,utinyint_type_col_name,usmallint_type_col_name,geometry_type_col_name,varchar_type_col_name,tinyint_type_col_name,double_type_col_name,speed,uint_type_col_name,bigint_type_col_name,varbinary_type_col_name,smallint_type_col_name) VALUES ("2016-12-16 04:48:53", "fdrpbbuwolrgigwu", "ovkkzehagcozavag", -859824747452770489, 2.668460352935784e+38, -36, -4146, "point(1.0 1.0)", "zpnfvkdabqhvvugr", 122, -1.6659109789494941e+308, -339715491, -744820813, 4922622614018944659, "drckbshqwqdgjywk", 26922);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(varchar_type_tag_name,nchar_type_tag_name,bool_type_tag_name,varbinary_type_tag_name,usmallint_type_tag_name,geometry_type_tag_name,utinyint_type_tag_name,b,bigint_type_tag_name,uint_type_tag_name,tinyint_type_tag_name,double_type_tag_name) TAGS("fnudpzattpadznjh", "curlvpnayxqyhgnj", True, "qujeqlinronfmnra", 26904, "point(1.0 1.0)", 103, "rmdyvbxvfscrklat", 1772757837581587144, 3755231946, -28, 1.392881389803201e+308) (ts) VALUES ("2016-12-16 04:49:43");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(geometry_type_tag_name,smallint_type_tag_name,usmallint_type_tag_name,f,uint_type_tag_name,b,varbinary_type_tag_name,bigint_type_tag_name,utinyint_type_tag_name) TAGS("point(1.0 1.0)", 23766, 34510, -9.391278476138455e+37, 1424312679, "usmzlgendwxwjzkd", "gfsuserzmdovezbh", -3630795755071364737, 33) (ts,ubigint_type_col_name,speed,bool_type_col_name,smallint_type_col_name,geometry_type_col_name,varbinary_type_col_name,usmallint_type_col_name) VALUES ("2016-12-16 05:08:42", 9043564226598764196, -1058070689, True, -27689, "point(1.0 1.0)", "jkcbtfqphclecaiw", -2968);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(nchar_type_tag_name,bigint_type_tag_name,b) TAGS("dtpxqkpvzwqhqtlf", 8497835948198860590, "labufkbmgoaihoke") (ts,speed,uint_type_col_name,ubigint_type_col_name,utinyint_type_col_name,usmallint_type_col_name,varchar_type_col_name,color,varbinary_type_col_name,tinyint_type_col_name,smallint_type_col_name,nchar_type_col_name,bigint_type_col_name,float_type_col_name,bool_type_col_name,double_type_col_name) VALUES ("2016-12-16 05:32:32", -1915664223, 1413499274, -5989223773653851128, -116, 26921, "ownicmwaptorttec", "ygzvhoyputddyowk", "wrkogplcbpemkxdn", -33, 18817, "clrhqokhsspzbxgc", -859502208102825417, -1.5128753403587181e+38, True, -1.3508466034943649e+308);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(geometry_type_tag_name,varbinary_type_tag_name,int_type_tag_name,b,tinyint_type_tag_name,double_type_tag_name,ubigint_type_tag_name,bigint_type_tag_name,uint_type_tag_name) TAGS("point(1.0 1.0)", "uvvthorbwmsnfjoz", 1030009117, "tyysttboblgpkypz", -69, 1.23842724503325e+308, 9192485125431744596, 29000826379644817, 3538861351) (ts) VALUES ("2016-12-16 05:41:58");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(int_type_tag_name,bool_type_tag_name,varchar_type_tag_name,utinyint_type_tag_name,ubigint_type_tag_name,tinyint_type_tag_name,double_type_tag_name,f,varbinary_type_tag_name,b,uint_type_tag_name,bigint_type_tag_name,geometry_type_tag_name,usmallint_type_tag_name,smallint_type_tag_name) TAGS(859129059, True, "uxbtbeicqswhoomz", -62, 3734511001108851286, 34, -1.5815188393505786e+308, 4.745631034394835e+37, "qoxpifitbedupend", "ppnqdxusgmlszoqw", 1004378621, 3705733919632701068, "point(1.0 1.0)", 38489, 29461) (ts,tinyint_type_col_name,usmallint_type_col_name,varchar_type_col_name,color,geometry_type_col_name,float_type_col_name,bool_type_col_name,speed,double_type_col_name,bigint_type_col_name,varbinary_type_col_name,uint_type_col_name) VALUES ("2016-12-16 06:08:50", 76, 12466, "nujbmtudnrleyvdy", "bgzmcovdcpghdlzi", "point(1.0 1.0)", -1.7192977879525407e+38, False, -910281174, 1.5781580952881898e+308, -3488933529074665133, "tfrgpkdcgqesmvbt", -1938221877);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(nchar_type_tag_name,varchar_type_tag_name,tinyint_type_tag_name,utinyint_type_tag_name,f,double_type_tag_name,bigint_type_tag_name,int_type_tag_name,usmallint_type_tag_name,bool_type_tag_name,smallint_type_tag_name,geometry_type_tag_name,b,ubigint_type_tag_name,varbinary_type_tag_name) TAGS("zfsuqkilwplvrebi", "ccqtsosvtnlbnkig", 103, 78, 1.3362517686508279e+38, -9.563002829076875e+307, -6627606384484374568, 1126761657, 27844, True, 30861, "point(1.0 1.0)", "hmnpllitztvocynw", 8180438212890952155, "qfekhbflxpldbddz") (ts,varchar_type_col_name,geometry_type_col_name,uint_type_col_name,usmallint_type_col_name) VALUES ("2016-12-16 06:12:48", "kavbtvnlqfmeyfgh", "point(1.0 1.0)", 86018588, 3835);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(nchar_type_tag_name,bigint_type_tag_name,utinyint_type_tag_name,varbinary_type_tag_name,varchar_type_tag_name,geometry_type_tag_name,int_type_tag_name) TAGS("rfnbxcuzeizhglks", 7283103569704428551, 94, "dudcfczmlnwyrkvp", "geivplrozxtocipa", "point(1.0 1.0)", -1224429691) (ts,float_type_col_name,varbinary_type_col_name,double_type_col_name,tinyint_type_col_name,uint_type_col_name) VALUES ("2016-12-16 06:26:38", -1.3097826665873164e+37, "xwfgtqoddvxyhcre", 1.5229330656778251e+308, 118, 1385681942);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(ubigint_type_tag_name,nchar_type_tag_name,bigint_type_tag_name,utinyint_type_tag_name) TAGS(9169294385094804151, "rdibiqdizmdrkfrf", 3962954747786936314, 54) (ts,geometry_type_col_name,varbinary_type_col_name,utinyint_type_col_name,smallint_type_col_name,float_type_col_name,tinyint_type_col_name,bigint_type_col_name,speed) VALUES ("2016-12-16 06:32:37", "point(1.0 1.0)", "ciymbzfmbfqqsxkv", -76, 32317, -9.09960741209682e+37, 77, 3789368028357457617, -432822270);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(double_type_tag_name,f,tinyint_type_tag_name,varchar_type_tag_name,bool_type_tag_name,utinyint_type_tag_name,bigint_type_tag_name,smallint_type_tag_name,int_type_tag_name,b,geometry_type_tag_name,nchar_type_tag_name,usmallint_type_tag_name,varbinary_type_tag_name) TAGS(-1.2944016628561449e+308, 7.983554080975201e+37, 53, "fcbmysknvqvehfiz", True, -6, -8922838578018838847, -20254, 1722340321, "wrrcjsdfwrihjnqy", "point(1.0 1.0)", "yflqloxmpchzkdts", 57539, "kvvzxzerqnmnzxwk") (ts,nchar_type_col_name,tinyint_type_col_name,ubigint_type_col_name,geometry_type_col_name,usmallint_type_col_name,double_type_col_name,varchar_type_col_name,uint_type_col_name,bool_type_col_name,speed,bigint_type_col_name,varbinary_type_col_name,utinyint_type_col_name) VALUES ("2016-12-16 06:34:00", "mrzcfbzniotxzbdi", 58, 7707860227701048488, "point(1.0 1.0)", 31402, -5.6095749182351896e+306, "ibzewxdivctecfot", -1652235605, False, -933263235, 384543174410180162, "woixarpkcucglfey", 124);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(double_type_tag_name,tinyint_type_tag_name,nchar_type_tag_name,bool_type_tag_name,bigint_type_tag_name,geometry_type_tag_name,uint_type_tag_name,varchar_type_tag_name,int_type_tag_name,varbinary_type_tag_name,utinyint_type_tag_name) TAGS(-5.930942323411467e+307, -121, "ckbowkjukztkjqoi", True, -2618046353021226711, "point(1.0 1.0)", 2166418040, "yxhuoimpnuqhlhgw", -1659085223, "zeyylgulwwdnwsii", -3) (ts,bigint_type_col_name) VALUES ("2016-12-16 06:34:14", -4941469222634542296);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(bigint_type_tag_name,b,tinyint_type_tag_name,varbinary_type_tag_name,smallint_type_tag_name,double_type_tag_name,nchar_type_tag_name,bool_type_tag_name,utinyint_type_tag_name,f,uint_type_tag_name) TAGS(5489251136620324287, "igrbjdomcwywiekb", -25, "xhhaerxfxfobwcvn", 14001, -1.796912338313077e+307, "umtnvilvgmbxbxsq", True, 43, -1.8528500716419152e+38, 1497513541) (ts) VALUES ("2016-12-16 06:35:34");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(bigint_type_tag_name,ubigint_type_tag_name,f,b,bool_type_tag_name,geometry_type_tag_name,utinyint_type_tag_name,nchar_type_tag_name,smallint_type_tag_name,int_type_tag_name,usmallint_type_tag_name,varchar_type_tag_name) TAGS(2431406493780788447, 4861403703027821860, 1.99259675649246e+38, "yzdneqzibyuwrypn", True, "point(1.0 1.0)", -127, "llytlpdymtuetvfm", -25050, -543736632, 11798, "dgznnsdqgrnrmazq") (ts,bool_type_col_name) VALUES ("2016-12-16 06:36:04", False);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(smallint_type_tag_name,tinyint_type_tag_name,double_type_tag_name,varbinary_type_tag_name,varchar_type_tag_name,geometry_type_tag_name) TAGS(-5334, -79, 1.2315866993517746e+308, "mywxqnmbjqsxdsff", "dahqwtcwipwwbdye", "point(1.0 1.0)") (ts,uint_type_col_name,bigint_type_col_name,geometry_type_col_name,varbinary_type_col_name,tinyint_type_col_name,speed,bool_type_col_name,color,ubigint_type_col_name,float_type_col_name) VALUES ("2016-12-16 07:08:57", -703937341, 508746925742892883, "point(1.0 1.0)", "yymznbjazhklgjxb", 12, 1587775618, True, "ozzyhsagmrpiyrjq", 5401400824616407615, -1.7440186980309764e+37);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(double_type_tag_name,varchar_type_tag_name,tinyint_type_tag_name,bigint_type_tag_name,bool_type_tag_name,geometry_type_tag_name,usmallint_type_tag_name,ubigint_type_tag_name,b,utinyint_type_tag_name,f,smallint_type_tag_name) TAGS(-7.999887918520793e+307, "qwbmvcvwhlkxwwld", 21, 468530456171689843, True, "point(1.0 1.0)", 10723, 4059334937310534108, "wgqsiptkcwhvmjwe", 99, -5.310912588143673e+37, -17363) (ts,float_type_col_name,geometry_type_col_name,smallint_type_col_name,varbinary_type_col_name,uint_type_col_name,speed,nchar_type_col_name,color,ubigint_type_col_name,bigint_type_col_name,usmallint_type_col_name,tinyint_type_col_name) VALUES ("2016-12-16 07:14:40", 2.8869331003756176e+38, "point(1.0 1.0)", -29659, "tbhqqyiqgtgckyyg", -471326270, 944696481, "ysahvyevqkwulqqv", "lzhzxslfmdzwsxpf", -9113216317948681955, 3545622045223678570, -25303, -80);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(nchar_type_tag_name) TAGS("auxtouxzloojhqtf") (ts,varbinary_type_col_name,nchar_type_col_name,double_type_col_name,color) VALUES ("2016-12-16 07:15:30", "ddluzbitxrtbkjbj", "ljgnuemqzlbotqwi", -5.352451641324967e+307, "suwegzsujiqfyvqt");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(b,geometry_type_tag_name,utinyint_type_tag_name,double_type_tag_name,nchar_type_tag_name,uint_type_tag_name,bigint_type_tag_name,int_type_tag_name,varbinary_type_tag_name,smallint_type_tag_name,bool_type_tag_name,ubigint_type_tag_name,varchar_type_tag_name,usmallint_type_tag_name,tinyint_type_tag_name,f) TAGS("pizyvqqjzxhkofpm", "point(1.0 1.0)", -22, 1.5081448005935855e+308, "ufwxcfxfunjhxxzm", 282211280, 4861090276718143202, -2091585085, "lbxpmtsvtpucnlzy", -30781, False, 124484168740646, "yjuefabvljbxrgsx", 33815, -72, -1.128908264468181e+38) (ts,bigint_type_col_name,ubigint_type_col_name,bool_type_col_name,varchar_type_col_name,double_type_col_name,smallint_type_col_name,tinyint_type_col_name,uint_type_col_name,speed,geometry_type_col_name) VALUES ("2016-12-16 07:17:15", 1001689612302252183, -105401984359440882, False, "wbbktwsethudmtja", -4.557626601447439e+307, 21541, -98, -2080051974, -1861023150, "point(1.0 1.0)");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(uint_type_tag_name,varchar_type_tag_name,varbinary_type_tag_name,int_type_tag_name,bigint_type_tag_name,geometry_type_tag_name) TAGS(2320968032, "dhquczttiqbnfyjr", "cixjeekgvvixcbud", -484475030, -4789196290580581091, "point(1.0 1.0)") (ts,bigint_type_col_name,varbinary_type_col_name,nchar_type_col_name,double_type_col_name,speed,color,varchar_type_col_name,bool_type_col_name,uint_type_col_name,ubigint_type_col_name,smallint_type_col_name,utinyint_type_col_name,float_type_col_name) VALUES ("2016-12-16 07:18:05", -1206873661752154164, "pjkbldrvpglbnulx", "dztdpobuyksgdhgt", -1.1951640769154985e+308, 542907991, "ekubcyxbjiciigss", "xnxufupmzhskjmpq", False, 267042413, 3084280261011428030, 26039, 31, 2.539995004940438e+38);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(ubigint_type_tag_name,uint_type_tag_name,varbinary_type_tag_name,bool_type_tag_name,tinyint_type_tag_name,nchar_type_tag_name,int_type_tag_name,double_type_tag_name) TAGS(-4414306501424620178, 4231079052, "mthgdnjdhnjraffo", False, -106, "hwcjdivkccrlukjw", 1762002945, -1.0781154156730552e+307) (ts,float_type_col_name,varbinary_type_col_name,usmallint_type_col_name,double_type_col_name,speed,varchar_type_col_name,nchar_type_col_name,utinyint_type_col_name,bigint_type_col_name,bool_type_col_name,geometry_type_col_name,uint_type_col_name,smallint_type_col_name,ubigint_type_col_name,color,tinyint_type_col_name) VALUES ("2016-12-16 07:24:51", -8.579854162437403e+37, "izylbbcyhuxvmohl", -11832, -1.238446106977585e+308, 1414832325, "nukonaftikjqqbdj", "cykvszvrxguiajwg", -28, -4542731759437382057, False, "point(1.0 1.0)", -250287824, -22672, 2059749290085408427, "wvojjnanujjbrjbk", 37);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(utinyint_type_tag_name,uint_type_tag_name,usmallint_type_tag_name,bool_type_tag_name,bigint_type_tag_name,geometry_type_tag_name,varchar_type_tag_name,b,nchar_type_tag_name,int_type_tag_name) TAGS(-87, 3054590850, 10240, False, 7471097903390818886, "point(1.0 1.0)", "gvmesmuwkboibbwm", "qnkzvaetvvsoliqw", "tsaezwjdobewrsgg", 718941504) (ts,uint_type_col_name,bool_type_col_name,color,varchar_type_col_name,speed,utinyint_type_col_name,tinyint_type_col_name,bigint_type_col_name,nchar_type_col_name) VALUES ("2016-12-16 07:47:31", -1418250282, True, "cxyfgdrwrdryoxdv", "urqrvjnzpghqycjl", 1139755242, -53, -40, -3750115493851220318, "yvystiojfnkeinwv");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(usmallint_type_tag_name) TAGS(11662) (ts,float_type_col_name,smallint_type_col_name,nchar_type_col_name,bigint_type_col_name,bool_type_col_name,tinyint_type_col_name,uint_type_col_name,speed,varchar_type_col_name,varbinary_type_col_name,usmallint_type_col_name,color,double_type_col_name,utinyint_type_col_name,geometry_type_col_name) VALUES ("2016-12-16 07:47:42", 1.5652814126254586e+38, 31965, "jzglkmapiqvmkcgt", -456718528158805320, True, 13, 1550395191, -468850482, "qsuieurxcdhljsyg", "pimzexqqdusasasq", -25133, "heaqwaulngjummmj", 1.4472853493781175e+307, -100, "point(1.0 1.0)");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(geometry_type_tag_name,tinyint_type_tag_name,b,varbinary_type_tag_name,int_type_tag_name,bool_type_tag_name,bigint_type_tag_name,usmallint_type_tag_name,varchar_type_tag_name,utinyint_type_tag_name,uint_type_tag_name,ubigint_type_tag_name) TAGS("point(1.0 1.0)", 71, "egjrjdgnsdelmvoi", "nnvaiqrgsmsgulsf", -1764160281, False, -3170988760692140923, 59567, "vvwezjglauxztbkw", -28, 3876664873, 2077268665321637137) (ts,geometry_type_col_name,ubigint_type_col_name,utinyint_type_col_name,speed,varbinary_type_col_name,float_type_col_name,bigint_type_col_name,color) VALUES ("2016-12-16 07:53:43", "point(1.0 1.0)", -8518449815289332525, -90, -1716688898, "llphooyquheusfis", 1.8971999924428717e+38, 6265618875544853883, "mhnrsjknurfeejin");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(utinyint_type_tag_name,int_type_tag_name,usmallint_type_tag_name,bool_type_tag_name,uint_type_tag_name,bigint_type_tag_name,varbinary_type_tag_name,geometry_type_tag_name,f,double_type_tag_name,smallint_type_tag_name,nchar_type_tag_name,varchar_type_tag_name,ubigint_type_tag_name) TAGS(-107, -1135898492, 7359, True, 2054944069, -5204892746217048371, "dtbkgxohffiiqvex", "point(1.0 1.0)", -1.6139634795645272e+38, -3.4474223981039393e+307, -4519, "geosetpzbiyvrxsl", "owahukwcrwnazqmg", -6817825300706607165) (ts,nchar_type_col_name) VALUES ("2016-12-16 07:57:23", "yfefrbnkzlnvszku");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(b,varbinary_type_tag_name,utinyint_type_tag_name,tinyint_type_tag_name,geometry_type_tag_name,uint_type_tag_name) TAGS("gujkmscmzrumlzgr", "kyjkxjmmiujedyoc", -63, -30, "point(1.0 1.0)", 3040843900) (ts,varbinary_type_col_name,uint_type_col_name,usmallint_type_col_name,tinyint_type_col_name,bigint_type_col_name,nchar_type_col_name,float_type_col_name,bool_type_col_name,utinyint_type_col_name,speed,varchar_type_col_name,smallint_type_col_name,ubigint_type_col_name,color) VALUES ("2016-12-16 08:00:58", "tzthqrttxnhexwie", -1719097053, 12664, 92, 8111449057800298881, "ckhlhqkuqbbkkqbc", -1.2378307380230564e+38, True, -77, 832149914, "zhaatkireunhqjmr", 10552, -1885112753329295315, "etiwbiqspffpftuy");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(bigint_type_tag_name,uint_type_tag_name,usmallint_type_tag_name,int_type_tag_name,bool_type_tag_name,tinyint_type_tag_name,smallint_type_tag_name,f,b,nchar_type_tag_name,varbinary_type_tag_name,double_type_tag_name,geometry_type_tag_name,ubigint_type_tag_name,varchar_type_tag_name,utinyint_type_tag_name) TAGS(6936877712832826111, 379134044, 5584, -873981273, True, -36, 23332, 3.0590465783887826e+38, "doyrcpkmqdmkvisu", "ebrzlgpzjdhwgbkg", "favnzcgrgbqhjykc", -5.409211271125824e+306, "point(1.0 1.0)", 7020490078397766201, "dfmaignpkotpzfzp", 0) (ts,utinyint_type_col_name,color,tinyint_type_col_name,usmallint_type_col_name,speed,float_type_col_name,smallint_type_col_name,varbinary_type_col_name,uint_type_col_name,bool_type_col_name,double_type_col_name) VALUES ("2016-12-16 08:08:05", 100, "embwiippvzztzfsx", -29, 30679, 398157649, -2.8271578721561e+38, 16481, "eapyuftmoemhlous", 1346563710, False, 1.2527960914103297e+308);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(usmallint_type_tag_name,varchar_type_tag_name,f,int_type_tag_name) TAGS(14445, "frbgwoxdfgvomhij", 3.112685005605257e+38, 919563343) (ts,smallint_type_col_name,uint_type_col_name,nchar_type_col_name,color,tinyint_type_col_name,utinyint_type_col_name,double_type_col_name,float_type_col_name,bigint_type_col_name,usmallint_type_col_name) VALUES ("2016-12-16 08:10:32", 30534, 287062448, "radqyprkqzicegcm", "digmvwqxesuzblxo", -45, 57, 4.2367818689200055e+307, -1.2630859264197575e+38, 5777026179863424498, -18041);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(tinyint_type_tag_name,geometry_type_tag_name,b) TAGS(-125, "point(1.0 1.0)", "sknwbldiaotpguoh") (ts,geometry_type_col_name,speed,bool_type_col_name,uint_type_col_name,nchar_type_col_name,tinyint_type_col_name,smallint_type_col_name,bigint_type_col_name,usmallint_type_col_name,varchar_type_col_name,float_type_col_name,varbinary_type_col_name,double_type_col_name) VALUES ("2016-12-16 08:21:15", "point(1.0 1.0)", -533077180, True, 125980213, "rzpvyyiafbdgsrlt", -18, 516, 1836336637894618829, -32398, "qyolcbkiphumcyni", -1.7088547654566307e+38, "uhfuttyjdsiwfpge", 9.045738084106129e+307);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(nchar_type_tag_name,varchar_type_tag_name) TAGS("eibgfpzivbkqipxh", "bajctkjmycezvfjy") (ts,uint_type_col_name,nchar_type_col_name,geometry_type_col_name,speed,varbinary_type_col_name,varchar_type_col_name,ubigint_type_col_name,usmallint_type_col_name) VALUES ("2016-12-16 08:27:17", 182114551, "bqoiqgcelwawaxoh", "point(1.0 1.0)", -2048616567, "ngeyahwjhojgfrji", "ajndkftrjrhebhkh", 7449846270987100591, 21014);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(ubigint_type_tag_name,double_type_tag_name) TAGS(-4625726455522573231, 2.8073063831603936e+307) (ts,float_type_col_name,bigint_type_col_name,uint_type_col_name,usmallint_type_col_name,color,varchar_type_col_name,tinyint_type_col_name,nchar_type_col_name,bool_type_col_name,varbinary_type_col_name,geometry_type_col_name,utinyint_type_col_name) VALUES ("2016-12-16 08:28:17", 2.389718468668489e+38, 232575111591325522, 1038517632, 22294, "gkuqyywzvitscnmf", "pzotmkbymjkajqxh", 84, "zwaqqoiitsaldvxd", False, "lutscwlzfncvtbzh", "point(1.0 1.0)", 104);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(ubigint_type_tag_name,varchar_type_tag_name,utinyint_type_tag_name,geometry_type_tag_name,smallint_type_tag_name,usmallint_type_tag_name,int_type_tag_name,b,uint_type_tag_name,f,varbinary_type_tag_name,nchar_type_tag_name,double_type_tag_name,tinyint_type_tag_name,bool_type_tag_name,bigint_type_tag_name) TAGS(3789358482002489003, "cbbfcxtbficxjubk", 87, "point(1.0 1.0)", 16290, 65141, 1107108066, "dbvdcpsxhwxkfcyz", 1995515016, 2.7409223337049425e+38, "qngmplwikoseyylt", "tgzwjjwlcizxxwnr", -1.6889546962063194e+308, -114, False, -3482122891531832648) (ts,nchar_type_col_name,tinyint_type_col_name,geometry_type_col_name,double_type_col_name,color,smallint_type_col_name,speed,usmallint_type_col_name,ubigint_type_col_name,varbinary_type_col_name,bigint_type_col_name,varchar_type_col_name,utinyint_type_col_name,float_type_col_name,bool_type_col_name,uint_type_col_name) VALUES ("2016-12-16 08:28:56", "ofdxnlygqcwvsdcj", -29, "point(1.0 1.0)", -1.8130271598650515e+307, "nefvavoukqtdzkgt", -17717, 1471102951, -22978, 6641200189088106550, "tzjbozbjlczkgwxa", -6094740512181599472, "etogqzsgcqipiztv", 83, 3.26367598847478e+38, False, -748583096);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(f,uint_type_tag_name,nchar_type_tag_name,bool_type_tag_name,double_type_tag_name,int_type_tag_name,tinyint_type_tag_name) TAGS(-3.3072135298943572e+38, 1159943179, "kswqkzvltgixlmfs", True, -4.306722847726777e+307, 232669674, 110) (ts,double_type_col_name,smallint_type_col_name,utinyint_type_col_name,bool_type_col_name,tinyint_type_col_name,color,float_type_col_name,bigint_type_col_name,uint_type_col_name,geometry_type_col_name,ubigint_type_col_name,usmallint_type_col_name,nchar_type_col_name,varbinary_type_col_name,varchar_type_col_name) VALUES ("2016-12-16 08:32:49", 6.47061313170663e+307, 10319, -39, False, 11, "zrdnjfphcwpeinqc", -1.9983066068141309e+37, -7934490781005501591, 254843018, "point(1.0 1.0)", 3715382894868674189, 15127, "czgcvwrtlnhrftfw", "mmsahbdykxugoszh", "oarqmzgnlqfgoetb");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(varchar_type_tag_name,usmallint_type_tag_name,nchar_type_tag_name,double_type_tag_name,bigint_type_tag_name,b,f) TAGS("eqpvdmknfwrubsuz", 25062, "viftdmeaoemnzlte", -8.206973826119586e+307, -3370842340933526422, "laotfjfckrruwnso", 1.6151693420601788e+37) (ts,ubigint_type_col_name,usmallint_type_col_name,bool_type_col_name,varchar_type_col_name,uint_type_col_name,color,float_type_col_name,smallint_type_col_name) VALUES ("2016-12-16 08:39:16", 3961511905025407799, 17678, False, "donavljkknjvmamp", 1568179614, "dgtldyeuhhgqsrhz", 4.974589437659843e+37, 4642);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(b,varbinary_type_tag_name,utinyint_type_tag_name,smallint_type_tag_name,int_type_tag_name,geometry_type_tag_name,ubigint_type_tag_name,nchar_type_tag_name,double_type_tag_name,tinyint_type_tag_name,usmallint_type_tag_name,bigint_type_tag_name,uint_type_tag_name,bool_type_tag_name) TAGS("hsbqzsfvkllngzft", "oshuiqqteddxsxhg", 12, -6023, -1854137419, "point(1.0 1.0)", -7820787410908786398, "ktlafrcpckbnasok", -1.1140330045511274e+308, -121, 30336, -5235830165957712064, 1885913417, True) (ts,bigint_type_col_name,varbinary_type_col_name,utinyint_type_col_name,usmallint_type_col_name,tinyint_type_col_name,color) VALUES ("2016-12-16 08:47:05", 1101333002744137125, "ztteslebezjpmdic", 9, -16849, -109, "otxajtxgosmycgwf");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(smallint_type_tag_name,tinyint_type_tag_name,usmallint_type_tag_name,geometry_type_tag_name,varbinary_type_tag_name) TAGS(12811, 115, 11564, "point(1.0 1.0)", "fvllsyeldqjvxwvh") (ts,nchar_type_col_name,color,float_type_col_name,ubigint_type_col_name,tinyint_type_col_name,geometry_type_col_name,double_type_col_name,varbinary_type_col_name,bigint_type_col_name,uint_type_col_name) VALUES ("2016-12-16 08:52:23", "kzlebaiflssmhrez", "rmgygwigqpcedjfd", -1.0528922331364947e+38, 2053899259005385975, -4, "point(1.0 1.0)", 1.2949613471672877e+307, "xpnwhkobylhldlja", -2081901725973275838, 1084220081);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(bool_type_tag_name,int_type_tag_name,tinyint_type_tag_name,uint_type_tag_name,bigint_type_tag_name,geometry_type_tag_name,b,double_type_tag_name,nchar_type_tag_name,smallint_type_tag_name,f,varchar_type_tag_name,ubigint_type_tag_name) TAGS(False, 81017693, -59, 3106871640, 6594200175307481979, "point(1.0 1.0)", "cxlcaxjqbottjwbt", 1.0810790118515493e+307, "mzpfnozkhzccymcy", -23268, -2.5710992840734416e+38, "bzcemqcjmfensoam", -6857344180628167939) (ts,varchar_type_col_name,tinyint_type_col_name,speed,bool_type_col_name,color,nchar_type_col_name,float_type_col_name,bigint_type_col_name,double_type_col_name,utinyint_type_col_name,ubigint_type_col_name,usmallint_type_col_name,geometry_type_col_name,uint_type_col_name,smallint_type_col_name) VALUES ("2016-12-16 08:52:40", "goxjebyqxffhytny", 42, 956707019, False, "mwhbccpdjxrnlfmj", "hsswrkdrgvqzrqvc", -3.1923783000520714e+37, 6439233177980554597, 1.5462567361109987e+308, -104, 5670859655382432947, -13629, "point(1.0 1.0)", -291035521, -28198);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(int_type_tag_name,tinyint_type_tag_name,bool_type_tag_name,ubigint_type_tag_name,geometry_type_tag_name,varchar_type_tag_name,smallint_type_tag_name,f,varbinary_type_tag_name,nchar_type_tag_name,double_type_tag_name,bigint_type_tag_name) TAGS(-1951062887, -15, False, 8992786638768246075, "point(1.0 1.0)", "zkbchpvyaborestv", 14319, -2.9661092483352556e+38, "sgmkfslmxakjfqna", "hujharmlkobjdcnn", -1.3558306099409006e+308, 6268021739102999331) (ts) VALUES ("2016-12-16 09:57:37");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(usmallint_type_tag_name,f,b,bigint_type_tag_name,smallint_type_tag_name,bool_type_tag_name,ubigint_type_tag_name) TAGS(1359, 3.0441073077150407e+38, "hdozqqjsswenceob", 4323504650099562462, -468, False, 2127413600006157512) (ts) VALUES ("2016-12-16 09:57:50");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(nchar_type_tag_name,double_type_tag_name,tinyint_type_tag_name,geometry_type_tag_name,ubigint_type_tag_name,usmallint_type_tag_name,uint_type_tag_name) TAGS("jrfnpvmonxehrxqh", 5.481850803776123e+307, -72, "point(1.0 1.0)", -6843236102647158686, 12864, 3757105281) (ts) VALUES ("2016-12-16 10:04:07");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(utinyint_type_tag_name,nchar_type_tag_name,usmallint_type_tag_name,bool_type_tag_name,tinyint_type_tag_name,f,ubigint_type_tag_name,int_type_tag_name,double_type_tag_name,varchar_type_tag_name,varbinary_type_tag_name,bigint_type_tag_name,geometry_type_tag_name) TAGS(38, "gdjxupnqalfsczwf", 6556, True, 16, 2.3326392387567076e+38, -3052440068987461367, 1379207868, 9.408456780510208e+307, "yfoiebrvvxepulkf", "gyldwqexpqwtymqb", -8612949720672024630, "point(1.0 1.0)") (ts,nchar_type_col_name,tinyint_type_col_name,uint_type_col_name,varchar_type_col_name,float_type_col_name,smallint_type_col_name,speed) VALUES ("2016-12-16 10:07:23", "xhzhyldsilkilnhj", -111, 29265820, "hfayzyyeielxuajo", -1.9673771091182076e+38, -16871, -687056858);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(b,f,ubigint_type_tag_name,double_type_tag_name) TAGS("ojupiiqggvxiyyeg", 1.828613068144597e+38, -3546696963839193043, 1.063690235483227e+308) (ts,bigint_type_col_name,geometry_type_col_name,color,speed,tinyint_type_col_name,usmallint_type_col_name,double_type_col_name,utinyint_type_col_name,ubigint_type_col_name,uint_type_col_name,float_type_col_name,bool_type_col_name,varbinary_type_col_name,smallint_type_col_name,nchar_type_col_name) VALUES ("2016-12-16 10:08:10", -8093382424883326599, "point(1.0 1.0)", "cqihlukuoejlpfry", 979506951, 21, -22385, -1.5427105800265006e+308, 27, -8297437264602062727, -1746384009, 2.252643841383272e+38, True, "lyyysgtqcxnmrtup", -12771, "lfzvhkaxvgdtprxe");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(ubigint_type_tag_name,tinyint_type_tag_name,smallint_type_tag_name) TAGS(-3588987228330855806, -26, 21365) (ts,tinyint_type_col_name) VALUES ("2016-12-16 10:09:18", -32);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(uint_type_tag_name,nchar_type_tag_name,double_type_tag_name,utinyint_type_tag_name) TAGS(245950801, "yvkkiivzhbqnnmsk", -1.658703905525468e+308, 28) (ts,smallint_type_col_name) VALUES ("2016-12-16 10:13:19", 26054);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(uint_type_tag_name,bool_type_tag_name,ubigint_type_tag_name,varchar_type_tag_name,double_type_tag_name,geometry_type_tag_name,varbinary_type_tag_name,b,utinyint_type_tag_name) TAGS(1694485723, False, -474604515817697594, "rtgthkbkwlbutbgv", 2.3887324912266175e+307, "point(1.0 1.0)", "gopcjcoagmnblahg", "jwnrdxiishgvobmd", 48) (ts,nchar_type_col_name,double_type_col_name,bigint_type_col_name,uint_type_col_name,smallint_type_col_name,tinyint_type_col_name,utinyint_type_col_name) VALUES ("2016-12-16 10:19:33", "xeinqeysquavrsyz", -8.949042643309358e+305, -5607735618216794531, -1459791787, -19075, -55, -127);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(f,uint_type_tag_name,utinyint_type_tag_name,ubigint_type_tag_name,smallint_type_tag_name,geometry_type_tag_name,usmallint_type_tag_name,nchar_type_tag_name,varchar_type_tag_name,bool_type_tag_name,b,tinyint_type_tag_name,extratag,varbinary_type_tag_name) TAGS(-2.4047245829078376e+38, 2561944294, 9, -8008616984432962570, -13634, "point(1.0 1.0)", 40692, "wnbqrneelpvqwlja", "jvqvobbxkeelzunr", True, "fmdtxmzdhmejwdtg", 34, 935844453, "pejduzquhxddarph") (ts,varbinary_type_col_name,varchar_type_col_name,double_type_col_name,bool_type_col_name,nchar_type_col_name,usmallint_type_col_name) VALUES ("2016-12-16 11:27:47", "sgusymsmfcwjnpcy", "npntezujzhtxahzl", -2.8300806976493463e+307, True, "vozigylgtwuwqyxd", -29259);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(utinyint_type_tag_name,geometry_type_tag_name) TAGS(2, "point(1.0 1.0)") (ts,tinyint_type_col_name,color,double_type_col_name,smallint_type_col_name,utinyint_type_col_name,float_type_col_name,varbinary_type_col_name,bool_type_col_name,speed,nchar_type_col_name,ubigint_type_col_name,uint_type_col_name,bigint_type_col_name) VALUES ("2016-12-16 11:38:41", 65, "xbkejkdziselkysy", -1.3741827310590848e+308, 31519, -36, 5.743820075715186e+37, "gnqhbldkghybjgsu", True, 1371169555, "xhfnbxeeaaniflfh", -479840166843776187, 1922629809, -8139122071465810064);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(int_type_tag_name,usmallint_type_tag_name,geometry_type_tag_name,nchar_type_tag_name,varbinary_type_tag_name,smallint_type_tag_name,f,uint_type_tag_name,bigint_type_tag_name,double_type_tag_name,utinyint_type_tag_name,tinyint_type_tag_name,extratag,bool_type_tag_name) TAGS(-270631341, 46930, "point(1.0 1.0)", "gnbznssgvnzwrwxw", "cesmnjhqapqjvrja", 23088, -3.3164207581144432e+38, 1700967625, -1030316662035835968, 1.2011743206213233e+308, -92, 121, 367729172, True) (ts,color,utinyint_type_col_name,usmallint_type_col_name,tinyint_type_col_name,bigint_type_col_name,ubigint_type_col_name,nchar_type_col_name,varchar_type_col_name,speed,double_type_col_name,smallint_type_col_name,float_type_col_name) VALUES ("2016-12-16 11:42:49", "tldfcpsuvkwvvcxt", 27, 23508, 56, 7459772708834616479, 4287277222975526137, "irlpvwywkyfduafy", "fthdcsvpfasrorxm", 2014476868, 6.679126531840444e+307, 24227, 7.882713831816527e+36);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(varbinary_type_tag_name) TAGS("ouvptxbwrpffphkp") (ts,color,double_type_col_name,float_type_col_name,nchar_type_col_name,bigint_type_col_name,varchar_type_col_name,ubigint_type_col_name,bool_type_col_name,tinyint_type_col_name,uint_type_col_name,geometry_type_col_name,speed,usmallint_type_col_name,smallint_type_col_name,utinyint_type_col_name) VALUES ("2016-12-16 12:34:44", "wnyagxmugtlzloqs", 2.5224403678140916e+307, -2.9593116477640043e+38, "wpatbvwqhdetaoko", 7131704094598121396, "cenguwerksdlwthz", -3084446013548702169, False, 121, -53423625, "point(1.0 1.0)", 1601558648, 23715, -10339, 45);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(b,varbinary_type_tag_name,int_type_tag_name,varchar_type_tag_name,bool_type_tag_name,smallint_type_tag_name,utinyint_type_tag_name,double_type_tag_name,nchar_type_tag_name,tinyint_type_tag_name,uint_type_tag_name,ubigint_type_tag_name) TAGS("ebiacunkvnicuhlq", "fqqxcyidlzmeaqqn", 1865880042, "fqyixbagtpigrvkm", True, -15973, 52, -1.2233588646642921e+308, "kjegzlhpztxcjjjt", 49, 3661613052, -3064287245566411855) (ts,tinyint_type_col_name,speed,usmallint_type_col_name,uint_type_col_name,bool_type_col_name,double_type_col_name,varbinary_type_col_name) VALUES ("2016-12-16 12:35:29", -54, -1777243683, -5292, -240610904, False, -1.4017848527201252e+308, "diubdgptppxueerk");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(ubigint_type_tag_name,tinyint_type_tag_name,varbinary_type_tag_name,int_type_tag_name,utinyint_type_tag_name,varchar_type_tag_name,b,double_type_tag_name,smallint_type_tag_name,uint_type_tag_name) TAGS(7218832446436978154, 34, "jqvhmixowianctmg", -169644439, -111, "yulvetumzeimvdew", "bsbqhjdbykaxhkah", -4.3917327843321925e+307, -12324, 3993659508) (ts,geometry_type_col_name,usmallint_type_col_name,color,tinyint_type_col_name,smallint_type_col_name,varchar_type_col_name,varbinary_type_col_name,double_type_col_name,utinyint_type_col_name,nchar_type_col_name,bigint_type_col_name,bool_type_col_name,uint_type_col_name,ubigint_type_col_name,float_type_col_name,speed) VALUES ("2016-12-16 12:55:41", "point(1.0 1.0)", 631, "nmddklgtjxrugcig", -88, -8868, "miajgamwlraattqs", "kffhsedlnafobisv", 1.4423313487130354e+308, -116, "kxoycofwhmsaeohq", -1136894476255564565, True, -939744415, -6653064581027995564, -1.9832809127199404e+38, -745235635);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(f,varchar_type_tag_name,utinyint_type_tag_name,nchar_type_tag_name,double_type_tag_name,usmallint_type_tag_name,bool_type_tag_name,geometry_type_tag_name,uint_type_tag_name,smallint_type_tag_name,bigint_type_tag_name,b,varbinary_type_tag_name,int_type_tag_name,extratag,tinyint_type_tag_name) TAGS(6.311858336249026e+37, "jgyxmmpsdxqtdwrb", 109, "ziwccnmvbdvxjqvt", -8.093949887150045e+307, 50753, True, "point(1.0 1.0)", 1312277084, -22696, -6774059684436011400, "cfvnaoytrwsqfgik", "scoopbahexobzuzi", 260884614, 2013977267, -98) (ts,geometry_type_col_name,bigint_type_col_name,float_type_col_name,varbinary_type_col_name) VALUES ("2016-12-16 12:58:13", "point(1.0 1.0)", 222826911129858937, 1.4161786490709517e+38, "pwyyqxegncyrgybp");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(extratag,tinyint_type_tag_name,bool_type_tag_name,utinyint_type_tag_name,int_type_tag_name,varbinary_type_tag_name,uint_type_tag_name,ubigint_type_tag_name,smallint_type_tag_name) TAGS(-350969142, -27, True, 95, -2014323156, "ytaraprsrowqgtya", 2187064438, 7657067162517860811, -11739) (ts,ubigint_type_col_name,speed,float_type_col_name,geometry_type_col_name,utinyint_type_col_name,smallint_type_col_name,uint_type_col_name,usmallint_type_col_name,tinyint_type_col_name) VALUES ("2016-12-16 12:58:20", 1695470437837518753, -248107853, -2.308796864773065e+38, "point(1.0 1.0)", 96, 27392, -317204398, -28969, 27);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(usmallint_type_tag_name,varchar_type_tag_name,extratag,geometry_type_tag_name,f,bool_type_tag_name,double_type_tag_name,uint_type_tag_name,ubigint_type_tag_name,smallint_type_tag_name,bigint_type_tag_name,nchar_type_tag_name,utinyint_type_tag_name,b,varbinary_type_tag_name,int_type_tag_name) TAGS(9315, "zcptltyqaoeubpam", -411172808, "point(1.0 1.0)", -1.274336621267979e+38, True, -1.574639717196322e+308, 3207202020, 8037317073978039576, 14431, 1953592773870071856, "qwzkcwunsuoqokru", -83, "crpiwmvdmhhxtnon", "rzvcgilgehavrorx", 1770221516) (ts,float_type_col_name,color,uint_type_col_name,speed,varchar_type_col_name,bigint_type_col_name,smallint_type_col_name) VALUES ("2016-12-16 12:58:25", 2.203270740971935e+38, "gclrvxcyluoaqkul", -1757420543, -1667540040, "fhcuwffqunwujhnu", -6952698129894047939, 31135);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(extratag,geometry_type_tag_name,smallint_type_tag_name,bigint_type_tag_name,int_type_tag_name,b,bool_type_tag_name,varchar_type_tag_name,varbinary_type_tag_name,tinyint_type_tag_name,ubigint_type_tag_name,nchar_type_tag_name,usmallint_type_tag_name,utinyint_type_tag_name) TAGS(928439163, "point(1.0 1.0)", -5510, -6111546345505423465, 1619259430, "zqnekxkjgjysmuiz", False, "uzacypoysstbvzjr", "rzhyionncrfhslvk", -95, 2084839207513824909, "xbakjryihqmzoyxb", 1124, -51) (ts) VALUES ("2016-12-16 13:10:00");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(bigint_type_tag_name,f,tinyint_type_tag_name,smallint_type_tag_name,varbinary_type_tag_name,uint_type_tag_name,utinyint_type_tag_name) TAGS(-7654723116287337126, 7.0413764481621105e+37, 28, 14707, "ohmuqnoqockmmvyr", 503417135, -1) (ts,varchar_type_col_name,color,geometry_type_col_name,usmallint_type_col_name,float_type_col_name,uint_type_col_name,ubigint_type_col_name,bigint_type_col_name,nchar_type_col_name,bool_type_col_name) VALUES ("2016-12-16 13:11:00", "vvnkffiwzkwchxku", "ettaavibyrfbkwnd", "point(1.0 1.0)", -14161, -1.8652679722611485e+38, -32936243, -5932829237196271077, 1036650175201440454, "gnkdvttswywmpmqr", False);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(double_type_tag_name,utinyint_type_tag_name,b,extratag) TAGS(-1.6449590526148958e+308, 5, "oyqjdboasjbcgkoa", 769124366) (ts,smallint_type_col_name,utinyint_type_col_name,varbinary_type_col_name,float_type_col_name,bool_type_col_name) VALUES ("2016-12-16 13:12:21", -13042, 36, "ioqlptmacnphnudi", -2.8818733348179174e+38, True);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(f,geometry_type_tag_name,extratag,usmallint_type_tag_name,varchar_type_tag_name,bigint_type_tag_name,utinyint_type_tag_name,b,tinyint_type_tag_name) TAGS(-3.002723197204508e+38, "point(1.0 1.0)", 673924760, 10423, "zqbdmmvwolrmxtdy", 9067788071941407006, 58, "xfzkhhjsdslfocok", -6) (ts,bigint_type_col_name,float_type_col_name,usmallint_type_col_name,bool_type_col_name,uint_type_col_name,color,double_type_col_name) VALUES ("2016-12-16 13:18:58", -8128143152489083329, 3.1863841600401516e+38, -16841, False, -1439274645, "ayaagfubotrfelgd", 3.940540502421231e+307);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(utinyint_type_tag_name,geometry_type_tag_name,uint_type_tag_name,double_type_tag_name,extratag,ubigint_type_tag_name,int_type_tag_name,varchar_type_tag_name,bigint_type_tag_name,varbinary_type_tag_name,usmallint_type_tag_name,nchar_type_tag_name,f) TAGS(72, "point(1.0 1.0)", 664119737, 8.636577697672091e+307, -1956689850, 5442726894170414063, -620118845, "atdkvjdrsslbkqwk", -1730258878203616660, "jetzkpnswyrblizo", 62924, "yubdmiswgttrzlud", -2.6952802203722693e+38) (ts,tinyint_type_col_name,varbinary_type_col_name,bigint_type_col_name,utinyint_type_col_name,nchar_type_col_name,usmallint_type_col_name,geometry_type_col_name,double_type_col_name,color,uint_type_col_name,float_type_col_name,ubigint_type_col_name,varchar_type_col_name,bool_type_col_name,speed) VALUES ("2016-12-16 13:22:31", -101, "pezwjcdegugdqlmj", 2660651858547046010, -106, "xdhkuoxnpbrxzikz", 32513, "point(1.0 1.0)", 1.0237067068787619e+308, "qipropwsssqtdswq", -918947945, -3.2678520762372033e+38, 407015107737783176, "vvigrjnmxmzasgqt", False, -1322323386);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(uint_type_tag_name,varchar_type_tag_name,geometry_type_tag_name,double_type_tag_name,extratag,bool_type_tag_name,usmallint_type_tag_name,tinyint_type_tag_name,f,int_type_tag_name,ubigint_type_tag_name) TAGS(667307468, "lykdtqsuiuxbdejt", "point(1.0 1.0)", -3.233371151222957e+307, 780193507, False, 6454, -104, -1.6348292668856767e+38, -332964092, 6842647149944893582) (ts,bigint_type_col_name,nchar_type_col_name,double_type_col_name,smallint_type_col_name,varbinary_type_col_name,bool_type_col_name,speed,ubigint_type_col_name,utinyint_type_col_name,color,geometry_type_col_name,float_type_col_name,tinyint_type_col_name,usmallint_type_col_name) VALUES ("2016-12-16 13:23:55", -2751819826451411816, "fwuvslqvozjdkybl", -1.4309368487421518e+308, -29059, "ncbtjyvhgdmrtwyb", False, 476112352, 5847161143554335168, 103, "rkxynqftsspdyohe", "point(1.0 1.0)", -2.7303867859897275e+38, 120, -15572);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(extratag,int_type_tag_name) TAGS(1467247951, -27058643) (ts,smallint_type_col_name) VALUES ("2016-12-16 13:28:54", 11705);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(ubigint_type_tag_name,double_type_tag_name,bool_type_tag_name,uint_type_tag_name,varbinary_type_tag_name,f,int_type_tag_name,extratag) TAGS(-7641570078560113172, -1.5720182754543317e+308, False, 3978085195, "otsbskgvmxxpqsuv", 1.761118847494028e+38, -798787056, 1618027135) (ts,tinyint_type_col_name,usmallint_type_col_name,float_type_col_name,varchar_type_col_name,color) VALUES ("2016-12-16 13:30:00", 34, -27037, 8.233875034151866e+37, "klvhnzbiagpaygjr", "azavalppgglodkpt");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(utinyint_type_tag_name,smallint_type_tag_name,nchar_type_tag_name,b,extratag,usmallint_type_tag_name,tinyint_type_tag_name,varchar_type_tag_name,f,varbinary_type_tag_name,geometry_type_tag_name) TAGS(-113, 26916, "hiabnhvkskqdxcft", "rilirkzfvvcsoxvu", 1985911354, 63961, -49, "tkqjhnbsfqlkrmen", 2.4436889435795517e+38, "ljxwjovyuimnwfyn", "point(1.0 1.0)") (ts,float_type_col_name,speed,double_type_col_name,nchar_type_col_name,tinyint_type_col_name,smallint_type_col_name,geometry_type_col_name,utinyint_type_col_name,varchar_type_col_name) VALUES ("2016-12-16 13:32:10", -2.8391080467349558e+38, -334011151, -6.231241486564915e+307, "yikfspsjjzvjmiig", 65, 32623, "point(1.0 1.0)", -79, "vqcenjbphvbzuyec");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(f,bool_type_tag_name,b,nchar_type_tag_name,uint_type_tag_name,utinyint_type_tag_name,varchar_type_tag_name) TAGS(7.628181285293382e+37, False, "xasbwapuqiwnuapm", "wgbkfpitzqilvgam", 1495376777, -22, "cyihglhaaqdhsbrt") (ts,bigint_type_col_name,ubigint_type_col_name,color) VALUES ("2016-12-16 13:33:30", 6511707951588009422, 2723033375589066235, "gxikhegxccxagvge");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(utinyint_type_tag_name,smallint_type_tag_name,bigint_type_tag_name,usmallint_type_tag_name,bool_type_tag_name,nchar_type_tag_name,geometry_type_tag_name,uint_type_tag_name,varchar_type_tag_name) TAGS(106, 142, 1896023978688432555, 64760, True, "kbfjnghakyfiaydm", "point(1.0 1.0)", 1202839796, "hmpxrvvhazkoxktl") (ts,color,double_type_col_name,geometry_type_col_name,float_type_col_name,ubigint_type_col_name,varbinary_type_col_name,bigint_type_col_name) VALUES ("2016-12-16 13:34:57", "rnlnepdxpkshnoon", -9.753180446674174e+307, "point(1.0 1.0)", 7.136745784580883e+37, -5844625605864726019, "cjivuqrqtdkhbiwa", 2274288423212647405);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(nchar_type_tag_name,double_type_tag_name,tinyint_type_tag_name,utinyint_type_tag_name,geometry_type_tag_name) TAGS("nebcguavuaezyyde", 1.2787498546480036e+308, -102, -1, "point(1.0 1.0)") (ts,bool_type_col_name,geometry_type_col_name,utinyint_type_col_name,usmallint_type_col_name) VALUES ("2016-12-16 13:37:33", True, "point(1.0 1.0)", 60, 3057);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(f,bigint_type_tag_name,utinyint_type_tag_name,double_type_tag_name,usmallint_type_tag_name,int_type_tag_name,b) TAGS(-3.3009424548590525e+38, 7360584785531994343, 20, 1.426103197404768e+308, 47478, -1878972741, "nscbvzswvnmgwucm") (ts,smallint_type_col_name,geometry_type_col_name,utinyint_type_col_name,bool_type_col_name,uint_type_col_name) VALUES ("2016-12-16 13:37:39", -27464, "point(1.0 1.0)", 112, True, 1250310797);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(ubigint_type_tag_name,double_type_tag_name,smallint_type_tag_name,usmallint_type_tag_name,varbinary_type_tag_name) TAGS(-1589972917066394459, 8.923822004171481e+307, 15758, 5488, "ruuxldxnhfwxpstv") (ts,uint_type_col_name,color,bool_type_col_name,ubigint_type_col_name,smallint_type_col_name,varchar_type_col_name,varbinary_type_col_name,float_type_col_name,usmallint_type_col_name,double_type_col_name,nchar_type_col_name,geometry_type_col_name) VALUES ("2016-12-16 13:44:22", 963762484, "wlcggiilxpahshwd", True, 3728201935390266604, -2468, "edlyrnopkadknbig", "odaximfsofanwsiq", 1.2948243726798647e+38, 22342, 1.6685972624971541e+308, "ebxjnldwzyxugscc", "point(1.0 1.0)");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(tinyint_type_tag_name,usmallint_type_tag_name,smallint_type_tag_name,geometry_type_tag_name,bigint_type_tag_name,uint_type_tag_name,b,int_type_tag_name,ubigint_type_tag_name,utinyint_type_tag_name,nchar_type_tag_name) TAGS(-88, 51955, 29505, "point(1.0 1.0)", -6962148594230058647, 2678324900, "kygvkaanownlmuny", -1846762302, -785520152137980973, 49, "oxptoddkmvlzukes") (ts,tinyint_type_col_name,varchar_type_col_name,bigint_type_col_name) VALUES ("2016-12-16 13:49:22", 31, "nicxhhisdvunqmyq", 8945862635913752172);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(smallint_type_tag_name,b,varchar_type_tag_name,int_type_tag_name,bigint_type_tag_name) TAGS(23202, "imrskuasopukglor", "bvizzkkpezerxhqu", 317353908, 754217902580887681) (ts,geometry_type_col_name) VALUES ("2016-12-16 13:53:17", "point(1.0 1.0)");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(int_type_tag_name,tinyint_type_tag_name,uint_type_tag_name,utinyint_type_tag_name,double_type_tag_name,ubigint_type_tag_name,bigint_type_tag_name,varbinary_type_tag_name,bool_type_tag_name,usmallint_type_tag_name,b,extratag,f,varchar_type_tag_name,nchar_type_tag_name,geometry_type_tag_name,smallint_type_tag_name) TAGS(-1011316156, 122, 3910130646, 43, 8.512388268116912e+307, 1669456457022538791, 2195079875842603602, "erjqjbgtlgvbwwja", True, 42205, "wovnwgvyflnrbkjr", 1404754906, 2.2368721201787224e+38, "yjisfzjurskvjdck", "vmjcbkwgfouvenyq", "point(1.0 1.0)", -6290) (ts,bool_type_col_name,ubigint_type_col_name,speed,tinyint_type_col_name,usmallint_type_col_name,utinyint_type_col_name,nchar_type_col_name,double_type_col_name,varbinary_type_col_name,smallint_type_col_name,uint_type_col_name,bigint_type_col_name,geometry_type_col_name,varchar_type_col_name) VALUES ("2016-12-16 13:55:15", False, -8830864698607791783, 200778707, 80, -12482, -108, "qlzsnerbfpxtrhsu", 7.918325930212065e+307, "bkeuitzjnwepwsoz", -24175, 1796806861, 8456809260387320755, "point(1.0 1.0)", "bfhekhbyzfnbfvbc");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(int_type_tag_name,varbinary_type_tag_name,varchar_type_tag_name,b,nchar_type_tag_name,extratag,double_type_tag_name,smallint_type_tag_name,uint_type_tag_name,utinyint_type_tag_name,tinyint_type_tag_name,bigint_type_tag_name,bool_type_tag_name,f,usmallint_type_tag_name,ubigint_type_tag_name,geometry_type_tag_name) TAGS(-109100963, "fkktjbsjdjozysqb", "kvckvuuvjkhrwvum", "svohobpldtonpiqs", "bgrvrzilrbtkzaim", 1058428584, 7.196238081264505e+306, 1884, 2991872141, -109, 117, 1510579019662137511, False, 1.2245033771852769e+38, 19364, -4972876200109100193, "point(1.0 1.0)") (ts,nchar_type_col_name,utinyint_type_col_name,varbinary_type_col_name,bigint_type_col_name,geometry_type_col_name,ubigint_type_col_name,smallint_type_col_name,bool_type_col_name,speed,color,uint_type_col_name) VALUES ("2016-12-16 13:58:17", "fhofoqbrebyjlnkk", 78, "jbttouyukxktabti", 715764060196867324, "point(1.0 1.0)", -3965830703103714728, 6591, True, -2043004502, "ipjtaiujqrieidut", -1209525645);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(varbinary_type_tag_name,uint_type_tag_name,utinyint_type_tag_name,bool_type_tag_name,smallint_type_tag_name,f,bigint_type_tag_name) TAGS("rqnninzykiejsiaq", 2744710939, 125, True, -3120, 2.294739380866984e+38, 3223998974927684831) (ts,nchar_type_col_name,smallint_type_col_name,bigint_type_col_name,geometry_type_col_name,color,ubigint_type_col_name,float_type_col_name,varchar_type_col_name,double_type_col_name,varbinary_type_col_name,speed,utinyint_type_col_name) VALUES ("2016-12-16 13:58:26", "dpuonivwjikfanqj", 28149, -8363753204688150611, "point(1.0 1.0)", "deqhimtcneshajxu", -7721659794023728322, 3.1823124307599837e+38, "lmykqmofvaeejays", 1.3450730693544848e+308, "cpvchycerzkkriye", -935361460, -32);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(nchar_type_tag_name,varbinary_type_tag_name,b) TAGS("gzexbtkchcrciore", "xzsaapvhaldvnsee", "luhcuujwpvsqcydj") (ts,varbinary_type_col_name,uint_type_col_name,smallint_type_col_name) VALUES ("2016-12-16 14:17:37", "vegoocllfotccxme", 1106951626, 22765);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(smallint_type_tag_name,nchar_type_tag_name,b,varchar_type_tag_name,bigint_type_tag_name,tinyint_type_tag_name) TAGS(16570, "silgmziwpdxxoyek", "yqvguhekzckruinc", "aajlxcknjrbyhkha", -8045441217037238680, 107) (ts,varchar_type_col_name,float_type_col_name,speed,utinyint_type_col_name,bool_type_col_name,color) VALUES ("2016-12-16 14:19:46", "heftclalnprpfawp", 6.0294286136178425e+37, 302462364, -8, False, "zdadyskvxrgyaqsm");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(smallint_type_tag_name,varbinary_type_tag_name,tinyint_type_tag_name,uint_type_tag_name,nchar_type_tag_name) TAGS(10191, "lhxvlfkfbtrhsjkt", 124, 77770857, "dmsjeojxddyuxink") (ts,tinyint_type_col_name,speed,uint_type_col_name,bool_type_col_name,varbinary_type_col_name,double_type_col_name,color) VALUES ("2016-12-16 14:32:40", 21, 379371801, 608762533, False, "rjgbwgnnkkemctro", 1.4188655662190125e+308, "sbwlxrlpgnkmvadl");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(bool_type_tag_name,int_type_tag_name) TAGS(False, 2060765790) (ts) VALUES ("2016-12-16 14:59:59");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(nchar_type_tag_name,b) TAGS("ieyyywpqpqushibb", "dkvjhgnakkgqzijs") (ts) VALUES ("2016-12-16 15:16:49");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(nchar_type_tag_name,varchar_type_tag_name,usmallint_type_tag_name,tinyint_type_tag_name,double_type_tag_name,bigint_type_tag_name,uint_type_tag_name,utinyint_type_tag_name,int_type_tag_name,bool_type_tag_name,extratag,b,geometry_type_tag_name,f) TAGS("mgatrnymxrqqmdyx", "oljnaeurozmvfqhp", 48759, 38, 3.403325685451397e+307, -6460116231033920128, 1576382718, 104, -603843450, True, 309025710, "tcbaxjfsqakxpvji", "point(1.0 1.0)", 2.8892847575707817e+38) (ts,usmallint_type_col_name,ubigint_type_col_name,nchar_type_col_name,uint_type_col_name,double_type_col_name,varbinary_type_col_name) VALUES ("2016-12-16 15:20:44", -17861, 7575197484024879527, "txwlduparjczcbnx", -2111059045, 4.196810591621617e+307, "asimawbydzjggkce");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(usmallint_type_tag_name,bigint_type_tag_name,double_type_tag_name) TAGS(58633, -7506966660525849170, 6.430296151375471e+307) (ts,smallint_type_col_name,color,bigint_type_col_name,geometry_type_col_name,speed,nchar_type_col_name,float_type_col_name,double_type_col_name,varchar_type_col_name,usmallint_type_col_name,uint_type_col_name,varbinary_type_col_name) VALUES ("2016-12-16 15:51:23", -16594, "twlhrkfaqrwnjumx", -6411319415230721292, "point(1.0 1.0)", 1147845389, "dkuebijphjfmniyc", -2.276532994058693e+38, -4.871085226210322e+307, "ttundubdmhuwtaaa", -29548, -424312121, "zgvfwozyxijapwho");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(uint_type_tag_name,int_type_tag_name) TAGS(4147856182, 710788816) (ts,uint_type_col_name,double_type_col_name,nchar_type_col_name) VALUES ("2016-12-16 16:03:05", -391718933, 9.11108254173214e+306, "mtfdzaczermguiog");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(varbinary_type_tag_name,int_type_tag_name,uint_type_tag_name,utinyint_type_tag_name,bool_type_tag_name,nchar_type_tag_name,bigint_type_tag_name,varchar_type_tag_name,extratag,b,smallint_type_tag_name,ubigint_type_tag_name,usmallint_type_tag_name) TAGS("abhddtiwgwsawqif", -326574137, 3092694575, 117, True, "elqkqieyrmvxdfal", 513325224677025259, "coxihpudvcdmvavx", 949926470, "jtbtsxdafkcutiyq", 18084, -3755127971745692605, 15049) (ts,color,uint_type_col_name,bigint_type_col_name,ubigint_type_col_name,bool_type_col_name,geometry_type_col_name,tinyint_type_col_name,varchar_type_col_name,speed,usmallint_type_col_name,varbinary_type_col_name,double_type_col_name,smallint_type_col_name,nchar_type_col_name,float_type_col_name) VALUES ("2016-12-16 16:10:12", "geiqxfxzxvcisxvq", 404296035, 6018544511539939806, -2723124593683508517, False, "point(1.0 1.0)", -35, "vpgmwoviojtaksyc", -1590408139, -21520, "yivgshgarquqsmkx", -5.091863294679578e+307, -6162, "hwxnlpshligbgdwr", 2.8760534412729593e+38);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(geometry_type_tag_name,f,nchar_type_tag_name,double_type_tag_name,ubigint_type_tag_name,extratag,b,varbinary_type_tag_name) TAGS("point(1.0 1.0)", -8.890969508566344e+37, "olgmpbkzjdyaaxkw", 1.1670001553372841e+308, -6483556380230416046, -1489326043, "kavalxtywfupgxae", "nimnqvcrgffqrnry") (ts,geometry_type_col_name,double_type_col_name,varchar_type_col_name,tinyint_type_col_name,nchar_type_col_name,bool_type_col_name,float_type_col_name,utinyint_type_col_name,usmallint_type_col_name,bigint_type_col_name,speed,uint_type_col_name,smallint_type_col_name,color) VALUES ("2016-12-16 16:31:17", "point(1.0 1.0)", -1.6228106351276176e+308, "mrbiqastjhshphqy", -31, "sldcopievsrcpmdn", True, 1.2788940507924604e+38, -53, 1934, -93937490102293875, 251909968, -1180421292, 2009, "fvcuvlqkjdivmbhf");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(nchar_type_tag_name,varchar_type_tag_name,uint_type_tag_name,geometry_type_tag_name,extratag,bigint_type_tag_name,double_type_tag_name,usmallint_type_tag_name,int_type_tag_name,varbinary_type_tag_name,bool_type_tag_name,ubigint_type_tag_name,f) TAGS("hcwwkenozisgewdo", "ftzlnzgbqcyttqkz", 557595811, "point(1.0 1.0)", -1874674248, -2833874801024332821, 1.106348478672925e+308, 10205, -377441795, "nlqfaejgqdmixvco", True, -8116329742748132558, 2.0010693036315465e+37) (ts,varbinary_type_col_name,smallint_type_col_name,geometry_type_col_name,tinyint_type_col_name,usmallint_type_col_name,color,nchar_type_col_name,bigint_type_col_name,utinyint_type_col_name,bool_type_col_name,ubigint_type_col_name,speed,double_type_col_name,float_type_col_name,varchar_type_col_name) VALUES ("2016-12-16 16:59:27", "kjukvijrgrplxrqt", 15581, "point(1.0 1.0)", 94, 25505, "btgdgtpeqlczgeua", "sstxtgzlyuxqmpla", -8232897057478421459, -38, False, 1902106109546699459, -2035112348, -6.609585770864842e+307, -5.473155208537856e+37, "wkymamybnhbkbwod");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(b,extratag,varchar_type_tag_name,double_type_tag_name,tinyint_type_tag_name,utinyint_type_tag_name,geometry_type_tag_name,varbinary_type_tag_name,bool_type_tag_name) TAGS("obtjobsephyqxyky", 1926001254, "scxtotlkrgfzsqej", 8.631070766476075e+307, 116, -122, "point(1.0 1.0)", "venokzvoaqfytamy", False) (ts,tinyint_type_col_name,varchar_type_col_name,utinyint_type_col_name,geometry_type_col_name,varbinary_type_col_name,ubigint_type_col_name,nchar_type_col_name,bool_type_col_name,double_type_col_name,bigint_type_col_name,float_type_col_name,smallint_type_col_name,uint_type_col_name) VALUES ("2016-12-16 17:09:37", 38, "wihymoxehtmockaj", 119, "point(1.0 1.0)", "lamqyqtuicaumtur", 228827014834750467, "wjeizsgkbechyzya", True, -4.942776530531653e+307, -7607643892481897470, -8.442862379478159e+36, -19143, -2117225342);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(utinyint_type_tag_name,varchar_type_tag_name,f,smallint_type_tag_name,tinyint_type_tag_name,double_type_tag_name,varbinary_type_tag_name,extratag,nchar_type_tag_name,bool_type_tag_name,bigint_type_tag_name,usmallint_type_tag_name,geometry_type_tag_name) TAGS(-103, "rlxmlphalsiwfxkb", -3.256319143371585e+38, -23823, -50, -4.530638219225517e+307, "ycpjvlrnkgdcxbxl", -1782343000, "eibzodmwkyfectbm", False, -3662763902289367996, 11348, "point(1.0 1.0)") (ts,color,bool_type_col_name,uint_type_col_name) VALUES ("2016-12-16 17:13:24", "bpczdwxzdhdlacff", True, 853512564);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(f,geometry_type_tag_name,double_type_tag_name,usmallint_type_tag_name,b,uint_type_tag_name,varbinary_type_tag_name,varchar_type_tag_name,bool_type_tag_name,bigint_type_tag_name,extratag,smallint_type_tag_name,int_type_tag_name,tinyint_type_tag_name,nchar_type_tag_name) TAGS(2.8559644361518244e+38, "point(1.0 1.0)", -8.660488863866903e+307, 51580, "mfdzkxvqcmvlwcab", 1370077655, "gsocrcrzmrbagyvu", "gwtxcyfmdzlvijkk", False, 4749716129372507648, -1343610171, 3648, 67398117, 55, "onuoalimpzxphmrb") (ts,varchar_type_col_name,nchar_type_col_name) VALUES ("2016-12-16 17:19:38", "lbdzxuiflnytuwcm", "qyiblgcvjolvnfxd");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(bool_type_tag_name,utinyint_type_tag_name,varchar_type_tag_name,b,nchar_type_tag_name,double_type_tag_name,uint_type_tag_name,varbinary_type_tag_name,bigint_type_tag_name,ubigint_type_tag_name,f,int_type_tag_name,usmallint_type_tag_name,smallint_type_tag_name,geometry_type_tag_name) TAGS(True, -128, "ghxlfvebdngntlsy", "gyshejexhflthjyt", "csoufooqhjixarep", -3.560079945924916e+307, 3796289973, "xrwzaykbqpnpowzg", -5254959553491612400, 6959026343484215526, -2.426597157147208e+38, 1953534210, 56530, -27622, "point(1.0 1.0)") (ts,nchar_type_col_name,varbinary_type_col_name,varchar_type_col_name,uint_type_col_name,speed,ubigint_type_col_name,double_type_col_name,usmallint_type_col_name,bool_type_col_name,bigint_type_col_name,tinyint_type_col_name,color,float_type_col_name,geometry_type_col_name,smallint_type_col_name,utinyint_type_col_name) VALUES ("2016-12-16 17:28:43", "bxarvuznezbovivi", "ljmaaewnxbwquqbv", "vmttcfyjpofkfxdz", -160343511, -1153710436, -6078325270497694207, -1.6708621643614452e+308, -18667, False, -5283782545471513173, 34, "xmbhflvmvnjsjukp", 1.7453583209432804e+38, "point(1.0 1.0)", 21766, 96);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(varchar_type_tag_name,ubigint_type_tag_name,bool_type_tag_name,nchar_type_tag_name,varbinary_type_tag_name,int_type_tag_name,b,utinyint_type_tag_name) TAGS("xzxnwavsfkqexqst", 6248701313661488236, False, "tfzyiigcdgdviljn", "pyaziteptbnjwetv", 1550386893, "hvgiajgmbrfjbhzv", -50) (ts,uint_type_col_name,ubigint_type_col_name,utinyint_type_col_name,nchar_type_col_name) VALUES ("2016-12-16 17:29:35", -2140028488, 9126620526143931960, 48, "vzlvftkxtgejntwx");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(int_type_tag_name,f,varchar_type_tag_name) TAGS(962788507, 1.835407119522404e+38, "dcugcviilgfzpjup") (ts,usmallint_type_col_name,smallint_type_col_name,bigint_type_col_name,geometry_type_col_name,ubigint_type_col_name,speed,nchar_type_col_name,double_type_col_name,float_type_col_name) VALUES ("2016-12-16 17:33:20", 2254, 28827, -8316728271968247646, "point(1.0 1.0)", 6630573292051824500, -1180210336, "bvbksqzbwgmpufzu", 2.591615616226201e+307, 1.8393414054114685e+38);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(bigint_type_tag_name,b,f,double_type_tag_name,ubigint_type_tag_name,int_type_tag_name,varbinary_type_tag_name,bool_type_tag_name,smallint_type_tag_name,tinyint_type_tag_name,uint_type_tag_name,varchar_type_tag_name,usmallint_type_tag_name,nchar_type_tag_name,geometry_type_tag_name,extratag) TAGS(-1652523720828862491, "rshcsvsqtejnnyzt", -2.8033588099999885e+38, 1.1267740923697902e+308, 6134475623749100063, 275423891, "symfelluxyjghegv", True, 28636, 15, 2850861607, "dluujqzooplynbpi", 11747, "xkepcycandqyqhng", "point(1.0 1.0)", 28000589) (ts,float_type_col_name) VALUES ("2016-12-16 17:35:20", -2.768468628882595e+38);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(usmallint_type_tag_name,utinyint_type_tag_name,b,varbinary_type_tag_name,varchar_type_tag_name,smallint_type_tag_name,nchar_type_tag_name,tinyint_type_tag_name,bigint_type_tag_name) TAGS(40614, -17, "xwadkvwyxpirlkuv", "tfgddotpqkdjbtbh", "weehvoxpqcioyipx", -25537, "xtrykrvmibasrfpk", 64, 2611368116480765912) (ts,color,geometry_type_col_name,usmallint_type_col_name,float_type_col_name,smallint_type_col_name,bigint_type_col_name,utinyint_type_col_name) VALUES ("2016-12-16 17:37:51", "jdyzckzuwxieaecb", "point(1.0 1.0)", -27205, -1.711911078586609e+38, 31375, -6123067329853056480, -90);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(bigint_type_tag_name,usmallint_type_tag_name) TAGS(1819937892824962656, 8171) (ts,ubigint_type_col_name,float_type_col_name,bool_type_col_name,uint_type_col_name,color,double_type_col_name) VALUES ("2016-12-16 17:43:42", -4609243792627697209, 2.006334657982245e+38, False, 1603774652, "czkpwgrrldvfefpq", -5.301467469348041e+307);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(bigint_type_tag_name,b,usmallint_type_tag_name,int_type_tag_name,uint_type_tag_name,double_type_tag_name,tinyint_type_tag_name,utinyint_type_tag_name) TAGS(1581454524159189903, "aauchczywgtewzec", 10564, -1624200982, 1778830750, 1.007077574465233e+308, -117, -8) (ts,double_type_col_name,color,nchar_type_col_name,utinyint_type_col_name,bigint_type_col_name,uint_type_col_name,tinyint_type_col_name,varchar_type_col_name) VALUES ("2016-12-16 17:47:52", 3.178641188947165e+307, "plewvtmwmncovgwi", "afkkkizxcmpvjrof", 97, -4082154569696236500, 785036327, 36, "tnjnpkqduaiplcbr");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(smallint_type_tag_name) TAGS(-9259) (ts,ubigint_type_col_name,utinyint_type_col_name,varbinary_type_col_name,bool_type_col_name,varchar_type_col_name,nchar_type_col_name,geometry_type_col_name,usmallint_type_col_name,speed) VALUES ("2016-12-16 17:50:22", 6575849309295898287, -110, "ebiistxhnphfulox", False, "djlqhenlzryusbkd", "ltldluztvsgqjeku", "point(1.0 1.0)", 8278, 1651340708);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(double_type_tag_name,nchar_type_tag_name,geometry_type_tag_name,smallint_type_tag_name,utinyint_type_tag_name,extratag) TAGS(1.0764964917532312e+308, "ykuhegoyikhmcgre", "point(1.0 1.0)", 9094, 74, 1323341877) (ts,varbinary_type_col_name) VALUES ("2016-12-16 17:51:12", "nafbgufapnohskpj");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(smallint_type_tag_name,double_type_tag_name) TAGS(28583, 1.953720446700205e+307) (ts,nchar_type_col_name,varbinary_type_col_name,utinyint_type_col_name,geometry_type_col_name,varchar_type_col_name,speed) VALUES ("2016-12-16 18:11:59", "qwqpnycixypxdgkx", "sqdczulupdskltin", -2, "point(1.0 1.0)", "gbqmwfvaobmucwws", -1295442484);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(ubigint_type_tag_name,uint_type_tag_name,utinyint_type_tag_name,nchar_type_tag_name,bigint_type_tag_name,tinyint_type_tag_name,geometry_type_tag_name,f,int_type_tag_name,double_type_tag_name,varchar_type_tag_name,extratag,bool_type_tag_name,smallint_type_tag_name,b,usmallint_type_tag_name) TAGS(-1899740088608098071, 3000382785, -90, "lyiqgjrtcmygsulu", 3674173029313761846, 24, "point(1.0 1.0)", -2.0614150673404532e+38, -83384014, 8.266327304822514e+307, "hmriafyufcvjdmxp", -1458878109, True, 2751, "ldrlpabgmvlmmvpg", 14211) (ts,color,ubigint_type_col_name,uint_type_col_name,smallint_type_col_name,varbinary_type_col_name,speed,tinyint_type_col_name,double_type_col_name,float_type_col_name,varchar_type_col_name,usmallint_type_col_name,geometry_type_col_name,bool_type_col_name) VALUES ("2016-12-16 18:14:29", "hlfayalksfvnguaw", 7446576754933889227, -200330992, 28598, "bqqqhufmncpjhsuv", 218558271, -85, -9.741398605743586e+307, 7.376357821892906e+37, "tpvxybkpxgmhowjr", 25868, "point(1.0 1.0)", False);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(geometry_type_tag_name,nchar_type_tag_name,usmallint_type_tag_name,uint_type_tag_name,varchar_type_tag_name,b,int_type_tag_name,utinyint_type_tag_name,varbinary_type_tag_name,double_type_tag_name,bigint_type_tag_name,smallint_type_tag_name,f,ubigint_type_tag_name,bool_type_tag_name) TAGS("point(1.0 1.0)", "sjzthkwujsqenwih", 48703, 4087817577, "xmqagtnxequrrylr", "ijtbyhilxioxzuah", -352262545, 1, "sckpgzmooxqjheoe", 1.1198965017615236e+308, 6916146561643120258, 32531, -1.6419733589465474e+38, -4935693961629680589, False) (ts,nchar_type_col_name,geometry_type_col_name,double_type_col_name,varbinary_type_col_name,varchar_type_col_name,bigint_type_col_name,smallint_type_col_name,tinyint_type_col_name) VALUES ("2016-12-16 18:16:09", "jssdvwbxvsbmilue", "point(1.0 1.0)", 6.391478347681934e+307, "zdtetttfsnleoyet", "ppoptsqilikhsino", -840467639559539794, -31830, -103);') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(geometry_type_tag_name,smallint_type_tag_name,bigint_type_tag_name,int_type_tag_name,utinyint_type_tag_name,f,uint_type_tag_name,tinyint_type_tag_name) TAGS("point(1.0 1.0)", 24091, 2578286530814614745, 1008675772, -8, 7.362335563770809e+37, 1819796668, 44) (ts,utinyint_type_col_name,bigint_type_col_name,tinyint_type_col_name,ubigint_type_col_name,smallint_type_col_name,varbinary_type_col_name,float_type_col_name,speed,varchar_type_col_name,bool_type_col_name,usmallint_type_col_name,color,geometry_type_col_name) VALUES ("2016-12-16 18:16:59", 93, -2924293332667446092, 18, -1926645562871095772, 25986, "xjlujcacaynnnmub", -9.456838052905681e+37, 529848418, "nxkirdhlqqloitkl", True, 4620, "acujdfhatzkugcrk", "point(1.0 1.0)");') + tdSql.execute(f'INSERT INTO td32506.reg_table_159 using td32506.fs_table(tinyint_type_tag_name,usmallint_type_tag_name,b,f,varbinary_type_tag_name,bigint_type_tag_name,smallint_type_tag_name,geometry_type_tag_name,varchar_type_tag_name,extratag,utinyint_type_tag_name,uint_type_tag_name,ubigint_type_tag_name,double_type_tag_name,bool_type_tag_name,int_type_tag_name) TAGS(-98, 2946, "qgvkaujyrikpmgxp", 3.2784411370027565e+38, "dspxtsyqnqdyciab", -794888918858663169, -1378, "point(1.0 1.0)", "diaerlydilfkqveu", -1591170700, -9, 88084273, -8326438069324931384, -6.790019844508353e+307, False, 1326851510) (ts,speed,double_type_col_name,geometry_type_col_name,ubigint_type_col_name,bool_type_col_name,utinyint_type_col_name,bigint_type_col_name,usmallint_type_col_name,color,smallint_type_col_name,varchar_type_col_name,nchar_type_col_name,float_type_col_name,varbinary_type_col_name) VALUES ("2016-12-16 18:17:51", -1374792144, -1.149850424042433e+308, "point(1.0 1.0)", 8907011909602006795, False, 104, 1588514034331429385, -18984, "namrvnonxcrzziic", -26616, "ueddmjfyoclvjwfx", "mkkexxinfededdfr", -2.403953587086065e+38, "kadxrwlomevmukfr");') + + def test_percentile(self): + tdSql.error('SELECT SPREAD(bigint_type_tag_name),LEASTSQUARES(bigint_type_tag_name, 9, 2),COUNT(bigint_type_tag_name),HYPERLOGLOG(bigint_type_tag_name),PERCENTILE(bigint_type_tag_name,89,27,20,19,87,99,26,17,45),AVG(bigint_type_tag_name), HYPERLOGLOG(tinyint_type_tag_name),AVG(tinyint_type_tag_name),SPREAD(tinyint_type_tag_name),STDDEV(tinyint_type_tag_name),SUM(tinyint_type_tag_name),COUNT(tinyint_type_tag_name),APERCENTILE(tinyint_type_tag_name, 1, "t-digest"),LEASTSQUARES(tinyint_type_tag_name, 8, 1), STDDEV(usmallint_type_tag_name), COUNT(nchar_type_tag_name),HYPERLOGLOG(nchar_type_tag_name), PERCENTILE(double_type_col_name,6,23,52,24,1,53,95,51,38),HYPERLOGLOG(double_type_col_name),SPREAD(double_type_col_name) FROM td32506.reg_table_159 STATE_WINDOW(1);') + + def run(self): + tdLog.debug(f"start to excute {__file__}") + + self.insert_data() + + # math function + self.test_percentile() + + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/army/query/test_case_when.py b/tests/army/query/test_case_when.py new file mode 100644 index 00000000000..e7729141839 --- /dev/null +++ b/tests/army/query/test_case_when.py @@ -0,0 +1,375 @@ +from frame.log import * +from frame.cases import * +from frame.sql import * +from frame.caseBase import * +from frame import * +from frame.eos import * +from datetime import datetime, timedelta + + +class TDTestCase(TBase): + """Verify the case...when... expression in the query statement + """ + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + self.stable_schema = { + "columns": { + "ts": "timestamp", + "c_null": "int", + "c_bool": "bool", + "c_tinyint": "tinyint", + "c_smallint": "smallint", + "c_int": "int", + "c_bigint": "bigint", + "c_float": "float", + "c_double": "double", + "c_varchar": "varchar(16)", + "c_timestamp": "timestamp", + "c_nchar": "nchar(16)", + "c_utinyint": "tinyint unsigned", + "c_usmallint": "smallint unsigned", + "c_uint": "int unsigned", + "c_ubigint": "bigint unsigned", + "c_varbinary": "varbinary(16)", + "c_geometry": "geometry(32)" + }, + "tags": { + "t_null": "int", + "t_bool": "bool", + "t_tinyint": "tinyint", + "t_smallint": "smallint", + "t_int": "int", + "t_bigint": "bigint", + "t_float": "float", + "t_double": "double", + "t_varchar": "varchar(16)", + "t_timestamp": "timestamp", + "t_nchar": "nchar(16)", + "t_utinyint": "tinyint unsigned", + "t_usmallint": "smallint unsigned", + "t_uint": "int unsigned", + "t_ubigint": "bigint unsigned", + "t_varbinary": "varbinary(16)", + "t_geometry": "geometry(32)" + } + } + + def prepare_data(self): + # create database + tdSql.execute("create database test_case_when;") + tdSql.execute("use test_case_when;") + # create stable + columns = ",".join([f"{k} {v}" for k, v in self.stable_schema["columns"].items()]) + tags = ",".join([f"{k} {v}" for k, v in self.stable_schema["tags"].items()]) + st_sql = f"create stable st1 ({columns}) tags ({tags});" + tdSql.execute(st_sql) + st_sql_json_tag = f"create stable st2 ({columns}) tags (t json);" + tdSql.execute(st_sql_json_tag) + # create child table + tdSql.execute("create table ct1 using st1 tags(NULL, True, 1, 1, 1, 1, 1.1, 1.11, 'aaaaaaaa', '2021-09-01 00:00:00.000', 'aaaaaaaa', 1, 1, 1, 1, \"0x06\",'POINT(1 1)');") + tdSql.execute("""create table ct2 using st2 tags('{"name": "test", "location": "beijing"}');""") + # insert data + ct1_data = [ + """'2024-10-01 00:00:00.000', NULL, True, 2, 2, 2, 2, 2.2, 2.22, 'bbbbbbbb', '2021-09-01 00:00:00.000', 'bbbbbbbb', 2, 2, 2, 2, "0x07",'POINT(2 2)'""", + """'2024-10-01 00:00:01.000', NULL, False, 3, 3, 3, 3, 3.3, 3.33, 'cccccccc', '2021-09-01 00:00:00.000', 'cccccccc', 3, 3, 3, 3, "0x08",'POINT(3 3)'""", + """'2024-10-01 00:00:02.000', NULL, True, 4, 4, 4, 4, 4.4, 4.44, 'dddddddd', '2021-09-01 00:00:00.000', 'dddddddd', 4, 4, 4, 4, "0x09",'POINT(4 4)'""", + """'2024-10-01 00:00:03.000', NULL, False, 5, 5, 5, 5, 5.5, 5.55, 'eeeeeeee', '2021-09-01 00:00:00.000', 'eeeeeeee', 5, 5, 5, 5, "0x0A",'POINT(5 5)'""", + """'2024-10-01 00:00:04.000', NULL, True, 6, 6, 6, 6, 6.6, 6.66, 'ffffffff', '2021-09-01 00:00:00.000', 'ffffffff', 6, 6, 6, 6, "0x0B",'POINT(6 6)'""", + """'2024-10-01 00:00:05.000', NULL, False, 7, 7, 7, 7, 7.7, 7.77, 'gggggggg', '2021-09-01 00:00:00.000', 'gggggggg', 7, 7, 7, 7, "0x0C",'POINT(7 7)'""", + """'2024-10-01 00:00:06.000', NULL, True, 8, 8, 8, 8, 8.8, 8.88, 'hhhhhhhh', '2021-09-01 00:00:00.000', 'hhhhhhhh', 8, 8, 8, 8, "0x0D",'POINT(8 8)'""", + """'2024-10-01 00:00:07.000', NULL, False, 9, 9, 9, 9, 9.9, 9.99, 'iiiiiiii', '2021-09-01 00:00:00.000', 'iiiiiiii', 9, 9, 9, 9, "0x0E",'POINT(9 9)'""", + """'2024-10-01 00:00:08.000', NULL, True, 10, 10, 10, 10, 10.10, 10.1010, 'jjjjjjjj', '2021-09-01 00:00:00.000', 'jjjjjjjj', 10, 10, 10, 10, "0x0F",'POINT(10 10)'""", + """'2024-10-01 00:00:09.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL""" + ] + ct1_insert_sql = "insert into ct1 values(%s);" % "),(".join(ct1_data) + tdSql.execute(ct1_insert_sql) + ct2_data = [ + """'2024-10-01 00:00:00.000', NULL, True, 2, 2, 2, 2, 2.2, 2.22, 'bbbbbbbb', '2021-09-01 00:00:00.000', 'bbbbbbbb', 2, 2, 2, 2, "0x07",'POINT(2 2)'""", + """'2024-10-01 00:00:01.000', NULL, False, 3, 3, 3, 3, 3.3, 3.33, 'cccccccc', '2021-09-01 00:00:00.000', 'cccccccc', 3, 3, 3, 3, "0x08",'POINT(3 3)'""", + """'2024-10-01 00:00:02.000', NULL, True, 4, 4, 4, 4, 4.4, 4.44, 'dddddddd', '2021-09-01 00:00:00.000', 'dddddddd', 4, 4, 4, 4, "0x09",'POINT(4 4)'""", + """'2024-10-01 00:00:03.000', NULL, False, 5, 5, 5, 5, 5.5, 5.55, 'eeeeeeee', '2021-09-01 00:00:00.000', 'eeeeeeee', 5, 5, 5, 5, "0x0A",'POINT(5 5)'""", + """'2024-10-01 00:00:04.000', NULL, True, 6, 6, 6, 6, 6.6, 6.66, 'ffffffff', '2021-09-01 00:00:00.000', 'ffffffff', 6, 6, 6, 6, "0x0B",'POINT(6 6)'""", + """'2024-10-01 00:00:05.000', NULL, False, 7, 7, 7, 7, 7.7, 7.77, 'gggggggg', '2021-09-01 00:00:00.000', 'gggggggg', 7, 7, 7, 7, "0x0C",'POINT(7 7)'""", + """'2024-10-01 00:00:06.000', NULL, True, 8, 8, 8, 8, 8.8, 8.88, 'hhhhhhhh', '2021-09-01 00:00:00.000', 'hhhhhhhh', 8, 8, 8, 8, "0x0D",'POINT(8 8)'""", + """'2024-10-01 00:00:07.000', NULL, False, 9, 9, 9, 9, 9.9, 9.99, 'iiiiiiii', '2021-09-01 00:00:00.000', 'iiiiiiii', 9, 9, 9, 9, "0x0E",'POINT(9 9)'""", + """'2024-10-01 00:00:08.000', NULL, True, 10, 10, 10, 10, 10.10, 10.1010, 'jjjjjjjj', '2021-09-01 00:00:00.000', 'jjjjjjjj', 10, 10, 10, 10, "0x0F",'POINT(10 10)'""", + """'2024-10-01 00:00:09.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL""" + ] + ct2_insert_sql = "insert into ct2 values(%s);" % "),(".join(ct2_data) + tdSql.execute(ct2_insert_sql) + + def test_case_when_statements(self): + tdSql.execute("use test_case_when;") + tdSql.query("select case when c_null is null then c_null else t_null end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_null is not null then c_null else t_null end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_bool is null then c_bool else c_null end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_bool is not null then c_bool else c_null end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(1,), (0,), (1,), (0,), (1,), (0,), (1,), (0,), (1,), (None,)]) + + tdSql.query("select case when c_tinyint is null then c_tinyint else c_null end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_tinyint is not null then c_tinyint else c_null end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_smallint is null then c_smallint else c_null end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_smallint is not null then c_smallint else c_null end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_int is null then c_int else c_null end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_int is not null then c_int else c_null end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_bigint is null then c_bigint else c_null end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_bigint is not null then c_bigint else c_null end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_float is null then c_float else c_null end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_float is not null then c_float else c_null end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('2.200000',), ('3.300000',), ('4.400000',), ('5.500000',), ('6.600000',), ('7.700000',), ('8.800000',), ('9.900000',), ('10.100000',), (None,)]) + + tdSql.query("select case when c_double is null then c_double else c_null end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_double is not null then c_double else c_null end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('2.220000',), ('3.330000',), ('4.440000',), ('5.550000',), ('6.660000',), ('7.770000',), ('8.880000',), ('9.990000',), ('10.101000',), (None,)]) + + tdSql.query("select case when c_varchar is null then c_varchar else c_null end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_varchar is not null then c_varchar else c_null end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('bbbbbbbb',), ('cccccccc',), ('dddddddd',), ('eeeeeeee',), ('ffffffff',), ('gggggggg',), ('hhhhhhhh',), ('iiiiiiii',), ('jjjjjjjj',), (None,)]) + + tdSql.query("select case when c_nchar is null then c_nchar else c_null end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_nchar is not null then c_nchar else c_null end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('bbbbbbbb',), ('cccccccc',), ('dddddddd',), ('eeeeeeee',), ('ffffffff',), ('gggggggg',), ('hhhhhhhh',), ('iiiiiiii',), ('jjjjjjjj',), (None,)]) + + tdSql.query("select case when c_utinyint is null then c_utinyint else c_null end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_utinyint is not null then c_utinyint else c_null end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_usmallint is null then c_usmallint else c_null end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_usmallint is not null then c_usmallint else c_null end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_uint is null then c_uint else c_null end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_uint is not null then c_uint else c_null end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_ubigint is null then c_ubigint else c_null end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_ubigint is not null then c_ubigint else c_null end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('2',), ('3',), ('4',), ('5',), ('6',), ('7',), ('8',), ('9',), ('10',), (None,)]) + + tdSql.error("select case when c_varbinary is null then c_varbinary else c_null end from st1;") + tdSql.error("select case when c_varbinary is not null then c_varbinary else c_null end from st1;") + + tdSql.query("select case when c_null is null then NULL else c_bool end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_null is not null then NULL else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(True,), (False,), (True,), (False,), (True,), (False,), (True,), (False,), (True,), (None,)]) + + tdSql.query("select case when c_bool=true then NULL else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(None,), (False,), (None,), (False,), (None,), (False,), (None,), (False,), (None,), (None,)]) + + tdSql.query("select case when c_bool!=true then NULL else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(True,), (None,), (True,), (None,), (True,), (None,), (True,), (None,), (True,), (None,)]) + + tdSql.query("select case when c_tinyint=2 then c_tinyint else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (0,), (1,), (0,), (1,), (0,), (1,), (0,), (1,), (None,)]) + + tdSql.query("select case when c_tinyint!=2 then c_tinyint else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(1,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_smallint=2 then c_smallint else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (0,), (1,), (0,), (1,), (0,), (1,), (0,), (1,), (None,)]) + + tdSql.query("select case when c_smallint!=2 then c_smallint else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(1,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_int=2 then c_int else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (0,), (1,), (0,), (1,), (0,), (1,), (0,), (1,), (None,)]) + + tdSql.query("select case when c_int!=2 then c_int else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(1,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_bigint=2 then c_bigint else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (0,), (1,), (0,), (1,), (0,), (1,), (0,), (1,), (None,)]) + + tdSql.query("select case when c_bigint!=2 then c_bigint else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(1,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_float=2.2 then c_float else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res[1:] == [(0.0,), (1.0,), (0.0,), (1.0,), (0.0,), (1.0,), (0.0,), (1.0,), (None,)]) + + tdSql.query("select case when c_float!=2.2 then c_float else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res[0] == (1.0,)) + + tdSql.query("select case when c_double=2.22 then c_double else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2.22,), (0.0,), (1.0,), (0.0,), (1.0,), (0.0,), (1.0,), (0.0,), (1.0,), (None,)]) + + tdSql.query("select case when c_double!=2.2 then c_double else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2.22,), (3.33,), (4.44,), (5.55,), (6.66,), (7.77,), (8.88,), (9.99,), (10.101,), (None,)]) + + tdSql.query("select case when c_varchar='bbbbbbbb' then c_varchar else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('bbbbbbbb',), ('false',), ('true',), ('false',), ('true',), ('false',), ('true',), ('false',), ('true',), (None,)]) + + tdSql.query("select case when c_varchar!='bbbbbbbb' then c_varchar else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('true',), ('cccccccc',), ('dddddddd',), ('eeeeeeee',), ('ffffffff',), ('gggggggg',), ('hhhhhhhh',), ('iiiiiiii',), ('jjjjjjjj',), (None,)]) + + tdSql.query("select case when c_timestamp='2021-09-01 00:00:00.000' then c_timestamp else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(1630425600000,), (1630425600000,), (1630425600000,), (1630425600000,), (1630425600000,), (1630425600000,), (1630425600000,), (1630425600000,), (1630425600000,), (None,)]) + + tdSql.query("select case when c_timestamp!='2021-09-01 00:00:00.000' then c_timestamp else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(1,), (0,), (1,), (0,), (1,), (0,), (1,), (0,), (1,), (None,)]) + + tdSql.query("select case when c_nchar='bbbbbbbb' then c_nchar else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('bbbbbbbb',), ('false',), ('true',), ('false',), ('true',), ('false',), ('true',), ('false',), ('true',), (None,)]) + + tdSql.query("select case when c_nchar!='bbbbbbbb' then c_nchar else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('true',), ('cccccccc',), ('dddddddd',), ('eeeeeeee',), ('ffffffff',), ('gggggggg',), ('hhhhhhhh',), ('iiiiiiii',), ('jjjjjjjj',), (None,)]) + + tdSql.query("select case when c_utinyint=2 then c_utinyint else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (0,), (1,), (0,), (1,), (0,), (1,), (0,), (1,), (None,)]) + + tdSql.query("select case when c_utinyint!=2 then c_utinyint else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(1,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_usmallint=2 then c_usmallint else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (0,), (1,), (0,), (1,), (0,), (1,), (0,), (1,), (None,)]) + + tdSql.query("select case when c_usmallint!=2 then c_usmallint else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(1,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_uint=2 then c_uint else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (0,), (1,), (0,), (1,), (0,), (1,), (0,), (1,), (None,)]) + + tdSql.query("select case when c_uint!=2 then c_uint else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(1,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_ubigint=2 then c_ubigint else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (0,), (1,), (0,), (1,), (0,), (1,), (0,), (1,), (None,)]) + + tdSql.query("select case when c_ubigint!=2 then c_ubigint else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(1,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_ubigint=2 then c_ubigint else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (0,), (1,), (0,), (1,), (0,), (1,), (0,), (1,), (None,)]) + + tdSql.query("select case when c_ubigint!=2 then c_ubigint else c_bool end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(1,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.error("select case when c_varbinary='\x30783037' then c_varbinary else c_bool end from st1;") + tdSql.error("select case when c_varbinary!='\x30783037' then c_varbinary else c_bool end from st1;") + + tdSql.query("select case when c_null is null then NULL else c_tinyint end from st1;") + assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) + + tdSql.query("select case when c_null is not null then NULL else c_tinyint end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_bool=true then false else c_tinyint end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(0,), (3,), (0,), (5,), (0,), (7,), (0,), (9,), (0,), (None,)]) + + tdSql.query("select case when c_bool!=true then false else c_tinyint end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (0,), (4,), (0,), (6,), (0,), (8,), (0,), (10,), (None,)]) + + tdSql.query("select case when c_smallint=2 then c_smallint else c_tinyint end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_smallint!=2 then c_smallint else c_tinyint end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_int=2 then c_smallint else c_int end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_int!=2 then c_smallint else c_int end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [(2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (None,)]) + + tdSql.query("select case when c_float=2.2 then 387897 else 'test message' end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('387897',), ('test message',), ('test message',), ('test message',), ('test message',), ('test message',), ('test message',), ('test message',), ('test message',), ('test message',)]) + + tdSql.query("select case when c_double=2.22 then 387897 else 'test message' end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('387897',), ('test message',), ('test message',), ('test message',), ('test message',), ('test message',), ('test message',), ('test message',), ('test message',), ('test message',)]) + + tdSql.query("select case when c_varchar='cccccccc' then 'test' when c_varchar='bbbbbbbb' then 'bbbb' else 'test message' end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('bbbb',), ('test',), ('test message',), ('test message',), ('test message',), ('test message',), ('test message',), ('test message',), ('test message',), ('test message',)]) + + tdSql.query("select case when ts='2024-10-01 00:00:04.000' then 456646546 when ts>'2024-10-01 00:00:04.000' then 'after today' else 'before today or unknow date' end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('before today or unknow date',), ('before today or unknow date',), ('before today or unknow date',), ('before today or unknow date',), ('456646546',), ('after today',), ('after today',), ('after today',), ('after today',), ('after today',)]) + + tdSql.error("select case when c_geometry is null then c_geometry else c_null end from st1;") + tdSql.error("select case when c_geometry is not null then c_geometry else c_null end from st1;") + tdSql.error("select case when c_geometry='POINT(2 2)' then c_geometry else c_bool end from st1;") + tdSql.error("select case when c_geometry!='POINT(2 2)' then c_geometry else c_bool end from st1;") + + tdSql.error("select case when t is null then t else c_null end from st2;") + tdSql.error("select case when t is not null then t else c_null end from st2;") + tdSql.error("select case when t->'location'='beijing' then t->'location' else c_bool end from st2;") + tdSql.error("select case when t->'location'!='beijing' then t->'location' else c_bool end from st1;") + + tdSql.query("select case when c_float!=2.2 then 387897 else 'test message' end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('test message',), ('387897',), ('387897',), ('387897',), ('387897',), ('387897',), ('387897',), ('387897',), ('387897',), ('test message',)]) + + tdSql.query("select case when c_double!=2.22 then 387897 else 'test message' end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('test message',), ('387897',), ('387897',), ('387897',), ('387897',), ('387897',), ('387897',), ('387897',), ('387897',), ('test message',)]) + + tdSql.query("select case c_tinyint when 2 then -2147483648 when 3 then 'three' else '4294967295' end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('-2147483648',), ('three',), ('4294967295',), ('4294967295',), ('4294967295',), ('4294967295',), ('4294967295',), ('4294967295',), ('4294967295',), ('4294967295',)]) + + tdSql.query("select case c_float when 2.2 then 9.2233720e+18 when 3.3 then -9.2233720e+18 else 'aa' end from st1;") + assert(tdSql.checkRows(10) and tdSql.res == [('9223372000000000000.000000',), ('-9223372000000000000.000000',), ('aa',), ('aa',), ('aa',), ('aa',), ('aa',), ('aa',), ('aa',), ('aa',)]) + + tdSql.query("select case t1.c_int when 2 then 'run' when t1.c_int is null then 'other' else t2.c_varchar end from st1 t1, st2 t2 where t1.ts=t2.ts;") + print(tdSql.res) + assert(tdSql.checkRows(10) and tdSql.res == [('run',), ('cccccccc',), ('dddddddd',), ('eeeeeeee',), ('ffffffff',), ('gggggggg',), ('hhhhhhhh',), ('iiiiiiii',), ('jjjjjjjj',), (None,)]) + + tdSql.query("select avg(case when c_tinyint>=2 then c_tinyint else c_null end) from st1;") + assert(tdSql.checkRows(1) and tdSql.res == [(6.0,)]) + + tdSql.query("select sum(case when c_tinyint>=2 then c_tinyint else c_null end) from st1;") + assert(tdSql.checkRows(1) and tdSql.res == [(54,)]) + + tdSql.query("select first(case when c_int >=2 then 'abc' else 0 end) from st1;") + assert(tdSql.checkRows(1) and tdSql.res == [('abc',)]) + + tdSql.query("select last(case when c_int >=2 then c_int else 0 end) from st1;") + assert(tdSql.checkRows(1) and tdSql.res == [(0,)]) + + def run(self): + self.prepare_data() + self.test_case_when_statements() + + def stop(self): + tdSql.execute("drop database test_case_when;") + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 817d9f049a4..c6596be7fca 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -15,11 +15,14 @@ ,,y,army,./pytest.sh python3 ./test.py -f cluster/snapshot.py -N 3 -L 3 -D 2 ,,y,army,./pytest.sh python3 ./test.py -f query/function/test_func_elapsed.py ,,y,army,./pytest.sh python3 ./test.py -f query/function/test_function.py +,,y,army,./pytest.sh python3 ./test.py -f query/function/test_percentile.py ,,y,army,./pytest.sh python3 ./test.py -f query/function/test_resinfo.py +,,y,army,./pytest.sh python3 ./test.py -f query/function/test_interp.py ,,y,army,./pytest.sh python3 ./test.py -f query/function/concat.py ,,y,army,./pytest.sh python3 ./test.py -f query/function/cast.py ,,y,army,./pytest.sh python3 ./test.py -f query/test_join.py ,,y,army,./pytest.sh python3 ./test.py -f query/test_compare.py +,,y,army,./pytest.sh python3 ./test.py -f query/test_case_when.py ,,y,army,./pytest.sh python3 ./test.py -f insert/test_column_tag_boundary.py ,,y,army,./pytest.sh python3 ./test.py -f query/fill/fill_desc.py -N 3 -L 3 -D 2 ,,y,army,./pytest.sh python3 ./test.py -f query/fill/fill_null.py @@ -47,7 +50,7 @@ ,,y,army,./pytest.sh python3 ./test.py -f query/window/base.py ,,y,army,./pytest.sh python3 ./test.py -f query/sys/tb_perf_queries_exist_test.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f query/test_having.py -,,n,army,python3 ./test.py -f tmq/drop_lost_comsumers.py +,,n,army,python3 ./test.py -f tmq/drop_lost_comsumers.py # # system test # @@ -1083,6 +1086,7 @@ ,,y,script,./test.sh -f tsim/user/privilege_table.sim ,,y,script,./test.sh -f tsim/user/privilege_create_db.sim ,,y,script,./test.sh -f tsim/db/alter_option.sim +,,y,script,./test.sh -f tsim/db/dnodelist.sim # ,,y,script,./test.sh -f tsim/db/alter_replica_31.sim ,,y,script,./test.sh -f tsim/db/basic1.sim ,,y,script,./test.sh -f tsim/db/basic2.sim @@ -1317,6 +1321,8 @@ ,,y,script,./test.sh -f tsim/stream/basic2.sim ,,y,script,./test.sh -f tsim/stream/basic3.sim ,,y,script,./test.sh -f tsim/stream/basic4.sim +,,y,script,./test.sh -f tsim/stream/snodeCheck.sim +,,y,script,./test.sh -f tsim/stream/concurrentcheckpt.sim ,,y,script,./test.sh -f tsim/stream/checkpointInterval0.sim ,,y,script,./test.sh -f tsim/stream/checkStreamSTable1.sim ,,y,script,./test.sh -f tsim/stream/checkStreamSTable.sim diff --git a/tests/pytest/auto_crash_gen.py b/tests/pytest/auto_crash_gen.py index 343cbd72c3d..4e4679db6a4 100755 --- a/tests/pytest/auto_crash_gen.py +++ b/tests/pytest/auto_crash_gen.py @@ -6,15 +6,12 @@ # -*- coding: utf-8 -*- import os ,sys import random -import argparse import subprocess -import time -import platform # valgrind mode ? valgrind_mode = False -msg_dict = {0:"success" , 1:"failed" , 2:"other errors" , 3:"crash occured" , 4:"Invalid read/write" , 5:"memory leak" } +msg_dict = {0: "success", 1: "failed", 2: "other errors", 3: "crash occured", 4: "Invalid read/write", 5: "memory leak", 6: "dead locked"} # formal hostname = socket.gethostname() @@ -112,9 +109,9 @@ def random_args(args_list): # args_list["--connector-type"]=connect_types[random.randint(0,2)] args_list["--connector-type"]= connect_types[0] args_list["--max-dbs"]= random.randint(1,10) - + # dnodes = [1,3] # set single dnodes; - + # args_list["--num-dnodes"]= random.sample(dnodes,1)[0] # args_list["--num-replicas"]= random.randint(1,args_list["--num-dnodes"]) args_list["--debug"]=False @@ -125,7 +122,7 @@ def random_args(args_list): # args_list["--ignore-errors"]=[] ## can add error codes for detail - + args_list["--run-tdengine"]= False args_list["--use-shadow-db"]= False args_list["--dynamic-db-table-names"]= True @@ -162,7 +159,7 @@ def random_args(args_list): if args_list["--larger-data"]: threads = [16,32] else: - threads = [32,64,128,256] + threads = [32,64,128,256] args_list["--num-threads"]=random.sample(threads,1)[0] #$ debug return args_list @@ -176,7 +173,7 @@ def limits(args_list): pass # env is start by test frame , not crash_gen instance - + # elif args_list["--num-replicas"]==0: # print(" make sure num-replicas is at least 1 ") # args_list["--num-replicas"]=1 @@ -186,10 +183,10 @@ def limits(args_list): # elif args_list["--num-replicas"]>1: # if not args_list["--auto-start-service"]: # print("it should be deployed by crash_gen auto-start-service for multi replicas") - + # else: # pass - + return args_list def get_auto_mix_cmds(args_list ,valgrind=valgrind_mode): @@ -216,9 +213,9 @@ def get_auto_mix_cmds(args_list ,valgrind=valgrind_mode): arguments+="" else: arguments+=(k+"="+str(v)+" ") - + if valgrind : - + crash_gen_cmd = 'cd %s && ./crash_gen.sh --valgrind %s -g 0x32c,0x32d,0x3d3,0x18,0x2501,0x369,0x388,0x061a,0x2550,0x0203,0x4012 '%(crash_gen_path ,arguments) else: @@ -239,7 +236,7 @@ def start_taosd(): start_cmd = 'cd %s && python3 test.py >>/dev/null '%(start_path) os.system(start_cmd) -def get_cmds(args_list): +def get_cmds(args_list): crash_gen_cmd = get_auto_mix_cmds(args_list,valgrind=valgrind_mode) return crash_gen_cmd @@ -276,11 +273,15 @@ def check_status(): os.system("tail -n 50 %s>>%s"%(result_file,exit_status_logs)) core_check = subprocess.Popen('ls -l %s | grep "^-" | wc -l'%core_path, shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8") + dead_lock_check = subprocess.Popen("grep -i 'dead locked' %s "%result_file, shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8") if int(core_check.strip().rstrip()) > 0: # it means core files has occured return 3 - + + if dead_lock_check: + return 6 + if "Crash_Gen is now exiting with status code: 1" in run_code: return 1 elif "Crash_Gen is now exiting with status code: 0" in run_code: @@ -293,7 +294,7 @@ def main(): args_list = {"--auto-start-service":False ,"--max-dbs":0,"--connector-type":"native","--debug":False,"--run-tdengine":False,"--ignore-errors":[], "--track-memory-leaks":False , "--larger-data":False, "--mix-oos-data":False, "--dynamic-db-table-names":False, - "--per-thread-db-connection":False , "--record-ops":False , "--max-steps":100, "--num-threads":10, "--verify-data":False,"--use-shadow-db":False , + "--per-thread-db-connection":False , "--record-ops":False , "--max-steps":100, "--num-threads":10, "--verify-data":False,"--use-shadow-db":False , "--continue-on-exception":False } args = random_args(args_list) @@ -301,24 +302,24 @@ def main(): build_path = get_path() - + if repo =="community": crash_gen_path = build_path[:-5]+"community/tests/pytest/" elif repo =="TDengine": crash_gen_path = build_path[:-5]+"/tests/pytest/" else: pass - + if os.path.exists(crash_gen_path+"crash_gen.sh"): print(" make sure crash_gen.sh is ready") else: print( " crash_gen.sh is not exists ") sys.exit(1) - + git_commit = subprocess.Popen("cd %s && git log | head -n1"%crash_gen_path, shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")[7:16] - + # crash_cmds = get_cmds() - + crash_cmds = get_cmds(args) # clean run_dir os.system('rm -rf %s'%run_dir ) @@ -329,9 +330,9 @@ def main(): run_crash_gen(crash_cmds) endtime = datetime.datetime.now() status = check_status() - + print("exit status : ", status) - + if status ==4: print('======== crash_gen found memory bugs ========') if status ==5: @@ -344,15 +345,15 @@ def main(): try: cmd = crash_cmds.split('&')[2] if status == 0: - log_dir = "none" + log_dir = "none" else: - log_dir= "/root/pxiao/crash_gen_logs" - + log_dir= "/root/pxiao/crash_gen_logs" + if status == 3: core_dir = "/root/pxiao/crash_gen_logs" else: core_dir = "none" - + text = f''' exit status: {msg_dict[status]} test scope: crash_gen @@ -364,12 +365,12 @@ def main(): log dir: {log_dir} core dir: {core_dir} cmd: {cmd}''' - - send_msg(get_msg(text)) + + send_msg(get_msg(text)) except Exception as e: print("exception:", e) exit(status) - + if __name__ == '__main__': main() diff --git a/tests/pytest/auto_crash_gen_valgrind.py b/tests/pytest/auto_crash_gen_valgrind.py index 29d9d617320..1e0de6ace11 100755 --- a/tests/pytest/auto_crash_gen_valgrind.py +++ b/tests/pytest/auto_crash_gen_valgrind.py @@ -9,15 +9,12 @@ # -*- coding: utf-8 -*- import os ,sys import random -import argparse import subprocess -import time -import platform # valgrind mode ? valgrind_mode = True -msg_dict = {0:"success" , 1:"failed" , 2:"other errors" , 3:"crash occured" , 4:"Invalid read/write" , 5:"memory leak" } +msg_dict = {0: "success", 1: "failed", 2: "other errors", 3: "crash occured", 4: "Invalid read/write", 5: "memory leak", 6: "dead locked"} # formal hostname = socket.gethostname() @@ -48,6 +45,7 @@ def send_msg(json): 'Content-Type': 'application/json' } + req = requests.post(url=group_url, headers=headers, json=json) inf = req.json() if "StatusCode" in inf and inf["StatusCode"] == 0: @@ -115,9 +113,9 @@ def random_args(args_list): # args_list["--connector-type"]=connect_types[random.randint(0,2)] args_list["--connector-type"]= connect_types[0] args_list["--max-dbs"]= random.randint(1,10) - + # dnodes = [1,3] # set single dnodes; - + # args_list["--num-dnodes"]= random.sample(dnodes,1)[0] # args_list["--num-replicas"]= random.randint(1,args_list["--num-dnodes"]) args_list["--debug"]=False @@ -125,13 +123,13 @@ def random_args(args_list): args_list["--track-memory-leaks"]=False args_list["--max-steps"]=random.randint(200,500) - + threads = [16,32] args_list["--num-threads"]=random.sample(threads,1)[0] #$ debug # args_list["--ignore-errors"]=[] ## can add error codes for detail - + args_list["--run-tdengine"]= False args_list["--use-shadow-db"]= False args_list["--dynamic-db-table-names"]= True @@ -177,7 +175,7 @@ def limits(args_list): pass # env is start by test frame , not crash_gen instance - + # elif args_list["--num-replicas"]==0: # print(" make sure num-replicas is at least 1 ") # args_list["--num-replicas"]=1 @@ -187,10 +185,10 @@ def limits(args_list): # elif args_list["--num-replicas"]>1: # if not args_list["--auto-start-service"]: # print("it should be deployed by crash_gen auto-start-service for multi replicas") - + # else: # pass - + return args_list def get_auto_mix_cmds(args_list ,valgrind=valgrind_mode): @@ -217,9 +215,9 @@ def get_auto_mix_cmds(args_list ,valgrind=valgrind_mode): arguments+="" else: arguments+=(k+"="+str(v)+" ") - + if valgrind : - + crash_gen_cmd = 'cd %s && ./crash_gen.sh --valgrind %s -g 0x32c,0x32d,0x3d3,0x18,0x2501,0x369,0x388,0x061a,0x2550,0x0203,0x4012 '%(crash_gen_path ,arguments) else: @@ -228,7 +226,6 @@ def get_auto_mix_cmds(args_list ,valgrind=valgrind_mode): return crash_gen_cmd - def start_taosd(): build_path = get_path() if repo == "community": @@ -272,7 +269,7 @@ def check_status(): if int(core_check.strip().rstrip()) > 0: # it means core files has occured return 3 - + mem_status = check_memory() if mem_status >0: return mem_status @@ -281,8 +278,8 @@ def check_status(): elif "Crash_Gen is now exiting with status code: 0" in run_code: return 0 else: - return 2 - + return 2 + def check_memory(): @@ -301,34 +298,37 @@ def check_memory(): os.mkdir(back_path) stderr_file = os.path.join(crash_gen_path , "valgrind.err") - + stdout_file = os.path.join(crash_gen_path, 'valgrind.out') + status = 0 grep_res = subprocess.Popen("grep -i 'Invalid read' %s "%stderr_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8") - + if grep_res: # os.system("cp %s %s"%(stderr_file , back_path)) status = 4 - + grep_res = subprocess.Popen("grep -i 'Invalid write' %s "%stderr_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8") - + if grep_res: # os.system("cp %s %s"%(stderr_file , back_path)) status = 4 - + grep_res = subprocess.Popen("grep -i 'taosMemoryMalloc' %s "%stderr_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8") - + if grep_res: + # mem-leak can be also occure when exit normally when dead lock # os.system("cp %s %s"%(stderr_file , back_path)) - status = 5 - + dead_lock_res = subprocess.Popen("grep -i 'dead locked' %s "%stdout_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8") + status = 6 if dead_lock_res else 5 + return status def main(): args_list = {"--auto-start-service":False ,"--max-dbs":0,"--connector-type":"native","--debug":False,"--run-tdengine":False,"--ignore-errors":[], "--track-memory-leaks":False , "--larger-data":False, "--mix-oos-data":False, "--dynamic-db-table-names":False, - "--per-thread-db-connection":False , "--record-ops":False , "--max-steps":100, "--num-threads":10, "--verify-data":False,"--use-shadow-db":False , + "--per-thread-db-connection":False , "--record-ops":False , "--max-steps":100, "--num-threads":10, "--verify-data":False,"--use-shadow-db":False , "--continue-on-exception":False } args = random_args(args_list) @@ -341,17 +341,17 @@ def main(): crash_gen_path = build_path[:-5]+"/tests/pytest/" else: pass - + if os.path.exists(crash_gen_path+"crash_gen.sh"): print(" make sure crash_gen.sh is ready") else: print( " crash_gen.sh is not exists ") sys.exit(1) - + git_commit = subprocess.Popen("cd %s && git log | head -n1"%crash_gen_path, shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")[7:16] # crash_cmds = get_cmds() - + crash_cmds = get_cmds(args) # clean run_dir @@ -364,9 +364,9 @@ def main(): endtime = datetime.datetime.now() status = check_status() # back_path = os.path.join(core_path,"valgrind_report") - + print("exit status : ", status) - + if status ==4: print('======== crash_gen found memory bugs ========') if status ==5: @@ -379,15 +379,15 @@ def main(): try: cmd = crash_cmds.split('&')[2] if status == 0: - log_dir = "none" + log_dir = "none" else: - log_dir= "/root/pxiao/crash_gen_logs" - + log_dir= "/root/pxiao/crash_gen_logs" + if status == 3: core_dir = "/root/pxiao/crash_gen_logs" else: core_dir = "none" - + text = f''' exit status: {msg_dict[status]} test scope: crash_gen @@ -399,12 +399,12 @@ def main(): log dir: {log_dir} core dir: {core_dir} cmd: {cmd}''' - + send_msg(get_msg(text)) except Exception as e: print("exception:", e) exit(status) - + if __name__ == '__main__': main() diff --git a/tests/pytest/auto_crash_gen_valgrind_cluster.py b/tests/pytest/auto_crash_gen_valgrind_cluster.py index 8546d436de0..22f453e51ef 100755 --- a/tests/pytest/auto_crash_gen_valgrind_cluster.py +++ b/tests/pytest/auto_crash_gen_valgrind_cluster.py @@ -1,23 +1,17 @@ #!/usr/bin/python3 - - +# -*- coding: utf-8 -*- import datetime import os import socket import requests - -# -*- coding: utf-8 -*- import os ,sys import random -import argparse import subprocess -import time -import platform # valgrind mode ? valgrind_mode = True -msg_dict = {0:"success" , 1:"failed" , 2:"other errors" , 3:"crash occured" , 4:"Invalid read/write" , 5:"memory leak" } +msg_dict = {0: "success", 1: "failed", 2: "other errors", 3: "crash occured", 4: "Invalid read/write", 5: "memory leak", 6: "dead locked"} # formal hostname = socket.gethostname() @@ -115,9 +109,9 @@ def random_args(args_list): # args_list["--connector-type"]=connect_types[random.randint(0,2)] args_list["--connector-type"]= connect_types[0] args_list["--max-dbs"]= random.randint(1,10) - + # dnodes = [1,3] # set single dnodes; - + # args_list["--num-dnodes"]= random.sample(dnodes,1)[0] # args_list["--num-replicas"]= random.randint(1,args_list["--num-dnodes"]) args_list["--debug"]=False @@ -125,13 +119,12 @@ def random_args(args_list): args_list["--track-memory-leaks"]=False args_list["--max-steps"]=random.randint(200,500) - + threads = [16,32] args_list["--num-threads"]=random.sample(threads,1)[0] #$ debug # args_list["--ignore-errors"]=[] ## can add error codes for detail - args_list["--run-tdengine"]= False args_list["--use-shadow-db"]= False args_list["--dynamic-db-table-names"]= True @@ -177,7 +170,7 @@ def limits(args_list): pass # env is start by test frame , not crash_gen instance - + # elif args_list["--num-replicas"]==0: # print(" make sure num-replicas is at least 1 ") # args_list["--num-replicas"]=1 @@ -187,10 +180,9 @@ def limits(args_list): # elif args_list["--num-replicas"]>1: # if not args_list["--auto-start-service"]: # print("it should be deployed by crash_gen auto-start-service for multi replicas") - + # else: # pass - return args_list def get_auto_mix_cmds(args_list ,valgrind=valgrind_mode): @@ -217,18 +209,13 @@ def get_auto_mix_cmds(args_list ,valgrind=valgrind_mode): arguments+="" else: arguments+=(k+"="+str(v)+" ") - + if valgrind : - crash_gen_cmd = 'cd %s && ./crash_gen.sh --valgrind -i 3 %s -g 0x32c,0x32d,0x3d3,0x18,0x2501,0x369,0x388,0x061a,0x2550,0x0707,0x0203,0x4012 '%(crash_gen_path ,arguments) - else: - crash_gen_cmd = 'cd %s && ./crash_gen.sh -i 3 %s -g 0x32c,0x32d,0x3d3,0x18,0x2501,0x369,0x388,0x061a,0x2550,0x0014,0x0707,0x0203,0x4012'%(crash_gen_path ,arguments) - return crash_gen_cmd - def start_taosd(): build_path = get_path() if repo == "community": @@ -242,7 +229,7 @@ def start_taosd(): os.system(start_cmd +">>/dev/null") def get_cmds(args_list): - + crash_gen_cmd = get_auto_mix_cmds(args_list,valgrind=valgrind_mode) return crash_gen_cmd @@ -272,7 +259,7 @@ def check_status(): if int(core_check.strip().rstrip()) > 0: # it means core files has occured return 3 - + mem_status = check_memory() if mem_status >0: return mem_status @@ -281,8 +268,7 @@ def check_status(): elif "Crash_Gen is now exiting with status code: 0" in run_code: return 0 else: - return 2 - + return 2 def check_memory(): @@ -301,57 +287,58 @@ def check_memory(): os.mkdir(back_path) stderr_file = os.path.join(crash_gen_path , "valgrind.err") - + stdout_file = os.path.join(crash_gen_path, 'valgrind.out') status = 0 grep_res = subprocess.Popen("grep -i 'Invalid read' %s "%stderr_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8") - + if grep_res: # os.system("cp %s %s"%(stderr_file , back_path)) status = 4 - + grep_res = subprocess.Popen("grep -i 'Invalid write' %s "%stderr_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8") - + if grep_res: # os.system("cp %s %s"%(stderr_file , back_path)) status = 4 - + grep_res = subprocess.Popen("grep -i 'taosMemoryMalloc' %s "%stderr_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8") - + if grep_res: + # mem-leak can be also occure when exit normally when dead lock # os.system("cp %s %s"%(stderr_file , back_path)) - status = 5 - + dead_lock_res = subprocess.Popen("grep -i 'dead locked' %s "%stdout_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8") + status = 6 if dead_lock_res else 5 + return status def main(): - args_list = {"--auto-start-service":False ,"--max-dbs":0,"--connector-type":"native","--debug":False,"--run-tdengine":False,"--ignore-errors":[], "--track-memory-leaks":False , "--larger-data":False, "--mix-oos-data":False, "--dynamic-db-table-names":False, - "--per-thread-db-connection":False , "--record-ops":False , "--max-steps":100, "--num-threads":10, "--verify-data":False,"--use-shadow-db":False , + "--per-thread-db-connection":False , "--record-ops":False , "--max-steps":100, "--num-threads":10, "--verify-data":False,"--use-shadow-db":False , "--continue-on-exception":False } args = random_args(args_list) args = limits(args) - build_path = get_path() + build_path = get_path() if repo =="community": crash_gen_path = build_path[:-5]+"community/tests/pytest/" elif repo =="TDengine": crash_gen_path = build_path[:-5]+"/tests/pytest/" else: pass - + if os.path.exists(crash_gen_path+"crash_gen.sh"): print(" make sure crash_gen.sh is ready") else: print( " crash_gen.sh is not exists ") sys.exit(1) - + git_commit = subprocess.Popen("cd %s && git log | head -n1"%crash_gen_path, shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8")[7:16] # crash_cmds = get_cmds() - + crash_cmds = get_cmds(args) # clean run_dir @@ -364,9 +351,9 @@ def main(): endtime = datetime.datetime.now() status = check_status() # back_path = os.path.join(core_path,"valgrind_report") - + print("exit status : ", status) - + if status ==4: print('======== crash_gen found memory bugs ========') if status ==5: @@ -379,15 +366,15 @@ def main(): try: cmd = crash_cmds.split('&')[2] if status == 0: - log_dir = "none" + log_dir = "none" else: - log_dir= "/root/pxiao/crash_gen_logs" - + log_dir= "/root/pxiao/crash_gen_logs" + if status == 3: core_dir = "/root/pxiao/crash_gen_logs" else: core_dir = "none" - + text = f''' exit status: {msg_dict[status]} test scope: crash_gen @@ -399,12 +386,11 @@ def main(): log dir: {log_dir} core dir: {core_dir} cmd: {cmd}''' - - send_msg(get_msg(text)) + + send_msg(get_msg(text)) except Exception as e: print("exception:", e) exit(status) - if __name__ == '__main__': main() diff --git a/tests/script/api/makefile b/tests/script/api/makefile index d8a4e192187..9c2bb6be3d5 100644 --- a/tests/script/api/makefile +++ b/tests/script/api/makefile @@ -25,6 +25,7 @@ exe: gcc $(CFLAGS) ./stmt.c -o $(ROOT)stmt $(LFLAGS) gcc $(CFLAGS) ./stmt2.c -o $(ROOT)stmt2 $(LFLAGS) gcc $(CFLAGS) ./stmt2-example.c -o $(ROOT)stmt2-example $(LFLAGS) + gcc $(CFLAGS) ./stmt2-get-fields.c -o $(ROOT)stmt2-get-fields $(LFLAGS) gcc $(CFLAGS) ./stmt2-nohole.c -o $(ROOT)stmt2-nohole $(LFLAGS) gcc $(CFLAGS) ./stmt-crash.c -o $(ROOT)stmt-crash $(LFLAGS) @@ -42,5 +43,6 @@ clean: rm $(ROOT)stmt rm $(ROOT)stmt2 rm $(ROOT)stmt2-example + rm $(ROOT)stmt2-get-fields rm $(ROOT)stmt2-nohole rm $(ROOT)stmt-crash diff --git a/tests/script/api/stmt2-get-fields.c b/tests/script/api/stmt2-get-fields.c new file mode 100644 index 00000000000..befde39f8a6 --- /dev/null +++ b/tests/script/api/stmt2-get-fields.c @@ -0,0 +1,129 @@ +// TAOS standard API example. The same syntax as MySQL, but only a subet +// to compile: gcc -o stmt2-get-fields stmt2-get-fields.c -ltaos + +#include +#include +#include +#include "taos.h" + +void getFields(TAOS *taos, const char *sql) { + TAOS_STMT2_OPTION option = {0}; + TAOS_STMT2 *stmt = taos_stmt2_init(taos, &option); + int code = taos_stmt2_prepare(stmt, sql, 0); + if (code != 0) { + printf("failed to execute taos_stmt2_prepare. error:%s\n", taos_stmt2_error(stmt)); + taos_stmt2_close(stmt); + return; + } + int fieldNum = 0; + TAOS_FIELD_STB *pFields = NULL; + code = taos_stmt2_get_stb_fields(stmt, &fieldNum, &pFields); + if (code != 0) { + printf("failed get col,ErrCode: 0x%x, ErrMessage: %s.\n", code, taos_stmt2_error(stmt)); + } else { + printf("col nums:%d\n", fieldNum); + for (int i = 0; i < fieldNum; i++) { + printf("field[%d]: %s, data_type:%d, field_type:%d\n", i, pFields[i].name, pFields[i].type, + pFields[i].field_type); + } + } + printf("====================================\n"); + taos_stmt2_free_stb_fields(stmt, pFields); + taos_stmt2_close(stmt); +} + +void do_query(TAOS *taos, const char *sql) { + TAOS_RES *result = taos_query(taos, sql); + int code = taos_errno(result); + if (code) { + printf("failed to query: %s, reason:%s\n", sql, taos_errstr(result)); + taos_free_result(result); + return; + } + taos_free_result(result); +} + +void do_stmt(TAOS *taos) { + do_query(taos, "drop database if exists db"); + do_query(taos, "create database db"); + do_query(taos, + "create table db.stb (ts timestamp, b binary(10)) tags(t1 " + "int, t2 binary(10))"); + do_query(taos, "CREATE TABLE db.d0 USING db.stb (t1,t2) TAGS (7,'Cali');"); + do_query(taos, "CREATE TABLE db.ntb(nts timestamp, nb binary(10),nvc varchar(16),ni int);"); + + printf("field_type: TAOS_FIELD_COL = 1, TAOS_FIELD_TAG=2, TAOS_FIELD_QUERY=3, TAOS_FIELD_TBNAME=4\n"); + + // case 1 : INSERT INTO db.stb(t1,t2,ts,b,tbname) values(?,?,?,?,?) + // test super table + const char *sql = "insert into db.stb(t1,t2,ts,b,tbname) values(?,?,?,?,?)"; + printf("====================================\n"); + printf("case 1 : %s\n", sql); + getFields(taos, sql); + + // case 2 : INSERT INTO db.d0 VALUES (?,?) + // test child table + sql = "INSERT INTO db.d0(ts,b) VALUES (?,?)"; + printf("case 2 : %s\n", sql); + getFields(taos, sql); + + // case 3 : INSERT INTO db.ntb VALUES(?,?,?,?) + // test normal table + sql = "INSERT INTO db.ntb VALUES(?,?,?,?)"; + printf("case 3 : %s\n", sql); + getFields(taos, sql); + + // case 4 : INSERT INTO db.? using db.stb TAGS(?,?) VALUES(?,?) + // not support this clause + sql = "insert into db.? using db.stb tags(?, ?) values(?,?)"; + printf("case 4 (not support): %s\n", sql); + getFields(taos, sql); + + // case 5 : INSERT INTO db.stb(t1,t2,ts,b) values(?,?,?,?) + // no tbname error + sql = "INSERT INTO db.stb(t1,t2,ts,b) values(?,?,?,?)"; + printf("case 5 (no tbname error): %s\n", sql); + getFields(taos, sql); + + // case 6 : INSERT INTO db.d0 using db.stb values(?,?) + // none para for ctbname + sql = "INSERT INTO db.d0 using db.stb values(?,?)"; + printf("case 6 (no tags error): %s\n", sql); + getFields(taos, sql); + + // case 7 : insert into db.stb(t1,t2,tbname) values(?,?,?) + // no value + sql = "insert into db.stb(t1,t2,tbname) values(?,?,?)"; + printf("case 7 (no PK error): %s\n", sql); + getFields(taos, sql); + + // case 8 : insert into db.stb(ts,b,tbname) values(?,?,?) + // no tag + sql = "insert into db.stb(ts,b,tbname) values(?,?,?)"; + printf("case 8 : %s\n", sql); + getFields(taos, sql); + + // case 9 : insert into db.stb(ts,b,tbname) values(?,?,?,?,?) + // wrong para nums + sql = "insert into db.stb(ts,b,tbname) values(?,?,?,?,?)"; + printf("case 9 (wrong para nums): %s\n", sql); + getFields(taos, sql); + + // case 10 : insert into db.ntb(nts,ni) values(?,?,?,?,?) + // wrong para nums + sql = "insert into db.ntb(nts,ni) values(?,?)"; + printf("case 10 : %s\n", sql); + getFields(taos, sql); +} + +int main() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", "", 0); + if (!taos) { + printf("failed to connect to db, reason:%s\n", taos_errstr(taos)); + exit(1); + } + + do_stmt(taos); + taos_close(taos); + taos_cleanup(); +} \ No newline at end of file diff --git a/tests/script/tsim/compress/commitlog.sim b/tests/script/tsim/compress/commitlog.sim index 38899b95ba9..d0380dd5595 100644 --- a/tests/script/tsim/compress/commitlog.sim +++ b/tests/script/tsim/compress/commitlog.sim @@ -20,7 +20,7 @@ sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bi $count = 0 while $count < $N $ms = 1591200000000 + $count - sql insert into $tb values( $ms , 1, 0, $count , $count , $count ,'it is a string') + sql insert into $tb values( $ms , 10, 0, $count , $count , $count ,'it is a string') $count = $count + 1 endw @@ -29,6 +29,13 @@ if $rows != $N then return -1 endi +sql flush database $db + +sql select * from $tb +if $rows != $N then + return -1 +endi + print =============== step2 $i = 1 $db = $dbPrefix . $i diff --git a/tests/script/tsim/compress/compressDisable.sim b/tests/script/tsim/compress/compressDisable.sim new file mode 100644 index 00000000000..dac7ef712ae --- /dev/null +++ b/tests/script/tsim/compress/compressDisable.sim @@ -0,0 +1,146 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ============================ dnode1 start +$i = 0 +$dbPrefix = db +$tbPrefix = tb +$db = $dbPrefix . $i +$tb = $tbPrefix . $i + +$N = 2000 + +print =============== step1 +sql create database $db +sql use $db +sql create table $tb (ts timestamp, b bool encode 'disabled', t tinyint encode 'disabled', s smallint encode 'disabled', i int encode 'disabled', big bigint encode 'disabled', str binary(256)) + +$count = 0 +while $count < $N + $ms = 1591200000000 + $count + sql insert into $tb values( $ms , 1, 0, $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +sql select * from $tb +if $rows != $N then + return -1 +endi + +sql flush database $db + +sql select * from $tb +if $rows != $N then + return -1 +endi + +sql alter table $tb modify column ts encode 'disabled' + +$count = 0 +while $count < $N + $ms = 1591200030000 + $count + sql insert into $tb values( $ms , 1, 0, $count , $count , $count ,'it is a string') + $count = $count + 1 +endw + +$M = 4000 +sql select * from $tb +if $rows != $M then + return -1 +endi + +sql flush database $db + +sql select * from $tb +if $rows != $M then + return -1 +endi + + +$stb1 = txx1 +sql create table txx1 (ts timestamp encode 'disabled' compress 'disabled' level 'h', f int compress 'lz4') tags(t int) + +$count = 0 +$subTb1 = txx1_sub1 +$subTb2 = txx1_sub2 + +sql create table $subTb1 using $stb1 tags(1) +sql create table $subTb2 using $stb1 tags(2) + +while $count < $N + $ms = 1591200030000 + $count + sql insert into $subTb1 values( $ms , 1) + + $ms2 = 1591200040000 + $count + sql insert into $subTb2 values( $ms2 , 1) + $count = $count + 1 +endw + +$count = 0 +sql select * from $stb1 +if $rows != $M then + return -1 +endi + +sql flush database $db + +sql select * from $stb1 +if $rows != $M then + return -1 +endi + +$L = 8000 +sql alter table $stb1 modify column ts encode 'delta-i' +sql alter table $stb1 modify column f encode 'disabled' + +while $count < $N + $ms = 1591200050000 + $count + sql insert into $subTb1 values( $ms , 1) + + $ms2 = 1591200060000 + $count + sql insert into $subTb2 values( $ms2 , 1) + $count = $count + 1 +endw + + +sql select * from $stb1 +if $rows != $L then + return -1 +endi + +sql flush database $db + +sql select * from $stb1 +if $rows != $L then + return -1 +endi + +sql alter table $stb1 modify column ts encode 'disabled' + + +$count = 0 +$I = 12000 +while $count < $N + $ms = 1591200070000 + $count + sql insert into $subTb1 values( $ms , 1) + + $ms2 = 1591200080000 + $count + sql insert into $subTb2 values( $ms2 , 1) + $count = $count + 1 +endw + + +sql select * from $stb1 +if $rows != $I then + return -1 +endi + +sql flush database $db + +sql select * from $stb1 +if $rows != $I then + return -1 +endi + diff --git a/tests/script/tsim/db/dnodelist.sim b/tests/script/tsim/db/dnodelist.sim new file mode 100644 index 00000000000..08bf08a1fef --- /dev/null +++ b/tests/script/tsim/db/dnodelist.sim @@ -0,0 +1,258 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start + +sql connect +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 +sql create dnode $hostname port 7500 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql select * from information_schema.ins_dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 +if $rows != 5 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != ready then + goto step1 +endi +if $data(4)[4] != ready then + goto step1 +endi +if $data(5)[4] != ready then + goto step1 +endi + +print --- error case + +sql_error create database d1 vgroups 1 dnodes '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; +sql_error create database d1 vgroups 1 dnodes '1 '; +sql_error create database d1 vgroups 1 dnodes ' 1'; +sql_error create database d1 vgroups 1 dnodes '1,'; +sql_error create database d1 vgroups 1 dnodes '1, '; +sql_error create database d1 vgroups 1 dnodes 'a '; +sql_error create database d1 vgroups 1 dnodes '- '; +sql_error create database d1 vgroups 1 dnodes '1,1'; +sql_error create database d1 vgroups 1 dnodes '1, 1'; +sql_error create database d1 vgroups 1 dnodes '1,1234567890'; +sql_error create database d1 vgroups 1 dnodes '1,2,6'; +sql_error create database d1 vgroups 1 dnodes ',1,2'; +sql_error create database d1 vgroups 1 dnodes 'x1,2'; +sql_error create database d1 vgroups 1 dnodes 'c1,ab2'; +sql_error create database d1 vgroups 1 dnodes '1,1,2'; + +sql_error create database d1 vgroups 1 replica 2 dnodes '1'; +sql_error create database d1 vgroups 1 replica 2 dnodes '1,8'; +sql_error create database d1 vgroups 1 replica 3 dnodes '1'; +sql_error create database d1 vgroups 1 replica 3 dnodes '1,2'; +sql_error create database d1 vgroups 1 replica 3 dnodes '1,2,4,6'; + +print --- replica 1 + +print --- case10 +sql create database d10 vgroups 1 dnodes '1'; +sql show dnodes; +if $data(1)[2] != 1 then + return -1 +endi +sql_error alter database d10 replica 1 dnodes '1,2,3'; +sql drop database d10; + +print --- case11 +sql create database d11 vgroups 1 dnodes '2'; +sql show dnodes; +if $data(2)[2] != 1 then + return -1 +endi +sql drop database d11; + +print --- case12 +sql create database d12 vgroups 2 dnodes '3,4'; +sql show dnodes; +if $data(3)[2] != 1 then + return -1 +endi +if $data(4)[2] != 1 then + return -1 +endi +sql drop database d12; + +print --- case13 +sql create database d13 vgroups 2 dnodes '5'; +sql show dnodes; +if $data(5)[2] != 2 then + return -1 +endi +sql drop database d13; + +print --- case14 +sql create database d14 vgroups 1 dnodes '1,2,5'; +sql drop database d14; + +print --- case15 +sql create database d15 vgroups 2 dnodes '1,4,3'; +sql drop database d15; + +print --- case16 +sql create database d16 vgroups 3 dnodes '1'; +sql show dnodes; +if $data(1)[2] != 3 then + return -1 +endi +sql drop database d16; + +print --- case17 +sql create database d17 vgroups 3 dnodes '1,4'; +sql drop database d17; + +print --- case18 +sql create database d18 vgroups 3 dnodes '1,2,4'; +sql show dnodes; +if $data(1)[2] != 1 then + return -1 +endi +if $data(2)[2] != 1 then + return -1 +endi +if $data(4)[2] != 1 then + return -1 +endi +sql drop database d18; + +print --- replica 2 + +print --- case20 +sql create database d20 replica 2 vgroups 1 dnodes '1,2'; +sql show dnodes; +if $data(1)[2] != 1 then + return -1 +endi +if $data(2)[2] != 1 then + return -1 +endi +sql drop database d20; + +print --- case21 +sql create database d21 replica 2 vgroups 3 dnodes '1,2,3'; +sql show dnodes; +if $data(1)[2] != 2 then + return -1 +endi +if $data(2)[2] != 2 then + return -1 +endi +if $data(3)[2] != 2 then + return -1 +endi +sql drop database d21; + +print --- case22 +sql create database d22 replica 2 vgroups 2 dnodes '1,2'; +sql show dnodes; +if $data(1)[2] != 2 then + return -1 +endi +if $data(2)[2] != 2 then + return -1 +endi +sql drop database d22; + +print --- replica 3 + +print --- case30 +sql create database d30 replica 3 vgroups 3 dnodes '1,2,3'; +sql show dnodes; +if $data(1)[2] != 3 then + return -1 +endi +if $data(2)[2] != 3 then + return -1 +endi +if $data(3)[2] != 3 then + return -1 +endi +sql_error alter database d30 replica 1 dnodes '1'; +sql drop database d30; + +print --- case31 +sql create database d31 replica 3 vgroups 2 dnodes '1,2,4'; +sql show dnodes; +if $data(1)[2] != 2 then + return -1 +endi +if $data(2)[2] != 2 then + return -1 +endi +if $data(4)[2] != 2 then + return -1 +endi +sql drop database d31; + +print --- case32 +sql create database d32 replica 3 vgroups 4 dnodes '4,2,3,1'; +sql show dnodes; +if $data(1)[2] != 3 then + return -1 +endi +if $data(2)[2] != 3 then + return -1 +endi +if $data(3)[2] != 3 then + return -1 +endi +if $data(4)[2] != 3 then + return -1 +endi +sql drop database d32; + +print --- case33 +sql create database d33 replica 3 vgroups 5 dnodes '4,2,3,1,5'; +sql show dnodes; +if $data(1)[2] != 3 then + return -1 +endi +if $data(2)[2] != 3 then + return -1 +endi +if $data(3)[2] != 3 then + return -1 +endi +if $data(4)[2] != 3 then + return -1 +endi +if $data(5)[2] != 3 then + return -1 +endi +sql drop database d33; + +return + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/tsim/scalar/caseWhen.sim b/tests/script/tsim/scalar/caseWhen.sim index 67c8ac36735..4753e245137 100644 --- a/tests/script/tsim/scalar/caseWhen.sim +++ b/tests/script/tsim/scalar/caseWhen.sim @@ -838,7 +838,7 @@ endi if $data20 != 11 then return -1 endi -if $data30 != 1664176504 then +if $data30 != 1664176504000 then return -1 endi @@ -1130,38 +1130,38 @@ if $data00 != varchar_val then return -1 endi -sql select case when ts > '2022-01-01 00:00:00' then c_varchar else c_geometry end as result from t_test; -if $data00 != varchar_val then - return -1 -endi - -sql select case when ts > '2022-01-01 00:00:00' then c_bool else c_geometry end as result from t_test; -if $data00 != true then +sql select case when 1 then 1234567890987654 else 'abcertyuiojhgfddhjgfcvbn' end; +if $data00 != 1234567890987654 then return -1 endi -sql select case when 0 then tag_id else c_geometry end as result from t_test; -if $data00 != 16842773 then +sql select case when 0 then 1234567890987654 else 'abcertyuiojhgfddhjgfcvbn' end; +if $data00 != abcertyuiojhgfddhjgfcvbn then return -1 endi -sql select case when 0 then tag_id else c_nchar end as result from t_test; +sql select case when 0 then 1234567890987654 else c_nchar end from t_test; if $data00 != 涛思数据 then return -1 endi -sql select case when 0 then tag_id else c_int end as result from t_test; -if $data00 != 123 then +sql select case when 1 then 1234567890987654 else c_nchar end from t_test; +if $data00 != 1234567890987654 then return -1 endi -sql select case when 0 then tag_id else c_float end as result from t_test; -if $data00 != 123.449997 then +sql select case when 1 then c_varchar else c_varbinary end from t_test; +if $data00 != null then return -1 endi +sql_error select case when ts > '2022-01-01 00:00:00' then c_varchar else c_geometry end as result from t_test; +sql_error select case when ts > '2022-01-01 00:00:00' then c_bool else c_geometry end as result from t_test; +sql_error select case when 0 then tag_id else c_geometry end as result from t_test; +sql_error select case when 0 then tag_id else c_nchar end as result from t_test; +sql_error select case when 0 then tag_id else c_int end as result from t_test; +sql_error select case when 0 then tag_id else c_float end as result from t_test; sql_error select case when c_double > 100 then c_varbinary else c_geometry end as result from t_test; sql_error select case when c_bool then c_double else c_varbinary end as result from t_test; -sql_error select case when c_bool then c_varbinary else c_varchar end as result from t_test; system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/concurrentcheckpt.sim b/tests/script/tsim/stream/concurrentcheckpt.sim new file mode 100644 index 00000000000..4162617debc --- /dev/null +++ b/tests/script/tsim/stream/concurrentcheckpt.sim @@ -0,0 +1,79 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 1 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database abc1 vgroups 1; +sql use abc1; +sql create table st1(ts timestamp, k int) tags(a int); +sql create table t1 using st1 tags(1); +sql create table t2 using st1 tags(2); +sql insert into t1 values(now, 1); + +sql create stream str1 trigger at_once into str_dst1 as select count(*) from st1 interval(30s); +sql create stream str2 trigger at_once into str_dst2 as select count(*) from st1 interval(30s); +sql create stream str3 trigger at_once into str_dst3 as select count(*) from st1 interval(30s); + +print ============== create 3 streams, check the concurrently checkpoint +sleep 180000 + +sql select task_id, checkpoint_id from information_schema.ins_stream_tasks order by checkpoint_id; + +print $data01 $data11 $data21 +if $data01 == $data11 then + print not allowed 2 checkpoint start completed + return -1 +endi + +if $data11 == $data21 then + print not allowed 2 checkpoints start concurrently + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT + +print ========== concurrent checkpoint is set 2 + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c concurrentCheckpoint -v 2 + +system sh/exec.sh -n dnode1 -s start + +print ========== step2 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database abc1 vgroups 1; +sql use abc1; +sql create table st1(ts timestamp, k int) tags(a int); +sql create table t1 using st1 tags(1); +sql create table t2 using st1 tags(2); +sql insert into t1 values(now, 1); + +sql create stream str1 trigger at_once into str_dst1 as select count(*) from st1 interval(30s); +sql create stream str2 trigger at_once into str_dst2 as select count(*) from st1 interval(30s); +sql create stream str3 trigger at_once into str_dst3 as select count(*) from st1 interval(30s); + +print ============== create 3 streams, check the concurrently checkpoint +sleep 180000 + +sql select count(*) a, checkpoint_id from information_schema.ins_stream_tasks group by checkpoint_id order by a; +print $data00 $data01 +print $data10 $data11 + +if $data00 != 1 then + print expect 1, actual $data00 + return -1 +endi + +if $data10 != 2 then + print expect 2, actual $data10 + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/snodeCheck.sim b/tests/script/tsim/stream/snodeCheck.sim new file mode 100644 index 00000000000..f4ab8c81249 --- /dev/null +++ b/tests/script/tsim/stream/snodeCheck.sim @@ -0,0 +1,64 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode2 -c supportVnodes -v 4 +system sh/cfg.sh -n dnode3 -c supportVnodes -v 4 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== step2 +sql create dnode $hostname port 7200 +system sh/exec.sh -n dnode2 -s start + +sql create dnode $hostname port 7300 +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql select * from information_schema.ins_dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 3 then + return -1 +endi +if $data(1)[4] != ready then + goto step2 +endi +if $data(2)[4] != ready then + goto step2 +endi + +print ========== step3 +sql drop database if exists test; +sql create database if not exists test vgroups 4 replica 3 precision "ms" ; +sql use test; + +sql create table test.test (ts timestamp, c1 int) tags (t1 int) ; + +print create stream without snode existing +sql_error create stream stream_t1 trigger at_once into str_dst as select count(*) from test interval(20s); + +print create snode +sql create snode on dnode 1; + +sql create stream stream_t1 trigger at_once into str_dst as select count(*) from test interval(20s); + +print drop snode and then create stream +sql drop snode on dnode 1; + +sql_error create stream stream_t2 trigger at_once into str_dst as select count(*) from test interval(20s); + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/tsim/testsuit.sim b/tests/script/tsim/testsuit.sim index c208a07488d..ec52b8c234b 100644 --- a/tests/script/tsim/testsuit.sim +++ b/tests/script/tsim/testsuit.sim @@ -102,6 +102,7 @@ run tsim/stream/triggerInterval0.sim run tsim/stream/triggerSession0.sim run tsim/stream/distributeIntervalRetrive0.sim run tsim/stream/basic0.sim +run tsim/stream/snodeCheck.sim run tsim/stream/session0.sim run tsim/stream/schedSnode.sim run tsim/stream/partitionby.sim @@ -110,6 +111,7 @@ run tsim/stream/distributeInterval0.sim run tsim/stream/distributeSession0.sim run tsim/stream/state0.sim run tsim/stream/basic2.sim +run tsim/stream/concurrentcheckpt.sim run tsim/insert/basic1.sim run tsim/insert/commit-merge0.sim run tsim/insert/basic0.sim diff --git a/tests/script/win-test-file b/tests/script/win-test-file index ff69e919672..ef99442214e 100644 --- a/tests/script/win-test-file +++ b/tests/script/win-test-file @@ -325,6 +325,7 @@ ./test.sh -f tsim/compress/compress.sim ./test.sh -f tsim/compress/compress_col.sim ./test.sh -f tsim/compress/uncompress.sim +./test.sh -f tsim/compress/compressDisable.sim ./test.sh -f tsim/compute/avg.sim ./test.sh -f tsim/compute/block_dist.sim ./test.sh -f tsim/compute/bottom.sim diff --git a/tests/system-test/0-others/sysinfo.py b/tests/system-test/0-others/sysinfo.py index 43a0400f188..35e574739bd 100644 --- a/tests/system-test/0-others/sysinfo.py +++ b/tests/system-test/0-others/sysinfo.py @@ -39,7 +39,7 @@ def check_version(self): taos_list = ['server','client'] for i in taos_list: tdSql.query(f'select {i}_version()') - version_info = str(subprocess.run('cat ../../source/util/src/version.c |grep "char version"', shell=True,capture_output=True).stdout.decode('utf8')).split('"')[1] + version_info = str(subprocess.run('cat ../../source/util/src/version.c |grep "char td_version"', shell=True,capture_output=True).stdout.decode('utf8')).split('"')[1] tdSql.checkData(0,0,version_info) def get_server_status(self): diff --git a/tests/taosc_test/CMakeLists.txt b/tests/taosc_test/CMakeLists.txt index 3ea6964462e..c16fe592718 100644 --- a/tests/taosc_test/CMakeLists.txt +++ b/tests/taosc_test/CMakeLists.txt @@ -5,15 +5,15 @@ FIND_PATH(HEADER_GTEST_INCLUDE_DIR gtest.h /usr/include/gtest /usr/local/include FIND_LIBRARY(LIB_GTEST_STATIC_DIR libgtest.a /usr/lib/ /usr/local/lib /usr/lib64 /usr/local/taos/driver/) FIND_LIBRARY(LIB_GTEST_SHARED_DIR libgtest.so /usr/lib/ /usr/local/lib /usr/lib64 /usr/local/taos/driver/) -IF (HEADER_GTEST_INCLUDE_DIR AND (LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) +IF(HEADER_GTEST_INCLUDE_DIR AND(LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) MESSAGE(STATUS "gTest library found, build os test") INCLUDE_DIRECTORIES(${HEADER_GTEST_INCLUDE_DIR}) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) - ENDIF() aux_source_directory(src OS_SRC) + # taoscTest add_executable(taoscTest "taoscTest.cpp") target_link_libraries(taoscTest taos os gtest_main) @@ -25,4 +25,3 @@ add_test( NAME taoscTest COMMAND taoscTest ) - diff --git a/tools/keeper/main.go b/tools/keeper/main.go index 43432bde3d7..5f7d47cb1cf 100644 --- a/tools/keeper/main.go +++ b/tools/keeper/main.go @@ -1,11 +1,8 @@ package main -import ( - "github.com/taosdata/taoskeeper/system" -) +import "github.com/taosdata/taoskeeper/system" func main() { r := system.Init() system.Start(r) - // config.IsEnterprise } diff --git a/tools/keeper/process/empty_test.go b/tools/keeper/process/empty_test.go deleted file mode 100644 index 6718d125255..00000000000 --- a/tools/keeper/process/empty_test.go +++ /dev/null @@ -1,8 +0,0 @@ -package process - -import ( - "testing" -) - -func TestEmpty(t *testing.T) { -} diff --git a/tools/keeper/process/handle_test.go b/tools/keeper/process/handle_test.go new file mode 100644 index 00000000000..bfd5c369b4c --- /dev/null +++ b/tools/keeper/process/handle_test.go @@ -0,0 +1,121 @@ +package process + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_i2string(t *testing.T) { + tests := []struct { + value interface{} + expected string + }{ + {"abc", "abc"}, + {"abcdef", "abcdef"}, + {[]byte{97, 98, 99, 100, 101, 102}, "abcdef"}, + } + + for _, tt := range tests { + res := i2string(tt.value) + assert.Equal(t, tt.expected, res) + } +} + +func Test_i2string_panic(t *testing.T) { + defer func() { + if r := recover(); r == nil { + t.Errorf("Expected panic for unexpected type, but did not panic") + } + }() + + i2string(12345) +} + +func Test_i2float(t *testing.T) { + tests := []struct { + value interface{} + expected float64 + }{ + {int8(1), 1.0}, + {int16(1), 1.0}, + {int32(1), 1.0}, + {int64(1), 1.0}, + {uint8(1), 1.0}, + {uint16(1), 1.0}, + {uint32(1), 1.0}, + {uint64(1), 1.0}, + {float32(1.5), 1.5}, + {float64(1.5), 1.5}, + {true, 1.0}, + {false, 0.0}, + } + + for _, tt := range tests { + res := i2float(tt.value) + assert.Equal(t, tt.expected, res) + } +} + +func Test_i2float_panic(t *testing.T) { + defer func() { + if r := recover(); r == nil { + t.Errorf("Expected panic for unexpected type, but did not panic") + } + }() + + i2float("unexpected type") +} + +func Test_getRoleStr(t *testing.T) { + tests := []struct { + value float64 + expected string + }{ + {0, "offline"}, + {99.5, "follower"}, + {100, "follower"}, + {100.4, "follower"}, + {100.5, "candidate"}, + {101, "candidate"}, + {101.4, "candidate"}, + {101.5, "leader"}, + {102, "leader"}, + {102.4, "leader"}, + {102.5, "error"}, + {103, "error"}, + {104, "learner"}, + {99.4, "unknown"}, + {105, "unknown"}, + {-1, "unknown"}, + {150, "unknown"}, + } + + for _, tt := range tests { + res := getRoleStr(tt.value) + assert.Equal(t, tt.expected, res) + } +} + +func Test_getStatusStr(t *testing.T) { + tests := []struct { + value float64 + expected string + }{ + {-0.4, "offline"}, + {0, "offline"}, + {0.4, "offline"}, + {0.5, "ready"}, + {1, "ready"}, + {1.4, "ready"}, + {1.5, "unknown"}, + {2, "unknown"}, + {-0.5, "unknown"}, + {-1, "unknown"}, + } + + for _, tt := range tests { + res := getStatusStr(tt.value) + assert.Equal(t, tt.expected, res) + } +} diff --git a/tools/keeper/system/program_test.go b/tools/keeper/system/program_test.go index eabc4fff35e..63fbb630141 100644 --- a/tools/keeper/system/program_test.go +++ b/tools/keeper/system/program_test.go @@ -3,15 +3,18 @@ package system import ( "context" "fmt" + "net/http" "testing" + "time" + "github.com/kardianos/service" "github.com/stretchr/testify/assert" "github.com/taosdata/taoskeeper/db" "github.com/taosdata/taoskeeper/infrastructure/config" "github.com/taosdata/taoskeeper/util" ) -func TestStart(t *testing.T) { +func TestInit(t *testing.T) { server := Init() assert.NotNil(t, server) @@ -20,3 +23,23 @@ func TestStart(t *testing.T) { conn.Query(context.Background(), fmt.Sprintf("drop database if exists %s", config.Conf.Metrics.Database.Name), util.GetQidOwn()) conn.Query(context.Background(), fmt.Sprintf("drop database if exists %s", config.Conf.Audit.Database.Name), util.GetQidOwn()) } + +func Test_program(t *testing.T) { + server := &http.Server{} + prg := newProgram(server) + svcConfig := &service.Config{ + Name: "taoskeeper", + DisplayName: "taoskeeper", + Description: "taosKeeper is a tool for TDengine that exports monitoring metrics", + } + svc, err := service.New(prg, svcConfig) + assert.NoError(t, err) + + err = prg.Start(svc) + assert.NoError(t, err) + + time.Sleep(100 * time.Millisecond) + + err = prg.Stop(svc) + assert.NoError(t, err) +} diff --git a/tools/shell/src/shellArguments.c b/tools/shell/src/shellArguments.c index 4638f2ad74b..442329674da 100644 --- a/tools/shell/src/shellArguments.c +++ b/tools/shell/src/shellArguments.c @@ -102,7 +102,7 @@ void shellPrintHelp() { #include #endif -const char *argp_program_version = version; +const char *argp_program_version = td_version; #ifdef CUS_EMAIL const char *argp_program_bug_address = CUS_EMAIL; #else @@ -440,11 +440,11 @@ int32_t shellParseArgs(int32_t argc, char *argv[]) { #ifdef TD_ENTERPRISE snprintf(shell.info.programVersion, sizeof(shell.info.programVersion), "%s\n%s version: %s compatible_version: %s\ngit: %s\ngitOfInternal: %s\nbuild: %s", TD_PRODUCT_NAME, - CUS_PROMPT, version, compatible_version, gitinfo, gitinfoOfInternal, buildinfo); + CUS_PROMPT, td_version, td_compatible_version, td_gitinfo, td_gitinfoOfInternal, td_buildinfo); #else snprintf(shell.info.programVersion, sizeof(shell.info.programVersion), - "%s\n%s version: %s compatible_version: %s\ngit: %s\nbuild: %s", TD_PRODUCT_NAME, CUS_PROMPT, version, - compatible_version, gitinfo, buildinfo); + "%s\n%s version: %s compatible_version: %s\ngit: %s\nbuild: %s", TD_PRODUCT_NAME, CUS_PROMPT, td_version, + td_compatible_version, td_gitinfo, td_buildinfo); #endif #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 50a7fe81196..6d56aa7fe27 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -58,7 +58,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 bool shellGetGrantInfo(char *buf); +static bool shellGetGrantInfo(char* buf); static void shellCleanup(void *arg); static void *shellCancelHandler(void *arg); diff --git a/tools/shell/src/shellNettest.c b/tools/shell/src/shellNettest.c index 2e5ec7bc24b..d1ecf503d24 100644 --- a/tools/shell/src/shellNettest.c +++ b/tools/shell/src/shellNettest.c @@ -34,7 +34,7 @@ static void shellWorkAsClient() { rpcInit.user = "_dnd"; rpcInit.timeToGetConn = tsTimeToGetAvailableConn; - taosVersionStrToInt(version, &(rpcInit.compatibilityVer)); + taosVersionStrToInt(td_version, &rpcInit.compatibilityVer); clientRpc = rpcOpen(&rpcInit); if (clientRpc == NULL) { printf("failed to init net test client since %s\r\n", terrstr()); @@ -125,7 +125,7 @@ static void shellWorkAsServer() { rpcInit.connType = TAOS_CONN_SERVER; rpcInit.idleTime = tsShellActivityTimer * 1000; - taosVersionStrToInt(version, &(rpcInit.compatibilityVer)); + taosVersionStrToInt(td_version, &rpcInit.compatibilityVer); void *serverRpc = rpcOpen(&rpcInit); if (serverRpc == NULL) { diff --git a/utils/test/c/write_raw_block_test.c b/utils/test/c/write_raw_block_test.c index 8ed997bc921..ae4a606e6e6 100644 --- a/utils/test/c/write_raw_block_test.c +++ b/utils/test/c/write_raw_block_test.c @@ -19,196 +19,77 @@ #include "taos.h" #include "types.h" -int buildStable(TAOS* pConn) { - TAOS_RES* pRes = taos_query(pConn, - "CREATE STABLE `meters` (`ts` TIMESTAMP, `current` INT, `voltage` INT, `phase` FLOAT) TAGS " - "(`groupid` INT, `location` VARCHAR(16))"); - if (taos_errno(pRes) != 0) { - printf("failed to create super table meters, reason:%s\n", taos_errstr(pRes)); - return -1; - } +TAOS* pConn = NULL; +void action(char* sql) { + TAOS_RES* pRes = taos_query(pConn, sql); + ASSERT(taos_errno(pRes) == 0); taos_free_result(pRes); - - pRes = taos_query(pConn, "create table d0 using meters tags(1, 'San Francisco')"); - if (taos_errno(pRes) != 0) { - printf("failed to create child table d0, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "insert into d0 (ts, current) values (now, 120)"); - if (taos_errno(pRes) != 0) { - printf("failed to insert into table d0, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create table d1 using meters tags(2, 'San Francisco')"); - if (taos_errno(pRes) != 0) { - printf("failed to create child table d1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create table d2 using meters tags(3, 'San Francisco')"); - if (taos_errno(pRes) != 0) { - printf("failed to create child table d2, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create table ntba(ts timestamp, addr binary(32))"); - if (taos_errno(pRes) != 0) { - printf("failed to create ntba, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create table ntbb(ts timestamp, addr binary(8))"); - if (taos_errno(pRes) != 0) { - printf("failed to create ntbb, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "insert into ntba values(now,'123456789abcdefg123456789')"); - if (taos_errno(pRes) != 0) { - printf("failed to insert table ntba, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "insert into ntba values(now + 1s,'hello')"); - if (taos_errno(pRes) != 0) { - printf("failed to insert table ntba, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - return 0; } -int32_t init_env() { - TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); - if (pConn == NULL) { - return -1; - } - int32_t ret = -1; - - TAOS_RES* pRes = taos_query(pConn, "drop database if exists db_raw"); - if (taos_errno(pRes) != 0) { - printf("error in drop db_taosx, reason:%s\n", taos_errstr(pRes)); - goto END; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create database if not exists db_raw vgroups 2"); - if (taos_errno(pRes) != 0) { - printf("error in create db_taosx, reason:%s\n", taos_errstr(pRes)); - goto END; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "use db_raw"); - if (taos_errno(pRes) != 0) { - printf("error in create db_taosx, reason:%s\n", taos_errstr(pRes)); - goto END; - } - taos_free_result(pRes); - - buildStable(pConn); - - pRes = taos_query(pConn, "select * from d0"); - if (taos_errno(pRes) != 0) { - printf("error in drop db_taosx, reason:%s\n", taos_errstr(pRes)); - goto END; - } - void *data = NULL; +int32_t test_write_raw_block(char* query, char* dst) { + TAOS_RES* pRes = taos_query(pConn, query); + ASSERT(taos_errno(pRes) == 0); + void* data = NULL; int32_t numOfRows = 0; int error_code = taos_fetch_raw_block(pRes, &numOfRows, &data); - if(error_code !=0 ){ - printf("error fetch raw block, reason:%s\n", taos_errstr(pRes)); - goto END; - } - - taos_write_raw_block(pConn, numOfRows, data, "d1"); + ASSERT(error_code == 0); + error_code = taos_write_raw_block(pConn, numOfRows, data, dst); taos_free_result(pRes); + return error_code; +} - pRes = taos_query(pConn, "select ts,phase from d0"); - if (taos_errno(pRes) != 0) { - printf("error in drop db_taosx, reason:%s\n", taos_errstr(pRes)); - goto END; - } - error_code = taos_fetch_raw_block(pRes, &numOfRows, &data); - if(error_code !=0 ){ - printf("error fetch raw block, reason:%s\n", taos_errstr(pRes)); - goto END; - } +int32_t test_write_raw_block_with_fields(char* query, char* dst) { + TAOS_RES* pRes = taos_query(pConn, query); + ASSERT(taos_errno(pRes) == 0); + void* data = NULL; + int32_t numOfRows = 0; + int error_code = taos_fetch_raw_block(pRes, &numOfRows, &data); + ASSERT(error_code == 0); int numFields = taos_num_fields(pRes); - TAOS_FIELD *fields = taos_fetch_fields(pRes); - taos_write_raw_block_with_fields(pConn, numOfRows, data, "d2", fields, numFields); + TAOS_FIELD* fields = taos_fetch_fields(pRes); + error_code = taos_write_raw_block_with_fields(pConn, numOfRows, data, dst, fields, numFields); taos_free_result(pRes); + return error_code; +} - // check error msg - pRes = taos_query(pConn, "select * from ntba"); - if (taos_errno(pRes) != 0) { - printf("error select * from ntba, reason:%s\n", taos_errstr(pRes)); - goto END; - } - - data = NULL; - numOfRows = 0; - error_code = taos_fetch_raw_block(pRes, &numOfRows, &data); - if(error_code !=0 ){ - printf("error fetch select * from ntba, reason:%s\n", taos_errstr(pRes)); - goto END; - } - error_code = taos_write_raw_block(pConn, numOfRows, data, "ntbb"); - if(error_code == 0) { - printf(" taos_write_raw_block to ntbb expect failed , but success!\n"); - goto END; - } - - // pass NULL return last error code describe - const char* err = tmq_err2str(error_code); - printf("write_raw_block return code =0x%x err=%s\n", error_code, err); - if(strcmp(err, "success") == 0) { - printf("expect failed , but error string is success! err=%s\n", err); - goto END; - } - - // no exist table - error_code = taos_write_raw_block(pConn, numOfRows, data, "no-exist-table"); - if(error_code == 0) { - printf(" taos_write_raw_block to no-exist-table expect failed , but success!\n"); - goto END; - } - - err = tmq_err2str(error_code); - printf("write_raw_block no exist table return code =0x%x err=%s\n", error_code, err); - if(strcmp(err, "success") == 0) { - printf("expect failed write no exist table, but error string is success! err=%s\n", err); - goto END; - } - - // success - ret = 0; - -END: - // free - if(pRes) taos_free_result(pRes); - if(pConn) taos_close(pConn); - return ret; +void init_env() { + pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); + ASSERT(pConn); + + action("drop database if exists db_raw"); + action("create database if not exists db_raw vgroups 2"); + action("use db_raw"); + + action( + "CREATE STABLE `meters` (`ts` TIMESTAMP, `current` INT, `voltage` INT, `phase` FLOAT) TAGS (`groupid` INT, " + "`location` VARCHAR(16))"); + action("create table d0 using meters tags(1, 'San Francisco')"); + action("create table d1 using meters tags(2, 'San Francisco')"); + action("create table d2 using meters tags(3, 'San Francisco')"); + action("insert into d0 (ts, current) values (now, 120)"); + + action("create table ntba(ts timestamp, addr binary(32))"); + action("create table ntbb(ts timestamp, addr binary(8))"); + action("create table ntbc(ts timestamp, addr binary(8), c2 int)"); + + action("insert into ntba values(now,'123456789abcdefg123456789')"); + action("insert into ntbb values(now + 1s,'hello')"); + action("insert into ntbc values(now + 13s, 'sdf', 123)"); } int main(int argc, char* argv[]) { - printf("test write_raw_block...\n"); - int ret = init_env(); - if (ret < 0) { - printf("test write_raw_block failed.\n"); - return ret; - } - printf("test write_raw_block ok.\n"); + printf("test write_raw_block start.\n"); + init_env(); + ASSERT(test_write_raw_block("select * from d0", "d1") == 0); // test schema same + ASSERT(test_write_raw_block("select * from ntbb", "ntba") == 0); // test schema compatible + ASSERT(test_write_raw_block("select * from ntbb", "ntbc") == 0); // test schema small + ASSERT(test_write_raw_block("select * from ntbc", "ntbb") == 0); // test schema bigger + ASSERT(test_write_raw_block("select * from ntba", "ntbb") != 0); // test schema mismatch + ASSERT(test_write_raw_block("select * from ntba", "no-exist-table") != 0); // test no exist table + ASSERT(test_write_raw_block("select addr from ntba", "ntbb") != 0); // test without ts + ASSERT(test_write_raw_block_with_fields("select ts,phase from d0", "d2") == 0); // test with fields + + printf("test write_raw_block end.\n"); return 0; } \ No newline at end of file